Page 2 of 2
Posted: Mon Jul 26, 2004 2:53 pm
by feyd
try switching out all this:
Code: Select all
$fp = fopen( $filename, 'r' );
$file_contents = fread( $fp, filesize( $filename ) );
fclose( $fp );
// Place the individual lines from the file contents into an array.
$lines = explode ( "\n", $file_contents );
with
Posted: Mon Jul 26, 2004 3:19 pm
by romeo
trying on yet a different server
Getting error
Notice: Undefined offset: 6 in /home/httpd/vhosts/localsupport.com/httpdocs/vpcpages/login.php on line 26
Notice: Undefined offset: 5 in /home/httpd/vhosts/localsupport.com/httpdocs/vpcpages/login.php on line 26
Notice: Undefined offset: 4 in /home/httpd/vhosts/localsupport.com/httpdocs/vpcpages/login.php on line 26
Notice: Undefined offset: 3 in /home/httpd/vhosts/localsupport.com/httpdocs/vpcpages/login.php on line 26
Notice: Undefined offset: 2 in /home/httpd/vhosts/localsupport.com/httpdocs/vpcpages/login.php on line 26
Notice: Undefined offset: 1 in /home/httpd/vhosts/localsupport.com/httpdocs/vpcpages/login.php on line 26
Warning: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/BLAH/httpdocs/vpcpages/login.php:26) in /home/httpd/vhosts/BLAH/httpdocs/vpcpages/login.php on line 58
So all i nee dto do is that those offsets and define them 1 by 1? or is there a way to shut defining off?
Posted: Mon Jul 26, 2004 3:34 pm
by romeo
that switch gave me the same erro different line numbers
Th eline giving the UNDEFINED ERRORS IS
list( $memberid, $membername, $contactname, $username, $password, $email, $reportname ) = explode( '|', $line );
Posted: Mon Jul 26, 2004 4:05 pm
by feyd
the first row of the file may be blank.. it definitely didn't explode as there weren't any pipes in the string..
Posted: Wed Jul 28, 2004 8:49 am
by romeo
ok, so I moved it to yet another server and it works to a point, it always fails the first AUTHENTICATION...
any ideas?
Posted: Wed Jul 28, 2004 8:51 am
by romeo
forgot the code
Posted: Wed Jul 28, 2004 11:31 am
by feyd
How's this do?
Code: Select all
<?php
ini_set('display_errors', '1');
ini_set('error_reporting', E_ALL);
$auth = false; // Assume user is not authenticated
if (isset( $_SERVER['PHP_AUTH_USER'] ) && isset( $_SERVER['PHP_AUTH_PW'] )) {
// Read the entire file into the variable $file_contents
$filename = '../data/webusers.txt';
$lines = file( $filename );
// Split each of the lines into a username and a password pair
// and attempt to match them to $PHP_AUTH_USER and $PHP_AUTH_PW.
foreach ( $lines as $k => $line )
{
$line = trim($line);
if(empty($line)) continue;
if(($num = preg_match_all('#\|#',$line)) != 6)
echo 'line ' . ($k+1) . 'has too ' . ($num < 6 ? 'few' : 'many') . ' pipes:' . "\n" . var_export($line) . "\n" . $line . "\n";
list( $memberid, $membername, $contactname, $username, $password, $email, $reportname ) = preg_split( '#\s*\|\s*#', $line );
if (($username == $_SERVER['PHP_AUTH_USER']) && ($password == $_SERVER['PHP_AUTH_PW']))
{
// A match is found, meaning the user is authenticated.
// Stop the search.
$auth = true;
break;
}
}
}
if (!$auth) {
header( 'WWW-Authenticate: Basic realm="Private"' );
header( 'HTTP/1.0 401 Unauthorized' );
echo 'Authorization Required.';
exit;
} else {
$memberid = base64_encode($memberid);
$membername = base64_encode($membername);
$email = base64_encode($email);
$contact = base64_encode($contactname);
$reportname = base64_encode($reportname);
header("Location: http://www.localsupport.com/vpcpages/me ... reportname");
}
?>
Posted: Wed Jul 28, 2004 6:37 pm
by romeo
i got this error Feyd...
Warning: Wrong parameter count for preg_match_all() in /home/httpd/vhosts/localsupport.com/httpdocs/vpcpages/login.php on line 24
'12 | B.W. Stetson & Company | MR JAMES CRILLEY | james | james123 |
floyd@bwstetson.com | mc12snohitat.PDF'line 1has too few pipes: 12 | B.W. Stetson & Company | MR JAMES CRILLEY | james | james123 |
floyd@bwstetson.com | mc12snohitat.PDF
Warning: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/localsupport.com/httpdocs/vpcpages/login.php:24) in /home/httpd/vhosts/localsupport.com/httpdocs/vpcpages/login.php on line 52
By the By... you got a paypal account.. sooner or later your getinga beer

Posted: Wed Jul 28, 2004 6:45 pm
by romeo
a Note
this takes data from a form, then if fails launches the server htaccess box
u can see the site here
http://www.localsupport.com/vpcpages
Posted: Wed Jul 28, 2004 7:06 pm
by feyd
heh, oops

forgot the $matches bit..

Code: Select all
if(($num = preg_match_all('#\|#',$line,$matches)) != 6)
echo 'line ' . ($k+1) . ' has too ' . ($num < 6 ? 'few' : 'many') . ' pipes:' . "\n" . var_export($line,true) . "\n" . $line . "\n";
P.S. I don't drink beer
Posted: Wed Jul 28, 2004 10:14 pm
by romeo
so pepsi ?
Still not authenticating on from teh form, only the htaccess
STILL DOESNT WORK ON THE WINDOWS SERVER... GAH I HATE WINDOWS
Posted: Thu Jul 29, 2004 8:51 pm
by romeo
i must have totally forgotten about a PAGE form login as I think its structured poorly for it