
Core Class
By:
gromanazzi on
Apr 29th, 2012 | syntax:
PHP | size: 2.16 KB | hits: 51 | expires: Never
<?php
require('app/login.class.php');
class Application {
private $userId;
private $userEmail;
private $userName;
private $logged;
public function __construct(){
}
private function openHtml(){
echo '<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>';
}
private function closeHtml(){
echo ' </body>
</html>';
}
public function run(){
$login = new Login();
$this->openHtml();
if($this->logged){
if(isset($_GET['a'])){
if($_GET['a'] == 'logout')
$login->logout();
}
else{
//Go to application
}
}
else{
if(!isset($_GET['a']))
$login::showForm();
else if($_GET['a'] == 'login'){
if($login->autenticate($_POST['email'], $_POST['password'])){
$this->logged = true;
$this->userId = $login->getUserId();
$this->userEmail = $login->getUserEmail();
$this->userName = $login->getUserName();
}
else
$this->logged = false;
header('location: ./');
}
}
$this->closeHtml();
}
public function viewUserName(){
echo $this->user;
}
public static function saveHistance($object){
$_SESSION['mainHistance'] = base64_encode(serialize($object)); //Crypted in next version
}
public static function loadHistance(){
return unserialize(base64_decode($_SESSION['mainHistance']));
}
public function showStatus(){
echo $this->logged;
}
}
?>