Просмотр файла incs/fmysql.php

Размер файла: 2.1Kb
<?php
##########Проверка авторизации################
if (isset($_COOKIE['nick'])){
$nick = $_COOKIE['nick'];
$pass = $_COOKIE['pass'];
$pass = md5($pass);
$qb=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `nick` = '$nick'"));
if($qb[pass]==$pass){
$on=1;
}else{
$on=0;
}
}
##########$user################
$nick_user = $_COOKIE['nick'];
$user=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `nick` = '$nick_user'"));
##########настройки################
$settings=mysql_fetch_array(mysql_query("SELECT * FROM `settings`"));
##########Онлан################
$time=time();
if($on==0){
$guests=mysql_fetch_array(mysql_query("SELECT * FROM `guests` WHERE `ip` = '".@$_SERVER['REMOTE_ADDR']."'"));
if($guests[id]==""){
mysql_query("INSERT INTO `guests` (`ip`, `date_last`) values('".@$_SERVER['REMOTE_ADDR']."', '$time')");
}
}
if($on==1){
mysql_query("UPDATE `user` SET `date_last` = '$time' WHERE `id` = '$user[id]'");
}
if($on==0){
mysql_query("UPDATE `guests` SET `date_last` = '$time' WHERE `ip` = '".@$_SERVER['REMOTE_ADDR']."'");
}
$online = mysql_num_rows(mysql_query("SELECT `id` FROM `user` WHERE `date_last` > '".($time-600)."'"));
$online_g = mysql_num_rows(mysql_query("SELECT `id` FROM `guests` WHERE `date_last` > '".($time-600)."'"));
$global_online=$online+$online_g;
##########фильтрация $_POST################
function filtr($somestr){
$somestr=trim(mysql_real_escape_string(htmlspecialchars(str_replace("\0","",$somestr))));
return $somestr;
}
##########фильтрация $_GET################
function fil($somest){
$somest=str_replace("'","",$somest);
return $somest;
}
##########Показ ошибок################
if($user[level]<=10){
error_reporting(0);
}
##########Время в онлайне################
if($on==1){
$new_time_online_us=$time-$user[date_last];
if($new_time_online_us>600){$new_time_online_us=0;}
$time_online_us=$user[time_online]+$new_time_online_us;
mysql_query("UPDATE `user` SET `time_online` = '$time_online_us' WHERE `id` = '$user[id]'");
}
##########Время################
$vremja="".date('H:i:s')."";

if($on==0){$user[them]=$settings[them];}
?>