вопрос
Всем привет! Нужно отредактировать модуль, все работает, но нужно подключить библиотеку getid3, код рабочий но при интеграции в этот модуль, крашится выдавая подобное:
{"content":"×","allowed_upload":"1","field_value":"[audiо=http://localhost/uploads/files/1455102385_garmiani-bomb-a-drop-original-mix.mp3]","filed_delimiter":""}
Глюки начинаются когда просто анализирую файл без использования. Буду очень признателен за помощь, весь мозг вынес себе.
{"content":"×","allowed_upload":"1","field_value":"[audiо=http://localhost/uploads/files/1455102385_garmiani-bomb-a-drop-original-mix.mp3]","filed_delimiter":""}
Глюки начинаются когда просто анализирую файл без использования. Буду очень признателен за помощь, весь мозг вынес себе.
include_once ENGINE_DIR . '/modules/mediatags/getid3.php';
$mp3 = new getID3();
$array = $mp3->analyze("uploads/$new_name");
$track_title = $array['id3v2']['comments']['title'][0];
$track_artist = $array['id3v2']['comments']['artist'][0];
$track_album = $array['tags']['id3v2']['album'][0];
$track_year = $array['tags']['id3v2']['year'][0];
$track_genre = $array['tags']['id3v2']['genre'][0];
$track_bitrate = $array['bitrate'];
$track_time = $array['playtime_string'];
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","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/files/';
$PATH_FTP = 'uploads/files/';
}
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,$audiofile;
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).'">×</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']).'">×</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).'">×</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).'">×</span></span>';
}
}
}
}else
if ($field_opt['result']=='audio') {
if($field_opt['notag']) {
$return = '<span class="file">'.$parse->build_uppod($field_value).'<span class="close" data-hash="'.xfields_set_hash($field_value).'">×</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_uppod($field_value).'<span class="close" data-hash="'.xfields_set_hash($field_value).'">×</span></span>';
}
}
}
}else
if ($field_opt['result']=='image') {
if($field_opt['notag']) {
$return = '<span class="img"><a class="highslide" onclick="return hs.expand(this)" target="_blank" href="'.$field_value.'" ><img src="'.$field_value.'"></a><span class="close" data-hash="'.xfields_set_hash($field_value).'">×</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 class="highslide" onclick="return hs.expand(this)" target="_blank" href="'.$image_thumb.'" ><img src="'.$field_value.'"></a><span class="close" data-hash="'.xfields_set_hash($field_value).'">×</span></span>';
}
}
}
}
return $return;
}
}