<?php

require '../app.inc.php';
require '../appmenu.inc.php';

$src = isset($_GET['src']) ? $_GET['src'] : '';
$src = str_replace('../', '', $src);
$file = "${_SERVER['DOCUMENT_ROOT']}/$src";

$app = new Application("Quelltext von $src", $menu);

if (!is_readable($file) || is_dir($file))
    $app->not_found();

$ext = array_pop(explode(".", $src));
if ($ext == 'wsgi')
    $ext = 'py';
elseif ($ext == 'h')
    $ext = 'cpp';

$app->head_add = "<script type='text/javascript' src='/js/sh/scripts/shCore.js'></script>
<script type='text/javascript' src='/js/sh/scripts/shBrushPhp.js'></script>
<script type='text/javascript' src='/js/sh/scripts/shBrushPython.js'></script>
<script type='text/javascript' src='/js/sh/scripts/shBrushJScript.js'></script>
<script type='text/javascript' src='/js/sh/scripts/shBrushBash.js'></script>
<script type='text/javascript' src='/js/sh/scripts/shBrushCpp.js'></script>
<link type='text/css' rel='stylesheet' href='/js/sh/styles/shCore.css' />
<link type='text/css' rel='stylesheet' href='/js/sh/styles/shTheme2b.css' />
";
$app->header();

echo "<pre class='brush: $ext'>";
echo htmlentities(file_get_contents($file), ENT_NOQUOTES, 'UTF-8');
echo "</pre>

<script type='text/javascript'>
SyntaxHighlighter.defaults['tab-size'] = 8;
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
</script>\n\n";

$app->footer();
?>