diff --git a/globals/Dependencies/Common/Email.php b/globals/Dependencies/Common/Email.php new file mode 100644 index 0000000..6c9113f --- /dev/null +++ b/globals/Dependencies/Common/Email.php @@ -0,0 +1,56 @@ +prepare("SELECT COUNT(*) FROM verify_email_keys WHERE token = :t"); + $tokencheck->bindParam(":t", $hash, PDO::PARAM_STR); + $tokencheck->execute(); + } while ($tokencheck->fetchColumn() != 0); + return $hash; + } + + public static function GenerateResetPasswordHash(int $len) + { + $hash = ""; + do { + $hash = HashingUtiltity::GenerateByteHash($len); + $tokencheck = $GLOBALS['pdo']->prepare("SELECT COUNT(*) FROM password_reset_keys WHERE token = :t"); + $tokencheck->bindParam(":t", $hash, PDO::PARAM_STR); + $tokencheck->execute(); + } while ($tokencheck->fetchColumn() != 0); + return $hash; + } + + public static function IsEmailRegistered(string $email) + { + $check = $GLOBALS['pdo']->prepare("SELECT COUNT(*) FROM users WHERE email = :e"); + $check->bindParam(":e", $email, PDO::PARAM_STR); + $check->execute(); + if ($check->fetchColumn() > 0) { + return true; + } + return false; + } + } +} \ No newline at end of file diff --git a/html/register.php b/html/register.php index a81511a..76c0496 100644 --- a/html/register.php +++ b/html/register.php @@ -6,6 +6,7 @@ */ use Alphaland\Administration\SignupKey; +use Alphaland\Common\Email; use Alphaland\Moderation\Filter; use Alphaland\Users\Activation; use Alphaland\Users\ReferralProgram; @@ -77,7 +78,7 @@ else $error = '