Auth_HTTP
[ class tree: Auth_HTTP ] [ index: Auth_HTTP ] [ all elements ]

Source for file Auth_HTTP.php

Documentation is available at Auth_HTTP.php

  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2004 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license,      |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Martin Jansen <mj@php.net>                                  |
  17. // |          Rui Hirokawa <hirokawa@php.net>                             |
  18. // |          David Costa  <gurugeek@php.net>                             |
  19. // +----------------------------------------------------------------------+
  20. //
  21. //  $Id: Auth_HTTP.php,v 1.20 2004/08/08 03:01:46 hirokawa Exp $ 
  22. //
  23.  
  24. require_once "Auth/Auth.php";
  25.  
  26. define('AUTH_HTTP_NONCE_TIME_LEN'16);
  27. define('AUTH_HTTP_NONCE_HASH_LEN'32);
  28.  
  29. // {{{ class Auth_HTTP
  30.  
  31. /**
  32.  * PEAR::Auth_HTTP
  33.  *
  34.  * The PEAR::Auth_HTTP class provides methods for creating an
  35.  * HTTP authentication system based on RFC-2617 using PHP.
  36.  *
  37.  * Instead of generating an HTML driven form like PEAR::Auth
  38.  * does, this class sends header commands to the clients which
  39.  * cause them to present a login box like they are e.g. used
  40.  * in Apache's .htaccess mechanism.
  41.  *
  42.  * This class requires the PEAR::Auth package.
  43.  *
  44.  * @notes The HTTP Diegest Authentication part is based on
  45.  *   authentication class written by Tom Pike <tom.pike@xiven.com>
  46.  *
  47.  * @author  Martin Jansen <mj@php.net>
  48.  * @author  Rui Hirokawa <hirokawa@php.net>
  49.  * @author  David Costa <gurugeek@php.net>
  50.  * @package Auth_HTTP
  51.  * @extends Auth
  52.  * @version $Revision: 1.20 $
  53.  */
  54. class Auth_HTTP extends Auth
  55. {
  56.    
  57.     // {{{ properties
  58.  
  59.     /**
  60.      * Authorization method: 'basic' or 'digest'
  61.      *
  62.      * @access public
  63.      * @var    string 
  64.      */
  65.     var $authType = 'basic';
  66.  
  67.     /**
  68.      * Name of the realm for Basic Authentication
  69.      *
  70.      * @access public
  71.      * @var    string 
  72.      * @see    drawLogin()
  73.      */
  74.     var $realm = "protected area";
  75.  
  76.     /**
  77.      * Text to send if user hits cancel button
  78.      *
  79.      * @access public
  80.      * @var    string 
  81.      * @see    drawLogin()
  82.      */
  83.     var $CancelText = "Error 401 - Access denied";
  84.  
  85.     /**
  86.      * option array
  87.      *
  88.      * @access public
  89.      * @var    array 
  90.      */
  91.     var $options = array();
  92.  
  93.     /**
  94.      * flag to indicate the nonce was stale.
  95.      *
  96.      * @access public
  97.      * @var    bool 
  98.      */
  99.     var $stale = false;
  100.  
  101.     /**
  102.      * opaque string for digest authentication
  103.      *
  104.      * @access public
  105.      * @var    string 
  106.      */
  107.     var $opaque = 'dummy';
  108.  
  109.     /**
  110.      * digest URI
  111.      *
  112.      * @access public
  113.      * @var    string 
  114.      */
  115.     var $uri = '';
  116.  
  117.     /**
  118.      * authorization info returned by the client
  119.      *
  120.      * @access public
  121.      * @var    array 
  122.      */
  123.     var $auth = array();
  124.  
  125.     /**
  126.      * next nonce value
  127.      *
  128.      * @access public
  129.      * @var    string 
  130.      */
  131.     var $nextNonce = '';
  132.  
  133.     /**
  134.      * nonce value
  135.      *
  136.      * @access public
  137.      * @var    string 
  138.      */
  139.     var $nonce = '';
  140.  
  141.     /**
  142.      * Holds a reference to the global server variable
  143.      * @var array 
  144.      */
  145.     var $server;
  146.  
  147.     /**
  148.      * Holds a reference to the global post variable
  149.      * @var array 
  150.      */
  151.     var $post;
  152.  
  153.     /**
  154.      * Holds a reference to the global cookie variable
  155.      * @var array 
  156.      */
  157.     var $cookie;
  158.  
  159.  
  160.     // }}}
  161.     // {{{ Constructor
  162.  
  163.     /**
  164.      * Constructor
  165.      *
  166.      * @param string    Type of the storage driver
  167.      * @param mixed     Additional options for the storage driver
  168.      *                   (example: if you are using DB as the storage
  169.      *                    driver, you have to pass the dsn string here)
  170.      *
  171.      * @return void 
  172.      */
  173.     function Auth_HTTP($storageDriver$options ''
  174.     {
  175.         /* set default values for options */
  176.         $this->options = array('cryptType' => 'md5',
  177.                                'algorithm' => 'MD5',
  178.                                'qop' => 'auth-int,auth',
  179.                                'opaquekey' => 'moo',
  180.                                'noncekey' => 'moo',
  181.                                'digestRealm' => 'protected area',
  182.                                'forceDigestOnly' => false,
  183.                                'nonceLife' => 300,
  184.                                'sessionSharing' => true,
  185.                                );
  186.         
  187.         if (!empty($options['authType'])) {
  188.             $this->authType = strtolower($options['authType']);
  189.         }
  190.         
  191.         foreach($options as $key => $value{
  192.             if (array_key_exists$key$this->options)) {
  193.                 $this->options[$key$value;
  194.             }
  195.         }
  196.         
  197.         if (!empty($this->options['opaquekey'])) {
  198.             $this->opaque = md5($this->options['opaquekey']);
  199.         }
  200.         
  201.         $this->Auth($storageDriver$options);
  202.     }
  203.     
  204.     // }}}
  205.     // {{{ assignData()
  206.  
  207.     /**
  208.      * Assign values from $PHP_AUTH_USER and $PHP_AUTH_PW or 'Authorization' header
  209.      * to internal variables and sets the session id based
  210.      * on them
  211.      *
  212.      * @return void 
  213.      */
  214.     function assignData()
  215.     {
  216.         if (method_exists($this'_importGlobalVariable')) {
  217.             $this->server = &$this->_importGlobalVariable('server');
  218.         }
  219.         
  220.         
  221.         if ($this->authType == 'basic'{
  222.             if (!empty($this->server['PHP_AUTH_USER'])) {
  223.                 $this->username $this->server['PHP_AUTH_USER'];
  224.             }
  225.             
  226.             if (!empty($this->server['PHP_AUTH_PW'])) {
  227.                 $this->password $this->server['PHP_AUTH_PW'];
  228.             }
  229.             
  230.             /**
  231.              * Try to get authentication information from IIS
  232.              */
  233.             if  (empty($this->username&& empty($this->password)) {
  234.                 if (!empty($this->server['HTTP_AUTHORIZATION'])) {
  235.                     list($this->username$this->password
  236.                         explode(':'base64_decode(substr($this->server['HTTP_AUTHORIZATION']6)));
  237.                 }
  238.             }
  239.         elseif ($this->authType == 'digest'{
  240.          $this->username '';
  241.          $this->password '';
  242.  
  243.             $headers = getallheaders();
  244.             if(isset($headers['Authorization']&& !empty($headers['Authorization'])) {
  245.                 $authtemp explode(','substr($headers['Authorization'],
  246.                                                 strpos($headers['Authorization'],' ')+1));
  247.                 $auth = array();
  248.                 foreach($authtemp as $key => $value{
  249.                     $value trim($value);
  250.                     if(strpos($value,'='!== false{
  251.                         $lhs substr($value,0,strpos($value,'='));
  252.                         $rhs substr($value,strpos($value,'=')+1);
  253.                         if(substr($rhs,0,1== '"' && substr($rhs,-1,1== '"'{
  254.                             $rhs substr($rhs,1,-1);
  255.                         }
  256.                         $auth[$lhs$rhs;
  257.                     }
  258.                 }
  259.             }
  260.             if (!isset($auth['uri']|| !isset($auth['realm'])) {
  261.                 return;
  262.             }
  263.             
  264.             if ($this->selfURI(== $auth['uri']{
  265.                 $this->uri = $auth['uri'];
  266.                 if (substr($headers['Authorization'],0,7== 'Digest '{
  267.                     
  268.                     $this->authType = 'digest';
  269.  
  270.                     if (!isset($auth['nonce']|| !isset($auth['username']|| 
  271.                   !isset($auth['response']|| !isset($auth['qop']|| 
  272.                   !isset($auth['nc']|| !isset($auth['cnonce'])){
  273.                         return;
  274.                     }
  275.  
  276.                if ($auth['qop'!= 'auth' && $auth['qop'!= 'auth-int'{
  277.                         return;
  278.                }
  279.                     
  280.                     $this->stale = $this->_judgeStale($auth['nonce']);
  281.  
  282.                if ($this->nextNonce == false{
  283.                   return;
  284.                }
  285.  
  286.                     $this->username $auth['username'];
  287.                     $this->password $auth['response'];
  288.                     $this->auth['nonce'$auth['nonce'];
  289.                     
  290.                $this->auth['qop'$auth['qop'];
  291.                $this->auth['nc'$auth['nc'];
  292.                $this->auth['cnonce'$auth['cnonce'];
  293.  
  294.                     if (isset($auth['opaque'])) {
  295.                         $this->auth['opaque'$auth['opaque'];
  296.                     }
  297.                     
  298.                 elseif (substr($headers['Authorization'],0,6== 'Basic '{
  299.                     if ($this->options['forceDigestOnly']{
  300.                         return// Basic authentication is not allowed.
  301.                     }
  302.                     
  303.                     $this->authType = 'basic';
  304.                     list($username$password
  305.                         explode(':',base64_decode(substr($headers['Authorization'],6)));
  306.                     $this->username $username;
  307.                     $this->password $password;
  308.                 }
  309.             }
  310.         else {
  311.             return PEAR::raiseError('authType is invalid.');
  312.         }
  313.  
  314.         if ($this->options['sessionSharing'&& 
  315.             isset($this->username&& isset($this->password)) {
  316.             session_id(md5('Auth_HTTP' $this->username $this->password));
  317.         }
  318.         
  319.         /**
  320.          * set sessionName for AUTH, so that the sessionName is different 
  321.          * for distinct realms 
  322.          */
  323.          $this->_sessionName "_authhttp".md5($this->realm);
  324.     }
  325.  
  326.     // }}}
  327.     // {{{ login()
  328.  
  329.     /**
  330.      * Login function
  331.      *
  332.      * @access private
  333.      * @return void 
  334.      */
  335.     function login(
  336.     {
  337.         $login_ok = false;
  338.         if (method_exists($this'_loadStorage')) {
  339.             $this->_loadStorage();
  340.         }
  341.  
  342.         /**
  343.          * When the user has already entered a username,
  344.          * we have to validate it.
  345.          */
  346.         if (!empty($this->username&& !empty($this->password)) {
  347.             if ($this->authType == 'basic' && !$this->options['forceDigestOnly']{
  348.                 if (true === $this->storage->fetchData($this->username$this->password)) {
  349.                     $login_ok = true;
  350.                 }
  351.             else /* digest authentication */
  352.  
  353.                 if (!$this->getAuth(|| $this->getAuthData('a1'== null{
  354.                     /* 
  355.                      * note:
  356.                      *  - only PEAR::DB is supported as container.
  357.                      *  - password should be stored in container as plain-text 
  358.                      *    (if $options['cryptType'] == 'none') or 
  359.                      *     A1 hashed form (md5('username:realm:password')) 
  360.                      *    (if $options['cryptType'] == 'md5')
  361.                      */
  362.                     $dbs $this->storage;
  363.                     if (!DB::isConnection($dbs->db)) {
  364.                         $dbs->_connect($dbs->options['dsn']);
  365.                     }
  366.                     
  367.                     $query 'SELECT '.$dbs->options['passwordcol']." FROM ".$dbs->options['table'].
  368.                         ' WHERE '.$dbs->options['usernamecol']." = '".
  369.                         $dbs->db->quoteString($this->username)."' ";
  370.                     
  371.                     $pwd $dbs->db->getOne($query)// password stored in container.
  372.                     
  373.                     if (DB::isError($pwd)) {
  374.                         return PEAR::raiseError($pwd->getMessage()$pwd->getCode());
  375.                     }
  376.                     
  377.                     if ($this->options['cryptType'== 'none'{
  378.                         $a1 md5($this->username.':'.$this->options['digestRealm'].':'.$pwd);
  379.                     else {
  380.                         $a1 $pwd;
  381.                     }
  382.                     
  383.                     $this->setAuthData('a1'$a1true);
  384.                 else {
  385.                     $a1 $this->getAuthData('a1');
  386.                 }
  387.                 
  388.                 $login_ok $this->validateDigest($this->password$a1);
  389.                 if ($this->nextNonce == false{
  390.                     $login_ok = false;
  391.                 }
  392.             }
  393.             
  394.             if (!$login_ok && is_callable($this->loginFailedCallback)) {
  395.                 call_user_func($this->loginFailedCallback,$this->username$this);
  396.             }
  397.         }
  398.         
  399.         if (!empty($this->username&& $login_ok{
  400.             $this->setAuth($this->username);
  401.             if (is_callable($this->loginCallback)) {
  402.                 call_user_func($this->loginCallback,$this->username$this);
  403.             }
  404.         }
  405.         
  406.         /**
  407.          * If the login failed or the user entered no username,
  408.          * output the login screen again.
  409.          */
  410.         if (!empty($this->username&& !$login_ok{
  411.             $this->status = AUTH_WRONG_LOGIN;
  412.         }
  413.         
  414.         if ((empty($this->username|| !$login_ok&& $this->showLogin{
  415.             $this->drawLogin($this->storage->activeUser);
  416.             return;
  417.         }
  418.  
  419.       if (!empty($this->username&& $login_ok && $this->authType == 'digest'
  420.          && $this->auth['qop'== 'auth'
  421.          $this->authenticationInfo();
  422.       }
  423.     }
  424.     
  425.     // }}}
  426.     // {{{ drawLogin()
  427.  
  428.     /**
  429.      * Launch the login box
  430.      *
  431.      * @param  string $username  Username
  432.      * @return void 
  433.      */
  434.     function drawLogin($username "")
  435.     {
  436.         /**
  437.          * Send the header commands
  438.          */
  439.         if ($this->authType == 'basic'{
  440.             header("WWW-Authenticate: Basic realm=\"".$this->realm."\"");
  441.             header('HTTP/1.0 401 Unauthorized');            
  442.         else if ($this->authType == 'digest'{
  443.             $this->nonce = $this->_getNonce();
  444.  
  445.             $wwwauth 'WWW-Authenticate: Digest ';
  446.             $wwwauth .= 'qop="'.$this->options['qop'].'", ';
  447.             $wwwauth .= 'algorithm='.$this->options['algorithm'].', ';
  448.             $wwwauth .= 'realm="'.$this->options['digestRealm'].'", ';
  449.             $wwwauth .= 'nonce="'.$this->nonce.'", ';
  450.             if ($this->stale{
  451.                 $wwwauth .= 'stale=true, ';
  452.             }
  453.             if (!empty($this->opaque)) {
  454.                 $wwwauth .= 'opaque="'.$this->opaque.'"' ;
  455.             }
  456.             $wwwauth .= "\r\n";
  457.             if (!$this->options['forceDigestOnly']{
  458.                 $wwwauth .= 'WWW-Authenticate: Basic realm="'.$this->realm.'"';
  459.             }
  460.             header($wwwauth);
  461.             header('HTTP/1.0 401 Unauthorized');            
  462.         }
  463.  
  464.         /**
  465.          * This code is only executed if the user hits the cancel
  466.          * button or if he enters wrong data 3 times.
  467.          */
  468.         if ($this->stale{
  469.             echo 'Stale nonce value, please re-authenticate.';
  470.         else {
  471.             echo $this->CancelText;
  472.         }
  473.         exit;
  474.     }
  475.  
  476.     // }}}
  477.     // {{{ setRealm()
  478.  
  479.     /**
  480.      * Set name of the current realm
  481.      *
  482.      * @access public
  483.      * @param  string $realm  Name of the realm
  484.      * @param  string $digestRealm  Name of the realm for digest authentication
  485.      * @return void 
  486.      */
  487.     function setRealm($realm$digestRealm '')
  488.     {
  489.         $this->realm = $realm;
  490.         if (!empty($digestRealm)) {
  491.             $this->options['digestRealm'$digestRealm;
  492.         }
  493.     }
  494.  
  495.     // }}}
  496.     // {{{ setCancelText()
  497.  
  498.     /**
  499.      * Set the text to send if user hits the cancel button
  500.      *
  501.      * @access public
  502.      * @param  string $text  Text to send
  503.      * @return void 
  504.      */
  505.     function setCancelText($text)
  506.     {
  507.         $this->CancelText = $text;
  508.     }
  509.  
  510.     // }}}
  511.     // {{{ validateDigest()
  512.     
  513.     /**
  514.      * judge if the client response is valid.
  515.      *
  516.      * @access public
  517.      * @param  string $response  client response
  518.      * @param  string $a1 password or hashed password stored in container
  519.      * @return bool true if success, false otherwise
  520.      */
  521.     function validateDigest($response$a1)    
  522.     {
  523.         if (method_exists($this'_importGlobalVariable')) {
  524.             $this->server = &$this->_importGlobalVariable('server');
  525.         }
  526.  
  527.         $a2unhashed $this->server['REQUEST_METHOD'].":".$this->selfURI();
  528.         if($this->auth['qop'== 'auth-int'{
  529.             if(isset($GLOBALS["HTTP_RAW_POST_DATA"])) {
  530.                 // In PHP < 4.3 get raw POST data from this variable
  531.                 $body $GLOBALS["HTTP_RAW_POST_DATA"];
  532.             else if($lines @file('php://input')) {
  533.                 // In PHP >= 4.3 get raw POST data from this file
  534.                 $body implode("\n"$lines);
  535.             else {
  536.                 if (method_exists($this'_importGlobalVariable')) {
  537.                     $this->post = &$this->_importGlobalVariable('post');
  538.                 }
  539.                 $body '';
  540.                 foreach($this->post as $key => $value{
  541.                     if($body != ''$body .= '&';
  542.                     $body .= rawurlencode($key'=' rawurlencode($value);
  543.                 }
  544.             }
  545.  
  546.             $a2unhashed .= ':'.md5($body);
  547.         }
  548.         
  549.         $a2 md5($a2unhashed);
  550.         $combined $a1.':'.
  551.             $this->auth['nonce'].':'.
  552.             $this->auth['nc'].':'.
  553.             $this->auth['cnonce'].':'.
  554.             $this->auth['qop'].':'.
  555.             $a2;
  556.         $expectedResponse md5($combined);
  557.         
  558.         if(!isset($this->auth['opaque']|| $this->auth['opaque'== $this->opaque{
  559.             if($response == $expectedResponse// password is valid
  560.                 if(!$this->stale{
  561.                     return true;
  562.                 else {
  563.                     $this->drawLogin();
  564.                 }
  565.             }
  566.         }
  567.         
  568.         return false;
  569.     }
  570.     
  571.     // }}}
  572.     // {{{ _judgeStale()
  573.     
  574.     /**
  575.      * judge if nonce from client is stale.
  576.      *
  577.      * @access private
  578.      * @param  string $nonce  nonce value from client
  579.      * @return bool stale
  580.      */
  581.     function _judgeStale($nonce
  582.     {
  583.         $stale = false;
  584.         
  585.         if(!$this->_decodeNonce($nonce$time$hash_cli)) {
  586.          $this->nextNonce = false;
  587.          $stale = true;
  588.             return $stale;
  589.         }
  590.  
  591.         if ($time time($this->options['nonceLife']{
  592.          $this->nextNonce = $this->_getNonce();
  593.             $stale = true;
  594.         else {
  595.          $this->nextNonce = $nonce;
  596.       }
  597.  
  598.         return $stale;
  599.     }
  600.     
  601.     // }}}
  602.     // {{{ _nonceDecode()
  603.     
  604.     /**
  605.      * decode nonce string
  606.      *
  607.      * @access private
  608.      * @param  string $nonce nonce value from client
  609.      * @param  string $time decoded time
  610.      * @param  string $hash decoded hash
  611.      * @return bool false if nonce is invalid
  612.      */
  613.     function _decodeNonce($nonce&$time&$hash
  614.     {
  615.         if (method_exists($this'_importGlobalVariable')) {
  616.             $this->server = &$this->_importGlobalVariable('server');
  617.         }
  618.  
  619.         if (strlen($nonce!= AUTH_HTTP_NONCE_TIME_LEN + AUTH_HTTP_NONCE_HASH_LEN{
  620.             return false;
  621.         }
  622.  
  623.         $time =  base64_decode(substr($nonce0AUTH_HTTP_NONCE_TIME_LEN));
  624.         $hash_cli substr($nonceAUTH_HTTP_NONCE_TIME_LENAUTH_HTTP_NONCE_HASH_LEN);
  625.  
  626.         $hash md5($time $this->server['HTTP_USER_AGENT'$this->options['noncekey']);
  627.  
  628.         if ($hash_cli != $hash{
  629.             return false;
  630.         }
  631.         
  632.         return true;
  633.     }
  634.  
  635.     // }}}
  636.     // {{{ _getNonce()
  637.     
  638.     /**
  639.      * return nonce to detect timeout
  640.      *
  641.      * @access private
  642.      * @return string nonce value
  643.      */
  644.     function _getNonce(
  645.     {
  646.         if (method_exists($this'_importGlobalVariable')) {
  647.             $this->server = &$this->_importGlobalVariable('server');
  648.         }
  649.  
  650.         $time time();
  651.         $hash md5($time $this->server['HTTP_USER_AGENT'$this->options['noncekey']);
  652.  
  653.         return base64_encode($time$hash;  
  654.     }
  655.  
  656.     // }}}
  657.     // {{{ authenticationInfo()
  658.     
  659.     /**
  660.      * output HTTP Authentication-Info header
  661.      *
  662.      * @notes md5 hash of contents is required if 'qop' is 'auth-int'
  663.      *
  664.      * @access public
  665.      * @param string MD5 hash of content
  666.      */
  667.     function authenticationInfo($contentMD5 ''{
  668.         
  669.         if($this->getAuth(&& ($this->getAuthData('a1'!= null)) {
  670.             $a1 $this->getAuthData('a1');
  671.  
  672.             // Work out authorisation response
  673.             $a2unhashed ":".$this->selfURI();
  674.             if($this->auth['qop'== 'auth-int'{
  675.                 $a2unhashed .= ':'.$contentMD5;
  676.             }
  677.             $a2 md5($a2unhashed);
  678.             $combined $a1.':'.
  679.                         $this->nonce.':'.
  680.                         $this->auth['nc'].':'.
  681.                         $this->auth['cnonce'].':'.
  682.                         $this->auth['qop'].':'.
  683.                         $a2;
  684.             
  685.             // Send authentication info
  686.             $wwwauth 'Authentication-Info: ';
  687.             if($this->nonce != $this->nextNonce{
  688.                 $wwwauth .= 'nextnonce="'.$this->nextNonce.'", ';
  689.             }
  690.             $wwwauth .= 'qop='.$this->auth['qop'].', ';
  691.             $wwwauth .= 'rspauth="'.md5($combined).'", ';
  692.             $wwwauth .= 'cnonce="'.$this->auth['cnonce'].'", ';
  693.             $wwwauth .= 'nc='.$this->auth['nc'].'';
  694.             header($wwwauth);
  695.         }
  696.     }
  697.     // }}}
  698.     // {{{ setOption()
  699.     /**
  700.      * set authentication option
  701.      *
  702.      * @access public
  703.      * @param mixed $name key of option
  704.      * @param mixed $value value of option
  705.      * @return void 
  706.      */
  707.     function setOption($name$value = null
  708.     {
  709.         if (is_array($name)) {
  710.             foreach($name as $key => $value{
  711.                 if (array_key_exists$key$this->options)) {
  712.                     $this->options[$key$value;
  713.                 }
  714.             }
  715.         else {
  716.             if (array_key_exists$name$this->options)) {
  717.                     $this->options[$name$value;
  718.             }
  719.         }
  720.     }
  721.  
  722.     // }}}
  723.     // {{{ getOption()
  724.     /**
  725.      * get authentication option
  726.      *
  727.      * @access public
  728.      * @param string $name key of option
  729.      * @return mixed option value
  730.      */
  731.     function getOption($name
  732.     {
  733.         if (array_key_exists$name$this->options)) {
  734.             return $this->options[$name];
  735.         }
  736.         if ($name == 'CancelText'{
  737.             return $this->CancelText;
  738.         }
  739.         if ($name == 'Realm'{
  740.             return $this->realm;
  741.         }
  742.         return false;
  743.     }
  744.  
  745.     // }}}
  746.     // {{{ selfURI()
  747.     /**
  748.      * get self URI
  749.      *
  750.      * @access public
  751.      * @return string self URI
  752.      */
  753.     function selfURI(
  754.     {
  755.         if (method_exists($this'_importGlobalVariable')) {
  756.             $this->server = &$this->_importGlobalVariable('server');
  757.         }
  758.  
  759.         if (preg_match("/MSIE/",$this->server['HTTP_USER_AGENT'])) {
  760.             // query string should be removed for MSIE
  761.             $uri preg_replace("/^(.*)\?/","\\1",$this->server['REQUEST_URI']);
  762.         else {
  763.             $uri $this->server['REQUEST_URI'];
  764.         }
  765.         return $uri;
  766.     }
  767.  
  768.     // }}}
  769.  
  770. }
  771.  
  772. // }}}
  773.  
  774. /*
  775.  * Local variables:
  776.  * tab-width: 4
  777.  * c-basic-offset: 4
  778.  * End:
  779.  */
  780. ?>

Documentation generated on Mon, 11 Mar 2019 13:55:01 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.