01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94:
|
<?PHP
/** * Fügt Zeilenzahlen vor jeder Programmzeile ein * * Systemvoraussetzung: * Linux, Windows * PHP 4 >= 4.0.1, PHP 5 * * Hebt Syntax hervor incl. Zeilenzahlen * * LICENSE: GNU General Public License (GPL) * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * as published by the Free Software Foundation. * * @category CURL * @author Damir Enseleit <info@selfphp.de> * @copyright 2001-2006 SELFPHP * @version $Id: file_number.php,v 0.10 2006/04/16 14:21:10 des1 Exp $ * @link http://www.selfphp.de */
/** * Hebt Syntax hervor incl. Zeilenzahlen * * @param string $file Die darzustellende Datei * @param string $table Tabelle fuer Darstellung * @param bool $print Direkte Ausgabe * * @return mixed */
function lineNumber($file, $table, $print=false) { $content = highlight_file($file,TRUE); $ex_line = file($file); $lines = count($ex_line); $length = strlen($lines); for($x=1;$x<=$lines;$x++) { $ausgabe .= str_pad($x, $length, "0", STR_PAD_LEFT); $ausgabe .= ":<br>"; } $table = @preg_replace('/{lineNumber}/',$ausgabe,$table); $table = @preg_replace('/{phpHighlight}/',$content,$table); if($print === false) { return $table; } else { echo $table; } } // Standardmäßig wird die anzuzeigende Datei aus der ReferUrl ermittelt ! $file = $_SERVER['HTTP_REFERER']; $url = $_SERVER['HTTP_REFERER']; $url_array = parse_url ( $url ); $fileurl = $url_array["path"]; echo '<div style="overflow: none;">'; echo '<h2 align="center">' . $file . '</h2>'; echo '</div>'; echo '<div style="height: 90%; overflow:auto;">';
$table .= '<table>'; $table .= '<tr><td><code>'; $table .= '<span style="color: #AAAAAA;">{lineNumber}</span>'; $table .= '</code></td>'; $table .= '<td>{phpHighlight}</td>'; $table .= '</tr></table>';
// wenn Dateiname ermittelt, dann anzeigen if(!empty($fileurl)) { $file = $_SERVER['DOCUMENT_ROOT'] .trim($fileurl); }
// sonst dieses Script anzeigen else { $file = $_SERVER['DOCUMENT_ROOT'] . "/" .$_SERVER['PHP_SELF']; }
// Ausgabe der Anzeige $lineNum = lineNumber($file,$table,true);
echo '</div>'; ?>
|