Exemplo n.º 1
0
 public function __construct($global, $global_private)
 {
     $this->global = $global;
     $this->global_private = $global_private;
     $this->dir_core = $this->global['dir_lib'];
     $this->dir_class = (array) $this->global['dir_class'];
     $this->dir_module = (array) $this->global['dir_module'];
     spl_autoload_register(array($this, '__autoload'), false);
     \Fp\Core\Debug::set($this);
 }
Exemplo n.º 2
0
 public function parse_console()
 {
     $txt = '';
     $d = array();
     $d['stats'] = Debug::point();
     $d['logSql'] = Db::get_logReq();
     $d['globData'] = $this->global_data;
     $d['data'] = $this->data;
     $d['block'] = array();
     $d['parsed'] = array();
     foreach ($this->block as $k => $block) {
         $v = (array) $block;
         $v['file'] = !empty($block['file']) ? $block['file'] : null;
         $v['file'] = htmlentities(substr($block['file'], 0, 300), null, 'UTF-8');
         if (isset($this->logBlock[$k])) {
             $v['duration'] = $this->logBlock[$k]['duration'];
             $v['memory'] = $this->logBlock[$k]['memory'];
             $v['memory_peak'] = $this->logBlock[$k]['memory_peak'];
         }
         $d['block'][] = $v;
     }
     foreach ($this->parsed as $block) {
         $v = (array) $block;
         $v['file'] = htmlentities(substr($block['file'], 0, 300), null, 'UTF-8');
         $v['current_file'] = htmlentities(substr($block['current_file'], 0, 300), null, 'UTF-8');
         if (isset($this->logBlock[$block['name']])) {
             $v['duration'] = $this->logBlock[$block['name']]['duration'];
             $v['memory'] = $this->logBlock[$block['name']]['memory'];
             $v['memory_peak'] = $this->logBlock[$block['name']]['memory_peak'];
         }
         $d['parsed'][] = $v;
     }
     $d['log'] = Logger::getLog();
     $file = dirname(__FILE__) . '/tpl_console.php';
     $data = new TemplateData($d);
     try {
         $txt = $this->parse($data, $file);
         $txt = json_encode($txt);
         $txt = "<!-- start Console -->                \n                    <iframe style='width:100%;' id='4p_console_content'  ></iframe>\n                    <script>// <!--\n                    var \$4pConsole = document.getElementById('4p_console_content').contentWindow.document;\n                    \$4pConsole.open();\n                    \$4pConsole.write({$txt});\n                    \$4pConsole.close(); \n                    function \$4presizeIframe(obj) {                        \n                        obj.style.height = (obj.contentWindow.document.body.scrollHeight+500) + 'px';\n                    }\n                    \$4presizeIframe(document.getElementById('4p_console_content'));\n                    // -->\n                    </script>\n                    <!-- end Console -->\r\n";
     } catch (\Exception $e) {
         var_dump($e);
         die('parse_console error');
     }
     return $txt;
 }
Exemplo n.º 3
0
try {
    require_once __DIR__ . '/init_framework.php';
    require_once $C_glob['dir_data'] . 'class/class_init.php';
    $O = new Fp\Apps\init($C_glob, $C_glob_Private);
    $O->process();
} catch (Exception $e_init) {
    if (!headers_sent()) {
        header('HTTP/1.1 503 Service Temporarily Unavailable');
        header('Status: 503 Service Temporarily Unavailable');
        header('Retry-After: 3600');
    }
    try {
        // tentative de log
        $e = $e_init;
        do {
            \Fp\Core\Debug::ExceptionHandler($e);
        } while ($e = $e->getPrevious());
    } catch (Exception $e) {
        /* echec silencieux */
    }
    if (isset($C_glob) && array_key_exists('debug', $C_glob) && $C_glob['debug'] > 2) {
        echo "<pre>\r\n";
        do {
            printf("[%s] %s \n %s:%d  (%d) \n %s\r\n ================== \r\n", get_class($e_init), $e_init->getMessage(), $e_init->getFile(), $e_init->getLine(), $e_init->getCode(), $e_init->getTraceAsString());
        } while ($e_init = $e_init->getPrevious());
        echo "\r\n</pre>";
    } else {
        if (is_file($C_glob['dir'] . '503_service_unavailable.php')) {
            ob_get_clean();
            include $C_glob['dir'] . '503_service_unavailable.php';
            die;
Exemplo n.º 4
0
 /**
  * Logs with an arbitrary level.
  *
  * @param mixed $level
  * @param string $message
  * @param array $context
  * @return null
  */
 public function log($level, $message, array $context = array())
 {
     $errstr = $backtrace = $errno = $errfile = $errline = $code = null;
     if (isset($context[0]) && $context[0] instanceof \Exception) {
         $errstr = $context[0]->getMessage();
         $backtrace = $context[0]->getTraceAsString();
         $errfile = $context[0]->getFile();
         $errline = $context[0]->getLine();
         $code = $context[0]->getCode();
     } else {
         if (array_key_exists('exception', $context) and $context['exception'] instanceof \Exception) {
             $errstr = $context['exception']->getMessage();
             $backtrace = $context['exception']->getTraceAsString();
             $errfile = $context['exception']->getFile();
             $errline = $context['exception']->getLine();
             $code = $context['exception']->getCode();
         } else {
             $errortype = array(E_ERROR => 'Erreur', E_WARNING => 'Alerte', E_PARSE => 'Erreur d\'analyse', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'Erreur spécifique', E_USER_WARNING => 'Alerte spécifique', E_USER_NOTICE => 'Note spécifique', E_STRICT => 'Runtime Notice', E_RECOVERABLE_ERROR => 'Catchable Fatal Error');
             $errno = Filter::int($level);
             if ($errno && array_key_exists($errno, $errortype)) {
                 $level = $errortype[$errno];
             }
             $errfile = Filter::raw('file', $context);
             $errline = Filter::raw('line', $context);
             $code = null;
         }
     }
     \Fp\Core\Debug::msg($message, $backtrace, $errno, $errfile, $errline, $level);
     self::$logMessage[] = "<div><b>{$level}:</b> {$message}<div>{$errfile} {$errline}<pre>{$backtrace}</pre></div></div>";
 }