Upstream tarball 10154
[amule.git] / src / webserver / default / amuleweb-main-dload.php
blob6e0b67c9d3d7dd5d937f820c0dc013ffb2aa3c1d
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <title>aMule control panel</title>
5 <?php
6 if ( $_SESSION["auto_refresh"] > 0 ) {
7 echo "<meta http-equiv=\"refresh\" content=\"", $_SESSION["auto_refresh"], '">';
9 ?><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
11 <script language="JavaScript" type="text/JavaScript">
12 <!--
13 function MM_swapImgRestore() { //v3.0
14 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
17 function MM_preloadImages() { //v3.0
18 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
19 var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
20 if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
23 function MM_findObj(n, d) { //v4.01
24 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
25 d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
26 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
27 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
28 if(!x && d.getElementById) x=d.getElementById(n); return x;
31 function MM_swapImage() { //v3.0
32 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
33 if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
36 function MM_nbGroup(event, grpName) { //v6.0
37 var i,img,nbArr,args=MM_nbGroup.arguments;
38 if (event == "init" && args.length > 2) {
39 if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
40 img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
41 if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
42 nbArr[nbArr.length] = img;
43 for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
44 if (!img.MM_up) img.MM_up = img.src;
45 img.src = img.MM_dn = args[i+1];
46 nbArr[nbArr.length] = img;
47 } }
48 } else if (event == "over") {
49 document.MM_nbOver = nbArr = new Array();
50 for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
51 if (!img.MM_up) img.MM_up = img.src;
52 img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
53 nbArr[nbArr.length] = img;
55 } else if (event == "out" ) {
56 for (i=0; i < document.MM_nbOver.length; i++) {
57 img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
58 } else if (event == "down") {
59 nbArr = document[grpName];
60 if (nbArr)
61 for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
62 document[grpName] = nbArr = new Array();
63 for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
64 if (!img.MM_up) img.MM_up = img.src;
65 img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
66 nbArr[nbArr.length] = img;
67 } }
69 //-->
70 </script>
72 <link href="style.css" rel="stylesheet" type="text/css">
73 <style type="text/css">
74 <!--
75 caption {
76 font-family: Helvetica;
77 font-size: 18px;
78 font-weight: bold;
79 color: #003161;
81 th {
82 font-family: Helvetica;
83 font-size: 14px;
84 font-height: 22px;
85 font-weight: bold;
86 color: #003161;
88 a:link {
89 color: #003161;
90 text-decoration: none;
92 a:active {
93 color: #003161;
94 text-decoration: none;
96 a:visited {
97 color: #003161;
98 text-decoration: none;
100 a:hover {
101 color: #c0c0c0;
102 text-decoration: underline;
104 td {
105 font-family: Helvetica;
106 font-size: 12px;
107 font-weight: normal;
109 label {
110 font-family: Helvetica;
111 font-size: 14px;
112 font-weight: bold;
114 .texte {
115 font-family: Helvetica;
116 font-size: 12px;
117 font-weight: normal;
119 label {
120 font-family:"trebuchet ms",sans-serif;
121 font-size: 12px;
122 font-weight:bold
124 input {
125 border:1px solid #003161;
126 background-color: white;
127 font-family:"trebuchet ms",sans-serif;
128 font-size: 12px;
129 color: #003161;
131 select, option {
132 background-color: white;
133 font-size: 12px;
134 color: #003161;
136 textarea {
137 border:1px solid #003161;
138 background-color: #90B6DB;
139 font-family:"trebuchet ms",sans-serif;
140 font-size: 12px;
141 color: white;
144 </style>
145 </head><script language="JavaScript" type="text/JavaScript">
146 function formCommandSubmit(command)
148 if ( command == "cancel" ) {
149 var res = confirm("Delete selected files ?")
150 if ( res == false ) {
151 return;
154 if ( command != "filter" ) {
155 <?php
156 if ($_SESSION["guest_login"] != 0) {
157 echo 'alert("You logged in as guest - commands are disabled");';
158 echo "return;";
162 var frm=document.forms.mainform
163 frm.command.value=command
164 frm.submit()
167 </script>
168 <body background="images/fond.gif" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('images/transf_1.png','images/shared_1.png','images/search_1.png','images/edkserv_1.png','images/sheserv_1.png','images/stats_1.png')">
169 <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
170 <tr valign="top">
171 <td width="143" height="64"><img src="images/logo.png" width="143" height="64"></td>
172 <td width="100%" height="64" align="right" background="images/fond_haut.png"> <table border="0" cellspacing="0" cellpadding="0">
173 <tr>
174 <td><a href="amuleweb-main-dload.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('transfert','','images/transf_1.png',1)"><img src="images/transf_0.png" alt="transfert" name="transfert" width="52" height="50" border="0"></a></td>
175 <td><a href="amuleweb-main-shared.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('shared','','images/shared_1.png',1)"><img src="images/shared_0.png" alt="shared" name="shared" width="52" height="50" border="0"></a></td>
176 <td><a href="amuleweb-main-search.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('search','','images/search_1.png',1)"><img src="images/search_0.png" alt="search" name="search" width="52" height="50" border="0"></a></td>
177 <td><a href="amuleweb-main-servers.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('edkserver','','images/edkserv_1.png',1)"><img src="images/edkserv_0.png" alt="edkserver" name="edkserver" width="52" height="50" border="0"></a></td>
178 <td><a href="amuleweb-main-kad.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('sheserv','','images/sheserv_1.png',1)"><img src="images/sheserv_0.png" alt="sheserv" name="sheserv" width="52" height="50" border="0"></a></td>
179 <td><a href="amuleweb-main-stats.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('statistiques','','images/stats_1.png',1)"><img src="images/stats_0.png" alt="statistiques" name="statistiques" width="52" height="50" border="0"></a></td>
180 <td><img src="images/col.png"></td>
181 <td width="10"></td>
182 <td width="190" align="right" class="texteinv"><a href="login.php">exit</a><br>
183 <a href="amuleweb-main-log.php">log &bull;</a> <a href="amuleweb-main-prefs.php">configuration</a>
184 </td>
185 <td width="10"></td>
186 </tr>
187 </table></td>
188 </tr>
189 <tr align="center" valign="top">
190 <td colspan="2"><form action="amuleweb-main-dload.php" method="post" name="mainform">
191 <table width="100%" border="0" cellpadding="0" cellspacing="0">
192 <tr>
193 <td align="center"><table border="0" cellpadding="0" cellspacing="0">
194 <tr>
195 <td><input type="hidden" name="command"></td>
196 <td><a href="javascript:formCommandSubmit('pause');" onClick="MM_nbGroup('down','group1','pause','',1)" onMouseOver="MM_nbGroup('over','pause','','',1)" onMouseOut="MM_nbGroup('out')"><img name="pause" src="images/pause.png" alt="pause" border="0" onLoad=""></a></td>
197 <td><a href="javascript:formCommandSubmit('resume');" onClick="MM_nbGroup('down','group1','resume','',1)" onMouseOver="MM_nbGroup('over','resume','','',1)" onMouseOut="MM_nbGroup('out')"><img img name="resume" src="images/play.png" alt="resume" border="0" onLoad=""></a></td>
198 <td><a href="javascript:formCommandSubmit('prioup');" onClick="MM_nbGroup('down','group1','up','',1)" onMouseOver="MM_nbGroup('over','up','','',1)" onMouseOut="MM_nbGroup('out')"><img img name="prioup" src="images/up.png" alt="prioup" border="0" onLoad=""></a></td>
199 <td><a href="javascript:formCommandSubmit('priodown');" onClick="MM_nbGroup('down','group1','down','',1)" onMouseOver="MM_nbGroup('over','down','','',1)" onMouseOut="MM_nbGroup('out')"><img img name="priodown" src="images/down.png" alt="priodown" border="0" onLoad=""></a></td>
200 <td><a href="javascript:formCommandSubmit('cancel');" onClick="MM_nbGroup('down','group1','cancel','',1)" onMouseOver="MM_nbGroup('over','delete','','',1)" onMouseOut="MM_nbGroup('out')"><img img name="cancel" src="images/close.png" alt="cancel" border="0" onLoad=""></a></td>
201 <td><table border="0" cellpadding="0" cellspacing="0">
202 <tr>
203 <td>
204 <?php
205 $all_status = array("all", "Waiting", "Paused", "Downloading");
206 if ( $HTTP_GET_VARS["command"] == "filter") {
207 $_SESSION["filter_status"] = $HTTP_GET_VARS["status"];
208 $_SESSION["filter_cat"] = $HTTP_GET_VARS["category"];
210 if ( $_SESSION["filter_status"] == '') $_SESSION["filter_status"] = 'all';
211 if ( $_SESSION["filter_cat"] == '') $_SESSION["filter_cat"] = 'all';
213 echo '<select name="status"> ';
214 foreach ($all_status as $s) {
215 echo (($s == $_SESSION["filter_status"]) ? '<option selected>' : '<option>'), $s, '</option>';
217 echo '</select>';
218 //var_dump($_SESSION["filter_cat"]);
219 echo '<select name="category" id="category">';
220 $cats = amule_get_categories();
221 foreach($cats as $c) {
222 echo (($c == $_SESSION["filter_cat"]) ? '<option selected>' : '<option>'), $c, '</option>';
224 echo '</select>';
226 </td>
227 <td><a href="javascript:formCommandSubmit('filter');" onClick="MM_nbGroup('down','group1','resume','',1)" onMouseOver="MM_nbGroup('over','resume','','',1)" onMouseOut="MM_nbGroup('out')"><img src="images/filter.png" border="0" alt="Apply" name="resume" border="0" onload=""></a></td>
228 <td>&nbsp;</td>
229 <td>&nbsp;</td>
230 <td>
231 <?php
232 if ($_SESSION["guest_login"] != 0) {
233 echo "<b>&nbsp;You logged in as guest - commands are disabled</b>";
236 </td>
237 </tr>
238 </table></td>
239 </tr>
240 </table></td>
241 </tr>
242 <tr>
243 <td height="10" align="center"> </td>
244 </tr>
245 <tr>
246 <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <caption>
247 DOWNLOAD
248 </caption>
249 <tr>
250 <td width="24"><img src="images/tab_top_left.png" width="24" height="24"></td>
251 <td background="images/tab_top.png">&nbsp;</td>
252 <td width="24"><img src="images/tab_top_right.png" width="24" height="24"></td>
253 </tr>
254 <tr>
255 <td width="24" background="images/tab_left.png">&nbsp;</td>
256 <td bgcolor="#FFFFFF"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
258 <tr>
259 <th>&nbsp;</th>
260 <th><a href="amuleweb-main-dload.php?sort=name">File name</a></th>
261 <th><a href="amuleweb-main-dload.php?sort=size">Size</a></th>
262 <th><a href="amuleweb-main-dload.php?sort=size_done">Completed</a></th>
263 <th><a href="amuleweb-main-dload.php?sort=speed">Download speed</a></th>
264 <th><a href="amuleweb-main-dload.php?sort=progress">Progress</a></th>
265 <th><a href="amuleweb-main-dload.php?sort=srccount">Sources</a></th>
266 <th><a href="amuleweb-main-dload.php?sort=status">Status</a></th>
267 <th><a href="amuleweb-main-dload.php?sort=prio">Priority</a></th>
268 </tr><tr><td colspan="9" height="1" bgcolor="#000000"></td></tr>
269 <?php
270 function CastToXBytes($size)
272 if ( $size < 1024 ) {
273 $result = $size . " b";
274 } elseif ( $size < 1048576 ) {
275 $result = ($size / 1024.0) . " kb";
276 } elseif ( $size < 1073741824 ) {
277 $result = ($size / 1048576.0) . " mb";
278 } else {
279 $result = ($size / 1073741824.0) . " gb";
281 return $result;
284 function StatusString($file)
286 if ( $file->status == 7 ) {
287 return "Paused";
288 } elseif ( $file->src_count_xfer > 0 ) {
289 return "Downloading";
290 } else {
291 return "Waiting";
295 function PrioString($file)
297 $prionames = array(0 => "Low", 1 => "Normal", 2 => "High",
298 3 => "Very high", 4 => "Very low", 5=> "Auto", 6 => "Release");
299 $result = $prionames[$file->prio];
300 if ( $file->prio_auto == 1) {
301 $result = $result . "(auto)";
303 return $result;
307 // declare it here, before any function reffered it in "global"
309 $sort_order;$sort_reverse;
311 function my_cmp($a, $b)
313 global $sort_order, $sort_reverse;
315 switch ( $sort_order) {
316 case "size": $result = $a->size > $b->size; break;
317 case "size_done": $result = $a->size_done > $b->size_done; break;
318 case "progress": $result = (((float)$a->size_done)/((float)$a->size)) > (((float)$b->size_done)/((float)$b->size)); break;
319 case "name": $result = $a->name > $b->name; break;
320 case "speed": $result = $a->speed > $b->speed; break;
321 case "scrcount": $result = $a->src_count > $b->src_count; break;
322 case "status": $result = StatusString($a) > StatusString($b); break;
323 case "prio": $result = $a->prio < $b->prio; break;
326 if ( $sort_reverse ) {
327 $result = !$result;
329 //var_dump($sort_reverse);
330 return $result;
334 // perform command before processing content
336 if ( ($HTTP_GET_VARS["command"] != "") && ($_SESSION["guest_login"] == 0) ) {
337 foreach ( $HTTP_GET_VARS as $name => $val) {
338 // this is file checkboxes
339 if ( (strlen($name) == 32) and ($val == "on") ) {
340 //var_dump($name);
341 amule_do_download_cmd($name, $HTTP_GET_VARS["command"]);
345 // check "filter-by-status" settings
347 if ( $HTTP_GET_VARS["command"] == "filter") {
348 //var_dump($_SESSION);
349 $_SESSION["filter_status"] = $HTTP_GET_VARS["status"];
350 $_SESSION["filter_cat"] = $HTTP_GET_VARS["category"];
353 if ( $_SESSION["filter_status"] == "") $_SESSION["filter_status"] = "all";
354 if ( $_SESSION["filter_cat"] == "") $_SESSION["filter_cat"] = "all";
356 $downloads = amule_load_vars("downloads");
358 $sort_order = $HTTP_GET_VARS["sort"];
360 if ( $sort_order == "" ) {
361 $sort_order = $_SESSION["download_sort"];
362 } else {
363 if ( $_SESSION["download_sort_reverse"] == "" ) {
364 $_SESSION["download_sort_reverse"] = 0;
365 } else {
366 if ( $HTTP_GET_VARS["sort"] != '') {
367 $_SESSION["download_sort_reverse"] = !$_SESSION["download_sort_reverse"];
371 //var_dump($_SESSION);
372 $sort_reverse = $_SESSION["download_sort_reverse"];
373 if ( $sort_order != "" ) {
374 $_SESSION["download_sort"] = $sort_order;
375 usort(&$downloads, "my_cmp");
379 // Prepare categories index array
380 $cats = amule_get_categories();
381 foreach($cats as $i => $c) {
382 $cat_idx[$c] = $i;
385 foreach ($downloads as $file) {
386 $filter_status_result = ($_SESSION["filter_status"] == "all") or
387 ($_SESSION["filter_status"] == StatusString($file));
389 $filter_cat_result = ($_SESSION["filter_cat"] == "all") or
390 ($cat_idx[ $_SESSION["filter_cat"] ] == $file->category);
392 if ( $filter_status_result and $filter_cat_result) {
393 print "<tr>";
395 echo "<td class='texte' height='22'>", '<input type="checkbox" name="', $file->hash, '" >', "</td>";
397 echo "<td class='texte' height='22'>", $file->short_name, "</td>";
399 echo "<td class='texte' height='22' align='center'>", CastToXBytes($file->size), "</td>";
401 echo "<td class='texte' height='22' align='center'>", CastToXBytes($file->size_done), "&nbsp;(",
402 ((float)$file->size_done*100)/((float)$file->size), "%)</td>";
404 echo "<td class='texte' height='22' align='center'>", ($file->speed > 0) ? (CastToXBytes($file->speed) . "/s") : "-", "</td>";
406 echo "<td class='texte' height='22' align='center' align='center'>", $file->progress, "</td>";
408 echo "<td class='texte' height='22' align='center'>";
409 if ( $file->src_count_not_curr != 0 ) {
410 echo $file->src_count - $file->src_count_not_curr, " / ";
412 echo $file->src_count, " ( ", $file->src_count_xfer, " ) ";
413 if ( $file->src_count_a4af != 0 ) {
414 echo "+ ", $file->src_count_a4af;
416 echo "</td>";
418 echo "<td class='texte' height='22' align='center'>", StatusString($file), "</td>";
420 echo "<td class='texte' height='22' align='center'>", PrioString($file), "</td>";
422 print "</tr><tr><td colspan='9' height='1' bgcolor='#c0c0c0'></td></tr>";
426 </table></td>
427 <td width="24" background="images/tab_right.png">&nbsp;</td>
428 </tr>
429 <tr>
430 <td width="24"><img src="images/tab_bottom_left.png" width="24" height="24"></td>
431 <td background="images/tab_bottom.png">&nbsp;</td>
432 <td width="24"><img src="images/tab_bottom_right.png" width="24" height="24"></td>
433 </tr>
434 </table></td>
435 </tr>
436 </table>
437 </form>
438 <table width="100%" border="0" cellspacing="0" cellpadding="0"><caption>
439 UPLOAD
440 </caption>
441 <tr>
442 <td width="24"><img src="images/tab_top_left.png" width="24" height="24"></td>
443 <td background="images/tab_top.png">&nbsp;</td>
444 <td width="24"><img src="images/tab_top_right.png" width="24" height="24"></td>
445 </tr>
446 <tr>
447 <td width="24" background="images/tab_left.png">&nbsp;</td>
448 <td bgcolor="#FFFFFF"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="doad-table">
450 <tr>
451 <td>&nbsp;</td>
452 <th>File Name</th>
453 <th>Username</th>
454 <th>Up</th>
455 <th>Down</th>
456 <th>&nbsp;</th>
457 <th>&nbsp;</th>
458 <th>Speed</th>
459 <td>&nbsp;</td>
460 </tr><tr><td colspan="9" height="1" bgcolor="#000000"></td></tr>
461 <?php
462 function CastToXBytes($size)
464 if ( $size < 1024 ) {
465 $result = $size . " b";
466 } elseif ( $size < 1048576 ) {
467 $result = ($size / 1024.0) . " kb";
468 } elseif ( $size < 1073741824 ) {
469 $result = ($size / 1048576.0) . " mb";
470 } else {
471 $result = ($size / 1073741824.0) . " gb";
473 return $result;
475 $uploads = amule_load_vars("uploads");
476 foreach ($uploads as $file) {
477 echo "<tr>";
479 echo "<td class='texte' height='22' align='center'>", "</td>";
481 echo "<td class='texte' height='22'>", $file->short_name, "</td>";
483 echo "<td class='texte' height='22' align='center'>", $file->user_name, "</td>";
485 echo "<td class='texte' height='22' align='center'>", CastToXBytes($file->xfer_up), "</td>";
486 echo "<td class='texte' height='22' align='center'>", CastToXBytes($file->xfer_down), "</td>";
487 echo "<td class='texte' height='22' align='center'>", "</td>";
488 echo "<td class='texte' height='22' align='center'>", "</td>";
489 echo "<td class='texte' height='22' align='center'>", ($file->xfer_speed > 0) ? (CastToXBytes($file->xfer_speed) . "/s") : "-", "</td>";
490 echo "<td class='texte' height='22' align='center'>", "</td>";
491 echo "</tr><tr><td colspan='9' height='1' bgcolor='#c0c0c0'></td></tr>";
494 </table></td>
495 <td width="24" background="images/tab_right.png">&nbsp;</td>
496 </tr>
497 <tr>
498 <td width="24"><img src="images/tab_bottom_left.png" width="24" height="24"></td>
499 <td background="images/tab_bottom.png">&nbsp;</td>
500 <td width="24"><img src="images/tab_bottom_right.png" width="24" height="24"></td>
501 </tr>
502 </table>
504 </td>
505 </tr>
506 <tr valign="bottom">
507 <td height="25" colspan="2"> <table width="100%" height="40" border="0" cellpadding="0" cellspacing="0">
508 <tr align="center" valign="middle">
509 <td width="50%"> <iframe name="stats" src="footer.php" height="35" width="100%" scrolling="no" frameborder="0">ed2klink</iframe>
510 </td>
511 <td width="50%"> <iframe name="stats" src="stats.php" height="35" width="100%" scrolling="no" frameborder="0">connection</iframe>
512 </td>
513 </tr>
514 </table></td>
515 </tr>
516 </table>
517 </body>
518 </html>