<html>
<head>
<title>File Viewer</title>
</head>
<body bgcolor = "#FFFFFF">


<center>--- 
<img border=0 src=./images/computer1.GIF width=32 height=32> FILE VIEWER ---</center><br>
</body></html>
<?php
/***************************************************************************
 *			filemngs.php                                        *
 *                     	          				           *
 *   File Info:		  File Viewer                                      *
 *   Copyright:       Copyright 2003 http://www.128concepts.com            *
 *						                           * ***************************************************************************/

# extract data 

$str = getenv("QUERY_STRING");
$str = str_replace("%20"," ",$str);

$pos = strpos($str,"=");
$type = substr($str,0,$pos);
$poss = strpos($str,"+");
$lgt = ($poss-1) - $pos;
$location = substr($str,$pos+1,$lgt);
$file = substr($str,$poss+1,strlen($str));

$str = strrev($file);
$pos = strpos($str,'/');
$file_names = substr($str,0,$pos);
$file_name = strrev($file_names);


$delfile = $file_name;

echo "<table align=center cellspacing=3 cellpadding=3 border=1>";
echo "<tr><td align=center><b>File</b></td><td align=center><b>Image Size (bytes)</b></td></tr>";

if ($type == "image")
{
	$dirs = $location;
	$dirs.= "images/";
	$dir = opendir($dirs);
	while (false != ($file = readdir($dir)))
	{
		if (($file != ".") and ($file != ".."))
		{
			# extract extension and process graphic files only
			$ext = substr($file,-4);
			$ext = strtolower($ext);
			if ($ext == ".png" or $ext == ".jpg" or $ext == ".jpeg" or $ext == ".gif" or $ext == ".bmp")
			{
				$file1 = $dirs;
				$file1.= $file;
				$file_size = @filesize($file1);
				if ($file != $delfile)
				echo "<tr><td><a href=./viewimages.php?$file1>$file</a></td><td>$file_size bytes</td></tr>";
				if ($file == $delfile)
				echo "<tr><td><a href=./viewimages.php?$file1>$file</a>  <a href=./filedel.php?$file1><img src=./images/trashcan.gif border=0 height=18 alt=Delete></a></td><td>$file_size bytes</td></tr>";
			}

		}
	}
	closedir($dir);
}

if ($type == "info")
{
	$dirs = $location;
	$dirs.= "info/";
	$dir = opendir($dirs);
	while (false != ($file = readdir($dir)))
	{
		if (($file != ".") and ($file != ".."))
		{
			# extract extension and process graphic files only
			$ext = substr($file,-4);
			$ext = strtolower($ext);
			if ($ext == ".txt")
			{
				$file1 = $dirs;
				$file1.= $file;
				$file_size = @filesize($file1);
				if ($file != $delfile)
				echo "<tr><td><a href=./viewinfos.php?$file1>$file</a></td><td>$file_size bytes</td></tr>";
				if ($file == $delfile)
				echo "<tr><td><a href=./viewinfos.php?$file1>$file</a>  <a href=./filedel.php?$file1><img src=./images/trashcan.gif border=0 height=18 alt=Delete></a></td><td>$file_size bytes</td></tr>";
			}

		}
	}
	closedir($dir);
}
echo "</table><center><form><input type = button value = Refresh onClick=javascript:history.go()></form></center>";
echo "<br><center>***** END OF FILES *****</center>";
echo "<br><center><a href=./upload.html><img src=images/previous-1.gif border = 0 alt=Back></center><br>";

?>
</body>
</html>