Attached Files | aMule-web-chicane-servers-sort.patch [^] (1,815 bytes) 2008-11-17 11:09 [Show Content] [Hide Content]diff -Nur aMule-2.2.2-orig/src/webserver/chicane/servers.php aMule-2.2.2/src/webserver/chicane/servers.php
--- aMule-2.2.2-orig/src/webserver/chicane/servers.php 2006-03-22 23:28:19.000000000 +0100
+++ aMule-2.2.2/src/webserver/chicane/servers.php 2008-11-17 10:37:02.000000000 +0100
@@ -384,6 +384,36 @@
</tr>
<?php
+
+ //
+ // declare it here, before any function reffered it in "global"
+ //
+ $sort_order;$sort_reverse;
+
+ function my_cmp($a, $b)
+ {
+ global $sort_order, $sort_reverse;
+ switch ( $sort_order) {
+ case "name": $result = $a->name > $b->name; break;
+ case "desc": $result = $a->desc > $b->desc; break;
+ case "users": $result = $a->users > $b->users; break;
+ case "max_users": $result = $a->maxusers > $b->maxusers; break;
+ case "files":$result = $a->files > $b->files; break;
+ }
+
+ if ( $sort_reverse ) {
+ $result = !$result;
+ }
+ return $result;
+ }
+
+
+ $servers = amule_load_vars("servers");
+ $sort_order = $HTTP_GET_VARS["sort"];
+
+ //
+ // perform command before processing content
+ //
if ( ($HTTP_GET_VARS["cmd"] != "") && ($_SESSION["guest_login"] == 0) ) {
var_dump($HTTP_GET_VARS);
if ( $HTTP_GET_VARS["cmd"] == "add" ) {
@@ -392,8 +422,22 @@
amule_do_server_cmd($HTTP_GET_VARS["ip"], $HTTP_GET_VARS["port"], $HTTP_GET_VARS["cmd"]);
}
}
-
- $servers = amule_load_vars("servers");
+
+ if ( $sort_order == "" ) {
+ $sort_order = $_SESSION["servers_sort"];
+ } else {
+ if ( $_SESSION["sort_reverse"] == "" ) {
+ $_SESSION["sort_reverse"] = 0;
+ } else {
+ $_SESSION["sort_reverse"] = !$_SESSION["sort_reverse"];
+ }
+ }
+
+ $sort_reverse = $_SESSION["sort_reverse"];
+ if ( $sort_order != "" ) {
+ $_SESSION["servers_sort"] = $sort_order;
+ usort(&$servers, "my_cmp");
+ }
foreach ($servers as $srv) {
echo "<tr>";
|