<?php
/*
The Index software may be freely distributed.
See license.txt for details.
*/
define('ROOT', './');
$files = array(
"source.php", // Must be the first one!
"text.inc",
"layout.inc",
"list/random.inc",
"index.php",
"item.php",
"submit.php",
"changes.php",
"about.php",
"counts/count.inc",
"counts/jump.php",
"list/list.inc",
"notes/notes.inc",
"license.txt"
);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>Source of <?php print $file ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<pre>
<?php
if ($file != "")
{
$ok = 0;
reset($files);
while (list(,$listed) = each($files))
{
if ($file == $listed)
{
$ok = 1;
}
}
if (!$ok)
{
print "$file: Access denied\n\n";
print "You can only view sources of the Index software. Access to any other file will always be denied.\n";
}
else
{
$file = ROOT . $file;
$f = @fopen($file, "r");
if ($f)
{
while (!feof($f))
{
$s = fgets($f, 4096);
$s = htmlentities($s);
for ($i = 0; $i < count($files); $i++)
{
$s = str_replace($files[$i],
"<a href=\"source.php?file=$files[$i]\">$files[$i]</a>", $s);
}
print $s;
}
fclose($f);
}
else
{
print "$file: cannot open";
}
}
}
else
{
?>No file<?php
}
?>
</pre>
</body>
</html>