$_SESSION['status'] = 2; $_SESSION['gameover'] = 333; $_SESSION['wrongQuestion'] = true; $wrongQuestion = generateQuestion($_SESSION['qNum']); } } else { if (isset($_GET['gameover']) && $_GET['gameover'] == 1) { $b = $_SESSION['qNum'] - 1; $_SESSION['gameover'] = 333; $_SESSION['profit'] = $prizes[$b]; } else { $_SESSION['questions1'] = UniqueRandom(1); $_SESSION['questions2'] = UniqueRandom(2); $_SESSION['questions3'] = UniqueRandom(3); $_SESSION['qNum'] = 1; $question = generateQuestion($_SESSION['qNum']); $_SESSION['profit'] = 0; $_SESSION['status'] = 0; $_SESSION['questionAnswer'] = $question['right_answer']; } } ?> <!DOCTYPE html> <html> <head> <title>Стани Богат</title> <meta charset="UTF-8"> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div id="wrap">
function generateQuestion() { $firstNr = rand(1, 10); $secondNr = rand(1, 10); $plusMinus = rand(1, 2); if ($plusMinus == 1) { $_SESSION['answer'] = $firstNr + $secondNr; return strval($firstNr) . "+" . strval($secondNr); } else { $_SESSION['answer'] = $firstNr - $secondNr; return strval($firstNr) . "-" . strval($secondNr); } } switch ($_GET['action']) { case "entry": $template->assign("question", generateQuestion()); $template->display('entry.tpl'); break; case "login": if (!empty($_POST['username']) && !empty($_POST['password'])) { $user = new user($_POST['username'], $_POST['password'], $connection); if (isset($_SESSION["user"]) && $user->isValid()) { header("Location: index.php"); } } $template->display('login.tpl'); break; case "logout": $user->logout(); header("Location: index.php"); break;