diff --git a/inside/functions.php b/inside/functions.php index 2f9919c..1f31ac0 100644 --- a/inside/functions.php +++ b/inside/functions.php @@ -634,13 +634,36 @@ function checkPassword($userid, $verificationCode) { } function displayCode($code) { - print "

" . getCode($code) . "

"; + print "

"; + print "Kortnummer: $code
"; + print "Kode: " . getCode($code) . "
"; + if (isValidCode($code)) { + print "Koden har ikke vært brukt"; + } else { + print "Koden har allerede vært brukt"; + } + print "

"; } function getCode($code) { return substr(crypt(trim($code), 1813), 2, 6); } +function isValidCode($code) { + $conn = db_connect(); + $sql = "SELECT id FROM din_user WHERE cardno=$code"; + $result = $conn->query($sql); + if (DB :: isError($result) != true) { + if ($result->numRows() > 0) { + return false; + } + } else { + error($result->toString()); + notify("En ukjent feil oppstod. Vennligst kontakt administrator."); + } + return true; +} + function generatePassword() { $seed = rand(1, 2000);