getDetails()->getLanguage()); $tr->setLanguage($language.DEFAULT_ENCODING, $language.DEFAULT_ENCODING); $tr->addDomain('kesa', 'i18n'); $tr->useDomain('kesa'); $this->translator = $tr; $this->template = "base_content.html"; } function finalize() { global $user; $templ = new PHPTAL(); $templ->setTemplateRepository("templates/"); $templ->setTemplate($this->template); $templ->setTranslator($this->translator); $templ->here = $this; $templ->request = $_GET; $templ->user = $user; print $templ->execute(); } function __destruct() { // html välja! } function isAnon() { if ( !isset($_SESSION['logged_in'])) { return True; } if ( $_SESSION['logged_in'] ) { return False; } else { return True; } } function getTranslator() { return $this->translator; } public function getTemplate() { return $this->template; } public function setTemplate($tmpl) { $this->template = $tmpl; } public function getPage() { return $this->dataObj; } public function setPage($qd) { $this->dataObj = $qd; } public function getTrash() { global $kdb; return $kdb->getTrash(); } public function emptyTrash() { global $kdb; return $kdb->emptyTrash(); } /*function getCategories() { global $kdb; return $kdb->getCategories(); }*/ public function getUsersFootprints() { global $kdb; return $kdb->getFootprintsByUserId($_SESSION['userid']); } } if ( !isset($_SESSION['page']) ) { $_SESSION['page'] = 'index'; } if ( isset($_GET['login']) ) { $_SESSION['page'] = 'login'; } else if ( isset($_GET['register']) ) { if ($_SESSION['page']!='register') { $_SESSION['last_page'] = $_SESSION['page']; } $_SESSION['page'] = 'register'; } // login action if ( isset($_POST['actionLogin']) ) { global $kdb; $uname = $_POST['uname']; $pwd = $_POST['salasona']; $ret = $kdb->query("SELECT id, uname FROM users WHERE registred AND uname='".$uname."' AND pwd='".$pwd."'"); $num = mysql_num_rows($ret); if ( $num == 1) { // OK $res = mysql_fetch_array($ret); if ( ! strcmp($res[1], $uname)) { $_SESSION['logged_in'] = True; $_SESSION['userid'] = (int) $res[0]; if ( isset($_SESSION['last_page']) ) { $_SESSION['page'] = $_SESSION['last_page']; } else { $_SESSION['page'] = 'index'; } header("Location:index.php"); } } else { $_SESSION['page'] = 'login'; header("Location:index.php?error"); } // action cancel login } else if ( isset($_POST['actionCancel']) ) { $_SESSION['page'] = 'index'; unset($_SESSION['pre_started']); //header("Location:index.php"); } // logoff action if ( isset($_GET['logoff']) ) { session_destroy(); header("Location:index.php"); } if ( isset($_POST['actionMoreInfo']) ) { $_SESSION['page'] = 'info'; header("Location:index.php"); } else if ( isset($_POST['actionSharedfootprints']) ) { $_SESSION['page'] = 'sharedfootprints'; header("Location:index.php"); } else if ( isset($_GET['myfootprints']) ) { $_SESSION['page'] = 'myfootprints'; header("Location:index.php"); } else if ( isset($_POST['actionStartCalc']) ) { $_SESSION['page'] = 'calculator'; header("Location:index.php"); } else if ( isset($_POST['actionReCalc']) ) { unset($_SESSION['cid']); $_SESSION['page'] = 'calculator'; header("Location:index.php"); } else if ( isset($_POST['actionProgress']) ) { $_SESSION['page'] = 'progress'; header("Location:index.php"); } else if ( isset($_POST['actionFootprint']) ) { $_SESSION['page'] = 'footprint'; header("Location:index.php"); } else if ( isset($_POST['actionIndex']) ) { if (isset($_SESSION['cid'])){ unset($_SESSION['cid']); } $_SESSION['page'] = 'index'; header("Location:index.php"); } $kesa = new Kesa(); if (isset($_GET['showTrash'])) { print_r($kesa->getTrash()); } else if (isset($_GET['emptyTrash'])) { $kesa->emptyTrash(); } // if calculator not started switch ( $_SESSION['page'] ) { case 'index': $kesa->setTemplate("start.html"); break; case 'info': $kesa->setTemplate("info.html"); break; case 'login': $kesa->setTemplate("login.html"); break; case 'register': require_once("register.php"); break; case 'footprint': require_once("footprint.php"); break; case 'footprints': require_once("more_footprints.php"); break; case 'progress': require_once("progress.php"); break; case 'calculator': require_once("calculator.php"); break; case 'sharedfootprints': require_once("more_footprints.php"); break; case 'myfootprints': require_once("my_footprints.php"); break; } $kesa->finalize(); ?>