X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=BotLoader%2FBotLoader.class.php;h=df06eeaed4d1f137aeb63ff3b6cecf3f5f45c5c6;hb=412e324075de1312fbc5f49b735180b46cdff82c;hp=855d64c7657a5031a5f06be9f30a504ae4805350;hpb=7e30c2dbf6582392fd4389adbac56a995ab86595;p=PHP-P10.git diff --git a/BotLoader/BotLoader.class.php b/BotLoader/BotLoader.class.php index 855d64c..df06eea 100644 --- a/BotLoader/BotLoader.class.php +++ b/BotLoader/BotLoader.class.php @@ -20,22 +20,43 @@ * * ************************************************************************ * - * BotLoader/Bot.class.php + * BotLoader/BotLoader.class.php * - * bots' parent class. + * This class loades / rehashs or unloads all Bots. * */ 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; + } } }