示例#1
0
<?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']));