Файл: forum_php/system/sys.php
Строк: 193
<?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
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;
ob_start ('ob_gzhandler');
//
echo '<!DOCTYPE html>';
echo '<html>';
echo '<head>';
echo '<meta name="description" content="Территория 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'])) {
}
else {
}
if ($_SERVER['PHP_SELF'] == '/index.php') {
echo '<a href="/"><div class="verx"></a></div>';
if (isset ($us['id'])) {}else{
echo '
<div class="z99">
<a class="jk" href="/log.in.php"> Авторизация </a>
<a class="jk" href="/reg.php"> Регистрация</a>
</div>
';
}
}
// adversite
if (DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `ads`") != 0) {
echo '<div class="menu">Рекламный блок</div>';
echo '<div class="rekl">';
$query = DB :: $dbs -> query ("SELECT * FROM `ads` WHERE (`time`>'" . time () . "') ORDER BY RAND() LIMIT 3");
while ($ads = $query -> fetch ()) {
echo '<img src="/styles/snowy/resources/n.png" alt="" align="rekl"/> <a href="' . $ads['link'] . '">' . $ads['name'] . '</a><br/>';
}
echo '</div>';
}
if (isset ($menu_title)) {
echo '<div class="bk">' . $menu_title . '</div>';
}
if ($_SERVER['PHP_SELF'] == '/index.php') {
#$random = DB::$dbs->query("SELECT * FROM billing_rekl WHERE gde = ? AND type = ? ORDER BY id DESC",array('index',1));
$random = DB::$dbs->query("SELECT * FROM billing_rekl WHERE gde = ? AND type = ? ORDER BY RAND() DESC",array('index',1)); #Рандомный вывод
if($random->rowCount() >0){
echo '<div class="rekl">';
while($r = $random->fetch()){
echo '<img src="/images/rekl.png" class="ico" alt="*"/> <a href="http://'.$r['url'].'">'.$r['name'].'</a><br/>';
}
echo '</div>';
}
} elseif ($_SERVER['PHP_SELF'] != '/') {
$random = DB::$dbs->query("SELECT * FROM billing_rekl WHERE gde = ? AND type = ? ORDER BY RAND() DESC",array('all',1));
if($random->rowCount() >0){
echo '<div class="rekl">';
while($r = $random->fetch()){
echo '<img src="/images/rekl.png" class="ico" alt="*"/> <a href="http://'.$r['url'].'">'.$r['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']==0) {
echo '<div class="menu"><table width="100%" cellpadding="0" cellspacing="0"><tr>';
echo '<td width="25%" align="center"><a href="/kab"> <img src="/images/vcard.png" alt="*"/> </a></td>';
echo '<td width="25%" align="center"><a href="/mail.php"> <img src="/images/mail2.png" alt="*"/> ' . ($n_m != 0 ? '' . $n_m . '' : '') . '</a></td>';
echo '<td width="25%" align="center"><a href="/action.php"><img src="/images/rss2.png" alt="*"/>' . ($n_a != 0 ? '' . $n_a . '' : '') . '</a></td>';
echo '<td width="25%" align="center"><a href="?exit"> <img src="/images/warning.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;
}
}
}
function F ()
{
$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 ' <table style="width: 100%" cellspacing="0"><tbody><tr> <td class="blk" style="width:
55%"><center> ';
echo' <a href="http://jatop.ru/go/256"><img src="http://jatop.ru/imageOther/256" alt="jatop.ru"/></a>';
echo '</center> </td>';
echo '<td class="blk" style="width: 44%"><center><a href="/online.php" style="color:white;"><span class="cont">Онлайн: ' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `us` WHERE (`last`>'" . (time () - 3600) . "')") . ' из ' . DB :: $dbs -> querySingle ("SELECT COUNT(*) FROM `us`") . '</a></span></center></td>';
echo '
</tr>
</tbody></table>';
echo '</body></html>';
}