escapeHtml() public static method

public static escapeHtml ( $input )
Example #1
0
 public static function formatHtml($mask)
 {
     $args = func_get_args();
     return preg_replace_callback('#%#', function () use(&$args, &$count) {
         return Helpers::escapeHtml($args[++$count]);
     }, $mask);
 }
Example #2
0
 private function renderHtml()
 {
     $res = '<style>code, pre {white-space:nowrap} a {text-decoration:none} pre {color:gray;display:inline} big {color:red}</style><code>';
     foreach ($this->list as $item) {
         $stack = [];
         foreach (array_slice($item[3], 1) as $t) {
             $t += ['class' => '', 'type' => '', 'function' => ''];
             $stack[] = "{$t['class']}{$t['type']}{$t['function']}()" . (isset($t['file'], $t['line']) ? ' in ' . basename($t['file']) . ":{$t['line']}" : '');
         }
         $res .= '<span title="' . Helpers::escapeHtml(implode("\n", $stack)) . '">' . Helpers::editorLink($item[0], $item[1]) . ' ' . str_replace(self::BOM, '<big>BOM</big>', Dumper::toHtml($item[2])) . "</span><br>\n";
     }
     return $res . '</code>';
 }
Example #3
0
function e($s)
{
    return Helpers::escapeHtml($s);
}
Example #4
0
 /**
  * Returns syntax highlighted source code.
  * @param  string
  * @param  int
  * @param  int
  * @return string|NULL
  */
 public static function highlightFile($file, $line, $lines = 15, array $vars = NULL)
 {
     $source = @file_get_contents($file);
     // @ file may not exist
     if ($source) {
         $source = static::highlightPhp($source, $line, $lines, $vars);
         if ($editor = Helpers::editorUri($file, $line)) {
             $source = substr_replace($source, ' data-tracy-href="' . Helpers::escapeHtml($editor) . '"', 4, 0);
         }
         return $source;
     }
 }
Example #5
0
 /**
  * @return array
  */
 private function renderPanels($suffix = NULL)
 {
     set_error_handler(function ($severity, $message, $file, $line) {
         if (error_reporting() & $severity) {
             throw new \ErrorException($message, 0, $severity, $file, $line);
         }
     });
     $obLevel = ob_get_level();
     $panels = [];
     foreach ($this->panels as $id => $panel) {
         $idHtml = preg_replace('#[^a-z0-9]+#i', '-', $id) . $suffix;
         try {
             $tab = (string) $panel->getTab();
             $panelHtml = $tab ? (string) $panel->getPanel() : NULL;
             if ($tab && $panel instanceof \Nette\Diagnostics\IBarPanel) {
                 $e = new \Exception('Support for Nette\\Diagnostics\\IBarPanel is deprecated');
             }
         } catch (\Throwable $e) {
         } catch (\Exception $e) {
         }
         if (isset($e)) {
             while (ob_get_level() > $obLevel) {
                 // restore ob-level if broken
                 ob_end_clean();
             }
             $idHtml = "error-{$idHtml}";
             $tab = "Error in {$id}";
             $panelHtml = "<h1>Error: {$id}</h1><div class='tracy-inner'>" . nl2br(Helpers::escapeHtml($e)) . '</div>';
             unset($e);
         }
         $panels[] = (object) ['id' => $idHtml, 'tab' => $tab, 'panel' => $panelHtml];
     }
     restore_error_handler();
     return $panels;
 }