<?
error_reporting(7);
@ini_set("memory_limit", "1024M");
@ob_end_clean();
ob_implicit_flush(TRUE);
//ignore_user_abort(1);
$nn = "\r\n";
if(!defined('CRLF')) define('CRLF',"\r\n");
if(!defined("FTP_AUTOASCII")) define("FTP_AUTOASCII", -1);
if(!defined("FTP_BINARY")) define("FTP_BINARY", 1);
if(!defined("FTP_ASCII")) define("FTP_ASCII", 0);
if(!defined('FTP_FORCE')) define('FTP_FORCE', TRUE);
define('FTP_OS_Unix','u');
define('FTP_OS_Windows','w');
define('FTP_OS_Mac','m');
define('VERSION', "0.46");
define('PATH_SPLITTER', (strstr(realpath("./"), ":") ? "\\" : "/"));
foreach($_POST as $key => $value)
{
$_GET[$key] = $value;
}
if(!$_COOKIE)
{
if(strstr($_SERVER["HTTP_COOKIE"], ";"))
{
foreach(explode("; ", $_SERVER["HTTP_COOKIE"]) as $key => $value)
{
list($var, $val) = explode("=", $value);
$_COOKIE[$var] = $val;
}
}
else
{
list($var, $val) = @explode("=", $_SERVER["HTTP_COOKIE"]);
$_COOKIE[$var] = $val;
}
}
if(!$PHP_SELF)
{
$PHP_SELF = $_SERVER["PHP_SELF"];
}
if($_COOKIE["clearsettings"])
{
setcookie("domail", "", time() - 3600);
setcookie("email", "", time() - 3600);
setcookie("saveto", "", time() - 3600);
setcookie("path", "", time() - 3600);
setcookie("useproxy", "", time() - 3600);
setcookie("proxy", "", time() - 3600);
setcookie("split", "", time() - 3600);
setcookie("partSize", "", time() - 3600);
setcookie("savesettings", "", time() - 3600);
setcookie("clearsettings", "", time() - 3600);
}
if(!$_GET[FileName] || !$_GET[host] || !$_GET[path])
{
$LINK = trim($_GET["link"]);
if(!$LINK)
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//RU">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<style type="text/css">
<!--
body {font-family: Tahoma; font-size: 11px;}
tr {font-family: Tahoma; font-size: 11px; line-height: 14.5px;}
input {font-family: Tahoma; font-size: 11px;}
select {font-family: Tahoma; font-size: 11px;}
textarea {font-family: Tahoma; font-size: 11.5px;}
a:visited {color: #0000FF;}
.tab-on {
padding: 2px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: none;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #cccccc;
border-right-color: #cccccc;
border-bottom-color: #cccccc;
border-left-color: #cccccc;
color: #000000;
background-color: #ffffff;
width: 100px;
}
.tab-onr {
padding: 2px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #cccccc;
border-right-color: #cccccc;
border-bottom-color: #cccccc;
border-left-color: #cccccc;
color: #000000;
background-color: #ffffff;
width: 100px;
}
.tab-off
{
padding: 2px;
background-color: #f6f6f6;
color: #666666;
border-top: 1px solid #cccccc;
border-right: 1px none #cccccc;
border-bottom: 1px solid #cccccc;
border-left: 1px solid #cccccc;
width: 100px;
}
.tab-offr
{
padding: 2px;
background-color: #f6f6f6;
color: #666666;
border-top: 1px solid #cccccc;
border-right: 1px solid #cccccc;
border-bottom: 1px solid #cccccc;
border-left: 1px solid #cccccc;
width: 100px;
}
.tab-none
{
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: none;
border-right-style: none;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #cccccc;
border-right-color: #cccccc;
border-bottom-color: #cccccc;
border-left-color: #cccccc;
}
.show-table {display: block;}
.hide-table {display: none;}
</style>
<script>
function switchCell(m) {
var style
document.getElementById("navcell1").className = "tab-off";
document.getElementById("navcell2").className = "tab-off";
document.getElementById("navcell3").className = "tab-offr";
document.getElementById("tb1").className = "hide-table";
document.getElementById("tb2").className = "hide-table";
document.getElementById("tb3").className = "hide-table";
if(m == 3) {style = "tab-onr"} else {style = "tab-on"}
document.getElementById("navcell" + m).className = style;
document.getElementById("tb" + m).className = "tab-content show-table";
}
</script>
<title> <? $str = 'UmFwaWRnZXQgNS4xIFBybyBSZXZPbHVUaW9u';echo base64_decode($str);?></title>
</head>
<body>
<script language="JavaScript">
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}
function deleteCookie(name, path, domain) {
if (getCookie(name)) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}
</script>
<table align="center">
<tbody>
<tr>
<td>
<table id="tb_content">
<tbody>
<tr>
<td align="center">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td onClick="switchCell(1)" class="tab-on" id="navcell1" align="center">
<a href="javascript:switchCell(1)">Main</a>
</td>
<td onClick="switchCell(2)" class="tab-off" id="navcell2" align="center">
<a href="javascript:switchCell(2)">Options</a>
</td>
<td onClick="switchCell(3)" class="tab-off" id="navcell3" align="center">
<a href="javascript:switchCell(3)">Files</a>
</td>
</tr>
</tbody>
</table>
<table class="tab-content" id="tb1" name="tb" cellspacing="5" width="100%">
<tbody>
<tr>
<td align="center">
<form method=get>
Link to Download: <input name="link" size=75>
<input type=submit value="Download File">
</td>
</tr>
<tr>
<td align="center">
<input type="checkbox" name="add_comment" onClick="javascript:var displ=this.checked?'':'none';document.getElementById('comment').style.display=displ;"> Add Comments
</td>
</tr>
<tr id="comment" style="DISPLAY: none;">
<td align="center">
<textarea name="comment" rows=4 cols=60></textarea>
</td>
</tr>
</tbody>
</table>
<table class="hide-table" id="tb2" name="tb" cellspacing="5" width="100%">
<tbody>
<tr>
<td align="center">
<table align="center">
<tr>
<td>
<input type="checkbox" name=domail id=domail onClick="javascript:document.getElementById('emailtd').style.display=document.getElementById('splittd').style.display=this.checked?'':'none';document.getElementById('methodtd').style.display=(document.getElementById('splitchkbox').checked&this.checked)?'':'none';"<? echo $_COOKIE["domail"] ? " checked" : ""; ?>> Send File to Email
</td>
<td>
</td>
<td id=emailtd<? echo $_COOKIE["domail"] ? "" : " style=\"display: none;\""; ?>>
Email: <input name=email<? echo $_COOKIE["email"] ? " value=\"".$_COOKIE["email"]."\"" : ""; ?>>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr id=splittd<? echo $_COOKIE["split"] ? "" : " style=\"display: none;\""; ?>>
<td>
<input id=splitchkbox type="checkbox" name=split onClick="javascript:var displ=this.checked?'':'none';document.getElementById('methodtd').style.display=displ;"<? echo $_COOKIE["split"] ? " checked" : ""; ?>> Split Files
</td>
<td>
</td>
<td id=methodtd<? echo $_COOKIE["split"] ? "" : " style=\"display: none;\""; ?>>
<table>
<tr>
<td>
Method: <select name=method><option value=tc<? echo $_COOKIE["method"] == "tc" ? " selected" : ""; ?>>Total Commander</option><option value=rfc<? echo $_COOKIE["method"] == "rfc" ? " selected" : ""; ?>>RFC 2046</option></select>
</td>
</tr>
<tr>
<td>
Parts Size: <input name=partSize size=1 value=<? echo $_COOKIE["partSize"] ? $_COOKIE["partSize"] : 10; ?>> MB
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<input type="checkbox" id=useproxy name=useproxy onClick="javascript:var displ=this.checked?'':'none';document.getElementById('proxy').style.display=displ;"<? echo $_COOKIE["useproxy"] ? " checked" : ""; ?>> Use Proxy Settings
</td>
<td>
</td>
<td id=proxy<? echo $_COOKIE["useproxy"] ? "" : " style=\"display: none;\""; ?>>
Proxy: <input name=proxy size=19<? echo $_COOKIE["proxy"] ? " value=\"".$_COOKIE["proxy"]."\"" : ""; ?>>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<input type="checkbox" name=saveto id=saveto onClick="javascript:var displ=this.checked?'':'none';document.getElementById('path').style.display=displ;"<? echo $_COOKIE["saveto"] ? " checked" : ""; ?>> Save To
</td>
<td>
</td>
<td id=path<? echo $_COOKIE["saveto"] ? "" : " style=\"display: none;\""; ?>>
Path: <input name=path size=30 value="<? echo ($_COOKIE["path"] ? $_COOKIE["path"] : (strstr(realpath("./"), ":") ? addslashes(dirname(__FILE__)) : dirname(__FILE__))); ?>">
</td>
</tr>
<tr>
<td>
<input type="checkbox" name=savesettings id=savesettings<? echo $_COOKIE["savesettings"] ? " checked" : ""; ?> onClick="javascript:var displ=this.checked?'':'none';document.getElementById('clearsettings').style.display=displ;"> Save Settings
</td>
<td>
</td>
<td id=clearsettings<? echo $_COOKIE["savesettings"] ? "" : " style=\"display: none;\""; ?>>
<script>
function clearSettings() {
clear("domail"); clear("email"); clear("split"); clear("method");
clear("partSize"); clear("useproxy"); clear("proxy"); clear("saveto");
clear("path"); clear("savesettings");
document.getElementById('domail').checked =
document.getElementById('splitchkbox').checked =
document.getElementById('useproxy').checked =
document.getElementById('saveto').checked =
document.getElementById('savesettings').checked = "";
document.getElementById('emailtd').style.display =
document.getElementById('splittd').style.display =
document.getElementById('methodtd').style.display =
document.getElementById('proxy').style.display =
document.getElementById('path').style.display =
document.getElementById('clearsettings').style.display = "none";
document.cookie = "clearsettings = 1;";
}
function clear(name) {
document.cookie = name + " = " + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
</script>
<a href="javascript:clearSettings();">Clear Current Settings</a>
</td>
</tr>
</table>
</form>
</td>
</tr>
</tbody>
</table>
<table class="hide-table" id="tb3" name="tb" cellspacing="5" width="100%">
<tbody><? echo $_GET["act"] ? "<script>switchCell(3);</script>" : "<script>switchCell(1);</script>"; ?>
<td align="center">
<?
if($_COOKIE["showAll"] == 1)
{
$dir = dir("./");
while(false !== ($file = $dir->read()))
{
if($file != "." & $file != ".." & $file != "files.lst" & $file != basename($PHP_SELF) & is_file("./".$file))
{
$file = "./".$file;
$time = filectime($file);
while(isset($list[$time]))
{
$time++;
}
$list[$time] = array(
"name" => realpath($file),
"size" => bytesToKbOrMb(filesize($file)),
"date" => $time,
);
}
}
$dir->close();
}
else
{
if(@file_exists("files.lst"))
{
$list = file("files.lst");
foreach($list as $key => $record)
{
foreach(unserialize($record) as $field => $value)
{
$listReformat[$key][$field] = $value;
if($field == "date")
{
$date = $value;
}
}
$list[$date] = $listReformat[$key];
unset($list[$key], $listReformat[$key]);
}
}
}
switch($_GET["act"])
{
case "delete":
if(count($_GET["files"]) < 1)
{
echo "Please select atleast one file<br><br>";
}
else
{
?>
<form method="post">
<input type=hidden name=act value="delete_go">
File<? echo count($_GET["files"]) > 1 ? "y" : ""; ?>:
<?
for($i = 0; $i < count($_GET["files"]); $i++)
{
$file = $list[$_GET["files"][$i]];
?>
<input type=hidden name="files[]" value="<? echo $_GET["files"][$i]; ?>">
<b><? echo basename($file["name"]); ?></b><? echo $i == count($_GET["files"]) - 1 ? "." : ", "; ?>
<?
}
?><br>Move<? echo count($_GET["files"]) > 1 ? " These Files" : " This File"; ?>?<br>
<table>
<tr>
<td>
<input type=submit name="yes" style="width:33px; height:23px" value="Yes">
</td>
<td>
</td>
<td>
<input type=submit name="no" style="width:33px; height:23px" value="No">
</td>
</tr>
</table>
</form>
<?
}
break;
case "delete_go":
if($_GET["yes"])
{
for($i = 0; $i < count($_GET["files"]); $i++)
{
$file = $list[$_GET["files"][$i]];
if(file_exists($file["name"]))
{
if(@unlink($file["name"]))
{
echo "File <b>".$file["name"]."</b> File Deleted<br><br>";
unset($list[$_GET["files"][$i]]);
}
else
{
echo "Error deleting the file <b>".$file["name"]."</b>!<br><br>";
}
}
else
{
echo "File <b>".$file["name"]."</b> File Not Found!<br><br>";
}
}
if(!updateListInFile($list))
{
echo "Error in updating the list!<br><br>";
}
}
else
{
?>
<script>
location.href="<? echo substr($PHP_SELF, 0, strlen($PHP_SELF) - strlen(strstr($PHP_SELF, "?")))."?act=files"; ?>";
</script>
<?
}
break;
case "mail":
if(count($_GET["files"]) < 1)
{
echo "Select atleast one file.<br><br>";
}
else
{
?>
<form method="post">
<input type=hidden name=act value="mail_go">
File<? echo count($_GET["files"]) > 1 ? "y" : ""; ?>:
<?
for($i = 0; $i < count($_GET["files"]); $i++)
{
$file = $list[($_GET["files"][$i])];
?>
<input type=hidden name="files[]" value="<? echo $_GET["files"][$i]; ?>">
<b><? echo basename($file["name"]); ?></b><? echo $i == count($_GET["files"]) - 1 ? "." : ", "; ?>
<?
}
?><br><br>
<table align="center">
<tr>
<td>
Email: <input name=email<? echo $_COOKIE["email"] ? " value=\"".$_COOKIE["email"]."\"" : ""; ?>>
</td>
<td>
<input type=submit value="Send">
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<table>
<tr>
<td>
<input id=splitchkbox type="checkbox" name=split onClick="javascript:var displ=this.checked?'':'none';document.getElementById('methodtd2').style.display=displ;"<? echo $_COOKIE["split"] ? " checked" : ""; ?>> Split by Parts
</td>
<td>
</td>
<td id=methodtd2<? echo $_COOKIE["split"] ? "" : " style=\"display: none;\""; ?>>
<table>
<tr>
<td>
Method: <select name=method><option value=tc<? echo $_COOKIE["method"] == "tc" ? " selected" : ""; ?>>Total Commander</option><option value=rfc<? echo $_COOKIE["method"] == "rfc" ? " selected" : ""; ?>>RFC 2046</option></select>
</td>
</tr>
<tr>
<td>
Parts Size: <input name=partSize size=1 value=<? echo $_COOKIE["partSize"] ? $_COOKIE["partSize"] : 10; ?>> MB
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<?
}
break;
case "mail_go":
if(!checkmail($_GET["email"]))
{
echo "Invalid E-mail Address.<br><br>";
}
else
{
?>
<script>
function mail(str, field) {
document.getElementById("mailPart." + field).innerHTML = str;
return true;
}
</script>
<?
$_GET["partSize"] = ((isset($_GET["partSize"]) & $_GET["split"] == "on") ? $_GET["partSize"] * 1024 * 1024 : FALSE);
for($i = 0; $i < count($_GET["files"]); $i++)
{
$file = $list[$_GET["files"][$i]];
if(file_exists($file["name"]))
{
if(xmail("[email protected]", $_GET[email], "File ".basename($file["name"]), "File: ".basename($file["name"])."\r\n"."Link: ".$file["link"].($file["comment"] ? "\r\Comments: ".str_replace("\\r\\n", "\r\n", $file["comment"]) : ""), $file["name"], $_GET["partSize"], $_GET["method"]))
{
echo "<script>mail('File <b>".basename($file["name"])."</b> it is sent for the address <b>".$_GET["email"]."</b>!', '".basename($file["name"])."');</script>\r\n<br>";
}
else
{
echo "Error sending file!<br>";
}
}
else
{
echo "File <b>".$file["name"]."</b> Not Found!<br><br>";
}
}
}
break;
case "split":
if(count($_GET["files"]) < 1)
{
echo "Select atleast one file.<br><br>";
}
else
{
?>
<form method="post">
<input type=hidden name=act value="split_go">
<table align="center">
<tr>
<td>
<table>
<?
for($i = 0; $i < count($_GET["files"]); $i++)
{
$file = $list[$_GET["files"][$i]];
?>
<input type=hidden name="files[]" value="<? echo $_GET["files"][$i]; ?>">
<tr>
<td align="center"><b><? echo basename($file["name"]); ?></b></td>
</tr>
<tr>
<td>
Parts Size: <input name="partSize[]" size=1 value=<? echo $_COOKIE["partSize"] ? $_COOKIE["partSize"] : 10; ?>> MB
</td>
</tr>
<tr>
<td>
Save To: <input name="saveTo[]" size=40 value="<? echo addslashes(dirname($file["name"])); ?>">
</td>
</tr>
<tr>
<td>
</td>
</tr>
<?
}
?>
</table>
</td>
<td>
<input type=submit value="Split">
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</form>
<?
}
break;
case "split_go":
for($i = 0; $i < count($_GET["files"]); $i++)
{
$file = $list[$_GET["files"][$i]];
$partSize = urldecode($_GET["partSize"][$i]) * 1024 * 1024;
$saveTo = urldecode($_GET["saveTo"][$i]);
$partSize = round($partSize);
$fileContents = read_file($file["name"]);
$fileSize = strlen($fileContents);
$crc = strtoupper(dechex(crc32($fileContents)));
$crc = str_repeat("0", 8 - strlen($crc)).$crc;
if(file_exists($file["name"]))
{
echo "Started to split file <b>".basename($file["name"])."</b> of parts ".bytesToKbOrMb($partSize).", Using Method - Total Commander...<br>";
$totalParts = ceil($fileSize / $partSize);
echo "Total Parts: <b>".$totalParts."</b><br><br>";
$fileTmp = $fileNamePerman = basename($file["name"]);
while(strpos($fileTmp, "."))
{
$fileName .= substr($fileTmp, 0, strpos($fileTmp, ".") + 1);
$fileTmp = substr($fileTmp, strpos($fileTmp, ".") + 1);
}
$fileName = substr($fileName, 0, -1);
$path = stripslashes($saveTo.(strstr(realpath("./"), ":") ? "\\\\" : "/"));
for($j = 0; $j < $totalParts; $j++)
{
if($j == 0)
{
$fileChunk = substr($fileContents, 0, $partSize);
if(!@write_file($path.$fileName.".crc", "filename=".basename($file["name"])."\r\n"."size=".$fileSize."\r\n"."crc32=".$crc."\r\n"))
{
echo "It is not possible to split the file. CRC Error<b>".$fileName.".crc"."</b> !<br><br>";
}
else
{
$time = explode(" ", microtime());
$time = str_replace("0.", $time[1], $time[0]);
$list[$time] = array("name" => $path.$fileName.".crc",
"size" => bytesToKbOrMb(strlen(read_file($path.$fileName.".crc"))),
"date" => $time,
"comment" => "Title Part Files ".$fileNamePerman);
}
if(!@write_file($path.$fileName.".001", $fileChunk))
{
echo "It was not possible to split the file <b>".$fileName.".001"."</b> !<br><br>";
}
else
{
$time = explode(" ", microtime());
$time = str_replace("0.", $time[1], $time[0]);
$list[$time] = array("name" => $path.$fileName.".001",
"size" => bytesToKbOrMb(strlen($fileChunk)),
"date" => $time,
"comment" => ($j + 1)."by the parts (from ".$totalParts.") files ".$fileNamePerman);
}
}
elseif($j == $totalParts - 1)
{
$fileChunk = substr($fileContents, $j * $partSize);
$num = strlen($j + 1) == 2 ? "0".($j + 1) : (strlen($j + 1) == 1 ? "00".($j + 1) : ($j + 1));
if(!@write_file($path.$fileName.".".$num, $fileChunk))
{
echo "It was not possible to split the file <b>".$fileName.".".$num."</b> !<br><br>";
}
else
{
$time = explode(" ", microtime());
$time = str_replace("0.", $time[1], $time[0]);
$list[$time] = array("name" => $path.$fileName.".".$num,
"size" => bytesToKbOrMb(strlen($fileChunk)),
"date" => $time,
"comment" => ($j + 1)."by the parts (from ".$totalParts.") files ".$fileNamePerman);
}
}
else
{
$fileChunk = substr($fileContents, $j * $partSize, $partSize);
$num = strlen($j + 1) == 2 ? "0".($j + 1) : (strlen($j + 1) == 1 ? "00".($j + 1) : ($j + 1));
if(!@write_file($path.$fileName.".".$num, $fileChunk))
{
echo "It was not possible to split the file <b>".$fileName.".".$num."</b> !<br><br>";
}
else
{
$time = explode(" ", microtime());
$time = str_replace("0.", $time[1], $time[0]);
$list[$time] = array("name" => $path.$fileName.".".$num,
"size" => bytesToKbOrMb(strlen($fileChunk)),
"date" => $time,
"comment" => ($j + 1)."by the parts (from ".$totalParts.") files ".$fileNamePerman);
}
}
}
unset($fileName);
if(!updateListInFile($list))
{
echo "Couldn't update. File Already Exists<br><br>";
}
} //if(file_exists($file["name"]))
}
break;
case "rename":
if(count($_GET["files"]) < 1)
{
echo "Select atleast one file.<br><br>";
}
else
{
?>
<form method="post">
<input type=hidden name=act value="rename_go">
<table align="center">
<tr>
<td>
<table>
<?
for($i = 0; $i < count($_GET["files"]); $i++)
{
$file = $list[$_GET["files"][$i]];
?>
<input type=hidden name="files[]" value="<? echo $_GET["files"][$i]; ?>">
<tr>
<td align="center"><b><? echo basename($file["name"]); ?></b></td>
</tr>
<tr>
<td>
New Name: <input name="newName[]" size=25 value="<? echo basename($file["name"]); ?>">
</td>
</tr>
<tr>
<td>
</td>
</tr>
<?
}
?>
</table>
</td>
<td>
<input type=submit value="Rename">
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</form>
<?
}
break;
case "rename_go":
$smthExists = FALSE;
for($i = 0; $i < count($_GET["files"]); $i++)
{
$file = $list[$_GET["files"][$i]];
if(file_exists($file["name"]))
{
$smthExists = TRUE;
$newName = dirname($file["name"]).PATH_SPLITTER.$_GET["newName"][$i];
if(@rename($file["name"], $newName))
{
echo "File <b>".$file["name"]."</b> Renamed to<b>".basename($newName)."</b><br><br>";
$list[$_GET["files"][$i]]["name"] = $newName;
}
else
{
echo "Couldn't rename the file <b>".$file["name"]."</b>!<br><br>";
}
}
else
{
echo "File <b>".$file["name"]."</b> Not Found!<br><br>";
}
}
if($smthExists)
{
if(!updateListInFile($list))
{
echo "Couldn't Update<br><br>";
}
}
break;
case "ftp":
if(count($_GET["files"]) < 1)
{
echo "Select atleast one file.<br><br>";
}
else
{
?>
<form method="post">
<input type=hidden name=act value="ftp_go">
File<? echo count($_GET["files"]) > 1 ? "y" : ""; ?>:
<?
for($i = 0; $i < count($_GET["files"]); $i++)
{
$file = $list[($_GET["files"][$i])];
?>
<input type=hidden name="files[]" value="<? echo $_GET["files"][$i]; ?>">
<b><? echo basename($file["name"]); ?></b><? echo $i == count($_GET["files"]) - 1 ? "." : ", "; ?>
<?
}
?><br><br>
<table align="center">
<tr>
<td>
<table>
<tr>
<td>
Host:
</td>
<td>
<input name=host id="host"<? echo $_COOKIE["host"] ? " value=\"".$_COOKIE["host"]."\"" : ""; ?>>
</td>
</tr>
<tr>
<td>
Port:
</td>
<td>
<input name=port id="port"<? echo $_COOKIE["port"] ? " value=\"".$_COOKIE["port"]."\"" : " value=\"21\""; ?> size="1">
</td>
</tr>
<tr>
<td>
Login:
</td>
<td>
<input name=login id="login"<? echo $_COOKIE["login"] ? " value=\"".$_COOKIE["login"]."\"" : ""; ?> size="12">
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<input name=password id="password"<? echo $_COOKIE["password"] ? " value=\"".$_COOKIE["password"]."\"" : ""; ?> size="12">
</td>
</tr>
<tr>
<td>
Directory:
</td>
<td>
<input name=dir id="dir"<? echo $_COOKIE["dir"] ? " value=\"".$_COOKIE["dir"]."\"" : " value=\"/\""; ?> size="23">
</td>
</tr>
</table>
</td>
<td>
</td>
<td>
<table>
<tr align="center">
<td>
<input type=submit value="Upload">
</td>
</tr>
<tr align="center">
<td>
Options
</td>
</tr>
<tr align="center">
<td>
<script language="JavaScript">
function setFtpParams() {
setParam("host"); setParam("port"); setParam("login");
setParam("password"); setParam("dir");
document.cookie = "ftpParams=1";
document.getElementById("hrefSetFtpParams").style.color = "#808080";
document.getElementById("hrefDelFtpParams").style.color = "#0000FF";
}
function delFtpParams() {
deleteCookie("host"); deleteCookie("port"); deleteCookie("login");
deleteCookie("password"); deleteCookie("dir"); deleteCookie("ftpParams");
document.getElementById("hrefSetFtpParams").style.color = "#0000FF";
document.getElementById("hrefDelFtpParams").style.color = "#808080";
}
function setParam(param) {
document.cookie = param + "=" + document.getElementById(param).value;
}
document.write(
'<a href="javascript:setFtpParams();" id="hrefSetFtpParams" style="color: ' + (getCookie('ftpParams') == 1 ? '#808080' : '#0000FF') + ';">Copy Files</a> | ' +
'<a href="javascript:delFtpParams();" id="hrefDelFtpParams" style="color: ' + (getCookie('ftpParams') == 1 ? '#0000FF' : '#808080') + '";">Move Files</a>'
);
</script>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<?
}
break;
case "ftp_go":
$ftp = new ftp();
if(!$ftp->SetServer($_POST["host"], (int)$_POST["port"]))
{
$ftp->quit();
echo "Couldn't connect to the server".$_POST["host"].":".$_POST["port"].".<br>".
"<a href=\"javascript:history.back(-1);\">Go Back</a><br><br>";
}
else
{
echo " Connecting..<b>".$_POST["host"]."</b>...";
if(!$ftp->connect())
{
$ftp->quit();
echo "<br>Couldn't connect to the server ".$_POST["host"].":".$_POST["port"].".<br>".
"<a href=\"javascript:history.back(-1);\">Go Back</a><br><br>";
}
else
{
if (!$ftp->login($_POST["login"], $_POST["password"]))
{
$ftp->quit();
echo "<br>Wrong Password <b>".$_POST["login"].":".$_POST["password"]."</b>.<br>".
"<a href=\"javascript:history.back(-1);\">Go Back</a><br><br>";
}
else
{
if(!$ftp->chdir($_POST["dir"]))
{
$ftp->quit();
echo "<br>Cannot locate the folder<b>".$_POST["dir"]."</b>.<br>".
"<a href=\"javascript:history.back(-1);\">Go Back</a><br><br>";
}
else
{
?>
<br>
<div id="status"></div><br>
<table cellspacing=0 cellpadding=0 style="FONT-FAMILY: Tahoma; FONT-SIZE: 11px;">
<tr>
<td></td>
<td>
<div style='border:#BBBBBB 1px solid; width:300px; height:10px;'>
<div id=progress style='background-color:#000099; margin:1px; width:0%; height:8px;'>
</div>
</div>
</td>
<td></td>
<tr>
<tr>
<td align=left id=received>0 KB</td>
<td align=center id=percent>0%</td>
<td align=right id=speed>0 KB/s</td>
</tr>
</table>
<script>
function pr(percent, received, speed){
document.getElementById("received").innerHTML = '<b>' + received + '</b>';
document.getElementById("percent").innerHTML = '<b>' + percent + '%</b>';
if(percent > 90){percent = percent - 1;}
document.getElementById("progress").style.width = percent + '%';
document.getElementById("speed").innerHTML = '<b>' + speed + ' KB/s</b>';
return true;
}
function changeStatus(file, size) {
document.getElementById("status").innerHTML = 'Loading File <b>' + file + '</b>,Size<b>' + size + '</b>...<br>';
}
</script>
<br>
<?
$FtpUpload = TRUE;
for($i = 0; $i < count($_GET["files"]); $i++)
{
$file = $list[$_GET["files"][$i]];
echo "<script>changeStatus('".basename($file["name"])."', '".$file["size"]."');</script>";
$FtpBytesTotal = filesize($file["name"]);
$FtpChunkSize = round($FtpBytesTotal / 333);
$FtpTimeStart = getmicrotime();
if($ftp->put($file["name"], basename($file["name"])))
{
$time = round(getmicrotime() - $FtpTimeStart);
$speed = round($FtpBytesTotal / 1024 / $time, 2);
echo "<script>pr(100, '".bytesToKbOrMb($FtpBytesTotal)."', ".$speed.")</script>\r\n";
echo "File <a href=\"ftp://".$_POST["login"].":".$_POST["password"]."@".$_POST["host"].":".$_POST["port"].
$_POST["dir"]."/".basename($file["name"])."\"><b>".basename($file["name"])."</b></a>Successfully uploaded!".
"<br>Time: <b>".sec2time($time)."</b><br>Average speed: <b>".$speed." KB/s</b><br><br>";
}
else
{
echo "Couldn't upload the file <b>".basename($file["name"])."</b>!<br>";
}
}
$ftp->quit();
}
}
}
}
break;
}
if($list)
{
?>
<script>
function setCheckboxes(act)
{
elts = document.forms["flist"].elements["files[]"];
var elts_cnt = (typeof(elts.length) != 'undefined') ? elts.length : 0;
if (elts_cnt)
{
for (var i = 0; i < elts_cnt; i++)
{
elts[i].checked = (act == 1 || act == 0) ? act : elts[i].checked ? 0 : 1;
}
}
}
function showAll() {
<?
$Path = parse_url($PHP_SELF);
$Path = substr($Path["path"], 0, strlen($Path["path"]) - strlen(strrchr($Path["path"], "?")));
?>
if(getCookie("showAll") == 1)
{
deleteCookie("showAll");
location.href = "<? echo $Path."?act=files"; ?>";
}
else
{
document.cookie = "showAll = 1;";
location.href = "<? echo $Path."?act=files"; ?>";
}
}
<? unset($Path); ?>
</script>
<form name="flist" method="post">
<a href="javascript:setCheckboxes(1);" style="color: #0000FF;">Check All</a> |
<a href="javascript:setCheckboxes(0);" style="color: #0000FF;">Un-Check All</a> |
<a href="javascript:setCheckboxes(2);" style="color: #0000FF;">Invert Selection</a> |
<a href="javascript:showAll();" style="color: #0000FF;">Show
<script language="JavaScript">
if(getCookie("showAll") == 1)
{
document.write("None");
}
else
{
document.write("Everything");
}
</script></a><br><br>
<table cellpadding="3" cellspacing="1">
<tbody>
<tr bgcolor="#E1E1E1" valign="bottom" align="center">
<td>
<select name="act" onChange="javascript:void(document.flist.submit());">
<option>Action</option>
<option value="mail">E-Mail</option>
<option value="split">Split Files</option>
<option value="ftp">FTP File</option>
<option value="rename">Rename</option>
<option value="delete">Delete</option>
</select>
</td>
<td>Name</td>
<td>Size</td>
<td>Download Link</td>
<td>Comments</td>
<td>Date</td>
</tr>
<?
}
else
{
echo "No Files Found";
}
if($list)
{
foreach($list as $key => $file)
{
if(file_exists($file["name"]))
{
$inCurrDir = strstr(dirname($file["name"]), realpath("./")) ? TRUE : FALSE;
if($inCurrDir)
{
$Path = parse_url($PHP_SELF);
$Path = substr($Path["path"], 0, strlen($Path["path"]) - strlen(strrchr($Path["path"], "/")));
}
?>
<tr onMouseOver="this.bgColor='#C8D0E6';" onMouseOut="this.bgColor='#F2F2F2';" align="center" bgcolor="#f2f2f2" title="<? echo $file["name"]; ?>">
<td><input type=checkbox name="files[]" value="<? echo $file["date"]; ?>"></td>
<td><? echo $inCurrDir ? "<a href=\"".$Path.substr(dirname($file["name"]), strlen(realpath("./")) + 1)."/".basename($file["name"]) : ""; echo $inCurrDir ? "\">".basename($file["name"])."</a>" : basename($file["name"]); ?></td>
<td><? echo $file["size"]; ?></td>
<td><? echo $file["link"] ? "<a href=\"".$file["link"]."\" style=\"color: #0000FF;\">".$file["link"]."</a>" : "" ; ?></td>
<td><? echo $file["comment"] ? str_replace("\\r\\n", "<br>", $file["comment"]) : ""; ?></td>
<td><? echo date("d.m.Y H:i:s", $file[date]) ?></td>
</tr>
<?
}
}
}
if($list)
{
?>
</tbody>
</table>
<form>
<?
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<table width="60%" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<? echo str_repeat("*", 100); ?>
</td>
</tr>
<tr>
<td>
<div align="center"></div>
<script>
var show = 0;
function showAdd(){
document.getElementById('add').style.display = show ? 'none' : '';
show = show ? 0 : 1;
}
var show2 = 0;
function showAdd2(){
document.getElementById('add2').style.display = show2 ? 'none' : '';
show2 = show2 ? 0 : 1;
}
</script>
<div align="center">
</div>
<div align="center"> <? $str = 'UmFwaWRnZXQgNS4xIFBybyBSZXZPbHVUaW9uIGJ5IFByYW1vZCAmIENoZWNrbWF0ZSAtIEJhc2VkIG9uIDAuNDUgVnlydXMgU291cmNlPGJyPg0KQnVncyBSZXBvcnQgdG8gUmFwaWRnZXQuYnVnW2F0XWdtYWlsLmNvbTxicj4NClJseiBvbiA2dGggRmViLiAyMDA2IEAgaHR0cDovL3Jsei5ncmluZGVyei53cw==';echo base64_decode($str);?></div>
</td>
</tr>
<tr>
<td>
<? echo str_repeat("*", 100); ?>
</td>
</tr>
</table>
</body>
</html>
<?
die;
}
if($_GET["savesettings"] == "on")
{
setcookie("savesettings", TRUE);
if($_GET["domail"] == "on")
{
setcookie("domail", TRUE);
if(checkmail($_GET["email"]))
{
setcookie("email", $_GET["email"]);
}
else
{
setcookie("email", "", time() - 3600);
}
if($_GET["split"] == "on")
{
setcookie("split", TRUE);
if(is_numeric($_GET["partSize"]))
{
setcookie("partSize", $_GET["partSize"]);
}
else
{
setcookie("partSize", "", time() - 3600);
}
if(in_array($_GET["method"], array("tc", "rfc")))
{
setcookie("method", $_GET["method"]);
}
else
{
setcookie("method", "", time() - 3600);
}
}
else
{
setcookie("split", "", time() - 3600);
}
}
else
{
setcookie("domail", "", time() - 3600);
}
if($_GET["saveto"] == "on")
{
setcookie("saveto", TRUE);
if(isset($_GET["path"]))
{
setcookie("path", $_GET["path"]);
}
else
{
setcookie("path", "", time() - 3600);
}
}
else
{
setcookie("saveto", "", time() - 3600);
}
if($_GET["useproxy"] == "on")
{
setcookie("useproxy", TRUE);
if(strlen(strstr($_GET["proxy"], ":")) > 0)
{
setcookie("proxy", $_GET["proxy"]);
}
else
{
setcookie("proxy", "", time() - 3600);
}
}
else
{
setcookie("useproxy", "", time() - 3600);
}
}
if(isset($_GET[saveto]) & !$_GET[path])
{
html_error("Не указан путь для сохранения Fileа");
}
if(isset($_GET[useproxy]) & (!$_GET[proxy] || !strstr($_GET[proxy], ":")))
{
html_error("Не указан адрес прокси сервера");
}
if(isset($_GET[domail]) & !checkmail($_GET[email]))
{
html_error("Не указан или неправильный E-mail");
}
elseif($_GET[domail] & $_GET[split] & !is_numeric($_GET[partSize]))
{
html_error("Неверно указан размер части");
}
$Referer = $LINK;
$Url = parse_url($LINK);
/* if($Url[scheme] == "ftp")
{
$Url = parse_url($_SERVER[HTTP_REFERER]."?act=ftp_get&host=".$Url[host]."&port=".$Url[port]."&user=".$Url[user]."&pass=".$Url[pass]."&path=".str_replace("&", "%26", $Url[path]));
}
*/
if(!in_array($Url[host], array("rapidshare.de", "www.megaupload.com", "www.upload2.net", "sr1.mytempdir.com", "www.mytempdir.com",
"getfile.biz", "webfile.ru", "slil.ru", "zalil.ru")))
{
$directLink = TRUE;
}
else
{
$page = geturl($Url["host"], $Url["port"] ? $Url["port"] : 80, $Url["path"]."?".$Url["query"], 0, 0, 0, 0, isset($_GET["useproxy"]) ? $_GET["proxy"] : "");
}
if(!$page & !$directLink)
{
html_error("Error obtaining the link".$LINK."<br>".$lastError);
}
else
{
if(!$directLink)
{
switch($Url[host]) {
case "rapidshare.de":
$post["uri"] = $Url[path];
//$post[hint] = cut_str($page, "name=\"hint\" value=\"", "\">");
//$post[letsgo] = "Free";
$post["dl.start"] = "Free";
$url = "/";
$countDownLeft = "var c = ";
$countDownRight = ";";
break;
case "www.megaupload.com":
$noSecondPage = TRUE;
$countDownLeft = "asdf=";
$countDownRight = ";";
break;
case "www.upload2.net":
$noSecondPage = TRUE;
$countDownLeft = "wt=";
$countDownRight = ";func";
break;
case "sr1.mytempdir.com":
case "www.mytempdir.com":
$noSecondPage = TRUE;
$countDownLeft = "loading()', ";
$countDownRight = "000);";
break;
case "getfile.biz":
case "webfile.ru":
case "slil.ru":
case "zalil.ru":
$noSecondPage = TRUE;
$noCountDown = TRUE;
break;
default:
$directLink = TRUE;
$noSecondPage = TRUE;
unset($post);
break;
}
if(!$noSecondPage)
{
$Referer = "http://".$Url[host].$url;
$page = geturl($Url["host"], $Url["port"] ? $Url["port"] : 80, $url, $LINK, 0, $post, 0, isset($_GET["useproxy"]) ? $_GET["proxy"] : "");
if(!$page)
{
html_error("Html error with the link in the second page");
}
}
if(strstr($page, "This file exceeds your download-limit.") || strstr($page, "KB in one hour"))
{
html_error("Currently your IP-Address is downloading some other file");
}
if(strstr($page, "is already downloading a file"))
{
html_error("Currently your IP-Address is downloading some other file.");
}
if(strstr($page, "Too many users downloading right now.") || strstr($page, "Too many connections"))
{
html_error("Service indicates that too many users are connected<br><span id=\"repeat\"></span>
<script>
var c = 10;
fc();
function fc() {
if(c > 0)
{
document.getElementById(\"repeat\").innerHTML = \"Повтор через \" + c + ' сек.';
c = c - 1;
setTimeout(\"fc()\", 1000)
}
else
{
location.reload();
}
}
</script>");
}
if(strstr($page, "is not allowed to use the free-service anymore today"))
{
html_error("No More Free Downloads from this IP today");
}
if(strstr($page, "html not found."))
{
html_error("File Not Found!");
}
/*if($Url["host"] == "rapidshare.de")
{
$Uuid = cut_str($page, "uuid=", ";");
if(!is_numeric($Uuid) || !$Uuid)
{
html_error("Ошибка при получении номера сессии.".pre($page));
}
}
*/
switch($Url["host"])
{
case "rapidshare.de":
$countDown = cut_str($page, $countDownLeft, $countDownRight);
?>
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1251">
<title>Please Wait...</title>
</head>
<body style="FONT-FAMILY: Tahoma; FONT-SIZE: 11px;">
<center><span id="dl"></span></center>
<script>
var c = <? echo $countDown; ?>;
fc();
function fc() {
if(c > 0)
{
document.getElementById("dl").innerHTML = "Please wait " + c + ' sec. Getting ticket... ';
c = c - 1;
setTimeout("fc()", 1000)
}
}
</script>
<?
sleep($countDown);
$Href = urldecode(cut_str($page, "unescape('", "')"));
$code = cut_str($Href, "</table><h3>No premium-", "</h3>");
$FileAddr = cut_str($Href, "<form name=\"dl\" action=\"", "\"");
if (!$FileAddr)
{
echo '<br>Something Wrong in this code... </br>';
echo $Href;
}
if(!$Href)
{
html_error("Error with the link".pre($page));
}
Echo "<form action=\"redir.php?saveto="; ?><? echo $_REQUEST[saveto] ?>&path=<? echo $_GET[path]; ?>&comment=<? echo $_GET[comment]; ?>&domail=<? echo $_GET[domail]; ?>&email=<? echo $_GET[email]; ?>&useproxy=<? echo $_GET[useproxy]; ?>&proxy=<? echo $_GET[proxy]; ?>&split=<? echo $_GET[split]; ?>&method=<? $_GET[method]; ?>&partSize=<? echo $_GET[partSize]; ?>&redirto=<? echo $PHP_SELF; ?>&link=<? echo $FileAddr . "\" method=\"post\">" ; ?><? echo $code; ?><? Echo '</form>' ?>
</body>
</html>
<?
exit;
break;
case "www.megaupload.com":
$post["d"] = cut_str($Url[query], "d=", "/n");
$Referer = "http://www.megaupload.com/dl.php".$post[d]."&l=en";
$page = geturl($Url["host"], $Url["port"] ? $Url["port"] : 80, "/", 0, 0, $post, 0, isset($_GET["useproxy"]) ? $_GET["proxy"] : "");
$Href = cut_str($page, "document.getElementById(\"downloadhtml\").innerHTML = '<a href=\"", "\" class=\"downloadlink");
break;
case "www.upload2.net":
$Href = cut_str($page, "document.getElementById(\"dl\").innerHTML='<a class=common href=\"", "\">Click here to");
break;
case "sr1.mytempdir.com":
case "www.mytempdir.com":
$Href = cut_str(urldecode(cut_str($page, "unescape('", "')")), "Download: <a href=\"", "\"");
break;
case "getfile.biz":
$Href = cut_str($page, "</b><br><br>\n<a href=\"", "\"");
break;
case "webfile.ru":
$Href = "http://webfile.ru".cut_str($page, "<p class=link><b>>>> <a href=\"", "\"");
$Tmp = parse_url($Href);
$Referer = $Href;
$Href = cut_str(geturl($Tmp["host"], 80, $Tmp["path"], $Href, 0, 0, 0,
isset($_GET["useproxy"]) ? $_GET["proxy"] : ""), "Location: ", "\r");
unset($Tmp);
break;
case "slil.ru":
case "zalil.ru":
$Href = "http://".$Url["host"].cut_str($page, ";URL=", "\"");
break;
}
$Url = parse_url($Href);
if(!$Href)
{
html_error("Error with the link".pre($page));
}
if($noCountDown)
{
$countDown = 0;
}
else
{
$countDown = cut_str($page, $countDownLeft, $countDownRight);
}
if(strstr($Url[host], "megaupload.com"))
{
$findvar = cut_str($page, "if(", " == 0");
$countDownLeft = $findvar . "=";
$countDown = cut_str($page, $countDownLeft, $countDownRight);
if(!$countDown)
{
$countDown = 50;
}
}
if(!$countDown & $countDown != 0)
{
html_error("Error in Wait Time".pre($page));
}
$tmp = explode("/", $Url[path]);
$FileName = array_pop($tmp);
}
else
{
$countDown = 0;
$tmp = explode("/", $LINK);
$FileName = array_pop($tmp);
if($Url["user"] & $Url["pass"])
{
$auth = "&auth=".base64_encode($Url["user"].":".$Url["pass"]);
}
else
{
$auth = "";
}
}
?>
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1251">
<title>Downloading File</title>
</head>
<body style="FONT-FAMILY: Tahoma; FONT-SIZE: 11px;">
<center><span id="dl"></span></center>
<script>
var c = <? echo $countDown; ?>;
fc();
function fc() {
if(c > 0)
{
document.getElementById("dl").innerHTML = "Please wait " + c + ' sec. Getting ticket...';
c = c - 1;
setTimeout("fc()", 1000)
}
else
{
location.href = '?FileName=<? echo urlencode($FileName); ?>&host=<? echo $Url[host]; ?>&path=<? echo urlencode($Url[path].($Url["query"] ? "?".$Url["query"] : "")); ?>&referer=<? echo urlencode($Referer); ?>&uuid=<? echo $Uuid; ?>&email=<? echo $_GET["domail"] ? $_GET["email"] : ""; ?>&partSize=<? echo $_GET[split] ? $_GET[partSize] : ""; ?>&method=<? echo $_GET[method]; ?>&proxy=<? echo $_GET["useproxy"] ? $_GET["proxy"] : ""; ?>&saveto=<? echo $_GET["path"]; ?>&link=<? echo urlencode($_GET["link"]); ?><? echo $_GET["add_comment"] == "on" ? "&comment=".urlencode($_GET["comment"]) : ""; ?><? echo $auth; ?>';
}
}
</script>
</body>
</html>
<?
}
}
else
{
?>
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1251">
<title>Downloaded</title>
</head>
<body style="FONT-FAMILY: Tahoma; FONT-SIZE: 11px;">
<center>
<?
set_time_limit(0);
$_GET["FileName"] = urldecode($_GET["FileName"]);
$_GET["path"] = urldecode($_GET["path"]);
$_GET["referer"] = urldecode($_GET["referer"]);
$_GET["link"] = urldecode($_GET["link"]);
//$_GET["path"] = str_replace("act=ftp_get", "act=ftpget", $_GET["path"]);
if($_GET["auth"])
{
$AUTH["use"] = TRUE;
$AUTH["str"] = $_GET["auth"];
}
else
{
unset($AUTH);
}
//$pathWithName = $_GET["saveto"].(strstr(realpath("./"), ":") ? "\\\\" : "/").$_GET["FileName"];
$ftp = parse_url($_GET["link"]);
$IS_FTP = $ftp["scheme"] == "ftp" ? TRUE : FALSE;
$AUTH["ftp"] = array(
"login" => $ftp["user"] ? $ftp["user"] : "anonymous",
"password" => $ftp["pass"] ? $ftp["pass"] : "anonymous"
);
$pathWithName = $_GET["saveto"].PATH_SPLITTER.$_GET["FileName"];
echo "Connected To : <b>".(strstr(strtolower($_GET[path]), strtolower(basename(__FILE__))) ? cut_str($_GET[path], "&host=", "&port") : $_GET[host])."</b>...<br>";
$file = geturl($_GET[host], $IS_FTP ? ($ftp["port"] ? $ftp["port"] : 21) : ($ftp["port"] ? $ftp["port"] : 80), $_GET[path], $_GET[referer], ($_GET[uuid] ? "uuid=".$_GET[uuid] : ""), 0, $pathWithName, $_GET["proxy"]);
if($lastError)
{
echo $lastError;
}
elseif($file[bytesReceived] == $file[bytesTotal])
{
$inCurrDir = strstr(dirname($pathWithName), realpath("./")) ? TRUE : FALSE;
if($inCurrDir)
{
$Path = parse_url($PHP_SELF);
$Path = substr($Path["path"], 0, strlen($Path["path"]) - strlen(strrchr($Path["path"], "/")));
}
echo "<script>pr(100, '".$file[size]."', '".$file[speed]."')</script>\r\n";
echo "File <b>".($inCurrDir ? "<a href=\"".$Path.substr(dirname($pathWithName), strlen(realpath("./")) + 1)."/".$_GET[FileName]."\">" : "").$_GET[FileName].($inCurrDir ? "</a>" : "")."</b> (<b>".$file[size]."</b>) Saved!<br>Time: <b>".$file[time]."</b><br>Average Speed: <b>".$file[speed]." KB/s</b><br>";
if(!write_file("files.lst", serialize(array("name" => $file["file"], "size" => $file["size"], "date" => time(), "link" => $_GET["link"], "comment" => str_replace("\n", "\\n", str_replace("\r", "\\r", $_GET["comment"]))))."\r\n", 0))
{
echo "Couldn't update the files list<br>";
}
if($_GET["email"])
{
$_GET[partSize] = (isset($_GET[partSize]) ? $_GET[partSize] * 1024 * 1024 : FALSE);
if(xmail("[email protected]", $_GET["email"], "File ".basename($_GET["FileName"]), "File: ".basename($_GET["FileName"])."\r\n"."Link: ".$_GET["link"].($_GET["comment"]? "\r\n"."Comments: ".str_replace("\\r\\n", "\r\n", $_GET["comment"]) : ""), $pathWithName, $_GET["partSize"], $_GET["method"]))
{
echo "<script>mail('File was sent to this address<b>".$_GET[email]."</b>!', '".basename($_GET["FileName"])."');</script>\r\n";
}
else
{
echo "Error Sending File!<br>";
}
}
$Path = parse_url($PHP_SELF);
$Path = substr($Path["path"], 0, strlen($Path["path"]) - strlen(strrchr($Path["path"], "?")));
echo "<br><a href=\"".$Path."\" style=\"color: #0000FF;\">Go Back to Main!</a>";
}
else
{
echo "Connection Lost :-(<br><a href=\"javascript:location.reload();\">Reload</a>";
}
?>
</center>
</body>
</html>
<?
}
function geturl($host, $port, $url, $referer = 0, $cookie = 0, $post = 0, $saveToFile = 0, $proxy = 0, $deploy = 0) {
global $nn, $lastError, $PHP_SELF, $AUTH, $IS_FTP, $FtpBytesTotal, $FtpBytesReceived, $FtpTimeStart, $FtpChunkSize;
if($IS_FTP)
{
$ftp = new ftp(FALSE, FALSE);
//$ftp->Verbose = true;
//$ftp->LocalEcho = true;
if(!$ftp->SetServer($host, (int)$port))
{
$ftp->quit();
$lastError = "Could not be established the server ".$host.":".$port.".<br>".
"<a href=\"javascript:history.back(-1);\">Go Back</a><br><br>";
return FALSE;
}
else
{
if(!$ftp->connect())
{
$ftp->quit();
$lastError = "Could not be been connected with the server ".$host.":".$port.".<br>".
"<a href=\"javascript:history.back(-1);\">Go Back</a><br><br>";
return FALSE;
}
else
{
if (!$ftp->login($AUTH["ftp"]["login"], $AUTH["ftp"]["password"]))
{
$ftp->quit();
$lastError = "Incorrect login or the password <b>".$AUTH["ftp"]["login"].":".$AUTH["ftp"]["password"]."</b>.<br>".
"<a href=\"javascript:history.back(-1);\">Go Back</a><br><br>";
return FALSE;
}
else
{
//$ftp->Passive(FALSE);
$tmp = explode("/", $url);
$ftp_file = array_pop($tmp);
$ftp_dir = implode("/", $tmp);
$ftp->chdir($ftp_dir);
$fileSize = $FtpBytesTotal = $ftp->filesize($ftp_file);
$FtpChunkSize = round($fileSize / 333);
if(file_exists($saveToFile))
{
$saveToFile = dirname($saveToFile).PATH_SPLITTER.time()."_".basename($saveToFile);
}
echo "Downloaded File <b>".$saveToFile."</b>, Size<b>".bytesToKbOrMb($fileSize)."</b>...<br>";
?>
<br>
<table cellspacing=0 cellpadding=0 style="FONT-FAMILY: Tahoma; FONT-SIZE: 11px;">
<tr>
<td></td>
<td>
<div style='border:#BBBBBB 1px solid; width:300px; height:10px;'>
<div id=progress style='background-color:#000099; margin:1px; width:0%; height:8px;'>
</div>
</div>
</td>
<td></td>
<tr>
<tr>
<td align=left id=received>0 KB</td>
<td align=center id=percent>0%</td>
<td align=right id=speed>0 KB/s</td>
</tr>
</table>
<script>
function pr(percent, received, speed){
document.getElementById("received").innerHTML = '<b>' + received + '</b>';
document.getElementById("percent").innerHTML = '<b>' + percent + '%</b>';
if(percent > 90){percent = percent - 1;}
document.getElementById("progress").style.width = percent + '%';
document.getElementById("speed").innerHTML = '<b>' + speed + ' KB/s</b>';
return true;
}
function mail(str, field) {
document.getElementById("mailPart." + field).innerHTML = str;
return true;
}
</script>
<br>
<?
$FtpTimeStart = getmicrotime();
if($ftp->get($ftp_file, $saveToFile))
{
return array(
"time" => sec2time(round($time)),
"speed" => round($FtpBytesTotal / 1024 / (getmicrotime() - $FtpTimeStart), 2),
"received" => TRUE,
"size" => bytesToKbOrMb($fileSize),
"bytesReceived" => $FtpBytesReceived,
"bytesTotal" => $FtpBytesTotal,
"file" => $saveToFile
);
}
else
{
return FALSE;
}
$ftp->quit();
}
}
}
}
if($post !== 0)
{
$method = "POST";
$postdata = formpostdata($post);
$length = strlen($postdata);
$content_tl = "Content-Type: application/x-www-form-urlencoded".$nn."Content-Length: ".$length.$nn;
}
else
{
$method = "GET";
$postdata = "";
$content_tl = "";
}
if($cookie)
{
$cookies = "Cookie: ".$cookie.$nn;
}
else
{
$cookies = "";
}
if($referer)
{
$referer = "Referer: ".$referer.$nn;
}
else
{
$referer = "";
}
if($proxy)
{
list($proxyHost, $proxyPort) = explode(":", $proxy);
$url = "http://".$host.":".$port.$url;
$host = $host.":".$port;
}
if($AUTH["use"] == TRUE)
{
$auth = "Authorization: Basic ".$AUTH["str"].$nn;
}
else
{
$auth = "";
}
$zapros=
$method." ".str_replace(" ", "%20", $url)." HTTP/1.0".$nn.
"Host: ".$host.$nn.
//"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)".$nn.
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru-RU; rv:1.7.12) Gecko/20050919 Firefox/1.0.7".$nn.
"Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5".$nn.
"Accept-Language: en-en,en;q=0.5".$nn.
"Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7".$nn.
"Keep-Alive: 300".$nn.
"Connection: Keep-Alive".$nn.
$auth.
$referer.
$cookies.
$content_tl.$nn.$postdata;
if($deploy !== 0)
{
pre($zapros);
exit;
}
//write_file("debug", $zapros);
$fp = @fsockopen($proxyHost ? $proxyHost : $host, $proxyPort ? $proxyPort : $port, &$errno, &$errstr, 15);
if($errno || $errstr)
{
//echo $errno;
$lastError = $errstr;
return false;
}
fputs($fp,$zapros);
if($saveToFile)
{
if(file_exists($saveToFile))
{
$saveToFile = dirname($saveToFile).PATH_SPLITTER.time()."_".basename($saveToFile);
}
$fs = @fopen($saveToFile, "w");
if(!$fs)
{
$secondName = dirname($saveToFile).PATH_SPLITTER.str_replace(":", "", str_replace("?", "", basename($saveToFile)));
$fs = @fopen($secondName, "w");
if(!$fs)
{
$lastError = "It is not possible to open the file ".$saveToFile." <br>".
"Wrong Installation, that the way for the retention is assigned correctly and in the script".
"File couldn't be stored into this folder (try chmod the folder to 777).<br>".
"<a href=javascript:location.reload(); style=\"color: #0000FF;\">Repeat</a>";
return FALSE;
}
}
flock($fs, LOCK_EX);
$timeStart = getmicrotime();
}
//socket_set_timeout($fp, 10);
//$f = fopen("debug", "w");
while($data = fgets($fp, 128))
{
//fwrite($f, $data);
if($saveToFile)
{
if($headersReceived)
{
$bytesSaved = fwrite($fs, $data);
if($bytesSaved > -1)
{
$bytesReceived += $bytesSaved;
}
else
{
echo "It is not possible to carry out a record in File".$saveToFile;
return false;
}
if($bytesReceived >= $bytesTotal)
{
$percent = 100;
}
else
{
$percent = round($bytesReceived / $bytesTotal * 100, 2);
}
if($bytesReceived > $last + $chunkSize)
{
$received = bytesToKbOrMb($bytesReceived);
$time = getmicrotime() - $timeStart;
$chunkTime = $time - $lastChunkTime;
$lastChunkTime = $time;
$speed = round($chunkSize / 1024 / $chunkTime, 2);
//echo "Скачано <b>".$received."</b> — <b>".$percent."%</b>; time — <b>".$tmpTime."</b>; speed — <b>".$speed." KB/s</b><br>";
echo "<script>pr(".$percent.", '".$received."', ".$speed.")</script>\r\n";
$last = $bytesReceived;
}
}
else
{
$tmp .= $data;
if(strstr($tmp, "\n\n"))
{
$det = "\n\n";
}
elseif(strstr($tmp, $nn.$nn))
{
$det = $nn.$nn;
}
if($det)
{
$tmp = explode($det, $tmp);
$bytesSaved = fwrite($fs, $tmp[1]);
if($bytesSaved > -1)
{
$bytesReceived += $bytesSaved;
}
else
{
echo "It is not possible to carry out a record in File".$saveToFile."<br>";
return FALSE;
}
$headersReceived = true;
$redirect = cut_str($tmp[0], "Location:", "\n");
if($redirect)
{
$lastError = "Error!! it is obtained perenapravleniye to ".$redirect." On the course of events, the reference became obsolete. So start from the beginning...<br><br><a href=\"".$PHP_SELF."\" style=\"color: #0000FF;\">Main</a>";
fclose($fs);
unlink($saveToFile) ? "" : unlink($secondName);
return FALSE;
}
if(in_array(cut_str($tmp[0], "WWW-Authenticate: ", " "), array("Basic", "Digest")))
{
$lastError = "This site requires authorization. For the indication of login and password of access it is necessary to use similar url:<br>http://<b>login:password@</b>www.site.com/file.exe";
fclose($fs);
unlink($saveToFile) ? "" : unlink($secondName);
return FALSE;
}
$bytesTotal = cut_str($tmp[0], "Content-Length: ", "\n");
$fileSize = bytesToKbOrMb($bytesTotal);
$chunkSize = round($bytesTotal / 333);
echo "File <b>".$saveToFile."</b>, size<b>".$fileSize."</b>...<br>";
?>
<br>
<table cellspacing=0 cellpadding=0 style="FONT-FAMILY: Tahoma; FONT-SIZE: 11px;">
<tr>
<td></td>
<td>
<div style='border:#BBBBBB 1px solid; width:300px; height:10px;'>
<div id=progress style='background-color:#000099; margin:1px; width:0%; height:8px;'>
</div>
</div>
</td>
<td></td>
<tr>
<tr>
<td align=left id=received>0 KB</td>
<td align=center id=percent>0%</td>
<td align=right id=speed>0 KB/s</td>
</tr>
</table>
<script>
function pr(percent, received, speed){
document.getElementById("received").innerHTML = '<b>' + received + '</b>';
document.getElementById("percent").innerHTML = '<b>' + percent + '%</b>';
if(percent > 90){percent = percent - 1;}
document.getElementById("progress").style.width = percent + '%';
document.getElementById("speed").innerHTML = '<b>' + speed + ' KB/s</b>';
return true;
}
function mail(str, field) {
document.getElementById("mailPart." + field).innerHTML = str;
return true;
}
</script>
<br>
<?
}
}
}
else
{
$page .= $data;
}
}
//fclose($f);
if($saveToFile)
{
flock($fs, LOCK_UN);
fclose($fs);
if($bytesReceived <= 0)
{
$lastError = "Wrong Link? Error Downloading File..<br><a href=\"javascript:history.back(-1);\">Go Back</a>";
fclose($fp);
return FALSE;
}
}
fclose($fp);
if($saveToFile)
{
return array("time" => sec2time(round($time)),
"speed" => round($bytesTotal / 1024 / (getmicrotime() - $timeStart), 2),
"received" => true,
"size" => $fileSize,
"bytesReceived" => $bytesReceived,
"bytesTotal" => $bytesTotal,
"file" => $saveToFile);
}
else
{
return $zapros.$nn.$nn.$page;
}
}
function formpostdata($post) {
global $postdata, $first;
$first = "";
array_walk($post, "fpd_f");
return $postdata;
}
function fpd_f($value, $key) {
global $postdata, $first;
$postdata .= $first.$key."=".urlencode($value);
$first = "&";
}
function cut_str($str, $left, $right){
$str = substr(stristr($str, $left), strlen($left));
$leftLen = strlen(stristr($str, $right));
$leftLen = $leftLen ? -($leftLen) : strlen($str);
$str = substr($str, 0, $leftLen);
return $str;
}
function write_file ($file_name, $data, $trunk = 1) {
if($trunk == 1) {$mode = "w";} elseif ($trunk == 0) {$mode = "a";}
$fp = fopen($file_name, $mode);
if(!$fp)
{
return FALSE;
}
else
{
if(!flock($fp, LOCK_EX))
{
return FALSE;
}
else
{
if(!fwrite($fp, $data))
{
return FALSE;
}
else
{
if(!flock($fp, LOCK_UN))
{
return FALSE;
}
else
{
if(!fclose($fp))
{
return FALSE;
}
}
}
}
}
return TRUE;
}
function read_file($file_name, $count = -1) {
if($count == -1) {$count = filesize($file_name);}
$fp = fopen($file_name, "r");
flock($fp, LOCK_SH);
$ret = fread($fp, $count);
flock($fp, LOCK_UN);
fclose($fp);
return $ret;
}
function pre($var) {
echo "<pre>";
print_r($var);
echo "</pre>";
}
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
function html_error($msg){
?>
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1251">
<title>Working....</title>
</head>
<body style="FONT-FAMILY: Tahoma; FONT-SIZE: 11px;">
<center>
<? echo $msg; ?><br>
<a href="javascript:history.back(-1);">Go Back</a>
</center>
</body>
</html>
<?
die;
}
function sec2time($time){
$hour = round($time / 3600, 2);
if($hour >= 1)
{
$hour = floor($hour);
$time -= $hour * 3600;
}
$min = round($time / 60, 2);
if($min >= 1)
{
$min = floor($min);
$time -= $min * 60;
}
$sec = $time;
$hour = ($hour >= 1) ? $hour." hr" : "";
$min = ($min >= 1) ? $min." min" : "";
$sec = ($sec >= 1) ? $sec." sec" : "";
return $hour.$min.$sec;
}
function bytesToKbOrMb($bytes){
$size = ($bytes >= (1024 * 1024)) ? round($bytes / (1024 * 1024), 2)." MB" : round($bytes / 1024, 2)." KB";
return $size;
}
function checkmail($mail) {
if(strlen($mail) == 0)
{
return false;
}
if(!preg_match("/^[a-z0-9_\.-]{1,20}@(([a-z0-9-]+\.)+(com|net|org|mil|".
"edu|gov|arpa|info|biz|inc|name|[a-z]{2})|[0-9]{1,3}\.[0-9]{1,3}\.[0-".
"9]{1,3}\.[0-9]{1,3})$/is", $mail))
{
return false;
}
return true;
}
function xmail($from, $to, $subj, $text, $filename, $partSize = FALSE, $method = FALSE) {
global $un;
$fileContents = read_file($filename);
$fileSize = strlen($fileContents);
if($method == "tc" & $partSize != FALSE)
{
$crc = strtoupper(dechex(crc32($fileContents)));
$crc = str_repeat("0", 8 - strlen($crc)).$crc;
}
$file = base64_encode($fileContents);
$file = chunk_split($file);
if($method != "tc")
{
unset($fileContents);
}
if(!$file)
{
return FALSE;
}
else
{
echo "Sending Files...<br>";
for($i = 0; $i < strlen($subj); $i++)
{
$subzh .= "=".strtoupper(dechex(ord(substr($subj, $i, 1))));
}
$subj = "=?Windows-1251?Q?".$subzh.'?=';
$un = strtoupper(uniqid(time()));
$head = "From: ".$from."\n".
"X-Mailer: PHP RapidGet - Pramod\n".
"Reply-To: ".$from."\n".
"Mime-Version: 1.0\n".
"Content-Type: multipart/mixed; boundary=\"----------".$un."\"\n\n";
$zag = "------------".$un."\nContent-Type: text/plain; charset=Windows-1251\n".
"Content-Transfer-Encoding: 8bit\n\n".$text."\n\n".
"------------".$un."\n".
"Content-Type: application/octet-stream; name=\"".basename($filename)."\"\n".
"Content-Transfer-Encoding: base64\n".
"Content-Disposition: attachment; filename=\"".basename($filename)."\"\n\n";
echo "<span id=mailPart.".basename($filename)."></span><br>";
if($partSize)
{
$partSize = round($partSize);
if($method == "rfc")
{
$multiHeadMain = "From: ".$from."\n".
"X-Mailer: PHP RapidGet - Pramod\n".
"Reply-To: ".$from."\n".
"Mime-Version: 1.0\n".
"Content-Type: message/partial; ";
echo "Spliting into Parts ".bytesToKbOrMb($partSize).", Method - RFC 2046...<br>";
$totalParts = ceil(strlen($file) / $partSize);
echo "Total Parts: <b>".$totalParts."</b><br>";
$mailed = TRUE;
for($i = 0; $i < $totalParts; $i++)
{
$multiHead = $multiHeadMain."id=\"".$filename."\"; number=".($i + 1)."; total=".$totalParts."\n\n";
if($i == 0)
{
$multiHead = $multiHead.$head;
$fileChunk = $zag.substr($file, 0, $partSize);
}
elseif($i == $totalParts - 1)
{
$fileChunk = substr($file, $i * $partSize);
}
else
{
$fileChunk = substr($file, $i * $partSize, $partSize);
}
echo "<script>mail('Sending parts№ <b>".($i + 1)."</b>...', '".basename($filename)."');</script>\r\n";
$mailed = $mailed & mail($to, $subj, $fileChunk, $multiHead);
}
}
elseif($method == "tc")
{
echo "Spliting into parts".bytesToKbOrMb($partSize).", Method - Total Commander...<br>";
$totalParts = ceil($fileSize / $partSize);
echo "Total Parts: <b>".$totalParts."</b><br>";
$mailed = TRUE;
$fileTmp = $filename;
while(strpos($fileTmp, "."))
{
$fileName .= substr($fileTmp, 0, strpos($fileTmp, ".") + 1);
$fileTmp = substr($fileTmp, strpos($fileTmp, ".") + 1);
}
$fileName = substr($fileName, 0, -1);
for($i = 0; $i < $totalParts; $i++)
{
if($i == 0)
{
$fileChunk = substr($fileContents, 0, $partSize);
$addHeads = addAdditionalHeaders(array("msg" => $text."\r\n"."File ".basename($filename)." (часть ".($i + 1)." из ".$totalParts .").", "file" => array("filename" => $fileName.".crc", "stream" => chunk_split(base64_encode("filename=".basename($filename)."\r\n"."size=".$fileSize."\r\n"."crc32=".$crc."\r\n")))));
$addHeads .= addAdditionalHeaders(array("file" => array("filename" => $fileName.".001", "stream" => chunk_split(base64_encode($fileChunk)))));
//write_file($fileName.".crc", "filename=".basename($filename)."\r\n"."size=".$fileSize."\r\n"."crc32=".$crc."\r\n");
//write_file($fileName.".001", $fileChunk);
}
elseif($i == $totalParts - 1)
{
$fileChunk = substr($fileContents, $i * $partSize);
$addHeads = addAdditionalHeaders(array("msg" => "File ".basename($filename)." (parts ".($i + 1)." from ".$totalParts .").",
"file" => array("filename" => $fileName.".".(strlen($i + 1) == 2 ? "0".($i + 1) : (strlen($i + 1) == 1 ? "00".($i + 1) : ($i + 1))),
"stream" => chunk_split(base64_encode($fileChunk)))));
//write_file($fileName.".".(strlen($i + 1) == 2 ? "0".($i + 1) : (strlen($i + 1) == 1 ? "00".($i + 1) : ($i + 1))), $fileChunk);
}
else
{
$fileChunk = substr($fileContents, $i * $partSize, $partSize);
$addHeads = addAdditionalHeaders(array("msg" => "File ".basename($filename)." (parts ".($i + 1)." from ".$totalParts .").",
"file" => array("filename" => $fileName.".".(strlen($i + 1) == 2 ? "0".($i + 1) : (strlen($i + 1) == 1 ? "00".($i + 1) : ($i + 1))),
"stream" => chunk_split(base64_encode($fileChunk)))));
//write_file($fileName.".".(strlen($i + 1) == 2 ? "0".($i + 1) : (strlen($i + 1) == 1 ? "00".($i + 1) : ($i + 1))), $fileChunk);
}
echo "<script>mail('Sending Parts № <b>".($i + 1)."</b>...', '".basename($filename)."');</script>\r\n";
$mailed = $mailed & mail($to, $subj, $addHeads, $head);
}
}
}
else
{
$mailed = mail($to, $subj, $zag.$file, $head);
}
if(!$mailed)
{
return FALSE;
}
else
{
return TRUE;
}
}
}
function addAdditionalHeaders($head) {
global $un;
if($head["msg"])
{
$ret = "------------".$un.
"\nContent-Type: text/plain; charset=Windows-1251\n".
"Content-Transfer-Encoding: 8bit\n\n".$head["msg"]."\n\n";
}
if($head["file"]["filename"])
{
$ret .= "------------".$un."\n".
"Content-Type: application/octet-stream; name=\"".basename($head["file"]["filename"])."\"\n".
"Content-Transfer-Encoding: base64\n".
"Content-Disposition: attachment; filename=\"".basename($head["file"]["filename"])."\"\n\n".
$head["file"]["stream"]."\n\n";
}
return $ret;
}
function updateListInFile($list) {
if(count($list) > 0 & $_COOKIE["showAll"] != 1)
{
foreach($list as $key => $value)
{
$list[$key] = serialize($value);
}
if(!@write_file("files.lst", implode("\r\n", $list)."\r\n") & count($list) > 0)
{
return FALSE;
}
else
{
return TRUE;
}
}
elseif($_COOKIE["showAll"] != 1)
{
return unlink("files.lst");
}
else
{
return TRUE;
}
}
function updateFtpProgress($bytesReceived) {
global $FtpBytesTotal, $FtpBytesReceived, $FtpTimeStart, $FtpLastChunkTime, $FtpChunkSize, $FtpLast, $FtpUpload, $FtpUploadBytesSent;
if($FtpUpload)
{
$FtpUploadBytesSent += $bytesReceived;
$bytesReceived = $FtpUploadBytesSent;
}
if($bytesReceived > $FtpLast + $FtpChunkSize)
{
$time = getmicrotime() - $FtpTimeStart;
$chunkTime = $time - $FtpLastChunkTime;
$FtpLastChunkTime = $time;
$speed = round($FtpChunkSize / 1024 / $chunkTime, 2);
$FtpBytesReceived = $bytesReceived;
if($bytesReceived > $FtpBytesTotal)
{
$percent = 100;
}
else
{
$percent = round($bytesReceived / $FtpBytesTotal * 100, 2);
}
$FtpLast = $bytesReceived;
echo "<script>pr(".$percent.", '".bytesToKbOrMb($bytesReceived)."', ".$speed.")</script>\r\n";
}
}
/*if(!defined('CRLF')) define('CRLF',"\r\n");
if(!defined("FTP_AUTOASCII")) define("FTP_AUTOASCII", -1);
if(!defined("FTP_BINARY")) define("FTP_BINARY", 1);
if(!defined("FTP_ASCII")) define("FTP_ASCII", 0);
if(!defined('FTP_FORCE')) define('FTP_FORCE', TRUE);
define('FTP_OS_Unix','u');
define('FTP_OS_Windows','w');
define('FTP_OS_Mac','m'); */
class ftp_base {
/* Public variables */
var $LocalEcho=FALSE;
var $Verbose=FALSE;
var $OS_local;
/* Private variables */
var $_lastaction=NULL;
var $_errors;
var $_type;
var $_umask;
var $_timeout;
var $_passive;
var $_host;
var $_fullhost;
var $_port;
var $_datahost;
var $_dataport;
var $_ftp_control_sock;
var $_ftp_data_sock;
var $_ftp_temp_sock;
var $_login;
var $_password;
var $_connected;
var $_ready;
var $_code;
var $_message;
var $_can_restore;
var $_port_available;
var $_error_array=array();
var $AuthorizedTransferMode=array(
FTP_AUTOASCII,
FTP_ASCII,
FTP_BINARY
);
var $OS_FullName=array(
FTP_OS_Unix => 'UNIX',
FTP_OS_Windows => 'WINDOWS',
FTP_OS_Mac => 'MACOS'
);
var $NewLineCode=array(
FTP_OS_Unix => "\n",
FTP_OS_Mac => "\r",
FTP_OS_Windows => "\r\n"
);
var $AutoAsciiExt=array("ASP","BAT","C","CPP","CSV","H","HTM","HTML","SHTML","INI","LOG","PHP","PHP3","PL","PERL","SH","SQL","TXT");
/* Constructor */
function ftp_base($port_mode=FALSE) {
$this->_port_available=($port_mode==TRUE);
$this->SendMSG("Staring FTP client class with".($this->_port_available?"":"out")." PORT mode support");
$this->_connected=FALSE;
$this->_ready=FALSE;
$this->_can_restore=FALSE;
$this->_code=0;
$this->_message="";
$this->SetUmask(0022);
$this->SetType(FTP_AUTOASCII);
$this->SetTimeout(30);
$this->Passive(!$this->_port_available);
$this->_login="anonymous";
$this->_password="[email protected]";
$this->OS_local=FTP_OS_Unix;
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->OS_local=FTP_OS_Windows;
elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local=FTP_OS_Mac;
}
// <!-- --------------------------------------------------------------------------------------- -->
// <!-- Public functions -->
// <!-- --------------------------------------------------------------------------------------- -->
function parselisting($list) {
//Parses i line like:"drwxrwx--- 2 owner group 4096 Apr 23 14:57 text"
if(preg_match("/^([-ld])([rwxst-]+)\s+(\d+)\s+([-_\w]+)\s+([-_\w]+)\s+(\d+)\s+(\w{3})\s+(\d+)\s+([\:\d]+)\s+(.+)$/i", $list, $ret)) {
$v=array(
"type"=> ($ret[1]=="-"?"f":$ret[1]),
"perms"=> 0,
"inode"=> $ret[3],
"owner"=> $ret[4],
"group"=> $ret[5],
"size"=> $ret[6],
"date"=> $ret[7]." ".$ret[8]." ".$ret[9],
"name"=> $ret[10]
);
$v["perms"]+=00400*(int)($ret[2]{0}=="r");
$v["perms"]+=00200*(int)($ret[2]{1}=="w");
$v["perms"]+=00100*(int)in_array($ret[2]{2}, array("x","s"));
$v["perms"]+=00040*(int)($ret[2]{3}=="r");
$v["perms"]+=00020*(int)($ret[2]{4}=="w");
$v["perms"]+=00010*(int)in_array($ret[2]{5}, array("x","s"));
$v["perms"]+=00004*(int)($ret[2]{6}=="r");
$v["perms"]+=00002*(int)($ret[2]{7}=="w");
$v["perms"]+=00001*(int)in_array($ret[2]{8}, array("x","t"));
$v["perms"]+=04000*(int)in_array($ret[2]{2}, array("S","s"));
$v["perms"]+=02000*(int)in_array($ret[2]{5}, array("S","s"));
$v["perms"]+=01000*(int)in_array($ret[2]{8}, array("T","t"));
}
return $v;
}
function SendMSG($message = "", $crlf=true) {
if ($this->Verbose) {
echo $message.($crlf?CRLF:"");
flush();
}
return TRUE;
}
function SetType($mode=FTP_AUTOASCII) {
if(!in_array($mode, $this->AuthorizedTransferMode)) {
$this->SendMSG("Wrong type");
return FALSE;
}
$this->_type=$mode;
$this->_data_prepare($mode);
$this->SendMSG("Transfer type: ".($this->_type==FTP_BINARY?"binary":($this->_type==FTP_ASCII?"ASCII":"auto ASCII") ) );
return TRUE;
}
function Passive($pasv=NULL) {
if(is_null($pasv)) $this->_passive=!$this->_passive;
else $this->_passive=$pasv;
if(!$this->_port_available and !$this->_passive) {
$this->SendMSG("Only passive connections available!");
$this->_passive=TRUE;
return FALSE;
}
$this->SendMSG("Passive mode ".($this->_passive?"on":"off"));
return TRUE;
}
function SetServer($host, $port=21, $reconnect=true) {
if(!is_long($port)) {
$this->verbose=true;
$this->SendMSG("Incorrect port syntax");
return FALSE;
} else {
$ip=@gethostbyname($host);
$dns=@gethostbyaddr($host);
if(!$ip) $ip=$host;
if(!$dns) $dns=$host;
if(ip2long($ip) === -1) {
$this->SendMSG("Wrong host name/address \"".$host."\"");
return FALSE;
}
$this->_host=$ip;
$this->_fullhost=$dns;
$this->_port=$port;
$this->_dataport=$port-1;
}
$this->SendMSG("Host \"".$this->_fullhost."(".$this->_host."):".$this->_port."\"");
if($reconnect){
if($this->_connected) {
$this->SendMSG("Reconnecting");
if(!$this->quit(FTP_FORCE)) return FALSE;
if(!$this->connect()) return FALSE;
}
}
return TRUE;
}
function SetUmask($umask=0022) {
$this->_umask=$umask;
umask($this->_umask);
$this->SendMSG("UMASK 0".decoct($this->_umask));
return TRUE;
}
function SetTimeout($timeout=30) {
$this->_timeout=$timeout;
$this->SendMSG("Timeout ".$this->_timeout);
if($this->_connected)
if(!$this->_settimeout($this->_ftp_control_sock)) return FALSE;
return TRUE;
}
function connect() {
$this->SendMsg('Local OS : '.$this->OS_FullName[$this->OS_local]);
if(!($this->_ftp_control_sock = $this->_connect($this->_host, $this->_port))) {
$this->SendMSG("Error : Cannot connect to remote host \"".$this->_fullhost." :".$this->_port."\"");
return FALSE;
}
$this->SendMSG("Connected to remote host \"".$this->_fullhost.":".$this->_port."\". Waiting for greeting.");
do {
if(!$this->_readmsg()) return FALSE;
if(!$this->_checkCode()) return FALSE;
$this->_lastaction=time();
} while($this->_code<200);
$this->_ready=true;
return TRUE;
}
function quit($force=false) {
if($this->_ready) {
if(!$this->_exec("QUIT") and !$force) return FALSE;
if(!$this->_checkCode() and !$force) return FALSE;
$this->_ready=false;
$this->SendMSG("Session finished");
}
$this->_quit();
return TRUE;
}
function login($user=NULL, $pass=NULL) {
if(!is_null($user)) $this->_login=$user;
else $this->_login="anonymous";
if(!is_null($pass)) $this->_password=$pass;
else $this->_password="[email protected]";
if(!$this->_exec("USER ".$this->_login, "login")) return FALSE;
if(!$this->_checkCode()) return FALSE;
if($this->_code!=230) {
if(!$this->_exec((($this->_code==331)?"PASS ":"ACCT ").$this->_password, "login")) return FALSE;
if(!$this->_checkCode()) return FALSE;
}
$this->SendMSG("Authentication succeeded");
$this->_can_restore=$this->restore(100);
$this->SendMSG("This server can".($this->_can_restore?"":"'t")." resume broken uploads/downloads");
return TRUE;
}
function pwd() {
if(!$this->_exec("PWD", "pwd")) return FALSE;
if(!$this->_checkCode()) return FALSE;
return ereg_replace("^[0-9]{3} \"(.+)\" .+".CRLF, "\\1", $this->_message);
}
function cdup() {
if(!$this->_exec("CDUP", "cdup")) return FALSE;
if(!$this->_checkCode()) return FALSE;
return true;
}
function chdir($pathname) {
if(!$this->_exec("CWD ".$pathname, "chdir")) return FALSE;
if(!$this->_checkCode()) return FALSE;
return TRUE;
}
function rmdir($pathname) {
if(!$this->_exec("RMD ".$pathname, "rmdir")) return FALSE;
if(!$this->_checkCode()) return FALSE;
return TRUE;
}
function mkdir($pathname) {
if(!$this->_exec("MKD ".$pathname, "mkdir")) return FALSE;
if(!$this->_checkCode()) return FALSE;
return TRUE;
}
function rename($from, $to) {
if(!$this->_exec("RNFR ".$from, "rename")) return FALSE;
if(!$this->_checkCode()) return FALSE;
if($this->_code==350) {
if(!$this->_exec("RNTO ".$to, "rename")) return FALSE;
if(!$this->_checkCode()) return FALSE;
} else return FALSE;
return TRUE;
}
function filesize($pathname) {
if(!$this->_exec("SIZE ".$pathname, "filesize")) return FALSE;
if(!$this->_checkCode()) return FALSE;
return ereg_replace("^[0-9]{3} ([0-9]+)".CRLF, "\\1", $this->_message);
}
function mdtm($pathname) {
if(!$this->_exec("MDTM ".$pathname, "mdtm")) return FALSE;
if(!$this->_checkCode()) return FALSE;
$mdtm = ereg_replace("^[0-9]{3} ([0-9]+)".CRLF, "\\1", $this->_message);
$date = sscanf($mdtm, "%4d%2d%2d%2d%2d%2d");
$timestamp = mktime($date[3], $date[4], $date[5], $date[1], $date[2], $date[0]);
return $timestamp;
}
function systype() {
if(!$this->_exec("SYST", "systype")) return FALSE;
if(!$this->_checkCode()) return FALSE;
$DATA = explode(" ", $this->_message);
return $DATA[1];
}
function delete($pathname) {
if(!$this->_exec("DELE ".$pathname, "delete")) return FALSE;
if(!$this->_checkCode()) return FALSE;
return TRUE;
}
function site($command, $fnction="site") {
if(!$this->_exec("SITE ".$command, $fnction)) return FALSE;
if(!$this->_checkCode()) return FALSE;
return TRUE;
}
function chmod($pathname, $mode) {
if(!$this->site("CHMOD ".decoct($mode)." ".$pathname, "chmod")) return FALSE;
return TRUE;
}
function restore($from) {
if(!$this->_exec("REST ".$from, "restore")) return FALSE;
if(!$this->_checkCode()) return FALSE;
return TRUE;
}
function features() {
if(!$this->_exec("FEAT", "features")) return FALSE;
if(!$this->_checkCode()) return FALSE;
return preg_split("/[".CRLF."]+/", ereg_replace("[0-9]{3}[ -][^".CRLF."]*".CRLF, "", $this->_message), -1, PREG_SPLIT_NO_EMPTY);
}
function rawlist($arg="", $pathname="") {
return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "LIST", "rawlist");
}
function nlist($arg="", $pathname="") {
return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "NLST", "nlist");
}
function is_exists($pathname)
{
if (!($remote_list = $this->nlist("-a", dirname($pathname)))) {
$this->SendMSG("Error : Cannot get remote file list");
return -1;
}
reset($remote_list);
while (list(,$value) = each($remote_list)) {
if ($value == basename($pathname)) {
$this->SendMSG("Remote file ".$pathname." exists");
return TRUE;
}
}
$this->SendMSG("Remote file ".$pathname." does not exist");
return FALSE;
}
function get($remotefile, $localfile=NULL) {
if(is_null($localfile)) $localfile=$remotefile;
if (@file_exists($localfile)) $this->SendMSG("Warning : local file will be overwritten");
$fp = @fopen($localfile, "w");
if (!$fp) {
$this->PushError("get","can't open local file", "Cannot create \"".$localfile."\"");
return FALSE;
}
$pi=pathinfo($remotefile);
if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
else $mode=FTP_BINARY;
if(!$this->_data_prepare($mode)) {
fclose($fp);
return FALSE;
}
if($this->_can_restore) $this->restore(0);
if(!$this->_exec("RETR ".$remotefile, "get")) {
$this->_data_close();
fclose($fp);
return FALSE;
}
if(!$this->_checkCode()) {
$this->_data_close();
fclose($fp);
return FALSE;
}
$out=$this->_data_read($mode, $fp);
fclose($fp);
$this->_data_close();
if(!$this->_readmsg()) return FALSE;
if(!$this->_checkCode()) return FALSE;
return $out;
}
function get2($remotefile, $from) {
$mode=FTP_BINARY;
if(!$this->_data_prepare($mode)) {
return FALSE;
}
if($this->_can_restore) $this->restore($from);
if(!$this->_exec("RETR ".$remotefile, "get")) {
$this->_data_close();
return FALSE;
}
if(!$this->_checkCode()) {
$this->_data_close();
return FALSE;
}
$out=$this->_data_read2();
$this->_data_close();
if(!$this->_readmsg()) return FALSE;
if(!$this->_checkCode()) return FALSE;
return $out;
}
function put($localfile, $remotefile=NULL) {
if(is_null($remotefile)) $remotefile=$localfile;
if (!@file_exists($localfile)) {
$this->PushError("put","can't open local file", "No such file or directory \"".$localfile."\"");
return FALSE;
}
$fp = @fopen($localfile, "r");
if (!$fp) {
$this->PushError("put","can't open local file", "Cannot read file \"".$localfile."\"");
return FALSE;
}
$pi=pathinfo($localfile);
if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
else $mode=FTP_BINARY;
if(!$this->_data_prepare($mode)) {
fclose($fp);
return FALSE;
}
if($this->_can_restore) $this->restore(0);
if(!$this->_exec("STOR ".$remotefile, "put")) {
$this->_data_close();
fclose($fp);
return FALSE;
}
if(!$this->_checkCode()) {
$this->_data_close();
fclose($fp);
return FALSE;
}
$ret=$this->_data_write($mode, $fp);
fclose($fp);
$this->_data_close();
if(!$this->_readmsg()) return FALSE;
if(!$this->_checkCode()) return FALSE;
return $ret;
}
// <!-- --------------------------------------------------------------------------------------- -->
// <!-- Private functions -->
// <!-- --------------------------------------------------------------------------------------- -->
function _checkCode() {
return ($this->_code<400 and $this->_code>0);
}
function _list($arg="", $cmd="LIST", $fnction="_list") {
if(!$this->_data_prepare()) return FALSE;
if(!$this->_exec($cmd.$arg, $fnction)) {
$this->_data_close();
return FALSE;
}
if(!$this->_checkCode()) {
$this->_data_close();
return FALSE;
}
$out=$this->_data_read();
$this->_data_close();
if(!$this->_readmsg()) return FALSE;
if(!$this->_checkCode()) return FALSE;
if($out === FALSE ) return FALSE;
$out=preg_split("/[".CRLF."]+/", $out, -1, PREG_SPLIT_NO_EMPTY);
$this->SendMSG(implode($this->NewLineCode[$this->OS_local], $out));
return $out;
}
// <!-- --------------------------------------------------------------------------------------- -->
// <!-- Partie : gestion des erreurs -->
// <!-- --------------------------------------------------------------------------------------- -->
// Genere une erreur pour traitement externe a la classe
function PushError($fctname,$msg,$desc=false){
$error=array();
$error['time']=time();
$error['fctname']=$fctname;
$error['msg']=$msg;
$error['desc']=$desc;
if($desc) $tmp=' ('.$desc.')'; else $tmp='';
$this->SendMSG($fctname.': '.$msg.$tmp);
return(array_push($this->_error_array,$error));
}
// Recupere une erreur externe
function PopError(){
if(count($this->_error_array)) return(array_pop($this->_error_array));
else return(false);
}
}
$mod_sockets=TRUE;
if (!extension_loaded('sockets')) {
$prefix = (PHP_SHLIB_SUFFIX == 'dll') ? 'php_' : '';
if(!@dl($prefix . 'sockets.' . PHP_SHLIB_SUFFIX)) $mod_sockets=FALSE;
}
$mod_sockets=TRUE;
if (!extension_loaded('sockets')) {
$prefix = (PHP_SHLIB_SUFFIX == 'dll') ? 'php_' : '';
if(!@dl($prefix . 'sockets.' . PHP_SHLIB_SUFFIX)) $mod_sockets=FALSE;
}
class ftp extends ftp_base {
function ftp($verb=FALSE, $le=FALSE) {
$this->LocalEcho = $le;
$this->Verbose = $verb;
$this->ftp_base();
}
// <!-- --------------------------------------------------------------------------------------- -->
// <!-- Private functions -->
// <!-- --------------------------------------------------------------------------------------- -->
function _settimeout($sock) {echo"===";
/*if(!@stream_set_timeout($sock, $this->_timeout)) {
$this->PushError('_settimeout','socket set send timeout');
$this->_quit();
return FALSE;
}
*/return TRUE;
}
function _connect($host, $port) {
$this->SendMSG("Creating socket");
$sock = @fsockopen($host, $port, $errno, $errstr, $this->_timeout);
if (!$sock) {
$this->PushError('_connect','socket connect failed', $errstr." (".$errno.")");
return FALSE;
}
$this->_connected=true;
return $sock;
}
function _readmsg($fnction="_readmsg"){
if(!$this->_connected) {
$this->PushError($fnction, 'Connect first');
return FALSE;
}
$result=true;
$this->_message="";
$this->_code=0;
$go=true;
do {
$tmp=@fgets($this->_ftp_control_sock, 512);
if($tmp===false) {
$go=$result=false;
$this->PushError($fnction,'Read failed');
} else {
$this->_message.=$tmp;
//for($i=0; $i<strlen($this->_message); $i++)
//if(ord($this->_message[$i])<32) echo "#".ord($this->_message[$i]); else echo $this->_message[$i];
//echo CRLF;
if(preg_match("/^([0-9]{3})(-(.*".CRLF.")+\\1)? [^".CRLF."]+".CRLF."$/", $this->_message, $regs)) $go=false;
}
} while($go);
if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF;
$this->_code=(int)$regs[1];
return $result;
}
function _exec($cmd, $fnction="_exec") {
if(!$this->_ready) {
$this->PushError($fnction,'Connect first');
return FALSE;
}
if($this->LocalEcho) echo "PUT > ",$cmd,CRLF;
$status=@fputs($this->_ftp_control_sock, $cmd.CRLF);
if($status===false) {
$this->PushError($fnction,'socket write failed');
return FALSE;
}
$this->_lastaction=time();
if(!$this->_readmsg($fnction)) return FALSE;
return TRUE;
}
function _data_prepare($mode=FTP_ASCII) {
if($mode==FTP_BINARY) {
if(!$this->_exec("TYPE I", "_data_prepare")) return FALSE;
} else {
if(!$this->_exec("TYPE A", "_data_prepare")) return FALSE;
}
if($this->_passive) {
if(!$this->_exec("PASV", "pasv")) {
$this->_data_close();
return FALSE;
}
if(!$this->_checkCode()) {
$this->_data_close();
return FALSE;
}
$ip_port = explode(",", ereg_replace("^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*".CRLF."$", "\\1", $this->_message));
$this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3];
$this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]);
$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
$this->_ftp_data_sock=@fsockopen($this->_datahost, $this->_dataport, $errno, $errstr, $this->_timeout);
if(!$this->_ftp_data_sock) {
$this->PushError("_data_prepare","fsockopen fails", $errstr." (".$errno.")");
$this->_data_close();
return FALSE;
}
else $this->_ftp_data_sock;
} else {
$this->SendMSG("Only passive connections available!");
return FALSE;
}
return TRUE;
}
function _data_read($mode=FTP_ASCII, $fp=NULL) {
$NewLine=$this->NewLineCode[$this->OS_local];
if(is_resource($fp)) $out=0;
else $out="";
if(!$this->_passive) {
$this->SendMSG("Only passive connections available!");
return FALSE;
}
if($mode!=FTP_BINARY) {
while (!feof($this->_ftp_data_sock)) {
$tmp=fread($this->_ftp_data_sock, 4096);
$line.=$tmp;
if(!preg_match("/".CRLF."$/", $line)) continue;
$line=rtrim($line,CRLF).$NewLine;
if(is_resource($fp))
{
$out+=fwrite($fp, $line, strlen($line));
updateFtpProgress($out);
}
else
{
$out.=$line;
}
$line="";
}
} else {
while (!feof($this->_ftp_data_sock)) {
$block=fread($this->_ftp_data_sock, 4096);
if(is_resource($fp))
{
$out+=fwrite($fp, $block, strlen($block));
updateFtpProgress($out);
}
else
{
$out.=$line;
}
}
}
return $out;
}
function _data_read2() {
$NewLine=$this->NewLineCode[$this->OS_local];
$out=0;
if(!$this->_passive) {
$this->SendMSG("Only passive connections available!");
return FALSE;
}
while (!feof($this->_ftp_data_sock)) {
$block=fread($this->_ftp_data_sock, 4096);
$out+=strlen($block);
echo $block;
}
return $out;
}
function _data_write($mode=FTP_ASCII, $fp=NULL) {
$NewLine=$this->NewLineCode[$this->OS_local];
if(is_resource($fp)) $out=0;
else $out="";
if(!$this->_passive) {
$this->SendMSG("Only passive connections available!");
return FALSE;
}
if(is_resource($fp)) {
while(!feof($fp)) {
$line=fgets($fp, 4096);
if($mode!=FTP_BINARY) $line=rtrim($line, CRLF).CRLF;
do {
if(($res=@fwrite($this->_ftp_data_sock, $line))===FALSE)
{
$this->PushError("_data_write","Can't write to socket");
return FALSE;
}
else
{
updateFtpProgress(strlen($line));
}
$line=substr($line, $res);
}while($line!="");
}
} else {
if($mode!=FTP_BINARY) $fp=rtrim($fp, $NewLine).CRLF;
do {
if(($res=@fwrite($this->_ftp_data_sock, $fp))===FALSE)
{
$this->PushError("_data_write","Can't write to socket");
return FALSE;
}
else
{
updateFtpProgress(strlen($fp));
}
$fp=substr($fp, $res);
}while($fp!="");
}
return TRUE;
}
function _data_close() {
@fclose($this->_ftp_data_sock);
$this->SendMSG("Disconnected data from remote host");
return TRUE;
}
function _quit($force=FALSE) {
if($this->_connected or $force) {
@fclose($this->_ftp_control_sock);
$this->_connected=false;
$this->SendMSG("Socket closed");
}
}
}
?>