Location: PHPKode > projects > CMS Admin > www/include/login.php
<?php
// from PEAR documentation, for the most part
// http://pear.php.net/manual/en/package.authentication.auth.auth.auth.php

require_once 'Auth.php';
require_once 'DB.php';
require_once dirname(__FILE__).'/db.php';
require_once dirname(__FILE__).'/../layout/layout.php';
require_once dirname(__FILE__).'/../classes/user.php';
require_once dirname(__FILE__).'/permissions.php';

function loginFunction()
{
    Layout::header('Login');
	$image = SystemConfig::webroot . '/img/argus-small.jpg';
	$action = SystemConfig::webroot . '/index.php';

echo <<< END
<div id="login">
<fieldset>
<legend>Argus: Log in</legend>
<form method="post" action="$action">
<p><label>Email</label><input type="text" name="username" /></p>
<p><label>Password</label><input type="password" name="password" /><br /></p>
<p><label>&nbsp;</label><input type="submit" value="Log in" /></p>
</form>
</fieldset>
</div>
<div id="sidebar"> </div>
END;
    Layout::footer();
}

$params = array(
    "dsn" => SystemConfig::dsn,
    "table" => "user",
    "usernamecol" => "Email",
    "passwordcol" => "UserPassword"
);

$auth = new Auth("DB", $params, "loginFunction");

$auth->start();

if ($auth->checkAuth()) {
    if(isset($_GET['logout'])) {
        $auth->logout();
        $auth->start();
        echo "Successfully logged out.";
    } else {
		if (isset($_GET['c']) && ctype_digit($_GET['c']))
			$course = $_GET['c'];

        $users = new Users($course);
        $email = $auth->getUsername();
        $userID = $users->GetUserIDfromEmail($email);
        $user = new User($userID);
        $perm = new Permissions();

		// load the main module, either by calling $m->main(), or just main()
        if(isset($module))
            $module->main($user,$perm, $course);
        else
            main($user, $perm, $course);
    }
} else {
    if($auth->getStatus() == AUTH_WRONG_LOGIN)
        echo "Incorrect login.";
}

?>
Return current item: CMS Admin