Exemplo n.º 1
0
<?php

session_start();
if (empty($_SESSION['account_id']) && !empty($_COOKIE['remember'])) {
    list($selector, $authenticator) = explode(':', $_COOKIE['remember']);
    require_once '../config.php';
    require_once '../CMySql.php';
    $cmysql = new CMySql($host, $user, $pass);
    $cmysql->delete($db_web, "auth_tokens", " expires < '" . date('Y-m-d\\TH:i:s', time()) . "'");
    $row = $cmysql->selectRow($db_web, "auth_tokens", '*', "selector = '" . $selector . "'");
    $cmysql->disconnect();
    if ($row['token'] == hash('sha256', base64_decode($authenticator))) {
        $_SESSION['account_id'] = $row['account_id'];
        // Then regenerate login token as above
    }
}
if (!empty($_SESSION['account_id'])) {
    header("location: main.php");
}
?>
<!doctype html>
<html lang='en'>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Member Login</title>

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="../css/bootstrap.min.css">
<!-- Optional theme >
<link rel="stylesheet" href="css/bootstrap-theme.min.css"-->