Guest Posted February 11, 2004 Share Posted February 11, 2004 I;ve installed a contrib for admin password. The following code is giving me grief.. ;( / Save the following PHP codes as authen.php in /admin/includes/authen.php <?php if(!isset($PHP_AUTH_USER)) { header('WWW-Authenticate: Basic realm="' . TITLE . '"'); header('HTTP/1.0 401 Unauthorized'); echo $SERVER_NAME . ' Authorization Required.'; exit; } else { if (($PHP_AUTH_USER != ADMIN_USERNAME) || ($PHP_AUTH_PW != ADMIN_PASSWORD)) { header('WWW-Authenticate: Basic realm="' . TITLE. '"'); header('HTTP/1.0 401 Unauthorized'); echo $SERVER_NAME . ' Authorization Required.'; exit; } } ?> Its just a direct cut and paste of the full code which is Quick Setup of Admin Authentication. // Open /admin/includes/application_top.php add the following code in // include authentication user/password of administration require(DIR_WS_INCLUDES . 'authen.php'); // Open /admin/includes/configure.php and add the following code in // define admin user/password define('ADMIN_USERNAME', 'admin'); define('ADMIN_PASSWORD', 'mypasword'); // Save the following PHP codes as authen.php in /admin/includes/authen.php <?php if(!isset($PHP_AUTH_USER)) { header('WWW-Authenticate: Basic realm="' . TITLE . '"'); header('HTTP/1.0 401 Unauthorized'); echo $SERVER_NAME . ' Authorization Required.'; exit; } else { if (($PHP_AUTH_USER != ADMIN_USERNAME) || ($PHP_AUTH_PW != ADMIN_PASSWORD)) { header('WWW-Authenticate: Basic realm="' . TITLE. '"'); header('HTTP/1.0 401 Unauthorized'); echo $SERVER_NAME . ' Authorization Required.'; exit; } } ?> Link to comment Share on other sites More sharing options...
joeyjgarcia Posted February 12, 2004 Share Posted February 12, 2004 So what's your question? Link to comment Share on other sites More sharing options...
Guest Posted February 13, 2004 Share Posted February 13, 2004 why didn't you just password protect that folder? Link to comment Share on other sites More sharing options...
Alcom_23 Posted February 14, 2004 Share Posted February 14, 2004 I'm trying to implement this script as well. However, I'm on Windows XP Home and I am without the password-protected sharing features of XP pro. Another problem with the Windows file system is that it will not allow you to create a nameless file (i.e., extension only: .htaccess, .htpasswd). When I use the admin_authen contribution, I get the login prompt but the user name/password combination that I specified in the admin/configure.php always fails. Even with no password (blank), I get the message "Authorization Required". I have nailed down that it is the first if statement that the script is hung on by adding a digit in the error message string. if(!isset($PHP_AUTH_USER)) { header('WWW-Authenticate: Basic realm="' . TITLE . '"'); header('HTTP/1.0 401 Unauthorized'); echo $SERVER_NAME . ' Authorization Required1.'; exit; } What is $PHP_AUTH_USER? A pre-defined PHP global? Unless someone can offer advice, I'll be looking into other 2.2 contributions. Link to comment Share on other sites More sharing options...
keviny Posted May 15, 2004 Share Posted May 15, 2004 The HTTP Authentication hooks in PHP are only available when it is running as an Apache module and is hence not available in the CGI version. read more on this page http://www.zend.com/manual/features.http-auth.php hope this helps or puts your mind at ease. Link to comment Share on other sites More sharing options...
SGershon Posted May 15, 2004 Share Posted May 15, 2004 You are publishing your store on a Windows XP Home? Hard to believe. If you are doing this locale, just for testing purposes, you may leave admin unprotected. When you eventually go live, you can protect it. Files like .htaccess don't work on windows, and its not because the extension problem. (and yes, you can have extensionless files in Windows). If you are really publishing your store live on a Windows XP Home, require from your hosting this passwors protection features you said. If at first you don't succeed, you must be a programmer. Tip Posted: Languageless Reviews Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.