X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=zncadmin%2FZNCServer.class.php;h=d019be005b9925b292bb6ab19a093993e5ff6537;hb=b35aabd3a108d88fb6c64319c42a19d0d49a7d15;hp=35724a1c1994628cfa283a2a8c4b84872a71ce1c;hpb=68a600683c091740094edc47f27286e9719f644a;p=ZNCAdmin.git diff --git a/zncadmin/ZNCServer.class.php b/zncadmin/ZNCServer.class.php index 35724a1..d019be0 100644 --- a/zncadmin/ZNCServer.class.php +++ b/zncadmin/ZNCServer.class.php @@ -16,6 +16,11 @@ * along with this program. If not, see . */ +define("ERR_OK", 0); +define("ERR_UNKNOWN", 1); +define("ERR_MODULE_NOT_FOUND", 2); +define("ERR_USER_NOT_FOUND", 3); + class ZNCServer { private $host, $port; private $connector; @@ -40,7 +45,7 @@ class ZNCServer { } public function getUserList() { - $html = $this->connector->get("http://".$this->host.":".$this->port."/mods/webadmin/listusers"); + $html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/webadmin/listusers"); $exp = explode('
', $html); $exp = explode('
', $exp[1]); $exp = explode('', $exp[0]); @@ -64,7 +69,7 @@ class ZNCServer { } public function getSeenList() { - $html = $this->connector->get("http://".$this->host.":".$this->port."/mods/lastseen/"); + $html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/lastseen/"); $exp = explode('
', $html); $exp = explode('
', $exp[1]); $exp = explode('', $exp[0]); @@ -94,7 +99,7 @@ class ZNCServer { ident */ public function addZNC($username, $password, $settings, $servers, $modules, $others) { - $html = $this->connector->get("http://".$this->host.":".$this->port."/mods/webadmin/adduser"); + $html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/webadmin/adduser"); $exp = explode('name="_CSRF_Check" value="', $html); $exp = explode('"', $exp[1]); $csrf = $exp[0]; @@ -119,12 +124,12 @@ class ZNCServer { foreach($others as $name => $value) { $post[$name] = $value; } - $html = $this->connector->post("http://".$this->host.":".$this->port."/mods/webadmin/adduser", $post); + $html = $this->connector->post("http://".$this->host.":".$this->port."/mods/global/webadmin/adduser", $post); return !preg_match("/Invalid Submission/i", $html); } public function delZNC($username) { - $html = $this->connector->get("http://".$this->host.":".$this->port."/mods/webadmin/deluser?user=".$username); + $html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/webadmin/deluser?user=".$username); $exp = explode('name="_CSRF_Check" value="', $html); $exp = explode('"', $exp[1]); $csrf = $exp[0]; @@ -132,14 +137,10 @@ class ZNCServer { $post['_CSRF_Check'] = $csrf; $post['submitted'] = '1'; $post['user'] = $username; - $this->connector->post("http://".$this->host.":".$this->port."/mods/webadmin/deluser", $post); + $this->connector->post("http://".$this->host.":".$this->port."/mods/global/webadmin/deluser", $post); } - 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/webadmin/edituser?user=".$username); - if(preg_match("/No such username/i", $html)) return false; - $post = array(); - $post['loadmod'] = array(); + private function parseHTMLFields($html, &$post) { preg_match_all("]*)>", $html, $matches); foreach($matches[0] as $input) { $fields = array(0 => ""); @@ -208,6 +209,58 @@ class ZNCServer { $content = $content[0]; $post[$name] = $content; } + //select boxes + $selectboxes = explode("