Exemplo n.º 1
0
 protected function _fillTmpl($vars = array(), $blocks = array())
 {
     foreach ($vars as $key => $val) {
         if (is_array($val)) {
             foreach ($val as $key => $value) {
                 $this->_tpl->set("{{$key}}", $value);
             }
             continue;
         }
         $this->_tpl->set("{{$key}}", $val);
     }
     foreach ($blocks as $key => $value) {
         if (is_bool($value) || is_integer($value)) {
             $this->_tpl->set_block("#\\[{$key}\\](.+?)\\[/{$key}\\]#si", $value ? '\\1' : '');
         } else {
             $this->_tpl->set_block("#\\[{$key}\\](.+?)\\[/{$key}\\]#si", $value);
         }
     }
 }
Exemplo n.º 2
0
 unset($original_img);
 //конец показа оригинальной картинки
 //Показ рейтинга
 if ($rowb['allow_rate']) {
     if ($config['short_rating'] and $user_group[$member_id['user_group']]['allow_rating']) {
         $tplb->set('{rating}', ShortRating($rowb['id'], $rowb['rating'], $rowb['vote_num'], 1));
     } else {
         $tplb->set('{rating}', ShortRating($rowb['id'], $rowb['rating'], $rowb['vote_num'], 0));
     }
     $tplb->set('{vote-num}', $rowb['vote_num']);
     $tplb->set('[rating]', "");
     $tplb->set('[/rating]', "");
 } else {
     $tplb->set('{rating}', "");
     $tplb->set('{vote-num}', "");
     $tplb->set_block("'\\[rating\\](.*?)\\[/rating\\]'si", "");
 }
 //Конец показа рейтинга
 /* понеслась, куча тегов.. */
 if ($config['allow_alt_url'] == "yes") {
     $go_page = $config['http_home_url'] . "user/" . urlencode($rowb['autor']) . "/";
 } else {
     $go_page = "{$PHP_SELF}?subaction=userinfo&user="******"' . $go_page . '" title="' . urlencode($rowb['autor']) . '">');
 $tplb->set('[/profile]', '</a>');
 $tplb->set('{login}', $rowb['autor']);
 $tplb->set('{author}', "<a onclick=\"ShowProfile('" . urlencode($rowb['autor']) . "', '" . $go_page . "', '" . $user_group[$member_id['user_group']]['admin_editusers'] . "'); return false;\" title=\"" . urlencode($rowb['autor']) . "\" href=\"" . $go_page . "\">" . $rowb['autor'] . "</a>");
 if (date('Ymd', $rowb['date']) == date('Ymd', $_TIME)) {
     $tplb->set('{date}', $lang['time_heute'] . langdate(", H:i", $rowb['date']));
 } elseif (date('Ymd', $rowb['date']) == date('Ymd', $_TIME - 86400)) {
Exemplo n.º 3
0
         }
     }
 }
 $tpl->set('{subj}', $subj);
 $tpl->set('{text}', stripslashes($text));
 $tpl->set('{author}', $member_id['name']);
 $tpl->set('[reply]', "<a href=\"#\">");
 $tpl->set('[/reply]', "</a>");
 $tpl->set('[del]', "<a href=\"#\">");
 $tpl->set('[/del]', "</a>");
 $tpl->set('[ignore]', "<a href=\"#\">");
 $tpl->set('[/ignore]', "</a>");
 $tpl->set('[complaint]', "<a href=\"#\">");
 $tpl->set('[/complaint]', "</a>");
 if ($member_id['signature'] and $user_group[$member_id['user_group']]['allow_signature']) {
     $tpl->set_block("'\\[signature\\](.*?)\\[/signature\\]'si", "\\1");
     $tpl->set('{signature}', stripslashes($member_id['signature']));
 } else {
     $tpl->set_block("'\\[signature\\](.*?)\\[/signature\\]'si", "");
 }
 if ($member_id['icq']) {
     $tpl->set('{icq}', stripslashes($member_id['icq']));
 } else {
     $tpl->set('{icq}', '--');
 }
 if ($user_group[$member_id['user_group']]['icon']) {
     $tpl->set('{group-icon}', "<img src=\"" . $user_group[$member_id['user_group']]['icon'] . "\" border=\"0\" alt=\"\" />");
 } else {
     $tpl->set('{group-icon}', "");
 }
 $tpl->set('{group-name}', $user_group[$member_id['user_group']]['group_prefix'] . $user_group[$member_id['user_group']]['group_name'] . $user_group[$member_id['user_group']]['group_suffix']);
Exemplo n.º 4
0
    $tpl->set('{favorite-count}', '0');
}
if (count(explode("@", $member_id['foto'])) == 2) {
    $tpl->set('{foto}', 'http://www.gravatar.com/avatar/' . md5(trim($member_id['foto'])) . '?s=' . intval($user_group[$member_id['user_group']]['max_foto']));
} else {
    if ($member_id['foto'] and file_exists(ROOT_DIR . "/uploads/fotos/" . $member_id['foto'])) {
        $tpl->set('{foto}', $config['http_home_url'] . "uploads/fotos/" . $member_id['foto']);
    } else {
        $tpl->set('{foto}', "{THEME}/dleimages/noavatar.png");
    }
}
if ($user_group[$member_id['user_group']]['allow_admin']) {
    $tpl->set('[admin-link]', "");
    $tpl->set('[/admin-link]', "");
} else {
    $tpl->set_block("'\\[admin-link\\](.*?)\\[/admin-link\\]'si", "");
}
if ($config['allow_alt_url'] == "yes") {
    $tpl->set('{profile-link}', $config['http_home_url'] . "user/" . urlencode($member_id['name']) . "/");
    $tpl->set('{stats-link}', $config['http_home_url'] . "statistics.html");
    $tpl->set('{addnews-link}', $config['http_home_url'] . "addnews.html");
    $tpl->set('{favorites-link}', $config['http_home_url'] . "favorites/");
    $tpl->set('{newposts-link}', $config['http_home_url'] . "newposts/");
} else {
    $tpl->set('{profile-link}', $PHP_SELF . "?subaction=userinfo&user="******"?do=stats");
    $tpl->set('{addnews-link}', $PHP_SELF . "?do=addnews");
    $tpl->set('{favorites-link}', $PHP_SELF . "?do=favorites");
    $tpl->set('{newposts-link}', $PHP_SELF . "?subaction=newposts");
}
$tpl->compile('login_panel');
Exemplo n.º 5
0
 unset($news_seiten);
 if ($anzahl_seiten > 1) {
     $tpl2 = new dle_template();
     $tpl2->dir = TEMPLATE_DIR;
     $tpl2->load_template('splitnewsnavigation.tpl');
     if ($news_page < $anzahl_seiten) {
         $pages = $news_page + 1;
         if ($config['allow_alt_url']) {
             $nextpage = "<a href=\"" . $short_link . "page," . $pages . "," . $row['alt_name'] . ".html\">";
         } else {
             $nextpage = "<a href=\"{$PHP_SELF}?newsid=" . $row['id'] . "&amp;news_page=" . $pages . "\">";
         }
         $tpl2->set('[next-link]', $nextpage);
         $tpl2->set('[/next-link]', "</a>");
     } else {
         $tpl2->set_block("'\\[next-link\\](.*?)\\[/next-link\\]'si", "<span>\\1</span>");
     }
     if ($news_page > 1) {
         $pages = $news_page - 1;
         if ($config['allow_alt_url']) {
             if ($pages == 1) {
                 $prevpage = "<a href=\"" . $full_link . "\">";
             } else {
                 $prevpage = "<a href=\"" . $short_link . "page," . $pages . "," . $row['alt_name'] . ".html\">";
             }
         } else {
             if ($pages == 1) {
                 $prevpage = "<a href=\"" . $full_link . "\">";
             } else {
                 $prevpage = "<a href=\"{$PHP_SELF}?newsid=" . $row['id'] . "&amp;news_page=" . $pages . "\">";
             }
Exemplo n.º 6
0
 /**
  * Generate block with last post in forum
  *
  * @param dle_template $tpl
  * @return string
  */
 public function last_forum_posts(dle_template &$tpl)
 {
     if (!$this->config['allow_module'] || !$this->config['allow_forum_block']) {
         return '';
     }
     if ((int) $this->config['block_new_cache_time'] && file_exists(ENGINE_DIR . "/cache/last_forum_posts.tmp") && time() - filemtime(ENGINE_DIR . "/cache/last_forum_posts.tmp") > (int) $this->config['block_new_cache_time'] && ($cache = dle_cache("last_forum_posts"))) {
         $tpl->result['last_forum_posts'] = $cache;
     }
     $this->_db_connect();
     if ($this->config['bad_forum_for_block'] != "") {
         $forum_bad = explode(",", $this->config['bad_forum_for_block']);
         $forum_id = " WHERE forum_id NOT IN('" . implode("','", $forum_bad) . "')";
     } elseif ($this->config['good_forum_for_block'] != "") {
         $forum_good = explode(",", $this->config['good_forum_for_block']);
         $forum_id = " WHERE forum_id IN('" . implode("','", $forum_good) . "')";
     } else {
         $forum_id = "";
     }
     if ($forum_id != "") {
         $forum_id .= " AND state='open' AND approved=1";
     } else {
         $forum_id .= " WHERE state='open' AND approved=1";
     }
     if (!(int) $this->config['count_post']) {
         die("Не указано количество постов для блока сообщений с форума");
     }
     $result = $this->db->query("SELECT t.posts, \n                                           t.views, \n                                           t.forum_id, \n                                           t.tid, \n                                           t.title, \n                                           t.title_seo, \n                                           t.last_post, \n                                           t.last_poster_name, \n                                           t.last_poster_id, \n                                           t.starter_name, \n                                           t.starter_id, \n                                           f.name AS forum_name, \n                                           t.seo_last_name, \n                                           t.seo_first_name, \n                                           f.name_seo AS fname_seo \n                                   FROM " . IPB_PREFIX . "topics AS t\n    \t\t\t\t\t\t  LEFT JOIN " . IPB_PREFIX . "forums AS f\n    \t\t\t\t\t\t  ON f.id=t.forum_id\n    \t\t\t\t\t\t  " . $forum_id . " ORDER BY t.last_post DESC LIMIT 0 ," . (int) $this->config['count_post']);
     $tpl->load_template('block_forum_posts.tpl');
     preg_match("'\\[row\\](.*?)\\[/row\\]'si", $tpl->copy_template, $matches);
     while ($row = $this->db->get_row($result)) {
         foreach ($row as &$value) {
             $this->_convert_charset($value, true);
         }
         $short_name = $name = $row["title"];
         quoted_printable_decode($name);
         if ($this->config['leght_name']) {
             if (strlen($name) > $this->config['leght_name']) {
                 if (function_exists('mb_substr')) {
                     $short_name = mb_substr($name, 0, $this->config['leght_name'], DLE_CHARSET) . " ...";
                 } else {
                     $short_name = substr($name, 0, $this->config['leght_name']) . " ...";
                 }
             }
         }
         //$server_offset = timezone_offset_get();
         if (isset($this->member['time_offset']) && (int) $this->member['time_offset'] && !(int) $this->config['block_new_cache_time']) {
             $row["last_post"] += ($this->member['time_offset'] - $this->IPBConfig('time_offset')) * 3600;
         }
         /*
                     else if ((int)$this->IPBConfig('time_offset'))
                     {
                         //$row["last_post"] += $this->IPBConfig('time_offset')*3600;
                     }*/
         switch (date("d.m.Y", $row["last_post"])) {
             case date("d.m.Y"):
                 $date = date($this->lang['today_in'] . "H:i", $row["last_post"]);
                 break;
             case date("d.m.Y", time() - 86400):
                 $date = date($this->lang['yestoday_in'] . "H:i", $row["last_post"]);
                 break;
             default:
                 $date = date("d.m.Y H:i", $row["last_post"]);
         }
         $replace = array('{user}' => $row['last_poster_name'], '{user_url}' => $this->config['forum_block_alt_url'] ? $this->ipb_config['board_url'] . "/user/{$row['last_poster_id']}-{$row['seo_last_name']}/" : $this->ipb_config['board_url'] . "/index.php?showuser="******"/user/{$row['starter_id']}-{$row['seo_first_name']}/" : $this->ipb_config['board_url'] . "/index.php?showuser="******"posts"], '{view_count}' => $row["views"], '{full_name}' => $name, '{author}' => $row['starter_name'], '{forum}' => $row['forum_name'], '{forum_url}' => $this->config['forum_block_alt_url'] ? $this->ipb_config['board_url'] . "/forum/{$row['forum_id']}-{$row['fname_seo']}/" : $this->ipb_config['board_url'] . "/index.php?showforum=" . $row['forum_id'], '{post_url}' => $this->config['forum_block_alt_url'] ? $this->ipb_config['board_url'] . "/topic/{$row['tid']}-{$row['title_seo']}/page__view__getnewpost" : $this->ipb_config['board_url'] . "/index.php?showtopic=" . $row["tid"] . "&amp;view=getnewpost", '{shot_name_post}' => $short_name, '{date}' => $date);
         $tpl->copy_template = strtr($tpl->copy_template, $replace);
         $tpl->copy_template = preg_replace("'\\[row\\](.*?)\\[/row\\]'si", "\\1\n" . $matches[0], $tpl->copy_template);
     }
     $tpl->set_block("'\\[row\\](.*?)\\[/row\\]'si", "");
     $tpl->compile('block_forum_posts');
     $tpl->clear();
     $this->db->free();
     $this->_db_disconnect();
     if ((int) $this->config['block_new_cache_time']) {
         create_cache("last_forum_posts", $tpl->result['block_forum_posts']);
     }
 }
Exemplo n.º 7
0
     $descr = $lang['rules_edit'];
 }
 if ($_POST['allow_template']) {
     $dle_module = "static";
     if ($_POST['static_tpl'] == "") {
         if (@is_file($tpl->dir . "/preview.tpl")) {
             $tpl->load_template('preview.tpl');
         } else {
             $tpl->load_template('static.tpl');
         }
     } else {
         $tpl->load_template($_POST['static_tpl'] . '.tpl');
     }
     $tpl->set('[static-preview]', "");
     $tpl->set('[/static-preview]', "");
     $tpl->set_block("'\\[full-preview\\](.*?)\\[/full-preview\\]'si", "");
     $tpl->set_block("'\\[short-preview\\](.*?)\\[/short-preview\\]'si", "");
     $tpl->set('{static}', stripslashes($template));
     $tpl->set('{description}', $descr);
     $tpl->set('{views}', "0");
     $tpl->set('{pages}', "");
     $tpl->set('{date}', "--");
     $tpl->copy_template = preg_replace("#\\{date=(.+?)\\}#i", "", $tpl->copy_template);
     $tpl->set('[print-link]', "<a href=#>");
     $tpl->set('[/print-link]', "</a>");
     $tpl->copy_template = "<fieldset style=\"border-style:solid; border-width:1; border-color:black;\"><legend> <span style=\"font-size: 10px; font-family: Verdana\">{$lang['preview_static']}</span> </legend>" . $tpl->copy_template . "</fieldset>";
     $tpl->compile('template');
     $tpl->result['template'] = str_replace("[hide]", "", str_replace("[/hide]", "", $tpl->result['template']));
     $tpl->result['template'] = str_replace('{THEME}', $config['http_home_url'] . 'templates/' . $config['skin'], $tpl->result['template']);
     echo $tpl->result['template'];
 } else {
Exemplo n.º 8
0
 private function _lastPosts_block(dle_template &$tpl)
 {
     $cache = '';
     if ($this->config['vb_block_new_cache_time'] && function_exists('dle_cache')) {
         $block_time = get_vars('vb_block_new_time');
         if (time() - $block_time < $this->config['vb_block_new_cache_time']) {
             $cache = dle_cache('vb_block_new_cache');
         }
     }
     if (!$cache) {
         $this->_db_connect();
         if ($this->config['vb_block_new_badf']) {
             $forum_bad = explode(",", $this->config['vb_block_new_badf']);
             $forum_id = " WHERE th.forumid NOT IN('" . implode("','", $forum_bad) . "') AND th.open=1 AND th.visible=1";
         } else {
             if ($this->config['vb_block_new_goodf']) {
                 $forum_good = explode(",", $this->config['vb_block_new_goodf']);
                 $forum_id = " WHERE th.forumid IN('" . implode("','", $forum_good) . "') AND th.open=1 AND th.visible=1";
             } else {
                 $forum_id = " WHERE th.open=1 AND th.visible=1";
             }
         }
         $result = $this->db->query("SELECT th.replycount, th.views, th.threadid, th.title, th.lastpost, th.lastposter, p.userid, f.title AS forum_title, f.forumid FROM " . VB_PREFIX . "thread AS th\n                                LEFT JOIN " . VB_PREFIX . "forum AS f\n                                ON f.forumid=th.forumid\n                                LEFT OUTER JOIN " . VB_PREFIX . "post AS p\n                                ON p.postid=th.lastpostid\n                                " . $forum_id . " ORDER BY lastpost DESC LIMIT 0 ," . $this->config['vb_block_new_count_post']);
         $tpl->load_template('block_forum_posts.tpl');
         preg_match("'\\[row\\](.*?)\\[/row\\]'si", $tpl->copy_template, $matches);
         while ($row = $this->db->get_row($result)) {
             if (VB_CHARSET && VB_CHARSET != DLE_CHARSET) {
                 $row["title"] = iconv(VB_CHARSET, DLE_CHARSET, $row["title"]);
                 $row['forum_title'] = iconv(VB_CHARSET, DLE_CHARSET, $row['forum_title']);
                 $row['lastposter'] = iconv(VB_CHARSET, DLE_CHARSET, $row['lastposter']);
             }
             $short_name = $row["title"];
             if ($this->config['vb_block_new_leght_name'] && iconv_strlen($row["title"], DLE_CHARSET) > $this->config['vb_block_new_leght_name']) {
                 $short_name = iconv_substr($row["title"], 0, $this->config['vb_block_new_leght_name'], DLE_CHARSET) . " ...";
             }
             $row["lastpost"] = $row["lastpost"] + $GLOBALS['config']['date_adjust'] * 60;
             switch (date("d.m.Y", $row["lastpost"])) {
                 case date("d.m.Y"):
                     $date = date($this->lang['today_in'] . "H:i", $row["lastpost"]);
                     break;
                 case date("d.m.Y", time() - 86400):
                     $date = date($this->lang['yestoday_in'] . "H:i", $row["lastpost"]);
                     break;
                 default:
                     $date = date("d.m.Y H:i", $row["lastpost"]);
                     break;
             }
             $replace = array('{user}' => $row['lastposter'], '{user_url}' => $this->vb_config['bburl'] . "/member.php?u=" . $row['userid'], '{forum_url}' => $this->vb_config['bburl'] . "/forumdisplay.php?f=" . $row['forumid'], '{forum}' => $row['forum_title'], '{reply_count}' => $row["replycount"], '{view_count}' => $row["views"], '{full_name}' => $row["title"], '{post_url}' => $this->vb_config['bburl'] . "/showthread.php?goto=newpost&amp;t=" . $row["threadid"], '{shot_name_post}' => $short_name, '{date}' => $date);
             $tpl->copy_template = strtr($tpl->copy_template, $replace);
             $tpl->copy_template = preg_replace("'\\[row\\](.*?)\\[/row\\]'si", "\\1\n" . $matches[0], $tpl->copy_template);
         }
         $tpl->set_block("'\\[row\\](.*?)\\[/row\\]'si", "");
         $tpl->compile('block_forum_posts');
         $tpl->clear();
         $this->db->free();
         if ((int) $this->config['vb_block_new_cache_time'] && function_exists('create_cache')) {
             create_cache("vb_block_new_cache", $tpl->result['block_forum_posts']);
             set_vars('vb_block_new_time', TIMENOW);
         }
     } else {
         $tpl->result['block_forum_posts'] = $cache;
     }
 }
Exemplo n.º 9
0
$entry = "";
for ($i = 0; $i < sizeof($body); $i++) {
    $num = $answer[$i]['count'];
    ++$pn;
    if ($pn > 5) {
        $pn = 1;
    }
    if (!$num) {
        $num = 0;
    }
    if ($max != 0) {
        $proc = 100 * $num / $max;
    } else {
        $proc = 0;
    }
    $proc = round($proc, 2);
    $entry .= "<div class=\"vote\">{$body[$i]} - {$num} ({$proc}%)</div><div class=\"voteprogress\"><span class=\"vote{$pn}\" style=\"width:" . intval($proc) . "%;\">{$proc}%</span></div>\n";
}
$entry = "<div id=\"dle-vote\">{$entry}</div>";
$tpl->load_template('vote.tpl');
$tpl->set('{list}', $entry);
$tpl->set('{vote_id}', $rid);
$tpl->set('{title}', $title);
$tpl->set('{votes}', $max);
$tpl->set('[voteresult]', '');
$tpl->set('[/voteresult]', '');
$tpl->set_block("'\\[votelist\\].*?\\[/votelist\\]'si", "");
$tpl->compile('vote');
$db->close();
$tpl->result['vote'] = str_replace('{THEME}', $config['http_home_url'] . 'templates/' . $vote_skin, $tpl->result['vote']);
echo $tpl->result['vote'];
Exemplo n.º 10
0
    $my_cat_link = stripslashes(implode(', ', $my_cat_link));
}
$dle_module = "main";
if (@is_file($tpl->dir . "/preview.tpl")) {
    $tpl->load_template('preview.tpl');
} else {
    $tpl->load_template('shortstory.tpl');
}
if ($parse->not_allowed_text) {
    $tpl->copy_template = $lang['news_err_39'];
}
$tpl->copy_template = preg_replace("#\\{custom(.+?)\\}#i", "", $tpl->copy_template);
$tpl->template = preg_replace("#\\{custom(.+?)\\}#i", "", $tpl->template);
$tpl->set('[short-preview]', "");
$tpl->set('[/short-preview]', "");
$tpl->set_block("'\\[full-preview\\](.*?)\\[/full-preview\\]'si", "");
$tpl->set_block("'\\[static-preview\\](.*?)\\[/static-preview\\]'si", "");
$tpl->set('{title}', $title);
if (preg_match("#\\{title limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches)) {
    $count = intval($matches[1]);
    $title = strip_tags($title);
    if ($count and dle_strlen($title, $config['charset']) > $count) {
        $title = dle_substr($title, 0, $count, $config['charset']);
        if ($temp_dmax = dle_strrpos($title, ' ', $config['charset'])) {
            $title = dle_substr($title, 0, $temp_dmax, $config['charset']);
        }
    }
    $tpl->set($matches[0], $title);
}
if (!count($_REQUEST['catlist'])) {
    $_REQUEST['catlist'] = array();
Exemplo n.º 11
0
    $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]', '');
}
$list = "<div id=\"dle-poll-list-{$row['id']}\">";
if (!$log['count'] and $user_group[$member_id['user_group']]['allow_poll']) {
    if (!$poll['multiple']) {
        for ($v = 0; $v < sizeof($body); $v++) {
            if (!$v) {
                $sel = "checked=\"checked\"";
            } else {
                $sel = "";
Exemplo n.º 12
0
		/**
		 * Метод подхватывает 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];
		}
Exemplo n.º 13
0
 }
 if (strpos($config['http_home_url'], "//") === 0) {
     $return_domain = "http:" . $config['http_home_url'];
 } elseif (strpos($config['http_home_url'], "/") === 0) {
     $return_domain = "http://" . $_SERVER['HTTP_HOST'] . $config['http_home_url'];
 } else {
     $return_domain = $config['http_home_url'];
 }
 if ($social_config['vk']) {
     $social_params = array('client_id' => $social_config['vkid'], 'redirect_uri' => $return_domain . "index.php?do=auth-social&provider=vk", 'scope' => 'offline,wall,email', 'state' => $_SESSION['state'], 'response_type' => 'code');
     $vk_url = 'http://oauth.vk.com/authorize' . '?' . http_build_query($social_params, '', '&amp;');
     $tpl->set('[vk]', "");
     $tpl->set('[/vk]', "");
     $tpl->set('{vk_url}', $vk_url);
 } else {
     $tpl->set_block("'\\[vk\\](.*?)\\[/vk\\]'si", "");
     $tpl->set('{vk_url}', '');
 }
 if ($social_config['od']) {
     $social_params = array('client_id' => $social_config['odid'], 'redirect_uri' => $return_domain . "index.php?do=auth-social&provider=od", 'state' => $_SESSION['state'], 'response_type' => 'code');
     $odnoklassniki_url = 'http://www.odnoklassniki.ru/oauth/authorize' . '?' . http_build_query($social_params, '', '&amp;');
     $tpl->set('[odnoklassniki]', "");
     $tpl->set('[/odnoklassniki]', "");
     $tpl->set('{odnoklassniki_url}', $odnoklassniki_url);
 } else {
     $tpl->set_block("'\\[odnoklassniki\\](.*?)\\[/odnoklassniki\\]'si", "");
     $tpl->set('{odnoklassniki_url}', '');
 }
 if ($social_config['fc']) {
     $social_params = array('client_id' => $social_config['fcid'], 'redirect_uri' => $return_domain . "index.php?do=auth-social&provider=fc", 'scope' => 'public_profile,email', 'display' => 'popup', 'state' => $_SESSION['state'], 'response_type' => 'code');
     $facebook_url = 'https://www.facebook.com/dialog/oauth' . '?' . http_build_query($social_params, '', '&amp;');
Exemplo n.º 14
0
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 = "&amp;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;
}
Exemplo n.º 15
0
     if ($row['foto'] and file_exists(ROOT_DIR . "/uploads/fotos/" . $row['foto'])) {
         $tpl->set('{foto}', $config['http_home_url'] . "uploads/fotos/" . $row['foto']);
     } else {
         $tpl->set('{foto}', "{THEME}/dleimages/noavatar.png");
     }
 }
 if ($row['banned'] == 'yes') {
     $user_group[$row['user_group']]['group_name'] = $lang['user_ban'];
 }
 $tpl->set('{status}', $user_group[$row['user_group']]['group_prefix'] . $user_group[$row['user_group']]['group_name'] . $user_group[$row['user_group']]['group_suffix']);
 $tpl->set('{registration}', langdate("j F Y H:i", $row['reg_date']));
 $tpl->set('{lastdate}', langdate("j F Y H:i", $row['lastdate']));
 if ($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", "");
 }
 if ($row['fullname']) {
     $tpl->set('[fullname]', "");
     $tpl->set('[/fullname]', "");
     $tpl->set('{fullname}', stripslashes($row['fullname']));
     $tpl->set_block("'\\[not-fullname\\](.*?)\\[/not-fullname\\]'si", "");
 } else {
     $tpl->set_block("'\\[fullname\\](.*?)\\[/fullname\\]'si", "");
     $tpl->set('{fullname}', "");
     $tpl->set('[not-fullname]', "");
     $tpl->set('[/not-fullname]', "");
Exemplo n.º 16
0
 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&amp;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&amp;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&amp;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>';
 }
Exemplo n.º 17
0
 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'];
 }
Exemplo n.º 18
0
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 . "&amp;" . $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}&amp;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}&amp;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}&amp;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 . "&amp;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&amp;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&amp;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&amp;user="******"{allcomm-url}", $config['http_home_url'] . "index.php?do=lastcomments&amp;userid=" . urlencode($user_row['user_id']));
            $tpl->set("{pm-url}", $config['http_home_url'] . "index.php?do=pm&amp;doaction=newpm&amp;user="******"{email-url}", $config['http_home_url'] . "index.php?do=feedback&amp;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;
    }
}