Welcome Guest, Not a member yet? Register   Sign In
Basic 401 Authentication Library
#9

[eluser]Unknown[/eluser]
Nice library.
But I think better to change below.

if ( !isset($_SERVER['PHP_AUTH_USER']) )

if ( !isset($_SERVER['PHP_AUTH_USER']) || !$_SERVER['PHP_AUTH_USER'] )

Please see below.

Code:
$ diff -u a/basic401auth.php b/basic401auth.php
--- a/basic401auth.php    2008-12-25 01:03:36.000000000 +0900
+++ b/basic401auth.php    2011-02-02 14:16:23.000000000 +0900
@@ -25,9 +25,18 @@
         $user = $this->ci->config->item('admin_user');
         $password = $this->ci->config->item('admin_pw');

-        if ( !isset($_SERVER['PHP_AUTH_USER']) )
+        if(! $this->ci->config->item('realm'))
         {
-            header('WWW-Authenticate: Basic realm="SMF Studios"');
+            $realm = 'Pasword Protected Site';
+        }
+        else
+        {
+            $realm = $this->ci->config->item('realm');
+        }
+
+        if ( !isset($_SERVER['PHP_AUTH_USER']) || !$_SERVER['PHP_AUTH_USER'] )
+        {
+            header('WWW-Authenticate: Basic realm="' . $realm . '"');
             header('HTTP/1.0 401 Unauthorized');
             echo("Please enter a valid username and password");
             exit();        
@@ -54,4 +63,4 @@
     }
}


Messages In This Thread
Basic 401 Authentication Library - by El Forum - 12-24-2008, 10:15 AM
Basic 401 Authentication Library - by El Forum - 12-24-2008, 10:59 AM
Basic 401 Authentication Library - by El Forum - 12-24-2008, 05:58 PM
Basic 401 Authentication Library - by El Forum - 01-06-2009, 10:57 AM
Basic 401 Authentication Library - by El Forum - 01-06-2009, 12:36 PM
Basic 401 Authentication Library - by El Forum - 02-05-2009, 05:02 PM
Basic 401 Authentication Library - by El Forum - 03-04-2009, 01:02 PM
Basic 401 Authentication Library - by El Forum - 03-04-2009, 05:50 PM
Basic 401 Authentication Library - by El Forum - 02-01-2011, 11:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB