$allow_comments = $row['allow_comm']; $allow_add = true; if ($config['max_comments_days']) { if ($row['date'] < $_TIME - $config['max_comments_days'] * 3600 * 24) { $allow_add = false; } } if ($view_template) { $allow_comments = false; } } $tpl->clear(); unset($row); if ($config['files_allow']) { if (strpos($tpl->result['content'], "[attachment=") !== false) { $tpl->result['content'] = show_attach($tpl->result['content'], $news_id); } } if (!$news_found and !$perm) { msgbox($lang['all_err_1'], "<b>{$user_group[$member_id['user_group']]['group_name']}</b> " . $lang['news_err_28']); } elseif (!$news_found) { @header("HTTP/1.0 404 Not Found"); msgbox($lang['all_err_1'], $lang['news_err_12']); } //#################################################################################################################### // Просмотр комментариев //#################################################################################################################### if ($allow_comments and $news_found) { if ($comments_num > 0) { include_once ENGINE_DIR . '/classes/comments.class.php'; $comments = new DLE_Comments($db, $comments_num, intval($config['comm_nummers']));
$tpl->set('{ACCEPT-DECLINE}', "<form method=\"post\" name=\"registration\" id=\"registration\" action=\"\"><input type=\"submit\" class=\"bbcodes\" value=\"{$lang['rules_accept']}\" /> <input type=\"button\" class=\"bbcodes\" value=\"{$lang['rules_decline']}\" onclick=\"history.go(-1); return false;\" /><input name=\"do\" type=\"hidden\" id=\"do\" value=\"register\" /><input name=\"dle_rules_accept\" type=\"hidden\" id=\"dle_rules_accept\" value=\"yes\" /></form>"); } } $tpl->compile('content'); $tpl->clear(); } else { $tpl->result['content'] = $template; } if ($user_group[$member_id['user_group']]['allow_hide']) { $tpl->result['content'] = str_replace("[hide]", "", str_replace("[/hide]", "", $tpl->result['content'])); } else { $tpl->result['content'] = preg_replace("#\\[hide\\](.+?)\\[/hide\\]#is", "<div class=\"quote\">" . $lang['news_regus'] . "</div>", $tpl->result['content']); } if ($config['files_allow'] == "yes") { if (strpos($tpl->result['content'], "[attachment=") !== false) { $tpl->result['content'] = show_attach($tpl->result['content'], $static_result['id'], true); } } if ($config['rss_informer'] and count($informers)) { foreach ($informers as $name => $value) { $tpl->result['content'] = str_replace("{inform_" . $name . "}", $value, $tpl->result['content']); } } if (stripos($tpl->result['content'], "[static=") !== false) { $tpl->result['content'] = preg_replace_callback("#\\[(static)=(.+?)\\](.*?)\\[/static\\]#is", "check_static", $tpl->result['content']); } if (stripos($tpl->result['content'], "[not-static=") !== false) { $tpl->result['content'] = preg_replace_callback("#\\[(not-static)=(.+?)\\](.*?)\\[/not-static\\]#is", "check_static", $tpl->result['content']); } if ($config['allow_banner']) { include_once ENGINE_DIR . '/modules/banners.php';
$tpl->set('[/searchcomments]', "</div>"); } else { // Для вывода статей $tpl->set_block("'\\[searchcomments\\].*?\\[/searchcomments\\]'si", ""); $tpl->set('[searchposts]', ""); $tpl->set('[/searchposts]', ""); } $tpl->compile('content'); if ($user_group[$member_id['user_group']]['allow_hide']) { $tpl->result['content'] = str_replace("[hide]", "", str_replace("[/hide]", "", $tpl->result['content'])); } else { $tpl->result['content'] = preg_replace("#\\[hide\\](.+?)\\[/hide\\]#is", "<div class=\"quote\">" . $lang['news_regus'] . "</div>", $tpl->result['content']); } if ($config['files_allow'] == "yes") { if (strpos($tpl->result['content'], "[attachment=") !== false) { $tpl->result['content'] = show_attach($tpl->result['content'], $attachments); } } } // Результаты поиска в статьях и комментариях } // while $tpl->clear(); $db->free($sql_result); } } } $tpl->clear(); //#################################################################################################################### // Навигация по новостям //####################################################################################################################
function custom_print($custom_category, $custom_template, $aviable, $custom_from, $custom_limit, $custom_cache, $do) { global $db, $is_logged, $member_id, $xf_inited, $cat_info, $config, $user_group, $category_id, $_TIME, $lang, $smartphone_detected, $dle_module, $PHP_SELF; $do = $do ? $do : "main"; $aviable = explode('|', $aviable); if (!in_array($do, $aviable) and $aviable[0] != "global") { return ""; } $custom_category = $db->safesql(str_replace(',', '|', $custom_category)); $custom_from = intval($custom_from); $custom_limit = intval($custom_limit); $thisdate = date("Y-m-d H:i:s", time() + $config['date_adjust'] * 60); if ($config['no_date'] and !$config['news_future']) { $where_date = " AND date < '" . $thisdate . "'"; } else { $where_date = ""; } $tpl = new dle_template(); $tpl->dir = TEMPLATE_DIR; if ($custom_cache == "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; } $custom_cache_id = "custom_cat_" . $custom_category . "template_" . $custom_template . "from_" . $custom_from . "limit_" . $custom_limit; $content = dle_cache("news", $custom_cache_id, true); if ($content) { return $content; } else { $allow_list = explode(',', $user_group[$member_id['user_group']]['allow_cats']); if ($allow_list[0] != "all") { if ($config['allow_multi_category']) { $stop_list = "category regexp '[[:<:]](" . implode('|', $allow_list) . ")[[:>:]]' AND "; } else { $stop_list = "category IN ('" . implode("','", $allow_list) . "') AND "; } } else { $stop_list = ""; } if ($user_group[$member_id['user_group']]['allow_short']) { $stop_list = ""; } 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_multi_category']) { $where_category = "category regexp '[[:<:]](" . $custom_category . ")[[:>:]]'"; } else { $custom_category = str_replace("|", "','", $custom_category); $where_category = "category IN ('" . $custom_category . "')"; } if ($config['allow_fixed']) { $fixed = "fixed desc, "; } else { $fixed = ""; } $sql_select = "SELECT p.id, p.autor, p.date, p.short_story, SUBSTRING(p.full_story, 1, 15) 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 " . $stop_list . $where_category . " AND approve=1" . $where_date . " ORDER BY " . $fixed . $news_sort . " " . $news_msort . " LIMIT " . $custom_from . "," . $custom_limit; 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); } return $tpl->result['content']; }
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, $news_date; if (!count($matches)) { return ""; } $param_str = trim($matches[1]); $aviable = array(); $thisdate = date("Y-m-d H:i:s", $_TIME); $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)) { $temp_array = array(); $where_id = array(); $match[1] = explode(',', trim($match[1])); foreach ($match[1] as $value) { if (count(explode('-', $value)) == 2) { $value = explode('-', $value); $where_id[] = "id >= '" . intval($value[0]) . "' AND id <= '" . intval($value[1]) . "'"; } else { $temp_array[] = intval($value); } } if (count($temp_array)) { $where_id[] = "id IN ('" . implode("','", $temp_array) . "')"; } if (count($where_id)) { $custom_id = implode(' OR ', $where_id); $where[] = $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)) { $temp_array = array(); $match[1] = explode(',', $match[1]); foreach ($match[1] as $value) { if (count(explode('-', $value)) == 2) { $temp_array[] = get_mass_cats($value); } else { $temp_array[] = intval($value); } } $temp_array = implode(',', $temp_array); $custom_category = $db->safesql(trim(str_replace(',', '|', $temp_array))); if ($config['allow_multi_category']) { $where[] = "category regexp '[[:<:]](" . $custom_category . ")[[:>:]]'"; } else { $custom_category = str_replace("|", "','", $custom_category); $where[] = "category IN ('" . $custom_category . "')"; } } if (preg_match("#days=['\"](.+?)['\"]#i", $param_str, $match)) { $days = intval(trim($match[1])); $where[] = "p.date >= '{$thisdate}' - INTERVAL {$days} DAY AND p.date < '{$thisdate}'"; } else { $days = 0; } if (preg_match("#author=['\"](.+?)['\"]#i", $param_str, $match)) { $author = $db->safesql(trim($match[1])); $where[] = "p.autor like '{$author}'"; } else { $author = ""; } $where[] = "approve=1"; if ($config['no_date'] and !$config['news_future'] and !$days) { $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 (preg_match("#fixed=['\"](.+?)['\"]#i", $param_str, $match)) { $fixed = ""; $fixedcache = "fixed yes"; if ($match[1] == "yes") { $fixed = "fixed DESC, "; } elseif ($match[1] == "only") { $where[] = "fixed='1'"; $fixedcache = "fixed only"; } } else { $fixed = ""; $fixedcache = ""; } 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 (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 . $custom_template . $days . $author . $fixedcache; $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; $tpl->load_template($custom_template . '.tpl'); $sql_result = $db->query($sql_select); 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']; } }
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, $news_date, $banners, $banner_in_news, $url_page, $user_query, $custom_news, $global_news_count; if (!count($matches)) { return ""; } $param_str = trim($matches[1]); $aviable = array("global"); $thisdate = date("Y-m-d H:i:s", $_TIME); $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]); } if (preg_match("#available=['\"](.+?)['\"]#i", $param_str, $match)) { $aviable = explode('|', $match[1]); } $do = $dle_module ? $dle_module : "main"; if (!in_array($do, $aviable) and $aviable[0] != "global") { return ""; } if (preg_match("#id=['\"](.+?)['\"]#i", $param_str, $match)) { $temp_array = array(); $where_id = array(); $match[1] = explode(',', trim($match[1])); foreach ($match[1] as $value) { if (count(explode('-', $value)) == 2) { $value = explode('-', $value); $where_id[] = "id >= '" . intval($value[0]) . "' AND id <= '" . intval($value[1]) . "'"; } else { $temp_array[] = intval($value); } } if (count($temp_array)) { $where_id[] = "id IN ('" . implode("','", $temp_array) . "')"; } if (count($where_id)) { $custom_id = implode(' OR ', $where_id); $where[] = $custom_id; } } if (preg_match("#tags=['\"](.+?)['\"]#i", $param_str, $match)) { $temp_array = array(); $tagscache = $match[1]; $match[1] = explode(',', trim($match[1])); foreach ($match[1] as $value) { $value = $db->safesql(trim($value)); if ($value) { $temp_array[] = "tag='{$value}'"; } } if (count($temp_array)) { $temp_array = implode(" OR ", $temp_array); $db->query("SELECT news_id FROM " . PREFIX . "_tags WHERE {$temp_array}"); $temp_array = array(); while ($row = $db->get_row()) { if (!in_array($row['news_id'], $temp_array)) { $temp_array[] = $row['news_id']; } } if (count($temp_array)) { $where[] = "id IN ('" . implode("','", $temp_array) . "')"; } else { $where[] = "id IN ('0')"; } } } else { $tagscache = ""; } if (preg_match("#idexclude=['\"](.+?)['\"]#i", $param_str, $match)) { $temp_array = array(); $where_id = array(); $match[1] = explode(',', trim($match[1])); foreach ($match[1] as $value) { if (count(explode('-', $value)) == 2) { $value = explode('-', $value); $where_id[] = "(id < '" . intval($value[0]) . "' OR id > '" . intval($value[1]) . "')"; } else { $temp_array[] = intval($value); } } if (count($temp_array)) { $where_id[] = "id NOT IN ('" . implode("','", $temp_array) . "')"; } if (count($where_id)) { $custom_id = implode(' AND ', $where_id); $where[] = $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)) { $temp_array = array(); $match[1] = explode(',', $match[1]); foreach ($match[1] as $value) { if (count(explode('-', $value)) == 2) { $temp_array[] = get_mass_cats($value); } else { $temp_array[] = intval($value); } } $temp_array = implode(',', $temp_array); $custom_category = $db->safesql(trim(str_replace(',', '|', $temp_array))); if ($config['allow_multi_category']) { $where[] = "category regexp '[[:<:]](" . $custom_category . ")[[:>:]]'"; } else { $custom_category = str_replace("|", "','", $custom_category); $where[] = "category IN ('" . $custom_category . "')"; } } if (preg_match("#categoryexclude=['\"](.+?)['\"]#i", $param_str, $match)) { $temp_array = array(); $match[1] = explode(',', $match[1]); foreach ($match[1] as $value) { if (count(explode('-', $value)) == 2) { $temp_array[] = get_mass_cats($value); } else { $temp_array[] = intval($value); } } $temp_array = implode(',', $temp_array); $custom_category = $db->safesql(trim(str_replace(',', '|', $temp_array))); if ($config['allow_multi_category']) { $where[] = "category NOT REGEXP '[[:<:]](" . $custom_category . ")[[:>:]]'"; } else { $custom_category = str_replace("|", "','", $custom_category); $where[] = "category NOT IN ('" . $custom_category . "')"; } } if (preg_match("#days=['\"](.+?)['\"]#i", $param_str, $match)) { $days = intval(trim($match[1])); $where[] = "p.date >= '{$thisdate}' - INTERVAL {$days} DAY AND p.date < '{$thisdate}'"; } else { $days = 0; } if (preg_match("#author=['\"](.+?)['\"]#i", $param_str, $match)) { $author = $match[1]; $match[1] = explode(',', $match[1]); $temp_array = array(); foreach ($match[1] as $value) { $value = $db->safesql(trim($value)); $temp_array[] = "p.autor = '{$value}'"; } $where[] = implode(' OR ', $temp_array); } else { $author = ""; } if (preg_match("#authorexclude=['\"](.+?)['\"]#i", $param_str, $match)) { $author = $match[1]; $match[1] = explode(',', $match[1]); $temp_array = array(); foreach ($match[1] as $value) { $value = $db->safesql(trim($value)); $temp_array[] = "p.autor != '{$value}'"; } $where[] = implode(' AND ', $temp_array); } else { $author = ""; } if (preg_match("#catalog=['\"](.+?)['\"]#i", $param_str, $match)) { $catalog = $match[1]; $match[1] = explode(',', $match[1]); $temp_array = array(); foreach ($match[1] as $value) { $value = $db->safesql(trim($value)); $temp_array[] = "p.symbol = '{$value}'"; } $where[] = implode(' OR ', $temp_array); } else { $catalog = ""; } if (preg_match("#catalogexclude=['\"](.+?)['\"]#i", $param_str, $match)) { $catalog = $match[1]; $match[1] = explode(',', $match[1]); $temp_array = array(); foreach ($match[1] as $value) { $value = $db->safesql(trim($value)); $temp_array[] = "p.symbol != '{$value}'"; } $where[] = implode(' AND ', $temp_array); } else { $catalog = ""; } if (preg_match("#xfields=['\"](.+?)['\"]#i", $param_str, $match)) { $xf = $match[1]; $match[1] = explode(',', $match[1]); $temp_array = array(); foreach ($match[1] as $value) { $value = @$db->safesql(htmlspecialchars(strip_tags(stripslashes(trim($value))), ENT_QUOTES, $config['charset'])); $temp_array[] = "p.xfields LIKE '%{$value}%'"; } $where[] = implode(' OR ', $temp_array); } else { $xf = ""; } if (preg_match("#xfieldsexclude=['\"](.+?)['\"]#i", $param_str, $match)) { $notxf = $match[1]; $match[1] = explode(',', $match[1]); $temp_array = array(); foreach ($match[1] as $value) { $value = @$db->safesql(htmlspecialchars(strip_tags(stripslashes(trim($value))), ENT_QUOTES, $config['charset'])); $temp_array[] = "p.xfields NOT LIKE '%{$value}%'"; } $where[] = implode(' AND ', $temp_array); } else { $notxf = ""; } $where[] = "approve=1"; if ($config['no_date'] and !$config['news_future'] and !$days) { $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]); $custom_all = $custom_from; } else { $custom_from = 0; $custom_all = 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'] = 1; } else { $config['allow_cache'] = false; } } if ($config['allow_cache']) { $short_news_cache = true; } else { $short_news_cache = false; } if (preg_match("#fixed=['\"](.+?)['\"]#i", $param_str, $match)) { $fixed = ""; $fixedcache = "fixed yes"; if ($match[1] == "yes") { $fixed = "fixed DESC, "; } elseif ($match[1] == "only") { $where[] = "fixed='1'"; $fixedcache = "fixed only"; } elseif ($match[1] == "without") { $where[] = "fixed='0'"; $fixedcache = "without fixed"; } } else { $fixed = ""; $fixedcache = ""; } 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 (preg_match("#sort=['\"](.+?)['\"]#i", $param_str, $match)) { $allowed_sort = array('asc' => 'ASC', 'desc' => 'DESC'); $match[1] = strtolower($match[1]); if ($allowed_sort[$match[1]]) { $news_msort = $allowed_sort[$match[1]]; } } 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()'); $match[1] = strtolower($match[1]); if ($allowed_sort[$match[1]]) { $news_sort = $allowed_sort[$match[1]]; } if ($match[1] == "rand") { $fixed = ""; $news_msort = ""; } } if (preg_match("#navigation=['\"](.+?)['\"]#i", $param_str, $match)) { if ($match[1] == "yes" and $url_page !== false) { $build_navigation = true; if (isset($_GET['cstart'])) { $cstart = intval($_GET['cstart']); } else { $cstart = 0; } if ($cstart > 10) { $config['allow_cache'] = false; } if ($cstart) { $cstart = $cstart - 1; $cstart = $cstart * $custom_limit + $custom_from; $custom_from = $cstart; } } else { $build_navigation = false; } } else { $build_navigation = false; } $custom_cache_id = $custom_id . $custom_category . $user_group[$member_id['user_group']]['allow_cats'] . $custom_from . $custom_limit . $news_sort . $news_msort . $custom_template . $days . $author . $catalog . $xf . $notxf . $fixedcache . $tagscache; $content = dle_cache("news", $custom_cache_id, true); if ($content !== false) { $config['allow_cache'] = $allow_cache; $custom_news = true; return $content; } else { if ($build_navigation) { $count_all = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_post p WHERE " . implode(' AND ', $where)); $count_all = $count_all['count'] - $custom_all; } $tpl = new dle_template(); $tpl->dir = TEMPLATE_DIR; $tpl->load_template($custom_template . '.tpl'); $sql_select .= " WHERE " . implode(' AND ', $where) . " ORDER BY " . $fixed . $news_sort . " " . $news_msort . " LIMIT " . $custom_from . "," . $custom_limit; $sql_result = $db->query($sql_select); include ENGINE_DIR . '/modules/show.custom.php'; if ($config['files_allow']) { if (strpos($tpl->result['content'], "[attachment=") !== false) { $tpl->result['content'] = show_attach($tpl->result['content'], $attachments); } } if ($custom_news) { create_cache("news", $tpl->result['content'], $custom_cache_id, true); } $config['allow_cache'] = $allow_cache; return $tpl->result['content']; } }
public function _parse_post($text_forum, $id) { require_once ENGINE_DIR . '/classes/parse.class.php'; $parse = new ParseFilter(array(), array(), 1, 1); function build_thumb(ParseFilter &$parse, $gurl = "", $url = "", $align = "") { $url = trim($url); $gurl = trim($gurl); $option = explode("|", trim($align)); $align = $option[0]; if ($align != "left" and $align != "right") { $align = ''; } $url = $parse->clear_url(urldecode($url)); $gurl = $parse->clear_url(urldecode($gurl)); if ($gurl == "" or $url == "") { return; } if ($align == '') { return "[{$align}][url=\"{$gurl}\"][img]{$url}[/img][/url][/{$align}]"; } else { return "[url=\"{$gurl}\"][img]{$url}[/img][/url]"; } } function decode_img($img, $txt) { $txt = stripslashes($txt); $align = false; if (strpos($txt, "align=\"") !== false) { $align = preg_replace("#(.+?)align=\"(.+?)\"(.*)#is", "\\2", $txt); } if ($align != "left" and $align != "right") { $align = false; } if ($align) { return "[{$align}][img]" . $img . "[/img][/{$align}]"; } else { return "[img]" . $img . "[/img]"; } } //$text_forum = stripslashes($text_forum); if (strpos($text_forum, "[attachment=") !== false) { $this->_db_disconnect(); $text_forum = show_attach($text_forum, $id); $this->_db_connect(); } $text_forum = preg_replace('#\\[.+?\\]#', '', $text_forum); $text_forum = preg_replace("#<img src=[\"'](\\S+?)['\"](.+?)>#ie", "decode_img('\\1', '\\2')", $text_forum); $text_forum = $parse->decodeBBCodes($text_forum, false); $text_forum = nl2br(preg_replace('#<.+?>#s', '', $text_forum)); $text_forum = str_replace('leech', 'url', $text_forum); $text_forum = preg_replace("#\\[video\\s*=\\s*(\\S.+?)\\s*\\]#ie", "\$parse->build_video('\\1')", $text_forum); $text_forum = preg_replace("#\\[audio\\s*=\\s*(\\S.+?)\\s*\\]#ie", "\$parse->build_audio('\\1')", $text_forum); $text_forum = preg_replace("#\\[flash=([^\\]]+)\\](.+?)\\[/flash\\]#ies", "\$parse->build_flash('\\1', '\\2')", $text_forum); $text_forum = preg_replace("#\\[youtube=([^\\]]+)\\]#ies", "\$parse->build_youtube('\\1')", $text_forum); $text_forum = preg_replace("'\\[thumb\\]([^\\[]*)([/\\\\])(.*?)\\[/thumb\\]'ie", "build_thumb(\$parse, '\$1\$2\$3', '\$1\$2thumbs\$2\$3')", $text_forum); $text_forum = preg_replace("'\\[thumb=(.*?)\\]([^\\[]*)([/\\\\])(.*?)\\[/thumb\\]'ie", "build_thumb(\$parse, '\$2\$3\$4', '\$2\$3thumbs\$3\$4', '\$1')", $text_forum); $text_forum = preg_replace('#<!--.+?-->#s', '', $text_forum); return $text_forum; }