Beispiel #1
0
 public function loginAction()
 {
     //First check if the form is valid...
     $_form = new LoginForm();
     if (!$_form->isValid($_POST)) {
         $this->_redirect(APPLICATION_BASEURL . "/user/index/error/2");
     }
     $_auth = Zend_Auth::getInstance();
     $_authAdapter = new Zend_Auth_Adapter_DbTable();
     $_authAdapter->setTableName('users')->setIdentityColumn('username')->setCredentialColumn('password');
     $_authAdapter->setIdentity($_form->getUsername())->setCredential(sha1($_form->getPassword()));
     //That's the actual authentication operation
     $_result = $_auth->authenticate($_authAdapter);
     if ($_result->isValid()) {
         $this->view->loggedIn = true;
     } else {
         $this->_redirect(APPLICATION_BASEURL . "/user/index/error/1");
     }
 }
 public function loginAction()
 {
     if (null !== $this->_participant) {
         throw new Exception("You have already passed the checkpoint. What else do you want? If you want to get in again, I don't know why, then say your goodbyes first.");
     }
     $this->view->title = "First Checkpoint";
     //First check if the form is valid...
     $_form = new LoginForm();
     if (!$_form->isValid($_POST)) {
         $this->_redirect(APPLICATION_BASEURL_INDEX . "/participant/index/error/2");
     }
     $_auth = Zend_Auth::getInstance();
     $_authAdapter = Participant::getAuthAdapter();
     $_authAdapter->setIdentity($_form->getUsername())->setCredential(sha1($_form->getPassword()));
     //That's the actual authentication operation
     $_result = $_auth->authenticate($_authAdapter);
     if ($_result->isValid()) {
         $this->view->loggedIn = true;
         $this->_redirect(APPLICATION_BASEURL_INDEX . "/index");
     } else {
         $this->_redirect(APPLICATION_BASEURL_INDEX . "/participant/index/error/1");
     }
 }
Beispiel #3
0
function __autoload($className)
{
    $file = "classes" . DIRECTORY_SEPARATOR . "{$className}.php";
    require_once $file;
}
$db_host = 'localhost';
$db_user = '******';
$db_password = '';
$db_name = 'regform';
$msg = '';
$db = new DB($db_host, $db_user, $db_password, $db_name);
$form = new LoginForm($_POST);
if ($_POST) {
    if ($form->validate()) {
        $username = $db->escape($form->getUsername());
        $password = new Password($db->escape($form->getPassword()));
        $res = $db->query("SELECT * FROM users WHERE username = '******' AND password = '******' LIMIT 1");
        if (!$res) {
            $msg = 'No such user found';
        } else {
            $user = $res[0]['username'];
            Session::set('user', $user);
            header('location: index.php?msg=You have been logged in');
        }
    } else {
        $msg = 'Please fill in fields';
    }
}
?>
<html>
<head>