Файл: index.php
Строк: 55
<?php
define('CMS',TRUE);
require('core/inc.php');
$id = !empty($_GET['id']) ? num($_GET['id']) : 0;
$mod = !empty($_GET['m']) ? check($_GET['m']) : '';
$page = !empty($_GET['page']) ? num($_GET['page']) : 1;
# Кеширование списка стран
$countries = get_vars('country');
if (!$countries || !is_array($countries)) {
$countries = array();
$rows = $db->select("SELECT `tld`,`name` FROM ?_country ORDER BY `name` ASC;");
foreach($rows as $row) $countries[$row['tld']] = $row['name'];
set_vars('country', $countries);
}
# Кеширование статических страниц
$static_pages = get_vars('static_pages');
if (!$static_pages || !is_array($static_pages)) {
$rows = $db->select( "SELECT `name`,`title` FROM ?_pages WHERE `active` = '1' ORDER BY `views` DESC, `id` DESC;" );
$static_pages = array();
if (!empty($rows)) {
foreach( $rows as $row ) {
$static_pages[$row['name']] = $row['title'];
}
}
set_vars('static_pages', $static_pages);
}
# Проверка пользователей на бан и подтверждение реги
if ($is_logged) {
if (!empty($mod) && $mod == 'exit') {
$_SESSION = array();
$inSes->setCookie('cookpar', '');
$inSes->setCookie('cooklog', '');
$inSes->setCookie(session_name(), '');
session_unset();
$inSes = cmsSession::getInstance();
$inSes->addMessage('Досвидание, ' . $log, 'ok');
gen_red('index', '', RND);
}
}
if (!empty($mod) && file_exists( MODULES_PATH . $mod . '.php' )) {
include( MODULES_PATH . $mod . '.php' );
}
else if (!empty($mod) && array_key_exists($mod, $static_pages)) {
include( MODULES_PATH . 'static.php' );
}
else {
define('IS_INDEX',TRUE);
show_header();
if (is_admin()) {
echo show_link(gen_admin('?' . RND), 'Управление');
}
$onpage = !empty($config['blog_num']) ? num($config['blog_num']) : 10;
if ($page > 1) $from = ($page - 1) * $onpage; else $from = 0;
$rows = array();
$rows = $db->selectPage($total, "SELECT * FROM ?_blog_posts
WHERE `blog_moders` <> '1'
ORDER BY `blog_time` DESC
LIMIT ?d, ?d", $from, $onpage );
if (!empty($rows) && $total > 0) {
foreach($rows as $numRow => $row) {
if (!empty($row['blog_is_xxx'])) {
$xxx = ' <span class="count" style="color:#ff0000">(18+)</span>';
}
else $xxx = '';
echo '<div class="link">';
echo ' <a href="/blog/' . gen_uri('post', $row['blog_id'], RND) . '">' . $row['blog_title'] . '</a>';
echo '</div>';
}
echo show_pages('index', '', 'p');
}
else {
show_error('Статей еще нет, будь первым!');
}
}
show_footer();
?>