<?php
/***
* @package: SourceOf
* @author: Woody Gilk
* @copyright: 2007
* @license: http://creativecommons.org/licenses/by-sa/3.0/
*
* This software depends on prettify.js, which is available here:
* http://code.google.com/p/google-code-prettify/
*/
// Set settings
$author = 'Woody Gilk';
$copyrt = '2007';
$source = '/wgoldskool/code/sourceof.php';
// Start benchmark and get code
$bm_s = microtime(true); ob_start();
$file = $_SERVER['REQUEST_URI'];
$path = pathinfo(realpath(__FILE__), PATHINFO_DIRNAME);
$path = $path.$file;
$code = file_get_contents($path);
$code = trim(htmlentities($code));
$code = str_replace ('"', '"', $code);
$file = preg_replace('@.*/code/@', '', $path);
// Statistics
$tloc = count(explode("\n",$code));
$size = filesize($path)/1024; // In kilobytes
$size = round($size, 1);
// Copyright date
$copy = date('Y');
$copy = ($copy > $copyrt) ? "$copyrt-$copy" : $copyrt;
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Source of: <?= $file ?></title>
<style type="text/css">@import "/prettify.css";</style>
<script type="text/javascript" src="/prettify.js"></script>
</head>
<body onload="prettyPrint()">
<div id="wrapper">
<h1><?= $file ?></h1>
<div class="codeblock">
<pre class="prettyprint"><?= $code ?></pre>
</div>
<div class="footer">
<p>All code is ©<?= $copy ?> by <?= $author ?>, unless otherwise noted.</p>
<p>Filesize: <?= $size ?>kb — Lines of code: <?= $tloc ?> — Rendered in: 0.00041 seconds</p>
<p><a href="<?= $source ?>" title="View Source">View source of SourceOf</a> — <a href="http://wgilk.com">wgilk.com</a></p>
</div>
</div>
</body>
</html>
<?php
$html = ob_get_contents(); ob_end_clean();
$bm_e = microtime(true);
$bm_t = $bm_e - $bm_s;
$bm_t = abs(round($bm_t, 5));
echo str_replace('0.00041', $bm_t, $html);
?>