somewon Posted October 26, 2008 Share Posted October 26, 2008 I found this script which will accept a list of URLs to files, which it will download into the directory that the script is in. All I want to do is make it so that it will also accept a directory to place the files in, rather than just use the directory the script is in. There was no commenting, so it's a bit weird to try to figure out, for me anyway. Thanks for any help. <? error_reporting(0); function style() { echo "<TITLE>Transload Version 2.0</TITLE> <STYLE> BODY { COLOR: #000000; margin: 5,5,5,5; FONT-FAMILY: Courier New,Courier; } TD { FONT-SIZE: 14px; FONT-FAMILY: Courier New,Courier; COLOR: #555555; HEIGHT: 20; } A:link, A:visited, A:active { COLOR: #000000; TEXT-DECORATION: none; } A:hover { COLOR: #FFFF00; TEXT-DECORATION: none; } </STYLE> "; } $thedir="galleries/"; function url_copy($source) { $d=explode("/",$source); $dest=$d[count($d)-1]; $f1=fopen($source,"rb"); $f2=fopen($dest,"w"); echo "<SCRIPT>window.status='Copying \'$source\' to \'$dest\'...';</SCRIPT>\n"; flush(); while ($buff=fread($f1,1024)) fwrite($f2,$buff); fclose($f1); fclose($f2); $size=filesize($dest); echo "<SCRIPT>window.status='$size bytes copied.';</SCRIPT>\n"; } function list_file() { echo "<TABLE width=90% align=center border=1 bordercolor=#0000FF style='border-collapse: collapse' cellpadding=2> <TR> <TD><B>File name</B></TD> <TD><B>File size</B></TD> <TD><B>File time</B></TD> </TR>"; $d=opendir("."); while ($f=readdir($d)) if (!($f=="." || $f==".." || $f=="index.php")) { $size=filesize($f); $date=filemtime($f); echo "<TR><TD><A href=$f>$f</A></TD><TD>$size</TD><TD>".date ("H:i:s - d F Y", $date)."</TD></TR>"; } echo "</TABLE>"; } function show_form() { echo "<H3 align=center>Transload URL version 2.0<BR> <br></H3> <TABLE width=90% align=center border=1 bordercolor=#0000FF style='border-collapse: collapse' cellpadding=2> <FORM method=post> <TR> <TD width=100% align=right valign=top><B>Tranload Url</B><BR>Put one URL or multi URL per line.<br> EX : http://domain1.com/aa.zip <br>http://domain2.com/bb.zip<br>http://domain3.com/cc.zip<br>..........................</TD> <TD><TEXTAREA wrap=virtual name=url rows=10 cols=80></TEXTAREA></TD> </TR> <TR> <TD colspan=2 align=center><INPUT type=submit value=' Transload now '></TD> </TR> </TABLE> </FORM>"; } function download() { header("Content-type: application/x-download"); header("Content-Disposition: attachment; filename=index.php"); @readfile("index.php"); die(); } $cmd=$_SERVER[QUERY_STRING]; if ($cmd=="source") download(); style(); show_form(); global $HTTP_POST_VARS; $url=$HTTP_POST_VARS[url]; if ($url!="") { $d=explode("\n",$url); $d=str_replace("\r","",$d); for ($i=0; $i<count($d); $i++) if (trim($d[$i])!="") url_copy($d[$i]); } list_file(); ?> <br> <br> Quote Link to comment Share on other sites More sharing options...
somewon Posted October 26, 2008 Author Share Posted October 26, 2008 Actually, nevermind. I got bored and ended up figuring it out myself. Thanks anyway. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.