Jump to content

[SOLVED] remote upload script problem


lewis987

Recommended Posts

Hey guys, me again lol

 

this time ive created a Client and remote upload script to upload these file types:

 

jpg, JPG, gif, png, PNG, bmp, zip, ZIP, rar, RAR, exe and EXE

 

the problem is, if the user uploads say an EXE through FTP, it give me an error. HTTP works perfectly. I just cant get the FTP to work with exe, EXE, rar, RAR, zip or ZIP. it works fine with images... just not them.

 

here is the remote upload part of it:

 

if($_POST['go1']){
if($mktime >= $uploadwait){
	if($_POST['files'] == ""){
		echo "You cannot use an empty Field!";
	}
	else
	{
		$string = " " . $_POST['files'];
		$find = "http://";
		$found1 = strpos($string, $find);
		if($found1 == FALSE){
			$find = "ftp://";
			$found2 = strpos($string, $find);
			if($found2 == FALSE){
				echo "Cannot use the protocol.";
			}
			else
			{
				$found = strstr($string, $find);
				$find2 = "/";
				$findLast = strrchr($found, $find2);
				$Exp = explode(".", $findLast);
				if(!$Exp){
					echo "Invalid File...";
				}
				else
				{
					if(($Exp[1] === "jpg") || ($Exp[1] === "gif") || ($Exp[1] === "JPG") || ($Exp[1] === "jpeg") || ($Exp[1] === "png") ||  ($Exp[1] === "PNG") || ($Exp[1] === "bmp") || ($Exp[1] === "exe") || ($Exp[1] === "EXE") || ($Exp[1] === "zip") || ($Exp[1] === "ZIP") || ($Exp[1] === "rar") || ($Exp[1] === "RAR")){
						if(($Exp[1] === "exe") || ($Exp[1] === "EXE") || ($Exp[1] === "zip") || ($Exp[1] === "ZIP") || ($Exp[1] === "rar") || ($Exp[1] === "RAR")){
							$md5name = $findlast;
							$copy = copy($found, "files" . $md5name);
						}
						else
						{
							$md5 = md5(mktime());
							$md5name = $md5 . "." . $explode[1];
							$copy = copy($found, "files/" . $md5name);
						}

						if(!$copy){
							echo "Unable to download file onto the server.";
						}
						else
						{
							$file = "files/" . $md5name;
							if(filesize($file) > $fileSizeLimit){
								unlink($file);
								echo "File to large";
							}
							else
							{
								if(fopen("files/" . $md5name)){
									echo "File already exists!";
								}
								else
								{
									echo "Download Complete of the file: " . $findlast . " (named as: {$md5name})<br />";
									echo "<a href='files/".$md5name."'>Click here</a> to view your upload.";
									$_SESSION['time'] = $finaltime;
								}
							}
						}
					}
					else
					{
						echo "File type invalid";
					}
				}
			}
		}	
		else
		{
			$found = strstr($string, $find);
			$find1 = "/";
			$findlast = strrchr($found, $find1);
			$explode = explode(".", $findlast);
			if(!$explode){
				echo "Invalid file...";
			}
			else
			{
				if(($explode[1] === "jpg") || ($explode[1] === "gif") || ($explode[1] === "JPG") || ($explode[1] === "jpeg") || ($explode[1] === "png")  || ($explode[1] === "PNG") || ($explode[1] === "bmp") || ($explode[1] === "exe") || ($explode[1] === "EXE") || ($explode[1] === "ZIP") || ($explode[1] === "zip") || ($explode[1] === "rar") || ($explode[1] === "RAR")){

					if(($explode[1] === "exe") || ($explode[1] === "EXE") || ($explode[1] === "ZIP") || ($explode[1] === "zip") || ($explode[1] === "rar") || ($explode[1] === "RAR")){
						$md5name = $findlast;
						$copy = copy($found, "files" . $md5name);
					}
					else
					{
						$md5 = md5(mktime());
						$md5name = $md5 . "." . $explode[1];
						$copy = copy($found, "files/" . $md5name);
					}

					if(!$copy){
						echo "Unable to download file onto the server.";
					}
					else
					{
						$file = "files/" . $md5name;
						if(filesize($file) > $fileSizeLimit){
							unlink($file);
							echo "File to large";
						}
						else
						{
							if(fopen("files/" . $md5name)){
								echo "File already exists!";
							}
							else
							{
								echo "Download Complete of the file: " . $findlast . " (named as: {$md5name})<br />";
								echo "<a href='files/".$md5name."'>Click here</a> to view your upload.";
								$_SESSION['time'] = $finaltime;
							}
						}	
					}
				}
				else
				{
					echo "File type invalid";
				}
			}
		}
	}
}
else
{
	echo '<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td bgcolor="#FF0000" height="2" width="2"></td>
    <td bgcolor="#FF0000"></td>
    <td bgcolor="#FF0000" height="2" width="2"></td>
  </tr>
  <tr>
    <td bgcolor="#FF0000" height="2"></td>
    <td bgcolor="#FFaaaa">You have not waited long enough before uploading again.</td>
    <td bgcolor="#FF0000" height="2"></td>
  </tr>
  <tr>
    <td bgcolor="#FF0000" height="2" width="2"></td>
    <td bgcolor="#FF0000"></td>
    <td bgcolor="#FF0000" height="2" width="2"></td>
  </tr>
</table>';
}
echo "</body>";
echo "</html>";
exit;
}

 

This is the specific FTP part of it:

 


$found = strstr($string, $find);
$find2 = "/";
$findLast = strrchr($found, $find2);
$Exp = explode(".", $findLast);
if(!$Exp){
echo "Invalid File...";
}
else
{
if(($Exp[1] === "jpg") || ($Exp[1] === "gif") || ($Exp[1] === "JPG") || ($Exp[1] === "jpeg") || ($Exp[1] === "png") ||  ($Exp[1] === "PNG") || ($Exp[1] === "bmp") || ($Exp[1] === "exe") || ($Exp[1] === "EXE") || ($Exp[1] === "zip") || ($Exp[1] === "ZIP") || ($Exp[1] === "rar") || ($Exp[1] === "RAR")){
	if(($Exp[1] === "exe") || ($Exp[1] === "EXE") || ($Exp[1] === "zip") || ($Exp[1] === "ZIP") || ($Exp[1] === "rar") || ($Exp[1] === "RAR")){
		$md5name = $findlast;
		$copy = copy($found, "files" . $md5name);
	}
	else
	{
		$md5 = md5(mktime());
		$md5name = $md5 . "." . $explode[1];
		$copy = copy($found, "files/" . $md5name);
	}		
	if(!$copy){
		echo "Unable to download file onto the server.";
	}
	else
	{
		$file = "files/" . $md5name;
		if(filesize($file) > $fileSizeLimit){
			unlink($file);
			echo "File to large";
		}
		else
		{
			if(fopen("files/" . $md5name)){
				echo "File already exists!";
			}
			else
			{
				echo "Download Complete of the file: " . $findlast . " (named as: {$md5name})<br />";
				echo "<a href='files/".$md5name."'>Click here</a> to view your pload.";
				$_SESSION['time'] = $finaltime;
			}
		}
	}
}
else
{
	echo "File type invalid";
}
}


 

 

 

thanks in advance...

Link to comment
https://forums.phpfreaks.com/topic/64272-solved-remote-upload-script-problem/
Share on other sites

change

	if(($Exp[1] === "exe") || ($Exp[1] === "EXE") || ($Exp[1] === "zip") || ($Exp[1] === "ZIP") || ($Exp[1] === "rar") || ($Exp[1] === "RAR")){
		$md5name = $findlast;
		$copy = copy($found, "files" . $md5name);
	}

 

to

	if(($Exp[1] === "exe") || ($Exp[1] === "EXE") || ($Exp[1] === "zip") || ($Exp[1] === "ZIP") || ($Exp[1] === "rar") || ($Exp[1] === "RAR")){
		$md5name = $findlast;
		$copy = copy($found, "files/" . $md5name);
	}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.