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","document.cookie",$url ); $url = str_replace( " ","%20",$url ); $url = str_replace( "<","<",$url ); $url = str_replace( ">",">",$url ); $url = preg_replace( "/javascript:/i","javascript:",$url ); $url = preg_replace( "/data:/i","data:",$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 = ''.basename($field_value).'×'; }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[] = ''.$row['name'].' ['.formatsize(@filesize($real_path)).'] ('.$lang['att_dcount'].' '.$row['dcount'].')×'; } } } }else if ($field_opt['result']=='video') { if($field_opt['notag']) { $return = ''.$parse->build_video($field_value).'×'; }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[] = ''.$parse->build_video($field_value).'×'; } } } }else if ($field_opt['result']=='audio') { if($field_opt['notag']) { $return = ''.$parse->build_audio($field_value).'×'; }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[] = ''.$parse->build_audio($field_value).'×'; } } } }else if ($field_opt['result']=='image') { if($field_opt['notag']) { $return = '×'; }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[] = '×'; } } } } 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 .= ''; $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 .= ''; $ajax .= ''; if (function_exists('echoheader')) print($ajax ); } $xfields_upload_value = str_replace('"','"',$xfields_upload_value); $xfields_upload_value = str_replace('&','&',$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"),'','
'.$n0xf_files.'
'); if(strpos($n0xf_output,'{THEME}')!==false) $n0xf_output = str_ireplace('{THEME}',$config['http_home_url'].'templates/'.$config['skin'],$n0xf_output); $output .= " {$value[1]}: {$n0xf_output} "; } }