public function dcc_rehash($chat, $args) { $chat->dccSend("Rehashing main config file, please wait..."); $currConfig = $this->ircClass->getClientConf(); $newConfig = bot::parseConfig($this->ircClass->getConfigFilename()); if ($newConfig == false) { $chat->dccSend("Could not find config file or IO error."); return; } $this->ircClass->setConfig($newConfig, $this->ircClass->getConfigFilename()); if ($currConfig['nick'] != $newConfig['nick']) { $chat->dccSend("Changing nick..."); $this->ircClass->changeNick($newConfig['nick']); } if ($currConfig['server'] != $newConfig['server']) { $chat->dccSend("Connecting to new server..."); $this->ircClass->disconnect(); $this->ircClass->reconnect(); } else { if (isset($currConfig['channel'])) { if (!is_array($currConfig['channel'])) { $currConfig['channel'] = array($currConfig['channel']); } if (!is_array($newConfig['channel'])) { $newConfig['channel'] = array($newConfig['channel']); } foreach ($currConfig['channel'] as $chan) { if (!in_array($chan, $newConfig['channel'])) { $chan = trim($chan) . " "; $chan = trim(substr($chan, 0, strpos($chan, chr(32)) + 1)); $this->ircClass->sendRaw("PART " . $chan); } } } } $this->ircClass->purgeMaintainList(); $chat->dccSend("Rehashing channel list..."); bot::createChannelArray($this->ircClass); $chat->dccSend("Rehashing IP address..."); if (isset($newConfig['natip'])) { if (isset($currConfig['natip'])) { if ($currConfig['natip'] != $newConfig['natip']) { $this->ircClass->setClientIP($newConfig['natip']); } } else { $this->ircClass->setClientIP($newConfig['natip']); } } else { if ($this->ircClass->getStatusRaw() != STATUS_CONNECTED_REGISTERED) { $chat->dccSend("NOTICE: Cannot reset IP address unless connected to server. No change made."); } else { $this->ircClass->setClientIP(); } } if (isset($newConfig['dccrangestart']) && $newConfig['dccrangestart'] != $currConfig['dccrangestart']) { $chat->dccSend("Updating TCP Range..."); $this->socketClass->setTcpRange($newConfig['dccrangestart']); } if (isset($newConfig['logfile']) && $newConfig['logfile'] != $currConfig['logfile']) { $chat->dccSend("Changing log file..."); $this->ircClass->closeLog(); } if (isset($newConfig['functionfile'])) { if ($newConfig['functionfile'] != $currConfig['functionfile']) { $this->parserClass->loadFuncs($newConfig['functionfile']); } } else { $chat->dccSend("Fatal Error, functionfile directive not set. The performance of this bot is no longer guaranteed (please restart and fix your error)"); return; } $chat->dccSend("Main config rehash complete."); }
private function readConfig() { global $argc, $argv; if ($argc < 2) { $args = array(config::$main['scriptdir'] . "/../ircbot/bot.conf"); } else { $args = $argv; array_shift($args); } $isPasswordEncrypt = false; foreach ($args as $filename) { if ($filename == "") { continue; } if ($isPasswordEncrypt == true) { die("Encrypted Password: "******"\nReplace this as 'dccadminpass' in bot.conf!"); } if ($filename == "-c") { $isPasswordEncrypt = true; continue; } if ($filename == "-b" && $this->background != 1) { $this->background = 1; $this->doBackground(); continue; } $config = bot::parseConfig($filename); if ($config == false) { echo "Could not spawn bot {$filename}"; die; } $bot = new botClass(); $bot->config = $config; $bot->configFilename = $filename; $this->bots[] = $bot; } if ($isPasswordEncrypt == true) { die("No password submitted on command line! Syntax: bot.php -c <new admin password>\n"); } if (!$this->background && PID != '') { $file = fopen(PID, "w+"); fwrite($file, getmypid()); fclose($file); } }
private function readConfig() { global $argc, $argv; if ($argc < 2) { echo "You must specify a config file.\n"; die; } $isPasswordEncrypt = false; array_shift($argv); foreach ($argv as $filename) { if ($filename == "") { continue; } if ($isPasswordEncrypt == true) { die("Encrypted Password: "******"\nReplace this as 'dccadminpass' in bot.conf!"); } if ($filename == "-c") { $isPasswordEncrypt = true; continue; } if ($filename == "-b" && $this->background != 1) { $this->background == 1; $this->doBackground(); continue; } $config = bot::parseConfig($filename); if ($config == false) { echo "Could not spawn bot {$filename}"; die; } $bot = new botClass(); $bot->config = $config; $bot->configFilename = $filename; $this->bots[] = $bot; } if ($isPasswordEncrypt == true) { die("No password submitted on command line! Syntax: bot.php -c <new admin password>\n"); } }