cvs: pear /Forum/lib/classes/db MysqlUser.php
| From: | Thomas V.V.Cox | Date: | Fri, 12 Oct 2001 17:40:25 +0000 |
| Subject: | cvs: pear /Forum/lib/classes/db MysqlUser.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-988@lists.php.net to get a copy of this message | ||
cox Fri Oct 12 13:40:25 2001 EDT
Added files:
/pear/Forum/lib/classes/db MysqlUser.php
Log:
this file is needed no?
Index: pear/Forum/lib/classes/db/MysqlUser.php
+++ pear/Forum/lib/classes/db/MysqlUser.php
<?PHP
if(!class_exists("Mysql")) {
require_once("$PHORUM[LIB]/classes/db/Mysql.php");
}
/**
* User backend, extends db class.
*
* @author Morgan Christiansson <mog@linux.nu>
* @access public
* @package user
*/
class MysqlUser extends Mysql {
/**
* Gets and returns user with user_id.
*
* @author Morgan Christiansson
* @param string $user_id (usually containing an int) user_id
* @param string $field Field to match $user against, usually "user" or
"user_id"
* @return $user Array with user headers.
*/
function get_user($user,$field="user") {
$SQL="SELECT * FROM $this->user_table WHERE $field='$user' LIMIT 1";
return $this->get_row(&$SQL);
}
/**
* Inserts a new user into the DB.
* Valid headers for this user backend are: nick, pass, homepage, email, image, signature.
*
* @author Morgan Christiansson
* @param array $user An array with fields that should be entered into the DB.
*/
function insert_user($user) {
$SQL="INSERT INTO $this->user_table"
." SET"
." nick='$user[nick]'"
." pass='".md5($user["pass"])."'"
." homepage='$user[homepage]'"
." email='$user[email]'"
." image='$user[image]'"
." signature='$user[signature]'";
return $this->query(&$SQL);
}
/**
* Update user settings.
*
* @author Morgan Christiansson
* @param string $user
*/
function update_user($user) {
$SQL="UPDATE $this->user_table"
." SET"
." nick='$user[nick]'"
." pass='".md5($user["pass"])."'"
." homepage='$user[homepage]'"
." email='$user[email]'"
." image='$user[image]'"
." signature='$user[signature]'"
." status='$user[status]'";
return $this->query(&$SQL);
}
/**
* Check if password md5sum $md5 matches md5sum from $user
*
* @author Morgan Christiansson
* @param array $user array returned from get_user
* @param string $md5 md5 sum of the password
* @return bool $is_user True if user exists and md5sum matches, false otherwise.
*/
function check_user($user,$md5) {
if(md5($user["pass"]) == $md5) {
return TRUE;
} else {
return FALSE;
}
}
}
?>