Exemplo n.º 1
0
 public static function getExceptionTrace(Exception $e)
 {
     $cwd = str_replace('\\', '/', dirname(dirname(dirname(__FILE__)))) . '/';
     $file = str_replace($cwd, '', $e->getFile());
     $trace = str_replace($cwd, '', $e->getTraceAsString());
     $str = PHP_EOL . "An exception occurred: {$e->getMessage()} in {$file} on line {$e->getLine()}" . PHP_EOL . $trace . PHP_EOL;
     DevTools_ChromePhp::error($str);
     return (PHP_SAPI == 'cli' ? '' : '<pre>') . $str;
 }
 public static function frontControllerPreDispatch(XenForo_FrontController $fc, XenForo_RouteMatch &$routeMatch)
 {
     if (defined('DEVTOOLS_AUTOLOADER_SETUP') or self::$_checked or $routeMatch->getResponseType() != 'html') {
         return;
     }
     $paths = XenForo_Application::getInstance()->loadRequestPaths();
     $url = $paths['fullBasePath'] . 'filesync.php';
     if (class_exists('XenForo_Dependencies_Admin', false)) {
         $url .= '?admin=1';
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     ob_start();
     curl_exec($ch);
     curl_close($ch);
     self::$_syncOutput = ob_get_contents();
     $logs = explode('<pre>', self::$_syncOutput);
     $errors = array();
     foreach ($logs as $log) {
         $lines = explode("\n", $log);
         foreach ($lines as $line) {
             if (strpos($line, 'E:') === 0) {
                 $origLine = str_replace('E: ', '', $line);
                 $line = '<strong>' . htmlspecialchars($origLine);
                 $pos = strpos($line, ':');
                 $line = substr($line, 0, $pos) . '</strong><i>' . substr($line, $pos);
                 $pos = strpos($line, ' in ' . DIRECTORY_SEPARATOR);
                 // hacked him!
                 $line = substr($line, 0, $pos) . '</i>' . substr($line, $pos);
                 $errors[] = $line;
                 DevTools_ChromePhp::error(trim($origLine));
             } else {
                 DevTools_ChromePhp::log(trim($line));
             }
         }
     }
     ob_end_clean();
     self::$_checked = true;
     self::$_errors = $errors;
 }