use u311\carexperiment\view\View; use u311\carexperiment\component\TrialManager; use u311\carexperiment\component\Router; session_start(); unset($_SESSION['trial_start']); $error_txt = ''; /* * Get difference from now to start and end. */ $diff = TrialManager::getNextTrialTime(); /* * If the nearest start is in the future. Redirect to the wait page */ if ($diff->start > 0) { $_SESSION['trial_start'] = $diff->start; $router = new Router(); header('Location: ' . $router->getDestination('wait')); exit; } /* * If the end difference is negative. There is no trial to do atm */ if ($diff->end < 0) { echo "There are no pending trials."; exit; } /* * Otherwise, display the login page. */ if (isset($_SESSION['login_err'])) { if (!empty($_SESSION['login_err'])) {
<?php namespace u311\carexperiment\ctrl; include_once __DIR__ . '/../../../../vendor/autoload.php'; use u311\carexperiment\ctrl\GameDataCtrl; use u311\carexperiment\component\Router; use u311\carexperiment\model\FormField; use u311\carexperiment\model\FormValidator; session_start(); $router = new Router(); $err_shuttle_rating = false; $err_shuttle_rating_text = ""; //If $_SESSION['user_id'] not set, user is not logged in. Send back to login page if (!isset($_SESSION['user_id'])) { $url = $router->getDestination('login'); header('Location: ' . $url); exit; } /* @var $user_id Stroes the value of logged in user_id */ $user_id = $_SESSION['user_id']; /* * $_SESSION['errors'] will hold all errors that need to be passed to the form * Starte by unsetting it */ unset($_SESSION['f_errs']); // clear all errors... unset($_SESSION['form_err']); // clear main form error /* * Initialize an array of FormFields
<?php include_once __DIR__ . '/vendor/autoload.php'; use u311\carexperiment\component\Router; use u311\carexperiment\view\View; use u311\carexperiment\ctrl\SQLUserManager; use u311\carexperiment\model\GameCompInfo; session_start(); $router = new Router(); if (!isset($_SESSION['user_id'])) { $url = $router->getDestination('login'); header('Location: ' . $url . '?src=explain'); exit; } $length = 5; $characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } $score = $_SESSION['score']; $user_id = $_SESSION['user_id']; $bonus = $score * 0.05; $error_msg = ""; $info = new GameCompInfo($user_id, $randomString, $score); try { $user_manager = new SQLUserManager(); $user_manager->updateCompInfo($info); } catch (\Exception $ex) { $error_msg = "ERROR USER:{$user_id}:SCORE:{$score}:STRING:{$randomString}:BONUS:{$bonus}";
<?php namespace u311\carexperiment\ctrl; include_once __DIR__ . '/../../../vendor/autoload.php'; use u311\carexperiment\component\Router; session_start(); session_unset(); session_destroy(); $router = new Router(); $url = $router->getDestination('default'); header('Location: ' . $url); exit;
<?php include_once __DIR__ . '/vendor/autoload.php'; use u311\carexperiment\component\Router; use u311\carexperiment\view\View; session_start(); $router = new Router(); $user_id = null; if (isset($_SESSION['user_id']) && !empty($_SESSION['user_id'])) { $user_id = $_SESSION['user_id']; } if (is_null($user_id)) { $url = $router->getDestination('login'); header('Location: ' . $url . '?src=explain'); exit; } $page_cont = array('logout_url' => $router->getDestination('logout'), 'game_url' => $router->getDestination('game')); $view = new View(__DIR__ . '/u311/carexperiment/resources/templates/'); $view->loadTemplate('instructions.twig'); echo $view->render($page_cont);
<?php include_once __DIR__ . '/vendor/autoload.php'; use u311\carexperiment\view\View; use u311\carexperiment\component\Router; session_start(); /* * Array of files to use for each survey page */ $survey_files = array(1 => array("tmpl" => "survey.twig", "proc" => "./u311/carexperiment/ctrl/surveyproc/sp_1.php"), 2 => array("tmpl" => "survey2.twig", "proc" => "./u311/carexperiment/ctrl/surveyproc/sp_2.php"), 3 => array("tmpl" => "survey3.twig", "proc" => "./u311/carexperiment/ctrl/surveyproc/sp_3.php"), 4 => array("tmpl" => "survey4.twig", "proc" => "./u311/carexperiment/ctrl/surveyproc/sp_4.php"), 5 => array("tmpl" => "survey5.twig", "proc" => "./u311/carexperiment/ctrl/surveyproc/sp_5.php"), 6 => array("tmpl" => "survey6.twig", "proc" => "./u311/carexperiment/ctrl/surveyproc/sp_6.php"), 7 => array("tmpl" => "survey7.twig", "proc" => "./u311/carexperiment/ctrl/surveyproc/sp_7.php"), 8 => array("tmpl" => "survey8.twig", "proc" => "./u311/carexperiment/ctrl/surveyproc/sp_8.php"), 9 => array("tmpl" => "survey9.twig", "proc" => "./u311/carexperiment/ctrl/surveyproc/sp_9.php"), 10 => array("tmpl" => "survey_final.twig", "proc" => "./u311/carexperiment/ctrl/surveyproc/sp_final.php"), 'err' => array("tmpl" => "surveyerror.twig", "proc" => "")); $router = new Router(); if (!isset($_SESSION['user_id'])) { $url = $router->getDestination('login'); header('Location: ' . $url); exit; } /* * Use it to get the right survey form * Set the survey display to final survey */ $session_number = 10; //if( isset($_SESSION['survey_id'])){ // $session_number = $_SESSION['survey_id']; //} $errors_array = []; if (isset($_SESSION['f_errs'])) { $errors_array = $_SESSION['f_errs']; } $form_error = ''; if (isset($_SESSION['form_err'])) { $form_error = $_SESSION['form_err'];