PDA

View Full Version : Zophar's PHP Script...


Xeon3D
08-25-2006, 03:40 AM
On my old days as a staffer here at ZD (note.. quite a few years ago) I was using some kind of script that made the server itself download the huge (10mb) files for me and put them in the server, since I was on 56k then (and downloading 10mb and uploading 10mb for each MAME release was a PITA).

I was wondering if someone knows a script that does just that (well, it could also have a login\password system and if we could choose where in the server the file would be saved... better!) <img src=smilies/werd.gif>
<P ID="signature"></P>

mFC
08-26-2006, 04:20 PM
you could make a simple php script that runs wget
or just shell in and use wget
thats what i usually did
<P ID="signature">Chris

/personal/mfc/newsig.png</P>

Xeon3D
09-01-2006, 12:32 PM
> you could make a simple php script that runs wget
> or just shell in and use wget
> thats what i usually did
>
Thing is... I don't have ssh at my server. :(
<P ID="signature"></P>

Ugly Joe
09-02-2006, 12:30 AM
This is a very insecure script, but does essentially what you want to do. It opens a url, writes it to a string. It then opens a file, and writes the contents of the string to the file. Make sure the folder permissions are correct.

Check to make sure that the filename is not going to try and overwrite an existing file (i'm using 'x' with fopen, but more care should be taken).

Basically, look at this script, figure out what needs to be done, and then write your own <img src=smilies/magbiggrin.gif>

&lt;?php
if ( isset( $_POST['file'] ) &amp;&amp; isset( $_POST['filename'] ) ) {
$file = file_get_contents( $_POST['file'] );
$writeme = @fopen( $_POST['filename'],'x' );
if ( $writeme === FALSE ) {
echo "filename already exists";
die();
}
$results = fwrite( $writeme, $file );
if ( $results === FALSE ) {
echo "failed to write to file.";
} else {
echo "successfully wrote $results bytes.";
}
}
?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Highly Insecure File Transfer Script&lt;/title&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;form action="" method="post"&gt;
Location of file (url): &lt;input type="text" name="file" /&gt;&lt;br /&gt;

Name of file (string): &lt;input type="text" name="filename" /&gt;&lt;br /&gt;
&lt;input type="submit" /&gt;

&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;


<P ID="signature">_______________________________________
http://ximwix.net/images/icons/smaller/altogether.gif (http://ximwix.net)</P>

mFC
09-04-2006, 07:47 PM
calling wget is still way easier
<P ID="signature">Chris

/personal/mfc/newsig.png</P>

Ugly Joe
09-04-2006, 08:03 PM
> calling wget is still way easier

Yep.

<P ID="signature">_______________________________________
http://ximwix.net/images/icons/smaller/altogether.gif (http://ximwix.net)</P>

Xeon3D
10-06-2006, 11:30 PM
Thank you oh so very much! :) I believe this does the trick!
<P ID="signature"></P>

Ugly Joe
10-06-2006, 11:59 PM
> Thank you oh so very much! :) I believe this does the trick!
>
No problem. Just make sure you beef up the security of the script. You have been warned. <img src=smilies/thumb.gif>
<P ID="signature">_______________________________________
http://ximwix.net/images/icons/smaller/altogether.gif (http://ximwix.net)</P>