вопрос
Здравствуйте, очень нужно выковырить код тега custom из DLE 9.7, чтобы была возможность написания id.
Код на DLE 9.7
Вписываю этот код на 9.3 (при этом полностью меняю show.custom и меняю значение в index.php
На 9.3
Т.е. заменяю его и выходит вод такая вод ошибка!!! Что сделать, что поменять в чем причина, помогите настроить!!!
Код на DLE 9.7
function custom_print( $matches=array() ) {
global $db, $is_logged, $member_id, $xf_inited, $cat_info, $config, $user_group, $category_id, $_TIME, $lang, $smartphone_detected, $dle_module, $allow_comments_ajax, $PHP_SELF;
if ( !count($matches) ) return "";
$param_str = trim($matches[1]);
$aviable = array();
$thisdate = date( "Y-m-d H:i:s", (time() + $config['date_adjust'] * 60) );
$sql_select = "SELECT p.id, p.autor, p.date, p.short_story, CHAR_LENGTH(p.full_story) as full_story, p.xfields, p.title, p.category, p.alt_name, p.comm_num, p.allow_comm, p.fixed, p.tags, e.news_read, e.allow_rate, e.rating, e.vote_num, e.votes, e.view_edit, e.editdate, e.editor, e.reason FROM " . PREFIX . "_post p LEFT JOIN " . PREFIX . "_post_extras e ON (p.id=e.news_id)";
$where = array();
$allow_cache = $config['allow_cache'];
if( preg_match( "#aviable=['\"](.+?)['\"]#i", $param_str, $match ) ) {
$aviable = explode( '|', $match[1] );
} else $aviable[] = "global";
$do = $dle_module ? $dle_module : "main";
if( ! (in_array( $do, $aviable )) and ($aviable[0] != "global") ) return "";
if( preg_match( "#id=['\"](.+?)['\"]#i", $param_str, $match ) ) {
$custom_id = str_replace( ',', "','", $db->safesql( trim($match[1]) ) );
$where[] = "id IN ('" . $custom_id . "')";
}
$allow_list = explode( ',', $user_group[$member_id['user_group']]['allow_cats'] );
if( $allow_list[0] != "all" AND !$user_group[$member_id['user_group']]['allow_short'] ) {
if( $config['allow_multi_category'] ) {
$where[] = "category regexp '[[:<:]](" . implode( '|', $allow_list ) . ")[[:>:]]'";
} else {
$where[] = "category IN ('" . implode( "','", $allow_list ) . "')";
}
}
if( preg_match( "#category=['\"](.+?)['\"]#i", $param_str, $match ) ) {
$custom_category = $db->safesql( trim(str_replace( ',', '|', $match[1] )) );
if( $config['allow_multi_category'] ) {
$where[] = "category regexp '[[:<:]](" . $custom_category . ")[[:>:]]'";
} else {
$custom_category = str_replace( "|", "','", $custom_category );
$where[] = "category IN ('" . $custom_category . "')";
}
}
$where[] = "approve=1";
if( $config['no_date'] AND !$config['news_future'] ) $where[] = "date < '" . $thisdate . "'";
if( preg_match( "#template=['\"](.+?)['\"]#i", $param_str, $match ) ) {
$custom_template = trim($match[1]);
} else $custom_template = "shortstory";
if( preg_match( "#from=['\"](.+?)['\"]#i", $param_str, $match ) ) {
$custom_from = intval($match[1]);
} else $custom_from = 0;
if( preg_match( "#limit=['\"](.+?)['\"]#i", $param_str, $match ) ) {
$custom_limit = intval($match[1]);
} else $custom_limit = $config['news_number'];
if( preg_match( "#cache=['\"](.+?)['\"]#i", $param_str, $match ) ) {
if( $match[1] == "yes" ) $config['allow_cache'] = "yes";
else $config['allow_cache'] = false;
}
if( $is_logged and ($user_group[$member_id['user_group']]['allow_edit'] and ! $user_group[$member_id['user_group']]['allow_all_edit']) ) $config['allow_cache'] = false;
if( $cat_info[$custom_category]['news_sort'] != "" ) $news_sort = $cat_info[$custom_category]['news_sort']; else $news_sort = $config['news_sort'];
if( $cat_info[$custom_category]['news_msort'] != "" ) $news_msort = $cat_info[$custom_category]['news_msort']; else $news_msort = $config['news_msort'];
if ($config['allow_fixed']) $fixed = "fixed DESC, "; else $fixed = "";
if( preg_match( "#order=['\"](.+?)['\"]#i", $param_str, $match ) ) {
$allowed_sort = array ('date' => 'date', 'rating' => 'rating', 'reads' => 'news_read', 'comments' => 'comm_num','title' => 'title', 'rand' => 'RAND()' );
if ( $allowed_sort[$match[1]] ) $news_sort = $allowed_sort[$match[1]];
if ($match[1] == "rand" ) { $fixed = ""; $news_msort = ""; } else $news_msort = "DESC";
if ($match[1] == "title" ) $news_msort = "ASC";
}
$sql_select .= " WHERE ".implode(' AND ', $where)." ORDER BY " . $fixed . $news_sort . " " . $news_msort . " LIMIT " . $custom_from . "," . $custom_limit;
$custom_cache_id = $custom_id.$custom_category.$user_group[$member_id['user_group']]['allow_cats'].$custom_from.$custom_limit.$news_sort.$news_msort;
$content = dle_cache( "news", $custom_cache_id, true );
if( $content !== false ) {
$config['allow_cache'] = $allow_cache;
return $content;
} else {
$tpl = new dle_template();
$tpl->dir = TEMPLATE_DIR;
include (ENGINE_DIR . '/modules/show.custom.php');
if( $config['files_allow'] == "yes" ) if( strpos( $tpl->result['content'], "[attachment=" ) !== false ) {
$tpl->result['content'] = show_attach( $tpl->result['content'], $attachments );
}
create_cache( "news", $tpl->result['content'], $custom_cache_id, true );
$config['allow_cache'] = $allow_cache;
return $tpl->result['content'];
}
}
Вписываю этот код на 9.3 (при этом полностью меняю show.custom и меняю значение в index.php
На 9.3
function custom_print( $matches=array() ) {
global $db, $is_logged, $member_id, $xf_inited, $cat_info, $config, $user_group, $category_id, $_TIME, $lang, $smartphone_detected, $dle_module, $allow_comments_ajax, $PHP_SELF;
if ( !count($matches) ) return "";
$param_str = trim($matches[1]);
$aviable = array();
$thisdate = date( "Y-m-d H:i:s", (time() + $config['date_adjust'] * 60) );
$where = array();
$allow_cache = $config['allow_cache'];
if( preg_match( "#aviable=['\"](.+?)['\"]#i", $param_str, $match ) ) {
$aviable = explode( '|', $match[1] );
} else $aviable[] = "global";
$do = $dle_module ? $dle_module : "main";
if( ! (in_array( $do, $aviable )) and ($aviable[0] != "global") ) return "";
if( preg_match( "#id=['\"](.+?)['\"]#i", $param_str, $match ) ) {
$custom_id = str_replace( ',', "','", $db->safesql( trim($match[1]) ) );
$where[] = "id IN ('" . $custom_id . "')";
}
$allow_list = explode( ',', $user_group[$member_id['user_group']]['allow_cats'] );
if( $allow_list[0] != "all" AND !$user_group[$member_id['user_group']]['allow_short'] ) {
if( $config['allow_multi_category'] ) {
$where[] = "category regexp '[[:<:]](" . implode( '|', $allow_list ) . ")[[:>:]]'";
} else {
$where[] = "category IN ('" . implode( "','", $allow_list ) . "')";
}
}
if( preg_match( "#category=['\"](.+?)['\"]#i", $param_str, $match ) ) {
$custom_category = $db->safesql( trim(str_replace( ',', '|', $match[1] )) );
if( $config['allow_multi_category'] ) {
$where[] = "category regexp '[[:<:]](" . $custom_category . ")[[:>:]]'";
} else {
$custom_category = str_replace( "|", "','", $custom_category );
$where[] = "category IN ('" . $custom_category . "')";
}
}
$where[] = "approve=1";
if( $config['no_date'] AND !$config['news_future'] ) $where[] = "date < '" . $thisdate . "'";
if( preg_match( "#template=['\"](.+?)['\"]#i", $param_str, $match ) ) {
$custom_template = trim($match[1]);
} else $custom_template = "shortstory";
if( preg_match( "#from=['\"](.+?)['\"]#i", $param_str, $match ) ) {
$custom_from = intval($match[1]);
} else $custom_from = 0;
if( preg_match( "#limit=['\"](.+?)['\"]#i", $param_str, $match ) ) {
$custom_limit = intval($match[1]);
} else $custom_limit = $config['news_number'];
if( preg_match( "#cache=['\"](.+?)['\"]#i", $param_str, $match ) ) {
if( $match[1] == "yes" ) $config['allow_cache'] = "yes";
else $config['allow_cache'] = false;
}
if( $is_logged and ($user_group[$member_id['user_group']]['allow_edit'] and ! $user_group[$member_id['user_group']]['allow_all_edit']) ) $config['allow_cache'] = false;
if( $cat_info[$custom_category]['news_sort'] != "" ) $news_sort = $cat_info[$custom_category]['news_sort']; else $news_sort = $config['news_sort'];
if( $cat_info[$custom_category]['news_msort'] != "" ) $news_msort = $cat_info[$custom_category]['news_msort']; else $news_msort = $config['news_msort'];
if ($config['allow_fixed']) $fixed = "fixed DESC, "; else $fixed = "";
if( preg_match( "#order=['\"](.+?)['\"]#i", $param_str, $match ) ) {
$allowed_sort = array ('date' => 'date', 'rating' => 'rating', 'reads' => 'news_read', 'comments' => 'comm_num','title' => 'title', 'rand' => 'RAND()' );
if ( $allowed_sort[$match[1]] ) $news_sort = $allowed_sort[$match[1]];
if ($match[1] == "rand" ) { $fixed = ""; $news_msort = ""; } else $news_msort = "DESC";
if ($match[1] == "title" ) $news_msort = "ASC";
}
$sql_select .= " WHERE ".implode(' AND ', $where)." ORDER BY " . $fixed . $news_sort . " " . $news_msort . " LIMIT " . $custom_from . "," . $custom_limit;
$custom_cache_id = $custom_id.$custom_category.$user_group[$member_id['user_group']]['allow_cats'].$custom_from.$custom_limit.$news_sort.$news_msort;
$content = dle_cache( "news", $custom_cache_id, true );
if( $content !== false ) {
$config['allow_cache'] = $allow_cache;
return $content;
} else {
$tpl = new dle_template();
$tpl->dir = TEMPLATE_DIR;
include (ENGINE_DIR . '/modules/show.custom.php');
if( $config['files_allow'] == "yes" ) if( strpos( $tpl->result['content'], "[attachment=" ) !== false ) {
$tpl->result['content'] = show_attach( $tpl->result['content'], $attachments );
}
create_cache( "news", $tpl->result['content'], $custom_cache_id, true );
$config['allow_cache'] = $allow_cache;
return $tpl->result['content'];
}
}
Т.е. заменяю его и выходит вод такая вод ошибка!!! Что сделать, что поменять в чем причина, помогите настроить!!!