| 1 |
1535
|
Luisehahne
|
<?php
|
| 2 |
|
|
/*~ class.quickskindebugger.php
|
| 3 |
|
|
.---------------------------------------------------------------------------.
|
| 4 |
|
|
| Software: QuickSkinDebugger Class * Used by QuickSkin Class |
|
| 5 |
|
|
| Version: 5.0 |
|
| 6 |
|
|
| Contact: andy.prevost@worxteam.com,andy@codeworx.ca |
|
| 7 |
|
|
| Info: http://quickskin.sourceforge.net |
|
| 8 |
|
|
| Support: http://sourceforge.net/projects/quickskin/ |
|
| 9 |
|
|
| ------------------------------------------------------------------------- |
|
| 10 |
|
|
| Author: Andy Prevost andy.prevost@worxteam.com (admin) |
|
| 11 |
|
|
| Author: Manuel 'EndelWar' Dalla Lana endelwar@aregar.it (former admin) |
|
| 12 |
|
|
| Author: Philipp v. Criegern philipp@criegern.com (original founder) |
|
| 13 |
|
|
| Copyright (c) 2002-2009, Andy Prevost. All Rights Reserved. |
|
| 14 |
|
|
| * NOTE: QuickSkin is the SmartTemplate project renamed. SmartTemplate |
|
| 15 |
|
|
| information and downloads can still be accessed at the |
|
| 16 |
|
|
| smarttemplate.sourceforge.net site |
|
| 17 |
|
|
| ------------------------------------------------------------------------- |
|
| 18 |
|
|
| License: Distributed under the Lesser General Public License (LGPL) |
|
| 19 |
|
|
| http://www.gnu.org/copyleft/lesser.html |
|
| 20 |
|
|
| This program is distributed in the hope that it will be useful - WITHOUT |
|
| 21 |
|
|
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
| 22 |
|
|
| FITNESS FOR A PARTICULAR PURPOSE. |
|
| 23 |
|
|
| ------------------------------------------------------------------------- |
|
| 24 |
|
|
| We offer a number of paid services: |
|
| 25 |
|
|
| - Web Hosting on highly optimized fast and secure servers |
|
| 26 |
|
|
| - Technology Consulting |
|
| 27 |
|
|
| - Oursourcing (highly qualified programmers and graphic designers) |
|
| 28 |
|
|
'---------------------------------------------------------------------------'
|
| 29 |
|
|
Last modified: January 01 2009 ~*/
|
| 30 |
|
|
|
| 31 |
|
|
/* designed to work with PHP5 - will NOT work with PHP4 */
|
| 32 |
|
|
|
| 33 |
|
|
class QuickSkinDebugger {
|
| 34 |
|
|
|
| 35 |
|
|
/* The template Filename
|
| 36 |
|
|
* @access private
|
| 37 |
|
|
*/
|
| 38 |
|
|
private $filename;
|
| 39 |
|
|
|
| 40 |
|
|
/* The template itself
|
| 41 |
|
|
* @access private
|
| 42 |
|
|
*/
|
| 43 |
|
|
private $template;
|
| 44 |
|
|
|
| 45 |
|
|
/* Default Left delimiter
|
| 46 |
|
|
* Can be overwritten by global configuration array $_CONFIG['left_delimiter']
|
| 47 |
|
|
* @access public
|
| 48 |
|
|
*/
|
| 49 |
|
|
private $left_delimiter = '{';
|
| 50 |
|
|
|
| 51 |
|
|
/* Default Right delimiter
|
| 52 |
|
|
* Can be overwritten by global configuration array $_CONFIG['right_delimiter']
|
| 53 |
|
|
* @access public
|
| 54 |
|
|
*/
|
| 55 |
|
|
private $right_delimiter = '}';
|
| 56 |
|
|
|
| 57 |
|
|
/* QuickSkinDebugger Constructor
|
| 58 |
|
|
* @param string $template_filename HTML Template Filename
|
| 59 |
|
|
*/
|
| 60 |
|
|
function __construct( $template_filename, $right_delimiter = '}', $left_delimiter = '{' ) {
|
| 61 |
|
|
$this->filename = $template_filename;
|
| 62 |
|
|
|
| 63 |
|
|
/* Load Template */
|
| 64 |
|
|
if ($hd = @fopen($template_filename, 'r')) {
|
| 65 |
|
|
$this->template = fread($hd, filesize($template_filename));
|
| 66 |
|
|
fclose($hd);
|
| 67 |
|
|
} else {
|
| 68 |
|
|
$this->template = 'QuickSkin Debugger Error: File not found: ' . $template_filename;
|
| 69 |
|
|
}
|
| 70 |
|
|
$this->tab[0] = '';
|
| 71 |
|
|
for ($i=1; $i < 10; $i++) {
|
| 72 |
|
|
$this->tab[$i] = str_repeat(' ', $i);
|
| 73 |
|
|
}
|
| 74 |
|
|
$this->right_delimiter = $right_delimiter;
|
| 75 |
|
|
$this->left_delimiter = $left_delimiter;
|
| 76 |
|
|
}
|
| 77 |
|
|
|
| 78 |
|
|
/* Main Template Parser
|
| 79 |
|
|
* @param string $compiled_template_filename Compiled Template Filename
|
| 80 |
|
|
* @desc Creates Compiled PHP Template
|
| 81 |
|
|
*/
|
| 82 |
|
|
function start ( $vars ) {
|
| 83 |
|
|
$page = $this->template;
|
| 84 |
|
|
|
| 85 |
|
|
$page = preg_replace("/(<!-- BEGIN [ a-zA-Z0-9_.]* -->)/", "\n$1\n", $page);
|
| 86 |
|
|
$page = preg_replace("/(<!-- IF .+? -->)/", "\n$1\n", $page);
|
| 87 |
|
|
$page = preg_replace("/(<!-- END.*? -->)/", "\n$1\n", $page);
|
| 88 |
|
|
$page = preg_replace("/(<!-- ELSEIF .+? -->)/", "\n$1\n", $page);
|
| 89 |
|
|
$page = preg_replace("/(<!-- ELSE [ a-zA-Z0-9_.]*-->)/", "\n$1\n", $page);
|
| 90 |
|
|
|
| 91 |
|
|
$page = $this->highlight_html($page);
|
| 92 |
|
|
|
| 93 |
|
|
$rows = explode("\n", $page);
|
| 94 |
|
|
$page_arr = array();
|
| 95 |
|
|
$level = 0;
|
| 96 |
|
|
$blocklvl = 0;
|
| 97 |
|
|
$rowcnt = 0;
|
| 98 |
|
|
$spancnt = 0;
|
| 99 |
|
|
$offset = 22;
|
| 100 |
|
|
$lvl_block = array();
|
| 101 |
|
|
$lvl_row = array();
|
| 102 |
|
|
$lvl_typ = array();
|
| 103 |
|
|
foreach ($rows as $row) {
|
| 104 |
|
|
if ($row = trim($row)) {
|
| 105 |
|
|
$closespan = false;
|
| 106 |
|
|
if (substr($row, $offset, 12) == '<!-- END ') {
|
| 107 |
|
|
if ($level < 1) {
|
| 108 |
|
|
$level++;
|
| 109 |
|
|
$error[$rowcnt] = 'END Without BEGIN';
|
| 110 |
|
|
} elseif ($lvl_typ[$level] != 'BEGIN') {
|
| 111 |
|
|
$error[$lvl_row[$level]] = 'IF without ENDIF';
|
| 112 |
|
|
$error[$rowcnt] = 'END Without BEGIN';
|
| 113 |
|
|
}
|
| 114 |
|
|
$blocklvl--;
|
| 115 |
|
|
$level--;
|
| 116 |
|
|
$closespan = true;
|
| 117 |
|
|
}
|
| 118 |
|
|
if (substr($row, $offset, 14) == '<!-- ENDIF ') {
|
| 119 |
|
|
if ($level < 1) {
|
| 120 |
|
|
$level++;
|
| 121 |
|
|
$error[$rowcnt] = 'ENDIF Without IF';
|
| 122 |
|
|
} elseif ($lvl_typ[$level] != 'IF') {
|
| 123 |
|
|
$error[$lvl_row[$level]] = 'BEGIN without END';
|
| 124 |
|
|
$error[$rowcnt] = 'ENDIF Without IF';
|
| 125 |
|
|
}
|
| 126 |
|
|
$closespan = true;
|
| 127 |
|
|
$level--;
|
| 128 |
|
|
}
|
| 129 |
|
|
if ($closespan) {
|
| 130 |
|
|
$page_arr[$rowcnt-1] .= '</span>';
|
| 131 |
|
|
}
|
| 132 |
|
|
$this_row = $this->tab[$level] . $row;
|
| 133 |
|
|
if (substr($row, $offset, 12) == '<!-- ELSE') {
|
| 134 |
|
|
if ($level < 1) {
|
| 135 |
|
|
$error[$rowcnt] = 'ELSE Without IF';
|
| 136 |
|
|
} elseif ($lvl_typ[$level] != 'IF') {
|
| 137 |
|
|
$error[$rowcnt] = 'ELSE Without IF';
|
| 138 |
|
|
} else {
|
| 139 |
|
|
$this_row = $this->tab[$level-1] . $row;
|
| 140 |
|
|
}
|
| 141 |
|
|
}
|
| 142 |
|
|
if (substr($row, $offset, 14) == '<!-- BEGIN ') {
|
| 143 |
|
|
if ($blocklvl == 0) {
|
| 144 |
|
|
if ($lp = strpos($row, '-->')) {
|
| 145 |
|
|
if ($blockname = trim(substr($row, $offset + 14, $lp -$offset -14))) {
|
| 146 |
|
|
if ($nr = count($vars[$blockname])) {
|
| 147 |
|
|
$this_row .= $this->toggleview($nr . ' Entries');
|
| 148 |
|
|
} else {
|
| 149 |
|
|
$this_row .= $this->toggleview('Emtpy');
|
| 150 |
|
|
}
|
| 151 |
|
|
}
|
| 152 |
|
|
}
|
| 153 |
|
|
} else {
|
| 154 |
|
|
$this_row .= $this->toggleview('[');
|
| 155 |
|
|
}
|
| 156 |
|
|
$blocklvl++;
|
| 157 |
|
|
$level++;
|
| 158 |
|
|
$lvl_row[$level] = $rowcnt;
|
| 159 |
|
|
$lvl_typ[$level] = 'BEGIN';
|
| 160 |
|
|
} elseif (substr($row, $offset, 11) == '<!-- IF ') {
|
| 161 |
|
|
$level++;
|
| 162 |
|
|
$lvl_row[$level] = $rowcnt;
|
| 163 |
|
|
$lvl_typ[$level] = 'IF';
|
| 164 |
|
|
$this_row .= $this->toggleview();
|
| 165 |
|
|
}
|
| 166 |
|
|
$page_arr[] = $this_row;
|
| 167 |
|
|
$lvl_block[$rowcnt] = $blocklvl;
|
| 168 |
|
|
$rowcnt++;
|
| 169 |
|
|
}
|
| 170 |
|
|
}
|
| 171 |
|
|
if ($level > 0) {
|
| 172 |
|
|
$error[$lvl_row[$level]] = 'Block not closed';
|
| 173 |
|
|
}
|
| 174 |
|
|
|
| 175 |
|
|
$page = join("\n", $page_arr);
|
| 176 |
|
|
$rows = explode("\n", $page);
|
| 177 |
|
|
$cnt = count($rows);
|
| 178 |
|
|
|
| 179 |
|
|
for ($i = 0; $i < $cnt; $i++) {
|
| 180 |
|
|
/* Add Errortext */
|
| 181 |
|
|
if (isset($error)) {
|
| 182 |
|
|
if ($err = $error[$i]) {
|
| 183 |
|
|
$rows[$i] = '<b>' . $rows[$i] . ' ERROR: ' . $err . '!</b>';
|
| 184 |
|
|
}
|
| 185 |
|
|
}
|
| 186 |
|
|
|
| 187 |
|
|
/* Replace Scalars */
|
| 188 |
|
|
$right_delimiter = preg_quote($this->right_delimiter);
|
| 189 |
|
|
$left_delimiter = preg_quote($this->left_delimiter);
|
| 190 |
|
|
if (preg_match_all("/$left_delimiter([a-zA-Z0-9_. &;]+)$right_delimiter/", $rows[$i], $var)) {
|
| 191 |
|
|
foreach ($var[1] as $tag) {
|
| 192 |
|
|
$fulltag = $tag;
|
| 193 |
|
|
if ($delim = strpos($tag, ' > ')) {
|
| 194 |
|
|
$tag = substr($tag, 0, $delim);
|
| 195 |
|
|
}
|
| 196 |
|
|
if (substr($tag, 0, 4) == 'top.') {
|
| 197 |
|
|
$title = $this->tip($vars[substr($tag, 4)]);
|
| 198 |
|
|
} elseif ($lvl_block[$i] == 0) {
|
| 199 |
|
|
$title = $this->tip($vars[$tag]);
|
| 200 |
|
|
} else {
|
| 201 |
|
|
$title = '[BLOCK?]';
|
| 202 |
|
|
}
|
| 203 |
|
|
$code = '<b title="' . $title . '">' . $left_delimiter . $fulltag . $right_delimiter . '</b>';
|
| 204 |
|
|
$rows[$i] = str_replace('{'.$fulltag.'}', $code, $rows[$i]);
|
| 205 |
|
|
}
|
| 206 |
|
|
}
|
| 207 |
|
|
|
| 208 |
|
|
/* Replace Extensions */
|
| 209 |
|
|
if (preg_match_all("/$left_delimiter([a-zA-Z0-9_]+):([^}]*)$right_delimiter/", $rows[$i], $var)) {
|
| 210 |
|
|
foreach ($var[2] as $tmpcnt => $tag) {
|
| 211 |
|
|
$fulltag = $tag;
|
| 212 |
|
|
if ($delim = strpos($tag, ' > ')) {
|
| 213 |
|
|
$tag = substr($tag, 0, $delim);
|
| 214 |
|
|
}
|
| 215 |
|
|
if (strpos($tag, ',')) {
|
| 216 |
|
|
list($tag, $addparam) = explode(',', $tag, 2);
|
| 217 |
|
|
}
|
| 218 |
|
|
$extension = $var[1][$tmpcnt];
|
| 219 |
|
|
|
| 220 |
|
|
if (substr($tag, 0, 4) == 'top.') {
|
| 221 |
|
|
$title = $this->tip($vars[substr($tag, 4)]);
|
| 222 |
|
|
} elseif ($lvl_block[$i] == 0) {
|
| 223 |
|
|
$title = $this->tip($vars[$tag]);
|
| 224 |
|
|
} else {
|
| 225 |
|
|
$title = '[BLOCK?]';
|
| 226 |
|
|
}
|
| 227 |
|
|
$code = '<b title="' . $title . '">' . $this->left_delimiter . $extension . ':' . $fulltag . $this->right_delimiter . '</b>';
|
| 228 |
|
|
$rows[$i] = str_replace($this->left_delimiter . $extension . ':' . $fulltag . $this->right_delimiter, $code, $rows[$i]);
|
| 229 |
|
|
}
|
| 230 |
|
|
}
|
| 231 |
|
|
|
| 232 |
|
|
/* 'IF nnn' Blocks */
|
| 233 |
|
|
if (preg_match_all('/<!-- IF ([a-zA-Z0-9_.]+) -->/', $rows[$i], $var)) {
|
| 234 |
|
|
foreach ($var[1] as $tag) {
|
| 235 |
|
|
if (substr($tag, 0, 4) == 'top.') {
|
| 236 |
|
|
$title = $this->tip($vars[substr($tag, 4)]);
|
| 237 |
|
|
} elseif ($lvl_block[$i] == 0) {
|
| 238 |
|
|
$title = $this->tip($vars[$tag]);
|
| 239 |
|
|
} else {
|
| 240 |
|
|
$title = '[BLOCK?]';
|
| 241 |
|
|
}
|
| 242 |
|
|
$code = '<span title="' . $title . '"><!-- IF ' . $tag . ' --></span>';
|
| 243 |
|
|
$rows[$i] = str_replace("<!-- IF $tag -->", $code, $rows[$i]);
|
| 244 |
|
|
if ($title == '[NULL]') {
|
| 245 |
|
|
$rows[$i] = str_replace('Hide', 'Show', $rows[$i]);
|
| 246 |
|
|
$rows[$i] = str_replace('block', 'none', $rows[$i]);
|
| 247 |
|
|
}
|
| 248 |
|
|
}
|
| 249 |
|
|
}
|
| 250 |
|
|
}
|
| 251 |
|
|
$page = join('<br>', $rows);
|
| 252 |
|
|
|
| 253 |
|
|
/* Print Header */
|
| 254 |
|
|
echo '<html><head><script type="text/javascript">
|
| 255 |
|
|
function toggleVisibility(el, src) {
|
| 256 |
|
|
var v = el.style.display == "block";
|
| 257 |
|
|
var str = src.innerHTML;
|
| 258 |
|
|
el.style.display = v ? "none" : "block";
|
| 259 |
|
|
src.innerHTML = v ? str.replace(/Hide/, "Show") : str.replace(/Show/, "Hide");}
|
| 260 |
|
|
</script></head><body>';
|
| 261 |
|
|
|
| 262 |
|
|
/* Print Index */
|
| 263 |
|
|
echo '<font face="Arial" Size="3"><b>';
|
| 264 |
|
|
echo 'QuickSkin Debugger<br>';
|
| 265 |
|
|
echo '<font size="2"><li>PHP-Script: ' . $_SERVER['SCRIPT_FILENAME'] . '</li><li>Template: ' . $this->filename . '</li></font><hr>';
|
| 266 |
|
|
echo '<li><a href="#template_code">Template</a></li>';
|
| 267 |
|
|
echo '<li><a href="#compiled_code">Compiled Template</a></li>';
|
| 268 |
|
|
echo '<li><a href="#data_code">Data</a></li>';
|
| 269 |
|
|
echo '</b></font><hr>';
|
| 270 |
|
|
|
| 271 |
|
|
/* Print Template */
|
| 272 |
|
|
echo '<a name="template_code"><br><font face="Arial" Size="3"><b>Template:</b> [<a href="javascript:void(\'\');" onclick="toggleVisibility(document.getElementById(\'Template\'), this); return false">Hide Ouptut</a>]</font><br>';
|
| 273 |
|
|
echo '<table border="0" cellpadding="4" cellspacing="1" width="100%" bgcolor="#C6D3EF"><tr><td bgcolor="#F0F0F0"><pre id="Template" style="display:block">';
|
| 274 |
|
|
echo $page;
|
| 275 |
|
|
echo '</pre></td></tr></table>';
|
| 276 |
|
|
|
| 277 |
|
|
/* Print Compiled Template */
|
| 278 |
|
|
if (@include_once ("class.quickskinparser.php")) {
|
| 279 |
|
|
$parser = new QuickSkinParser($this->filename);
|
| 280 |
|
|
$compiled = $parser->compile();
|
| 281 |
|
|
echo '<a name="compiled_code"><br><br><font face="Arial" Size="3"><b>Compiled Template:</b> [<a href="javascript:void(\'\');" onclick="toggleVisibility(document.getElementById(\'Compiled\'), this); return false">Hide Ouptut</a>]</font><br>';
|
| 282 |
|
|
echo '<table border="0" cellpadding="4" cellspacing="1" width="100%" bgcolor="#C6D3EF"><tr><td bgcolor="#F0F0F0"><pre id="Compiled" style="display:block">';
|
| 283 |
|
|
highlight_string($compiled);
|
| 284 |
|
|
echo '</pre></td></tr></table>';
|
| 285 |
|
|
} else {
|
| 286 |
|
|
exit( "QuickSkin Error: Cannot find class.quickskinparser.php; check QuickSkin installation");
|
| 287 |
|
|
}
|
| 288 |
|
|
|
| 289 |
|
|
/* Print Data */
|
| 290 |
|
|
echo '<a name="data_code"><br><br><font face="Arial" Size="3"><b>Data:</b> [<a href="javascript:void(\'\');" onclick="toggleVisibility(document.getElementById(\'Data\'), this); return false">Hide Ouptut</a>]</font><br>';
|
| 291 |
|
|
echo '<table border="0" cellpadding="4" cellspacing="1" width="100%" bgcolor="#C6D3EF"><tr><td bgcolor="#F0F0F0"><pre id="Data" style="display:block">';
|
| 292 |
|
|
echo $this->vardump($vars);
|
| 293 |
|
|
echo '</pre></td></tr></table></body></html>';
|
| 294 |
|
|
}
|
| 295 |
|
|
|
| 296 |
|
|
/* Insert Hide/Show Layer Switch
|
| 297 |
|
|
* @param string $suffix Additional Text
|
| 298 |
|
|
* @desc Insert Hide/Show Layer Switch
|
| 299 |
|
|
*/
|
| 300 |
|
|
function toggleview ( $suffix = '') {
|
| 301 |
|
|
global $spancnt;
|
| 302 |
|
|
|
| 303 |
|
|
$spancnt++;
|
| 304 |
|
|
if ($suffix) {
|
| 305 |
|
|
$suffix .= ':';
|
| 306 |
|
|
}
|
| 307 |
|
|
$ret = '[' . $suffix . '<a href="javascript:void(\'\');" onclick="toggleVisibility(document.getElementById(\'Block' . $spancnt . '\'), this); return false">Hide Block</a>]<span id="Block' . $spancnt . '" style="display:block">';
|
| 308 |
|
|
return $ret;
|
| 309 |
|
|
}
|
| 310 |
|
|
|
| 311 |
|
|
/* Create Title Text
|
| 312 |
|
|
* @param string $value Content
|
| 313 |
|
|
* @desc Create Title Text
|
| 314 |
|
|
*/
|
| 315 |
|
|
function tip ( $value ) {
|
| 316 |
|
|
if (empty($value)) {
|
| 317 |
|
|
return '[NULL]';
|
| 318 |
|
|
} else {
|
| 319 |
|
|
$ret = htmlentities(substr($value,0,200));
|
| 320 |
|
|
return $ret;
|
| 321 |
|
|
}
|
| 322 |
|
|
}
|
| 323 |
|
|
|
| 324 |
|
|
/* Recursive Variable Display Output
|
| 325 |
|
|
* @param mixed $var Content
|
| 326 |
|
|
* @param int $depth Incremented Indent Counter for Recursive Calls
|
| 327 |
|
|
* @return string Variable Content
|
| 328 |
|
|
* @access private
|
| 329 |
|
|
* @desc Recursive Variable Display Output
|
| 330 |
|
|
*/
|
| 331 |
|
|
function vardump($var, $depth = 0) {
|
| 332 |
|
|
if (is_array($var)) {
|
| 333 |
|
|
$result = "Array (" . count($var) . ")<BR>";
|
| 334 |
|
|
foreach(array_keys($var) as $key) {
|
| 335 |
|
|
$result .= $this->tab[$depth] . "<B>$key</B>: " . $this->vardump($var[$key], $depth+1);
|
| 336 |
|
|
}
|
| 337 |
|
|
return $result;
|
| 338 |
|
|
} else {
|
| 339 |
|
|
$ret = htmlentities($var) . '<BR>';
|
| 340 |
|
|
return $ret;
|
| 341 |
|
|
}
|
| 342 |
|
|
}
|
| 343 |
|
|
|
| 344 |
|
|
/* Splits Template-Style Variable Names into an Array-Name/Key-Name Components
|
| 345 |
|
|
* @param string $tag Variale Name used in Template
|
| 346 |
|
|
* @return array Array Name, Key Name
|
| 347 |
|
|
* @access private
|
| 348 |
|
|
* @desc Splits Template-Style Variable Names into an Array-Name/Key-Name Components
|
| 349 |
|
|
*/
|
| 350 |
|
|
function var_name($tag) {
|
| 351 |
|
|
$parent_level = 0;
|
| 352 |
|
|
while (substr($tag, 0, 7) == 'parent.') {
|
| 353 |
|
|
$tag = substr($tag, 7);
|
| 354 |
|
|
$parent_level++;
|
| 355 |
|
|
}
|
| 356 |
|
|
if (substr($tag, 0, 4) == 'top.') {
|
| 357 |
|
|
$ret = array('_stack[0]', substr($tag,4));
|
| 358 |
|
|
return $ret;
|
| 359 |
|
|
} elseif ($parent_level) {
|
| 360 |
|
|
$ret = array('_stack[$_stack_cnt-'.$parent_level.']', $tag);
|
| 361 |
|
|
return $ret;
|
| 362 |
|
|
} else {
|
| 363 |
|
|
$ret = array('_obj', $tag);
|
| 364 |
|
|
return $ret;
|
| 365 |
|
|
}
|
| 366 |
|
|
}
|
| 367 |
|
|
|
| 368 |
|
|
/* Highlight HTML Source
|
| 369 |
|
|
* @param string $code HTML Source
|
| 370 |
|
|
* @return string Hightlighte HTML Source
|
| 371 |
|
|
* @access private
|
| 372 |
|
|
* @desc Highlight HTML Source
|
| 373 |
|
|
*/
|
| 374 |
|
|
function highlight_html ( $code ) {
|
| 375 |
|
|
$code = htmlentities($code);
|
| 376 |
|
|
$code = preg_replace('/([a-zA-Z_]+)=/', '<font color="#FF0000">$1=</font>', $code);
|
| 377 |
|
|
$code = preg_replace('/(<[\/a-zA-Z0-9&;]+)/', '<font color="#0000FF">$1</font>', $code);
|
| 378 |
|
|
$code = str_replace('<!--', '<font color="#008080"><!--', $code);
|
| 379 |
|
|
$code = str_replace('-->', '--></font>', $code);
|
| 380 |
|
|
$code = preg_replace('/[\r\n]+/', "\n", $code);
|
| 381 |
|
|
return $code;
|
| 382 |
|
|
}
|
| 383 |
|
|
}
|
| 384 |
|
|
?>
|