<?php require_once '../php/setup.php'; require_once '../php/QuizParser.php'; header('Content-Type: application/javascript'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $quizTimestamp) . ' GMT'); // Parse the plain text quiz file into JSON $debug = $_REQUEST['debug'] == 'true'; $pureJSON = $_REQUEST['pure'] == 'true'; $quizParser = new QuizParser(); $quizParser->debug = $debug; $quizParser->parse($quizDataFilePath); echo $pureJSON ? '' : 'window.quizData = '; echo $quizParser->buildJSON($quizName, $quizTimestamp); echo $pureJSON ? '' : ';';
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/php/setup.php'; require_once $root . '/php/QuizParser.php'; $quizParser = new QuizParser(); if (is_readable($quizDataFilePath)) { $quizData = file_get_contents($quizDataFilePath); $quizParser->parseText($quizData); // Enforce password-protection of quiz edits if ($quizParser->isPasswordProtected()) { $password = $_REQUEST['password']; if ($quizParser->checkPassword($password)) { $cookiePassHash = $quizParser->createPassHash($quizParser->createPassHash($password)); setCookie('passwordCookie', $cookiePassHash, null, '/', $_SERVER['HTTP_HOST'], false, true); } else { $cookiePassword = $_COOKIE['passwordCookie']; if (!$quizParser->checkCookiePassword($cookiePassword)) { require $root . '/password.php'; exit; } } } } else { if (is_readable($faqDataFilePath)) { $quizData = file_get_contents($faqDataFilePath); } else { $quizData = 'Q: Shouldn\'t there be a helpful FAQ here?' . "\n" . 'NoRandomOrder' . "\n" . 'A: What, no! Everything is working fine...' . "\n" . 'A*: Erm, okay, maybe something has gone wrong. // You might want to try again later...' . "\n"; } } // Update the quiz text, if valid $newQuizData = trim(stripSlashes($_REQUEST['quizData']));