Location: PHPKode > projects > KISGB (Keep It Simple Guest Book) > authenticate.php
<?
/*
   KISGB - a Guest Book script written in PHP.
   Copyright (C) 2001-2002 Gaylen Fraley
   hide@address.com

   This program 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
   License file for more details.
*/
$sapi_name = strtolower(php_sapi_name());
if (strpos($sapi_name,"cgi")===FALSE) {
	if ((!($HTTP_SERVER_VARS['PHP_AUTH_USER']==$auth_id && $HTTP_SERVER_VARS['PHP_AUTH_PW']==$auth_pw)) && (!($HTTP_SERVER_VARS['AUTH_USER']==$auth_id && $HTTP_SERVER_VARS['AUTH_PASSWORD']==$auth_pw))) {
		header("WWW-Authenticate: Basic realm=$realm_name");
		header("HTTP/1.0 401 Unauthorized");
		echo "<html><head>";
/*** 7/19/2002 ***/ include_once("functions.php");
		metaTags();
		echo "</head><body><table align=\"center\" border=\"$Awindow_border\" width=\"50%\"><tr><td align=\"center\" style=\"background-color:$Awindow_background_color;color:$Awindow_text_color;border-color:$Awindow_border_color;font-size:$Atable_font_size;border-width:$Awindow_border_width\"><b>$not_authorized_msg</b></td></tr></table></body></html>";
		exit;
	}
}
else {
if ($HTTP_GET_VARS['tmp_theme']>'') $theme = $HTTP_GET_VARS['tmp_theme'];
if ($HTTP_GET_VARS['tmp_lang']>'') $language = $HTTP_GET_VARS['tmp_lang'];
if ($HTTP_POST_VARS['tmp_theme']>'') $theme = $HTTP_POST_VARS['tmp_theme'];
if ($HTTP_POST_VARS['tmp_lang']>'') $language = $HTTP_POST_VARS['tmp_lang'];
if (isset($default_path_for_themes)) require("$default_path_for_themes/$theme");
else require("$path_to_themes/$theme");
if (isset($default_path_for_languages)) require("$default_path_for_languages/$language");
else require("$path_to_languages/$language");
$action = $HTTP_GET_VARS['action'];
$cgi_id = $HTTP_POST_VARS['cgi_id'] ? $HTTP_POST_VARS['cgi_id'] : $HTTP_GET_VARS['cgi_id'];
$cgi_pw = $HTTP_POST_VARS['cgi_pw'] ? $HTTP_POST_VARS['cgi_pw'] : $HTTP_GET_VARS['cgi_pw'];
if ($sapi_name=="cgi"&&!($cgi_id==$auth_id&&$cgi_pw==$auth_pw)) {
$PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
?>
<html><head>
<?
/*** 7/19/2002 ***/ include_once("functions.php");
metaTags();
js_getPointer();
echo "<style type=\"text/css\">td {background-color:$Awindow_background_color;color:$Awindow_text_color;border-color:$Awindow_border_color;font-size:$Atable_font_size;border-width:$Awindow_border_width;}</style></head><body><form action=\"$PHP_SELF?action=$action\" method=post>";
echo "<input type=\"hidden\" name=\"tmp_theme\" value=\"$theme\" />";
echo "<input type=\"hidden\" name=\"tmp_lang\" value=\"$language\" />";
echo "<table align=\"center\" border=\"$Awindow_border\" width=\"25%\" cellpadding=\"0\" callspacing=\"0\" bgcolor=\"$Awindow_background_color\">";
echo "<tr><td align=\"center\" colspan=\"2\"><b>Authorization Required</b></td></tr>";
echo "<tr><td align=\"center\">User Id</td><td align=\"center\"><input name=\"cgi_id\" /></td><tr>";
echo "<tr><td align=\"center\">Password</td><td align=\"center\"><input type=\"password\" name=\"cgi_pw\" /></td><tr>";
echo "<tr><td align=\"center\"><input id=\"btn\" onMouseOver=\"this.style.cursor=get_pointer();\" type=\"submit\" name=\"submit\" value=\"Submit\" /></td><td></td></tr>";
echo "</table></form></body></html>";
exit;
}
}
?>
Return current item: KISGB (Keep It Simple Guest Book)