Commit 9d90ef01 authored by natrak's avatar natrak
Browse files

Adding the user.class

parent 1ccf830e
<?
$access = array("Administrator" => 0x00000001,
"User manager" => 0x00000002,
"News manager" => 0x00000004);
class User {
function User($userid, $passwd="") {
dbconnect();
$result = mysql_query("SELECT * FROM testusers WHERE LOWER(userid)=LOWER('$userid') && passwd=PASSWORD('$passwd') && STATUS=0") or die(sprintf("Critical error at line %d in %s: %s", __LINE__, __FILE__, mysql_error()));
if (mysql_num_rows($result) == 1) {
foreach (mysql_fetch_array($result) as $key=>$value) { $this->$key = $value; }
}
}
function update() {
dbconnect();
$result = mysql_query("SELECT * FROM users WHERE id=$this->id") or die(sprintf("Critical error at line %d in %s: %s", __LINE__, __FILE__, mysql_error()));
if (mysql_num_rows($result) == 1) {
foreach (mysql_fetch_array($result) as $key=>$value) { $this->$key = $value; }
}
}
function valid($access=0) {
if (!empty($this->userid)) {
$this->last_access = time();
$this->last_host = (!empty($GLOBALS[REMOTE_HOST]) ? $GLOBALS[REMOTE_HOST] : $GLOBALS[REMOTE_ADDR] );
dbconnect();
mysql_query("UPDATE users SET last_access='$this->last_access',last_host='$this->last_host' WHERE id=$this->id") or die(sprintf("Critical error at line %d in %s: %s", __LINE__, __FILE__, mysql_error()));
if ($this->access & $access || $access == 0) return 1;
}
return 0;
}
}
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment