mirror of
https://github.com/cydrobolt/polr.git
synced 2024-09-19 23:21:47 +02:00
more refactoring
This commit is contained in:
parent
192015304d
commit
ecd6ca01f9
@ -10,18 +10,17 @@ require_once 'lib-auth.php'; // require auth libs
|
|||||||
require_once 'helpers/helper-mailsend.php'; // require mail libs
|
require_once 'helpers/helper-mailsend.php'; // require mail libs
|
||||||
require_once 'lib-password.php'; // require password encryption libs
|
require_once 'lib-password.php'; // require password encryption libs
|
||||||
require_once 'fpasslib.php'; // require fpass functions
|
require_once 'fpasslib.php'; // require fpass functions
|
||||||
// require_once('ayah.php');
|
|
||||||
|
|
||||||
$polrauth = new polrauth();
|
$polrauth = new polrauth();
|
||||||
$fpass = new fpass();
|
$fpass = new fpass();
|
||||||
require_once 'layout-headerlg.php';
|
require_once 'layout-headerlg.php';
|
||||||
if (isset($_POST['rnpass']) && isset($_POST['npass']) && isset($_POST['crkey']) && isset($_POST['cuser'])) {
|
if (isset($_POST['rnpass']) && isset($_POST['npass']) && isset($_POST['crkey']) && isset($_POST['cuser'])) {
|
||||||
// if submitting new pw
|
// if submitting new password
|
||||||
$ckey = $mysqli->real_escape_string($_POST['crkey']);
|
$ckey = $mysqli->real_escape_string($_POST['crkey']);
|
||||||
$rnpass = $mysqli->real_escape_string($_POST['rnpass']);
|
$rnpass = $mysqli->real_escape_string($_POST['rnpass']);
|
||||||
$cuser = $mysqli->real_escape_string($_POST['cuser']);
|
$cuser = $mysqli->real_escape_string($_POST['cuser']);
|
||||||
$npass = $mysqli->real_escape_string($_POST['npass']);
|
$npass = $mysqli->real_escape_string($_POST['npass']);
|
||||||
$userinfoc = $polrauth->getinfomu($cuser); // fetch info
|
$userinfoc = $polrauth->getinfomu($cuser); // fetch the user's information
|
||||||
if ($userinfoc == false) {
|
if ($userinfoc == false) {
|
||||||
echo "<h2>That username is not associated with any account. Please try again.</h2>"
|
echo "<h2>That username is not associated with any account. Please try again.</h2>"
|
||||||
. "<br />"
|
. "<br />"
|
||||||
@ -36,16 +35,18 @@ if (isset($_POST['rnpass']) && isset($_POST['npass']) && isset($_POST['crkey'])
|
|||||||
require_once 'layout-footerlg.php';
|
require_once 'layout-footerlg.php';
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
if ($userinfoc['rkey'] == $_POST['crkey']) { // if rkey & user check out
|
if ($userinfoc['rkey'] == $_POST['crkey']) {
|
||||||
|
// if the rkey is correct
|
||||||
if ($npass != $rnpass) {
|
if ($npass != $rnpass) {
|
||||||
// if new pass & repeat don't match
|
// if new pass & repeat don't match
|
||||||
require_once 'layout-headerlg.php';
|
require_once 'layout-headerlg.php';
|
||||||
echo "<h2>Passwords don't match. Try again. (click the link in the email again)</h2>";
|
echo "<h2>Passwords don't match. Try again. (click the link in the email again)</h2>";
|
||||||
require_once 'layout-footerlg.php';
|
require_once 'layout-footerlg.php';
|
||||||
die();
|
die();
|
||||||
} else { // all checks out
|
} else {
|
||||||
$fpass->changepass($npass, $cuser); // change pass
|
// everything is as expected, perform password reset
|
||||||
$polrauth->crkey($cuser); //change rkey
|
$fpass->changepass($npass, $cuser); // update the user's password
|
||||||
|
$polrauth->crkey($cuser); // update their reset token
|
||||||
require_once 'layout-headerlg.php';
|
require_once 'layout-headerlg.php';
|
||||||
echo "<h2>Password changed.</h2>";
|
echo "<h2>Password changed.</h2>";
|
||||||
require_once 'layout-footerlg.php';
|
require_once 'layout-footerlg.php';
|
||||||
@ -56,7 +57,7 @@ if (isset($_POST['rnpass']) && isset($_POST['npass']) && isset($_POST['crkey'])
|
|||||||
$fpass = new fpass();
|
$fpass = new fpass();
|
||||||
if (isset($_GET['key']) && isset($_GET['username'])) {
|
if (isset($_GET['key']) && isset($_GET['username'])) {
|
||||||
$username = $mysqli->real_escape_string($_GET['username']);
|
$username = $mysqli->real_escape_string($_GET['username']);
|
||||||
$userinfoc = $polrauth->getinfomu($username); // fetch info
|
$userinfoc = $polrauth->getinfomu($username);
|
||||||
if ($userinfoc == false) {
|
if ($userinfoc == false) {
|
||||||
echo "<h2>That username is not associated with any account. Please try again.</h2>"
|
echo "<h2>That username is not associated with any account. Please try again.</h2>"
|
||||||
. "<br />"
|
. "<br />"
|
||||||
@ -65,13 +66,12 @@ if (isset($_GET['key']) && isset($_GET['username'])) {
|
|||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
if ($userinfoc == false) {
|
if ($userinfoc == false) {
|
||||||
// if user does not exist
|
// if the user does not exist
|
||||||
require_once 'layout-headerlg.php';
|
require_once 'layout-headerlg.php';
|
||||||
echo "<h2>User or key invalid or already used.</h2>";
|
echo "<h2>User or key invalid or already used.</h2>";
|
||||||
require_once 'layout-footerlg.php';
|
require_once 'layout-footerlg.php';
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
//var_dump($userinfoc);
|
|
||||||
if ($userinfoc['rkey'] == $_GET['key']) {
|
if ($userinfoc['rkey'] == $_GET['key']) {
|
||||||
require_once 'layout-headerlg.php';
|
require_once 'layout-headerlg.php';
|
||||||
echo "<h2>Change Password for {$_GET['username']}</h2>";
|
echo "<h2>Change Password for {$_GET['username']}</h2>";
|
||||||
@ -88,13 +88,9 @@ if (isset($_GET['key']) && isset($_GET['username'])) {
|
|||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if (isset($_POST['username']) == true && isset($_POST['key']) == true) {
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
@$email = $_POST['email'];
|
@$email = $_POST['email'];
|
||||||
if (!$email) {
|
if (!$email) {
|
||||||
// if requesting form
|
|
||||||
echo "<h2>Forgot your password?</h2>"
|
echo "<h2>Forgot your password?</h2>"
|
||||||
. "<br/ >"
|
. "<br/ >"
|
||||||
. "<form action='forgotpass.php' method='POST' style='margin:0 auto; width: 450px'>"
|
. "<form action='forgotpass.php' method='POST' style='margin:0 auto; width: 450px'>"
|
||||||
@ -125,6 +121,6 @@ if ($userinfo == false) {
|
|||||||
}
|
}
|
||||||
$rkey = $userinfo['rkey'];
|
$rkey = $userinfo['rkey'];
|
||||||
$username = $userinfo['username'];
|
$username = $userinfo['username'];
|
||||||
$fpass->sendfmail($email, $username, $rkey); // send the email
|
$fpass->sendfmail($email, $username, $rkey);
|
||||||
echo "Email successfully sent. Check your inbox for more info.";
|
echo "Email successfully sent. Check your inbox for more info.";
|
||||||
require_once 'layout-footerlg.php';
|
require_once 'layout-footerlg.php';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
// includes for forgotpassword functions
|
// includes for password resets
|
||||||
require_once 'helpers/helper-mailsend.php';
|
require_once 'helpers/helper-mailsend.php';
|
||||||
require_once 'lib-auth.php';
|
require_once 'lib-auth.php';
|
||||||
require_once 'lib-core.php';
|
require_once 'lib-core.php';
|
||||||
@ -20,7 +20,7 @@ class fpass {
|
|||||||
. "<br />"
|
. "<br />"
|
||||||
. "Cheers,<br />"
|
. "Cheers,<br />"
|
||||||
. "The {$wsn} Team<br />";
|
. "The {$wsn} Team<br />";
|
||||||
$sgmail->sendmail($to, $subject, $message); //actually send the email
|
$sgmail->sendmail($to, $subject, $message); // send email
|
||||||
}
|
}
|
||||||
public function hash($pass) {
|
public function hash($pass) {
|
||||||
$opts = [
|
$opts = [
|
||||||
|
Loading…
Reference in New Issue
Block a user