i want to transfer password protected files how to add password protection support in this script
<?
//Begin Check Authorized
$auth = 0;
$name='giangkoianlon';
$pass='bfb148852fb1aa08504a900f6a8c3d40'; //VERY IMPORTANT. This password is MD5 encrypted and default password is 'admin'. You must change this by goto http://gdataonline.com/makehash.php to make a MD5 and replace here.
if($auth == 1) {
if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER']!==$name || md5($_SERVER['PHP_AUTH_PW'])!==$pass)
{
header('WWW-Authenticate: Basic realm="Hey man! Please login"');
header('HTTP/1.0 401 Unauthorized');
exit("Oh no! You are bad man! <a href=http://climaxphoto.com>Exit Now</a>");
}
}
//End Check Authorized
error_reporting(0);
function style()
{
echo "<TITLE>Transload Version 2.0</TITLE>
<STYLE>
BODY {
background-color: #C0C0C0;
COLOR: #FFFFFF;
margin: 5px;
FONT-FAMILY: Tahoma; }
TD {
FONT-SIZE: 12px;
FONT-FAMILY: Tahoma;
PADDING: 5px;
COLOR: #000000;
HEIGHT: 20;}
A:link, A:visited, A:active {
COLOR: #0000FF;
TEXT-DECORATION: none; }
A:hover {
COLOR: #FFFF00;
TEXT-DECORATION: none; }
</STYLE>
";
}
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 "<br><TABLE width=1000 align=center border=1 bordercolor=#666666 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>Transfer File Server to Server</H3>
<TABLE width=1000 align=center border=1 bordercolor=#666666 style='border-collapse: collapse' cellpadding=2>
<FORM method=post>
<TR>
<TD width=100% valign=top>
<b>Tranload Url</b><br>
Put one URL or multi URL per line.<br>
Example:<br>
http://domain.com/file1.zip<br>
http://domain.com/file2.zip<br>
http://domain.com/file3.rar<br>
...<br>
http://domain.com/fileN.rar<br>
</TD>
<TD><TEXTAREA wrap=virtual name=url rows=10 cols=84></TEXTAREA></TD>
</TR>
<TR>
<TD colspan=2 align=center><INPUT type=submit value=' Transload '></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();
?>