/** * Returns the printable data * * @param mixed $label * @param mixed $value * * @since ADD MVC 0.10.4 */ public static function return_print_data($label, $value) { $smarty = new add_smarty(); $smarty->assign('label', $label); $smarty->assign('value', $value); $smarty->assign('indentations', 0); return $smarty->fetch('debug/print_data.tpl'); }
/** * Handle shutdown * When development, record the time spent on script execution (since 0.7.2) * * @since ADD MVC 0.5.1 */ static function handle_shutdown() { if (static::$handle_shutdown && !add::is_live() && add::is_developer()) { global $add_mvc_root_timer; $smarty = new add_smarty(); $smarty->display('debug/handle_shutdown.tpl'); if (isset($add_mvc_root_timer) && $add_mvc_root_timer instanceof add_debug_timer) { add_debug::print_config('environment_status'); add_debug::print_config('add_dir'); add_debug::print_config('path'); add_debug::print_config('developer_ips', true); add_debug::print_data('current_user_ip', current_user_ip()); add_debug::print_data('POST variable', $_POST); add_debug::print_data('GET variable', $_GET); add_debug::print_data('COOKIE variable', $_COOKIE); add_debug::print_data('REQUEST variable', $_COOKIE); add_debug::print_data('SESSION variable', $_SESSION); $add_mvc_root_timer->lap("Shutdown"); $add_mvc_root_timer->print_all_laps(); } return static::print_errors(); } }
/** * Returns the printable data * * @param mixed $label * @param mixed $value * @param boolean $escape (htmlspecialchars) (will still escape if passed null) and escape is ignored if the content type is text/plain (could be a problem if we are mistakenly thinking that the content type is text plain! * * @since ADD MVC 0.10.4 */ public static function return_print_data($label, $value, $escape = true) { $smarty = new add_smarty(); $smarty->assign('label', $label); $smarty->assign('value', $value); $smarty->assign('indentations', 0); if ($escape === false) { $smarty->assign('escape', false); } else { $smarty->assign('escape', true); } return $smarty->fetch('debug/print_data.tpl'); }
/** * Handle shutdown * When development, record the time spent on script execution (since 0.7.2) * * @since ADD MVC 0.5.1 */ static function handle_shutdown() { try { while (ob_get_level()) { # Do not echo this, it is a big security risk ob_get_clean(); } if (static::$handle_shutdown && !add::is_live() && add::is_developer()) { global $add_mvc_root_timer; $smarty = new add_smarty(); $smarty->display('debug/handle_shutdown.tpl'); if (isset($add_mvc_root_timer) && $add_mvc_root_timer instanceof add_debug_timer) { add_debug::print_config('environment_status'); add_debug::print_config('add_dir'); add_debug::print_config('path'); add_debug::print_config('developer_ips', true); add_debug::print_data('current_user_ip', current_user_ip()); add_debug::print_data('POST variable', $_POST); add_debug::print_data('GET variable', $_GET); add_debug::print_data('COOKIE variable', $_COOKIE); add_debug::print_data('REQUEST variable', $_COOKIE); if (isset($_SESSION)) { add_debug::print_data('SESSION variable', $_SESSION); } $add_mvc_root_timer->lap("Shutdown"); $add_mvc_root_timer->print_all_laps(); } return static::print_errors(); } } catch (Exception $e) { add::$handle_shutdown = false; add::handle_exception($e); } }
/** * Handle shutdown * When development, record the time spent on script execution (since 0.7.2) * * @since ADD MVC 0.5.1 */ static function handle_shutdown() { if (static::$handle_shutdown) { global $add_mvc_root_timer; $smarty = new add_smarty(); $smarty->display('debug/handle_shutdown.tpl'); if (isset($add_mvc_root_timer) && $add_mvc_root_timer instanceof add_debug_timer) { if (!add::is_live()) { add_debug::print_config('environment_status'); add_debug::print_config('add_dir'); add_debug::print_config('path'); add_debug::print_config('developer_ips', true); } $add_mvc_root_timer->lap("Shutdown"); $add_mvc_root_timer->print_all_laps(); } return static::print_errors(); } }
/** * Print errors */ static function print_errors() { $default_error_tpl = "errors/default.tpl"; $smarty = new add_smarty(); foreach (static::$errors as $error_index => $errors) { $error_tpl = "errors/" . strtolower($error_index) . ".tpl"; if (!$smarty->templateExists($error_tpl)) { $error_tpl = $default_error_tpl; } foreach ($errors as $error) { # The chunk of code on the location of the error if (!add::is_live()) { $code_on_error = ""; $file_codes = file($error['file']); $code_on_error_padding = 3; $code_on_error_start = max($error['line'] - 3, 1); $smarty->assign('code_on_error_start', $code_on_error_start); for ($code_on_error_x = $code_on_error_start; $code_on_error_x <= $error['line'] + $code_on_error_padding; $code_on_error_x++) { $code_on_error .= $file_codes[$code_on_error_x - 1]; } $smarty->assign('code_on_error', highlight_string($code_on_error, true)); $smarty->assign('code_on_error_end', $code_on_error_x); } $error['file'] = basename($error['file']); $error['file_lines'] = array(); foreach ($error['backtrace'] as $backtrace_data) { $error['file_lines'][] = array('file' => basename($backtrace_data['file']), 'line' => $backtrace_data['line']); } if ($smarty->templateExists($error_tpl)) { $smarty->assign("error", $error); $smarty->display($error_tpl); } else { echo "<div>{$error['type']} : {$error['file']}:{$error['line']} : <b>{$error['message']}</b></div>"; } } } }
/** * Smarty construct * * @since ADD MVC 0.7 */ public function __construct() { parent::__construct(); $this->setTemplateDir(array(add::config()->views_dir . '/exceptions', add::config()->add_dir . '/views/exceptions')); }
/** * Prints a data with label * * @since ADD MVC 0.7.4 */ public static function print_data($label, $value) { $smarty = new add_smarty(); $smarty->assign('label', $label); $smarty->assign('value', $value); static::restricted_echo($smarty->fetch('debug/print_data.tpl')); }