function displayerrors() { $errormsg = $GLOBALS['errormsg']; if (getErrorCount()) { echo "<ul>"; foreach ($errormsg as $value) { echo "<li>" . $value . "</li>"; } echo "</ul>"; } }
<?php $username = ""; $password = ""; $forwardpage = "views\\index.php"; if (isset($_POST['flubber_submit'])) { $username = isset($_POST['flubber_username']) ? $_POST['flubber_username'] : ""; $password = isset($_POST['flubber_password']) ? $_POST['flubber_password'] : ""; if ($username == "") { addError("login.username.missing"); } if ($password == "") { addError("login.password.missing"); } if (getErrorCount() > 0) { $forwardpage = "views\\index.php"; } else { if (validate($username, $password) == true) { $_SESSION['username'] = $username; if (isset($_SESSION['current_url'])) { $curl = $_SESSION['current_url']; unset($_SESSION['current_url']); doAction("redirect", $curl); } else { doAction("home"); } $forward = false; } else { addError("login.account.invalid"); $forwardpage = "views\\index.php"; }
include 'util.php'; header("Pragma: public"); header("Expires: 0"); $filename = 'db.php'; $templine = ''; initializeDB(); if (!file_exists($filename)) { addError("install.file.missing"); outputJSON($errormsg); } else { $lines = file($filename); foreach ($lines as $line_num => $line) { if (substr($line, 0, 2) != '--' && $line != '') { $templine .= $line; if (substr(trim($line), -1, 1) == ';') { try { queryDB($templine); } catch (Exception $e) { addError("error", $e->getMessage(), false); debug_display($e); } $templine = ''; } } } if (getErrorCount() > 1) { addError("error", "install.sql.error"); outputJSON("error"); } }
if (strcmp(trim($grid_step2_column_data["grid_step2_column" . $columnno . "_autogen_content"]), "") == 0) { addError("creategrid.autogen.content.missing"); } else { if (strcmp(trim($grid_step2_column_data["grid_step2_column" . $columnno . "_autogen_content"]), "seqnumbers") == 0) { $grid_step2_column_data["grid_step2_column" . $columnno . "_autogen_content_seq_start"] = isset($_POST['grid_step2_autogen_content_seq_start']) ? $_POST['grid_step2_autogen_content_seq_start'] : ""; if (strcmp($grid_step2_column_data["grid_step2_column" . $columnno . "_autogen_content_seq_start"], "") == 0) { $grid_step2_column_data["grid_step2_column" . $columnno . "_autogen_content_seq_start"] = 1; } } } } } } } $gridData["grid_step2_column" . $columnno . "_data"] = $grid_step2_column_data; if (getErrorCount() == 0) { if ($columnno == $gridData['grid_step1_no_columns']) { try { addGridToDB($gridData); $forwardpage = "views\\creategridstep3.php"; //unset($_SESSION['gridData']); } catch (Exception $e) { debug_display($e); $forwardpage = "views\\creategridstep3.php"; } } else { $_SESSION['gridData'] = $gridData; $current_column = $columnno + 1; $columnname = ""; $columndesc = ""; $grid_step2_column_data = array();
function addQuestion() { if (!isset($_SESSION['username'])) { addError("fatal", "user.unathorized"); outputJSON("error"); return; } if (!isset($_POST['data'])) { addError("fatal", "newquestion.fatal.error"); outputJSON("error"); return; } $postarray = $_POST['data']; $catcracker_newquestion_passage = isset($postarray['passage']) ? $postarray['passage'] : ""; $questions = $postarray['questions']; $catcracker_newquestion_question = array(); $catcracker_newquestion_optiona = array(); $catcracker_newquestion_optionb = array(); $catcracker_newquestion_optionc = array(); $catcracker_newquestion_optiond = array(); $catcracker_newquestion_rightanswer = array(); for ($i = 0; $i < sizeof($questions); $i++) { $catcracker_newquestion_question[$i] = isset($questions[$i]['question']) ? $questions[$i]['question'] : ""; $catcracker_newquestion_optiona[$i] = isset($questions[$i]['optiona']) ? $questions[$i]['optiona'] : ""; $catcracker_newquestion_optionb[$i] = isset($questions[$i]['optionb']) ? $questions[$i]['optionb'] : ""; $catcracker_newquestion_optionc[$i] = isset($questions[$i]['optionc']) ? $questions[$i]['optionc'] : ""; $catcracker_newquestion_optiond[$i] = isset($questions[$i]['optiond']) ? $questions[$i]['optiond'] : ""; $catcracker_newquestion_rightanswer[$i] = isset($questions[$i]['rightanswer']) ? $questions[$i]['rightanswer'] : ""; if ($catcracker_newquestion_question[$i] == "") { addError("newquestion_question_missing", "newquestion.question.missing"); } if ($catcracker_newquestion_optiona[$i] == "") { addError("newquestion_optiona_missing", "newquestion.optiona.missing"); } if ($catcracker_newquestion_optionb[$i] == "") { addError("newquestion_optionb_missing", "newquestion.optionb.missing"); } if ($catcracker_newquestion_optionc[$i] == "") { addError("newquestion_optionc_missing", "newquestion.optionc.missing"); } if ($catcracker_newquestion_optiond[$i] == "") { addError("newquestion_optiond_missing", "newquestion.optiond.missing"); } if ($catcracker_newquestion_rightanswer[$i] == "") { $catcracker_newquestion_rightanswer[$i] = "u"; } } $catcracker_newquestion_difficultylevel = isset($postarray['difficultylevel']) ? $postarray['difficultylevel'] : ""; $catcracker_newquestion_challengequestion = isset($postarray['challengequestion']) ? $postarray['challengequestion'] : ""; $catcracker_newquestion_tags = isset($postarray['tags']) ? $postarray['tags'] : ""; if ($catcracker_newquestion_difficultylevel == "") { $catcracker_newquestion_difficultylevel = "5"; } if ($catcracker_newquestion_challengequestion == "") { $catcracker_newquestion_challengequestion = "off"; } if (getErrorCount() > 1) { outputJSON("error"); return; } $questionid = ""; try { $questionid = addQuestionToDB($catcracker_newquestion_passage, $catcracker_newquestion_question, $catcracker_newquestion_optiona, $catcracker_newquestion_optionb, $catcracker_newquestion_optionc, $catcracker_newquestion_optiond, $catcracker_newquestion_rightanswer, $catcracker_newquestion_difficultylevel, $catcracker_newquestion_challengequestion, $catcracker_newquestion_tags); } catch (Exception $e) { addError("dbupdate_error", $e->getMessage()); return; } addMessage("questionid", $questionid, false); outputJSON("success"); }