scott_ttocs46 Posted September 18, 2008 Share Posted September 18, 2008 Hi All, I manage a high volume website. Currently, there are many unnecessary MYSQL inquiries. It would be much easier to handle updates and changes using CRON. I am certain this is how I want to handle the efficiency problem. I will have compiled HTML pages. I assume .htaccess is the best way to control access to the html pages. However, my issue is authentication. I can manage the .htaccess file. However, I am not sure how to detect who is logged in. The dynamic aspects of the site (PHP pages) will need to be able to detect who is logged in via .htaccess. Any ideas? ??? Also, do you think using .htaccess versus PHP authentication poses a security risk? The only downside I see is the .htaccess won't use salts for the MD5 hashes like my PHP authentication does. Scott Quote Link to comment Share on other sites More sharing options...
scott_ttocs46 Posted September 18, 2008 Author Share Posted September 18, 2008 This looks useful but the Apache/PHP relationship is unclear to me - function authenticate(){ header("WWW-Authenticate: Basic realm=\"Members\""); header('HTTP/1.0 401 Unauthorized'); echo "Please enter a valid user name and password."; exit; } for(; 1; authenticate()){ if (!isset($HTTP_SERVER_VARS['PHP_AUTH_USER'])) continue; $user = $HTTP_SERVER_VARS['PHP_AUTH_USER']; if(!($authUserLine = array_shift(preg_grep("/$user:.*$/", file("/home/kloss/html/test/.htpasswd"))))) continue; preg_match("/$user:((..).*)$/", $authUserLine, $matches); $authPW = $matches[1]; $salt = $matches[2]; $submittedPW = crypt($HTTP_SERVER_VARS['PHP_AUTH_PW'], $salt); if($submittedPW != $authPW) continue; break; } Found it at http://code.activestate.com/recipes/108479/ EDIT: Would there be an Apache server variable for the .htaccess username? I.e. $HTTP_SERVER_VARS Quote Link to comment Share on other sites More sharing options...
corbin Posted September 19, 2008 Share Posted September 19, 2008 $_SERVER['PHP_AUTH_USER'] http://us2.php.net/features.http-auth Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.