Improve speed of category tab title updates
[amule.git] / src / webserver / default / amuleweb-main-shared.php
blobca500a1deed686ac3c06c7a8b5997e1338d54fa3
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <title>aMule control panel</title>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
7 <script language="JavaScript" type="text/JavaScript">
8 <!--
9 function MM_swapImgRestore() { //v3.0
10 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
13 function MM_preloadImages() { //v3.0
14 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
15 var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
16 if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
19 function MM_findObj(n, d) { //v4.01
20 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
21 d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
22 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
23 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
24 if(!x && d.getElementById) x=d.getElementById(n); return x;
27 function MM_swapImage() { //v3.0
28 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
29 if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
32 function MM_nbGroup(event, grpName) { //v6.0
33 var i,img,nbArr,args=MM_nbGroup.arguments;
34 if (event == "init" && args.length > 2) {
35 if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
36 img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
37 if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
38 nbArr[nbArr.length] = img;
39 for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
40 if (!img.MM_up) img.MM_up = img.src;
41 img.src = img.MM_dn = args[i+1];
42 nbArr[nbArr.length] = img;
43 } }
44 } else if (event == "over") {
45 document.MM_nbOver = nbArr = new Array();
46 for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
47 if (!img.MM_up) img.MM_up = img.src;
48 img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
49 nbArr[nbArr.length] = img;
51 } else if (event == "out" ) {
52 for (i=0; i < document.MM_nbOver.length; i++) {
53 img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
54 } else if (event == "down") {
55 nbArr = document[grpName];
56 if (nbArr)
57 for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
58 document[grpName] = nbArr = new Array();
59 for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
60 if (!img.MM_up) img.MM_up = img.src;
61 img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
62 nbArr[nbArr.length] = img;
63 } }
65 //-->
66 </script>
67 <link href="style.css" rel="stylesheet" type="text/css"><style type="text/css">
68 <!--
69 caption {
70 font-family: Helvetica;
71 font-size: 18px;
72 font-weight: bold;
73 color: #003161;
75 th {
76 font-family: Helvetica;
77 font-size: 14px;
78 font-height: 22px;
79 font-weight: bold;
80 color: #003161;
82 a:link {
83 color: #003161;
84 text-decoration: none;
86 a:active {
87 color: #003161;
88 text-decoration: none;
90 a:visited {
91 color: #003161;
92 text-decoration: none;
94 a:hover {
95 color: #c0c0c0;
96 text-decoration: underline;
98 td {
99 font-family: Helvetica;
100 font-size: 12px;
101 font-weight: normal;
103 label {
104 font-family: Helvetica;
105 font-size: 14px;
106 font-weight: bold;
108 .texte {
109 font-family: Helvetica;
110 font-size: 12px;
111 font-weight: normal;
113 label {
114 font-family:"trebuchet ms",sans-serif;
115 font-size: 12px;
116 font-weight:bold
118 input {
119 border:1px solid #003161;
120 background-color: white;
121 font-family:"trebuchet ms",sans-serif;
122 font-size: 12px;
123 color: #003161;
125 select, option {
126 background-color: white;
127 font-size: 12px;
128 color: #003161;
130 textarea {
131 border:1px solid #003161;
132 background-color: #90B6DB;
133 font-family:"trebuchet ms",sans-serif;
134 font-size: 12px;
135 color: white;
138 </style>
139 </head><script language="JavaScript" type="text/JavaScript">
140 function formCommandSubmit(command)
142 <?php
143 if ($_SESSION["guest_login"] != 0) {
144 echo 'alert("You logged in as guest - commands are disabled");';
145 echo "return;";
148 var frm=document.forms.mainform
149 frm.command.value=command
150 frm.submit()
153 </script>
154 <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');">
155 <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
156 <tr valign="top">
157 <td width="143" height="64"><img src="images/logo.png" width="143" height="64"></td>
158 <td width="100%" height="64" align="right" background="images/fond_haut.png"> <table border="0" cellspacing="0" cellpadding="0">
159 <tr>
160 <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>
161 <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>
162 <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>
163 <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>
164 <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>
165 <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>
166 <td><img src="images/col.png"></td>
167 <td width="10"></td>
168 <td width="190" align="right" class="texteinv"><a href="login.php">exit</a><br>
169 <a href="amuleweb-main-log.php">log &bull;</a> <a href="amuleweb-main-prefs.php">configuration</a></td>
170 <td width="10"></td>
171 </tr>
172 </table></td>
173 </tr>
174 <tr align="center" valign="top">
175 <td colspan="2"><form name="mainform" action="amuleweb-main-shared.php" method="post">
176 <table border="0" align="center" cellpadding="0" cellspacing="0">
177 <tr>
178 <td><input type="hidden" name="command"></td>
180 <td><a href="javascript:formCommandSubmit('reload');" onClick="MM_nbGroup('down','group1','reload','',1)" onMouseOver="MM_nbGroup('over','reload','','',1)" onMouseOut="MM_nbGroup('out')"><img src="images/refresh.png" alt="Ricarica Files Condivisi" name="reload" border="0" onload=""></a></td>
181 <td><a href="javascript:formCommandSubmit('prioup');" onClick="MM_nbGroup('down','group1','up','',1)" onMouseOver="MM_nbGroup('over','up','','',1)" onMouseOut="MM_nbGroup('out')"><img name="up" src="images/up.png" border="0" alt="Alza Priorità" onLoad=""></a></td>
183 <td><a href="javascript:formCommandSubmit('priodown');" onClick="MM_nbGroup('down','group1','down','',1)" onMouseOver="MM_nbGroup('over','down','','',1)" onMouseOut="MM_nbGroup('out')"><img src="images/down.png" alt="Abbassa Priorità" name="down" border="0" onload=""></a></td>
184 <td><select name="select">
185 <option selected>Select prio</option>
186 <option>Low</option>
187 <option>Normal</option>
188 <option>High</option>
189 </select> </td>
191 <td><a href="javascript:formCommandSubmit('setprio');" onClick="MM_nbGroup('down','group1','resume','',1)" onMouseOver="MM_nbGroup('over','resume','','',1)" onMouseOut="MM_nbGroup('out')"><img src="images/ok.png" alt="Imposta Priorità" name="resume" border="0" onload=""></a></td>
193 <td>
194 <?php
195 if ($_SESSION["guest_login"] != 0) {
196 echo "<b>&nbsp;You logged in as guest - commands are disabled</b>";
199 </td>
200 </tr>
201 </table>
202 <table width="100%" border="0" cellspacing="0" cellpadding="0">
203 <caption>
204 SHARED FILES
205 </caption>
206 <tr>
207 <td width="24"><img src="images/tab_top_left.png" width="24" height="24"></td>
208 <td background="images/tab_top.png">&nbsp;</td>
209 <td width="24"><img src="images/tab_top_right.png" width="24" height="24"></td>
210 </tr>
211 <tr>
212 <td width="24" background="images/tab_left.png">&nbsp;</td>
214 <td bgcolor="#FFFFFF">
215 <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
216 <tr>
217 <th></th>
218 <th><a href="amuleweb-main-shared.php?sort=name">File Name</a></th>
219 <th><a href="amuleweb-main-shared.php?sort=xfer">Transferred</a>
220 (<a href="amuleweb-main-shared.php?sort=xfer_all">Total</a>)</th>
221 <th><a href="amuleweb-main-shared.php?sort=req">Requested</a>
222 (<a href="amuleweb-main-shared.php?sort=req_all">Total</a>)</th>
223 <th><a href="amuleweb-main-shared.php?sort=acc">Accepted requests</a>
224 (<a href="amuleweb-main-shared.php?sort=acc_all">Total</a>)</th>
225 <th><a href="amuleweb-main-shared.php?sort=size">Size</a></th>
226 <th><a href="amuleweb-main-shared.php?sort=prio">Priority</a></th>
227 </tr><tr><td colspan="9" height="1" bgcolor="#000000"></td></tr>
228 <?php
229 function CastToXBytes($size)
231 if ( $size < 1024 ) {
232 $result = $size . " bytes";
233 } elseif ( $size < 1048576 ) {
234 $result = ($size / 1024.0) . "KB";
235 } elseif ( $size < 1073741824 ) {
236 $result = ($size / 1048576.0) . "MB";
237 } else {
238 $result = ($size / 1073741824.0) . "GB";
240 return $result;
243 function StatusString($file)
245 if ( $file->status == 7 ) {
246 return "Paused";
247 } elseif ( $file->src_count_xfer > 0 ) {
248 return "Downloading";
249 } else {
250 return "Waiting";
254 function PrioString($file)
256 $prionames = array(0 => "Low", 1 => "Normal", 2 => "High",
257 3 => "Very high", 4 => "Very low", 5=> "Auto", 6 => "Release");
258 $result = $prionames[$file->prio];
259 if ( $file->prio_auto == 1) {
260 $result = $result . "(auto)";
262 return $result;
265 function PrioSort($file) {
266 // Very low (4) has a too high number
267 if (4 == $file->prio) {
268 return 0;
270 return $file->prio+1;
274 // declare it here, before any function reffered it in "global"
276 $sort_order;$sort_reverse;
278 function my_cmp($a, $b)
280 global $sort_order, $sort_reverse;
282 switch ( $sort_order) {
283 case "size": $result = $a->size > $b->size; break;
284 case "name": $result = $a->name > $b->name; break;
285 case "xfer": $result = $a->xfer > $b->xfer; break;
286 case "xfer_all": $result = $a->xfer_all > $b->xfer_all; break;
287 case "acc": $result = $a->accept > $b->accept; break;
288 case "acc_all": $result = $a->accept_all > $b->accept_all; break;
289 case "req": $result = $a->req > $b->req; break;
290 case "req_all": $result = $a->req_all > $b->req_all; break;
291 case "prio": $result = PrioSort($a) < PrioSort($b); break;
294 if ( $sort_reverse ) {
295 $result = !$result;
297 //var_dump($sort_reverse);
298 return $result;
302 // perform command before processing content
304 //var_dump($HTTP_GET_VARS);
305 if (($HTTP_GET_VARS["command"] != "") && ($_SESSION["guest_login"] == 0)) {
306 //amule_do_download_cmd($HTTP_GET_VARS["command"]);
307 foreach ( $HTTP_GET_VARS as $name => $val) {
308 // this is file checkboxes
309 if ( (strlen($name) == 32) and ($val == "on") ) {
310 //var_dump($name);var_dump($val);
311 amule_do_shared_cmd($name, $HTTP_GET_VARS["command"]);
314 if ($HTTP_GET_VARS["command"] == "reload") {
315 amule_do_reload_shared_cmd();
318 $shared = amule_load_vars("shared");
320 $sort_order = $HTTP_GET_VARS["sort"];
322 if ( $sort_order == "" ) {
323 $sort_order = $_SESSION["shared_sort"];
324 } else {
325 if ( $_SESSION["sort_reverse"] == "" ) {
326 $_SESSION["sort_reverse"] = 0;
327 } else {
328 $_SESSION["sort_reverse"] = !$_SESSION["sort_reverse"];
331 //var_dump($_SESSION);
332 $sort_reverse = $_SESSION["sort_reverse"];
333 if ( $sort_order != "" ) {
334 $_SESSION["shared_sort"] = $sort_order;
335 usort(&$shared, "my_cmp");
338 foreach ($shared as $file) {
339 print "<tr>";
341 echo "<td class='texte'>", '<input type="checkbox" name="', $file->hash, '" >', "</td>";
343 echo "<td class='texte'>", $file->short_name, "</td>";
344 echo "<td class='texte' align='center'>", CastToXBytes($file->xfer), " (", CastToXBytes($file->xfer_all),")</td>";
346 echo "<td class='texte' align='center'>", $file->req, " (", $file->req_all, ")</td>";
347 echo "<td class='texte' align='center'>", $file->accept, " (", $file->accept_all, ")</td>";
349 echo "<td class='texte' align='center'>", CastToXBytes($file->size), "</td>";
351 echo "<td class='texte' align='center'>", PrioString($file), "</td>";;
353 print "</tr><tr><td colspan='9' height='1' bgcolor='#c0c0c0'></td></tr>";
356 </table></td>
357 <td width="24" background="images/tab_right.png">&nbsp;</td>
358 </tr>
359 <tr>
360 <td width="24"><img src="images/tab_bottom_left.png" width="24" height="24"></td>
361 <td background="images/tab_bottom.png">&nbsp;</td>
362 <td width="24"><img src="images/tab_bottom_right.png" width="24" height="24"></td>
363 </tr>
364 </table></form></td>
365 </tr>
366 <tr valign="bottom">
367 <td height="25" colspan="2"> <table width="100%" height="40" border="0" cellpadding="0" cellspacing="0">
368 <tr align="center" valign="middle">
369 <td width="50%"> <iframe name="stats" src="footer.php" height="35" width="100%" scrolling="no" frameborder="0">edklink</iframe>
370 </td>
371 <td width="50%"> <iframe name="stats" src="stats.php" height="35" width="100%" scrolling="no" frameborder="0">connection</iframe>
372 </td>
373 </tr>
374 </table></td>
375 </tr>
376 </table>
377 </body>
378 </html>