add some code for traffic stats dev
authorNurPech <nurpech@nurpech.de>
Mon, 1 Jul 2013 19:50:26 +0000 (21:50 +0200)
committerNurPech <nurpech@nurpech.de>
Mon, 1 Jul 2013 19:50:26 +0000 (21:50 +0200)
Signed-off-by: NurPech <nurpech@nurpech.de>
zncadmin.php
zncadmin/ZNCServerV1.class.php

index d96ccb6312a9344a2512325917496e2850b5421e..28fce11803c4dadf58844750b95331b2a535284d 100644 (file)
@@ -580,6 +580,13 @@ function zncadmin_stats() {
         if($server > 0 && $zncserver['name'] == $server && $zncserver['protected'] === true && !$force) {
             error("Access denied\n");
             return;
+        } elseif($server > 0 && $zncserver['name'] == $server && (($zncserver['protected'] === true && $force) || $zncserver['protected'] === false)) {
+            $zncserver['conn'] = new ZNCServer($zncserver['host'], $zncserver['port'], (isset($zncserver['version']) ? $zncserver['version'] : NULL));
+            $zncserver['conn']->login($zncserver['auser'], $zncserver['apass']);
+            $trafficStats = $zncserver['conn']->getTrafficStats();
+        } else {
+            echo "No Servers configured...\n";
+            return;
         }
 
         $total = 0;
index 59bbfd6e25f602d688b59b9ed44315f94d65e52e..e18976736eab737ddaeac17061c1ce4de5c8363b 100644 (file)
@@ -1,37 +1,37 @@
 <?php
 /* ZNCServerV1.class.php - ZNC Server Class - 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/>.
  */
 
 $classinfo = array(
-       "name" => "ZNCServerV1",
-       "version" => 1.000,
+    "name" => "ZNCServerV1",
+    "version" => 1.000,
 );
 
 class ZNCServerV1 {
-       private $host, $port;
-       private $connector;
-       
-       public function ZNCServerV1($host, $port, $connector = NULL) {
-               $this->host = $host;
-               $this->port = $port;
-               if($connector == NULL)
-                       $connector = new HTTPConnector();
-               $this->connector = $connector;
-       }
+    private $host, $port;
+    private $connector;
+
+    public function ZNCServerV1($host, $port, $connector = NULL) {
+        $this->host = $host;
+        $this->port = $port;
+        if($connector == NULL)
+            $connector = new HTTPConnector();
+        $this->connector = $connector;
+    }
 
     public function login($user, $pass) {
         $post = array(
@@ -92,6 +92,10 @@ class ZNCServerV1 {
         return $seenlist;
     }
 
+    public function getTrafficStats() {
+        $html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/webadmin/traffic");
+    }
+
     /*
     $settings array elements:
         nick
@@ -391,7 +395,7 @@ class ZNCServerV1 {
         $post['autoclearchanbuffer'] = 'true';
         $this->connector->post("http://".$this->host.":".$this->port."/mods/global/webadmin/addchan?user=".$username.'&network=default', $post);
     }
-       
+
 }
 
 ?>
\ No newline at end of file