SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Login failure -

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    May 2004
    Location
    USA
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Login failure -

    I'm "TRYING" to install navphp4 for a client, and I would like to password protect it using the built in authentication system. It's just not working though and I can't find any documentation on the script out there at all.


    Here are the variables it's pulling in for the authentication function:

    PHP Code:
    $homedir "./";    
            
    # Default directory.

    $user "admin";
            
    # login username

    $passwd "admin";
            
    # Login password
            
    $restrict_to_home false;    
            
    # Restrict access to home folder and below.
            
    $enable_login true;        
            
    # Caution!! 'false' means everyone have access to your files! 
    And the actual function itself:

    PHP Code:
    function authenticate()
    {
     global 
    $user$passwd$enable_login$dir$homedir$restrict_to_home,$action$file$change$msg;
     
      if ((
    $_SERVER['PHP_AUTH_USER']!=$user||$_SERVER['PHP_AUTH_PW']!=$passwd)&&$enable_login) {
        
    header('WWW-Authenticate: Basic realm="PHP Navigator"');
        
    header('HTTP/1.0 401 Unauthorized');
        print 
    "<h2>You are not authorised to view this file!</h2>";
        exit;
      } 
    The problem I suppose is that $_SERVER['PHP_AUTH_USER'] isn't available in the PHP version on their server - what's a good alternative that I can keep tied down to just this one function --- don't want to rewrite the whole script.

  2. #2
    SitePoint Evangelist praetor's Avatar
    Join Date
    Aug 2005
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Another limitation is if you're using the IIS module (ISAPI) and PHP 4, you may not use the PHP_AUTH_* variables but instead, the variable HTTP_AUTHORIZATION is available.
    Are you on windows hosting?

  3. #3
    SitePoint Addict
    Join Date
    May 2004
    Location
    USA
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope it's a unix box. Cpanel, php4.4.

    I don't see anything wrong with the code, it's just php_auth_user that isn't working. I found a reference to it not working in some 4.x versions and I suppose that's the problem.

    Can I use the http_authorization in some fashion on a unix box?

  4. #4
    SitePoint Evangelist praetor's Avatar
    Join Date
    Aug 2005
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you upgrade to a higher php version? Most hosts offer php5 also.

  5. #5
    SitePoint Addict
    Join Date
    May 2004
    Location
    USA
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wish I could - but they don't want to upgrade at this point. Guess I'm just going to have to recode it to work with session data - unless someone has a shortcut


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •