From 7ee52d8a44c982d62baecf92cea6b266e8c2eb26 Mon Sep 17 00:00:00 2001 From: pk910 Date: Tue, 26 Jul 2011 20:04:36 +0200 Subject: [PATCH] added channel Burst --- Uplink/P10Formatter.class.php | 1 + Uplink/P10_Channel.class.php | 14 +++++++++ Uplink/Uplink.class.php | 55 +++++++++++++++++++++++++++++++++++ main.php | 1 + 4 files changed, 71 insertions(+) diff --git a/Uplink/P10Formatter.class.php b/Uplink/P10Formatter.class.php index b5087a4..39fb704 100644 --- a/Uplink/P10Formatter.class.php +++ b/Uplink/P10Formatter.class.php @@ -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 ); diff --git a/Uplink/P10_Channel.class.php b/Uplink/P10_Channel.class.php index efe960d..d38015b 100644 --- a/Uplink/P10_Channel.class.php +++ b/Uplink/P10_Channel.class.php @@ -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 diff --git a/Uplink/Uplink.class.php b/Uplink/Uplink.class.php index 6908ab7..b91bf8a 100644 --- a/Uplink/Uplink.class.php +++ b/Uplink/Uplink.class.php @@ -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"); } diff --git a/main.php b/main.php index 587e730..a217c69 100644 --- 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(); -- 2.20.1