}
}
+ 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);
case "W":
$this->recv_whois($from, $arguments);
break;
+ case "A":
+ $this->recv_away($from, $arguments);
+ break;
//default
default:
//unknown cmd
private function recv_ping($from, $args) {
$this->send("Z", $args[0]); //simply PONG
+ P10_Channel::recheckAllChannels();
}
private function recv_nick($from, $args) {
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]);
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]);
$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);
+ }
+ }
+
/********************************************************************************************
* SERVER FUNCTIONS *
********************************************************************************************/
$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());
}
}
- 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] != "#")
$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);
}