Re: [PHP-PEAR] RFC on merge of PHPLib and Pear

[email protected] ((Kristian Koehntopp)) 10 Mar 2001 12:00:20 -0000
Newsgroups netuse.lists.php-pear
Message-ID <[email protected]>
In netuse.lists.php-pear you write:
>> I should be able to pass a parameter to the Auth_ip constructor to 
>> tell it what ips are valid,

>Use the $GLOBALS[] name space or -- and there your argument
>comes true that this could be improved -- change auth.php
>that it calls $this->validatelogin() with a parameter (i.e.
>Hash to be flexible).

Not correct.

class Auth_IP extends Auth {
  var $valid_ip = array();
  
  function Auth_IP($ip = "") {
    if (!is_array($ip))
      return;
    
    $this->valid_ip = $ip;
  }
  
  function auth_preauth() {
    global $HTTP_SERVER_VARS;
    
    $ip = $HTTP_SERVER_VARS["REMOTE_ADDR"];
    
    if (isset($this->valid_ip($ip)) {
      return md5($ip);
    }
    
    return false;
  }
}

$auth = new Auth_IP(array("....."));

There you go.

Kristian