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']; } }
private function Explode_Category($category, $type) { $temp_array = array(); $category = explode(',', $category); foreach ($category as $value) { if (count(explode('-', $value)) == 2) { $temp_array[] = get_mass_cats($value); } else { $temp_array[] = intval($value); } } if ($type == "multi") { $temp_array = implode("|", $temp_array); } else { $temp_array = implode(",", $temp_array); } return $temp_array; unset($temp_array); }
function check_category($matches = array()) { global $category_id; $block = $matches[3]; $category = $category_id; $temp_array = array(); $matches[2] = str_replace(" ", "", $matches[2]); $matches[2] = explode(',', $matches[2]); foreach ($matches[2] as $value) { if (count(explode('-', $value)) == 2) { $temp_array[] = get_mass_cats($value); } else { $temp_array[] = intval($value); } } $temp_array = implode(',', $temp_array); if ($matches[1] == "category" or $matches[1] == "catlist") { $action = true; } else { $action = false; } $cats = explode(',', $temp_array); $category = explode(',', $category); $found = false; foreach ($category as $element) { if ($action) { if (in_array($element, $cats)) { return $block; } } else { if (in_array($element, $cats)) { $found = true; } } } if (!$action and !$found) { return $block; } return ""; }