2021-10-30 19:02:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class User_model extends MO_Model
|
|
|
|
{
|
2021-11-14 11:02:22 +01:00
|
|
|
public function __construct()
|
2021-10-30 19:02:07 +02:00
|
|
|
{
|
2021-11-14 11:02:22 +01:00
|
|
|
parent::__construct();
|
2021-10-30 19:02:07 +02:00
|
|
|
}
|
2021-11-14 11:02:22 +01:00
|
|
|
|
|
|
|
public function login_check($data)
|
2021-10-30 19:02:07 +02:00
|
|
|
{
|
2021-11-14 11:02:22 +01:00
|
|
|
$sql = "SELECT passkey FROM users WHERE username=" . $this->db->escape($data['username']);
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
$q = $this->db->query($sql);
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
if ($q->num_rows > 0) {
|
|
|
|
$row = $q->row_array();
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
if ($row['passkey'] == $data['password']) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2021-10-30 19:02:07 +02:00
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
public function get_userid($username)
|
2021-10-30 19:02:07 +02:00
|
|
|
{
|
2021-11-14 11:02:22 +01:00
|
|
|
$sql = "SELECT id FROM users WHERE username=" . $this->db->escape($username);
|
|
|
|
$q = $this->db->query($sql);
|
|
|
|
$res = $q->row_array();
|
|
|
|
|
|
|
|
return $res['id'];
|
2021-10-30 19:02:07 +02:00
|
|
|
}
|
2021-11-14 11:02:22 +01:00
|
|
|
|
|
|
|
public function reg_username_check($uname)
|
2021-10-30 19:02:07 +02:00
|
|
|
{
|
2021-11-14 11:02:22 +01:00
|
|
|
$sql = "SELECT username FROM users WHERE username=" . $this->db->escape($uname);
|
|
|
|
|
|
|
|
$q = $this->db->query($sql);
|
|
|
|
|
|
|
|
if ($q->num_rows() == 0) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2021-10-30 19:02:07 +02:00
|
|
|
}
|
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
public function reg_write($data)
|
|
|
|
{
|
|
|
|
$sql = "INSERT INTO users VALUES(default, "
|
|
|
|
. $this->db->escape($data['username']) . ", '"
|
|
|
|
. $data['password'] . "', '"
|
2021-10-30 19:02:07 +02:00
|
|
|
. $data['email'] . "',
|
|
|
|
default, default, default)";
|
|
|
|
|
|
|
|
|
2021-11-14 11:02:22 +01:00
|
|
|
return $this->db->query($sql);
|
|
|
|
}
|
2021-10-30 19:02:07 +02:00
|
|
|
}
|
|
|
|
//nowhitesp
|