public function __construct() { try { \PH7\Framework\Mvc\Router\FrontController::getInstance()->_databaseInitialize(); } catch (\PH7\Framework\Mvc\Model\Engine\Exception $oE) { // If we are not in development mode, we display an error message to avoid showing information on the database. if (!Debug::is()) { exit('Could not connect to database server!'); } } parent::__construct(); }
/** * Output Stream Views. * * @final * @param string $sFile Specify another display file instead of the default layout file. Default NULL * @return void */ public final function output($sFile = null) { /** * Remove database information for the tpl files in order to prevent any attack attempt. **/ \PH7\Framework\Mvc\Router\FrontController::getInstance()->_removeDatabaseInfo(); /** * Destroy all object instances of PDO and close the connection to the database before the display and the start of the template and free memory */ M\Engine\Db::free(); /** * Output our template and encoding. */ $sFile = !empty($sFile) ? $sFile : $this->view->getMainPage(); // header('Content-type: text/html; charset=' . PH7_ENCODING); $this->view->display($sFile, PH7_PATH_TPL . PH7_TPL_NAME . PH7_DS); $this->view->clean(); // Clean Template Data }
// Starting zlib-compressed output /* This "zlib output compression" compressthe pages. This allows you to save your bandwidth and faster download of your pages. WARNING: this function consumes CPU resources on your server. So you can if you want to remove this function. */ //ini_set('zlib.output_compression', 2048); //ini_set('zlib.output_compression_level', 6); ob_start(); new Server(); // Start Server Registry::getInstance()->start_time = microtime(true); /** * Initialize the FrontController, we are asking the front controller to process the HTTP request */ FrontController::getInstance()->runRouter(); } catch (Except\UserException $oE) { echo $oE->getMessage(); // Simple User Error with Exception } catch (Except\PH7Exception $oE) { Except\PH7Exception::launch($oE); } catch (\Exception $oE) { Except\PH7Exception::launch($oE); } finally { if ('' !== session_id()) { session_write_close(); } ob_end_flush(); exit(0); }