forked from cydrobolt/polr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfpasslib.php
40 lines (40 loc) · 1.61 KB
/
fpasslib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
// includes for password resets
require_once 'helpers/helper-mailsend.php';
require_once 'lib-auth.php';
require_once 'lib-core.php';
$polrauth = new polrauth();
$sgmail = new sgmail();
class fpass {
public function sendfmail($to, $username, $rkey) {
global $ip;
global $sgmail;
global $wsa;
global $wsn;
$subject = $wsn.' Password Recovery';
$message = 'Hello,<br /><br />'
. "Someone has requested a password reset email (IP: $ip)<br />"
. "To recover your password, click here: <a href='http://{$wsa}/forgotpass.php?key=$rkey&username=$username'>http://{$wsa}/forgotpass.php?key=$rkey&username=$username</a><br />"
. "If this was not you, no further action is needed. If you are constantly receiving these emails, but did not request<br />"
. "a new password, please contact us with the IP printed above. <br />"
. "<br />"
. "Cheers,<br />"
. "The {$wsn} Team<br />";
$sgmail->sendmail($to, $subject, $message); // send email
}
public function hash($pass) {
$opts = [
'cost' => 10,
];
$hashed = password_hash($pass, PASSWORD_BCRYPT, $opts);
return $hashed;
}
public function changepass($newpass, $username) {
global $mysqli;
$username = $mysqli->real_escape_string($username);
$hashpass = $this->hash($newpass);
$qr = "UPDATE auth SET password='{$hashpass}' WHERE username='{$username}';";
$e = $mysqli->query($qr) or showerror();
return true;
}
}