require_once ("include/functions.php");
require_once ("include/config.php");
function login() {
?>
block_begin(LOGIN);
if(!isset ($user))$user="";
?>
echo ACCOUNT_CREATE ?> echo RECOVER_PWD ?>
block_end();
}
dbconn();
if (!$CURUSER || $CURUSER["uid"]==1) {
if (isset($_POST["uid"]) && $_POST["uid"])
$user=$_POST["uid"];
else $user='';
if (isset($_POST["pwd"]) && $_POST["pwd"])
$pwd=$_POST["pwd"];
else $pdw='';
if (isset($_POST["uid"]) && isset($_POST["pwd"]))
{
$res = mysql_query("SELECT * FROM users WHERE username ='".AddSlashes($user)."'")
or die(mysql_error());
$row = mysql_fetch_array($res);
if (!$row)
{
standardheader("Login");
print("
".ERR_USERNAME_INCORRECT."
");
login();
}
elseif ($row["password"] != md5($pwd))
{
standardheader("Login");
print("
".ERR_PASSWORD_INCORRECT."
");
login();
}
else
{
logincookie($row["id"],$row["password"]);
if (isset($_GET["returnto"]))
$url=urldecode($_GET["returnto"]);
else
$url="index.php";
redirect($url);
}
}
else
{
standardheader("Login");
login();
stdfoot();
exit;
}
}
else {
if (isset($_GET["returnto"]))
$url=urldecode($_GET["returnto"]);
else
$url="index.php";
redirect($url);
}
?>