19 define(
"SOURCE_ROOT",
"/var/www/your/source/root/");
22 require_once(
"geshi.php");
31 exit(
"Access outside acceptable path.");
35 if(!file_exists(
$path)) {
36 exit(
"File not found ($path).");
41 $geshi->set_language(
'text');
46 $geshi->set_overall_style(
'color: #000066; border: 1px solid #d0d0d0; background-color: #f0f0f0;',
true);
47 $geshi->set_line_style(
'font: normal normal 95% \'Courier New\', Courier, monospace; color: #003030;',
'font-weight: bold; color: #006060;',
true);
48 $geshi->set_code_style(
'color: #000020;',
'color: #000020;');
51 $geshi->set_header_content(
'Source code viewer - ' .
$path .
' - ' .
$geshi->get_language_name());
52 $geshi->set_header_content_style(
'font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;');
53 $geshi->set_footer_content(
'Parsed in <TIME> seconds, using GeSHi <VERSION>');
54 $geshi->set_footer_content_style(
'font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-top: 1px solid #d0d0d0; padding: 2px;');
57 <!DOCTYPE
html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN" 58 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
59 <
html xmlns=
"http://www.w3.org/1999/xhtml" xml:lang=
"en" lang=
"en">
62 <
style type=
"text/css">
69 background-
color: #f0f0f0;
72 font-family: Verdana, Arial, sans-serif;
74 border: 2px solid #e0e0e0;
75 background-
color: #fcfcfc;
79 margin: .1em 0 .2em .5em;
80 border-bottom: 1px solid #b0b0b0;
86 margin: .1em 0 .2em .5em;
100 border: 1px solid #b0b0b0;
if(strncmp($real_path, SOURCE_ROOT, $base_path_len)) if(!file_exists($path)) $geshi
if(PHP_SAPI !='cli') color
const GESHI_HOVER
Links in the source in the :hover state.
const GESHI_HEADER_PRE
Use a "pre" to surround the source.
const GESHI_LINK
Links in the source in the :link state.
const GESHI_FANCY_LINE_NUMBERS
Use fancy line numbers when building the result.
const SOURCE_ROOT
Another GeSHi example script.