/** * * @return Session; */ public static function getInstance() { if (!self::$_proxy instanceof SessionProxy) { self::$_proxy = new SessionDefault(); } if (!self::$_instance instanceof self) { self::$_instance = new self(); } return self::$_instance; }
/** * Returns a peer instance associated with this om. * * Since Peer classes are not to have any instance attributes, this method returns the * same instance for all member of this class. The method could therefore * be static, but this would prevent one from overriding the behavior. * * @return SessionPeer */ public function getPeer() { if (self::$peer === null) { self::$peer = new SessionPeer(); } return self::$peer; }
private function loginNow($account, $newAccount = false) { $session = new BaseSession(); $ip = $_SERVER['REMOTE_ADDR']; $userAgent = $_SERVER['HTTP_USER_AGENT']; if ($account['active'] == 'active') { $active = true; } else { $active = false; } $session->set(array('ip' => $ip, 'userName' => strtolower($account['username']), 'userAgent' => $userAgent, 'active' => $active)); if ($this->accountModel->lastLogin($account['username'], $ip)) { if (isset($_SESSION['last-location'])) { header('Location:http://' . $_SERVER['HTTP_HOST'] . '/' . $_SESSION['last-location']); die; } else { header('Location:http://' . $_SERVER['HTTP_HOST'] . '/'); die; } } else { $session->end(); header('Location:http://' . $_SERVER['HTTP_HOST'] . '/'); die; } }
return false; } } // GLOBAL DEBUG ARRAY HTML function debug($data) { echo "<pre>"; print_r($data); echo "</pre>"; } $security = new Security(); require_once SITE_PATH . "router.php"; /* * * LOAD CONTROLLER * */ #debug($request); if ($request['Auth'] == true) { $session = new BaseSession(); $session->check(); # CHECK IF LOGGED IN, REDIRECT TO LOGIN IF NOT } $class = ucwords($request['Controller']) . "Controller"; $ctrl = new $class($class, $request); $action = $request['Method']; if (isset($request['Args'])) { $ctrl->{$action}($request['Args']); } else { $ctrl->{$action}(); }