PHP_Debug
[ class tree: PHP_Debug ] [ index: PHP_Debug ] [ all elements ]

Source for file source.php

Documentation is available at source.php


1 <?
2 /**
3 * Source.php : Show source of a php script
4 *
5 * You can use your own source.php file, param is for file to view is $_REQUEST['script']
6 * /!\ Be carreful you must secure this page !!!! /!\
7 *
8 * Don't forget to secure this script !
9 * With something like that or whatever you want ! :)
10 *
11 * if ( !Rights::is_Admin() )
12 * {
13 * redirect_login();
14 * exit;
15 * }
16 *
17 * @filesource
18 * @package PHP_Debug
19 * @see Debug
20 * @since 10 Dec 2003
21 */
22
23 /**
24 * Lang Var
25 */
26 $txtScriptNameNeeded = "Script Name needed";
27 $txtError = "ERROR";
28 $txtViewSource = "View Source of";
29 $txtWrongExt = "Only PHP or include script names are allowed";
30
31 /**
32 * Other Var
33 */
34 $code_back_color = "#F5F5F5";
35
36 /**
37 * highlight_file_line() : Modified version of show_source, with lines numbers
38 *
39 * @param string $file Path of the file to show source
40 *
41 * @since 10 Nov 2003
42 */
43 function highlight_file_line($file)
44 {
45 ob_start();
46 show_source($file);
47 $file_buf = ob_get_contents();
48 ob_end_clean();
49
50 $file_buf = "<code><ol><li>". $file_buf;
51 $file_buf = ereg_replace( "<br />" , "<li>" , $file_buf );
52 $file_buf = "</ol></code>". $file_buf;
53
54 return $file_buf;
55 }
56
57
58 // Start HTML
59 print('<html><body bgcolor="#FFFFFF">');
60
61 /**
62 * Output Source
63 */
64 if ( !$_REQUEST['script'] )
65 {
66 echo "<br><b>== $txtError : $txtScriptNameNeeded</b><br>";
67 }
68 else
69 {
70 $script = $_REQUEST['script'];
71 print("<h3>== $txtViewSource : ". $_REQUEST['script'] ."</h3>");
72
73 if (ereg("(\.php|\.inc|\.tpl|\.txt)$",$script))
74 {
75 print("<table bgcolor=\"$code_back_color\"><tr><td>");
76 print(highlight_file_line($script));
77 print('</td></tr></table>');
78 }
79 else
80 print("<b>== $txtError : $txtWrongExt</b>");
81 }
82
83 // Close HTML
84 print('</body></html>');
85 ?>

Documentation generated on Mon, 15 Dec 2003 18:46:48 +0100 by phpDocumentor 1.2.3