<?php
/*
*******************************************************************************
FiForms -- A collection of PHP classes designed
to facilitate rapid development of web-database software
Copyright (C) 2003-2008 Daniel McFeeters
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
The original author of this library can be contacted at the following
address:
Daniel McFeeters
182 Baker Rd.
Faubush, KY 42544-6526
email: databases [at] fiforms [dot] org
http://www.fiforms.org/
*******************************************************************************
FiForms_BasicAuth.inc.php
Authentication Module which uses HTTP Basic Authentication
*******************************************************************************
*/
if(!isset($FIFORMS_CONFIG))
{
die('No Configuration found. Did you perhaps call an include file' .
' directly instead of calling it as part of the FiForms' .
' application?');
}
/* ?><code><?php */
class FiFormsAuth
{
var $username;
var $passwd;
function FiFormsAuth()
{
if($GLOBALS['FIFORMS_CONFIG']['DEFAULT_USER'] != "")
{
$this->username = $GLOBALS['FIFORMS_CONFIG']['DEFAULT_USER'];
$this->passwd = $GLOBALS['FIFORMS_CONFIG']['DEFAULT_PASSWORD'];
}
else if(array_key_exists("PHP_AUTH_USER",$_SERVER))
{
$this->username = $_SERVER["PHP_AUTH_USER"];
$this->passwd = $_SERVER["PHP_AUTH_PW"];
}
}
function userInGroup($group)
{
// This function should return true is the user is a member of the
// specified group, otherwise false.
return true; // Basic Auth does not implement groups yet!!!
}
function connectFailure()
{
if($GLOBALS['FIFORMS_CONFIG']['DEFAULT_USER'] != "")
{
echo "There was an error connecting to the database with the default username and password. Please correct this error in the configuration file and be sure that your database server is running.";
}
else
{
header('WWW-Authenticate: Basic realm="'.$GLOBALS['FIFORMS_CONFIG']['AUTH_REALM'].'"');
header('HTTP/1.0 401 Unauthorized');
}
die();
}
}
/* ?></code><?php */
?>