From 5f36bf87e00bf7a5d5221c33b3e0b67b18cf96d5 Mon Sep 17 00:00:00 2001 From: h-alstad <> Date: Wed, 6 Apr 2011 23:32:17 +0200 Subject: [PATCH] =?UTF-8?q?Gi=20status=20p=C3=A5=20om=20kortnummer=20er=20?= =?UTF-8?q?brukt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inside/functions.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) 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);