Файл: system/sys.php
Строк: 187
<?php
// autoload application components
foreach (array (
$_SERVER['DOCUMENT_ROOT'] . '/system/configs/',
$_SERVER['DOCUMENT_ROOT'] . '/system/plugins/'
) as $dir) {
foreach (array_merge (glob ($dir . '*.php'), array (
)) as $file) {
require_once $file;
}
}
class PDO_ extends PDO
{
public function __construct ($dsn, $username, $password)
{
parent :: __construct ($dsn, $username, $password);
//$this -> setAttribute (PDO :: ATTR_ERRMODE, PDO :: ERRMODE_EXCEPTION);
$this -> setAttribute (PDO :: ATTR_DEFAULT_FETCH_MODE, PDO :: FETCH_ASSOC);
}
function prepare ($sql) {
$stmt = parent :: prepare($sql, array(
PDO :: ATTR_STATEMENT_CLASS => array('PDOStatement_')
));
return $stmt;
}
function query($sql, $params = array()) {
$stmt = $this -> prepare($sql);
$stmt -> execute($params);
return $stmt;
}
function querySingle($sql, $params = array()) {
$stmt = $this -> query($sql, $params);
$stmt -> execute($params);
return $stmt -> fetchColumn(0);
}
function queryFetch($sql, $params = array()) {
$stmt = $this -> query($sql, $params);
$stmt -> execute($params);
return $stmt -> fetch();
}
}
class PDOStatement_ extends PDOStatement {
function execute($params = array()) {
if (func_num_args() == 1) {
$params = func_get_arg(0);
} else {
$params = func_get_args();
}
if (!is_array($params)) {
$params = array($params);
}
parent :: execute($params);
return $this;
}
function fetchSingle() {
return $this -> fetchColumn(0);
}
function fetchAssoc() {
$this -> setFetchMode(PDO :: FETCH_NUM);
$data = array();
while ($row = $this -> fetch()) {
$data[$row[0]] = $row[1];
}
return $data;
}
}
class DB {
public static $dbs;
public function __construct ($config)
{
$this -> getInstance($config);
}
public static function getInstance ($config) {
//
try {
self :: $dbs = new PDO_ ($config['dsn'], $config['user'], $config['password']);
}
catch (PDOException $e) {
// add to log errors
$f = fopen($_SERVER['DOCUMENT_ROOT'] . '/system/errorlog.txt', 'a+');
fputs($f, $e -> getMessage () . "rn");
fclose ($f);
exit ('Сайт выключен из-за технических неполадок!');
}
}
}
$array = explode(" ",microtime());
$gen = $array[1] + $array[0];
//
$DB = new DB ($config['dbh']);
DB :: $dbs -> query ("SET NAMES 'utf8'");
if (isset ($_COOKIE['id'], $_COOKIE['pass'])) {
$query = DB :: $dbs -> query ("SELECT * FROM `us` WHERE (`id`=?) AND (`pass`=?)", array (intval ($_COOKIE['id']), addslashes ($_COOKIE['pass'])));
if ($query -> rowCount () != 0) {
$us = $query -> fetch ();
// update activity
DB :: $dbs -> query("UPDATE `us` SET `last`='" . time () . "',`ip`=?,`soft`=? WHERE (`id`='" . $us['id'] . "')", array ($_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT']));
// if last activity < 1 hour update all online
if ((time () - $us['last']) < 3600) {
DB :: $dbs -> query("UPDATE `us` SET `online`=`online`+'" . (time () - $us['last']) . "' WHERE (`id`='" . $us['id'] . "')", array ($_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT']));
}
}
}
function H ($title = '', $menu_title = NULL)
{
global $us;
header ('content-type: text/html');
ob_start ('ob_gzhandler');
if (isset ($us)) {
$query = DB :: $dbs -> query("SELECT * FROM `reg` WHERE (`us`='" . $us['id'] . "')");
if ($query -> rowCount () != 0) {
$reg = $query -> fetch ();
if ($reg['dop'] == '') {
$title = 'Одобрение регистрации';
}
elseif ($reg['dop']=='net') {
$title = 'Нет допуска';
}
}
}
//
echo '<!DOCTYPE html>';
echo '<html>';
echo '<head>';
echo '<meta name="description" content="PHP-Zona.RU - Территория WAP мастера!"/>';
echo '<meta name="keywords" content="wap форум, wap мастер, php скрипты"/>';
echo '<meta name="viewport" content="width=device-width; initial-scale=1.0;"/>';
echo '<link rel="shortcut icon" href="/favicon.ico?' . passgen () . '"/>';
echo '<link rel="stylesheet" href="/' . (isset ($us['id'])?$us['style']:'styles/snowy/style.css') . '?' . passgen () . '" type="text/css"/>';
echo '<link rel="stylesheet" href="/styles/ef.css?' . passgen () . '" type="text/css"/>';
echo '<title>' . $title . '</title>';
echo '</head><body>';
if (isset ($us['id'])) {
if ($_SERVER['REMOTE_ADDR']!=$us['ip']) {
echo '<div class="menu">Внимание!</div>';
echo '<div class="list1">Ваш IP-адрес изменился!</div>';
echo '<div class="lst">';
echo 'Предыдущий: <b>' . $us['ip'] . '</b><br/>';
echo 'Текущий: <b>' . $_SERVER['REMOTE_ADDR'] . '</b>';
echo '</div>';
}
}
else {
if (DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `guest` WHERE (`ip`=?)", array ($_SERVER['REMOTE_ADDR'])) == 0) {
DB :: $dbs -> query ("INSERT INTO `guest` (`ip`,`ua`,`time`) VALUES (?,?,'" . time () . "')", array($_SERVER['REMOTE_ADDR'],$_SERVER['HTTP_USER_AGENT']));
}
else {
DB :: $dbs -> query ("UPDATE `guest` SET `ua`=?, `time`='" . time () . "' WHERE (`ip`=?)", array ($_SERVER['HTTP_USER_AGENT'], $_SERVER['REMOTE_ADDR']));
}
}
if ($_SERVER['PHP_SELF'] == '/index.php') {
echo '<div class="verx"><img src="/images/logo.png" alt=""/></div>';
}
if (isset ($menu_title)) {
echo '<div class="menu">' . $menu_title . '</div>';
}
// adversite
if (DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `ads`") != 0) {
echo '<div class="razd1">';
echo 'Реклама:<br/>';
$query = DB :: $dbs -> query ("SELECT * FROM `ads` WHERE (`time`>'" . time () . "') ORDER BY RAND() LIMIT 3");
while ($ads = $query -> fetch ()) {
echo '<a href="' . $ads['link'] . '">' . $ads['name'] . '</a><br/>';
}
echo '</div>';
}
if ($_SERVER['PHP_SELF'] != '/mail.php' && $_SERVER['PHP_SELF'] != '/msg.php' && $_SERVER['PHP_SELF'] != '/kab/index.php') {
if (isset ($us)) {
$n_a = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `action` WHERE (`us`='" . $us['id'] . "') AND (`see`='1')");
$n_m = DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `msg` WHERE (`us`='" . $us['id'] . "') AND (`see`='1')");
if ($us['panel']==1) {
echo '<div class="rega"><table width="100%" cellpadding="0" cellspacing="0"><tr>';
echo '<td width="25%" align="center"><a href="/kab"> <img src="/images/contact.png" alt="*"/> </a></td>';
echo '<td width="25%" align="center"><a href="/mail.php"> <img src="/images/e_mail.png" alt="*"/> ' . ($n_m != 0 ? '' . $n_m . '' : '') . '</a></td>';
echo '<td width="25%" align="center"><a href="/action.php"><img src="/images/gnome_panel_notification_area.png" alt="*"/>' . ($n_a != 0 ? '' . $n_a . '' : '') . '</a></td>';
echo '<td width="25%" align="center"><a href="/feeds.php"> <img src="/images/page_feed.png" alt="*"/> </a></td>';
echo '</tr></table></div>';
}
else {
if ($n_a != 0) {
echo '<div class="lst"><a href="/action.php">Оповещения</a> (+' . $n_a . ')</a></div>';
}
if ($n_m != 0) {
echo '<div class="lst"><a href="/mail.php">Сообщения</a> (+' . $n_m . ')</a></div>';
}
}
}
}
$query = DB :: $dbs -> query ("SELECT * FROM `ban` WHERE (`us`='" . $us['id'] . "') AND (`end`>'" . time () . "')");
if ($query -> rowCount () != 0) {
$ban = $query -> fetch ();
if ($_SERVER['PHP_SELF'] != '/ban.php') {
header ('location: /ban.php');
exit;
}
}
if (isset ($us)) {
$query = DB :: $dbs -> query("SELECT * FROM `reg` WHERE (`us`='" . $us['id'] . "')");
if ($query -> rowCount () != 0) {
$reg = $query -> fetch ();
if (!isset ($reg['dop'])) {
echo '<div class="menu2">Дождитесь обобрения администрации.</div>';
exit;
}
elseif ($reg['dop'] == 'net') {
echo '<div class="menu2">Вы не были допущены на сайт!</div>';
exit;
}
}
}
}
function F ()
{
global $gen;
$end_array = explode(" ",microtime());
$end_time = $end_array[1] + $end_array[0];
$last = DB :: $dbs -> queryFetch ("SELECT * FROM `us` ORDER BY `reg` DESC LIMIT 1");
if ($_SERVER['PHP_SELF']!='/index.php') {
echo '<div class="navg"><img src="/images/homepage.gif" alt=""/> <a href="/">На главную</a></div>';
}
echo '<div class="blk">';
echo 'Онлайн: <a href="/online.php" style="color:white;">' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `us` WHERE (`last`>'" . (time () - 3600) . "')") . '</a> из <a href="/masters.php" style="color:white;">' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `us`") . '</a><br/>';
echo 'Последний зарег.-ный: <img src="/files/ico/' . ($last['sex']=='Муж'?'m':'j') . ($last['last']>(time () - 3600)?'on':'of') . '.png" alt=""/> <a href="/us' . $last['id'] . '" style="color:white;"><b>' . $last['nick'] . '</b></a><br/>';
echo 'Ген. ' . substr ($end_time - $gen, 0, 6) . ' сек.';
echo '</div>';
echo '</body></html>';
}