cid = $cid; global $kdb; $this->period = $kdb->getPeriodByCalculationId($cid); } function finalize() { } function __destruct() { } public function getCalcId() { return $this->cid; } public function getQuestion() { return $this->question; } public function setQuestion($qd) { $this->question = $qd; } public function getPeriod() { return $this->period; } } if ( isset($_SESSION['cid']) ) { $calculator = new Calculator($_SESSION['cid']); $kesa->setPage($calculator); } // if user NOT created if ( !isset($_SESSION['userid']) ) { // first question if (!isset($_SESSION['pre_started'])) { require_once("pre_starter.php"); $kesa->setTemplate("pre_start_calc.html"); } else { require_once("starter.php"); $kesa->setTemplate("start_calc.html"); } // if user IS created } else { if (isset($_SESSION['period_need_to_set'])) { require_once("period_calc.php"); $kesa->setTemplate("period_calc.html"); } else { if ( !isset($_SESSION['qid']) ) { $_SESSION['qid'] = 2; } if ( isset($_GET['reset']) ) { global $kdb; $kdb->query("DELETE FROM users WHERE id=".$_SESSION['userid']." AND !registred"); session_destroy(); header("Location:index.php"); // question stuff } else if ( isset($_GET['login']) ) { $_SESSION['page'] = 'login'; } else if ( isset($_GET['register']) ) { if ($_SESSION['page']!='register') { $_SESSION['last_page'] = $_SESSION['page']; } $_SESSION['page'] = 'register'; header("Location:index.php"); } else if ( is_numeric($_SESSION['qid']) && $_SESSION['qid']>1 && isset($_SESSION['cid']) ) { require_once("question.php"); // other stuff } else if (!isset($_SESSION['cid'])){ if (!$kdb->getFootprintsByUserId($_SESSION['userid'])) { $kdb->query("INSERT INTO answers (userid) values (".$_SESSION['userid'].")"); $cid = mysql_insert_id(); $_SESSION['cid'] = $cid; } require_once("starter.php"); $kesa->setTemplate("continue_calc.html"); } else { header("Location:index.php"); } } } ?>