<?php
// ------------------------------------------------------------
// Stratos PHP Framework
// Copyright (c) 2006-2007 Sephira Software, LLC
//
// This file is subject to the Stratos PHP Framework license
// which you should have received along with this file. The
// license is also accessible on the web at the following URI:
// http://www.stratosframework.com/wiki/Manual/License
// If you did not receive a copy of the Stratos PHP Framework
// license or you are unable to obtain it through the web,
// please send an e-mail to hide@address.com so a copy
// can be sent to you.
// ------------------------------------------------------------
/**
* This file contains the QuickAuth plugin class for the Stratos PHP Framework.
*
* @author Joshua Carnett
* @copyright Copyright (c) 2006-2007 Sephira Software, LLC
* @license http://www.stratosframework.com/wiki/Manual/License
* @package QuickAuth
*/
/**
*
*/
define('QUICK_AUTH_SITE_ID', md5(SERVER_HOST . SERVER_PORT . SCRIPT_PATH));
/**
* @package QuickAuth
*/
class QuickAuth extends StratosPlugin
{
function QuickAuth()
{
$this->__construct();
}
function __construct()
{
}
function start()
{
return true;
}
function notifyPhaseBeginStartup()
{
$action = Stratos::getAction();
if ( $action == 'QuickAuth/login'
|| $action == 'QuickAuth/logout' )
{
return true;
}
$request_uri = Stratos::server('REQUEST_URI');
if ( ($pos = strpos($request_uri, '/index.php')) !== false )
{
$_SESSION['QuickAuth_from_' . QUICK_AUTH_SITE_ID] = '.'
. substr($request_uri, $pos);
}
else
{
$_SESSION['QuickAuth_from_' . QUICK_AUTH_SITE_ID] = './index.php';
}
if ( !isset($_SESSION['QuickAuth_user_' . QUICK_AUTH_SITE_ID])
|| !isset($_SESSION['QuickAuth_pass_' . QUICK_AUTH_SITE_ID]) )
{
Stratos::redirect('QuickAuth/login');
}
else
{
$user = $_SESSION['QuickAuth_user_' . QUICK_AUTH_SITE_ID];
$pass = $_SESSION['QuickAuth_pass_' . QUICK_AUTH_SITE_ID];
if ( isset($this->_conf['users'][$user])
&& $this->_conf['users'][$user] == $pass )
{
return true;
}
else
{
unset($_SESSION['QuickAuth_user_' . QUICK_AUTH_SITE_ID]);
unset($_SESSION['QuickAuth_pass_' . QUICK_AUTH_SITE_ID]);
Stratos::putFlash('Invalid username and/or password.', 'error');
Stratos::redirect('QuickAuth/login');
}
}
}
}
?>