public function Compile($cont_name, $subhead = '') { foreach ($this->row_content as $row_name => $row_content) { if ($row_content) { $this->SetBlockContent($row_name, $row_content); } } $this->ClaerContent($this->content); if (!self::$show_sub) { $subhead = $this->subhead . $subhead; self::$show_sub = true; } if (!self::$show_superhead) { $this->style_cur = $this->superhead . $this->style_cur; self::$show_superhead = true; } if ((!defined('AJAX') || !AJAX) && (!defined('RSS') || !RSS)) { if ($this->_blank) { $this->Set($this->style_cur, "__style__")->Set($this->script_cur, "__script__")->Set($this->superhead, "__superhead__")->Set($subhead, "__subhead__"); $this->content = preg_replace('#__.*?__#i', '', $this->content); $this->content = str_replace('{THEME}', $GLOBALS['config']['http_home_url'] . 'templates/' . $GLOBALS['config']['skin'], $this->content); } else { $this->content = $this->style_cur . $this->script_cur . $subhead . $this->content; } } elseif (!defined('RSS') || !RSS) { $this->content = $this->ajax_style_cur . $this->ajax_script_cur . $this->AJAX_script . $this->content; } $cur_content = $this->content; $this->tpl->compile($cont_name); $this->tpl->clear(); $this->row_name = $this->sep_count = $this->row_count = $this->separator = $this->row_template = $this->row_content = array(); $this->content = $this->style_cur = $this->script_cur = $this->ajax_style_cur = $this->ajax_script_cur = ''; return $cur_content; }
protected function _compile($name) { $this->_tpl->compile($name); $return = $this->_tpl->result[$name]; unset($this->_tpl->result[$name]); $blocks = array(); $return = str_ireplace('{THEME}', $GLOBALS['config']['http_home_url'] . 'templates/' . $GLOBALS['config']['skin'], $return); $return = preg_replace('#{[\\w_]+}#i', '', $return); //preg_match_all('#\[(.{3,})\].*?\[/\1\]#si', $return, $blocks); // for 5.2 preg_match_all("#\\[/(.{3,}?)\\]#i", $return, $blocks); foreach ($blocks[1] as $name) { if (strpos($name, 'not-') === false) { $return = preg_replace("#\\[not\\-{$name}\\](.*?)\\[/not\\-{$name}\\]#si", '\\1', $return); $return = preg_replace("#\\[{$name}\\](.*?)\\[/{$name}\\]#si", '', $return); } else { $return = preg_replace("#\\[{$name}\\](.*?)\\[/{$name}\\]#si", '', $return); } } //$return = preg_replace('#\[(.{3,}?)\].+?\[/\1\]#si', '', $return); return $return; }
if ($relatedpro) { if ($new_version) { ////////////////////////////// //тут будет код для DLE 9.6+// ////////////////////////////// } else { if (strlen($row['full_story']) < strlen($row['short_story'])) { $body = $row['short_story']; } else { $body = $row['full_story']; } $body = $db->safesql(strip_tags(stripslashes($metatags['title'] . " " . $body))); } } if ($template) { $tplb = new dle_template(); $tplb->dir = TEMPLATE_DIR; $tplb->load_template($template . '.tpl'); $tooday = date('Y-m-d H:i:s', $_TIME); $query_mod = ""; $ignore_category = $ignore_cat ? "NOT" : ""; if ($show_cat && $show_cat != "this") { $query_mod .= "AND {$ignore_category} p.category regexp '[[:<:]](" . str_replace(',', '|', $show_cat) . ")[[:>:]]'"; } if ($show_cat == "this" && $category_id != "") { $query_mod .= "AND {$ignore_category} p.category IN (" . intval($category_id) . ")"; } if ($xfilter) { $query_mod .= "AND p.xfields regexp '[[:<:]](" . $xfilter . ")[[:>:]]'"; } if ($day && $day !== 0 && !$last && !$relatedpro && !$random) {
if (count($allowed_cats)) { $allowed_cats = implode(",", $allowed_cats); $allowed_cats = explode(",", $allowed_cats); $allowed_cats = array_unique($allowed_cats); sort($allowed_cats); if ($config['allow_multi_category']) { $allowed_cats = "category regexp '[[:<:]](" . implode('|', $allowed_cats) . ")[[:>:]]' AND "; } else { $allowed_cats = "category IN ('" . implode("','", $allowed_cats) . "') AND "; } } else { $allowed_cats = ""; } $db->query("SELECT id, date, short_story, xfields, title, category, alt_name FROM " . PREFIX . "_post WHERE {$allowed_cats}MATCH (title, short_story, full_story, xfields) AGAINST ('{$body}') AND id != " . $row['id'] . " AND approve=1" . $where_date . " LIMIT " . $config['related_number']); } $tpl2 = new dle_template(); $tpl2->dir = TEMPLATE_DIR; $tpl2->load_template('relatednews.tpl'); if (strpos($tpl2->copy_template, "[xfvalue_") !== false or strpos($tpl2->copy_template, "[xfgiven_") !== false) { $xfound = true; } else { $xfound = false; } while ($related = $db->get_row()) { if ($first_show) { $related_ids[] = $related['id']; } $related['date'] = strtotime($related['date']); if (!$related['category']) { $my_cat = "---"; $my_cat_link = "---";
if ($config['allow_multi_category']) { $where_category = "category regexp '[[:<:]](" . $get_cats . ")[[:>:]]' AND "; } else { if ($allow_sub_cats) { $get_cats = str_replace("|", "','", $get_cats); $where_category = "category IN ('" . $get_cats . "') AND "; } else { $where_category = "category = '{$get_cats}' AND "; } } } else { $where_category = ""; } $db->query("SELECT id, date, short_story, xfields, title, category, alt_name FROM " . PREFIX . "_post WHERE {$where_category}{$allowed_cats}MATCH (title, short_story, full_story, xfields) AGAINST ('{$body}') AND id != " . $row['id'] . " AND approve=1" . $where_date . " LIMIT " . $config['related_number']); } $tpl2 = new dle_template(); $tpl2->dir = TEMPLATE_DIR; $tpl2->load_template('relatednews.tpl'); if (strpos($tpl2->copy_template, "[xfvalue_") !== false or strpos($tpl2->copy_template, "[xfgiven_") !== false) { $xfound = true; } else { $xfound = false; } while ($related = $db->get_row()) { if ($first_show) { $related_ids[] = $related['id']; } $related['date'] = strtotime($related['date']); if (!$related['category']) { $my_cat = "---"; $my_cat_link = "---";
<?php if (!defined('DATALIFEENGINE') or !defined('LOGGED_IN')) { die("Hacking attempt!"); } require_once ROOT_DIR . '/engine/classes/templates.class.php'; $tpl = new dle_template(); $tpl->allow_php_include = false; $dle_module = "main"; if ($_POST['preview_mode'] == "static" and $_POST['skin_name']) { $_POST['skin_name'] = trim(totranslit($_POST['skin_name'], false, false)); if ($_POST['skin_name'] != '' and @is_dir(ROOT_DIR . '/templates/' . $_POST['skin_name'])) { $config['skin'] = $_POST['skin_name']; } } $tpl->dir = ROOT_DIR . '/templates/' . $config['skin']; $css = file_get_contents($tpl->dir . "/" . 'preview.css'); echo <<<HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset={$config['charset']}" http-equiv=Content-Type> <style type="text/css"> {$css} </style> <link media="screen" href="{$config['http_home_url']}engine/editor/css/default.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="{$config['http_home_url']}engine/editor/scripts/common/jquery-1.7.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js"></script> <script type="text/javascript" src="{$config['http_home_url']}engine/editor/scripts/webfont.js"></script> </head> <body>
$do = "alltags"; } $dle_module = $do; if ($do == "" and !$subaction and $year) { $dle_module = "date"; } elseif ($do == "" and $catalog) { $dle_module = "catalog"; } elseif ($do == "") { $dle_module = $subaction; } if ($subaction == '' and $newsid) { $dle_module = "showfull"; } $dle_module = $dle_module ? $dle_module : "main"; require_once ENGINE_DIR . '/classes/templates.class.php'; $tpl = new dle_template(); $tpl->dir = ROOT_DIR . '/templates/' . totranslit($config['skin'], false, false); define('TEMPLATE_DIR', $tpl->dir); if (isset($_POST['set_new_sort']) and $config['allow_change_sort']) { $allowed_sort = array('date', 'rating', 'news_read', 'comm_num', 'title'); $find_sort = str_replace(".", "", totranslit($_POST['set_new_sort'])); $direction_sort = str_replace(".", "", totranslit($_POST['set_direction_sort'])); if (in_array($_POST['dlenewssortby'], $allowed_sort) and stripos($find_sort, "dle_sort_") === 0) { if ($_POST['dledirection'] == "desc" or $_POST['dledirection'] == "asc") { $_SESSION[$find_sort] = $_POST['dlenewssortby']; $_SESSION[$direction_sort] = $_POST['dledirection']; $_SESSION['dle_no_cache'] = "1"; } } } if ($config['allow_registration'] == "yes") {
if ($do == "tags" and !$_GET['tag']) { $do = "alltags"; } $dle_module = $do; if ($do == "" and !$subaction and $year) { $dle_module = "date"; } elseif ($do == "" and $catalog) { $dle_module = "catalog"; } elseif ($do == "") { $dle_module = $subaction; } if ($subaction == '' and $newsid) { $dle_module = "showfull"; } $dle_module = $dle_module ? $dle_module : "main"; $tpl = new dle_template(); $tpl->dir = ROOT_DIR . '/templates'; define('TEMPLATE_DIR', $tpl->dir); //#################################################################################################################### // Определение категорий и их параметры //#################################################################################################################### $cat_info = get_vars("category"); if (!$cat_info) { $cat_info = array(); $db->query("SELECT * FROM " . PREFIX . "_category ORDER BY posi ASC"); while ($row = $db->get_row()) { $cat_info[$row['id']] = array(); foreach ($row as $key => $value) { $cat_info[$row['id']][$key] = $value; } }
public function Start($CommCfg) { $this->New_Cfg($CommCfg); // создаем новый конфиг $where = array(); // проверка некоторых параметров конфига по версиях $allow_alt_url = $this->config['version_id'] >= '10.2' ? $this->config['allow_alt_url'] == '1' : $this->config['allow_alt_url'] == "yes"; $allow_cache = $this->config['version_id'] >= '10.2' ? $this->config['allow_cache'] == '1' : $this->config['allow_cache'] == "yes"; $allow_multi_category = $this->config['version_id'] >= '10.2' ? $this->config['allow_multi_category'] == '1' : $this->config['allow_multi_category'] == "yes"; if ($this->config['version_id'] >= '10.4' and $this->comm_cfg['rating_comm']) { // рейтинг комментариев только для DLE 10.4 и выще $where[] = "c.rating > {$this->comm_cfg[rating_comm]}"; } // работа с категориями if ($allow_multi_category) { if ($this->comm_cfg['stop_category']) { $where[] = "category NOT REGEXP '[[:<:]](" . $this->Explode_Category($this->comm_cfg['stop_category'], "multi") . ")[[:>:]]'"; } if ($this->comm_cfg['from_category']) { $where[] = "category REGEXP '[[:<:]](" . $this->Explode_Category($this->comm_cfg['from_category'], "multi") . ")[[:>:]]'"; } } else { if ($this->comm_cfg['stop_category']) { $where[] = "category NOT IN ('" . $this->Explode_Category($this->comm_cfg['stop_category']) . "')"; } if ($this->comm_cfg['from_category']) { $where[] = "category IN ('" . $this->Explode_Category($this->comm_cfg['from_category']) . "')"; } } if ($this->comm_cfg['news_xfield']) { // работа с доп полями новостей $where[] = $this->Explode_xField($this->comm_cfg['news_xfield'], "p.xfields"); } if ($this->comm_cfg['user_xfield']) { // работа с доп полями пользователей $where[] = $this->Explode_xField($this->comm_cfg['user_xfield'], "u.xfields"); } // работа с новостями if ($this->comm_cfg['stop_id']) { $where[] = $this->Explode_NewsID($this->comm_cfg['stop_id']); } if ($this->comm_cfg['from_id']) { $where[] = $this->Explode_NewsID($this->comm_cfg['from_id']); } if ($this->comm_cfg['ncomm']) { // выводим только с комментариями у новостей больше чем $where[] = "p.comm_num > {$this->comm_cfg[ncomm]}"; } if ($this->comm_cfg['fixed']) { // выводим только с зафиксированых новостей $where[] = "p.fixed = 1"; } if ($this->comm_cfg['tags']) { $t = explode(',', $this->comm_cfg['tags']); $t = implode('|', $t); $where[] = "p.tags regexp '[[:<:]](" . $t . ")[[:>:]]'"; } if ($this->comm_cfg['news_read']) { // выводим только с комментариями у новостей больше чем $where[] = "e.news_read > {$this->comm_cfg[news_read]}"; } if ($this->comm_cfg['rating_news']) { // выводим только с комментариями у новостей больше чем $where[] = "e.rating > {$this->comm_cfg[rating_news]}"; } if ($this->comm_cfg['only_avatar']) { // выводим только с аватарами $where[] = "u.foto != ''"; } if ($this->comm_cfg['only_news']) { // выводим только с новостями $where[] = "u.news_num > 0"; } if ($this->comm_cfg['only_fav']) { // выводим только с закладками $where[] = "u.favorites != ''"; } if ($this->comm_cfg['only_fullname']) { // выводим только с полным именем $where[] = "u.fullname != ''"; } if ($this->comm_cfg['only_land']) { // выводим только с место жительством $where[] = "u.land != ''"; } if ($this->comm_cfg['news_user']) { // выводим только если новостей больше чем $where[] = "u.news_num > {$this->comm_cfg[news_user]}"; } if ($this->comm_cfg['comm']) { // выводим только если комментариев больше чем $where[] = "u.comm_num > {$this->comm_cfg[comm]}"; } // префикс кэша $Comm_hash = md5($this->comm_cfg['max_comm'] . $this->comm_cfg['max_text'] . $this->comm_cfg['max_title'] . $this->comm_cfg['check_guest'] . $this->comm_cfg['stop_category'] . $this->comm_cfg['from_category'] . $this->comm_cfg['stop_id'] . $this->comm_cfg['from_id'] . $this->comm_cfg['only_avatar'] . $this->comm_cfg['only_news'] . $this->comm_cfg['news_user'] . $this->comm_cfg['comm'] . $this->comm_cfg['only_fav'] . $this->comm_cfg['only_fullname'] . $this->comm_cfg['only_land']); $is_change = false; if (!$allow_cache) { if ($this->config['version_id'] >= '10.2') { $this->config['allow_cache'] = '1'; } else { $this->config['allow_cache'] = "yes"; } $is_change = true; } $Comm = dle_cache("Comm_", $this->config['skin'] . $Comm_hash); // подгружаем из кэша if (!$Comm) { if (count($where) > 0) { $where = " AND " . implode(" AND ", $where); } else { $where = ""; } $sql = $this->db->query("SELECT c.id as comid, c.post_id, c.date, c.user_id, c.is_register, c.text, c.autor, c.email, c.approve, p.id, p.date as newsdate, p.title, p.category, p.comm_num, p.alt_name, e.news_id, e.news_read, e.rating, u.foto, u.user_group, u.user_id FROM " . PREFIX . "_comments as c, " . PREFIX . "_post as p, " . PREFIX . "_post_extras as e, " . PREFIX . "_users as u WHERE p.id=c.post_id AND e.news_id=c.post_id AND c.approve = 1 AND c.user_id = u.user_id {$where} ORDER BY c.date DESC LIMIT 0, " . $this->comm_cfg['max_comm']); $tpl = new dle_template(); $tpl->dir = TEMPLATE_DIR; $tpl->load_template('comm/comm.tpl'); $count_rows = $sql->num_rows; if ($count_rows > 0) { while ($row = $this->db->get_row($sql)) { $row['date'] = strtotime($row['date']); $row['category'] = intval($row['category']); // Обработка ссылки на комментарий $on_page = FALSE; if ($row['comm_num'] > $this->config['comm_nummers']) { $on_page = 'page,1,' . ceil($row['comm_num'] / $this->config['comm_nummers']) . ','; } if ($allow_alt_url) { if ($condition = $this->config['seo_type'] == 1 or $this->config['seo_type'] == 2) { if ($row['category'] and $this->config['seo_type'] == 2) { $full_link = $this->config['http_home_url'] . get_url($row['category']) . "/" . $on_page . $row['id'] . "-" . $row['alt_name'] . ".html"; } else { $full_link = $this->config['http_home_url'] . $on_page . $row['id'] . "-" . $row['alt_name'] . ".html"; } } else { $full_link = $this->config['http_home_url'] . date('Y/m/d/', $row['date']) . $on_page . $row['alt_name'] . ".html"; } } else { $full_link = $this->config['http_home_url'] . "index.php?newsid=" . $row['id']; } $full_link = $full_link . '#comment-id-' . $row['comid']; // Обработка текста комментария if (dle_strlen($row['text'], $this->config['charset']) > $this->comm_cfg['max_text']) { $text = stripslashes(dle_substr($row['text'], 0, $this->comm_cfg['max_text'], $this->config['charset']) . " ..."); } else { $text = stripslashes($row['text']); } // Обработка заголовка новости (title) if (dle_strlen($row['title'], $this->config['charset']) > $this->comm_cfg['max_title']) { $title = stripslashes(dle_substr($row['title'], 0, $this->comm_cfg['max_title'], $this->config['charset']) . " ..."); } else { $title = stripslashes($row['title']); } // Обработка ника автора комментария if ($row['is_register'] == 1) { if ($allow_alt_url) { $go_page = $this->config['http_home_url'] . "user/" . urlencode($row['autor']) . "/"; } else { $go_page = "{$PHP_SELF}?subaction=userinfo&user="******"onclick=\"ShowProfile('" . urlencode($row['autor']) . "', '" . htmlspecialchars($go_page, ENT_QUOTES, $this->config['charset']) . "', '" . $this->group[$this->member['user_group']]['admin_editusers'] . "'); return false;\""; } else { $go_page = "onclick=\"ShowProfile('" . urlencode($row['autor']) . "', '" . $go_page . "'); return false;\""; } if ($allow_alt_url) { $author = "<a {$go_page} href=\"" . $this->config['http_home_url'] . "user/" . urlencode($row['autor']) . "/\">" . $row['autor'] . "</a>"; } else { $author = "<a {$go_page} href=\"{$PHP_SELF}?subaction=userinfo&user="******"\">" . $row['autor'] . "</a>"; } } else { $author = strip_tags($row['autor']); } // Обработка фото автора комментария if ($row['foto'] and $row['is_register'] == 1) { if (count(explode("@", $row['foto'])) == 2) { $tpl->set('{foto}', '//www.gravatar.com/avatar/' . md5(trim($row['foto'])) . '?s=' . intval($this->group[$row['user_group']]['max_foto'])); } else { if ($this->config['version_id'] >= '10.5') { if (strpos($row['foto'], "//") === 0) { $avatar = "http:" . $row['foto']; } else { $avatar = $row['foto']; } $avatar = @parse_url($avatar); if ($avatar['host']) { $tpl->set('{foto}', $row['foto']); } else { $tpl->set('{foto}', $this->config['http_home_url'] . "uploads/fotos/" . $row['foto']); } } else { if ($row['foto'] and file_exists(ROOT_DIR . "/uploads/fotos/" . $row['foto'])) { $tpl->set('{foto}', $this->config['http_home_url'] . "uploads/fotos/" . $row['foto']); } } } } else { $tpl->set('{foto}', "{THEME}/dleimages/noavatar.png"); } // Обработка ссылки автора комментария if ($allow_alt_url) { $user_url = $this->config['http_home_url'] . "user/" . urlencode($row['autor']) . "/"; } else { $user_url = "{$PHP_SELF}?subaction=userinfo&user="******", H:i", $row['date'])); } elseif (date('Ymd', $row['date']) == date('Ymd', $_TIME - 86400)) { $tpl->set('{date}', $lang['time_gestern'] . langdate(", H:i", $row['date'])); } else { $tpl->set('{date}', langdate($this->config['timestamp_active'], $row['date'])); } $tpl->copy_template = preg_replace("#\\{date=(.+?)\\}#ie", "langdate('\\1', '{$row['date']}')", $tpl->copy_template); $tpl->set('{text}', $text); //текст комментария $tpl->set('{user_url}', $user_url); // ссылка на автора $tpl->set('{user_name}', $row['autor']); // просто ник автора $tpl->set('[user_url]', "<a href=\"" . $user_url . "\">"); // оборачиваем в ссылку $tpl->set('[/user_url]', "</a>"); // оборачиваем в ссылку $tpl->set('{author}', $author); // автор с ссылкой на профиль с модальным окном $tpl->set('[color]', $this->group[$row['user_group']]['group_prefix']); // префикс цвета группы $tpl->set('[/color]', $this->group[$row['user_group']]['group_suffix']); // суфикс цвета группы $tpl->set('{title}', $title); // укороченный заголовок $tpl->set('{long_title}', stripslashes($row['title'])); // полный заголовок $tpl->set('{rating}', $row['rating']); // рейтинг новости $tpl->set('{views}', $row['news_read']); // просмотров новости $tpl->set('{full_link}', $full_link); // линк на комментарий $tpl->set('{comm_num}', $row['comm_num']); // кол-во комментариев новости $tpl->set("{error}", ""); $tpl->set('[comm]', ""); $tpl->set('[/comm]', ""); $tpl->set_block("'\\[not-comm\\](.*?)\\[/not-comm\\]'si", ""); $tpl->compile('comm'); //компиляция шаблона } $this->db->free($sql); //очищаем от запросов } else { $tpl->set("{error}", "Комментариев нету!"); $tpl->set_block("'\\[comm\\](.*?)\\[/comm\\]'si", ""); $tpl->set('[not-comm]', ""); $tpl->set('[/not-comm]', ""); $tpl->compile('comm'); } $tpl->clear(); //очищаем шаблон $Comm = $tpl->result['comm']; if (preg_match_all('/<!--dle_spoiler(.*?)<!--\\/dle_spoiler-->/is', $Comm, $spoilers)) { foreach ($spoilers as $spoiler) { $Comm = str_replace($spoiler, '<div class="quote">Для просмотра содержимого спойлера, перейдите к выбранному комментарию.</div>', $Comm); } } if ($this->group[$this->member['user_group']]['allow_hide']) { $Comm = preg_replace("'\\[hide\\](.*?)\\[/hide\\]'si", "\\1", $Comm); } else { $Comm = preg_replace("'\\[hide\\](.*?)\\[/hide\\]'si", "<div class=\"quote\"> Для вашей группы скрытый текст не виден </div>", $Comm); } create_cache("Comm_", $Comm, $this->config['skin'] . $Comm_hash); //создаем кэш if ($is_change) { $this->config['allow_cache'] = false; } //выключаем кэш принудительно (возвращаем назад) } echo '<div class="iComm" id="iComm"><ul class="lastcomm">' . $Comm . '</ul> <!-- .lastcomm --></div>'; }
if ($row['id'] and ($row['user'] == $member_id['user_id'] or $member_id['user_group'] == 1)) { $db->query("DELETE FROM " . USERPREFIX . "_ignore_list WHERE id = '{$row['id']}'"); echo $lang['ignore_del_ok']; die; } die("Operation not Allowed"); } else { $parse = new ParseFilter(); $parse->safe_mode = true; function del_tpl($read) { global $tpl; $read = str_replace('\\"', '"', str_replace("&", "&", $read)); $tpl->copy_template = $read; } $tpl = new dle_template(); $tpl->dir = ROOT_DIR . '/templates/' . $_REQUEST['skin']; define('TEMPLATE_DIR', $tpl->dir); $_POST['name'] = convert_unicode($_POST['name'], $config['charset']); $_POST['subj'] = convert_unicode($_POST['subj'], $config['charset']); $_POST['text'] = convert_unicode($_POST['text'], $config['charset']); $name = $parse->process(trim($_POST['name'])); $subj = $parse->process(trim($_POST['subj'])); if ($config['allow_comments_wysiwyg'] != "yes") { $text = $parse->BB_Parse($parse->process($_POST['text']), false); } else { $parse->wysiwyg = true; $parse->ParseFilter(array('div', 'span', 'p', 'br', 'strong', 'em', 'ul', 'li', 'ol'), array(), 0, 1); $text = $parse->BB_Parse($parse->process($_POST['text'])); } $tpl->load_template('pm.tpl');
} if ($config["lang_" . $_REQUEST['skin']]) { if (file_exists(ROOT_DIR . '/language/' . $config["lang_" . $_REQUEST['skin']] . '/website.lng')) { @(include_once ROOT_DIR . '/language/' . $config["lang_" . $_REQUEST['skin']] . '/website.lng'); } else { die("Language file not found"); } } else { @(include_once ROOT_DIR . '/language/' . $config['langs'] . '/website.lng'); } $config['charset'] = $lang['charset'] != '' ? $lang['charset'] : $config['charset']; require_once ENGINE_DIR . '/modules/sitelogin.php'; if (!$is_logged) { $member_id['user_group'] = 5; } $tpl = new dle_template(); $tpl->dir = ROOT_DIR . '/templates/' . $_REQUEST['skin']; define('TEMPLATE_DIR', $tpl->dir); $PHP_SELF = $config['http_home_url'] . "index.php"; if (isset($_GET['name'])) { $name = @$db->safesql(strip_tags(urldecode($_GET['name']))); } else { $name = ''; } if (!$name) { die("Hacking attempt!"); } if (preg_match("/[\\||\\'|\\<|\\>|\"|\\!|\\?|\$|\\@|\\/|\\\\|\\&\\~\\*\\+]/", $name)) { die("Not allowed user name!"); } $row = $db->super_query("SELECT * FROM " . USERPREFIX . "_users WHERE name = '{$name}'");
$_IP = get_ip(); if ($is_logged) { $log_id = intval($member_id['user_id']); } else { $log_id = $_IP; } $poll = $db->super_query("SELECT * FROM " . PREFIX . "_poll WHERE news_id = '{$row['id']}'"); if ($config['allow_cache'] and $dle_module != "showfull") { $log = array('count' => 0); } else { $log = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_poll_log WHERE news_id = '{$row['id']}' AND member ='{$log_id}'"); } $poll['title'] = stripslashes($poll['title']); $poll['frage'] = stripslashes($poll['frage']); $body = explode("<br />", stripslashes($poll['body'])); $tplpoll = new dle_template(); $tplpoll->dir = TEMPLATE_DIR; $tplpoll->load_template('poll.tpl'); $tplpoll->set('{title}', $poll['title']); $tplpoll->set('{question}', $poll['frage']); $tplpoll->set('{votes}', $poll['votes']); $tplpoll->set('{news-id}', $row['id']); if ($log['count']) { $tplpoll->set_block("'\\[not-voted\\](.+?)\\[/not-voted\\]'si", ""); $tplpoll->set('[voted]', ''); $tplpoll->set('[/voted]', ''); } else { $tplpoll->set_block("'\\[voted\\](.+?)\\[/voted\\]'si", ""); $tplpoll->set('[not-voted]', ''); $tplpoll->set('[/not-voted]', ''); }
public function LinkForum(array &$row, dle_template &$tpl) { $categories = explode(",", $row['category']); foreach ($categories as $category) { if (intval($this->config['vb_link_forumid'][$category])) { $cat_id = $category; break; } } switch ($this->config['link_title']) { case "old": $title_forum = preg_replace('/{Post_name}/', stripslashes($row['title']), $this->config['vb_link_name_post_on_forum']); $title_forum = $this->db->safesql($title_forum); break; case "title": $title_forum = $this->db->safesql(stripslashes($row['title'])); break; default: break; } if (!$this->config['vb_goforum'] || !$this->config['vb_onoff'] || !$this->config['vb_link_forumid'][$cat_id] || !$this->config['vb_link_show_no_register'] && !$GLOBALS['is_logged']) { $tpl->set('{link_on_forum}', ""); } else { $link_on_forum = $this->config['vb_link_link_on_forum']; if ($GLOBALS['newsid'] || $GLOBALS['subaction'] == 'showfull') { $this->config['vb_link_show_count'] = $this->config['vb_link_show_count_full']; } $count = 0; if ($this->config['vb_link_type'] == 2 && isset($row['vb_threadid'])) { if ((int) $row['vb_threadid']) { $link_on_forum = str_replace('{link_on_forum}', $this->vb_config['bburl'] . "/showthread.php?t={$row['vb_threadid']}&goto=newpost", $link_on_forum); if ($this->config['vb_link_show_count']) { $this->_db_connect(); $thread = $this->db->super_query("SELECT threadid, replycount FROM " . VB_PREFIX . "thread WHERE threadid='{$row['vb_threadid']}' AND visible='1' AND open=1"); $this->_db_disconnect(); if (!isset($thread['threadid'])) { $link_on_forum = preg_replace("'\\[count\\](.*?)\\[/count\\]'si", "", $link_on_forum); } else { $count = $thread['replycount']; $link_on_forum = preg_replace("'\\[count\\](.*?)\\[/count\\]'si", "\\1", $link_on_forum); } } } else { $link_on_forum = str_replace('{link_on_forum}', $this->vb_config['bburl'] . "/newthread.php?do=newthread&f={$this->config['vb_link_forumid'][$category]}&news_id={$this->config['forumid'][$cat_id]}&news_title=" . urlencode(stripslashes($row['title'])), $link_on_forum); } } else { if ($this->config['vb_link_show_count'] && !empty($title_forum)) { $this->_convert_charset($title_forum); $this->_db_connect(); $thread = $this->db->super_query("SELECT threadid, replycount FROM " . VB_PREFIX . "thread WHERE title='{$title_forum}' AND visible='1' AND open=1"); if (!isset($thread['threadid'])) { $link_on_forum = preg_replace("'\\[count\\](.*?)\\[/count\\]'si", "", $link_on_forum); } else { $count = $thread['replycount']; $link_on_forum = preg_replace("'\\[count\\](.*?)\\[/count\\]'si", "\\1", $link_on_forum); } $this->_db_disconnect(); } else { $link_on_forum = preg_replace("'\\[count\\](.*?)\\[/count\\]'si", "", $link_on_forum); } if ($GLOBALS['config']['allow_alt_url'] == "yes") { $link_on_forum = str_replace('{link_on_forum}', $GLOBALS['config']['http_home_url'] . "goforum/post-" . $row['id'] . "/", $link_on_forum); } else { $link_on_forum = str_replace('{link_on_forum}', $GLOBALS['PHP_SELF'] . "?do=goforum&postid=" . $row['id'], $link_on_forum); } } $link_on_forum = str_replace("{count}", $count, $link_on_forum); $tpl->set('{link_on_forum}', $link_on_forum); } }
Copyright (c) 2004,2012 SoftNews Media Group ===================================================== Данный код защищен авторскими правами ===================================================== Файл: opensearch.php ----------------------------------------------------- Назначение: Модуль поддержки OpenSearch ===================================================== */ define('DATALIFEENGINE', true); define('ROOT_DIR', substr(dirname(__FILE__), 0, -7)); define('ENGINE_DIR', ROOT_DIR . '/engine'); @error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE); @ini_set('display_errors', true); @ini_set('html_errors', false); @ini_set('error_reporting', E_ALL ^ E_WARNING ^ E_NOTICE); include ENGINE_DIR . '/data/config.php'; if ($config['http_home_url'] == "") { $config['http_home_url'] = explode("engine/opensearch.php", $_SERVER['PHP_SELF']); $config['http_home_url'] = reset($config['http_home_url']); $config['http_home_url'] = "http://" . $_SERVER['HTTP_HOST'] . $config['http_home_url']; } require_once ENGINE_DIR . '/classes/templates.class.php'; $tpl = new dle_template(); $tpl->dir = ROOT_DIR . '/templates'; define('TEMPLATE_DIR', $tpl->dir); $tpl->load_template('opensearch.tpl'); $tpl->set('{path}', $config['http_home_url']); $tpl->compile('main'); header('Content-type: application/xml'); echo $tpl->result['main'];
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']; } }
/** * Метод подхватывает tpl-шаблон, заменяет в нём теги и возвращает отформатированную строку * @param $template - название шаблона, который нужно применить * @param $vars - ассоциативный массив с данными для замены переменных в шаблоне * @param $blocks - ассоциативный массив с данными для замены блоков в шаблоне * @param $copyTemplate - массив с данными для замены тегов * @param $copyTemplateMetod - str_replace или preg_replace в зависимости от переменной * * @return string tpl-шаблон, заполненный данными из массива $data */ public function applyTemplate($template, $vars = array(), $blocks = array()) { // Подключаем файл шаблона $template.tpl, заполняем его $tpl = new dle_template(); $tpl->dir = TEMPLATE_DIR; $tpl->load_template($template.'.tpl'); // Заполняем шаблон переменными foreach($vars as $var => $value) { $tpl->set($var, $value); } // Заполняем шаблон блоками foreach($blocks as $block => $value) { $tpl->set_block($block, $value); } // Компилируем шаблон (что бы это не означало ;)) $tpl->compile($template); // Выводим результат return $tpl->result[$template]; }
function show_attach($story, $id, $static = false) { global $db, $config, $lang, $user_group, $member_id, $_TIME, $news_date; $find_1 = array(); $find_2 = array(); $replace_1 = array(); $replace_2 = array(); $tpl = new dle_template(); $tpl->dir = TEMPLATE_DIR; if ($static) { if (is_array($id) and count($id)) { $list = array(); foreach ($id as $value) { $list[] = intval($value); } $id = implode(',', $list); $where = "static_id IN ({$id})"; } else { $where = "static_id = '" . intval($id) . "'"; } $db->query("SELECT id, date, name, onserver, dcount FROM " . PREFIX . "_static_files WHERE {$where}"); $area = "&area=static"; } else { if (is_array($id) and count($id)) { $list = array(); foreach ($id as $value) { $list[] = intval($value); } $id = implode(',', $list); $where = "news_id IN ({$id})"; } else { $where = "news_id = '" . intval($id) . "'"; } $db->query("SELECT id, date, name, onserver, dcount FROM " . PREFIX . "_files WHERE {$where}"); $area = ""; } if (!file_exists($tpl->dir . "/attachment.tpl")) { $tpl->template = <<<HTML [allow-download]<span class="attachment"><a href="{link}" >{name}</a> [count] [{size}] ({$lang['att_dcount']} {count})[/count]</span>[/allow-download] [not-allow-download]<span class="attachment">{$lang['att_denied']}</span>[/not-allow-download] HTML; $tpl->copy_template = $tpl->template; } else { $tpl->load_template('attachment.tpl'); } while ($row = $db->get_row()) { $row['name'] = explode("/", $row['name']); $row['name'] = end($row['name']); $filename_arr = explode(".", $row['onserver']); $type = strtolower(end($filename_arr)); $find_1[] = '[attachment=' . $row['id'] . ']'; $find_2[] = "#\\[attachment={$row['id']}:(.+?)\\]#i"; if (stripos($tpl->copy_template, "{md5}") !== false) { $tpl->set('{md5}', @md5_file(ROOT_DIR . '/uploads/files/' . $row['onserver'])); } if (stripos($tpl->copy_template, "{size}") !== false) { $tpl->set('{size}', formatsize(@filesize(ROOT_DIR . '/uploads/files/' . $row['onserver']))); } if ($user_group[$member_id['user_group']]['allow_files']) { $tpl->set('[allow-download]', ""); $tpl->set('[/allow-download]', ""); $tpl->set_block("'\\[not-allow-download\\](.*?)\\[/not-allow-download\\]'si", ""); } else { $tpl->set('[not-allow-download]', ""); $tpl->set('[/not-allow-download]', ""); $tpl->set_block("'\\[allow-download\\](.*?)\\[/allow-download\\]'si", ""); } if ($config['files_count']) { $tpl->set('{count}', $row['dcount']); $tpl->set('[count]', ""); $tpl->set('[/count]', ""); $tpl->set_block("'\\[not-allow-count\\](.*?)\\[/not-allow-count\\]'si", ""); } else { $tpl->set('{count}', ""); $tpl->set('[not-allow-count]', ""); $tpl->set('[/not-allow-count]', ""); $tpl->set_block("'\\[count\\](.*?)\\[/count\\]'si", ""); } if (date('Ymd', $row['date']) == date('Ymd', $_TIME)) { $tpl->set('{date}', $lang['time_heute'] . langdate(", H:i", $row['date'])); } elseif (date('Ymd', $row['date']) == date('Ymd', $_TIME - 86400)) { $tpl->set('{date}', $lang['time_gestern'] . langdate(", H:i", $row['date'])); } else { $tpl->set('{date}', langdate($config['timestamp_active'], $row['date'])); } $news_date = $row['date']; $tpl->copy_template = preg_replace_callback("#\\{date=(.+?)\\}#i", "formdate", $tpl->copy_template); $tpl->set('{name}', $row['name']); $tpl->set('{extension}', $type); $tpl->set('{link}', $config['http_home_url'] . "engine/download.php?id=" . $row['id'] . $area); $tpl->set('{id}', $row['id']); $tpl->compile('attachment'); $replace_1[] = $tpl->result['attachment']; $tpl->result['attachment'] = str_replace($row['name'], "\\1", $tpl->result['attachment']); $replace_2[] = $tpl->result['attachment']; $tpl->result['attachment'] = ''; } $tpl->clear(); $db->free(); $story = str_replace($find_1, $replace_1, $story); $story = preg_replace($find_2, $replace_2, $story); return $story; }
public function link_forum(array &$row, dle_template &$tpl) { $categories = explode(",", $row['category']); foreach ($categories as $category) { if (intval($this->config['forumid'][$category])) { $cat_id = $category; break; } } //var_dump($cat_id, $categories, $this->config['forumid']);exit(); if (!$this->config['goforum'] || !$this->config['allow_module'] || !$cat_id || !$this->config['show_no_reginstred'] && !$GLOBALS['is_logged']) { return $tpl->set('{link_on_forum}', ""); } if (!intval($GLOBALS['newsid'])) { if (!$this->config['show_short']) { return $tpl->set('{link_on_forum}', ""); } elseif ($this->config['allow_count_short']) { $this->config['show_count'] = 1; } else { $this->config['show_count'] = 0; } } $link_on_forum = $this->config['link_on_forum']; if ($this->config['show_count']) { $this->_db_connect(); switch ($this->config['link_title']) { case "old": $title_forum = preg_replace('/{Post_name}/', $row['title'], $this->config['name_post_on_forum']); $title_forum = $this->db->safesql($title_forum); if ($title_forum == "") { return; } break; case "title": $title_forum = $this->db->safesql(stripslashes($row['title'])); break; default: $this->_db_disconnect(); return false; break; } $this->_convert_charset($title_forum); $topic = $this->db->super_query("SELECT tid, posts FROM " . IPB_PREFIX . "topics WHERE title='{$title_forum}' AND state='open'"); if (empty($topic['tid'])) { $link_on_forum = preg_replace("'\\[count\\](.*?)\\[/count\\]'si", "", $link_on_forum); $count = 0; } else { $count = $topic['posts']; $link_on_forum = preg_replace("'\\[count\\](.*?)\\[/count\\]'si", "\\1", $link_on_forum); } $this->_db_disconnect(); } else { $link_on_forum = preg_replace("'\\[count\\](.*?)\\[/count\\]'si", "", $link_on_forum); } $link_on_forum = str_replace("{count}", $count, $link_on_forum); $link_on_forum = str_replace('{link_on_forum}', $GLOBALS['config']['allow_alt_url'] == "yes" ? $GLOBALS['config']['http_home_url'] . "goforum/post-" . $row['id'] . "/" : $GLOBALS['PHP_SELF'] . "?do=goforum&postid=" . $row['id'], $link_on_forum); $tpl->set('{link_on_forum}', $link_on_forum); return true; }
function msgbox($title, $text) { global $tpl; $tpl_2 = new dle_template(); $tpl_2->dir = TEMPLATE_DIR; $tpl_2->load_template('info.tpl'); $tpl_2->set('{error}', $text); $tpl_2->set('{title}', $title); $tpl_2->compile('info'); $tpl_2->clear(); $tpl->result['info'] .= $tpl_2->result['info']; }
die("Language file not found"); } } else { include_once ROOT_DIR . '/language/' . $config['langs'] . '/website.lng'; } $config['charset'] = $lang['charset'] != '' ? $lang['charset'] : $config['charset']; require_once ENGINE_DIR . '/classes/templates.class.php'; require_once ENGINE_DIR . '/modules/sitelogin.php'; if (!$is_logged) { $member_id['user_group'] = 5; } $rid = intval($_REQUEST['vote_id']); $vote_check = intval($_REQUEST['vote_check']); $nick = $db->safesql($member_id['name']); $vote_skin = $config['skin']; $tpl = new dle_template(); $tpl->dir = ROOT_DIR . '/templates/' . $vote_skin; define('TEMPLATE_DIR', $tpl->dir); @header("Content-type: text/html; charset=" . $config['charset']); if ($_REQUEST['vote_action'] == "vote") { if ($user_group[$member_id['user_group']]['allow_vote']) { if ($is_logged) { $row = $db->super_query("SELECT count(*) as count FROM " . PREFIX . "_vote_result WHERE vote_id='{$rid}' AND name='{$nick}'"); } else { $row = $db->super_query("SELECT count(*) as count FROM " . PREFIX . "_vote_result WHERE vote_id='{$rid}' AND ip='{$_IP}'"); } if (!$row['count'] and count(explode(".", $_IP)) == 4) { $is_voted = false; } else { $is_voted = true; }
public function lastTopics(dle_template $tpl) { if (!$this->config['allow_forum_block'] || !$this->config['allow_module']) { return ''; } if ((int) $this->config['block_cache_time']) { $cache = dle_cache('xen_block_cache_time'); if ($cache) { $cache = unserialize($cache); if (!empty($cache['time']) && $cache['time'] > time() - $this->config['block_cache_time']) { return $cache['data']; } } } $forum_id = ""; if ($this->config['bad_forum_for_block'] && !$this->config['good_forum_for_block']) { $forum_bad = explode(",", $this->config['bad_forum_for_block']); $forum_id = " AND t.node_id NOT IN('" . implode("','", $forum_bad) . "')"; } elseif (!$this->config['bad_forum_for_block'] && $this->config['good_forum_for_block']) { $forum_good = explode(",", $this->config['good_forum_for_block']); $forum_id = " AND t.node_id IN('" . implode("','", $forum_good) . "')"; } if (!(int) $this->config['count_post']) { $this->config['count_post'] = 10; } $sth = $this->db->query('SELECT t.title, t.thread_id, t.last_post_date, t.reply_count, t.view_count, f.title as forum_title, t.node_id, t.last_post_username, t.last_post_user_id FROM ' . F_PREFIX . 'thread AS t LEFT JOIN ' . F_PREFIX . 'node AS f ON f.node_id = t.node_id WHERE discussion_state="visible"' . $forum_id . ' ORDER BY t.last_post_date DESC LIMIT 0, ' . intval($this->config['count_post'])); $forum_url = rtrim($this->options['boardUrl'], "/") . "/"; if (!$this->config['block_rewrite_url']) { $forum_url .= "index.php?"; } $tpl->load_template('block_forum_posts.tpl'); preg_match("'\\[row\\](.*?)\\[/row\\]'si", $tpl->copy_template, $matches); $block_content = ''; while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { $short_name = $title = $this->_convert_encoding($row["title"], true); $row['last_post_username'] = $this->_convert_encoding($row['last_post_username'], true); if (!empty($this->config['length_name']) && dle_strlen($title, $this->DLEConfig['charset']) > $this->config['length_name']) { $short_name = dle_substr($title, 0, $this->config['length_name'], $this->DLEConfig['charset']) . " ..."; } switch (date("d.m.Y", $row["last_post_date"])) { case date("d.m.Y"): $date = date($this->lang['today_in'] . "H:i", $row["last_post_date"]); break; case date("d.m.Y", time() - 86400): $date = date($this->lang['yesterday_in'] . "H:i", $row["last_post_date"]); break; default: $date = date("d.m.Y H:i", $row["last_post_date"]); } $replace = array('{user}' => $this->_convert_encoding($row['last_post_username'], true), '{user_url}' => $forum_url . "members/" . $this->getTitleForUrl($row['last_post_username']) . "." . $row['last_post_user_id'] . "/", '{reply_count}' => $row["reply_count"], '{view_count}' => $row["view_count"], '{full_name}' => $title, '{post_url}' => $forum_url . "threads/" . $this->getTitleForUrl($row['title']) . "." . $row["thread_id"] . "/", '{shot_name_post}' => $short_name, '{forum_name}' => $this->_convert_encoding($row['forum_title'], true), '{forum_url}' => $forum_url . "forums/" . $this->getTitleForUrl($row['forum_title']) . "." . $row["node_id"] . "/", '{date}' => $date); $block_content .= strtr($matches[1], $replace); } $tpl->set_block("'\\[row\\](.*?)\\[/row\\]'si", $block_content); $tpl->compile('block_forum_posts'); $tpl->clear(); if ((int) $this->config['block_cache_time']) { create_cache('xen_block_cache_time', serialize(array('time' => time(), 'data' => $tpl->result['block_forum_posts']))); } return $tpl->result['block_forum_posts']; }
function custom_users($matches = array()) { global $db, $_TIME, $config, $lang, $user_group, $user_conf, $news_date, $member_id, $nav; if (!count($matches)) { return ""; } $yes_no_map = array("yes" => "1", "no" => "0"); $param_str = trim($matches[1]); $thisdate = strtotime(date("Y-m-d H:i:s", $_TIME)); $where = array(); if (preg_match("#template=['\"](.+?)['\"]#i", $param_str, $match)) { $comm_tpl = trim($match[1]); } else { 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[] = "u.user_id >= '" . intval($value[0]) . "' AND u.user_id <= '" . intval($value[1]) . "'"; } else { $temp_array[] = intval($value); } } if (count($temp_array)) { $where_id[] = "u.user_id IN ('" . implode("','", $temp_array) . "')"; } if (count($where_id)) { $custom_id = implode(' OR ', $where_id); $where[] = $custom_id; } } if (preg_match("#group=['\"](.+?)['\"]#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[] = "u.user_group >= '" . intval($value[0]) . "' AND u.user_group <= '" . intval($value[1]) . "'"; } else { $temp_array[] = intval($value); } } if (count($temp_array)) { $where_id[] = "u.user_group IN ('" . implode("','", $temp_array) . "')"; } if (count($where_id)) { $custom_id = implode(' OR ', $where_id); $where[] = $custom_id; } } if (preg_match("#online=['\"](.+?)['\"]#i", $param_str, $match)) { if ($match[1] == "yes") { $where[] = "u.lastdate+1200 > {$_TIME} "; } else { $where[] = "u.lastdate+1200 <= {$_TIME} "; } } if (preg_match("#from=['\"](.+?)['\"]#i", $param_str, $match)) { $user_from = intval($match[1]); $custom_all = $custom_from; } else { $user_from = 0; $custom_all = 0; } if (preg_match("#limit=['\"](.+?)['\"]#i", $param_str, $match)) { $user_limit = intval($match[1]); } else { $user_limit = $config['comm_nummers']; } if (preg_match("#order=['\"](.+?)['\"]#i", $param_str, $match)) { $allowed_order = array('news' => 'news_num', 'comment' => 'comm_num', 'group' => 'user_group', 'lastdate' => 'lastdate', 'regdate' => 'reg_date', 'nick' => 'name', 'rand' => 'RAND()'); if ($allowed_order[$match[1]]) { $user_order = $allowed_order[$match[1]]; } } if (!$user_order) { $user_order = "reg_date"; } if (preg_match("#sort=['\"](.+?)['\"]#i", $param_str, $match)) { $allowed_sort = array('asc' => 'ASC', 'desc' => 'DESC'); if ($allowed_sort[$match[1]]) { $user_sort = $allowed_sort[$match[1]]; } } if (!$user_sort) { $user_order = "ASC"; } if (preg_match("#cache=['\"](.+?)['\"]#i", $param_str, $match)) { $user_cache = $yes_no_map[$match[1]]; } else { $user_cache = "0"; } if (preg_match("#not=['\"](.+?)['\"]#i", $param_str, $match)) { $not_found = $db->safesql($match[1]); } else { $not_found = ""; } if (preg_match("#friends=['\"](.+?)['\"]#i", $param_str, $match)) { $fids = array(); if ($match[1] == "current") { $friend_que = $db->query("SELECT friend_id FROM " . PREFIX . "_users_friends WHERE user_id = '{$member_id['user_id']}' AND approve = '1'"); while ($row = $db->get_row($friend_que)) { $fids[] = $row['friend_id']; } } else { if ($match[1] == "profile") { $friend_que = $db->query("SELECT f.friend_id FROM " . PREFIX . "_users_friends f LEFT JOIN " . PREFIX . "_users u ON ( u.user_id = f.user_id ) WHERE u.name = '{$_REQUEST['user']}' AND f.approve = '1'"); while ($row = $db->get_row($friend_que)) { $fids[] = $row['friend_id']; } } } if (count($fids) > 0) { $where[] = "u.user_id IN ('" . implode("','", $fids) . "')"; } else { $where[] = "u.user_id = '0'"; } } else { $user_friends = false; } if (preg_match("#xfield=['\"](.+?)['\"]#i", $param_str, $match)) { $_temp = explode(",", $match[1]); $_rules = array(); foreach ($_temp as $_temp2) { if (strpos($_temp2, "this.") !== False && isset($member_id)) { $_temp3 = explode(":", $_temp2); $_temp4 = trim(str_replace("this.", "", $_temp3[1])); unset($_temp3); $_thisxf = xfieldsdataload($member_id['xfields']); if (array_key_exists($_temp4, $_thisxf)) { $_rules[] = "u.xfields LIKE '%" . $_temp4 . "|" . $_thisxf[$_temp4] . "%'"; } } else { $_rules[] = "u.xfields LIKE '%" . str_replace(":", "|", $_temp2) . "%'"; } } if (count($_rules) > 0) { $where[] = "( " . implode(" AND ", $_rules) . " )"; $use_xfield = True; } } else { $use_xfield = False; } $user_yes = false; $user_cols = array("email", "name", "user_id", "news_num", "comm_num", "user_group", "lastdate", "reg_date", "signature", "foto", "fullname", "land", "logged_ip"); if ($user_conf['sel_xfields']) { $user_cols[] = "xfields"; } $_WHERE = count($where) > 0 ? " WHERE " . implode(' AND ', $where) : ""; $build_navigation = false; if (isset($_GET['cstart'])) { $cstart = intval($_GET['cstart']); } else { $cstart = 0; } if (preg_match("#navigation=['\"](.+?)['\"]#i", $param_str, $match)) { if ($match[1] == "yes" and $url_page !== false) { $build_navigation = true; $custom_limit = $user_limit; //if ( $cstart > 10 ) $config['allow_cache'] = false; if ($cstart) { $cstart = $cstart - 1; $cstart = $cstart * $custom_limit + $user_from; $user_from = $cstart; } $count_que = $db->super_query("SELECT COUNT(u.name) as total FROM " . PREFIX . "_users u{$_WHERE} ORDER BY {$user_order} {$user_sort}"); $count_all = $count_que['total']; } else { $build_navigation = false; } } else { $build_navigation = false; } $user_sql = "SELECT u." . implode(", u.", $user_cols) . " FROM " . PREFIX . "_users u{$_WHERE} ORDER BY {$user_order} {$user_sort} LIMIT {$user_from},{$user_limit}"; $user_que = $db->query($user_sql); if ($user_cache) { $user_cacheid = $param_str . $user_sql . $member_id['user_group'] . $build_navigation . $cstart . implode("|", $user_conf); $cache_content = dle_cache("news_ucustom", $user_cacheid, true); } else { $cache_content = false; } if (!$cache_content) { $tpl = new dle_template(); $tpl->dir = TEMPLATE_DIR; // Build navigation - start $url_page =& $nav['url_page']; $user_query =& $nav['user_query']; if ($build_navigation and $count_all) { $tpl->load_template('navigation.tpl'); $no_prev = false; $no_next = false; if (isset($_GET['cstart'])) { $cstart = intval($_GET['cstart']); } else { $cstart = 1; } if (isset($cstart) and $cstart != "" and $cstart > 1) { $prev = $cstart - 1; if ($config['allow_alt_url']) { $prev_page = $prev == 1 ? $url_page . "/" : $url_page . "/page/" . $prev . "/"; $tpl->set_block("'\\[prev-link\\](.*?)\\[/prev-link\\]'si", "<a href=\"" . $prev_page . "\">\\1</a>"); } else { $prev_page = $prev == 1 ? $PHP_SELF . "?" . $user_query : $PHP_SELF . "?cstart=" . $prev . "&" . $user_query; $tpl->set_block("'\\[prev-link\\](.*?)\\[/prev-link\\]'si", "<a href=\"" . $prev_page . "\">\\1</a>"); } } else { $tpl->set_block("'\\[prev-link\\](.*?)\\[/prev-link\\]'si", "<span>\\1</span>"); $no_prev = TRUE; } if ($custom_limit) { $pages = ""; if ($count_all > $custom_limit) { $enpages_count = @ceil($count_all / $custom_limit); if ($enpages_count <= 10) { for ($j = 1; $j <= $enpages_count; $j++) { if ($j != $cstart) { if ($config['allow_alt_url']) { $pages .= $j == 1 ? "<a href=\"" . $url_page . "/\">{$j}</a> " : "<a href=\"" . $url_page . "/page/" . $j . "/\">{$j}</a>"; } else { $pages .= $j == 1 ? "<a href=\"{$PHP_SELF}?{$user_query}\">{$j}</a> " : "<a href=\"{$PHP_SELF}?{$user_query}&cstart={$j}\">{$j}</a>"; } } else { $pages .= "<span>{$j}</span> "; } } } else { $start = 1; $end = 10; $nav_prefix = "<span class=\"nav_ext\">{$lang['nav_trennen']}</span> "; if ($cstart > 0) { if ($cstart > 6) { $start = $cstart - 4; $end = $start + 8; if ($end >= $enpages_count) { $start = $enpages_count - 9; $end = $enpages_count - 1; $nav_prefix = ""; } else { $nav_prefix = "<span class=\"nav_ext\">{$lang['nav_trennen']}</span> "; } } } if ($start >= 2) { $pages .= $config['allow_alt_url'] ? "<a href=\"" . $url_page . "/\">1</a> <span class=\"nav_ext\">{$lang['nav_trennen']}</span> " : "<a href=\"{$PHP_SELF}?{$user_query}\">1</a> <span class=\"nav_ext\">{$lang['nav_trennen']}</span> "; } for ($j = $start; $j <= $end; $j++) { if ($j != $cstart) { if ($config['allow_alt_url']) { $pages .= $j == 1 ? "<a href=\"" . $url_page . "/\">{$j}</a> " : "<a href=\"" . $url_page . "/page/" . $j . "/\">{$j}</a> "; } else { $pages .= $j == 1 ? "<a href=\"{$PHP_SELF}?{$user_query}\">{$j}</a> " : "<a href=\"{$PHP_SELF}?{$user_query}&cstart={$j}\">{$j}</a> "; } } else { $pages .= "<span>{$j}</span> "; } } if ($cstart != $enpages_count) { $pages .= $config['allow_alt_url'] ? $nav_prefix . "<a href=\"" . $url_page . "/page/{$enpages_count}/\">{$enpages_count}</a>" : $nav_prefix . "<a href=\"{$PHP_SELF}?{$user_query}&cstart={$enpages_count}\">{$enpages_count}</a>"; } else { $pages .= "<span>{$enpages_count}</span> "; } } } $tpl->set('{pages}', $pages); } if ($custom_limit and $custom_limit < $count_all and $cstart < $enpages_count) { $next_page = $cstart + 1; $next = $config['allow_alt_url'] ? $url_page . '/page/' . $next_page . '/' : $PHP_SELF . "?" . $user_query . "&cstart=" . $next_page; $tpl->set_block("'\\[next-link\\](.*?)\\[/next-link\\]'si", "<a href=\"" . $next . "\">\\1</a>"); } else { $tpl->set_block("'\\[next-link\\](.*?)\\[/next-link\\]'si", "<span>\\1</span>"); $no_next = TRUE; } if (!$no_prev or !$no_next) { $tpl->compile('navi'); } $tpl->clear(); } // Build navigation - end $tpl->load_template($comm_tpl . '.tpl'); while ($user_row = $db->get_row($user_que)) { $user_yes = true; $news_row = false; if ($user_conf['sel_news_info']) { $news_row = $db->super_query("SELECT id, title, category, alt_name, date FROM " . PREFIX . "_post WHERE autor = '{$user_row['name']}' ORDER BY date DESC LIMIT 0,1"); if ($news_row) { if (preg_match("#\\{news-title limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches)) { $count = intval($matches[1]); $tpl->set($matches[0], user_title($count, $news_row['title'])); } else { $tpl->set('{news-title}', strip_tags(stripslashes($news_row['title']))); } $tpl->set('{news-link}', user_fulllink($news_row['post_id'], $news_row['category'], $news_row['alt_name'], $news_row['pdate'])); $tpl->set('{news-cat}', get_categories($news_row['category'])); $news_date = strtotime($news_row['date']); $tpl->copy_template = preg_replace_callback("#\\{news-date=(.+?)\\}#i", "user_formdate", $tpl->copy_template); $tpl->set('{news-date}', $news_row['date']); $tpl->set('{news-id}', $news_row['id']); } } if ($user_row['lastdate'] + 1200 > $_TIME) { $tpl->set('[online]', ""); $tpl->set('[/online]', ""); $tpl->set_block("'\\[offline\\](.*?)\\[/offline\\]'si", ""); } else { $tpl->set('[offline]', ""); $tpl->set('[/offline]', ""); $tpl->set_block("'\\[online\\](.*?)\\[/online\\]'si", ""); } $news_date = $user_row['reg_date']; $tpl->copy_template = preg_replace_callback("#\\{reg-date=(.+?)\\}#i", "user_formdate", $tpl->copy_template); $tpl->set('{reg-date}', date("d.m.Y H:i:s", $news_date)); $news_date = $user_row['lastdate']; $tpl->copy_template = preg_replace_callback("#\\{last-date=(.+?)\\}#i", "user_formdate", $tpl->copy_template); $tpl->set('{last-date}', date("d.m.Y H:i:s", $news_date)); if (count(explode("@", $user_row['foto'])) == 2) { $tpl->set('{foto}', 'http://www.gravatar.com/avatar/' . md5(trim($user_row['foto'])) . '?s=' . intval($user_group[$user_row['user_group']]['max_foto'])); } else { if ($user_row['foto'] && $config['version_id'] < "10.5") { if (file_exists(ROOT_DIR . "/uploads/fotos/" . $user_row['foto'])) { $tpl->set('{foto}', $config['http_home_url'] . "uploads/fotos/" . $comm_row['foto']); } else { $tpl->set('{foto}', "{THEME}/dleimages/noavatar.png"); } } else { if ($user_row['foto'] && $config['version_id'] >= "10.5") { $tpl->set('{foto}', $user_row['foto']); } else { $tpl->set('{foto}', "{THEME}/dleimages/noavatar.png"); } } } if ($user_conf['sel_xfields']) { $xf = xfieldsdataload($user_row['xfields']); foreach ($xf as $xf_key => $xf_val) { $xf_key = preg_quote($xf_key, "'"); $tpl->set("{xfield-" . $xf_key . "}", $xf_val); } } else { $tpl->set_block("'{xfield-(.*?)}'si", ""); } $tpl->set("{name}", $user_row['name']); $tpl->set("{name-colored}", $user_group[$user_row['user_group']]['group_prefix'] . $user_row['name'] . $user_group[$user_row['user_group']]['group_suffix']); $tpl->set("{name-url}", $config['allow_alt_url'] ? $config['http_home_url'] . "user/" . urlencode($user_row['name']) : $config['http_home_url'] . "index.php?subaction=userinfo&user="******"{name-popup}", $config['allow_alt_url'] ? "ShowProfile('" . urlencode($user_row['name']) . "', '" . $config['http_home_url'] . "user/" . urlencode($user_row['name']) . "/', '1'); return false;" : "ShowProfile('" . urlencode($user_row['name']) . "', '" . $config['http_home_url'] . "index.php?subaction=userinfo&user="******"', '0'); return false;"); $tpl->set("{allnews-url}", $config['allow_alt_url'] ? $config['http_home_url'] . "user/" . urlencode($user_row['name']) . "/news/" : $config['http_home_url'] . "index.php?subaction=allnews&user="******"{allcomm-url}", $config['http_home_url'] . "index.php?do=lastcomments&userid=" . urlencode($user_row['user_id'])); $tpl->set("{pm-url}", $config['http_home_url'] . "index.php?do=pm&doaction=newpm&user="******"{email-url}", $config['http_home_url'] . "index.php?do=feedback&user="******"{news-num}", intval($user_row['news_num'])); $tpl->set("{comm-num}", intval($user_row['comm_num'])); $tpl->set("{email}", $user_row['email']); $tpl->set("{ip}", $user_row['logged_ip']); $tpl->set("{id}", $user_row['user_id']); $tpl->set("{land}", $user_row['land']); $tpl->set('{info}', $user_row['info']); $tpl->set('{sign}', $user_row['signature']); $tpl->set("{full-name}", $user_row['fullname']); $tpl->set("{group}", $user_group[$user_row['user_group']]['group_name']); $tpl->set("{group-id}", $user_group[$user_row['user_group']]['id']); $tpl->set("{group-colored}", $user_group[$user_row['user_group']]['group_prefix'] . $user_group[$user_row['user_group']]['group_name'] . $user_group[$user_row['user_group']]['group_suffix']); $tpl->set("{group-icon}", $user_group[$user_row['user_group']]['icon']); $tpl->compile("content"); $tpl->result['content'] = preg_replace("#\\{xfield-(.*?)\\}#is", "", $tpl->result['content']); $tpl->result['content'] = preg_replace("#\\[user-group=" . $user_row['user_group'] . "\\](.*?)\\[/user-group\\]#is", "\\1", $tpl->result['content']); $tpl->result['content'] = preg_replace("#\\[user-group=([0-9])\\](.*?)\\[/user-group\\]#is", "", $tpl->result['content']); $tpl->result['content'] = preg_replace("#\\[news\\](.*?)\\[/news\\]#is", $news_row != false ? "\\1" : "", $tpl->result['content']); } if (!$user_yes) { $tpl->result['content'] = $not_found; } if ($build_navigation) { $tpl->result['content'] = $tpl->result['content'] . $tpl->result['navi']; } $tpl->result['content'] = str_replace("{THEME}", $config['http_home_url'] . "templates/" . $config['skin'] . "/", $tpl->result['content']); if ($user_cache) { create_cache("news_ucustom", $tpl->result['content'], $user_cacheid, true); } return $tpl->result['content']; } else { return $cache_content; } }