/** * @return void */ protected function handle() { $this->writeLog(); $error = $this->getError(); if ($error instanceof Error && $error->isFatal() === false) { return; } if ($this->isDebuggerEnabled) { $this->flushInnerOutputBuffer(); $output = $this->getOutput(); $this->deleteOutputBuffer(); if (Response::headersSent() === false) { $this->rewriteHttpHeaders(); } $this->executeDebugger($output); ini_set('display_errors', '0'); } elseif (Response::headersSent() === false) { $this->rewriteHttpHeaders(); if (Config::getBool('hyperframework.web.error_view.enable', true)) { $this->deleteOutputBuffer(); $this->renderErrorView(); ini_set('display_errors', '0'); } } }
/** * @param string $name * @param string $outputFormat * @return string */ public static function build($name, $outputFormat = null) { $result = str_replace('-', '_', $name); if (Config::getBool('hyperframework.web.view.filename.include_output_format', true)) { if ($outputFormat === null) { $outputFormat = Config::getString('hyperframework.web.view.default_output_format', 'html'); } $outputFormat = (string) $outputFormat; if ($outputFormat !== '') { $result .= '.' . $outputFormat; } } $format = Config::getString('hyperframework.web.view.format', 'php'); if ($format !== '') { $result .= '.' . $format; } return $result; }
/** * @return bool */ public function isMultipleCommandMode() { if ($this->isMultipleCommandMode === null) { $this->isMultipleCommandMode = Config::getBool('hyperframework.cli.multiple_commands', false); } return $this->isMultipleCommandMode; }
/** * @return bool */ protected function isLoggerEnabled() { return Config::getBool('hyperframework.error_handler.enable_logger', true); }
/** * @return void */ private function handleProfile($state) { if ($this->profile === null) { return; } $profile = $this->profile; $this->profile = null; $shouldIgnoreRead = Config::getBool('hyperframework.db.operation_profiler.ignore_read', false); if ($shouldIgnoreRead && isset($profile['sql'])) { if (strtoupper(substr(trim($profile['sql']), 0, 6)) === 'SELECT') { return; } } $profile['state'] = $state; $endTime = $this->getTime(); $profile['running_time'] = (double) sprintf('%.6F', $endTime[1] - $profile['start_time'][1] + $endTime[0] - $profile['start_time'][0]); $profile['start_time'] = DateTime::createFromFormat('U.u', $profile['start_time'][1] . '.' . (int) ($profile['start_time'][0] * 1000000))->setTimeZone(new DateTimeZone(date_default_timezone_get())); $isLoggerEnabled = Config::getBool('hyperframework.db.operation_profiler.enable_logger', true); if ($isLoggerEnabled) { $callback = function () use($profile) { $log = '[DB] | '; if (isset($profile['connection_name'])) { $log .= "connection: " . $profile['connection_name'] . " | "; } $log .= 'state: ' . $profile['state'] . ' | time: ' . sprintf('%.6F', $profile['running_time']) . " | "; if ($profile['type'] !== 'transaction_operation') { $log .= 'sql: ' . $profile['sql']; $configName = 'hyperframework.db.operation_profiler' . '.log_prepared_statement_params'; $shouldLogPreparedStatementParams = Config::getBool($configName, true); if ($shouldLogPreparedStatementParams && isset($profile['params']) && count($profile['params']) > 0) { $log .= ' | params: ' . json_encode($profile['params'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); } } else { $log .= 'transaction: ' . $profile['operation']; } return $log; }; $loggerClass = Config::getClass('hyperframework.db.operation_profiler.logger_class', Logger::class); $loggerClass::debug($callback); } $profileHandler = $this->getProfileHandler(); if ($profileHandler !== null) { $profileHandler->handle($profile); } }
/** * @return bool */ public static function isEnabled() { return Config::getBool('hyperframework.web.csrf_protection.enable', true); }
/** * @return void */ protected function initializeGlobalPostData() { if (Config::getBool('hyperframework.web.initialize_global_post_data', false)) { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $_POST = $this->getBodyParams(); } } }