Upstream tarball 20080304
[amule.git] / src / webserver / php-default / amuleweb-main-servers.php
blob7f366ac47771f4655cfa632acca79f2570f93226
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3 <html>
4 <head>
5 <title>amule download page</title>
6 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
7 <style type="text/css">
8 <!--
9 body {
10 margin-left: 0px;
11 margin-top: 0px;
12 margin-right: 0px;
13 margin-bottom: 0px;
14 background-color: #003399;
16 .tbl_header {
18 -->
19 </style></head>
21 <body>
22 <table width="100%" border="1" bgcolor="#0099CC">
23 <tr>
24 <td height="20">&nbsp;</td>
25 </tr>
26 <tr>
27 <td><table width="100%" border="0" align="left" cellspacing="1">
28 <tr>
29 <th width="33" scope="col"></th>
30 <th width="172" ><div align="left"><a href="amuleweb-main-servers.php?sort=name" target="mainFrame">Name</a></div></th>
31 <th width="227" ><div align="left">
32 <div align="left"><a href="amuleweb-main-servers.php?sort=desc" target="mainFrame">Description</a></div></th>
33 <th width="149" scope="col"><div align="left">
34 <div align="left">Address</div></th>
35 <th width="77" scope="col"><div align="left"><a href="amuleweb-main-servers.php?sort=users" target="mainFrame">Users</a></div></th>
36 <th width="80" scope="col"><div align="left"><a href="amuleweb-main-servers.php?sort=maxusers" target="mainFrame">Max Users</a> </div></th>
37 <th width="37" scope="col"><div align="left"><a href="amuleweb-main-servers.php?sort=files" target="mainFrame">Files</a></div></th>
38 </tr>
40 <?php
44 // declare it here, before any function reffered it in "global"
46 $sort_order;$sort_reverse;
48 function my_cmp($a, $b)
50 global $sort_order, $sort_reverse;
51 switch ( $sort_order) {
52 case "name": $result = $a->name > $b->name; break;
53 case "desc": $result = $a->desc > $b->desc; break;
54 case "users": $result = $a->users > $b->users; break;
55 case "max_users": $result = $a->maxusers > $b->maxusers; break;
56 case "files":$result = $a->files > $b->files; break;
59 if ( $sort_reverse ) {
60 $result = !$result;
62 return $result;
65 $servers = amule_load_vars("servers");
67 $sort_order = $HTTP_GET_VARS["sort"];
70 // perform command before processing content
72 if ( ($HTTP_GET_VARS["cmd"] != "") and ($HTTP_GET_VARS["ip"] != "") and ($HTTP_GET_VARS["port"] != "")) {
73 if ($_SESSION["guest_login"] == 0) {
74 amule_do_server_cmd($HTTP_GET_VARS["ip"], $HTTP_GET_VARS["port"], $HTTP_GET_VARS["cmd"]);
78 if ( $sort_order == "" ) {
79 $sort_order = $_SESSION["servers_sort"];
80 } else {
81 if ( $_SESSION["sort_reverse"] == "" ) {
82 $_SESSION["sort_reverse"] = 0;
83 } else {
84 $_SESSION["sort_reverse"] = !$_SESSION["sort_reverse"];
88 $sort_reverse = $_SESSION["sort_reverse"];
89 if ( $sort_order != "" ) {
90 $_SESSION["servers_sort"] = $sort_order;
91 usort(&$servers, "my_cmp");
93 foreach ($servers as $srv) {
94 echo "<tr>";
96 if ($_SESSION["guest_login"] != 0) {
97 echo "<td></td>";
98 } else {
99 echo "<td>",
100 '<a href="amuleweb-main-servers.php?cmd=connect&ip=', $srv->ip,
101 '&port=', $srv->port, '" target="mainFrame">',
102 '<img src="connect.gif" width="16" height="16" border="0">','</a>',
103 '<a href="amuleweb-main-servers.php?cmd=remove&ip=', $srv->ip,
104 '&port=', $srv->port, '" target="mainFrame">',
105 '<img src="cancel.gif" width="16" height="16" border="0">','</a>',
106 "</td>";
109 echo "<td>", $srv->name, "</td>";
110 echo "<td>", $srv->desc, "</td>";
111 echo "<td>", $srv->addr, "</td>";
112 echo "<td>", $srv->users, "</td>";
113 echo "<td>", $srv->maxusers, "</td>";
114 echo "<td>", $srv->files, "</td>";
116 echo "</tr>";
119 </table></td>
120 </tr>
121 </table>
122 </body>
123 </html>