<?php
class Auth {
  // properties
  var $classname   = "Auth";
  var $lifetime    = 0;
  var $id          = "";
  var $md5pass     = "";
  var $sharedValue = "";
  var $auth        = 0;
  
  /*
   * constructor
   *
   * generates random shared value for use in md5 password auth.
   * registers the class as a part of the user session.
   */
  function Auth() {
    $this->sharedValue = md5(uniqid(rand())); 
    return;
  }
  
  function setcrack($crack) {
    $this->crack = $crack;
    return;
  }
  
  function setid($id) {
    $this->id = $id;
    return;
  }
  /*
   * validate
   *
   * looks up our user in the db.
   * returns false if user/password doesn't match.
   */
  function validate($user, $md5pass) {
    $this->id = $user;
    $this->md5pass = $md5pass;
    if($this->matchPasswd()) {
      return 1;
    } else {
      return 0;
    }
  }
  
  /*
   * matchPasswd
   *
   * looks up our user in the db.
   * returns false if user/password doesn't match.
   */
  function matchPasswd() {
    $staticpass = "seth";
    $dbpass = md5($this->user . $this->sharedValue . $staticpass);
    if($this->md5pass == $dbpass) {
      return 1;
    } else {
      return 0;
    }
  } 
}
?>
