Upstream tarball 20080304
[amule.git] / src / webserver / chicane / downloads.php
blob3763ca93b6dbecb88ea27b7a87fd8a94f0c031db
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>";
8 if ( $_SESSION["auto_refresh"] > 0 ) {
9 echo "<meta http-equiv=\"refresh\" content=\"", $_SESSION["auto_refresh"],
10 '; url=downloads.php', '">';
13 <style type="text/css">
14 img {
15 border : 0px;
18 a, a:link, a:visited {
19 color : white;
20 text-decoration: none;
23 a:hover {
24 color: #FFC412;
25 text-decoration: none;
28 .down-header, .down-header-left, .down-header-right,
29 .down-line, .down-line-good, .down-line-left, .down-line-good-left,
30 .down-line-right, .down-line-good-right,
31 .up-header, .up-header-left, .up-line, .up-line-left,
32 .server-header, .server-header-left, .server-line, .server-line-left,
33 .shared-header, .shared-header-left, .shared-line, .shared-line-changed,
34 .shared-line-left, .shared-line-left-changed,
35 .header, .smallheader, .commontext,
36 .upqueue-header, .upqueue-line, .upqueue-line-left,
37 .websearch-header, .websearch-line, .addserver-header, .addserver-line {
39 font-family : Tahoma;
40 font-size : 8pt;
43 .tabs {
44 font-family : Tahoma;
45 font-size : 10pt;
46 background-color : #1F76A5;
49 .tabs_too {
50 font-family : Tahoma;
51 font-size : 10pt;
52 background-color : #0075B3;
55 .tabs_three {
56 font-family : Tahoma;
57 font-size : 10pt;
60 .tabs_four {
61 font-family : Tahoma;
62 font-size : 10pt;
63 background-color : #21719B;
66 .tabs_five {
67 font-family : Tahoma;
68 font-size : 10pt;
69 background-color : #1D6083;
72 .down-header, .down-line, .down-line-good, .up-header, .up-line,
73 .server-header, .server-line, .shared-header, .shared-line, .shared-line-changed,
74 .upqueue-header, .upqueue-line,
75 .websearch-header, .websearch-line, .addserver-header, .addserver-line {
77 text-align : center;
80 .down-header-left, .down-line-left, .down-line-good-left,
81 .server-header-left, .server-line-left, .shared-header-left,
82 .up-header-left, .up-line-left, .shared-line-left, .shared-line-left-changed, .upqueue-line-left {
84 text-align : left;
87 .down-line-right, .down-line-good-right, .down-header-right {
88 text-align : right;
91 .down-header, .down-header-left, .down-header-right,
92 .up-header, .up-header-left, .server-header, .server-header-left,
93 .shared-header, .shared-header-left, .upqueue-header,
94 .websearch-header, .addserver-header {
96 background-color : #1D6083;
99 .header {
100 background-color : #0046AC;
103 .smallheader {
104 background-color : #003399;
105 color : #FFFFFF;
108 .commontext {
109 background-color : #FFFFFF;
110 color : #000000;
113 .commontext_too {
114 color : #FFFFFF;
115 font-family : Tahoma;
116 font-size : 8pt;
119 .down-line, .down-line-good, .down-line-left, .down-line-good-left,
120 .down-line-right, .down-line-good-right,
121 .up-line, .up-line-left, .server-line, .server-line-left,
122 .shared-line, .shared-line-changed, .shared-line-left, .shared-line-left-changed,
123 .upqueue-line, .upqueue-line-left,
124 .websearch-line, .addserver-line {
126 background-color : #1F76A5;
129 .down-line-good, .down-line-good-left, .down-line-good-right,
130 .shared-line-changed, .shared-line-left-changed {
132 color : #F0F000;
135 .percent_table {
136 border:0px solid #000000;
137 border-collapse: collapse;
140 .message {
141 font-family : Tahoma;
142 font-size : 8pt;
143 font-weight: bold;
144 color: #FFFFFF;
145 background-color: #1D6083;
148 .dinput {
149 border-width: 1px;
150 border-color: black;
153 </style>
154 </head>
155 <body background="main_bg.gif" text=white link="#1F76A5" vlink="#1F76A5" alink="#1F76A5" marginwidth=0 marginheight=0 topmargin=0 leftmargin=0 style="margin:0px">
156 <table border="0" width="100%" align="center" cellpadding="0" cellspacing="0">
157 <tr>
158 <td class="tabs_three" background="main_top_bg.gif" align="left" colspan="4">
160 <table border="0" cellpadding="4" cellspacing="0" width="100%">
161 <tr>
162 <td class="tabs_three" align="center" width="100">
164 &nbsp;
165 <font face="Tahoma" style="font-size:13pt;" color="#000000"><a href="http://www.amule.org" target="_blank">
166 <img src="emule.gif" alt="aMule | Web Control Panel">
167 </a>
168 </td>
169 <td class="tabs_three" align="center" width="30">
170 &nbsp;
171 </td>
172 <td align="center" class="tabs_three" width="95">
174 <a href="servers.php">
175 <img src="cp_servers.gif"><br />
176 Server list
177 </a>
178 </td>
179 <td align="center" class="tabs_three" width="96">
180 <a href="downloads.php">
181 <img src="cp_download.gif"><br />
182 Transfer
183 </a>
185 </td>
186 <td align="center" class="tabs_three" width="96">
187 <a href="search.php">
188 <img src="cp_search.gif"><br />
189 Search
190 </a>
191 </td>
192 <td align="center" class="tabs_three" width="96">
193 <a href="shared.php">
195 <img src="cp_shared.gif"><br />
196 Shared Files
197 </a>
198 <td align="center" class="tabs_three" width="110">
199 <a href="stat_tree.php">
200 <img src="cp_stats.gif"><br />
201 Statistics
202 </a>
203 <font color="#000000">|</font>
205 <a href="stat_graphs.php">
206 Graphs
207 </a>
208 </td>
209 <td align="center" class="tabs_three" width="95">
210 <a href="preferences.php">
211 <img src="cp_settings.gif"><br />
212 Preferences
213 </a>
214 </td>
216 <td class="tabs_three" align="center">
217 &nbsp;
218 </td>
219 <td align="left" class="tabs_three" width="95">
220 <img src="log.gif" align="absmiddle"> <a href="index.php?serverinfo=1">Serverinfo</a><br />
221 <img src="log.gif" align="absmiddle"> <a href="index.php?log=1">Log</a>
222 </td>
224 </tr>
225 </table>
227 </td>
228 </tr>
229 <tr>
230 <td background="main_topbar.gif" height="49" class="tabs_four">
231 &nbsp;&nbsp;<b>Connection:</b>
232 <?php
233 function CastToXBytes($size)
235 if ( $size < 1024 ) {
236 $result = $size . " bytes";
237 } elseif ( $size < 1048576 ) {
238 $result = ($size / 1024.0) . "KB";
239 } elseif ( $size < 1073741824 ) {
240 $result = ($size / 1048576.0) . "MB";
241 } else {
242 $result = ($size / 1073741824.0) . "GB";
244 return $result;
247 $stats = amule_get_stats();
248 if ( $stats["id"] == 0 ) {
249 echo "Not connected";
250 } elseif ( $stats["id"] == 0xffffffff ) {
251 echo "Connecting ...";
252 } else {
253 echo "Connected with ", (($stats["id"] < 16777216) ? "low" : "high"), " ID to ",
254 $stats["serv_name"], " ", $stats["serv_addr"];
256 echo '<br>&nbsp;&nbsp;<b>Speed:</b> Up: ', CastToXBytes($stats["speed_up"]), 'ps',
257 ' | Down: ', CastToXBytes($stats["speed_down"]), 'ps',
258 '<small> (Limits: ', CastToXBytes($stats["speed_limit_up"]), 'ps/',
259 CastToXBytes($stats["speed_limit_down"]), 'ps)</small>&nbsp;';
261 <font color="#FFE471">
262 <script language="javascript">
263 var d = new Date();
264 s = "[ " + d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear() + " " + d.getHours() + ":" + (d.getMinutes() < 10 ? "0" : "") + d.getMinutes() + ":" + (d.getSeconds() < 10 ? "0" : "") + d.getSeconds() + " ]";
265 document.write(s);
266 </script>
267 </font>
268 </td>
269 <td background="main_topbar.gif" align="center" valign="middle" class="tabs_four">
271 <a href="index.php?links=1">
272 <img src="arrow_right.gif" align="absmiddle">
273 &nbsp; ed2k:// ED2K Link(s)
274 </a>
275 </td>
276 <td background="main_topbar.gif" align="right">
278 <table border="0" cellpadding="0" cellspacing="0" width="8" height="100%">
279 <tr>
280 <td height="49" background="main_topbarseperator.gif">
282 &nbsp;
283 </td>
284 </tr>
285 </table>
287 </td>
288 <td background="main_topbardarker.gif" align="center" valign="middle" class="tabs_five">
289 <a href="login.php">
290 <img src="arrow_down_logout.gif" align="absmiddle">
291 &nbsp; Logout
292 </a>
294 </td>
295 </tr>
296 </table><font face=Tahoma style="font-size:8pt;">
297 </font>
298 &nbsp;<table border=0 align=center cellpadding=4 cellspacing=0 width="95%">
299 <tr>
300 <td align=center valign=middle>
302 <script type="text/javascript">
304 function GotoCat(cat) {
305 window.location.href="downloads.php?cmd=filter&status="+cat;
308 </script>
310 <font face=Tahoma style="font-size:8pt;">
311 <table border=0 align=center cellpadding=3 cellspacing=0 width="100%" bgcolor="#99CCFF">
313 <tr>
314 <td class="smallheader" style="background-color: #000000" colspan="8"><img src="arrow_down.gif">
315 <b>Downloads
316 <?php
317 $downloads = amule_load_vars("downloads");
318 echo '&nbsp;(', count($downloads), ')';
320 </b></td>
321 <td align="right" class="smallheader" style="background-color: #000000">
322 <form>
323 <select name="cat" size="1" onchange=GotoCat(this.form.cat.options[this.form.cat.selectedIndex].value)>
324 <?php
325 $all_status = array("All", "Waiting", "Paused", "Downloading");
327 if ( $HTTP_GET_VARS["cmd"] == "filter") {
328 $_SESSION["filter_status"] = $HTTP_GET_VARS["status"];
330 if ( $_SESSION["filter_status"] == '') $_SESSION["filter_status"] = 'All';
331 foreach ($all_status as $s) {
332 echo (($s == $_SESSION["filter_status"]) ? '<option selected>' : '<option>'), $s, '</option>';
335 </select>
336 </form>
337 </td>
338 </tr>
339 <tr>
340 <td valign=middle class="down-header-left"><a href="downloads.php?sort=name"><b>File Name</b></a></td>
342 <td valign=middle class="down-header"><a href="downloads.php?sort=size"><b>Size</b></a></td>
343 <td valign=middle class="down-header"><a href="downloads.php?sort=size_done"><b>Complete</b></a></td>
344 <td valign=middle class="down-header"><a href="downloads.php?sort=size_xfer"><b>Transferred</b></a></td>
345 <td valign=middle class="down-header"><a href="downloads.php?sort=progress"><b>Progress</b></a></td>
346 <td valign=middle class="down-header"><a href="downloads.php?sort=speed"><b>Speed</b></a></td>
347 <td valign=middle class="down-header"><b>Sources</b></td>
348 <td valign=middle class="down-header"><a href="downloads.php?sort=prio"><b>Priority</b></a></td>
349 <td valign=middle class="down-header"><b>Actions</b></td>
350 </tr>
352 <?php
353 function CastToXBytes($size)
355 if ( $size < 1024 ) {
356 $result = $size . " byte";
357 } elseif ( $size < 1048576 ) {
358 $result = ($size / 1024.0) . "KB";
359 } elseif ( $size < 1073741824 ) {
360 $result = ($size / 1048576.0) . "MB";
361 } else {
362 $result = ($size / 1073741824.0) . "GB";
364 return $result;
366 function PrioString($file)
368 $prionames = array(0 => "Low", 1 => "Normal", 2 => "High",
369 3 => "Very high", 4 => "Very low", 5=> "Auto", 6 => "Powershare");
370 $result = $prionames[$file->prio];
371 if ( $file->prio_auto == 1) {
372 $result = $result . "(auto)";
374 return $result;
376 function StatusString($file)
378 if ( $file->status == 7 ) {
379 return "Paused";
380 } elseif ( $file->src_count_xfer > 0 ) {
381 return "Downloading";
382 } else {
383 return "Waiting";
388 // declare it here, before any function reffered it in "global"
390 $sort_order;$sort_reverse;
392 function my_cmp($a, $b)
394 global $sort_order, $sort_reverse;
396 switch ( $sort_order) {
397 case "size": $result = $a->size > $b->size; break;
398 case "size_done": $result = $a->size_done > $b->size_done; break;
399 case "size_xfer": $result = $a->size_xfer > $b->size_xfer; break;
400 case "progress": $result = (((float)$a->size_done)/((float)$a->size)) > (((float)$b->size_done)/((float)$b->size)); break;
401 case "name": $result = $a->name > $b->name; break;
402 case "speed": $result = $a->speed > $b->speed; break;
403 case "scrcount": $result = $a->src_count > $b->src_count; break;
404 case "status": $result = StatusString($a) > StatusString($b); break;
405 case "prio": $result = PrioString($a) > PrioString($b); break;
408 if ( $sort_reverse ) {
409 $result = !$result;
411 //var_dump($sort_reverse);
412 return $result;
415 if ( ($HTTP_GET_VARS["cmd"] != "") && ($_SESSION["guest_login"] == 0) ) {
416 $name = $HTTP_GET_VARS['file'];
417 if ( strlen($name) == 32 ) {
418 amule_do_download_cmd($name, $HTTP_GET_VARS["cmd"]);
422 $downloads = amule_load_vars("downloads");
424 $sort_order = $HTTP_GET_VARS["sort"];
426 if ( $sort_order == "" ) {
427 $sort_order = $_SESSION["download_sort"];
429 $reverse_sort_key = "download_sort_reverse" . $sort_order;
430 if ( $_SESSION[$reverse_sort_key] == "" ) {
431 $_SESSION[$reverse_sort_key] = 0;
432 } else {
433 if ( $HTTP_GET_VARS["sort"] != '') {
434 $_SESSION[$reverse_sort_key] = !$_SESSION[$reverse_sort_key];
438 //var_dump($_SESSION);
439 $sort_reverse = $_SESSION[$reverse_sort_key];
441 if ( $sort_order != "" ) {
442 $_SESSION["download_sort"] = $sort_order;
443 usort(&$downloads, "my_cmp");
446 foreach ($downloads as $file) {
447 $status = StatusString($file);
448 if ( ($_SESSION['filter_status'] == 'All') || ($_SESSION['filter_status'] == $status) ) {
449 echo '<tr>';
450 $mark = $file->speed > 0 ? 1 : 0;
451 echo '<td valign=top class="', $mark ? 'down-line-good-left':'down-line-left',
452 '"><acronym title="', $file->name, '">', $file->short_name, '</acronym></td>';
453 echo '<td valign=top class="', $mark ? 'down-line-good-right':'down-line-right','">',
454 CastToXBytes($file->size), '</td>';
455 echo '<td valign=top class="', $mark ? 'down-line-good-right':'down-line-right','">',
456 CastToXBytes($file->size_done), '</td>';
457 echo '<td valign=top class="', $mark ? 'down-line-good-right':'down-line-right','">',
458 CastToXBytes($file->size_xfer), '</td>';
460 echo '<td valign=middle class="', $mark ? 'down-line-right">':'down-line">';
461 echo '<table width=200 height=11 border=1 class="percent_table" cellpadding=0 cellspacing=0 bordercolor="#000000">';
462 echo '<tr><td><img src="greenpercent.gif" height=4 width=', (($file->size_done * 1.0)/$file->size)*200 + 1, '><br>';
463 echo $file->progress, '</td></tr></table></td>';
465 echo '<td valign=middle class="', $mark ? 'down-line-good-right">':'down-line-right">',
466 $file->speed ? (CastToXBytes($file->speed) . '/s') : '-', '</td>';
468 // source count
469 echo '<td valign=middle class="', $mark ? 'down-line-good-right">':'down-line-right">';
470 if ( $file->src_count_not_curr != 0 ) {
471 echo $file->src_count - $file->src_count_not_curr, "&nbsp;/&nbsp;";
473 echo $file->src_count, "&nbsp;(", $file->src_count_xfer, ")";
474 if ( $file->src_count_a4af != 0 ) {
475 echo "+", $file->src_count_a4af;
477 echo '</td>';
479 echo '<td valign=middle class="', $mark ? 'down-line-good-right">':'down-line-right">',
480 PrioString($file), '</td>';
482 echo '<td valign=top class="down-line"><acronym title="', $status, '">';
483 echo '<img src="l_info.gif" alt="', $status, '"></acronym>';
485 // commands
486 echo '<acronym title="ED2K Link(s)"><a href="', $file->link, '"><img src="l_ed2klink.gif" alt="ED2K Link(s)"></a></acronym>';
487 if ( $_SESSION["guest_login"] == 0 ) {
488 if ( $file->status == 7 ) {
489 echo '<acronym title="Resume"><a href="?cmd=resume&file=', $file->hash, '"><img src="l_resume.gif" alt="Resume"></a></acronym>';
490 } else {
491 echo '<acronym title="Pause"><a href="?cmd=pause&file=', $file->hash, '"><img src="l_pause.gif" alt="Pause"></a></acronym>';
493 echo '<acronym title="Cancel"><a href="?cmd=cancel&file=', $file->hash,
494 "\" onclick=\"return confirm('Are you sure that you want to cancel and delete this file?')\" ",
495 '><img src="l_cancel.gif" alt="Cancel"></a></acronym>';
496 echo '<acronym title="Increase priority"><a href="?cmd=prioup&file=', $file->hash, '"><img src="l_up.gif" alt="Increase priority"></a></acronym>';
497 echo '<acronym title="Decrease priority"><a href="?cmd=priodown&file=', $file->hash, '"><img src="l_down.gif" alt="Decrease priority"></a></acronym>';
500 echo '</td></tr>', "\n";
505 </table>
506 &nbsp;
507 <table border=0 align=center cellpadding=4 cellspacing=0 width="100%">
508 <tr>
509 <td class="smallheader" colspan=4 style="background-color: #000000"><img src="arrow_up.gif">
510 <b>Uploads
511 <?php
512 $uploads = amule_load_vars("uploads");
513 echo '&nbsp;(', count($uploads), ')';
515 </b></td>
516 </tr>
517 <tr>
518 <td class="up-header-left"><b>Username</b></td>
519 <td class="up-header"><b>File Name</b></td>
520 <td class="up-header"><b>Transferred</b></td>
521 <td class="up-header"><b>Speed</b></td>
522 </tr>
523 <tr>
525 <?php
526 function CastToXBytes($size)
528 if ( $size < 1024 ) {
529 $result = $size . " bytes";
530 } elseif ( $size < 1048576 ) {
531 $result = ($size / 1024.0) . "KB";
532 } elseif ( $size < 1073741824 ) {
533 $result = ($size / 1048576.0) . "MB";
534 } else {
535 $result = ($size / 1073741824.0) . "GB";
537 return $result;
539 $uploads = amule_load_vars("uploads");
540 foreach ($uploads as $file) {
541 echo '<tr>';
542 echo '<td valign=top class="up-line-left"><acronym title="', $file->user_name, '">', $file->user_name, '</acronym></td>';
543 echo '<td valign=top class="up-line-left"><acronym title="', $file->name, '">', $file->short_name, '</acronym></td>';
544 echo '<td valign=top class="up-line">', CastToXBytes($file->xfer_up), "&nbsp;/&nbsp;", CastToXBytes($file->xfer_down), '</td>';
545 echo '<td valign=top class="up-line">', ($file->xfer_speed > 0) ? (CastToXBytes($file->xfer_speed) . "/s") : "-", '</td>';
546 echo '</tr>';
547 echo "\n";
551 </table>
552 &nbsp;
553 <p align=center>
556 &nbsp;
557 </p>
558 </font>
559 </td>
560 </tr>
561 </table></body>
562 </html>