2015-10-13 06:26:47 +00:00
|
|
|
<?php
|
|
|
|
class authme extends AmysqlModel {
|
|
|
|
public function register($username, $password, $mail, $ip) {
|
|
|
|
$value = array (
|
|
|
|
"username" => $username,
|
|
|
|
"password" => $password,
|
|
|
|
"ip" => $ip,
|
|
|
|
"lastlogin" => '',
|
|
|
|
"x" => '0',
|
|
|
|
"y" => '0',
|
|
|
|
"z" => '0',
|
|
|
|
"world" => 'world',
|
2015-11-09 12:54:43 +00:00
|
|
|
"email" => $mail );
|
|
|
|
$data = array ("address" => $mail,'verify' => '','statu' => '0','time' => date ( 'Y-m-d' ),"user" => $username );
|
2015-10-31 12:00:01 +00:00
|
|
|
$this->_insert ( 'mail', $data );
|
|
|
|
if ($this->_insert ( 'authme', $value ) != 0)
|
|
|
|
return true;
|
|
|
|
else
|
2015-10-13 06:26:47 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
public function login($username, $password) {
|
2015-11-09 12:54:43 +00:00
|
|
|
$sum = $this->_sum ( "SELECT * FROM `authme` WHERE `username` = '$username' AND `password` = '$password'" );
|
2015-11-12 13:01:18 +00:00
|
|
|
if ($sum != 0)
|
2015-11-09 12:54:43 +00:00
|
|
|
return true;
|
2015-11-12 13:01:18 +00:00
|
|
|
else
|
|
|
|
return false;
|
2015-11-09 12:54:43 +00:00
|
|
|
}
|
2015-11-10 12:28:22 +00:00
|
|
|
public function clientlogin($username, $password) {
|
|
|
|
$sum = $this->_sum ( "SELECT * FROM `authme` WHERE `username` = '$username' AND `password` = '$password'" );
|
2015-11-12 13:01:18 +00:00
|
|
|
if ($sum != 0) {
|
|
|
|
$key = array ("isLogged" => 1 );
|
|
|
|
$this->_update ( 'authme', $key, "WHERE `username`='$username'" );
|
2015-11-10 12:28:22 +00:00
|
|
|
return true;
|
2015-11-12 13:01:18 +00:00
|
|
|
} else
|
2015-11-10 12:28:22 +00:00
|
|
|
return false;
|
|
|
|
}
|
2015-11-09 12:54:43 +00:00
|
|
|
public function clientcheck($username) {
|
|
|
|
$num = $this->_sum ( "SELECT * FROM `authme` WHERE `username`='$username' AND `isLogged`='1'" );
|
|
|
|
if ($num != 0)
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
public function clientlogout($username) {
|
|
|
|
$key = array ("isLogged" => 0 );
|
2015-11-12 13:01:18 +00:00
|
|
|
$num = $this->_update ( 'authme', $key, "WHERE `username`='$username'" );
|
|
|
|
if ($num != 0)
|
2015-10-13 06:26:47 +00:00
|
|
|
return true;
|
2015-11-12 13:01:18 +00:00
|
|
|
else
|
|
|
|
return false;
|
2015-10-13 06:26:47 +00:00
|
|
|
}
|
|
|
|
public function pass($username, $newpass) {
|
2015-11-09 12:54:43 +00:00
|
|
|
$key = array ("password" => $newpass );
|
|
|
|
$num = $this->_update ( 'authme', $key, "WHERE `username`='" . $username . "'" );
|
2015-10-13 06:26:47 +00:00
|
|
|
if ($num == 0)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
public function pass_forge($value, $username) {
|
2015-11-09 12:54:43 +00:00
|
|
|
$key = array ("password" => $value );
|
|
|
|
$num = $this->_update ( 'authme', $key, "WHERE `username`='" . $username . "'" );
|
2015-10-13 06:26:47 +00:00
|
|
|
if ($num == 0)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
public function check_user($user) {
|
2015-10-13 09:09:13 +00:00
|
|
|
$sum = $this->_sum ( "SELECT * FROM `authme` WHERE `username` = '" . $user . "'" );
|
2015-10-13 06:26:47 +00:00
|
|
|
if ($sum == 0)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|