mirror of
https://github.com/ShaYmez/FreeSTAR-Status-Engine.git
synced 2025-07-23 02:15:18 -04:00
Fix for not sending mail when user created & checking if email used when changing it.
This commit is contained in:
parent
f5c2b5448d
commit
392d1f4019
@ -117,9 +117,8 @@ class User
|
|||||||
$stmt = $mysqli->prepare("INSERT INTO users values (NULL, ?, ?, ?, ?, ?, ?, ?, 1)");
|
$stmt = $mysqli->prepare("INSERT INTO users values (NULL, ?, ?, ?, ?, ?, ?, ?, 1)");
|
||||||
$stmt->bind_param("ssssssi", $email, $username, $name, $surname, $hash, $salt, $permission);
|
$stmt->bind_param("ssssssi", $email, $username, $name, $surname, $hash, $salt, $permission);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$query = $stmt->get_result();
|
|
||||||
|
|
||||||
if ($query->affected_rows>0)
|
if ($stmt->affected_rows>0)
|
||||||
{
|
{
|
||||||
$to = $email;
|
$to = $email;
|
||||||
$subject = 'User account created - '.NAME;
|
$subject = 'User account created - '.NAME;
|
||||||
@ -410,12 +409,26 @@ class User
|
|||||||
|
|
||||||
public function email_link(){
|
public function email_link(){
|
||||||
global $mysqli;
|
global $mysqli;
|
||||||
$email = $_POST['email'];
|
$email = trim($_POST['email']);
|
||||||
$time = strtotime('+1 day', time());
|
$time = strtotime('+1 day', time());
|
||||||
$salt = uniqid(mt_rand(), true);
|
$salt = uniqid(mt_rand(), true);
|
||||||
$id = $this->id;
|
$id = $this->id;
|
||||||
$token = hash('sha256', $id.$salt);
|
$token = hash('sha256', $id.$salt);
|
||||||
|
|
||||||
|
$stmt = $mysqli->prepare("SELECT count(*) as count FROM users WHERE email=?");
|
||||||
|
$stmt->bind_param("s", $email);
|
||||||
|
$stmt->execute();
|
||||||
|
$query = $stmt->get_result();
|
||||||
|
|
||||||
|
$count = $query->fetch_assoc()['count'];
|
||||||
|
|
||||||
|
if ($count)
|
||||||
|
{
|
||||||
|
$message = "This email is already used.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Token::new($id, 'email;$email', $time);
|
Token::new($id, 'email;$email', $time);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user