improved server stats
authorNurPech <nurpech@nurpech.de>
Sun, 30 Jun 2013 10:53:43 +0000 (12:53 +0200)
committerNurPech <nurpech@nurpech.de>
Sun, 30 Jun 2013 10:53:43 +0000 (12:53 +0200)
Signed-off-by: NurPech <nurpech@nurpech.de>
zncadmin.php

index 5b63e1e497b8e67f02a5b4b46c4b68649db02458..d96ccb6312a9344a2512325917496e2850b5421e 100644 (file)
@@ -1,19 +1,19 @@
 <?php
 /* czncadmin.php - main script - ZNCAdmin
  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
- * 
+ *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License 
- * along with this program. If not, see <http://www.gnu.org/licenses/>. 
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
 error_reporting(E_ALL & ~E_NOTICE);
@@ -47,7 +47,7 @@ switch(strtolower($argv[1])) {
     case "search":
         zncadmin_search();
         break;
-       case "seen":
+    case "seen":
         zncadmin_seen();
         break;
     case "resetpass":
@@ -77,7 +77,7 @@ function preg_prepare($string,$wildcards = true,$pregstart = "#") {
     foreach($in as $item) {
         $out[] = "\\".$item;
     }
-    if($wildcards) { 
+    if($wildcards) {
         array_push($in,"*");
         array_push($out,"(.*)");
     }
@@ -201,7 +201,7 @@ function zncadmin_search() {
                         $skip = (preg_match("#^".preg_prepare($flagval)."$#i", $zncserver['name']) != $positive);
                         break;
                     default:
-                        
+
                         break;
                 }
                 if($skip)
@@ -233,13 +233,13 @@ function zncadmin_search() {
 //SUBCOMMAND: search
 function zncadmin_seen() {
     global $argv, $zncservers;
-       $time = $argv[2];
-       $over_time = true;
-       if($time[0] == '>' || $time[0] == '<') {
-               if($time[0] == '<') $over_time = false;
-               $time = substr($time, 1);
-       }
-       $time = time() - str2time($time);
+    $time = $argv[2];
+    $over_time = true;
+    if($time[0] == '>' || $time[0] == '<') {
+        if($time[0] == '<') $over_time = false;
+        $time = substr($time, 1);
+    }
+    $time = time() - str2time($time);
     $mask = $argv[3];
     if(!$time) {
         error("missing time parameter");
@@ -570,11 +570,18 @@ function zncadmin_unblock() {
 
 //SUBCOMMAND: stats
 function zncadmin_stats() {
-    global $argv, $zncservers;
+    global $argv, $zncservers, $force;
+    $server = $argv[2];
     $table = new Table(6);
     $table->add("Server", "Port / SSL Port", "Total ZNC's", "Connected (IRC)", "Online (User)", "Protected?");
     $count = 0;
     foreach($zncservers as $zncserver) {
+        if($server > 0 && $zncserver['name'] != $server) continue;
+        if($server > 0 && $zncserver['name'] == $server && $zncserver['protected'] === true && !$force) {
+            error("Access denied\n");
+            return;
+        }
+
         $total = 0;
         $connected = 0;
         $online = 0;