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


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


if ($_SERVER['REQUEST_METHOD'] == "POST") 
  {
        # escape data and set variables
        $folder= addslashes($_POST["folder"]);
        $location = addslashes($_POST["location"]);
	$file = addslashes($_POST["file"]);
}

##### change \ to / if exists

$npos = strpos($file,"\\");
if ($npos >=1)
	$file = str_replace("\\","/",$file);

$ext = substr($file,-4);
$ext = strtolower($ext);

if ($file == NULL)
{
echo "<hr><center>File field must cannot be null...<br>Please go back and try again !!!!</center><hr>";
	echo "<br><br><center><a href=javascript:history.back()><img src=images/previous-1.gif border = 0 alt=Back></a></center><br>";
	exit();
}

if ($location == NULL)
{
echo "<hr><center>Location field must cannot be null...<br>Please go back and try again !!!!</center><hr>";
	echo "<br><br><center><a href=javascript:history.back()><img src=images/previous-1.gif border = 0 alt=Back></a></center><br>";
	exit();
}

#### check if file contains / character

$symbol = strpos($file,"/");
if ($symbol >= 1)
{

}
else
{
echo "<hr><center>$file must contain / character...<br>Please go back and try again !!!!</center><hr>";
	echo "<br><br><center><a href=javascript:history.back()><img src=images/previous-1.gif border = 0 alt=Back></a></center><br>";
	exit();
}

### check if file contains : character

$symbol = strpos($file,":");
if ($symbol >= 1)
{

}
else
{
echo "<hr><center>$file must contain : character...<br>Please go back and try again !!!!</center><hr>";
	echo "<br><br><center><a href=javascript:history.back()><img src=images/previous-1.gif border = 0 alt=Back></a></center><br>";
	exit();
}

#### check if location contains / character

$symbols = strpos($location,"/");
if ($symbols >= 1)
{

}
else
{
echo "<hr><center>$location must contain / character...<br>Please go back and try again !!!!</center><hr>";
	echo "<br><br><center><a href=javascript:history.back()><img src=images/previous-1.gif border = 0 alt=Back></a></center><br>";
	exit();
}

### check if location contains : character

$symbol = strpos($location,":");
if ($symbols >= 1)
{

}
else
{
echo "<hr><center>$location must contain : character...<br>Please go back and try again !!!!</center><hr>";
	echo "<br><br><center><a href=javascript:history.back()><img src=images/previous-1.gif border = 0 alt=Back></a></center><br>";
	exit();
}


# check for correct file extension if not display error message

if ($folder == "images")
if ($ext == ".png" or $ext == ".jpg" or $ext == ".jpeg" or $ext == ".gif" or $ext == 
".bmp")
{

}
else
{
	echo "<hr><center>$ext not correct graphics extension...<br>Please go back and try again !!!!</center><hr>";
	echo "<br><br><center><a href=javascript:history.back()><img src=images/previous-1.gif border = 0 alt=Back></a></center><br>";
	exit();
}

if ($folder == "info")
if ($ext == ".txt")
{

}
else
{
	echo "<hr><center>$ext not correct information extension...<br>Please go back and try again !!!!</center><hr>";
	echo "<br><br><center><a href=javascript:history.back()><img src=images/previous-1.gif border = 0 alt=Back></a></center><br>";
	exit();
}

if ($location == "")
{
	echo "<hr>No location specified...Please go back and try again !!!!<hr>";
	echo "<br><br><center><a href=javascript:history.back()><img src=images/previous-1.gif border = 0 alt=Back></a></center><br>";
	exit();
}

if ($file != "")
{
	# copy to folder images
	if ($folder == "images")
	{	
		$str = strrev($file);
		$pos = strpos($str,'/');
		$file_names = substr($str,0,$pos);
		$file_name = strrev($file_names);
		$files = $location;
		$files.= "images/";
		$files.= $file_name;
		$files1 = str_replace("/","//",$files);
		copy("$file","$files1")
		or die("Could not copy and upload file....File may not exist/wrong path");
	}
	# copy to folder info
	if ($folder == "info")
	{	
		$str = strrev($file);
		$pos = strpos($str,'/');
		$file_names = substr($str,0,$pos);
		$file_name = strrev($file_names);
		$files = $location;
		$files.= "info/";
		$files.= $file_name;
		$files1 = str_replace("/","//",$files);
		copy("$file","$files1")
		or die("Could not copy and upload file....File may not exist/wrong path");
	}
}
else
{
	
	echo "<hr>No file specified...Please go back and try again !!!!<hr>";
	echo "<br><br><center><a href=javascript:history.back()><img src=images/previous-1.gif border = 0 alt=Back></a></center><br>";
	exit();
}
?>
<html><head><title>Upload completed...</title>
<script language="JavaScript">
function newWindow(mypage,myname,w,h,features) {
  if(screen.width){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  }else{winl = 0;wint =0;}
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
}</script>
</head>
<body bgcolor = "#CCDDFF"><center><img src=./images/line.gif width=400 height=1 border=0><br>File upload succeeded...<img src=./images/line.gif width=400 height=1 border=0><br></center>
<ul>
<li><b>Sent:-</b> <?php echo "$file_name";?>
</ul>
<br>
<?php
$files = $file;
$files = str_replace(" ","%20%",$file);

if ($folder == "images")
echo "
<a href= javascript:newWindow('./viewimages.php?$files1','acePopup',350,300,'scrollbars=yes')><center><img src =./images/searchs.gif width=20 height=24 border = 0 alt=Info>View Image</a>  <a href = ./filemngs.php?image=$location+$files>View Graphic Files</a></center><br>";
if ($folder == "info")
echo "
<a href= javascript:newWindow('./viewinfos.php?$files1','acePopup',350,300,'scrollbars=yes')><center><img src =./images/searchs.gif width=20 height=24 border = 0 alt=Info>View Info File</a>  <a href = ./filemngs.php?info=$location+$files>View Information Files</a></center><br>";
echo "<br><font face=verdana size=2 color = navy>You can delete the file if you Click link for either View Graphic Files or View Information Files. Click the trash icon to perform deletion of file.</font>";

echo "<br><center><a href=javascript:history.back()><img src=images/previous-1.gif border = 0 alt=Back></a></center><br>";
?>
</body>
</html>