Размер файла: 2.71Kb
<?php
// coding by Felis
error_reporting(7);
session_start();
include('connect.php');
$db = new mysqli(HOSTNAME, USERNAME, PASSWORD, DATABASE) or exit;
$db->query("SET NAMES `utf8`");
$mode = isset($_GET['mode']) ? trim($_GET['mode']) : NULL;
$id = isset($_GET['id']) ? abs((int)$_GET['id']) : FALSE;
$u = isset($_GET['u']) ? abs((int)$_GET['u']) : FALSE;
$p = abs((int)$_GET['p']);
if(!isset($p) || $p <= 0) $p = 1;
$settings = $db->query("SELECT * FROM `settings`"); $conf = FALSE;
while($item_c = $settings->fetch_row())
{
$conf[$item_c[0]] = $item_c[1];
}
define('CFILE', getenv('SCRIPT_NAME'));
define('_AUTH_ERROR', 'Неавторизованне? Жепь ебрило!111');
define('_ERROR', 'Unhandled error');
define('AN_USER', 'Anonymous');
include('functions.php');
$sec = array('minute' => 60, 'hour' => 3600, 'day' => 86400, 'week' => 604800, 'month' => 2592000, 'year' => 31536000);
$time = time();
if(isset($_SESSION['id']) and isset($_SESSION['passwd']))
{
$uid = $_SESSION['id'];
$pwd = $_SESSION['passwd'];
$op = true;
}
elseif(isset($_COOKIE['id']) and isset($_COOKIE['passwd']))
{
$_SESSION['id'] = (int)base64_decode($_COOKIE['id']);
$uid = $_SESSION['id'];
$_SESSION['passwd'] = $fnc->encode(base64_decode($_COOKIE['passwd']));
$pwd = $_SESSION['passwd'];
$op = true;
}
function unses()
{
session_unset();
session_destroy();
setcookie('id', NULL);
setcookie('passwd', NULL);
}
if($op == true)
{
$opt = $db->query("SELECT * FROM `users` WHERE `id`=".$uid);
if($opt->num_rows > 0)
{
$usr = $opt->fetch_assoc();
if($usr['banned'] == 'n')
{
if($usr['ontime'] < $time - $conf['online'])
{
$db->query("UPDATE `users` SET `ontime`=$time WHERE `id`=".$uid);
}
if($usr['access'] == 'a')
$adm = true;
if($usr['access'] == 'a' or $usr['access'] == 'm')
$mod = true;
}
elseif($usr['banned'] == 'y' and $time - $usr['ban_point'] < $usr['ban_term'] and $usr['access'] != 'a')
{
unses();
}
else
{
$db->query("UPDATE `users` SET `banned`='n', `ban_point`=NULL, `ban_term`=NULL WHERE `id`=".$uid);
}
}
else
{
unses();
}
}
$uo = $db->query("SELECT COUNT(`id`) AS `count` FROM `users` WHERE `ontime`>=".($time - $conf['online']))->fetch_assoc(); $uo = $uo['count'];
$all_p = $db->query("SELECT `id` FROM `posts`")->num_rows;
$all_u = $db->query("SELECT `id` FROM `users`")->num_rows;
if($all_p > $conf['all_post'])
{
$db->query("DELETE FROM `posts` ORDER BY `id` ASC LIMIT 1");
$db->query("OPTIMIZE `posts`");
}
$onpage = ($op == true) ? $usr['onpage'] : $conf['onpage'];
$begin = $p * $onpage - $onpage;
ob_start();
// конец файла ./sys/kernel.php