Пример #1
0
 public static function getCookie()
 {
     if (!isset($_COOKIE['ospap2_id'])) {
         return null;
     }
     if (!isset($_COOKIE['ospap2_passhash'])) {
         return null;
     }
     $objUser = new clsUser($_COOKIE['ospap2_id']);
     if ($objUser->isNew()) {
         return null;
     }
     if (sha1($objUser->get('password')) == $_COOKIE['ospap2_passhash']) {
         /* Rejuvinate the cookie. */
         $objUser->setCookie();
         return $objUser;
     }
     return null;
 }
Пример #2
0
<?php

$objUser = new clsUser();
$objUser->getFromRequest();
if ($objUser->exists('password')) {
    if ($objUser->verify()) {
        $_SESSION['objUser'] = $objUser;
        $objUser->setCookie();
        header("Location: index.php?message=login_successful");
    } else {
        if ($objUser->verifyTemp()) {
            $_SESSION['objUser'] = $objUser;
            $objUser->setCookie();
            header("Location: index.php?action=members&subaction=view&" . $objUser->getIDPair() . "&message=login_successfultemp");
        } else {
            header("Location: index.php?action=login&error=login_failed&" . $objUser->getValuePair('username'));
        }
    }
    exit;
}
if ($objUser->isNew()) {
    $objTemplate->setText('PAGETITLE', "Logging in");
    $objBreadcrumbs->add('Login', 'index.php?action=login');
    $objMiniMenu->add('Register', 'index.php?action=members&subaction=view');
    if ($objUser->exists('username')) {
        $objTemplate->setText('ONLOAD', "\$('" . $objUser->getFieldName('password') . "').focus();");
    } else {
        $objTemplate->setText('ONLOAD', "\$('" . $objUser->getFieldName('username') . "').focus();");
    }
    ?>
		<form action='<?php