Location: PHPKode > projects > Replex > replex-0.9.0/lib/user.php
<?php
/*************************************************************
$Id: user.php,v 1.4 2001/05/02 15:08:31 jimir Exp $
 
 ***************************************************************/
 
class User {

  var $username;
  var $password;
  var $type;
  
  # Authenticate user. If the username/password is
  # valid.
  function HTTPauthenticate($DBCONN)
  {
    global $PHP_AUTH_USER;
    global $PHP_AUTH_PW;

    if (!isset($PHP_AUTH_USER) || !isset($PHP_AUTH_PW))
      return 0;
    else
    {
      $this->retrieveLogin($DBCONN, $PHP_AUTH_USER, $PHP_AUTH_PW);

      if ($this)
      {
        if (($this->getPassword()!=$PHP_AUTH_PW) || empty($PHP_AUTH_PW))
          return 0;
        else
          return 1;
      }

      return 0;
    }
  }
  
    # -- AUTHENTICATION FAILED --
  function http_refuse()
  {
    global $SERVER_SIGNATURE, $REALM;
    $REALM="Replex";
    header("WWW-Authenticate: Basic realm=\"".$REALM."\"");
    header("HTTP/1.1 401 Authorization Required");
    ?>
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <HTML><HEAD>
    <TITLE>401 Authorization Required</TITLE>
    </HEAD><BODY>
    <H1>Authorization Required</H1>
    This server could not verify that you
    are authorized to access the document
    requested.  Either you supplied the wrong
    credentials (e.g., bad password), or your
    browser doesn't understand how to supply
    the credentials required.<P>
    <HR>
    <ADDRESS><?php echo $SERVER_SIGNATURE ?></ADDRESS>
    </BODY></HTML>
    <?php
    exit;
  }
  
  function retrieveLogin($DBCONN, $username, $password) {
  	
    $query = "SELECT * FROM adminuser WHERE username='".$username."'";
    
    $DBCONN->QueryRow($query);
    $this->username=$DBCONN->data[username];
    $this->password=$DBCONN->data[password];
    $this->type=$DBCONN->data[type];
    
  }
  
  
  # GET Functions
  function getUsername() {
    return $this->username;
  }  
  function getPassword() {
    return $this->password;	
  }
  
  function getUserType() {
    return $this->type;	
  }

  
} //class end
?>
Return current item: Replex