5910.
WmLiM, да понял не дурак
Добавлено через 07:23 сек.
Ругается на куки строка 28(кенон хедерс...)
<?php
function generateCode($length=6) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHI JKLMNOPRQSTUVWXYZ0123456789";
$code = "";
$clen = strlen($chars) - 1;
while (strlen($code) < $length) {
$code .= $chars[mt_rand(0,$clen)];}
return $code;}
if((isset($_SESSION['id']) and isset($_SESSION['hash'])) != 0){
$sess_id=htmlspecialchars($_SESSION['id']);
$sess_hash=htmlspecialchars($_SESSION['hash']);
$sess_id=mysql_real_escape_string($sess_id);
$check=mysql_query("SELECT users_id,users_hash FROM users WHERE users_id='$sess_id' LIMIT 1");
$check=mysql_fetch_array($check);
if($sess_id == $check['users_id'] and $sess_hash == $check['users_hash']){
$new_hash = md5(generateCode(10));
mysql_query("UPDATE users SET users_hash='$new_hash' WHERE users_id='$sess_id'");
$cook_time=time()+60*60*24*10;
setcookie("id",$sess_id,$cook_time);
setcookie("hash",$new_hash,$cook_time);
$auth=1;}
else{
setcookie("id","",time()-3600*24*30*12,"/");
setcookie("hash","",time()-3600*24*30*12,"/");
$auth=0;}
}else{
if((isset($_COOKIE['id']) and isset($_COOKIE['hash'])) != 0){
$cook_id=htmlspecialchars($_COOKIE['id']);
$cook_hash=htmlspecialchars($_COOKIE['hash']);
$cook_id=ctype_digit($cook_id);
$cook_id=mysql_real_escape_string($cook_id);
$check=mysql_query("SELECT users_id,users_hash FROM users WHERE users_id='$cook_id' LIMIT 1");
$check=mysql_fetch_array($check);
if($cook_id == $check['users_id'] and $cook_hash == $check['users_hash']){
$new_hash = md5(generateCode(10));
mysql_query("UPDATE users SET
users_hash='$new_hash' WHERE users_id='$cook_id'");
$_SESSION['id']=$cook_id;
$_SESSION['hash']=$cook_hash;
$auth=1;}
else{
$_SESSION['id']=0;
$_SESSION['hash']=0;
$auth=0;}
}
}
?>
Вывода до этого файла нигде нет