From 20cd7f168efc290245a261ce8f916d4619897998 Mon Sep 17 00:00:00 2001 From: pk910 Date: Fri, 24 Apr 2015 23:11:16 +0200 Subject: [PATCH] fixed module loading --- config.example.php | 13 ++++++++----- zncadmin.php | 2 +- zncadmin/ZNCServerV1.class.php | 13 ++++++++++--- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/config.example.php b/config.example.php index 7633f2b..a687984 100644 --- a/config.example.php +++ b/config.example.php @@ -70,13 +70,16 @@ $add_settings = array( "groupname" => "KryptonZNC" ), "modules" => array( - "autocycle" => "", - "awaynick" => "%nick%|ZNC", "chansaver" => "", - "kickrejoin" => "", "perform" => "", - "simple_away" => "" - ) + ), + "netmodules" => array( + "autocycle" => "", + "awaynick" => "%nick%|ZNC", + "simple_away" => "" + "kickrejoin" => "", + "keepnick" => "", + ), ); ?> \ No newline at end of file diff --git a/zncadmin.php b/zncadmin.php index 5b63e1e..4552025 100644 --- a/zncadmin.php +++ b/zncadmin.php @@ -363,7 +363,7 @@ function zncadmin_add() { $settings['nick'] = $argv[2]; $settings['altnick'] = $argv[2]."`"; $settings['ident'] = $username; - $ret = $addserv['conn']->addZNC($argv[2], $password, $settings, $add_settings['servers'], $add_settings['modules'], $add_settings['other']); + $ret = $addserv['conn']->addZNC($argv[2], $password, $settings, $add_settings['servers'], $add_settings['modules'], $add_settings['netmodules'], $add_settings['other']); if($ret) { echo "Added user ".$argv[2]." to Server ".$addserv['name'].".\n"; echo " Server Host: ".$addserv['public']." Port: ".$addserv['port']." SSL Port: ".$addserv['sslport']."\n"; diff --git a/zncadmin/ZNCServerV1.class.php b/zncadmin/ZNCServerV1.class.php index 59bbfd6..674d612 100644 --- a/zncadmin/ZNCServerV1.class.php +++ b/zncadmin/ZNCServerV1.class.php @@ -98,7 +98,7 @@ class ZNCServerV1 { altnick ident */ - public function addZNC($username, $password, $settings, $servers, $modules, $others) { + public function addZNC($username, $password, $settings, $servers, $modules, $netmodules, $others) { $html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/webadmin/adduser"); $exp = explode('name="_CSRF_Check" value="', $html); $exp = explode('"', $exp[1]); @@ -128,7 +128,7 @@ class ZNCServerV1 { $html = $this->connector->post("http://".$this->host.":".$this->port."/mods/global/webadmin/adduser", $post); if(!preg_match("/Invalid Submission/i", $html)) { - if(!$this->addNetwork($username, $settings, $servers, $others)) { + if(!$this->addNetwork($username, $settings, $servers, $netmodules, $others)) { return false; } return !preg_match("/Invalid Submission/i", $html); @@ -136,7 +136,7 @@ class ZNCServerV1 { return !preg_match("/Invalid Submission/i", $html); } - public function addNetwork($username, $settings, $servers, $others) { + public function addNetwork($username, $settings, $servers, $modules, $others) { $html = $this->connector->get("http://".$this->host.":".$this->port."/mods/global/webadmin/addnetwork?user=".$username); $exp = explode('name="_CSRF_Check" value="', $html); $exp = explode('"', $exp[1]); @@ -154,6 +154,13 @@ class ZNCServerV1 { $post['floodrate'] = '1.0'; $post['floodburst'] = '4'; $post['user'] = $username; + + $post['loadmod'] = array(); + foreach($modules as $name => $args) { + $post['loadmod'][] = $name; + if($args != "") + $post['modargs_'.$name] = $args; + } foreach($others as $name => $value) { $post[$name] = $value; -- 2.20.1