* 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 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.
* 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.
- private $host, $port;
- private $connector;
-
- public function ZNCServer($host, $port) {
- $this->host = $host;
- $this->port = $port;
- $this->connector = new HTTPConnector();
- }
-
- public function login($user, $pass) {
- $post = array(
- "user" => $user,
- "pass" => $pass,
- "submitted" => "1"
- );
- $this->connector->post("http://".$this->host.":".$this->port."/login", $post);
- $http = $this->connector->get("http://".$this->host.":".$this->port."/?cookie_check=true");
- $logged_in = !preg_match("/errorbar/i", $http);
-
- return $logged_in;
- }
-
- public function getUserList() {
- $html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/webadmin/listusers");
- $exp = explode('<div class="toptable">', $html);
- $exp = explode('</div>', $exp[1]);
- $exp = explode('<tbody>', $exp[0]);
- $exp = explode('</tbody>', $exp[1]);
- $list = explode('<tr class=', $exp[0]);
- $userlist = array();
- for($i = 1; $i < count($list); $i++) {
- $userdata = array();
- $exp = explode('<td>', $list[$i]);
- $exp2 = explode('</td>', $exp[2]);
- $userdata['user'] = $exp2[0];
- $exp2 = explode('</td>', $exp[3]);
- $userdata['server'] = $exp2[0];
- $exp2 = explode('</td>', $exp[4]);
- $userdata['clients'] = $exp2[0];
- $userlist[] = $userdata;
- }
- return $userlist;
- }
-
+ private $host, $port;
+ private $connector;
+
+ public function ZNCServer($host, $port) {
+ $this->host = $host;
+ $this->port = $port;
+ $this->connector = new HTTPConnector();
+ }
+
+ public function login($user, $pass) {
+ $post = array(
+ "user" => $user,
+ "pass" => $pass,
+ "submitted" => "1"
+ );
+ $this->connector->post("http://".$this->host.":".$this->port."/login", $post);
+ $http = $this->connector->get("http://".$this->host.":".$this->port."/?cookie_check=true");
+ $logged_in = !preg_match("/errorbar/i", $http);
+
+ return $logged_in;
+ }
+
+ public function getUserList() {
+ $html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/webadmin/listusers");
+ $exp = explode('<div class="toptable">', $html);
+ $exp = explode('</div>', $exp[1]);
+ $exp = explode('<tbody>', $exp[0]);
+ $exp = explode('</tbody>', $exp[1]);
+ $list = explode('<tr class=', $exp[0]);
+ $userlist = array();
+ for($i = 1; $i < count($list); $i++) {
+ $userdata = array();
+ $exp = explode('<td>', $list[$i]);
+ $exp2 = explode('</td>', $exp[2]);
+ $userdata['user'] = $exp2[0];
+ $exp2 = explode('</td>', $exp[3]);
+ $userdata['server'] = $exp2[0];
+ $exp2 = explode('</td>', $exp[4]);
+ $userdata['clients'] = $exp2[0];
+ $userlist[] = $userdata;
+ }
+ return $userlist;
+ }
+
- $html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/lastseen/");
- $exp = explode('<div class="toptable">', $html);
- $exp = explode('</div>', $exp[1]);
- $exp = explode('<tbody>', $exp[0]);
- $exp = explode('</tbody>', $exp[1]);
- $list = explode('<tr class=', $exp[0]);
- $seenlist = array();
- for($i = 1; $i < count($list); $i++) {
- $userdata = array();
- $exp = explode('<td>', $list[$i]);
-
- $exp2 = explode('</td>', $exp[1]);
- $userdata['user'] = $exp2[0];
- $exp2 = explode('</td>', $exp[2]);
- $userdata['seen'] = $exp2[0];
+ $html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/lastseen/");
+ $exp = explode('<div class="toptable">', $html);
+ $exp = explode('</div>', $exp[1]);
+ $exp = explode('<tbody>', $exp[0]);
+ $exp = explode('</tbody>', $exp[1]);
+ $list = explode('<tr class=', $exp[0]);
+ $seenlist = array();
+ for($i = 1; $i < count($list); $i++) {
+ $userdata = array();
+ $exp = explode('<td>', $list[$i]);
+
+ $exp2 = explode('</td>', $exp[1]);
+ $userdata['user'] = $exp2[0];
+ $exp2 = explode('</td>', $exp[2]);
+ $userdata['seen'] = $exp2[0];
*/
public function addZNC($username, $password, $settings, $servers, $modules, $others) {
$html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/webadmin/adduser");
*/
public function addZNC($username, $password, $settings, $servers, $modules, $others) {
$html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/webadmin/adduser");
public function addNetwork($username, $settings, $servers, $other) {
$html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/webadmin/addnetwork?user=".$username);
$exp = explode('name="_CSRF_Check" value="', $html);
public function addNetwork($username, $settings, $servers, $other) {
$html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/webadmin/addnetwork?user=".$username);
$exp = explode('name="_CSRF_Check" value="', $html);
private function parseHTMLFields($html, &$post) {
preg_match_all("<input ([^\>]*)>", $html, $matches);
foreach($matches[0] as $input) {
private function parseHTMLFields($html, &$post) {
preg_match_all("<input ([^\>]*)>", $html, $matches);
foreach($matches[0] as $input) {
public function editZNC($username, $password = NULL, $new_servers = NULL, $add_modules = NULL, $del_modules = NULL, $others = NULL) {
$html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/webadmin/edituser?user=".$username);
if(preg_match("/No such username/i", $html)) return false;
public function editZNC($username, $password = NULL, $new_servers = NULL, $add_modules = NULL, $del_modules = NULL, $others = NULL) {
$html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/webadmin/edituser?user=".$username);
if(preg_match("/No such username/i", $html)) return false;
public function blockZNC($username, $block) {
$html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/webadmin/edituser?user=".$username);
$handle = fopen('/home/srvx/neonserv/log.txt', 'a');
public function blockZNC($username, $block) {
$html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/webadmin/edituser?user=".$username);
$handle = fopen('/home/srvx/neonserv/log.txt', 'a');
public function simulZNC($username, $raw, &$errmsg, $server = true) {
$html = $this->connector->get("http://".$this->host.":".$this->port."/mods/user/send_raw/");
if(preg_match("/Not Found/i", $html)) return ERR_MODULE_NOT_FOUND;
public function simulZNC($username, $raw, &$errmsg, $server = true) {
$html = $this->connector->get("http://".$this->host.":".$this->port."/mods/user/send_raw/");
if(preg_match("/Not Found/i", $html)) return ERR_MODULE_NOT_FOUND;