Пример #1
0
            $success = 1;
        }
    }
    if ($success == 2) {
        $wastheirid = $_loginaccount->GetId();
        $username = $_loginaccount->GetUsername();
        $ip = $_loginaccount->GetLastIP();
        $statement = $__database->prepare('INSERT INTO account_deletion_log (id, username, ip, at) VALUES
			(?,?,?,NOW())');
        $statement->bind_param('sss', $wastheirid, $username, $ip);
        $statement->execute();
        $finish = $__database->query("DELETE FROM accounts WHERE id = " . $_loginaccount->GetId());
        $finish->free();
        unset($_SESSION['username']);
        session_destroy();
        SetMaplerCookie('login_session', '', -100);
        require_once __DIR__ . '/../inc/header.php';
        if ($statement->affected_rows == 1) {
            ?>
		<p class="lead alert alert-info"><i class="icon-exlamation-sign"></i> Your account has been removed.</p>
		<ol>
			<li>Your account itself, and all related information has been removed successfully.</li>
			<li>Al characters has been removed successfully.</li>
			<li>All status messages have been removed successfully.</li>
			<li>All other matters handled successfully.</li>
		</ol>
		<p>If you have any feedback for our team, send us an email at support@mapler.me! :)</p>
		<p><b>We wish you a great day, and happy mapling!</b></p>
<?php 
        } else {
            ?>
        // Session expired.
        SetMaplerCookie('login_session', '', -100);
    }
    $query->free();
}
// Initialize Login Data
$_loggedin = false;
if (strpos($_SERVER['REQUEST_URI'], '/logoff') === FALSE && isset($_SESSION['username'])) {
    $username = $_SESSION['username'];
    $_loggedin = true;
    $_loginaccount = Account::Load($username);
    if ($_loginaccount->GetAccountRank() >= RANK_DEVELOPER) {
        error_reporting(E_ALL);
        ini_set('display_errors', 1);
    }
    if (GetMaplerCookie('login_session') === null) {
        $query = $__database->query("\r\nSELECT \r\n\tat.`code`\r\nFROM \r\n\taccount_tokens at\r\nWHERE\r\n\tat.account_id = " . $_loginaccount->GetID() . "\r\n\tAND\r\n\tat.type = 'login_token'\r\n\tAND \r\n\tat.till > NOW()\r\n");
        $code = '';
        if ($query->num_rows == 0) {
            // Create new
            $code = md5(time() . ' -- -- -- -- - ' . $_loginaccount->GetID() . ' - ' . $_loginaccount->GetUsername());
            $__database->query("\r\nINSERT INTO \r\n\taccount_tokens \r\nVALUES \r\n\t(" . $_loginaccount->GetID() . ", 'login_token', '" . $code . "', DATE_ADD(NOW(), INTERVAL 10 YEAR))\r\nON DUPLICATE KEY UPDATE\r\n\t`code` = VALUES(`code`),\r\n\t`till` = VALUES(`till`)\r\n");
        } else {
            // Use old one
            $row = $query->fetch_row();
            $code = $row[0];
        }
        $query->free();
        SetMaplerCookie('login_session', $code, 10 * 365);
    }
}