cvs: pear /Auth_HTTP Auth_HTTP.php
| From: | Martin Jansen | Date: | Fri, 24 Aug 2001 21:30:22 +0000 |
| Subject: | cvs: pear /Auth_HTTP Auth_HTTP.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-657@lists.php.net to get a copy of this message | ||
mj Fri Aug 24 17:30:22 2001 EDT
Modified files:
/pear/Auth_HTTP Auth_HTTP.php
Log:
* improved comments
Index: pear/Auth_HTTP/Auth_HTTP.php
diff -u pear/Auth_HTTP/Auth_HTTP.php:1.2 pear/Auth_HTTP/Auth_HTTP.php:1.3
--- pear/Auth_HTTP/Auth_HTTP.php:1.2 Fri Aug 24 17:22:00 2001
+++ pear/Auth_HTTP/Auth_HTTP.php Fri Aug 24 17:30:22 2001
@@ -16,7 +16,7 @@
// | Authors: Martin Jansen <mj@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: Auth_HTTP.php,v 1.2 2001/08/24 21:22:00 mj Exp $
+// $Id: Auth_HTTP.php,v 1.3 2001/08/24 21:30:22 mj Exp $
//
require_once "Auth/Auth.php";
@@ -27,21 +27,29 @@
* The PEAR::Auth_HTTP class provides methods for creating an
* HTTP authentication system using PHP.
*
+ * Instead of generating an HTML driven form like PEAR::Auth
+ * does, this class sends header commands to the clients which
+ * cause them to present a login box like they are e.g. used
+ * in Apache's .htaccess mechanism.
+ *
+ * This class requires the PEAR::Auth package.
+ *
* @author Martin Jansen <mj@php.net>
* @package Auth_HTTP
* @extends Auth
- * @version $Revision: 1.2 $
- * @todo Clean up PHPDoc comments
+ * @version $Revision: 1.3 $
*/
class Auth_HTTP extends Auth
{
-
+
+ // {{{ properties
+
/**
* Name of the realm
*
* @access public
* @var string
- * @see draw_login()
+ * @see drawLogin()
*/
var $realm = "protected area";
@@ -50,10 +58,19 @@
*
* @access public
* @var string
- * @see draw_login()
+ * @see drawLogin()
*/
- var $CancelText = "invalid login data";
+ var $CancelText = "Error 401 - Access denied";
+ // }}}
+ // {{{ assignData()
+
+ /**
+ * Assign values from $PHP_AUTH_USER and $PHP_AUTH_PW
+ * to internal variables
+ *
+ * @global $PHP_AUTH_USER, $PHP_AUTH_PW
+ */
function assignData()
{
global $PHP_AUTH_USER,$PHP_AUTH_PW;
@@ -67,6 +84,9 @@
}
}
+ // }}}
+ // {{{ drawLogin()
+
/**
* Launch the login box
*
@@ -75,12 +95,23 @@
*/
function drawLogin($username = "", $password = "")
{
+ /**
+ * Send the header commands
+ */
Header("WWW-Authenticate: Basic
realm=\"".$this->realm."\"");
Header("HTTP/1.0 401 Unauthorized");
+
+ /**
+ * This code is only executed if the user hits the cancel
+ * button or if he enters wrong data 3 times.
+ */
echo $this->CancelText;
exit;
}
+ // }}}
+ // {{{ setRealm()
+
/**
* Set name of the current realm
*
@@ -91,6 +122,9 @@
$this->realm = $name;
}
+ // }}}
+ // {{{ setCancelText()
+
/**
* Set the text to send if user hits the cancel button
*
@@ -100,5 +134,7 @@
function setCancelText($text) {
$this->CancelText = $text;
}
+
+ // }}}
}
?>