Login Script Broke on new server, PRETTY please - FREE BEER
Moderator: General Moderators
Login Script Broke on new server, PRETTY please - FREE BEER
I transfered my site to a new server its a windows server running 4.3.3 and the login script I used to rea da text file and match login and password stopped working
Did a function change, it seems that no matter what the data entered is not matched in the text file (constantly fails)? maybe some thing like globals is off? I 'm sure a more expereinced eye cna pick it up
Here is the code
SAVING SPACE, DELETED OLD CODE. LOOK FOR NEW BELOW
Did a function change, it seems that no matter what the data entered is not matched in the text file (constantly fails)? maybe some thing like globals is off? I 'm sure a more expereinced eye cna pick it up
Here is the code
SAVING SPACE, DELETED OLD CODE. LOOK FOR NEW BELOW
Last edited by romeo on Mon Jul 26, 2004 3:51 pm, edited 4 times in total.
got a different error
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in login.php on line 34
so it may be have been the globals... any help here, i dont see the problem
SAVING SPACE, DELETED OLD CODE. LOOK FOR NEW BELOW
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in login.php on line 34
so it may be have been the globals... any help here, i dont see the problem
SAVING SPACE, DELETED OLD CODE. LOOK FOR NEW BELOW
Last edited by romeo on Mon Jul 26, 2004 2:46 pm, edited 1 time in total.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
if ( ( $username == "$_SERVER['PHP_AUTH_USER']" ) &&
( $password == "$_SERVER['PHP_AUTH_PW']" ) ) {- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
ini_set('display_errors', '1');
error_reporing(E_ALL);here is the currect code, for those just joining us
Come on, Ill buy you a beer
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 = 'webusers.php';
$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 );
// 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 $line ) {
list( $memberid, $membername, $contactname, $username, $password, $email, $reportname ) = explode( '|', $line );
$memberid = trim($memberid);
$membername = trim($membername);
$contactname = trim($contactname);
$username = trim($username);
$password = trim($password);
$email = trim($email);
$reportname = trim($reportname);
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.lblah.com/vppages/membersonl ... reportname");
}
?>Come on, Ill buy you a beer