PageRenderTime 19ms CodeModel.GetById 2ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 1ms

/src/webserver/default/amuleweb-main-servers.php

https://bitbucket.org/gzf/umule
PHP | 248 lines | 224 code | 17 blank | 7 comment | 34 complexity | a0dd8d57a1dbf757512d460052b6c602 MD5 | raw file
  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">
  6
  7<script language="JavaScript" type="text/JavaScript">
  8<!--
  9function 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;
 11}
 12
 13function 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];}}
 17}
 18
 19function 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;
 25}
 26
 27function 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];}
 30}
 31//-->
 32</script>
 33<link href="style.css" rel="stylesheet" type="text/css"><style type="text/css">
 34<!--
 35caption {
 36	font-family: Helvetica;
 37	font-size: 18px;
 38	font-weight: bold;
 39	color: #003161;
 40}
 41th {
 42	font-family: Helvetica;
 43	font-size: 14px;
 44	font-height: 22px;
 45	font-weight: bold;
 46	color: #003161;
 47}
 48a:link {
 49	color: #003161;
 50	text-decoration: none;
 51}
 52a:active {
 53	color: #003161;
 54	text-decoration: none;
 55}
 56a:visited {
 57	color: #003161;
 58	text-decoration: none;
 59}
 60a:hover {
 61	color: #c0c0c0;
 62	text-decoration: underline;
 63}
 64td {
 65	font-family: Helvetica;
 66	font-size: 12px;
 67	font-weight: normal;
 68}
 69label {
 70	font-family: Helvetica;
 71	font-size: 14px;
 72	font-weight: bold;
 73}
 74.texte {
 75	font-family: Helvetica;
 76	font-size: 12px;
 77	font-weight: normal;
 78}
 79label {
 80font-family:"trebuchet ms",sans-serif;
 81font-size: 12px;
 82font-weight:bold
 83}
 84input {
 85border:1px solid #003161;
 86background-color:  white;
 87font-family:"trebuchet ms",sans-serif;
 88font-size: 12px;
 89color: #003161;
 90}
 91select, option {
 92background-color:  white;
 93font-size: 12px;
 94color: #003161;
 95}
 96textarea {
 97border:1px solid #003161;
 98background-color: #90B6DB;
 99font-family:"trebuchet ms",sans-serif;
100font-size: 12px;
101color: white;
102}
103-->
104</style>
105</head>
106<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');">
107<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
108  <tr valign="top"> 
109    <td width="143" height="64"><img src="images/logo.png" width="143" height="64"></td>
110    <td width="100%" height="64" align="right" background="images/fond_haut.png"> <table border="0" cellspacing="0" cellpadding="0">
111        <tr> 
112          <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>
113          <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>
114          <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>
115          <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>
116          <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>
117          <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>
118          <td><img src="images/col.png"></td>
119          <td width="10"></td>
120          <td width="190" align="right" class="texteinv"><a href="login.php">exit</a><br> 
121            <a href="amuleweb-main-log.php">log &bull;</a> <a href="amuleweb-main-prefs.php">configuration</a></td>
122          <td width="10"></td>
123        </tr>
124      </table></td>
125  </tr>
126  <tr align="center" valign="top"> 
127    <td colspan="2">
128        <table width="100%" border="0" cellspacing="0" cellpadding="0">
129          <caption>
130        SERVERS 
131        </caption>
132          <tr> 
133            <td width="24"><img src="images/tab_top_left.png" width="24" height="24"></td>
134            <td background="images/tab_top.png">&nbsp;</td>
135            <td width="24"><img src="images/tab_top_right.png" width="24" height="24"></td>
136          </tr>
137          <tr> 
138            <td width="24" background="images/tab_left.png">&nbsp;</td>
139            
140      <td bgcolor="#FFFFFF"><table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
141              <tr> 
142                <th width="3%"></th>
143                <th width="22%" ><a href="amuleweb-main-servers.php?sort=name">Server Name</a></th>
144                <th width="42%" ><a href="amuleweb-main-servers.php?sort=desc">Description</a></th>
145                <th width="19%">Address</th>
146                <th width="7%"><a href="amuleweb-main-servers.php?sort=users">Users</a></th>
147                <th width="7%"><a href="amuleweb-main-servers.php?sort=files">Files</a></th>
148		</tr><tr><td colspan="8" height="1" bgcolor="#000000"></td></tr>
149              <?php
150
151
152		//
153		// declare it here, before any function reffered it in "global"
154		//
155		$sort_order;$sort_reverse;
156
157		function my_cmp($a, $b)
158		{
159			global $sort_order, $sort_reverse;
160			switch ( $sort_order) {
161				case "name": $result = $a->name > $b->name; break;
162				case "desc": $result = $a->desc > $b->desc; break;
163				case "users": $result = $a->users > $b->users; break;
164				case "files":$result = $a->files > $b->files; break;
165			}
166
167			if ( $sort_reverse ) {
168				$result = !$result;
169			}
170			return $result;
171		}
172
173		$servers = amule_load_vars("servers");
174
175		$sort_order = $HTTP_GET_VARS["sort"];
176
177		//
178		// perform command before processing content
179		//
180		if ( ($HTTP_GET_VARS["cmd"] != "") and ($HTTP_GET_VARS["ip"] != "") and ($HTTP_GET_VARS["port"] != "")) {
181			if ($_SESSION["guest_login"] == 0) {
182				amule_do_server_cmd($HTTP_GET_VARS["ip"], $HTTP_GET_VARS["port"], $HTTP_GET_VARS["cmd"]);
183			}
184		}
185		
186		if ( $sort_order == "" ) {
187			$sort_order = $_SESSION["servers_sort"];
188		} else {
189			if ( $_SESSION["sort_reverse"] == "" ) {
190				$_SESSION["sort_reverse"] = 0;
191			} else {
192				$_SESSION["sort_reverse"] = !$_SESSION["sort_reverse"];
193			}
194		}
195
196		$sort_reverse = $_SESSION["sort_reverse"];
197		if ( $sort_order != "" ) {
198			$_SESSION["servers_sort"] = $sort_order;
199			usort(&$servers, "my_cmp");
200		}
201		foreach ($servers as $srv) {
202			echo "<tr>";
203			
204			if ($_SESSION["guest_login"] != 0) {
205				echo "<td class='texte' align='center'></td>";
206			} else {
207				echo "<td class='texte' align='center'>",
208					'<a href="amuleweb-main-servers.php?cmd=connect&ip=', $srv->ip,
209					'&port=', $srv->port, '">',
210					'<img src="images/connect.gif" width="16" height="16" border="0">','</a>',
211					'<a href="amuleweb-main-servers.php?cmd=remove&ip=', $srv->ip,
212					'&port=', $srv->port, '">',
213					'<img src="images/cancel.gif" width="16" height="16" border="0">','</a>',
214					"</td>";
215			}
216
217			echo "<td class='texte'>", $srv->name, "</td>";
218			echo "<td class='texte'>", $srv->desc, "</td>";
219			echo "<td class='texte' align='center'>", $srv->addr, "</td>";
220			echo "<td class='texte' align='center'>", $srv->users, "</td>";
221			echo "<td class='texte' align='center'>", $srv->files, "</td>";
222
223			echo "</tr><tr><td colspan='9' height='1' bgcolor='#c0c0c0'></td></tr>";
224		}
225	  ?>
226            </table></td>
227            <td width="24" background="images/tab_right.png">&nbsp;</td>
228          </tr>
229          <tr> 
230            <td width="24"><img src="images/tab_bottom_left.png" width="24" height="24"></td>
231            <td background="images/tab_bottom.png">&nbsp;</td>
232            <td width="24"><img src="images/tab_bottom_right.png" width="24" height="24"></td>
233          </tr>
234        </table></td>
235  </tr>
236  <tr valign="bottom"> 
237    <td height="25" colspan="2"> <table width="100%" height="40" border="0" cellpadding="0" cellspacing="0">
238        <tr align="center" valign="middle"> 
239          <td width="50%"> <iframe name="stats" src="footer.php" height="35" width="100%" scrolling="no" frameborder="0">edklink</iframe> 
240          </td>
241          <td width="50%"> <iframe name="stats" src="stats.php" height="35" width="100%" scrolling="no" frameborder="0">connection</iframe> 
242          </td>
243        </tr>
244      </table></td>
245  </tr>
246</table>
247</body>
248</html>