Upstream tarball 20080304
[amule.git] / src / webserver / default / downloads.php
blob1eeb20a085b1c8b1ecc34d76ee56741d14570a09
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
5 <meta http-equiv="pragmas" content="no-cache">
6 <?php
7 echo "<title>aMule " , amule_get_version(), " - Web Control Panel</title>";
9 if ( $_SESSION["auto_refresh"] > 0 ) {
10 echo "<meta http-equiv=\"refresh\" content=\"", $_SESSION["auto_refresh"],
11 '; url=downloads.php', '">';
14 <style type="text/css">
15 img
17 border : 0px;
19 a, a:active, a:link, a:visited
21 color: white;
23 .down-header, .down-header-left, .down-header-right,
24 .down-line, .down-line-good, .down-line-left, .down-line-good-left,
25 .down-line-right, .down-line-good-right,
26 .up-header, .up-header-left, .up-line, .up-line-left,
27 .server-header, .server-header-left, .server-line, .server-line-left,
28 .shared-header, .shared-header-left, .shared-line, .shared-line-changed,
29 .shared-line-left, .shared-line-left-changed,
30 .header, .smallheader, .commontext,
31 .upqueue-header, .upqueue-line, .upqueue-line-left,
32 .websearch-header, .websearch-line, .addserver-header, .addserver-line
34 font-family : Tahoma;
35 font-size : 8pt;
37 .tabs
39 font-family : Tahoma;
40 font-size : 10pt;
41 background-color : #3399FF;
43 .down-header, .down-line, .down-line-good, .up-header, .up-line,
44 .server-header, .server-line, .shared-header, .shared-line, .shared-line-changed,
45 .upqueue-header, .upqueue-line,
46 .websearch-header, .websearch-line, .addserver-header, .addserver-line
48 text-align : center;
50 .down-header-left, .down-line-left, .down-line-good-left,
51 .server-header-left, .server-line-left, .shared-header-left,
52 .up-header-left, .up-line-left, .shared-line-left, .shared-line-left-changed, .upqueue-line-left
54 text-align : left;
56 .down-line-right, .down-line-good-right, .down-header-right
58 text-align : right;
60 .down-header, .down-header-left, .down-header-right,
61 .up-header, .up-header-left, .server-header, .server-header-left,
62 .shared-header, .shared-header-left, .upqueue-header,
63 .websearch-header, .addserver-header
65 background-color : #0066CC;
67 .header
69 background-color : #0046AC;
71 .smallheader
73 background-color : #003399;
74 color : #FFFFFF;
76 .commontext
78 background-color : #FFFFFF;
79 color : #000000;
81 .down-line, .down-line-good, .down-line-left, .down-line-good-left,
82 .down-line-right, .down-line-good-right,
83 .up-line, .up-line-left, .server-line, .server-line-left,
84 .shared-line, .shared-line-changed, .shared-line-left, .shared-line-left-changed,
85 .upqueue-line, .upqueue-line-left,
86 .websearch-line, .addserver-line
88 background-color : #3399FF;
90 .down-line-good, .down-line-good-left, .down-line-good-right, .shared-line-changed, .shared-line-left-changed
92 color : #F0F000;
94 .percent_table
96 border:0px solid #000000;
97 border-collapse: collapse;
99 .message
101 font-size: 10pt;
102 font-weight: bold;
103 color: #FF0000;
105 .dinput
107 border-width: 1px;
108 border-color: black;
110 </style>
111 </head>
112 <body bgcolor="#FBDE9C" text=white link="#3399FF" vlink="#3399FF" alink="#3399FF" marginwidth=0 marginheight=0 topmargin=0 leftmargin=0 style="margin:0px">
113 <table border=0 width="100%" align=center cellpadding=4 cellspacing=0>
114 <tr>
115 <td class="tabs" align="left" colspan="2">
117 <table border="0" cellpadding="4" cellspacing="0">
118 <tr>
119 <td class="tabs" align="center">
120 &nbsp;<a href="http://www.amule.org" target="_blank"><img src="emule.gif"></a>
121 <font face="Tahoma" style="font-size:13pt;" color="#000000">aMule<br>Web Control Panel</font>
122 </td>
123 <td class="tabs" align="center" width="30">&nbsp; </td>
125 <td align="center" class="tabs" width="95">
126 <a href="servers.php">
127 <img src="cp_servers.gif"><br>
128 Server list
129 </a>
130 </td>
131 <td align="center" class="tabs" width="95">
132 <a href="downloads.php">
133 <img src="cp_download.gif"><br>
134 Transfer
135 </a>
136 </td>
137 <td align="center" class="tabs" width="95">
138 <a href="search.php">
139 <img src="cp_search.gif"><br>
140 Search
141 </a>
142 </td>
143 <td align="center" class="tabs" width="95">
144 <a href="shared.php">
145 <img src="cp_shared.gif"><br>
146 Shared Files
147 </a>
148 <td align="center" class="tabs" width="110">
149 <a href="stat_tree.php">
150 <img src="cp_stats.gif"><br>
151 Statistics</a>
152 <font color="#000000">|</font>
154 <a href="stat_graphs.php">Graphs</a>
155 </td>
156 </td>
157 <td align="center" class="tabs" width="95">
158 <a href="preferences.php">
159 <img src="cp_settings.gif"><br>
160 Preferences
161 </a>
162 </td>
164 <td class="tabs" align="center" width="30">&nbsp;</td>
165 <td align="left" class="tabs" width="95">
166 <img src="log.gif"> <a href="index.php?serverinfo=1">Serverinfo</a><br>
167 <img src="log.gif"> <a href="index.php?log=1">Log</a>
168 </td>
169 </tr>
170 </table>
172 </td>
173 </tr>
174 <tr>
175 <td style="background-color: #000000; height: 1px" colspan="2">
176 </td>
177 </tr>
178 <tr>
179 <td class="tabs">
180 &nbsp;&nbsp;<b>Connection:</b>
181 <?php
182 function CastToXBytes($size)
184 if ( $size < 1024 ) {
185 $result = $size . " bytes";
186 } elseif ( $size < 1048576 ) {
187 $result = ($size / 1024.0) . "KB";
188 } elseif ( $size < 1073741824 ) {
189 $result = ($size / 1048576.0) . "MB";
190 } else {
191 $result = ($size / 1073741824.0) . "GB";
193 return $result;
196 $stats = amule_get_stats();
197 if ( $stats["kad_connected"] == 1 ) {
198 echo "Connected";
199 if ( $stats["kad_firewalled"] == 1 ) {
200 echo " to KAD (firewalled), ";
201 } else {
202 echo " to KAD, ";
204 } else {
205 echo "Not connected to KAD, ";
207 if ( $stats["id"] == 0 ) {
208 echo "not connected to ED2K";
209 } elseif ( $stats["id"] == 0xffffffff ) {
210 echo "connecting to ED2k";
211 } else {
212 echo "connected with ", (($stats["id"] < 16777216) ? "low" : "high"), " ID to ",
213 $stats["serv_name"], " ", $stats["serv_addr"];
215 echo '<br>&nbsp;&nbsp;<b>Speed:</b> Up: ', CastToXBytes($stats["speed_up"]), 'ps',
216 ' | Down: ', CastToXBytes($stats["speed_down"]), 'ps',
217 '<small> (Limits: ', CastToXBytes($stats["speed_limit_up"]), 'ps/',
218 CastToXBytes($stats["speed_limit_down"]), 'ps)</small>&nbsp;';
221 <font color=black>
223 <script language="javascript">
224 var d = new Date();
225 s = "[ " + d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear() + " " + d.getHours() + ":" + (d.getMinutes() < 10 ? "0" : "") + d.getMinutes() + ":" + (d.getSeconds() < 10 ? "0" : "") + d.getSeconds() + " ]";
226 document.write(s);
227 </script>
228 </font>
229 </td>
230 <td align=right class=tabs>
231 <form>
232 <input type="button" value="ed2k://Download" onClick='self.location.href="index.php?links=1"'>
233 <input type="button" value="Logout" onClick='self.location.href="login.php"'>
234 </form>
235 </td>
236 </tr>
237 </table><font face=Tahoma style="font-size:8pt;">
238 </font>
239 &nbsp;<table border=0 align=center cellpadding=4 cellspacing=0 width="95%">
241 <tr>
242 <td align=center valign=middle>
244 <script type="text/javascript">
245 function GotoCat(cat) {
246 window.location.href="downloads.php?cmd=filter&status="+cat;
248 </script><font face=Tahoma style="font-size:8pt;">
249 <table border=0 align=center cellpadding=3 cellspacing=0 width="100%" bgcolor="#99CCFF">
250 <tr>
251 <td class="smallheader" style="background-color: #000000" colspan="8"><img src="arrow_down.gif">
252 <b>Downloads
253 <?php
254 $downloads = amule_load_vars("downloads");
255 echo '&nbsp;(', count($downloads), ')';
257 </b></td>
258 <td align="right" class="smallheader" style="background-color: #000000">
259 <form>
260 <select name="cat" size="1"onchange=GotoCat(this.form.cat.options[this.form.cat.selectedIndex].value)>
261 <?php
262 $all_status = array("All", "Waiting", "Paused", "Downloading");
264 if ( $HTTP_GET_VARS["cmd"] == "filter") {
265 $_SESSION["filter_status"] = $HTTP_GET_VARS["status"];
267 if ( $_SESSION["filter_status"] == '') $_SESSION["filter_status"] = 'All';
268 foreach ($all_status as $s) {
269 echo (($s == $_SESSION["filter_status"]) ? '<option selected>' : '<option>'), $s, '</option>';
272 </select>
273 </form>
274 </td>
276 </tr>
277 <tr>
278 <td valign=middle class="down-header-left"><a href="?sort=name"><b>File Name</b></a></td>
279 <td valign=middle class="down-header"><a href="?sort=size"><b>Size</b></a></td>
280 <td valign=middle class="down-header"><a href="?sort=size_done"><b>Complete</b></a></td>
281 <td valign=middle class="down-header"><a href="?sort=size_xfer"><b>Transferred</b></a></td>
282 <td valign=middle class="down-header"><a href="?sort=progress"><b>Progress</b></a></td>
284 <td valign=middle class="down-header">&nbsp;&nbsp;<a href="?sort=speed"><b>Speed</b></a>&nbsp;&nbsp;&nbsp;&nbsp;</td>
285 <td valign=middle class="down-header"><b>Sources</b></td>
286 <td valign=middle class="down-header"><a href="?sort=prio"><b>Priority</b></a></td>
287 <td valign=middle class="down-header"><b>Actions</b></td>
288 </tr>
290 <?php
291 function CastToXBytes($size)
293 if ( $size < 1024 ) {
294 $result = $size . " bytes";
295 } elseif ( $size < 1048576 ) {
296 $result = ($size / 1024.0) . "KB";
297 } elseif ( $size < 1073741824 ) {
298 $result = ($size / 1048576.0) . "MB";
299 } else {
300 $result = ($size / 1073741824.0) . "GB";
302 return $result;
304 function PrioString($file)
306 $prionames = array(0 => "Low", 1 => "Normal", 2 => "High",
307 3 => "Very high", 4 => "Very low", 5=> "Auto", 6 => "Powershare");
308 $result = $prionames[$file->prio];
309 if ( $file->prio_auto == 1) {
310 $result = $result . "(auto)";
312 return $result;
314 function StatusString($file)
316 if ( $file->status == 7 ) {
317 return "Paused";
318 } elseif ( $file->src_count_xfer > 0 ) {
319 return "Downloading";
320 } else {
321 return "Waiting";
326 // declare it here, before any function reffered it in "global"
328 $sort_order;$sort_reverse;
330 function my_cmp($a, $b)
332 global $sort_order, $sort_reverse;
334 switch ( $sort_order) {
335 case "size": $result = $a->size > $b->size; break;
336 case "size_done": $result = $a->size_done > $b->size_done; break;
337 case "size_xfer": $result = $a->size_xfer > $b->size_xfer; break;
338 case "progress": $result = (((float)$a->size_done)/((float)$a->size)) > (((float)$b->size_done)/((float)$b->size)); break;
339 case "name": $result = $a->name > $b->name; break;
340 case "speed": $result = $a->speed > $b->speed; break;
341 case "scrcount": $result = $a->src_count > $b->src_count; break;
342 case "status": $result = StatusString($a) > StatusString($b); break;
343 case "prio": $result = PrioString($a) > PrioString($b); break;
346 if ( $sort_reverse ) {
347 $result = !$result;
349 //var_dump($sort_reverse);
350 return $result;
353 if ( ($HTTP_GET_VARS["cmd"] != "") && ($_SESSION["guest_login"] == 0) ) {
354 $name = $HTTP_GET_VARS['file'];
355 if ( strlen($name) == 32 ) {
356 amule_do_download_cmd($name, $HTTP_GET_VARS["cmd"]);
360 $downloads = amule_load_vars("downloads");
362 $sort_order = $HTTP_GET_VARS["sort"];
364 if ( $sort_order == "" ) {
365 $sort_order = $_SESSION["download_sort"];
367 $reverse_sort_key = "download_sort_reverse" . $sort_order;
368 if ( $_SESSION[$reverse_sort_key] == "" ) {
369 $_SESSION[$reverse_sort_key] = 0;
370 } else {
371 if ( $HTTP_GET_VARS["sort"] != '') {
372 $_SESSION[$reverse_sort_key] = !$_SESSION[$reverse_sort_key];
376 //var_dump($_SESSION);
377 $sort_reverse = $_SESSION[$reverse_sort_key];
379 if ( $sort_order != "" ) {
380 $_SESSION["download_sort"] = $sort_order;
381 usort(&$downloads, "my_cmp");
384 foreach ($downloads as $file) {
385 echo '<td valign=top class="down-line-left"><acronym title="', $file->name, '">', $file->short_name, '</acronym></td>';
386 echo '<td valign=top class="down-line-right">', CastToXBytes($file->size), '</td>';
387 echo '<td valign=top class="down-line-right">', CastToXBytes($file->size_done), '</td>';
388 echo '<td valign=top class="down-line-right">', CastToXBytes($file->size_xfer), '</td>';
390 echo '<td valign=middle class="down-line">';
391 echo '<table width=200 height=11 border=1 class="percent_table" cellpadding=0 cellspacing=0 bordercolor="#000000">';
392 echo '<tr><td><img src="greenpercent.gif" height=4 width=', (($file->size_done * 1.0)/$file->size)*200 + 1, '><br>';
393 echo $file->progress, '</td></tr></table></td>';
395 echo '<td valign=top class="down-line-right">', CastToXBytes($file->speed), '</td>';
397 // source count
398 echo '<td valign=top class="down-line">';
399 if ( $file->src_count_not_curr != 0 ) {
400 echo $file->src_count - $file->src_count_not_curr, "&nbsp;/&nbsp;";
402 echo $file->src_count, "&nbsp;(", $file->src_count_xfer, ")";
403 if ( $file->src_count_a4af != 0 ) {
404 echo "+", $file->src_count_a4af;
406 echo '</td>';
408 echo '<td valign=top class="down-line">', PrioString($file), '</td>';
410 $status = StatusString($file);
411 echo '<td valign=top class="down-line"><acronym title="', $status, '">';
412 echo '<img src="l_info.gif" alt="', $status, '"></acronym>';
414 // commands
415 echo '<acronym title="ED2K Link(s)"><a href="', $file->link, '"><img src="l_ed2klink.gif" alt="ED2K Link(s)"></a></acronym>';
416 if ( $_SESSION["guest_login"] == 0 ) {
417 if ( $file->status == 7 ) {
418 echo '<acronym title="Resume"><a href="?cmd=resume&file=', $file->hash, '"><img src="l_resume.gif" alt="Resume"></a></acronym>';
419 } else {
420 echo '<acronym title="Pause"><a href="?cmd=pause&file=', $file->hash, '"><img src="l_pause.gif" alt="Pause"></a></acronym>';
422 echo '<acronym title="Cancel"><a href="?cmd=cancel&file=', $file->hash,
423 "\" onclick=\"return confirm('Are you sure that you want to cancel and delete this file?')\" ",
424 '><img src="l_cancel.gif" alt="Cancel"></a></acronym>';
425 echo '<acronym title="Increase priority"><a href="?cmd=prioup&file=', $file->hash, '"><img src="l_up.gif" alt="Increase priority"></a></acronym>';
426 echo '<acronym title="Decrease priority"><a href="?cmd=priodown&file=', $file->hash, '"><img src="l_down.gif" alt="Decrease priority"></a></acronym>';
428 echo '</td></tr>';
429 echo "\n";
432 <tr>
433 </tr>
434 </table>
435 <table border=0 align=center cellpadding=4 cellspacing=0 width="100%">
436 <tr>
438 <td class="smallheader" colspan=4 style="background-color: #000000"><img src="arrow_up.gif">
439 <b>Uploads
440 <?php
441 $uploads = amule_load_vars("uploads");
442 echo '&nbsp;(', count($uploads), ')';
444 </b></td>
446 </tr>
447 <tr>
448 <td class="up-header-left"><b>Username</b></td>
449 <td class="up-header"><b>File Name</b></td>
450 <td class="up-header"><b>Transferred</b></td>
451 <td class="up-header"><b>Speed</b></td>
452 </tr>
453 <?php
454 function CastToXBytes($size)
456 if ( $size < 1024 ) {
457 $result = $size . " bytes";
458 } elseif ( $size < 1048576 ) {
459 $result = ($size / 1024.0) . "KB";
460 } elseif ( $size < 1073741824 ) {
461 $result = ($size / 1048576.0) . "MB";
462 } else {
463 $result = ($size / 1073741824.0) . "GB";
465 return $result;
467 $uploads = amule_load_vars("uploads");
468 foreach ($uploads as $file) {
469 echo '<tr>';
470 echo '<td valign=top class="up-line-left"><acronym title="', $file->user_name, '">', $file->user_name, '</acronym></td>';
471 echo '<td valign=top class="up-line-left"><acronym title="', $file->name, '">', $file->short_name, '</acronym></td>';
472 echo '<td valign=top class="up-line">', CastToXBytes($file->xfer_up), "&nbsp;/&nbsp;", CastToXBytes($file->xfer_down), '</td>';
473 echo '<td valign=top class="up-line">', ($file->xfer_speed > 0) ? (CastToXBytes($file->xfer_speed) . "/s") : "-", '</td>';
474 echo '</tr>';
475 echo "\n";
478 </table>
479 &nbsp;
480 <p align=center>&nbsp;
481 </p>
482 </font>
483 </td>
484 </tr>
485 </table></body>
486 </html>