X-Git-Url: http://git.pk910.de/?p=PHP-P10.git;a=blobdiff_plain;f=Bots%2FIPv6.class.php;h=d5c4a1ef2b4ea5ab6270b12dd37721fa453b71bc;hp=34f1b5c860fca8a2d36988f260f64b0d8765cf3f;hb=7f51193ddac01b0540000c756c50167ff015e02a;hpb=f5697bd40b017e99b8eba03577e468ec9763d11e diff --git a/Bots/IPv6.class.php b/Bots/IPv6.class.php index 34f1b5c..d5c4a1e 100644 --- a/Bots/IPv6.class.php +++ b/Bots/IPv6.class.php @@ -1,12 +1,10 @@ . * * * ************************************************************************ - * - * Bots/ModManager.class.php * - * module manager bot... + * Bots/IPv6.class.php + * + * IPv6 bot... * */ @@ -30,17 +27,17 @@ class {$_NAME} extends Bot { private $uplink; private $ipv6; private $cache = array( - 0 => array(), - 1 => array() - ); - + 0 => array(), + 1 => array() + ); + public function load($uplink, $old = false) { $this->uplink = $uplink; if(!$old) { $nick = "IPv6"; $ident = "ipv6"; - $ip = "0::0"; - $host = "fd00::C0CA:C01A:ADD5:11FE"; //coca cola adds life maybe someone undestands it :D + $ip = "fd00::c0ca:c01a:add5:11fe"; //coca cola adds life maybe someone undestands it :D + $host = $ip; $realname = "IPv6"; $modes = "ioknISD"; $this->ipv6 = $this->uplink->addUser($nick,$ident,$host,$ip,$modes,$realname); @@ -51,13 +48,13 @@ class {$_NAME} extends Bot { } else { $this->ipv6 = $old; } - + ModCMD::bind($this, BIND_JOIN, "recive_join"); ModCMD::bind($this, BIND_CHANMODE, "recive_mode"); ModCMD::bind($this, BIND_KICK, "recive_kick"); ModCMD::bind($this, BIND_QUIT, "recive_quit"); } - + public function unload($rehash = false) { if($rehash) { return $this->ipv6; @@ -65,7 +62,7 @@ class {$_NAME} extends Bot { $this->uplink->delUser($this->ipv6, "Bye."); } } - + public function loop() { for($i = 0; $i < 2; $i++) { foreach($this->cache[$i] as $id => $cache) { @@ -73,28 +70,21 @@ class {$_NAME} extends Bot { } } } - + private function botOppedOnChannel($channel) { $privs = $channel->getUserPrivs($this->ipv6); return ($privs & P10_Channel::USERPRIV_OPED); } - + public function recive_join($user, $channel, $isBurst) { if(!$this->botOppedOnChannel($channel)) return false; - $ipv6 = '/^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))(|\/[0-9]{1,3})$/'; - if(preg_match($ipv6, $user->getIP())) { - $privs = $channel->getUserPrivs($user); - $privs |= (P10_Channel::USERPRIV_OPED | P10_Channel::USERPRIV_VOICE); - $channel->setUserPrivs($user, $privs); + if($user->getIP()->isIPv6()) { $this->uplink->mode($this->ipv6, $channel, "+ov ".$user->getNumeric()." ".$user->getNumeric()); } else { - $privs = $channel->getUserPrivs($user); - $privs |= (P10_Channel::USERPRIV_VOICE); - $channel->setUserPrivs($user, $privs); $this->uplink->mode($this->ipv6, $channel, "+v ".$user->getNumeric()); } } - + public function recive_mode($user, $channel, $modes) { if($user->getModes()->hasMode('o') || !$this->botOppedOnChannel($channel)) return false; if(array_key_exists($user->getNumeric(), $this->cache[0]) && $this->cache[0][$user->getNumeric()]['time'] > time()) { @@ -120,7 +110,7 @@ class {$_NAME} extends Bot { $modes = implode(" ",$mode); $this->uplink->mode($this->ipv6, $channel, $modes); } - + public function recive_kick($user, $target, $channel, $modes) { if($user->getModes()->hasMode('o') || !$this->botOppedOnChannel($channel)) return false; if(array_key_exists($user->getNumeric(), $this->cache[1]) && $this->cache[1][$user->getNumeric()]['time'] > time()) { @@ -130,7 +120,7 @@ class {$_NAME} extends Bot { $this->cache[1][$user->getNumeric()] = time() + 600; } } - + public function recive_quit($user, $reason) { if($user === $this->ipv6) { $this->load($this->uplink);