1
0
mirror of https://e.coding.net/circlecloud/McAccount.git synced 2024-11-21 01:38:55 +00:00
McAccount/Model/authme.php
502647092 68e7fe8c2e 允许退出10秒内免登陆...
Signed-off-by: 502647092 <jtb1@163.com>
2015-11-19 19:04:23 +08:00

80 lines
2.4 KiB
PHP

<?php
class authme extends AmysqlModel {
public function register($username, $password, $mail, $ip) {
$value = array (
"username" => $username,
"password" => $password,
"ip" => $ip,
"lastlogin" => time (),
"x" => '0',
"y" => '0',
"z" => '0',
"world" => 'world',
"email" => $mail );
$data = array ("address" => $mail,'verify' => '','statu' => '0','time' => date ( 'Y-m-d' ),"user" => $username );
$this->_insert ( 'mail', $data );
if ($this->_insert ( 'authme', $value ) != 0)
return true;
else
return false;
}
public function login($username, $password) {
$sum = $this->_sum ( "SELECT * FROM `authme` WHERE `username` = '$username' AND `password` = '$password'" );
if ($sum != 0)
return true;
else
return false;
}
public function clientlogin($username, $password) {
$sum = $this->_sum ( "SELECT * FROM `authme` WHERE `username` = '$username' AND `password` = '$password'" );
if ($sum != 0) {
$key = array ("isLogged" => 1 );
$this->_update ( 'authme', $key, "WHERE `username`='$username'" );
return true;
} else
return false;
}
public function clientcheck($username) {
$num = $this->_sum ( "SELECT * FROM `authme` WHERE `username`='$username' AND `isLogged`='1'" );
if ($num != 0)
return true;
else {
$last = $this->_sum ( "SELECT * FROM `authme` WHERE `username`='$username' AND `lastlogin`>" . (time () - 10) );
if ($last != 0) {
return true;
} else {
return false;
}
}
}
public function clientlogout($username) {
$key = array ("isLogged" => 0,"lastlogin" => time () );
$num = $this->_update ( 'authme', $key, "WHERE `username`='$username'" );
if ($num != 0)
return true;
else
return false;
}
public function pass($username, $newpass) {
$key = array ("password" => $newpass );
$num = $this->_update ( 'authme', $key, "WHERE `username`='" . $username . "'" );
if ($num == 0)
return false;
return true;
}
public function pass_forge($value, $username) {
$key = array ("password" => $value );
$num = $this->_update ( 'authme', $key, "WHERE `username`='" . $username . "'" );
if ($num == 0)
return false;
return true;
}
public function check_user($user) {
$sum = $this->_sum ( "SELECT * FROM `authme` WHERE `username` = '" . $user . "'" );
if ($sum == 0)
return true;
return false;
}
}
?>