/** * Class constructor, initialize the header content type. */ protected function __construct() { $buffer = ob_get_contents(); ob_get_clean(); // ob_start("ob_gzhandler"); // compress page before sending //Not supported for json response on ajax calls header('Content-Type: application/json; charset=utf-8'); if (!parent::isRightVersion()) { $output = INIT::$CONFIG_VERSION_ERR_MESSAGE; $this->result = array("errors" => array(array("code" => -1000, "message" => $output)), "data" => array()); $this->api_output = array("errors" => array(array("code" => -1000, "message" => $output)), "data" => array()); $this->finalize(); exit; } }
/** * Class constructor * * @param bool $isAuthRequired */ public function __construct($isAuthRequired = false) { if (!parent::isRightVersion()) { header("Location: " . INIT::$HTTPHOST . INIT::$BASEURL . "badConfiguration", true, 303); exit; } //SESSION ENABLED parent::sessionStart(); //load Template Engine require_once INIT::$ROOT . '/inc/PHPTAL/PHPTAL.php'; $this->supportedBrowser = $this->isSupportedWebBrowser(); //try to get user name from cookie if it is not present and put it in session if (empty($_SESSION['cid'])) { //log::doLog(get_class($this)." requires check for login"); $username_from_cookie = AuthCookie::getCredentials(); if ($username_from_cookie) { $_SESSION['cid'] = $username_from_cookie['username']; $_SESSION['uid'] = $username_from_cookie['uid']; } } //even if no login in required, if user data is present, pull it out if (!empty($_SESSION['cid'])) { $userSearch = new Users_UserStruct(); $userSearch->email = $_SESSION['cid']; $userDao = new Users_UserDao(Database::obtain()); $userObject = $userDao->read($userSearch); /** * @var $userObject Users_UserStruct */ $userObject = $userObject[0]; // $this->logged_user = getUserData( $_SESSION[ 'cid' ] ); $this->logged_user = $userObject; } if ($isAuthRequired) { //if auth is required, stat procedure $this->doAuth(); } }