Naming change, more dead code & vars removed
This commit is contained in:
parent
f121211a14
commit
55f669b5d8
|
@ -30,7 +30,7 @@ class Token
|
||||||
* @param String $data
|
* @param String $data
|
||||||
* @return int count of results in database
|
* @return int count of results in database
|
||||||
*/
|
*/
|
||||||
public static function validate_token($token, $id, $data)
|
public static function validate($token, $id, $data)
|
||||||
{
|
{
|
||||||
global $mysqli;
|
global $mysqli;
|
||||||
$time = time();
|
$time = time();
|
||||||
|
|
|
@ -273,7 +273,7 @@ class User
|
||||||
$id = $_COOKIE['user'];
|
$id = $_COOKIE['user'];
|
||||||
$token = $_COOKIE['token'];
|
$token = $_COOKIE['token'];
|
||||||
|
|
||||||
if (Token::validate_token($token, $id, "remember"))
|
if (Token::validate($token, $id, "remember"))
|
||||||
{
|
{
|
||||||
$year = strtotime('+356 days', time());
|
$year = strtotime('+356 days', time());
|
||||||
unset($_COOKIE['token']);
|
unset($_COOKIE['token']);
|
||||||
|
@ -401,7 +401,6 @@ class User
|
||||||
public function change_password($token = false)
|
public function change_password($token = false)
|
||||||
{
|
{
|
||||||
global $mysqli, $message;
|
global $mysqli, $message;
|
||||||
$time = time();
|
|
||||||
$id = $this->id;
|
$id = $this->id;
|
||||||
if ($_POST['password']!=$_POST['password_repeat'])
|
if ($_POST['password']!=$_POST['password_repeat'])
|
||||||
{
|
{
|
||||||
|
@ -437,7 +436,7 @@ class User
|
||||||
$stmt = $mysqli->prepare("DELETE FROM tokens WHERE user = ? AND data = 'remember'");
|
$stmt = $mysqli->prepare("DELETE FROM tokens WHERE user = ? AND data = 'remember'");
|
||||||
$stmt->bind_param("d", $id);
|
$stmt->bind_param("d", $id);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$query = $stmt->get_result();
|
$stmt->get_result();
|
||||||
User::logout();
|
User::logout();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -445,7 +444,7 @@ class User
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if (Token::validate_token($token, $id, "passwd"))
|
if (Token::validate($token, $id, "passwd"))
|
||||||
{
|
{
|
||||||
$stmt = $mysqli->prepare("SELECT password_salt as salt FROM users WHERE id=?");
|
$stmt = $mysqli->prepare("SELECT password_salt as salt FROM users WHERE id=?");
|
||||||
$stmt->bind_param("i", $id);
|
$stmt->bind_param("i", $id);
|
||||||
|
@ -463,7 +462,7 @@ class User
|
||||||
$stmt = $mysqli->prepare("DELETE FROM tokens WHERE user = ? AND data = 'remember'");
|
$stmt = $mysqli->prepare("DELETE FROM tokens WHERE user = ? AND data = 'remember'");
|
||||||
$stmt->bind_param("d", $id);
|
$stmt->bind_param("d", $id);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$query = $stmt->get_result();
|
$stmt->get_result();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -538,13 +537,12 @@ class User
|
||||||
public function change_email()
|
public function change_email()
|
||||||
{
|
{
|
||||||
global $mysqli, $message;
|
global $mysqli, $message;
|
||||||
$time = time();
|
|
||||||
$token = $_GET['token'];
|
$token = $_GET['token'];
|
||||||
$id = $_GET['id'];
|
$id = $_GET['id'];
|
||||||
|
|
||||||
if (Token::validate_token($token, $id, "email;%"))
|
if (Token::validate($token, $id, "email;%"))
|
||||||
{
|
{
|
||||||
$data = explode(";", $result['data']);
|
$data = explode(";", Token::get_data($token, $id));
|
||||||
|
|
||||||
$email = $data[1];
|
$email = $data[1];
|
||||||
|
|
||||||
|
@ -569,12 +567,10 @@ class User
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function logout(){
|
public static function logout(){
|
||||||
global $mysqli;
|
|
||||||
session_unset();
|
session_unset();
|
||||||
if (isset($_COOKIE['token']))
|
if (isset($_COOKIE['token']))
|
||||||
{
|
{
|
||||||
$token = $_COOKIE['token'];
|
$token = $_COOKIE['token'];
|
||||||
$time = time();
|
|
||||||
Token::delete($token);
|
Token::delete($token);
|
||||||
unset($_COOKIE['user']);
|
unset($_COOKIE['user']);
|
||||||
unset($_COOKIE['token']);
|
unset($_COOKIE['token']);
|
||||||
|
|
Loading…
Reference in New Issue