<?php
if (!defined('NTLCMS')) die('<center><b>Restricted access</b></center>');
header("Content-type:text/html; charset=utf-8");
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<!DOCTYPE html>';
echo '<html xmlns="http://www.w3.org/1999/xhtml" lang="ru">';
echo '<head>';
echo '<meta charset="UTF-8">';
echo '<title>' . htmlspecialchars($page_title) . '</title>';
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0"/>';
echo '<link rel="canonical" href="' . URL . $_SERVER['REQUEST_URI'] . '"/>';
echo '<meta name="application-name" content="Клик Клуб">';
echo '<meta name="apple-mobile-web-app-title" content="Клик Клуб">';
echo '<meta name="apple-mobile-web-app-capable" content="yes">';
echo '<meta name="apple-mobile-web-app-status-bar-style" content="default">';
echo '<meta name="mobile-web-app-capable" content="yes">';
echo '<meta name="msapplication-tap-highlight" content="no">';
echo '<meta property="og:type" content="website" />';
echo '<meta property="og:title" content="' . htmlspecialchars($page_title) . '" />';
echo '<meta property="og:url" content="' . URL . '" />';
echo '<meta property="og:site_name" content="Клик Клуб" />';
echo '<meta property="og:image" content="' . URL . '/style/images/og-image.jpg" />';
if (!empty($set['key'])) echo '<meta name="keywords" content="' . checkout($set['key']) . '"/>';
if (!empty($set['desc'])) {
echo '<meta name="description" content="' . checkout($set['desc']) . '"/>';
echo '<meta property="og:description" content="' . checkout($set['desc']) . '" />';
}
echo '<link rel="icon" type="image/x-icon" href="' . URL . '/favicon.ico">';
echo '<link rel="shortcut icon" href="' . URL . '/favicon.ico" type="image/x-icon"/>';
echo '<link rel="icon" type="image/svg+xml" href="' . URL . '/style/img/favicons/favicon.svg">';
echo '<link rel="icon" type="image/png" href="' . URL . '/style/img/favicons/favicon-16x16.png" sizes="16x16">';
echo '<link rel="icon" type="image/png" href="' . URL . '/style/img/favicons/favicon-32x32.png" sizes="32x32">';
echo '<link rel="icon" type="image/png" href="' . URL . '/style/img/favicons/favicon-48x48.png" sizes="48x48">';
echo '<link rel="icon" type="image/png" href="' . URL . '/style/img/favicons/favicon-64x64.png" sizes="64x64">';
echo '<link rel="icon" type="image/png" href="' . URL . '/style/img/favicons/favicon-96x96.png" sizes="96x96">';
echo '<link rel="icon" type="image/png" href="' . URL . '/style/img/favicons/favicon-128x128.png" sizes="128x128">';
echo '<link rel="icon" type="image/png" href="' . URL . '/style/img/favicons/favicon-256x256.png" sizes="256x256">';
echo '<link rel="apple-touch-icon" sizes="57x57" href="' . URL . '/style/img/favicons/apple-touch-icon-57x57.png">';
echo '<link rel="apple-touch-icon" sizes="60x60" href="' . URL . '/style/img/favicons/apple-touch-icon-60x60.png">';
echo '<link rel="apple-touch-icon" sizes="72x72" href="' . URL . '/style/img/favicons/apple-touch-icon-72x72.png">';
echo '<link rel="apple-touch-icon" sizes="76x76" href="' . URL . '/style/img/favicons/apple-touch-icon-76x76.png">';
echo '<link rel="apple-touch-icon" sizes="114x114" href="' . URL . '/style/img/favicons/apple-touch-icon-114x114.png">';
echo '<link rel="apple-touch-icon" sizes="120x120" href="' . URL . '/style/img/favicons/apple-touch-icon-120x120.png">';
echo '<link rel="apple-touch-icon" sizes="144x144" href="' . URL . '/style/img/favicons/apple-touch-icon-144x144.png">';
echo '<link rel="apple-touch-icon" sizes="152x152" href="' . URL . '/style/img/favicons/apple-touch-icon-152x152.png">';
echo '<link rel="apple-touch-icon" sizes="180x180" href="' . URL . '/style/img/favicons/apple-touch-icon-180x180.png">';
echo '<link rel="icon" type="image/png" sizes="192x192" href="' . URL . '/style/img/favicons/android-chrome-192x192.png">';
echo '<link rel="icon" type="image/png" sizes="512x512" href="' . URL . '/style/img/favicons/android-chrome-512x512.png">';
echo '<link rel="manifest" href="' . URL . '/site.webmanifest">';
echo '<meta name="msapplication-TileColor" content="#ffffff">';
echo '<meta name="msapplication-TileImage" content="' . URL . '/style/img/favicons/mstile-144x144.png">';
echo '<meta name="msapplication-config" content="' . URL . '/style/img/favicons/browserconfig.xml">';
echo '<meta name="theme-color" content="#ffffff">';
echo '<link rel="stylesheet" href="' . URL . '/style/bootstrap.min.css" type="text/css"/>';
echo '<link rel="stylesheet" href="' . URL . '/style/style.css" type="text/css"/>';
echo '<link rel="stylesheet" href="/style/font-awesome/css/font-awesome.min.css">';
echo '</head><body>';
?>
<?php
echo '<div class="head"><a href="' . URL . '"><img src="' . URL . '/style/logo.png" alt="Клик Клуб ' . strtoupper($_SERVER['HTTP_HOST']) . '" width="185" height="75" loading="eager" class="site-logo" data-logo="main"/></a><div class="time" id="liveTime"></div></div>';
$sql = DB::run()->query("select * from `reklama` order by `id` asc limit 10");
$countusads = DB::run()->querySingle("select count(`id`) from `reklama`");
if ($countusads != 0) {
$ads = array();
while ($row = $sql->fetch(PDO::FETCH_OBJ)) {
$ads[] = $row;
}
shuffle($ads);
foreach ($ads as $row) {
$cleanUrl = str_ireplace(['http://', 'https://'], '', $row->url);
$clickCount = (int)$row->count_all;
$clickText = $clickCount . ' ' . getNumEnding($clickCount, ['клик', 'клика', 'кликов']);
echo '<div class="rek" itemscope itemtype="http://schema.org/WebSite">';
echo '<i class="fa fa-star-o fa-fw" aria-hidden="true"></i> ';
echo '<a href="' . URL . '/away/' . $cleanUrl . '" 
title="Перейти на сайт ' . htmlspecialchars($row->name) . '"
itemprop="url">';
if (!empty($row->color)) {
echo '<span style="color:' . $row->color . '" itemprop="name">' . htmlspecialchars($row->name) . '</span>';
} else {
echo '<span itemprop="name">' . htmlspecialchars($row->name) . '</span>';
}
echo '</a>';
echo ' <sup title="' . $clickText . '">' . $clickCount . '</sup>';
echo '<br/>';
echo '</div>';
}
}
function getNumEnding($number, $endings) {
$number = $number % 100;
if ($number >= 11 && $number <= 19) {
return $endings[2];
}
$i = $number % 10;
switch ($i) {
case 1: return $endings[0];
case 2:
case 3:
case 4: return $endings[1];
default: return $endings[2];
}
}
if ($_USER['login']) echo '<div class="menu"><i class="fa fa-retweet fa-fw"></i> <a href="' . URL . '/advert">Заказ рекламы</a><span class="count">' . money() . ' ' . $set['rekcost'] . ' ' . $pay . ' сутки</span></div>';
if (isset($_SESSION['success'])) {
echo '<div class="post"><center><i class="fa fa-check-circle fa-fw"></i> <span style="color:green">' . checkout($_SESSION['success']) . '</span></center></div>';
unset($_SESSION['success']);
}
if (isset($_SESSION['fail'])) {
echo '<div class="post"><center><i class="fa fa-close fa-fw"></i> <span style="color:red">' . checkout($_SESSION['fail']) . '</span></center></div>';
unset($_SESSION['fail']);
}
if ($active && $_COOKIE[session_name()] != $_USER['sess']) {
unset($_SESSION['login'], $_SESSION['pass']);
$login = isset($_USER['login']) ? filter_var($_USER['login'], FILTER_SANITIZE_STRING) : false;
DB::run()->query("update `users` set `ontime` = ?, `transition` = ? where `login` = ?", array($login, 0, 0));
$_SESSION['fail'] = 'Ошибка сессии!';
header('Location: ' . URL);
}
if (isset($active) == false) {
echo '<div class="cms"> 
<a class="cms" href="' . URL . '/input"  title="Авторизация"><i class="fa fa-user fa-fw"></i> Авторизация</a>
<a class="cms" href="' . URL . '/registration"  title="Регистрация + ' . ($set['payreg']) . ' кр."> <i class="fa fa-user-plus fa-fw"></i> Регистрация </a> </div>';
} else {
$login = isset($_USER['login']) ? filter_var($_USER['login'], FILTER_SANITIZE_STRING) : false;
$newnotice = DB::run()->querySingle("select count(`id`) from `notice` where `to` = ? and `status` = ?", array($login, 1));
$newmail = DB::run()->querySingle("select count(`id`) from `message` where `komy` = ? and `readlen` = ?", array($login, 0));
$us = DB::run()->query("select (`kto`) from `message` where `komy` = ? and `readlen` = ? order by `id` desc limit 1", array($login, 0))->fetch(PDO::FETCH_OBJ);
$itemCount = 6;
$width = floor(100 / $itemCount);
echo '<table style="width:100%; table-layout:fixed;" cellspacing="0" cellpadding="0"><tbody><tr>';
echo '<td style="vertical-align:top; width:' . $width . '%;"><div class="cms"><a href="/cabinet" title="Главная"><center><i class="fa fa-home fa-2x"></i></center></a></div></td>';
echo '<td style="vertical-align:top; width:' . $width . '%;"><div class="cms"><center><a href="' . URL . '/notice" title="Уведомления"><i class="fa fa-bell-o fa-2x"></i>' . ($newnotice > 0 ? '<span class="counter notice">+' . $newnotice . '</span>' : '') . '</a></center></div></td>';
echo '<td style="vertical-align:top; width:' . $width . '%;"><div class="cms"><center><a href="' . ($newmail > 0 ? URL . '/dialog-' . checkout($us->kto) : URL . '/messages') . '" title="' . ($newmail > 0 ? 'Свежая почта' : 'Почта') . '"><i class="fa fa-envelope-o fa-2x"></i>' . ($newmail > 0 ? '<span class="counter mail">+' . $newmail . '</span>' : '') . '</a></center></div></td>';
echo '<td style="vertical-align:top; width:' . $width . '%;"><div class="cms"><center><a href="' . URL . '/site_list" title="Клик ссылки"><i class="fa fa-chain fa-2x"></i>' . (COUNTLINK() >= 1 ? '<span class="counter links">+' . COUNTLINK() . '</span>' : '') . '</a></center></div></td>';
echo '<td style="vertical-align:top; width:' . $width . '%;"><div class="cms"><a href="/finances" title="Биллинг"><center><i class="fa fa-credit-card fa-2x"></i></center></a></div></td>';
echo '<td style="vertical-align:top; width:' . $width . '%;"><div class="cms"><a href="/menu" title="Кабинет"><center><i class="fa fa-user-o fa-2x"></i></center></a></div></td>';
echo '</tr></tbody></table>';
}
if (is_ban($_USER['login'])) {
if ($_SERVER['ScrIPT_NAME'] != '/str/ban.php') {
header('Location: ' . URL . '/ban');
}
}
if ($_USER['active'] == '0' && !strstr($_SERVER['PHP_SELF'], 'str/activation.php')) {
header('Location: ' . URL . '/activation');
exit;
}
if ($_USER['admin'] != '1') {
if ($set['close'] == '1' && !strstr($_SERVER['PHP_SELF'], 'str/closed.php') && !strstr($_SERVER['PHP_SELF'], 'str/input.php') && $_USER['login'] != ADMINS()) {
header('Location: ' . URL . '/closed');
exit;
}
}
if ($active && $_SERVER['REMOTE_ADDR'] != $_USER['oldip']) {
echo '<div class="menu"><center>Внимание!<br/>Ваш IP-адрес изменился!<br/>';
echo 'Предыдущая сессия: <b>' . checkout($_USER['oldip']) . '</b><br/>
Обновлённая сессия: <b>' . checkout($_SERVER['REMOTE_ADDR']) . '</b></center></div>';
}
?>