added channel Burst
authorpk910 <philipp@zoelle1.de>
Tue, 26 Jul 2011 18:04:36 +0000 (20:04 +0200)
committerpk910 <philipp@zoelle1.de>
Tue, 26 Jul 2011 18:04:36 +0000 (20:04 +0200)
Uplink/P10Formatter.class.php
Uplink/P10_Channel.class.php
Uplink/Uplink.class.php
main.php

index b5087a462b9ea3c11d5eea31a2ef83b44ee303a8..39fb704291b60f98c4b88b52ab725df74201fca9 100644 (file)
@@ -42,6 +42,7 @@ class P10Formatter {
                "N"      => "{num} N %s 1 %s %s %s %s %s %s :%s",
                "EB"     => "{num} EB",
                "EA"     => "{num} EA",
+               "B"      => "{num} B %s %s %s",
                null     => null
        );
        
index efe960de62b9f407f823241485cbcb766f099a49..d38015b4a658e52e74f61917c568bce5035f6c32 100644 (file)
@@ -46,10 +46,15 @@ class P10_Channel {
                return NULL;
        }
        
+       public static function getChannels() {
+               return self::$static_channels;
+       }       
+       
        
        private $name;
        private $topic;
        private $modes;
+       private $create_time;
        private $users = array();
        const USERPRIV_OPED  = 0x0001;
        const USERPRIV_VOICE = 0x0002;
@@ -58,6 +63,7 @@ class P10_Channel {
        public function __construct($name) {
                $this->name = $name;
                $this->modes = new P10_ChannelModeSet($this);
+               $this->create_time = time();
                self::$static_channels[strtolower($name)] = $this;
        }
        
@@ -77,6 +83,10 @@ class P10_Channel {
                return $this->topic;
        }
        
+       public function getCreateTime() {
+               return $this->create_time;
+       }
+       
        public function joinUser($user) {
                $this->users[$user->getNumeric()] = $user;
                $this->userPrivs[$user->getNumeric()] = 0;
@@ -122,6 +132,10 @@ class P10_Channel {
                }
        }
        
+       public function getUsers() {
+               return $this->users;
+       }
+       
 }
 
 ?>
\ No newline at end of file
index 6908ab7a0d5fb987eaa7aff54e3d2b7b58528f9f..b91bf8a993b99e8fa55cea3a5bdfa60fa4feda58 100644 (file)
@@ -370,6 +370,10 @@ class Uplink {
                        $userstr = $args[count($args)-2];
                        $modeparamcount--;
                }
+               if($userstr[0] == "+") { //MODE String
+                       $modeparamcount++;
+                       $userstr = "";
+               }
                $users = explode(",",$userstr);
                $isop = false; $isvoice = false;
                foreach($users as $user) {
@@ -412,6 +416,57 @@ class Uplink {
                        $realname = $user->getRealname();
                        $this->send("N", $nick, $connect_time, $ident, $host, $modes, $ip, $numeric, $realname);
                }
+               foreach(P10_Channel::getChannels() as $channel) {
+                       $sorted_users = array('ov' => array(), 'o' => array(), 'v' => array(), '-' => array());
+                       $local_users = false;
+                       foreach($channel->getUsers() as $user) {
+                               if(substr($user->getNumeric(), 0, 2) != $this->server->getNumeric()) continue; //skip users that are not on the local server
+                               $privs = $channel->getUserPrivs($user);
+                               $strPrivs = "";
+                               if(($privs & P10_Channel::USERPRIV_OPED)) $strPrivs .= "o";
+                               if(($privs & P10_Channel::USERPRIV_VOICE)) $strPrivs .= "v";
+                               if($strPrivs == "") $strPrivs = "-";
+                               $local_users = true;
+                               $sorted_users[$strPrivs][] = $user;
+                       }
+                       if(!$local_users) continue;
+                       $userStr = "";
+                       foreach($sorted_users['-'] as $user) {
+                               if($userStr != "") $userStr.=",";
+                               $userStr .= $user->getNumeric();
+                       }
+                       foreach($sorted_users['ov'] as $i => $user) {
+                               if($userStr != "") $userStr.=",";
+                               $userStr .= $user->getNumeric();
+                               if($i == 0) $userStr .= ":ov";
+                       }
+                       foreach($sorted_users['o'] as $i => $user) {
+                               if($userStr != "") $userStr.=",";
+                               $userStr .= $user->getNumeric();
+                               if($i == 0) $userStr .= ":o";
+                       }
+                       foreach($sorted_users['v'] as $i => $user) {
+                               if($userStr != "") $userStr.=",";
+                               $userStr .= $user->getNumeric();
+                               if($i == 0) $userStr .= ":v";
+                       }
+                       $banString = "";
+                       //TODO: Build ban String
+                       $burstString = "";
+                       $modeString = $channel->getModes()->getModeString();
+                       if($modeString != "+") {
+                               $burstString .= $modeString;
+                       }
+                       if($userStr != "") {
+                               if($burstString != "") $burstString .= " ";
+                               $burstString .= $userStr;
+                       }
+                       if($banString != "") {
+                               if($burstString != "") $burstString .= " ";
+                               $burstString .= ":%".$banString;
+                       }
+                       $this->send("B", $channel->getName(), $channel->getCreateTime(), $burstString);
+               }
                $this->send("EB");
        }
        
index 587e730ca5e950688c1171faaf347627cfadfb71..a217c69ac107432074582bd6cde4b50004584067 100644 (file)
--- a/main.php
+++ b/main.php
@@ -31,6 +31,7 @@ require_once("Uplink/Uplink.class.php");
 $uplink = new Uplink();
 $uplink->setUplinkHost("192.168.2.103", 4401);
 $uplink->setUplinkServer(5, "PHP.TestNet", "very_weak_password", "Test Server");
+$uplink->setValidateServer("test.localhost", "very_weak_password");
 
 $uplink->initialize();