X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=Uplink%2FUplink.class.php;h=22a923c2b7f381afacece9a93b985af623b05b10;hb=22da0c012b5a82d0c6c7b20b55111995231886ae;hp=524d392c1084db3e72e6e8cb632c43d34e807a98;hpb=29c9dfc2f073856d051daf900c1d7818dde648fe;p=PHP-P10.git diff --git a/Uplink/Uplink.class.php b/Uplink/Uplink.class.php index 524d392..22a923c 100644 --- a/Uplink/Uplink.class.php +++ b/Uplink/Uplink.class.php @@ -142,6 +142,15 @@ class Uplink { } } + public function shutdown() { + if($this->client->connected()) { + if(($this->flags & self::FLAG_P10SESSION)) { + $this->send("SQ", "Shutdown requested."); + } + $this->client->disconnect(); + } + } + public function setUplinkHost($host, $port, $ssl = false, $bind = null) { $this->setSetting("host", $host); $this->setSetting("port", $port); @@ -267,6 +276,13 @@ class Uplink { case "W": $this->recv_whois($from, $arguments); break; + case "A": + $this->recv_away($from, $arguments); + break; + case "M": + case "OM": + $this->recv_mode($from, $arguments); + break; //default default: //unknown cmd @@ -347,6 +363,7 @@ class Uplink { private function recv_ping($from, $args) { $this->send("Z", $args[0]); //simply PONG + P10_Channel::recheckAllChannels(); } private function recv_nick($from, $args) { @@ -443,6 +460,7 @@ class Uplink { $users = explode(",",$userstr); $isop = false; $isvoice = false; foreach($users as $user) { + if($user == "") continue; $uexp = explode(":", $user); if(strlen($uexp[0]) != 5) { trigger_error("burst parse error: '".$uexp[0]."' is not an user numeric.", E_USER_ERROR); @@ -533,7 +551,7 @@ class Uplink { return; } if($this->eventHandler) { - if($args[0] == "#") { + if($args[0][0] == "#") { $channel = P10_Channel::getChannelByName($args[0]); if($channel == null) $channel = new P10_Channel($args[0]); @@ -556,7 +574,7 @@ class Uplink { return; } if($this->eventHandler) { - if($args[0] == "#") { + if($args[0][0] == "#") { $channel = P10_Channel::getChannelByName($args[0]); if($channel == null) $channel = new P10_Channel($args[0]); @@ -644,6 +662,45 @@ class Uplink { $this->send("318", $from, $args[1]); } + private function recv_away($from, $args) { + $user = P10_User::getUserByNum($from); + if($user == null) { + trigger_error("Server tries to send an away command from an user that does not exist or was not found on recv_away.", E_USER_ERROR); + return; + } + if(count($args) > 0) { + $user->setAway($args[0]); + } else { + $user->setAway(null); + } + } + + private function recv_mode($from, $args) { + $user = P10_User::getUserByNum($from); + if($user == null) { + trigger_error("Server tries to send a modechange from an user that does not exist or was not found on recv_mode.", E_USER_ERROR); + return; + } + $modes = implode(" ",array_slice($args,1)) + if($args[0][0] == "#") { + $channel = P10_Channel::getChannelByName($args[0]); + if($channel == null) + $channel = new P10_Channel($args[0]); + $channel->getModes()->setModes($modes); + if($this->eventHandler) + $this->eventHandler->event_chanmode($user, $channel, $modes); + } else { + $targetUser = P10_User::getUserByNum($args[0]); + if($targetUser == null) { + trigger_error("Server tries to send a mode to an user that does not exist or was not found on recv_mode.", E_USER_ERROR); + return; + } + $targetUser->getModes()->setModes($modes); + if($this->eventHandler) + $this->eventHandler->event_usermode($targetUser, $modes); + } + } + /******************************************************************************************** * SERVER FUNCTIONS * ********************************************************************************************/ @@ -727,6 +784,7 @@ class Uplink { $numeric = substr($this->server->getNumeric(),0,2).Numerics::intToNum($this->last_local_numeric, 3); } $this->last_local_numeric++; + $modes = new P10_UserModeSet($modes); $user = new P10_User($nick, $numeric, $this->server, time(), $ident, $host, $ip, $realname, $modes); if(($this->flags & self::FLAG_CONNECTED)) { $ip = Numerics::numericFromIP($user->getIP()); @@ -755,7 +813,7 @@ class Uplink { } } - public function join($user, $chanName) { + public function join($user, $chanName, $privs = 0) { if(!is_a($user, "P10_User") || !($user->getServer() === $this->server)) return ERR_INVALID_USER; if($chanName[0] != "#") @@ -766,6 +824,15 @@ class Uplink { $channel->joinUser($user); if(($this->flags & self::FLAG_CONNECTED)) $this->send("J", $user->getNumeric(), $chanName, time(), 0); + if($privs != 0) { + $channel->setUserPrivs($user, $privs); + if(($this->flags & self::FLAG_CONNECTED)) { + $modestr = "+".(($privs & P10_Channel::USERPRIV_OPED) ? "o" : "").(($privs & P10_Channel::USERPRIV_VOICE) ? "v" : ""); + $modestr .= (($privs & P10_Channel::USERPRIV_OPED) ? " ".$user->getNumeric() : ""); + $modestr .= (($privs & P10_Channel::USERPRIV_VOICE) ? " ".$user->getNumeric() : ""); + $this->send("OM", $user->getNumeric(), $chanName, $modestr); + } + } if($this->eventHandler) $this->eventHandler->event_join($user, $channel, false); }