Dragon-Scourge/login.php
Jamin Blount 0f3f0dc8ed Beta 4 Build 18
09.03.2006 - Build 18 (Joe Camel):
- Fixed function redeclaration with Blessed Strike & Stone Skin spells.
- When you're all alone, you no longer have a little blue "undefined"
orb to keep you company.
- Changing worlds after a quest now gives you the world's starting town
to avoid panel errors.
- Minor optimization fix for item building.
- Unique items no longer drop with prefixes/suffixes, and you can no
longer buy unique items.
- Removed alphanumeric requirement for passwords.
- hpleech(monster) now properly accounts for difficulty multiplier when
checking against the monster's maxhp.
- Added Deposit/Withdraw All links to the Bank.
- Fixed PVP and Post office bugs related to the new doquery syntax.
- Fixed single-quote bugs in mymail().
- Removed verbiage from the levelup template that was no longer
necessary.
- Fixed some more verbiage in the registration message that was also no
longer necessary.
- Added admin-definable cookie name and cookie domain to controlrow.
2017-02-05 11:58:57 -06:00

53 lines
1.9 KiB
PHP

<?php // login.php :: Handles user logins and logouts.
include("lib.php");
if (isset($_GET["do"])) { $do = $_GET["do"]; } else { $do = ""; }
switch($do) {
case "logout":
logout();
break;
default:
login();
}
function login() {
$controlrow = dorow(doquery("SELECT * FROM <<control>> WHERE id='1' LIMIT 1"));
if (isset($_POST["submit"])) {
// Setup.
include("config.php");
extract($_POST);
$query = doquery("SELECT * FROM <<accounts>> WHERE username='$username' LIMIT 1");
$row = dorow($query);
// Errors.
if ($row == false) { err("Invalid username. Please <a href=\"index.php\">go back</a> and try again.", false, false); }
if ($row["password"] != md5($password)) { err("Invalid password. Please <a href=\"index.php\">go back</a> and try again.", false, false); }
if ($row["verifycode"] != 1) { err("You have not yet verified your account. Please click the link found in your Accoutn Verification email before continuing. If you never received the email, please check your spam filter settings or contact the game administrator for further assistance.", false, false); }
// Finish.
$newcookie = $row["id"] . " " . $username . " " . md5($row["password"] . "--" . $dbsettings["secretword"]);
if (isset($remember)) { $expiretime = time()+31536000; $newcookie .= " 1"; } else { $expiretime = 0; $newcookie .= " 0"; }
setcookie($controlrow["cookiename"], $newcookie, $expiretime, "/", "", 0);
die(header("Location: index.php"));
} else {
display("Log In", gettemplate("login"), false);
}
}
function logout() {
include("globals.php");
setcookie($controlrow["cookiename"], "", (time()-3600), "/", $controlrow["cookiedomain"], 0);
die(header("Location: login.php?do=login"));
}
?>