PHP Code:
<?
require_once("include/bittorrent.php");
if (!mkglobal("username:password"))
die();
dbconn();
function bark($text = "Username or password incorrect")
{
stderr("<center>Login failed !</center>", $text);
}
$res = mysql_query("SELECT id, passhash, secret, enabled FROM users WHERE username = " . sqlesc($username) . " AND status = 'confirmed'");
$row = mysql_fetch_array($res);
if (!$row)
bark();
if ($row["passhash"] != md5($row["secret"] . $password . $row["secret"]))
bark();
if ($row["enabled"] == "no")
bark("<center>This account has been disabled.</center>");
// ADN MOD PERMANENT LOGIN
$expires = (int) $_POST["expires"];
if (!$expires or $expires <= 0 or $expires > 31556926) {
$expires = 0x7fffffff;
} else {
$expires = time() + $expires;
}
logincookie($row["id"], $row["passhash"], 1, $expires);
// END MOD PERMANENT LOGIN
/// and mod login return
if (!empty($_POST["returnto"]))
header("Location: $BASEURL$_POST[returnto]");
else
header("Location: $BASEURL/my.php");
///* end mod login return
?>