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',
|
|
|
|
"email" => $mail
|
|
|
|
);
|
|
|
|
$ic = array (
|
|
|
|
"username" => $username,
|
|
|
|
"balance" => "30",
|
|
|
|
"hidden" => "0"
|
|
|
|
);
|
|
|
|
$data = array (
|
|
|
|
"address" => $mail,
|
|
|
|
'verify' => '',
|
|
|
|
'statu' => '0',
|
|
|
|
'time' => date ( 'Y-m-d' ),
|
|
|
|
"user" => $username
|
|
|
|
);
|
|
|
|
if ($this->_insert ( 'authme', $value ) == 0) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
if ($this->_insert ( 'mail', $data ) == 0) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
if ($this->_insert ( 'iconomy', $ic ) == 0) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public function login($username, $password) {
|
2015-10-13 09:09:13 +00:00
|
|
|
if ($this->_sum ( "SELECT * FROM `authme` WHERE `username` = '$username' AND `password` = '$password'" ) == 0)
|
2015-10-13 06:26:47 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
public function pass($username, $newpass) {
|
|
|
|
$key = array (
|
|
|
|
"password" => $newpass
|
|
|
|
);
|
|
|
|
|
2015-10-13 09:09:13 +00:00
|
|
|
$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) {
|
|
|
|
$key = array (
|
|
|
|
"password" => $value
|
|
|
|
);
|
2015-10-13 09:09:13 +00:00
|
|
|
$num = $this->_update ( 'authme', $key, "WHERE username='" . $username . "'" );
|
2015-10-13 06:26:47 +00:00
|
|
|
// print_r($key);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|