Codice PHP:
session_start();
function is_logged () {
if (!isset($_SESSION["login"]) && isset($_COOKIE["login"])) {
$login_value = base64_decode($_COOKIE["login"]);
$login_value = explode (":", $login_value);
$result = mysql_query ("SELECT * FROM users WHERE id='".$login_value[0]."' AND login='".$login_value[2]."';");
if (mysql_num_rows($result) == 0) { return false; }
//$user = mysql_fetch_array ($result);
//if ($user["banned"] >= time()) return false;
//if ($user["last_login"] != $login_value[1]) { return false; }
return true;
}
elseif (isset($_SESSION["login"])) {
$login_value = base64_decode($_SESSION["login"]);
$login_value = explode (":", $login_value);
$result = mysql_query ("SELECT * FROM users WHERE id='".$login_value[0]."' AND login='".$login_value[2]."' AND pass='".$login_value[3]."';");
if (mysql_num_rows($result) == 0) { return false; }
//$user = mysql_fetch_array ($result);
//if ($user["banned"] >= time()) return false;
//if ($user["last_login"] != $login_value[1]) return false;
return true;
}
else {
return false;
}
}