Reply
Merging two server to server transfer scripts ?
Old 04-26-2008, 05:16 PM Merging two server to server transfer scripts ?
Novice Talker

Posts: 13
Hi

i had used these two scripts named "File Snatcher" and "Server to Server File Transfer 2".

File Snatcher while being a typical file snatching script is not well written and usually it is not able to get file size for the files, if the url contains redirection. On the other hand, SST is a great script which has a 100% success rate towards downloading files from other servers. But it has a restriction of 5 mb download allowed only.

The file snatcher script doesnt have any such restriction but its limit is the php timeout of the site only. But its not useful as its never able to detect the files on the other server. I was hoping and wished that somehow the SST script could be edited and that particular restriction removed. However, i am a noob so im really very helpless. Please help me in this thing. I am posting copies of both the scripts below, please help me
Desi-Instincts is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 04-26-2008, 05:21 PM Re: Merging two server to server transfer scripts ?
Novice Talker

Posts: 13
File Snatcher script


Index.php (The file which is to be run through the browser) ::

PHP Code:
<?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?> - &copy; http://noveis.net</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)*1002);
if(
$progress >= 100)
{
$done 1;
}
else
{
$done 0;
}
 
if(
$_GET['done'] == 0)
{
echo 
'<meta http-equiv="refresh" content="'$refresh_time .';index.php?&done='$done .'&amp;fs='.$file_size.'&amp;ds='.$ds.'">';
}
echo 
'<div class="p3news_bar" style="width:'$progress .'%;">'$progress .'% copied</div>';
echo 
'<p>Copied 'round($ds_fs/10242) .' of 'round($file_size/10242) .'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($chFCURLOPT_HEADER1);
curl_setopt($chFCURLOPT_NOBODY1);
 
$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/10242);
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.'&amp;ds='.$ds.'">
</iframe>'
;
$ch curl_init($file);
$fp fopen($ds'w');
curl_setopt($chCURLOPT_FILE$fp);
curl_setopt($chCURLOPT_HEADER0);
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 && 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']/10242);
$speed_dl round($curl_info['speed_download']/10242);
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 (The file containing all the settings) ::

PHP Code:
<?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 '/home/examplene/public_html/snatched';
// 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://example.net/snatched';
 
// Put a limit for file size in kilobytes (1024KB is 1MB)
// For unlimited put 0
// Example $sizelimit = 25;
$sizelimit 0;
?>

Last edited by Desi-Instincts : 04-27-2008 at 02:44 PM.
Desi-Instincts is offline
Reply With Quote
View Public Profile
 
Old 04-26-2008, 05:25 PM Re: Merging two server to server transfer scripts ?
Novice Talker

Posts: 13
SST (Server to Server Transfer 2 Script)

script.inc.php ::

PHP Code:
<?
////////////////////////////////////////////////////////////////////////////////
// 
// Project : Server to Server Transfer [SST] 2 
// Filename : script.inc.php 
// Purpose : Javascript script library
// Version : 2.1 
// Author : James Azarja 
// 
function status($msg)
{
echo 
"<SCRIPT>document.form.status.value=\"$msg\";</SCRIPT>\n";
}
function 
changebg()
{
echo 
"<SCRIPT>document.bgColor=\"#B22222\";</SCRIPT>\n";
}
function 
progress($progress,$max)
{
echo 
"<SCRIPT>showprogress($progress,$max);</SCRIPT>\n";
}
?>
downloader.php ::
http://www.webmaster-talk.com/attach...1&d=1209245537

sst.php (The file which is to be run through the browser) ::
http://www.webmaster-talk.com/attach...1&d=1209245537
Attached Files
File Type: txt downloader.txt (13.6 KB, 9 views)
File Type: txt sst.txt (4.4 KB, 3 views)

Last edited by Desi-Instincts : 04-27-2008 at 02:44 PM.
Desi-Instincts is offline
Reply With Quote
View Public Profile
 
Old 04-27-2008, 02:58 AM Re: Merging two server to server transfer scripts ?
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
modify this line from the downloader.php
$maxsize=1048576*5;
__________________
If you like my posts ... TK is appreciated:)
Web Directory | Blog
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Old 04-27-2008, 02:39 PM Re: Merging two server to server transfer scripts ?
Novice Talker

Posts: 13
Quote:
Originally Posted by solomongaby View Post
modify this line from the downloader.php
$maxsize=1048576*5;
I have already tried that . . . when i change the above mentioned value in your post to :
$maxsize=1073741824*5;

It increases the download limit till 15 MB or so..... but after that, when transferring any file, if it exceeds that value, it says :

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 33293516 bytes) in /(my server's various directories)/downloader.php on line 166
Desi-Instincts is offline
Reply With Quote
View Public Profile
 
Old 04-27-2008, 02:41 PM Re: Merging two server to server transfer scripts ?
Novice Talker

Posts: 13
Please its my request ... is there someone / anyone here who can help me ? Please help me its very urgent.
Desi-Instincts is offline
Reply With Quote
View Public Profile
 
Old 04-27-2008, 03:09 PM Re: Merging two server to server transfer scripts ?
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
that is due to the php configuration, increase the memory_limit setting in php.ini or directly in your php script by using the ini_set() function
__________________
If you like my posts ... TK is appreciated:)
Web Directory | Blog
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Old 04-27-2008, 03:15 PM Re: Merging two server to server transfer scripts ?
Novice Talker

Posts: 13
Quote:
Originally Posted by solomongaby View Post
that is due to the php configuration, increase the memory_limit setting in php.ini or directly in your php script by using the ini_set() function
Sorry for being an irritating dumb noob.... but i didnt understand a word of what you said. Please i request could you assist in the coding thing ? Pretty please !
Desi-Instincts is offline
Reply With Quote
View Public Profile
 
Old 04-27-2008, 03:29 PM Re: Merging two server to server transfer scripts ?
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
sure for some TK )

Since i had explain this to a lot of people i have writen a post on my blog about it ... so it come easyer than writing the explanation every time.

Php has a limit of memory alocated for each script ( default 8MB, you can see it by putting the line phpinfo() in a test script ).
In your case the script goes over the limit because of the file your trying to download. To fix you must increase the memory_limit either in php.ini ( if you have acces ) or by adding the line ini_set('memory_limit','50MB'); to youre script.
__________________
If you like my posts ... TK is appreciated:)
Web Directory | Blog
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Old 04-27-2008, 03:39 PM Re: Merging two server to server transfer scripts ?
Novice Talker

Posts: 13
where should i add this :

ini_set('memory_limit','50MB');

I mean in which line ? and in which file of the SST script ?
Desi-Instincts is offline
Reply With Quote
View Public Profile
 
Old 04-27-2008, 03:45 PM Re: Merging two server to server transfer scripts ?
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
downloader.php i would put in in the first lines
__________________
If you like my posts ... TK is appreciated:)
Web Directory | Blog
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Old 04-27-2008, 03:54 PM Re: Merging two server to server transfer scripts ?
Novice Talker

Posts: 13
I added the mentioned line like this :
PHP Code:
<?
////////////////////////////////////////////////////////////////////////////////
//                                                                              
// Project   : Server to Server Transfer [SST] 2                                
// Filename  : downloader.php                                                   
// Purpose   : HTTP Downloader Implementation                                   
// Version   : 2.1                                                              
// Author    : James Azarja                                                     
//                                    &nbs