barkster Posted August 12, 2007 Share Posted August 12, 2007 I was using this small script to prompt for password on some password protected folders. It was working great but I've moved servers and now the script hangs on the line "if(defined('USER_AUTHENTICATED') && USER_AUTHENTICATED){" It doesn't like the "USER_AUTHENTICATED" but if I take it out it shows the page while it is prompting for password which I don't want. What could be causing this, is USER_AUTHENTICATED a global variable or something? Not quite sure. Thanks require_once 'http_authenticate.php'; if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])){ // this simply means that they have submitted the login form for this realm $htpasswd = "Gallery/".$row['UserID']."/".$row['Folder']."/.htpasswd"; $auth=http_authenticate($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW'],$htpasswd); define('USER_AUTHENTICATED',$auth); } if(defined('USER_AUTHENTICATED') && USER_AUTHENTICATED){ // authentication successful - show the content echo '<?xml version="1.0" encoding="iso-8859-1"?>',"\n"; } else { // the user has not been authenticated, present a login form. header('WWW-Authenticate: Basic realm="'.$row['Folder'].'"'); header('HTTP/1.0 401 Unauthorized'); // if cancel the login form, below is what they get exit('Authentication is required to view this page.'); } Quote Link to comment https://forums.phpfreaks.com/topic/64573-http-authenication/ Share on other sites More sharing options...
teng84 Posted August 12, 2007 Share Posted August 12, 2007 what do you mean by this if(defined('USER_AUTHENTICATED') && USER_AUTHENTICATED){ i think its the same as if(defined('USER_AUTHENTICATED')){ any way can you elaborate more your prob Quote Link to comment https://forums.phpfreaks.com/topic/64573-http-authenication/#findComment-321891 Share on other sites More sharing options...
plutomed Posted August 12, 2007 Share Posted August 12, 2007 Have you defined USER_AUTHENTICATED Quote Link to comment https://forums.phpfreaks.com/topic/64573-http-authenication/#findComment-321892 Share on other sites More sharing options...
barkster Posted August 13, 2007 Author Share Posted August 13, 2007 Don't know it is part of a script that I was using from here http://koivi.com/php-http-auth/ it used to work on my old server and now it just hangs after you put in the username/password If I take out && USER_AUTHENTICATED and just put if(defined('USER_AUTHENTICATED')){ It shows the page content when it prompts for the username/password. With it in there on my old server it does not show the content until successful authentication. Quote Link to comment https://forums.phpfreaks.com/topic/64573-http-authenication/#findComment-321965 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.