php if defined DATALIFEENGINE die Hacking attempt if isset lang xfield

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
<?php
if(!defined('DATALIFEENGINE'))
{
die("Hacking attempt!");
}
if(!isset($lang['xfieldupload_file'])) {
$lang['xfieldupload_file'] = 'Загрузить файл';
$lang['xfieldupload_url'] = 'Загрузить URL';
$lang['xfieldupload_err_1'] = 'Hacking attempt!!!';
$lang['xfieldupload_err_3'] = 'Ошибка удаления - файл не найден';
$lang['xfieldupload_err_4'] = 'Доступ запрещён';
$lang['xfieldupload_err_5'] = 'Тип файла запрещён к загрузке';
$lang['xfieldupload_err_6'] = 'Ошибка загрузка файла';
$lang['xfieldupload_err_7'] = 'Достигнут максимум разрешённых файлов к загрузке';
$lang['xfieldupload_err_8'] = 'Размер передаваемых данных слишком большой';
}
if(!isset($lang['att_dcount']))
$lang['att_dcount'] = 'cкачиваний:';
if (!function_exists('xfield_get_option')) {
function xfield_get_option( $field ) {
if ($field[4]!='')
$xfields_upload_option = explode(':',strtolower($field[4]));
$is_xfield_upload = false;
if (count($xfields_upload_option)>0)
if (in_array($xfields_upload_option[0],array('file','video','audio','image')))
$is_xfield_upload = true;
if ($is_xfield_upload) {
$xfield_option = array(
'result'=>$xfields_upload_option[0],
'field'=>$field[0],
'notag'=>false,
'nothumb'=>false,
'urlfile'=>false,
'multiple'=>'',
'multiple_max'=>1,
);
$xfields_upload_option[1] = explode(',',$xfields_upload_option[1]);
foreach($xfields_upload_option[1] as $value) {
if ($xfield_option['result']=='file'and strpos($value,'type=')!==false) {
preg_match('#type=[\'"](.+?)[\'"]#i',$value,$match);
if(isset($match[1]) and $match[1]!='')
$xfield_option['files_type'] = str_replace(';',',',$match[1]);
}else
if ($xfield_option['result']=='image'and strpos($value,'size=')!==false) {
$xfield_option['size'] = str_replace('size=','',$value);
}else
if ($xfield_option['result']=='image'and strpos($value,'nothumb')!==false) {
$xfield_option['nothumb'] = true;
}else
if (strpos($value,'notag')!==false) {
$xfield_option['notag'] = true;
}else
if (strpos($value,'urlfile')!==false) {
$xfield_option['urlfile'] = true;
}else
if (strpos($value,'multiple=')!==false) {
preg_match('#multiple=[\'"](.+?)[\'"]#i',$value,$match);
if(isset($match[1]) and $match[1]!='')
$xfield_option['multiple'] = $match[1];
}else
if (strpos($value,'max=')!==false) {
$xfield_option['multiple_max'] = intval(str_replace('max=','',$value));
}
}
if($xfield_option['notag']){
$xfield_option['multiple'] = '';
$xfield_option['multiple_max'] = 1;
}
return $xfield_option;
}else
return false;
}
function parse_clear_url($url) {
$url = strip_tags( trim( stripslashes( $url ) ) );
$url = str_replace( '\"','"',$url );
$url = str_replace( "'","",$url );
$url = str_replace( '"',"",$url );
$url = str_ireplace( "document.cookie","d&#111;cument.cookie",$url );
$url = str_replace( " ","%20",$url );
$url = str_replace( "<","&#60;",$url );
$url = str_replace( ">","&#62;",$url );
$url = preg_replace( "/javascript:/i","j&#097;vascript:",$url );
$url = preg_replace( "/data:/i","d&#097;ta:",$url );
return $url;
}
function xfieldsGetAttach($ids) {
global $db;
$ids = ((is_array($ids) and count($ids))?implode( ",",array_map('intval',$ids)):$ids);
return $db->super_query( "SELECT id, name, onserver, dcount FROM ".PREFIX ."_files WHERE id IN ({$ids})",true );
}
function xfieldsGetPath($_option,$http=false) {
global $xfields_upload_config,$lang,$config;
if (file_exists(ENGINE_DIR .'/data/xfields.upload.config.php'))
include_once ENGINE_DIR .'/data/xfields.upload.config.php';
$PATH_FTP_ROOT = '';
$PATH_FTP = '';
$PATH_HTTP = '';
$PATH_COPY = '';
if ($_option['result']=='image') {
$PATH_HTTP_ROOT = $config['http_home_url'].'uploads/posts/';
$PATH_FTP = 'uploads/posts/{y}-{m}/';
}else {
$PATH_HTTP_ROOT = $config['http_home_url'].'uploads/noti/';
$PATH_FTP = 'uploads/noti/{y}-{m}/';
}
if (is_array($xfields_upload_config)) {
if (isset($xfields_upload_config['path']['type'][$_option['result']])) {
$PATH_FTP = $xfields_upload_config['path']['type'][$_option['result']]['ftp'];
$PATH_HTTP = $xfields_upload_config['path']['type'][$_option['result']]['http'];
}
if (isset($xfields_upload_config['path']['name'][$_option['field']])) {
$PATH_FTP = $xfields_upload_config['path']['name'][$_option['field']]['ftp'];
$PATH_HTTP = $xfields_upload_config['path']['name'][$_option['field']]['http'];
}
}
if(strpos($PATH_FTP,':/')===false) {
if($PATH_HTTP=='')
$PATH_HTTP = $PATH_FTP;
if(stripos($PATH_FTP,'{root}')==false)
$PATH_FTP = '{root}/'.$PATH_FTP;
if(stripos($PATH_HTTP,'{root}')==false)
$PATH_HTTP = '{root}/'.$PATH_HTTP;
}
$PATH_FTP = str_ireplace('{root}',ROOT_DIR,$PATH_FTP);
$PATH_HTTP= str_ireplace('{root}',$config['http_home_url'],$PATH_HTTP);
$PATH_HTTP= str_replace($config['http_home_url'].'/',$config['http_home_url'],$PATH_HTTP);
$date_str = date('d.m.Y',time());
$date_str = explode('.',$date_str);
if($http){
preg_match_all('#{(.+?)}#i',$PATH_HTTP,$match1,PREG_PATTERN_ORDER);
if(is_array($match1[0]) and count($match1[0])>0){
$match1 = $match1[0];
preg_match('#'.str_ireplace(array('{d}','{m}','{y}'),'(.+?)',$PATH_HTTP).'#i',$http,$match2);
if(is_array($match2) and count($match2)>1){
foreach($match1 as $ii =>$dd){
if(strtolower($dd)=='{d}') $zz = 0;else
if(strtolower($dd)=='{m}') $zz = 1;else
if(strtolower($dd)=='{y}') $zz = 2;else $zz = -1;
if($zz>=0) $date_str[$zz] = $match2[$ii+1];
}
}
}
}
$PATH_FTP = str_ireplace(array('{d}','{m}','{y}'),$date_str,$PATH_FTP);
$PATH_HTTP= str_ireplace(array('{d}','{m}','{y}'),$date_str,$PATH_HTTP);
$PATH_BD = (strpos($PATH_HTTP,$PATH_HTTP_ROOT)!==false?str_replace($PATH_HTTP_ROOT,'',$PATH_HTTP):FALSE);
if ($PATH_FTP!='') {
if( !is_dir( $PATH_FTP ) ) {
@mkdir( $PATH_FTP,0777 ,true);
@chmod( $PATH_FTP,0777 );
if ($_option['result']=='image') {
@mkdir( $PATH_FTP ."/thumbs",0777,true );
@chmod( $PATH_FTP ."/thumbs",0777 );
}
}
if( !is_dir( $PATH_FTP ) ) {
return $lang['upload_error_0'].' '.$PATH_FTP ;
}
}
return array(
'http'=>$PATH_HTTP,
'ftp'=>$PATH_FTP,
'bd'=>$PATH_BD,
);
}
function xfields_set_hash($a){
return base64_encode(serialize(array(
$a,
md5($a.md5(DBHOST.DBNAME.DBUSER.DBPASS))
)));
}
function xfields_get_hash($h){
$a = unserialize(base64_decode($h));
return ((is_array($a) and $a[1]==md5($a[0].md5(DBHOST.DBNAME.DBUSER.DBPASS)))?$a[0]:false);
}
function xfields_get_exists( $field_opt,$field_value) {
global $config,$parse,$tpl,$lang;
if(stripos($field_value,$field_opt['result'])===0)
$field_value='';
if ($field_value=='') return '';
if(!isset($parse)){
include_once ENGINE_DIR .'/classes/parse.class.php';
$parse = new ParseFilter( Array (),Array (),1,1 );
}
$return = '';
if ($field_opt['result']=='file') {
if($field_opt['notag']) {
$return = '<span class="file"><a href="'.$field_value.'">'.basename($field_value).'</a><span class="close" data-hash="'.xfields_set_hash($field_value).'">&times;</span></span>';
}else {
preg_match_all('#\\[attachment=(\d+)\\]#i',$field_value,$match);
if(isset($match[1]) and count($match[1])>0){
$match = xfieldsGetAttach($match[1]);
$return = array();
foreach($match as $row){
$real_path = ROOT_DIR.'/uploads/files/'.$row['onserver'];
$return[] = '<span class="file"><a href="'.$config['http_home_url'].'engine/download.php?id='.$row['id'].'" >'.$row['name'].'</a> ['.formatsize(@filesize($real_path)).'] ('.$lang['att_dcount'].' '.$row['dcount'].')<span class="close" data-hash="'.xfields_set_hash($row['id']).'">&times;</span></span>';
}
}
}
}else
if ($field_opt['result']=='video') {
if($field_opt['notag']) {
$return = '<span class="file">'.$parse->build_video($field_value).'<span class="close" data-hash="'.xfields_set_hash($field_value).'">&times;</span></span>';
}else {
preg_match_all('#\[video\s*=\s*(\S.+?)\s*\]#i',$field_value,$match);
if(isset($match[1]) and count($match[1])>0){
$return = array();
foreach($match[1] as $field_value){
$return[] = '<span class="file">'.$parse->build_video($field_value).'<span class="close" data-hash="'.xfields_set_hash($field_value).'">&times;</span></span>';
}
}
}
}else
if ($field_opt['result']=='audio') {
if($field_opt['notag']) {
$return = '<span class="file">'.$parse->build_audio($field_value).'<span class="close" data-hash="'.xfields_set_hash($field_value).'">&times;</span></span>';
}else {
preg_match_all('#\[audio\s*=\s*(\S.+?)\s*\]#i',$field_value,$match);
if(isset($match[1]) and count($match[1])>0){
$return = array();
foreach($match[1] as $field_value){
$return[] = '<span class="file">'.$parse->build_audio($field_value).'<span class="close" data-hash="'.xfields_set_hash($field_value).'">&times;</span></span>';
}
}
}
}else
if ($field_opt['result']=='image') {
if($field_opt['notag']) {
$return = '<span class="img"><a onclick="return hs.expand(this)" target="_blank" href="'.$field_value.'" ><span><img src="'.$field_value.'"></span></a><span class="close" data-hash="'.xfields_set_hash($field_value).'">&times;</span></span>';
}else {
$matchs = array();
preg_match_all('#\[img(.*?)\](.+?)\[/img\]#i',$field_value,$match);
$matchs = array_merge($matchs,$match[2]);
preg_match_all('#\[thumb(.*?)\](.+?)\[/thumb\]#i',$field_value,$match);
$matchs = array_merge($matchs,$match[2]);
if(isset($matchs) and count($matchs)>0){
$return = array();
foreach($matchs as $field_value){
$real_name = basename($field_value);
if (@file_exists(str_replace($real_name,'thumbs/'.$real_name,$field_value)))
$image_thumb = str_replace($real_name,'thumbs/'.$real_name,$field_value);
else
$image_thumb = $field_value;
$return[] = '<span class="img"><a onclick="return hs.expand(this)" target="_blank" href="'.$image_thumb.'" ><span><img src="'.$field_value.'"></span></a><span class="close" data-hash="'.xfields_set_hash($field_value).'">&times;</span></span>';
}
}
}
}
return $return;
}
}
if ($xfields_upload_action=='view'and is_array($xfields_upload_field)) {
if (is_array($row))
$newsid = intval($row['id']);
else
$newsid = 0;
$n0xf_option = xfield_get_option($xfields_upload_field);
if (!$n0xf_option)
$is_xfields_upload = false;
else {
$is_xfields_upload = true;
if (strpos($ajax,"jquery.xf.upload.js")===false) {
$ajax .= '<link media="screen" href="'.$config['http_home_url'].'engine/classes/js/jquery.xf.upload.css" type="text/css" rel="stylesheet" />';
$dle_xfupload_root = $config['http_home_url'];
if(strpos($_SERVER['HTTP_HOST'],'www')===false and strpos($dle_xfupload_root,'www')!==false){
$dle_xfupload_root = str_ireplace('http://www.','http://',$dle_xfupload_root);
}else
if(strpos($_SERVER['HTTP_HOST'],'www')!==false and strpos($dle_xfupload_root,'www')===false){
$dle_xfupload_root = str_ireplace('http://','http://www.',$dle_xfupload_root);
}
$ajax .= '<script language="javascript" type="text/javascript">var dle_xfuplinpvw=\''.(function_exists('echoheader')?'1':'0').'\',dle_xfupload_author=\''.$member_id['name'].'\',dle_xfupload_newsid=\''.$newsid.'\',dle_xfupload_root=\''.$dle_xfupload_root.'engine/ajax/xfields.upload.php\';</script>';
$ajax .= '<script type="text/javascript" src="'.$config['http_home_url'].'engine/classes/js/jquery.xf.upload.js"></script>';
if (function_exists('echoheader'))
print($ajax );
}
$xfields_upload_value = str_replace('&quot;','"',$xfields_upload_value);
$xfields_upload_value = str_replace('&amp;','&',$xfields_upload_value);
if($xfields_upload_value==$xfields_upload_field[4])
$xfields_upload_value='';
$n0xf_files = xfields_get_exists($n0xf_option,$xfields_upload_value);
$n0xf_isHideAct = false;
$n0xf_filesCount = 0;
if(is_array($n0xf_files)){
$n0xf_filesCount = count($n0xf_files);
$n0xf_files = implode('',$n0xf_files);
}else
if($n0xf_files!='')
$n0xf_filesCount = 1;
if(function_exists('dle_session'))
@dle_session();
else
@session_start();
$_SESSION['n0xfuploas'][$n0xf_option['field']] = $n0xf_filesCount;
$n0xf_isMultiple = ($n0xf_option['multiple']!=''or $n0xf_option['multiple_max']>0);
$n0xf_isShowAct = (($n0xf_filesCount<1) or ($n0xf_isMultiple and ($n0xf_option['multiple_max']==0 or $n0xf_option['multiple_max']>$n0xf_filesCount)));
$lang['_xf_not_notig'] = ($lang['xf_not_notig']!=''?'('.$lang['xf_not_notig'].')':'');
$lang['_xf_notig'] = ($lang['xf_notig']!=''?'('.$lang['xf_notig'].')':'');
$n0xf_output = str_replace(array("\r\n","\t"),'','
<div class="n0upload" data-field="'.$n0xf_option['field'].'" data-multiple="'.($n0xf_isMultiple?'1':'0').'">
<div class="n0fileContent">
<div class="n0uploadProgress" style="display:none"><div class="bar"></div></div>
<div class="n0uploadList">'.$n0xf_files.'</div>
<span class="clearfix"></span>
<div class="n0uploadAct"'.($n0xf_isShowAct?'':' style="display:none"').'>
<div class="n0uploadFile">'.$lang['xfieldupload_file'].'</div>'.($n0xf_option['urlfile']?'<div class="n0uploadUrl">'.$lang['xfieldupload_url'].'</div>':'').'
[if-optional]'.$lang['xf_not_notig'].'[/if-optional][not-optional]'.$lang['_xf_notig'].'[/not-optional]
</div>
<div class="n0uploadEdit"><input style="width:437px;" rel="essential" class="n0field" type="'.(function_exists('echoheader')?'text':'hidden').'" name="xfield['.$n0xf_option['field'].']" value="'.$xfields_upload_value.'" /></div>
</div>
</div><!--hs.expand-->
');
if(strpos($n0xf_output,'{THEME}')!==false)
$n0xf_output = str_ireplace('{THEME}',$config['http_home_url'].'templates/'.$config['skin'],$n0xf_output);
$output .= "<tr id=\"{$holderid}\" {$uid}>
<td class=addnews>{$value[1]}:</td>
<td class=xfields colspan=\"2\">{$n0xf_output}</td>
</tr>";
}
}