Source Viewer - sourceviewer.php
< Source Browser
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>Qtopia BlueZ Bluetooth GUI</TITLE>
<?php require("htmlhead.php"); ?>
</HEAD>
<BODY>
<DIV id="Page">
<?php require("header.php"); ?>
<?php require("menu.php"); ?>
<DIV id="Contents">
<H2>Source Viewer - <?php echo $_GET["file"];?></H2>
<P>< <A href="sourcebrowser.php">Source Browser</A></P>
<?php
function in_dir ($file, $in_dir)
{
$dir = realpath($file);
$in_dir = realpath($in_dir);
if (!is_dir ($dir))
{
$dir = dirname($dir);
}
do
{
if ($dir == $in_dir)
{
$is_in_dir = TRUE;
break;
}
} while ($dir != ($dir = dirname($dir)));
return (bool) $is_in_dir;
}
if (in_dir("./" . $_GET["file"],".") &&
(substr_compare($_GET["file"],".php",strlen($_GET["file"])-4,4,true) == 0
|| substr_compare($_GET["file"],".css",strlen($_GET["file"])-4,4,true) == 0
|| substr_compare($_GET["file"],".html",strlen($_GET["file"])-5,5,true) == 0))
{
$sourceFile = fopen( "./" . $_GET["file"], "r" ) ;
if ( $sourceFile )
{
echo "<PRE width=80>\n";
while (!feof($sourceFile))
{
$buffer = fgets($sourceFile, 4096);
$buffer = str_replace("&","&",$buffer);
$buffer = str_replace("<","<",$buffer);
$buffer = str_replace(">",">",$buffer);
echo $buffer;
}
fclose($sourceFile);
echo "\</PRE>";
}
else
{
echo "<P>Unable to open source file!</P>";
}
}
else
{
echo "<P>INVALID SOURCE FILE!</P>";
}
?>
</DIV>
<?php require("status.php");?>
</DIV>
<?php require("footer.php");?>
</BODY>
</HTML>
\