diff --git a/globals/Dependencies/Administration/SignupKey.php b/globals/Dependencies/Administration/SignupKey.php new file mode 100644 index 0000000..707fe13 --- /dev/null +++ b/globals/Dependencies/Administration/SignupKey.php @@ -0,0 +1,43 @@ +prepare("SELECT * FROM signup_keys WHERE signupkey = :t"); + $tokencheck->bindParam(":t", $hash, PDO::PARAM_STR); + $tokencheck->execute(); + } while ($tokencheck->fetchColumn() != 0); + + $n = $GLOBALS['pdo']->prepare("INSERT INTO signup_keys(signupkey, whenGenerated) VALUES(:t, UNIX_TIMESTAMP())"); + $n->bindParam(":t", $hash, PDO::PARAM_STR); + $n->execute(); + return $hash; + } + + public static function ValidateSignupKey(string $key) + { + $n = $GLOBALS['pdo']->prepare("SELECT COUNT(*) FROM signup_keys WHERE signupkey = :t"); + $n->bindParam(":t", $key, PDO::PARAM_STR); + $n->execute(); + + if ($n->fetchColumn() > 0) { + $invalidate = $GLOBALS['pdo']->prepare("DELETE FROM signup_keys WHERE signupkey = :t"); + $invalidate->bindParam(":t", $key, PDO::PARAM_STR); + $invalidate->execute(); + if ($invalidate->rowCount() > 0) { + return true; + } + } + return false; + } + } +} diff --git a/html/register.php b/html/register.php index 33f4112..a81511a 100644 --- a/html/register.php +++ b/html/register.php @@ -5,6 +5,7 @@ TODO: This needs a re-do. This is one of the first pages on this project */ +use Alphaland\Administration\SignupKey; use Alphaland\Moderation\Filter; use Alphaland\Users\Activation; use Alphaland\Users\ReferralProgram; @@ -98,7 +99,7 @@ else { $isUserGen = true; } - else if (verifySignupKey($signupkey)) //old invite keys from admins + else if (SignupKey::ValidateSignupKey($signupkey)) //invite keys from admins { $isAdminGen = true; } diff --git a/html_admin/create-signupkey.php b/html_admin/create-signupkey.php index 4ad8f93..a964021 100644 --- a/html_admin/create-signupkey.php +++ b/html_admin/create-signupkey.php @@ -1,5 +1,6 @@ Generated";