X-Git-Url: http://git.pk910.de/?p=PHP-P10.git;a=blobdiff_plain;f=BotLoader%2FBotLoader.class.php;fp=BotLoader%2FBotLoader.class.php;h=df06eeaed4d1f137aeb63ff3b6cecf3f5f45c5c6;hp=2b89cb392a6e60d975051c826587c523abb61125;hb=412e324075de1312fbc5f49b735180b46cdff82c;hpb=33c63e89baea7b16b507f55b0ea76a39cbc97f4f diff --git a/BotLoader/BotLoader.class.php b/BotLoader/BotLoader.class.php index 2b89cb3..df06eea 100644 --- a/BotLoader/BotLoader.class.php +++ b/BotLoader/BotLoader.class.php @@ -26,16 +26,37 @@ * */ require_once("Bot.class.php"); +require_once("saxdb.class.php"); class BotLoader { private $uplink; + private $saxdb; + private $botdb; + private $loadedBots = array(); public function __construct($uplink) { $this->uplink = $uplink; + $this->saxdb = new saxdb(); + $this->saxdb->loadDB("php_p10.db"); + $this->botdb = $this->saxdb->getSection("BotLoader"); } public function loadBots() { + if(array_key_exists("bots", $this->botdb) && is_array($this->botdb["bots"])) { + foreach($this->botdb["bots"] as $name => $botfile) { + $this->loadBot($name, $botfile); + } + } else { + $this->botdb["bots"] = array(); + } + } + private function loadBot($name, $botfile) { + if(array_key_exists($name, $this->loadedBots)) return; + //load bot + if(!array_key_exists($name, $this->botdb["bots"])) { + $this->botdb["bots"][$name] = $botfile; + } } }