/** * Muestra cuadro de Error * @param integer $type Numero de error * @param string $message Mensaje de error * @param string $file Archivo de error * @param string $line Linea de error * @param string $str Depurado de error */ public static function renderError($type, $message = "", $file = "", $line = "", $str = "") { $fullfile = $file; $file = str_replace(ROOT . DS, '', $file); if (ob_get_contents()) { ob_end_clean(); } if (!defined("ENVIRONMENT") || ENVIRONMENT == "dev") { $errorColor = in_array($type, array(E_ERROR, E_CORE_ERROR, E_USER_ERROR)) ? "#F6D8CE" : "#FFFFCC"; echo self::style($errorColor); echo self::drawDebugBox($type, $line, $file, $message); } echo self::showLines(self::getLines($fullfile, $line), $line); $br = "\n"; $text = $type . $br . $line . $br . $file . $br . $message . $br . implode($br, self::getLines($fullfile, $line)); $encodedError = \Supernova\Crypt::encrypt($text); //$encodedError = \Supernova\Crypt::decrypt($encodedError); \Supernova\View::callError(500, $encodedError); }
private static function cleanAllVars() { if (isset($_SERVER['QUERY_STRING']) && strpos(urldecode($_SERVER['QUERY_STRING']), chr(0)) !== false) { \Supernova\View::callError(500); } if (@ini_get('register_globals')) { foreach ($_REQUEST as $key => $value) { ${$key} = null; unset(${$key}); } } $labels = array('@<script[^>]*?>.*?</script>@si', '@&#(\\d+);@', '@\\[\\[(.*?)\\]\\]@si', '@\\[!(.*?)!\\]@si', '@\\[\\~(.*?)\\~\\]@si', '@\\[\\((.*?)\\)\\]@si', '@{{(.*?)}}@si', '@\\[\\+(.*?)\\+\\]@si', '@\\[\\*(.*?)\\*\\]@si'); foreach (array($_GET, $_POST, $_COOKIE, $_REQUEST) as $eachClean) { self::clean($eachClean, $labels); } foreach (array('PHP_SELF', 'HTTP_USER_AGENT', 'HTTP_REFERER', 'QUERY_STRING') as $key) { $_SERVER[$key] = isset($_SERVER[$key]) ? htmlspecialchars($_SERVER[$key], ENT_QUOTES) : null; } unset($etiquetas, $key, $value); }
/** * Deshabilita una acción en el controlador * @return null */ public static function disabled() { debug(__("Disabled view")); \Supernova\View::callError(404); }
<!DOCTYPE html> <html lang="es"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <title>Supernova Framework</title> </head> <body> <header> </header> <?php echo \Supernova\View::getMessage(); ?> <?php echo $content_for_layout; ?> </body> </html>
/** * Carga la acción en memoria */ public static function checkAction() { $mainAppController = new \App\Main(); $mainAppController->beforeController(); $mainController = new \Supernova\Controller(); $namespace = self::$namespace; $actionClass = new $namespace(); if (method_exists($namespace, "execute" . self::$elements['prefix'] . self::$elements['action'])) { call_user_func_array(array($actionClass, "execute" . self::$elements['prefix'] . self::$elements['action']), self::$request['get']); } else { if (method_exists($namespace, "execute" . self::$elements['action'])) { call_user_func_array(array($actionClass, "execute" . self::$elements['action']), self::$request['get']); } else { debug(__("Action not exist:") . " <strong>execute" . self::$elements['action'] . "</strong> " . __("in controller:") . " <strong>" . $namespace . "</strong>"); \Supernova\View::callError(404); } } $mainAppController->afterController(); \Supernova\View::render(); }