123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?php
- define("SOURCE_ROOT", "/var/www/your/source/root/");
- require_once("geshi.php");
- $path = SOURCE_ROOT.$_SERVER['PATH_INFO'];
- $base_path_len = strlen(SOURCE_ROOT);
- $real_path = realpath($path);
- if(strncmp($real_path, SOURCE_ROOT, $base_path_len)) {
- exit("Stop that.");
- }
- if(!file_exists($path)) {
- exit("File not found ($path).");
- }
- $contents = file_get_contents($path);
- $geshi =& new GeSHi($contents, "PHP");
- $geshi->set_header_type(GESHI_HEADER_PRE);
- $geshi->enable_classes();
- $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 10);
- $geshi->set_overall_style('color: #000066; border: 1px solid #d0d0d0; background-color: #f0f0f0;', true);
- $geshi->set_line_style('font: normal normal 95% \'Courier New\', Courier, monospace; color: #003030;', 'font-weight: bold; color: #006060;', true);
- $geshi->set_code_style('color: #000020;', 'color: #000020;');
- $geshi->set_link_styles(GESHI_LINK, 'color: #000060;');
- $geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;');
- $geshi->set_header_content('Source code viewer');
- $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;');
- $geshi->set_footer_content('Parsed in <TIME> seconds, using GeSHi <VERSION>');
- $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;');
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <title>Source code viewer - <?php echo $path; ?></title>
- <style type="text/css">
- <!--
- <?php
-
- echo $geshi->get_stylesheet();
- ?>
- html {
- background-color:
- }
- body {
- font-family: Verdana, Arial, sans-serif;
- margin: 10px;
- border: 2px solid
- background-color:
- padding: 5px;
- }
- h2 {
- margin: .1em 0 .2em .5em;
- border-bottom: 1px solid
- color:
- font-weight: normal;
- font-size: 150%;
- }
- h3 {
- margin: .1em 0 .2em .5em;
- color:
- font-weight: normal;
- font-size: 120%;
- }
-
- text-align: center;
- font-size: 80%;
- color:
- }
-
- color:
- }
- textarea {
- border: 1px solid
- font-size: 90%;
- color:
- margin-left: 20px;
- }
- select, input {
- margin-left: 20px;
- }
- p {
- font-size: 90%;
- margin-left: .5em;
- }
- -->
- </style>
- </head>
- <body>
- <?php
- echo $geshi->parse_code();
- ?>
- <hr/>
- </body>
- </html>
|