* void setValidateServer(String $name, String $password)
* sets additional security relevant information about the remote server.
*
+ * void setHISOptions(String $serverName, String $serverDescription String $usermask)
+ * sets the default Account fakehost
+ *
* void setEventHandler(EventHandler $event_handler)
* sets the EventHandlder
*/
public function __construct() {
$this->client = new Client();
$this->setSetting("recv_timeout", 1000);
+ $this->setSetting("his_usermask", "user.NoMask");
}
public function initialize() {
$this->setSetting("their_password", $password);
}
+ public function setHISOptions($servername, $serverdesc, $usermask) {
+ $this->setSetting("his_name", $servername);
+ $this->setSetting("his_desc", $serverdesc);
+ $this->setSetting("his_usermask", $usermask);
+ }
+
public function setEventHandler($event_handler) {
if(!is_a($event_handler, "EventHandler")) {
trigger_error((is_object($event_handler) ? get_class($event_handler) : gettype($event_handler))." is NOT a valid EventHandler.", E_USER_ERROR);
case "O":
$this->recv_notice($from, $arguments);
break;
+ case "W":
+ $this->recv_whois($from, $arguments);
+ break;
//default
default:
//unknown cmd
}
}
+ private function recv_whois($from, $args) {
+ /* [get] ACAAF W AX :NetworkServ */
+ $fromUser = P10_User::getUserByNum($from);
+ if($fromUser == null) {
+ trigger_error("Server tries to send a whois from an user that does not exist or was not found on recv_whois.", E_USER_ERROR);
+ return;
+ }
+ $users=explode(",",$args[1]);
+ foreach($users as $nick) {
+ $user = P10_User::getUserByNick($nick);
+ if(!$user) {
+ $this->send("401", $from, $nick);
+ continue;
+ }
+ $nick = $user->getNick();
+ $ident = $user->getIdent();
+ $hostmask = $user->getHost();
+ $modes = $user->getModes();
+ if($modes->hasMode('x')) {
+ if(($fakehost = $modes->hasMode('f'))) {
+ $hostmask = $fakehost;
+ } elseif(($account = $modes->hasMode('r'))) {
+ $hostmask = $account.".".$this->getSetting("his_usermask");
+ }
+ }
+ $realname = $user->getRealname();
+ $this->send("311", $from , $nick, $ident, $hostmask, $realname);
+ if(((!$modes->hasMode('n') && !$modes->hasMode('k')) || $from == $user->getNumeric()) && count($user->getChannels()) != 0) {
+ $channels = "";
+ foreach($user->getChannels() as $channel) {
+ $cmodes = $channel->getModes();
+ $privs = $channel->getUserPrivs($user);
+ if($cmodes->hasMode("s") && !$fromUser->isOnChannel($channel) && $from != $user->getNumeric()) continue;
+ if($cmodes->hasMode("u") && ($privs & (P10_Channel::USERPRIV_OPPED | P10_Channel::USERPRIV_VOICE)) == 0 && $from != $user->getNumeric()) continue;
+ $chanstr = ($channels == "" ? "" : " ");
+ $prefix = "";
+ if(($privs & P10_Channel::USERPRIV_OPPED)) {
+ $prefix = "@";
+ } else if(($privs & P10_Channel::USERPRIV_VOICE)) {
+ $prefix = "+";
+ }
+ $chanstr .= $prefix.$channel->getName();
+ if(strlen($channels) + strlen($chanstr) > 450) {
+ $this->send("319", $from, $nick, $channels);
+ $channels = $prefix.$channel->getName();
+ }
+ }
+ if($channels != "") {
+ $this->send("319", $from, $nick, $channels);
+ }
+ if($fromUser->getModes()->hasMode("o") || $from == $user->getNumeric() || !$this->getSetting("his_name")) {
+ $this->send("312", $from, $nick, $user->getServer()->getName(), $user->getServer()->getDescription());
+ } else {
+ $this->send("312", $from, $nick, $this->getSetting("his_name"), $this->getSetting("his_desc"));
+ }
+ if($modes->hasMode("o") && (!$modes->hasMode("H") || $fromUser->getModes()->hasMode("o"))) {
+ if($modes->hasMode("S")) {
+ if($modes->hasMode("D"))
+ $this->send("313", $from, $nick, "is a Network Service");
+ else
+ $this->send("313", $from, $nick, "is an illegal Network Service - HACKER!");
+ } else
+ $this->send("313", $from, $nick, "is an IRC Operator");
+ }
+ if(($auth = $modes->hasMode("r"))) {
+ $this->send("330", $from, $nick, $auth);
+ }
+ }
+ }
+ $this->send("318", $from, $args[1]);
+ }
+
/********************************************************************************************
* SERVER FUNCTIONS *
********************************************************************************************/