1
0
mirror of https://e.coding.net/circlecloud/McAccount.git synced 2024-11-22 01:48:55 +00:00

添加用户检测 和用户登录 登出...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-11-09 20:54:43 +08:00
parent eaef526fd3
commit da6ef10111
2 changed files with 40 additions and 21 deletions

View File

@ -13,9 +13,23 @@ class user_public extends AmysqlController {
function login() { function login() {
if ($this->_model ( "authme" )->login ( @$_REQUEST ['user'], md5 ( @$_REQUEST ['pass'] ) )) { if ($this->_model ( "authme" )->login ( @$_REQUEST ['user'], md5 ( @$_REQUEST ['pass'] ) )) {
$_SESSION ['username'] = @$_REQUEST ['user']; $_SESSION ['username'] = @$_REQUEST ['user'];
JsonSuccess ( '登陆成功' ); JsonSuccess ( '登陆成功!' );
} else { } else {
JsonError ( '登陆失败' ); JsonError ( '登陆失败!' );
}
}
function clientcheck() {
if ($this->_model ( "authme" )->clientcheck ( @$_REQUEST ['user'] )) {
JsonSuccess ( '通过验证 允许登录服务器!' );
} else {
JsonError ( '未通过验证 请T出服务器!' );
}
}
function clientlogout() {
if ($this->_model ( "authme" )->clientlogout ( @$_REQUEST ['user'] )) {
JsonSuccess ( '离线成功!' );
} else {
JsonError ( '离线失败!' );
} }
} }
function pass() { function pass() {

View File

@ -10,15 +10,8 @@ class authme extends AmysqlModel {
"y" => '0', "y" => '0',
"z" => '0', "z" => '0',
"world" => 'world', "world" => 'world',
"email" => $mail "email" => $mail );
); $data = array ("address" => $mail,'verify' => '','statu' => '0','time' => date ( 'Y-m-d' ),"user" => $username );
$data = array (
"address" => $mail,
'verify' => '',
'statu' => '0',
'time' => date ( 'Y-m-d' ),
"user" => $username
);
$this->_insert ( 'mail', $data ); $this->_insert ( 'mail', $data );
if ($this->_insert ( 'authme', $value ) != 0) if ($this->_insert ( 'authme', $value ) != 0)
return true; return true;
@ -26,26 +19,38 @@ class authme extends AmysqlModel {
return false; return false;
} }
public function login($username, $password) { public function login($username, $password) {
if ($this->_sum ( "SELECT * FROM `authme` WHERE `username` = '$username' AND `password` = '$password'" ) == 0) $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;
}
}
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 );
$num = $this->_update ( 'authme', $key, "WHERE `username`='" . $username . "'" );
if ($num == 0)
return false; return false;
else else
return true; return true;
} }
public function pass($username, $newpass) { public function pass($username, $newpass) {
$key = array ( $key = array ("password" => $newpass );
"password" => $newpass $num = $this->_update ( 'authme', $key, "WHERE `username`='" . $username . "'" );
);
$num = $this->_update ( 'authme', $key, "WHERE username='" . $username . "'" );
if ($num == 0) if ($num == 0)
return false; return false;
return true; return true;
} }
public function pass_forge($value, $username) { public function pass_forge($value, $username) {
$key = array ( $key = array ("password" => $value );
"password" => $value $num = $this->_update ( 'authme', $key, "WHERE `username`='" . $username . "'" );
);
$num = $this->_update ( 'authme', $key, "WHERE username='" . $username . "'" );
// print_r($key);
if ($num == 0) if ($num == 0)
return false; return false;
return true; return true;