forked from Th3-822/rapidleech
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathftp.php
More file actions
157 lines (154 loc) · 5.78 KB
/
Copy pathftp.php
File metadata and controls
157 lines (154 loc) · 5.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
function ftp() {
global $list, $options, $PHP_SELF;
?>
<form method="post" action="<?php echo $PHP_SELF; ?>"><input type="hidden" name="act" value="ftp_go" />
<?php echo lang(104); ?>:
<?php
for($i = 0; $i < count ( $_GET ["files"] ); $i ++) {
$file = $list [($_GET ["files"] [$i])];
?>
<input type="hidden" name="files[]" value="<?php echo $_GET ["files"] [$i]; ?>" /> <b><?php echo basename ( $file ["name"] ); ?></b><?php echo $i == count ( $_GET ["files"] ) - 1 ? "." : ", "; ?>
<?php
}
?><br />
<br />
<table align="center" style="text-align: left;">
<tr>
<td>
<table>
<tr>
<td><?php echo lang(153); ?>:</td>
<td><input type="text" name="host" id="host" <?php echo @$_COOKIE ["host"] ? ' value="' . $_COOKIE ["host"] . '"' : ''; ?>
size="23" /></td>
</tr>
<tr>
<td><?php echo lang(154); ?>:</td>
<td><input type="text" name="port" id="port" <?php echo @$_COOKIE ["port"] ? ' value="' . $_COOKIE ["port"] . '"' : ' value="21"'; ?>
size="4" /></td>
</tr>
<tr>
<td><?php echo lang(37); ?>:</td>
<td><input type="text" name="login" id="login" <?php echo @$_COOKIE ["login"] ? ' value="' . $_COOKIE ["login"] . '"' : ''; ?>
size="23" /></td>
</tr>
<tr>
<td><?php echo lang(38); ?>:</td>
<td><input type="password" name="password" id="password" <?php echo @$_COOKIE ["password"] ? ' value="' . $_COOKIE ["password"] . '"' : ''; ?>
size="23" /></td>
</tr>
<tr>
<td><?php echo lang(155); ?>:</td>
<td><input type="text" name="dir" id="dir" <?php echo @$_COOKIE ["dir"] ? ' value="' . $_COOKIE ["dir"] . '"' : ' value="/"'; ?>
size="23" /></td>
</tr>
<tr>
<td><input type="checkbox" name="del_ok" <?php if ($options['disable_deleting']) echo 'disabled="disabled"'; ?> /> <?php echo lang(156); ?></td>
</tr>
</table>
</td>
<td> </td>
<td>
<table>
<tr align="center">
<td><input type="submit" value="Upload" /></td>
</tr>
<tr align="center">
<td><?php echo lang(33); ?></td>
</tr>
<tr align="center">
<td><a href="javascript:setFtpParams();" id="hrefSetFtpParams"><?php echo lang(157); ?></a> | <a href="javascript:delFtpParams();" id="hrefDelFtpParams"><?php echo lang(158); ?></a></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<?php
}
function ftp_go() {
global $list, $options, $FtpUpload, $FtpBytesTotal, $FtpChunkSize, $FtpTimeStart, $FtpUploadBytesSent, $FtpLastChunkTime, $FtpLast;
require_once (CLASS_DIR . "ftp.php");
$ftp = new ftp ( );
if (! $ftp->SetServer ( $_POST ["host"], ( int ) $_POST ["port"] )) {
$ftp->quit ();
printf(lang(79),$_POST ["host"] . ":" . $_POST ["port"]);
echo '<br /><a href="javascript:history.back(-1);">'.lang(78).'</a><br /><br />';
} else {
if (! $ftp->connect ()) {
$ftp->quit ();
echo "<br />";
printf(lang(79),$_POST ["host"] . ":" . $_POST ["port"]);
echo '<br /><a href="javascript:history.back(-1);">'.lang(78).'</a><br /><br />';
} else {
printf(lang(81),'ftp://'.$_POST['host'].':'.$_POST['port']);
if (! $ftp->login ( $_POST ["login"], $_POST ["password"] )) {
$ftp->quit ();
echo "<br />";
echo lang(80);
echo '<br /><a href="javascript:history.back(-1);">'.lang(78).'</a><br /><br />';
} else {
//$ftp->Passive(FALSE);
if (! $ftp->chdir ( $_POST ["dir"] )) {
$ftp->quit ();
echo "<br />";
printf(lang(159),$_POST['dir']);
echo '<br /><a href="javascript:history.back(-1);">'.lang(78).'</a><br /><br />';
} else {
?>
<br />
<div id="status"></div>
<br />
<table cellspacing="0" cellpadding="0">
<tr>
<td></td>
<td>
<div class="progressouter">
<div style="width:298px">
<div id="progress" class="ftpprogress"></div>
</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>
<br />
<script type="text/javascript">switchCell(3);</script>
<?php
for($i = 0; $i < count ( $_POST ["files"] ); $i ++) {
$file = $list [$_POST ["files"] [$i]];
echo '<script type="text/javascript">pr(0,0,0);changeStatus('."'" . addslashes(basename ( $file ["name"] )) . "', '" . $file ["size"] . "');</script>";
$FtpUpload = true;
$FtpBytesTotal = filesize($file['name']);
$FtpChunkSize = round($FtpBytesTotal/333);
$FtpTimeStart = getmicrotime ();
$FtpUploadBytesSent = $FtpLastChunkTime = $FtpLast = 0;
if ($ftp->put ( $file ["name"], basename ( $file ["name"] ) )) {
$time = round ( getmicrotime () - $FtpTimeStart );
$speed = @round ( $FtpBytesTotal / 1024 / $time, 2 );
echo '<script type="text/javascript">pr(100, '."'" . bytesToKbOrMbOrGb ( $FtpBytesTotal ) . "', " . $speed . ")</script>\r\n";
flush ();
if (@$_POST["del_ok"] && !$options['disable_deleting']) {
if (@unlink ( $file ["name"] )) {
unset ( $list [$_POST ["files"] [$i]] );
}
}
printf(lang(160),'<a href="ftp://' . $_POST ["login"] . ':' . $_POST ["password"] . '@' . $_POST ["host"] . ':' . $_POST ["port"] . $_POST ["dir"] . (substr ($_POST ["dir"], - 1) != '/' ? '/' : '') . basename ( $file ["name"] ) . '"><b>' . basename ( $file ["name"] ) . '</b></a>');
echo "<br />".lang(161).": <b>" . sec2time ( $time ) . "</b><br />".lang(162).": <b>" . $speed . " KB/s</b><br /><br />";
} else {
printf(lang(163),basename($file['name']));
echo "<br />";
}
}
$ftp->quit ();
}
}
}
}
}
?>