/** * Removes a channel from list * * @param string $name * @return void */ public function removeChannel($name) { if (!Services::memcacheLoaded()) { foreach ($this->channelList as $key => $channel) { if (strtolower($channel->getName()) == strtolower($name)) { unset($this->channelList[$key]); } } } else { Services::getMemcache()->delete('channel_' . $name); } }
/** * Loads modules from memcache */ protected function readModuleListCache() { // check for memcache extension if (!Services::memcacheLoaded()) { return false; } // check for stored data if (!Services::getMemcache()->get('moduleList') or !Services::getMemcache()->get('botInstances')) { return false; } // load data $modules = Services::getMemcache()->get('moduleList'); $botInstances = Services::getMemcache()->get('botInstances'); // debug log if (defined('DEBUG')) { Services::getConnection()->getProtocol()->sendLogLine("Loading modules from cache ..."); } // start modules foreach ($modules as $row) { $this->loadModule(SDIR . 'lib/modules/' . $row['name'] . '.class.php', $row['address'], true); } // start bot instances foreach ($botInstances as $row) { $this->createBotInstance($row['moduleAddress'], $row['trigger'], $row['nick'], $row['hostname'], $row['ident'], $row['ip'], $row['modes'], $row['gecos']); } // ok all done return true; }
/** * @see UserTypeManager::getUserByNick() */ public function getUserByNick($nickname) { if (Services::memcacheLoaded() and Services::getMemcache()->get(get_class($this) . '_data' !== false)) { $userList = Services::getMemcache()->get(get_class($this) . '_data'); } else { $userList = $this->userList; } foreach ($userList as $key => $user) { if ($userList[$key]->getNick() == $nickname) { return $userList[$key]; } } return null; }
/** * Starts network burst * * @return void */ public function initConnection() { // CAPAB Services::getConnection()->sendLine("CAPAB START " . PROTOCOL_VERSION); Services::getConnection()->sendLine("CAPAB CAPABILITIES :PROTOCOL=" . PROTOCOL_VERSION); Services::getConnection()->sendLine("CAPAB END"); // SERVER Services::getConnection()->sendLine("SERVER " . $this->name . " " . $this->password . " " . $this->hops . " " . $this->numeric . " :" . $this->description); // BURST $this->connectionState = 'burst'; Services::getConnection()->sendServerLine("BURST " . time()); Services::getConnection()->sendServerLine("VERSION :Evil-Co.de Services (Protocol Version 1.0.0)"); Services::getConnection()->sendServerLine("ENDBURST"); // handle burst ... $input = ""; do { // read lines $input = Services::getConnection()->readLine(); $inputEx = explode(" ", $input); // auth commands switch ($inputEx[0]) { case 'SERVER': $this->serverList[] = $inputEx[1]; break; } } while (!isset($inputEx[1]) or $inputEx[1] != "BURST"); // handle commands do { // read lines $input = Services::getConnection()->readLine(); $input = substr($input, 1); $inputEx = explode(" ", $input); if (!empty($input) and count($inputEx) >= 2) { if (method_exists('ProtocolHandler', $inputEx[1])) { call_user_func(array('ProtocolHandler', strtoupper($inputEx[1])), $input, $inputEx); } } } while (!isset($inputEx[1]) or $inputEx[1] != 'ENDBURST'); // Endburst processed! // Little ... er ... easteregg ... AI for services (Or automatic management for IRC networks) //Services::getConnection()->sendServerLine("NOTICE ".$this->servicechannel." :Evil-Co.de Service AI is now ready!"); // Default runtime while (Services::getConnection()->isAlive()) { // read lines $input = Services::getConnection()->readLine(); $input = substr($input, 1); $inputEx = explode(" ", $input); if (!empty($input) and count($inputEx) >= 2) { if (method_exists('ProtocolHandler', $inputEx[1])) { call_user_func(array('ProtocolHandler', strtoupper($inputEx[1])), $input, $inputEx); } } // check memcache connection if (Services::memcacheLoaded() and !Services::getMemcache()->checkConnection()) { throw new Exception("Memcache is gone away!"); } } }