function login_by_ip()
 {
     global $db, $db_prefix;
     $requesting_ip = $_SERVER['REMOTE_ADDR'];
     $sql = "select ip_range, usergroups from {$db_prefix}ipaccess where username = "******"uid={$this->uid},{$requesting_ip}", 0);
         return false;
     }
     foreach ($res as $row) {
         if ($this->_checkIPorRange($requesting_ip, $row['ip_range'])) {
             if ($row['usergroups'] != '') {
                 $groups = explode(',', $row['usergroups']);
                 foreach ($groups as $group) {
                     $this->groups[] = trim($group);
                 }
             }
             sess_log(LOG_LOGIN, 0, "uid={$this->uid},{$requesting_ip}", 1);
             return true;
         }
     }
     // no matching ip found
     sess_log(LOG_LOGIN, 0, "uid={$uid},{$requesting_ip}", 0);
     return false;
 }
 function login($uid, $pwd, $ip = 0)
 {
     $this->groups = array();
     $this->uid = $uid;
     if (!($ds = ldap_connect($this->host))) {
         return false;
     }
     if (!($r = @ldap_bind($ds, "uid={$uid},{$this->basedn}", $pwd))) {
         ldap_unbind($ds);
         sess_log(LOG_LOGIN, 0, "uid={$uid},{$this->basedn}", 0);
         return false;
     }
     $filter = "(&(objectclass=posixGroup)(memberuid={$uid}))";
     $retvals = array("cn");
     $sr = ldap_search($ds, $this->basedn, $filter, $retvals);
     $entries = ldap_get_entries($ds, $sr);
     $this->groups = array();
     for ($i = 0; $i < $entries["count"]; $i++) {
         for ($j = 0; $j < $entries[$i]["cn"]["count"]; $j++) {
             $this->groups[] = $entries[$i]["cn"][$j];
         }
     }
     ldap_free_result($sr);
     ldap_unbind($ds);
     //	print_r( $this->groups );
     sess_log(LOG_LOGIN, 0, "uid={$uid},{$this->basedn}", 1);
     return true;
 }
 function login($uid, $pwd, $ip = 0)
 {
     if (!array_key_exists($uid, $this->users)) {
         return false;
     }
     if ($this->users[$uid]['password'] != md5($pwd)) {
         return false;
     }
     $this->uid = $uid;
     sess_log(LOG_LOGIN, 0, "uid={$uid}", 1);
     return true;
 }