Source code for /Users/Shared/www/vhosts/top-frog/public_html/script_src/source.php
- <?php
-
- http://www.top-frog.com
- http://www.top-frog.com/archives/2006/11/22/show_php_source_without_duplicating_files
- http://pear.php.net/package/Text_Highlighter/docs
-
- $types = array(
- 'js' => 'JAVASCRIPT',
- 'php' => 'PHP',
- 'phps' => 'PHP',
- 'css' => 'CSS',
- 'xml' => 'XML',
- 'sql' => 'SQL',
- 'py' => 'PYTHON',
- 'htm' => 'HTML',
- 'html' => 'HTML',
- 'shtml' => 'HTML',
- 'rb' => 'RUBY',
- 'pl' => 'PERL',
- 'sh' => 'SQL'
- );
-
- $filename = str_replace('phps','php',array_pop(explode('/',$_SERVER['REQUEST_URI'])));
- $file = dirname(realpath(__FILE__)).($filename != 'source.php' ? '/files/' : '/').$filename;
- if(is_file($file)) {
- require_once('Text/Highlighter.php');
- $th =& Text_Highlighter::factory($types[pathinfo($file,PATHINFO_EXTENSION)],array('numbers' => HL_NUMBERS_LI));
- $src = $th->highlight(file_get_contents($file));
- }
- else {
- $src = '<p>I could not find <i>'.$file.'</i> in the allowed directory structure. '.
- 'Please check your request and try again. If you followed a link here then please '.
- 'contact that system administrator and inform him/her of the bad link.</p>';
- $file = 'File not found';
- }
-
- ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
- "http://www.w3.org/TR/html4/strict.dtd">
- <html lang="en">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
- <title>Source for: <?php echo $file; ?></title>
- <link rel="stylesheet" type="text/css" href="highlight.css" />
- <style type="text/css" media="all">
- body {
- margin: 30px;
- }
- h1, #footer {
- background: #ddd;
- }
- h1 {
- font-family: arial, helvetica, sans-serif;
- font-size: 18px;
- border-bottom: 1px solid gray;
- padding: 10px;
- }
- #footer{
- padding: 5px;
- border-top: 1px solid gray;
- font-size: 11px;
- margin-top: 15px;
- }
- #footer p {
- margin: 0;
- padding: 0;
- }
- ol.hl-main {
- background: #efefef;
- }
- ol.hl-main li {
- white-space: pre;
- font: 10px/1.3 sans-serif;
- background: white;
- margin-bottom: 1px;
- padding: 1px;
- }
- ol.hl-main li span {
- font: 12px/1.3 courier,"courier new", monospaced;
- }
- </style>
- </head>
- <body>
- <h1>Source code for <?php echo $file; ?></h1>
- <div id="source">
- <?php echo $src ?>
- </div>
- <div id="footer"><p>Page delivered by: <a href="source.phps">PHPS source file viewer</a>.</p></div>
- </body>
- </html>