database has to be loaded earlier

lektura
max.mehl 2017-03-23 23:39:27 +01:00
parent 03b1a35d9c
commit 5a5d901c92
1 changed files with 5 additions and 5 deletions

View File

@ -4,7 +4,6 @@ $codemod = 2138367; // modificator with which the confirmation ID will be obfu
$output = ""; $output = "";
$selfurl = "http://pmpc-test.mehl.mx/cgi/sign.php"; // absolute URL of this PHP script $selfurl = "http://pmpc-test.mehl.mx/cgi/sign.php"; // absolute URL of this PHP script
$db = "../userdata/signatures.json"; // Signature database path $db = "../userdata/signatures.json"; // Signature database path
$data = "";
// Get info from form // Get info from form
$action = isset($_GET['action']) ? $_GET['action'] : false; $action = isset($_GET['action']) ? $_GET['action'] : false;
@ -57,6 +56,8 @@ function read_db($db) {
/// SIGNING /// /// SIGNING ///
if ($action === "sign") { if ($action === "sign") {
read_db($db);
// Test whether email is a duplicate // Test whether email is a duplicate
$total = count($data); $total = count($data);
for ($row = 0; $row < $total; $row++) { for ($row = 0; $row < $total; $row++) {
@ -66,8 +67,6 @@ if ($action === "sign") {
} }
} }
read_db($db);
// Take sequential ID // Take sequential ID
$id = $total; $id = $total;
// Create a random string for email verification // Create a random string for email verification
@ -113,6 +112,7 @@ if ($action === "sign") {
/// CONFIRMATION /// /// CONFIRMATION ///
$id = $confirmid - $codemod; // substract the obfuscation number from the given ID $id = $confirmid - $codemod; // substract the obfuscation number from the given ID
if ($id < 0) { if ($id < 0) {
$output .= "Invalid signature ID."; $output .= "Invalid signature ID.";
show_page($output, 1); show_page($output, 1);
@ -139,12 +139,12 @@ if ($action === "sign") {
file_put_contents($db, $allsig, LOCK_EX); file_put_contents($db, $allsig, LOCK_EX);
unset($allsig); unset($allsig);
$output .= "Your email address ($email) has been confirmed. <br /><br />"; $output .= "Your email address has been confirmed. <br /><br />";
$output .= "Thank you for signing the open letter! Your signature will appear on the website within the next hours."; $output .= "Thank you for signing the open letter! Your signature will appear on the website within the next hours.";
show_page($output, 0); show_page($output, 0);
} else { } else {
$output .= "The provided signature code is incorrect."; $output .= "The provided confirmation code is incorrect.";
show_page($output, 1); show_page($output, 1);
} }
} else if ($confirmed === "yes") { } else if ($confirmed === "yes") {