Viewing file: Auth_model.php (1.46 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
class Auth_model extends CI_Model
{
public function checkUser($email, $password){
return $this->db->get_where('users', array('email' => $email, 'password' => md5($password)))->num_rows() == 1;
}
public function insertUser($name, $email, $password, $city, $address) {
return $this->db->insert('users', array(
"id" => null,
"name" => $name,
"email" => $email,
"password" => md5($password),
"api_key" => md5($email.$password.(string)time()),
"balance" => 0,
"reg_date" => time(),
"type" => 0,
"city" => empty($city) ? "" : $city,
"address" => empty($address) ? "" : $address
));
}
public function checkEmail($email) {
return $this->db->get_where('users', array('email' => $email))->num_rows() == 1;
}
public function checkResetKey($key) {
return $this->db->query("SELECT * from users WHERE MD5(CONCAT(email,password)) = '$key'")->num_rows() == 1;
}
public function resetPasswordByKey($new_password,$key) {
$pass = md5($new_password);
$this->db->query("UPDATE users SET password = '$pass' WHERE MD5(CONCAT(email,password)) = '$key'");
}
public function getUserByEmail($email) {
$result = $this->db->get_where('users', array('email' => $email))->result_array();
return count($result) > 0 ? $result[0] : null;
}
}
?>
|