I am running an apache server w/ php on 2 machines, one windows, one linux.
This is an authication script I found from a script site that Basically, I
put the following code at the top of the page I want to protect:
<?php
include "auth.inc.php";
verifyAccess(1);
?>
<?php include('add.php'); ?>
and here is the contents of auth.inc.php:
<?php
function authUser($name, $pass) {
$userlist = file("users.inc.php");
$done = false;
$auth = false;
$found = false;
$i = 1;
while (!$done && !$found) {
list($n,$p,$a) = explode(':',$userlist[$i]);
$found = ($n==$name);
$auth = $found && ($p == md5($name.$pass));
$done = $auth || ($i>=count($userlist));
$i++;
}
return $auth;
}
function verifyAccess($minlevel) {
global $HTTP_COOKIE_VARS;
$userlist = file("users.inc.php");
$done = false;
$auth = false;
$found = false;
$i = 1;
list($name,$pass) = explode(':',$HTTP_COOKIE_VARS["AUTHORIZER"]);
while (!$done) {
list($n,$p,$a) = explode(':',$userlist[$i]);
$found = ($name == $n) && ($n!="");
$auth = $found && ($pass == $p) && ($a<=$minlevel);
$done = $found || ($i>=count($userlist));
$i++;
}
if (!$auth) {
readfile("auth_login.inc.html");
die("");
}
}
?>
and here is auth_login.inc.html:
<?php
function authUser($name, $pass) {
$userlist = file("users.inc.php");
$done = false;
$auth = false;
$found = false;
$i = 1;
while (!$done && !$found) {
list($n,$p,$a) = explode(':',$userlist[$i]);
$found = ($n==$name);
$auth = $found && ($p == md5($name.$pass));
$done = $auth || ($i>=count($userlist));
$i++;
}
return $auth;
}
function verifyAccess($minlevel) {
global $HTTP_COOKIE_VARS;
$userlist = file("users.inc.php");
$done = false;
$auth = false;
$found = false;
$i = 1;
list($name,$pass) = explode(':',$HTTP_COOKIE_VARS["AUTHORIZER"]);
while (!$done) {
list($n,$p,$a) = explode(':',$userlist[$i]);
$found = ($name == $n) && ($n!="");
$auth = $found && ($pass == $p) && ($a<=$minlevel);
$done = $found || ($i>=count($userlist));
$i++;
}
if (!$auth) {
readfile("auth_login.inc.html");
die("");
}
}
?>
now this script works great on my windows server, but when I try logging in
to it on my linux box I get the following errors:
Warning: Cannot add header information - headers already sent by (output
started at /usr/local/apache/htdocs/auth.inc.php:46) in
/usr/local/apache/htdocs/auth_login.php on line 7
Warning: Cannot add header information - headers already sent by (output
started at /usr/local/apache/htdocs/auth.inc.php:46) in
/usr/local/apache/htdocs/auth_login.php on line 9
any ideas? both pages on each server are identical but the linux one does not work. any help would be greatly appreciated, please email
youngl@hot.rr.com, thanks!
Laura Young