Jump to content

Help me [URL upload script]


nimish01

Recommended Posts

ok, lemme get my code for you...

 

<?PHP
session_start();
function zz($fileSizeLimit){
    switch (true){
    case ($fileSizeLimit > 1048576):
        $fileSizeLimit /= 1048576;
        $suffix = 'MB';    
    break;
    case ($fileSizeLimit > 1024):
        $fileSizeLimit /= 1024;
        $suffix = 'KB';
        break;
    default:
        $suffix = 'B';
    }
    return round($fileSizeLimit, 2).$suffix;
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>_DRW_Uploader (30 Trial Version)</title>
</head>

<body>
<?PHP
//SET YOURSELF (DEFAULT WAS 30 SECONDS AND 50MB)
//This is to prevent hammering the server with uploads...
$time = 30;
$fileSizeLimit = 52428800;
//DO NOT ALTER ANYTHING BELOW!!!
if(!is_dir("files")){
echo "Cannot find the files folder";
exit;
}

$mktime = mktime();
$finaltime = $mktime + $time;

$uploadwait = $_SESSION['time'];
if($uploadwait === ""){
$uploadwait = mktime();
}

$file_address1 = "files/";
$file_address2 = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['REQUEST_URI'] . "files";

if($_POST['go']){
if($mktime >= $uploadwait){
	if($_FILES['upload']['size'] > $fileSizeLimit){
		echo "file to large";
	}
	else{
		$name = $_FILES['upload']['name'];
		$explode = explode(".", $name);
		$ext = strtolower($explode[1]);
		if(($ext == "jpg") || ($ext == "gif") || ($ext == "jpeg") || ($ext == "png") || ($ext == "bmp") || ($ext == "exe") || ($ext == "zip") || ($ext == "rar")){ 

			if(($ext == "exe") || ($ext == "zip") || ($ext == "rar")){
				$md5name = $name;
			}
			else
			{
				$md5 = md5(mktime());
				$md5name = $md5 . "." . $ext;
			}
			$copy = copy($_FILES['upload']['tmp_name'], "files/" . $md5name);
			if(!$copy){
				echo "Cannot upload file. Please try again later...";
			}
			else
			{
				echo "Upload the file: {$name} is complete! (named as: {$md5name})<br />";
				echo "<a href='files/".$md5name."'>Click here</a> to view your upload.";
				$_SESSION['time'] = $finaltime;
			}
		}
		else
		{
			echo "Invalid file type";
		}
	}
}
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;
}
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
				{
					$Ext = strtolower($Exp[1]);
					if(($Ext == "jpg") || ($Ext == "gif") || ($Ext == "jpeg") || ($Ext == "png") || ($Ext == "bmp") || ($Ext == "exe") || ($Ext == "zip") || ($Ext == "rar")){
						if(($Ext == "exe") || ($Ext == "zip") || ($Ext == "rar")){
							$md5name = $findLast;
							if(@fopen("files" . $md5name, r)){
								echo "File already exists!";
								exit;
							}
							$copy = copy($found, "files" . $md5name);
						}
						else
						{
							$md5 = md5(mktime());
							$md5name = $md5 . "." . $Ext;
							if(@fopen("files/" . $md5name, r)){
								echo "File already exists!";
								exit;
							}
							$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
							{
								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
			{
				$ext = strtolower($explode[1]);
				if(($ext == "jpg") || ($ext == "gif") || ($ext == "jpeg") || ($ext == "png")  || ($ext == "bmp") || ($ext == "exe") || ($ext == "zip") || ($ext == "rar")){

					if(($ext == "exe") || ($ext == "zip") || ($ext == "rar")){
						$md5name = $findlast;
						if(fopen("files/" . $md5name)){
							echo "File already exists!";
						}
						$copy = copy($found, "files/" . $md5name);
					}
					else
					{
						$md5 = md5(mktime());
						$md5name = $md5 . "." . $ext;
						if(fopen("files/" . $md5name)){
							echo "File already exists!";
						}
						$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
						{
							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;
}
?>
<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td bgcolor="#888888"><strong>Upload from your own PC!</strong></td>
  </tr>
  <tr>
    <td bgcolor="#aaaaaa">

<form action="" method="post" enctype="multipart/form-data">
<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>File:</td>
    <td><input name="upload" type="file" /></td>
  </tr>
  <tr>
    <td colspan="2" align="center"><input name="go" type="submit" value="Upload" /><input name="reset" type="reset" value="Clear" /></td>
  </tr>
</table>
</form>
</td>
  </tr>
  <tr>
    <td bgcolor="#888888"><strong>REMOTE UPLOADS</strong></td>
  </tr>
  <tr>
    <td bgcolor="#aaaaaa">
<form action="" method="post" enctype="multipart/form-data">
Please include the http:// or ftp:// part of the address! <br />
(for ftp:// please make sure you include the username/password if required)<br />
<input name="files" type="text" size="20" /><br />
<input name="go1" type="submit" value="Remote upload" />
</form>
</td>
  </tr>
  <tr>
  	<td>
    	Time between uploads: <?PHP echo $time; ?> seconds. Max upload size is: <?PHP echo zz($fileSizeLimit); ?>.<br />
	Valid file types: <br />
	<strong>Images:</strong><br />
	bmp, jpg, gif, png.<br />
	<br />
	<strong>Applications:</strong><br />
        zip, rar, exe.
    </td>
  </tr>
</table>
</body>
</html>

 

edit the code accordingly

 

this code will check if the file is a valid file type, and whether its from http/ftp only, if its not then it throws an error.

HEY BRO I USED UR SCRIPT

I CREATED A SUBDIRECTORY:"FILES"

AND UPLOADED THE INDEX.PHP IN MAIN DIR

NOW WHEN I OPEN INDEX.PHP IT OPENS WELL BUT WHEN I TRY TO COPY .rar FILE THEN IT SAYS THAT FILE TYPE INVALID SO PLZ TELL WAT TO DO

 

ALSO IF U CAN PLZ GIVE ME FILE SNATCHER LIKE THE ONES ON THESE SITES:

http://dweep.110mb.com/

http://soamz.12gbfree.com/

 

PLZ BRO IF U CAN IT WOULD BE GREAT FAVOUR FOR ME

ok, to change the file types, edit this part:

 

if(($ext == "jpg") || ($ext == "gif") || ($ext == "jpeg") || ($ext == "png") || ($ext == "bmp") || ($ext == "exe") || ($ext == "zip") || ($ext == "rar")){

 

after  "|| ($ext == "rar")" put this:

 

" || ($ext == "EXTENSION")" but change EXTENSION to whatever you want

 

The reason its failing is because the permissions of the files directory isnt 0777 (write a scipt yourself or use FTP)

 

and i cant give you a file snatcher, i havent coded one.

 

need any more help, pm me and i will get back to you

Warning: fopen() expects at least 2 parameters, 1 given in /www/110mb.com/f/r/e/n/d/z/_/_/frendz/htdocs/upload/index.php on line 206

Warning: copy() [function.copy]: URL file-access is disabled in the server configuration in /www/110mb.com/f/r/e/n/d/z/_/_/frendz/htdocs/upload/index.php on line 209

Warning: copy(http://dweep.110mb.com/files/Doctor.jpg) [function.copy]: failed to open stream: no suitable wrapper could be found in /www/110mb.com/f/r/e/n/d/z/_/_/frendz/htdocs/upload/index.php on line 209
Unable to download file onto the server.

 

THIS IS THE ERROR WAT TO DO TELL PLZ

ALSO TELL HOW TO PM?? I CANT SEE ANY OPTION ON THE PAGE

 

ONE MORE THING

IT WAS SHOWING FILE TYPE INVALID EVEN WHEN I WAS TRYING TO UPLOAD .rar .jpg and .zip FILES THROUGH URL

ahh ok, i will need to re-write some of it. the script is about 2 months old and coded on php 5.2.3

 

but heres some other fixes...

 

<?PHP
session_start();
function zz($fileSizeLimit){
    switch (true){
    case ($fileSizeLimit > 1048576):
        $fileSizeLimit /= 1048576;
        $suffix = 'MB';    
    break;
    case ($fileSizeLimit > 1024):
        $fileSizeLimit /= 1024;
        $suffix = 'KB';
        break;
    default:
        $suffix = 'B';
    }
    return round($fileSizeLimit, 2).$suffix;
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>_DRW_Uploader (30 Trial Version)</title>
</head>

<body>
<?PHP
//SET YOURSELF (DEFAULT WAS 30 SECONDS AND 50MB)
//This is to prevent hammering the server with uploads...
$time = 30;
$fileSizeLimit = 52428800;
//DO NOT ALTER ANYTHING BELOW!!!
if(!is_dir("files")){
echo "Cannot find the files folder";
exit;
}

$mktime = time();
$finaltime = $mktime + $time;

$uploadwait = $_SESSION['time'];
if($uploadwait === ""){
$uploadwait = time();
}

$file_address1 = "files/";
$file_address2 = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['REQUEST_URI'] . "files";

if($_POST['go']){
if($mktime >= $uploadwait){
	if($_FILES['upload']['size'] > $fileSizeLimit){
		echo "file to large";
	}
	else{
		$name = $_FILES['upload']['name'];
		$explode = explode(".", $name);
		$ext = strtolower($explode[1]);
		if(($ext == "jpg") || ($ext == "gif") || ($ext == "jpeg") || ($ext == "png") || ($ext == "bmp") || ($ext == "exe") || ($ext == "zip") || ($ext == "rar")){ 

			if(($ext == "exe") || ($ext == "zip") || ($ext == "rar")){
				$md5name = $name;
			}
			else
			{
				$md5 = md5(time());
				$md5name = $md5 . "." . $ext;
			}
			$copy = copy($_FILES['upload']['tmp_name'], "files/" . $md5name);
			if(!$copy){
				echo "Cannot upload file. Please try again later...";
			}
			else
			{
				echo "Upload the file: {$name} is complete! (named as: {$md5name})<br />";
				echo "<a href='files/".$md5name."'>Click here</a> to view your upload.";
				$_SESSION['time'] = $finaltime;
			}
		}
		else
		{
			echo "Invalid file type";
		}
	}
}
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;
}
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);
				$Count = count($Exp);
				if(!$Exp){
					echo "Invalid File...";
				}
				else
				{
					$Ext = strtolower($Exp[($Count-1)]);
					if(($Ext == "jpg") || ($Ext == "gif") || ($Ext == "jpeg") || ($Ext == "png") || ($Ext == "bmp") || ($Ext == "exe") || ($Ext == "zip") || ($Ext == "rar")){
						if(($Ext == "exe") || ($Ext == "zip") || ($Ext == "rar")){
							$md5name = $findLast;
							if(@fopen("files" . $md5name, r)){
								echo "File already exists!";
								exit;
							}
							$copy = copy($found, "files/" . $md5name);
						}
						else
						{
							$md5 = md5(time());
							$md5name = $md5 . "." . $Ext;
							if(@fopen("files/" . $md5name, "r")){
								echo "File already exists!";
								exit;
							}
							$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
							{
								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);
			$count = count($explode);
			if(!$explode){
				echo "Invalid file...";
			}
			else
			{
				$ext = strtolower($explode[($count-1)]);
				if(($ext == "jpg") || ($ext == "gif") || ($ext == "jpeg") || ($ext == "png")  || ($ext == "bmp") || ($ext == "exe") || ($ext == "zip") || ($ext == "rar")){

					if(($ext == "exe") || ($ext == "zip") || ($ext == "rar")){
						$md5name = $findlast;
						if(fopen("files/" . $md5name)){
							echo "File already exists!";
						}
						$copy = copy($found, "files/" . $md5name);
					}
					else
					{
						$md5 = md5(time());
						$md5name = $md5 . "." . $ext;
						if(fopen("files/" . $md5name)){
							echo "File already exists!";
						}
						$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
						{
							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;
}
?>
<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td bgcolor="#888888"><strong>Upload from your own PC!</strong></td>
  </tr>
  <tr>
    <td bgcolor="#aaaaaa">

<form action="" method="post" enctype="multipart/form-data">
<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>File:</td>
    <td><input name="upload" type="file" /></td>
  </tr>
  <tr>
    <td colspan="2" align="center"><input name="go" type="submit" value="Upload" /><input name="reset" type="reset" value="Clear" /></td>
  </tr>
</table>
</form>
</td>
  </tr>
  <tr>
    <td bgcolor="#888888"><strong>REMOTE UPLOADS</strong></td>
  </tr>
  <tr>
    <td bgcolor="#aaaaaa">
<form action="" method="post" enctype="multipart/form-data">
Please include the http:// or ftp:// part of the address! <br />
(for ftp:// please make sure you include the username/password if required)<br />
<input name="files" type="text" size="20" /><br />
<input name="go1" type="submit" value="Remote upload" />
</form>
</td>
  </tr>
  <tr>
  	<td>
    	Time between uploads: <?PHP echo $time; ?> seconds. Max upload size is: <?PHP echo zz($fileSizeLimit); ?>.<br />
	Valid file types: <br />
	<strong>Images:</strong><br />
	bmp, jpg, gif, png.<br />
	<br />
	<strong>Applications:</strong><br />
        zip, rar, exe.
    </td>
  </tr>
</table>
</body>
</html>

 

im not sure if it will work 100%

NO BUDDY ITS NOT WORKING TOO

CHECK THIS SCRIPT AND TELL WATS WRONG OR WATS NEEDED MORE IN IT

 

INDEX.php

<?php
define('_ALLOWINCLUDE',0);
include 'settings.php';
$version = '2.8 Beta 3';

//////////////////////////////////////////////
//Do Not Change Below Here////////////////////
//////////////////////////////////////////////
if (function_exists('curl_init'))
{
$snatch_system = 'curl';
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>File Snatcher <?php echo $version; ?> - © http://freaks.uk.to</title>
<style type="text/css">
iframe {
border:none;
width:600px;
height:100px;
overflow:hidden;
}

div.p3news_bar {
margin-top:2px;
height:16px;
background-color:#ab4a37;
border-bottom:1px solid #5f1000;
border-right:1px solid #af1d00;
color:#ffffff;
text-align:right;
font-weight:bold;
font-size:12px;
}
</style>
</head>
<body>

<div id="main">
<?php
$submit = $_POST['submit'];
$file_size = $_GET['fs'];
$ds = $_GET['ds'];
if ($_GET['fs'] == true)
{
$ds_fs = filesize($ds);
$progress = round(($ds_fs/$file_size)*100, 2);
if($progress >= 100)
{
	$done = 1;
}
else
{
	$done = 0;
}

if($_GET['done'] == 0)
{
	echo '<meta http-equiv="refresh" content="'. $refresh_time .';index.php?&done='. $done .'&fs='.$file_size.'&ds='.$ds.'">';
}
echo '<div class="p3news_bar" style="width:'. $progress .'%;">'. $progress .'% copied</div>';
echo '<p>Copied '. round($ds_fs/1024, 2) .' of '. round($file_size/1024, 2) .'KB</p>';
}
elseif ($submit == true)
{
if (isset($password))
{
	if ($_POST['password'] != $password)
	{
		die('<p><strong>Password incorrect!</strong></p>');
		$error = true;
	}
}

if (!file_exists($defaultDest))
{
	mkdir($defaultDest);
}
chdir($defaultDest);
$sizelimit_kb = $sizelimit;
$sizelimit = $sizelimit * 1024;

$file = rawurldecode($_POST['file']);

$uploadfile = explode('/', $file);
$filename = array_pop($uploadfile);
$newfilename = $_POST['new'];
if(strstr($newfilename, '/'))
{
	$new_path = explode('/', $newfilename);
	array_pop($new_path);
	$new_path = implode('/', $new_path);
	if(!file_exists($new_path))
	{
		mkdir($new_path);
		echo '<p>Making directory "'. $new_path .'"</p>';
	}
}

$newfilename = str_replace('*', $filename, $newfilename);

if (!$newfilename)
{
	$newfilename = $filename;
}

if (!isset($file))
{
	echo '<p><strong>Please enter a URL to retrieve file from!</strong></p>';
	$error = true;
}

if (!isset($newfilename))
{
	echo '<p><strong>Please enter a new file name!</strong></p>';
	$error = true;
}

if ($error == false)
{
	$dest = $defaultDest;
	$ds = array($dest, '/', $newfilename);
	$ds = implode('', $ds);
	$newname_count = 0;
	if (file_exists($ds))
	{
		echo '<p><strong>File already exists!</strong></p>';
		//Dev Add - next 1 line
		$new_name_needed = true;			
		$newname_count++;
		$newfile = array($newname_count, $newfilename);
		$newfile = implode('~', $newfile);
		$newfile_ds = array($dest, '/', $newfile);
		$newfile_ds = implode('', $newfile_ds);
		while($renamed == false)
		{
			if (file_exists($newfile_ds))
			{
				$newname_count++;
				$newfile = array($newname_count, $newfilename);
				$newfile = implode('~', $newfile);
				$newfile_ds = array($dest, '/', $newfile);
				$newfile_ds = implode('', $newfile_ds);
			}
			else
			{
				$renamed = true;
			}
		}
		$newfilename = $newfile;
		$ds = $newfile_ds;
		echo '<p>New file name is <strong>'.$newfile.'</strong>.</p>';
	}
	echo '<p><strong>Copying...</strong></p>';
	if ($snatch_system == 'curl')
	{
		// Start Remote File Size //
		ob_start();
		$chF = curl_init($file);
		curl_setopt($chF, CURLOPT_HEADER, 1);
		curl_setopt($chF, CURLOPT_NOBODY, 1);

		$ok = curl_exec($chF);
		curl_close($chF);
		$head = ob_get_contents();
		ob_end_clean();

		$regex = '/Content-Length:\s([0-9].+?)\s/';
		$count = preg_match($regex, $head, $matches);

		if($matches[1] > 0)
		{
			if (isset($matches))
			{
				$file_size = $matches[1];
				$file_size_kb = round($file_size/1024, 2);
				echo '<p>Size of file to be copied: '.$file_size_kb.'KB.</p>';
			}
			else
			{
				$no_filesize = true;
				unset($file_size);
			}
		}
		else
		{
			echo '<p>Could not get file size.</p>';
		}
			if($file_size > $sizelimit && $sizelimit > 0)
			{
				echo '<p>File size is too large.<br />Max file size is '.$sizelimit_kb.'KB.</p>';
				$copy_fail = true;
			}

			if($copy_file == false && $file_size > 0)
			{
			echo '<iframe name="progress"
				src="index.php?fs='.$file_size.'&ds='.$ds.'">
				</iframe>';
				$ch = curl_init($file);
				$fp = fopen($ds, 'w');
				curl_setopt($ch, CURLOPT_FILE, $fp);
				curl_setopt($ch, CURLOPT_HEADER, 0);
				curl_exec($ch);
				$curl_info =  curl_getinfo($ch);
				curl_close($ch);
				fclose($fp);
			}
	}
	else
	{
		if (!copy($file, $ds))
		{
			echo '<p>Was unable to copy <a href="'.$file.'">'.$file.'</a><br />See if your path and destination are correct.</p>';
			$copy_fail = true;
		}
	}

	if ($copy_fail == false)
	{
		if ($sizelimit > 0 && filesize($ds) > $sizelimit)
		{
			echo '<p><strong>File is too large.</strong>';
			unlink($ds);
		}
		else
		{
			echo '<p><strong>Copy successful!</strong></p>';
			echo '<p><a href="'.$URLDest.'/'.$newfilename.'">Click here for file</a></p>';
			if ($snatch_system == 'curl')
			{
				$size_dl = round($curl_info['size_download']/1024, 2);
				$speed_dl = round($curl_info['speed_download']/1024, 2);
				echo '<p>Downloaded '.$size_dl.'KB in '.$curl_info['total_time'].' seconds.<br />With an average download speed of '.$speed_dl.'KB/s.';
			}
		}
	}
}
}

if ($_GET['fs'] == false)
{
$self = $_SERVER['PHP_SELF'];
echo '<form method="POST" action="'.$self.'">';
echo '<fieldset><legend>File Snatcher</legend>';
echo '<label for="file">Full path to file to copy</label>';
echo '<p>Example: http://foobar.com/image.png</p>';
echo '<p><input type="text" name="file" id="file" size="45" value=""></p>';
echo '<label for="new">New file name (Optional)</label><br />';
echo '<p>Example: image.png. Or you can specify a different path in relation to the default path, and you can use an asterix (*) to use the orginal file name. Example: new_folder/*</p>';
echo '<p><input type="text" name="new" id="new" size="45" value=""></p>';
if (isset($password))
{
echo '<label for="password">Password</label>';
echo '<p><input type="password" name="password" id="password" size="45" value=""></p>';
}
echo '<p><input name="submit" type="submit" id="submit" value="submit" accesskey="s"></p>';
echo '</fieldset></form>';
}
?>
</div>
</body>
</html>

 

 

 

SETTINGS.php

<?php
defined('_ALLOWINCLUDE') or die();

// Default destination to copy files too NO TRAILING SLASH!!
// If it is complete path, file be copied there eg: /home/public_html/FOLDER (Linux) C:\htdocs\FOLDER (Windows)
// If it is just a folder it will be copied to the folder the script is in, but in the folder eg: /SnatcherFolder/FOLDER
$defaultDest = '/files';

// If you want a password to be required
// Remember if you don't have a password anyone can copy a file to your server!
$password = 'password'; 


// Operating System your SERVER Uses
//1 for Linux. 2 for Windows.
//I'm not sure but I think most Operating Systems other then Windows will use 1.
$os = '1'; 


// URL to location of snatched files WITH OUT TRAILING SLASH
$URLDest = 'http://frendz.12gbfree.com/files';


// Put a limit for file size in kilobytes (1024KB is 1MB)
// For unlimited put 0
// Example $sizelimit = 25;
$sizelimit = 5100;

?>

 

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.