sourceview.phpDenna kod är public domain. Om ni hittar fel eller vill ändra något i koden blir jag jätteglad om ni skickar dessa ändringar till jesper [at] fantasi [punkt] se.
<?php
$title="Sourceview -- ".$_GET["file"];
$currentFile=__FILE__;
include("header.php");
if ($_GET["file"] != "")
{
$badRequest = 0;
if ($_GET["file"][0] == '/')
$badRequest = 1;
else
{
$nr = 0;
for ($i = 0; $i < strlen($_GET["file"]); $i++)
{
if ($_GET["file"][$i] == '.')
$nr++;
else if ($_GET["file"][$i] < '-')
{
$nr++;
$_GET["file"][$i] = '-';
}
}
}
if ($nr != 1)
$badRequest = 1;
if ($badRequest == 0)
{
echo "<h1>".basename($_GET["file"])."</h1>";
echo "<p class=\"maincontent\">Denna kod är public domain. ";
echo "Om ni hittar fel eller vill ändra något i koden blir ";
echo "jag jätteglad om ni skickar dessa ändringar till ";
echo "jesper [at] fantasi [punkt] se.";
echo "</p><hr>";
$file = fopen($_GET["file"],"r");
if ($file != null)
{
echo "<pre class=\"codebox\">";
while (!feof($file))
{
$ch = fgetc($file);
switch ($ch)
{
case '<': echo "<"; break;
case '>': echo ">"; break;
case '&': echo "&"; break;
default: echo $ch;
}
}
fclose($file);
echo "</pre>";
}
else
echo "<p class=\"maincontent\">Unable to open file.</p>";
}
else
echo "<p class=\"maincontent\">I'd prefer not to display that page.</p>";
}
else
echo "<p class=\"maincontent\">No file to open...</p>";
include("footer.php");
?>
|