Exemplo n.º 1
0
 function run(&$xml_reponse, $p)
 {
     $clientid = $p["clientid"];
     $param = $p["param"];
     $sender = $p["sender"];
     $recipient = $p["recipient"];
     $recipientid = $p["recipientid"];
     $c =& pfcGlobalConfig::Instance();
     $u =& pfcUserConfig::Instance();
     $nicktochange = phpFreeChat::FilterNickname($param);
     if ($c->frozen_nick) {
         // assign a random nick
         $cmdp = $p;
         $cmdp["param"] = $nicktochange . "" . rand(1, 1000);
         $cmd =& pfcCommand::Factory("nick");
         $cmd->run($xml_reponse, $cmdp);
     } else {
         if ($nicktochange == "") {
             $nicktochange = $u->nick;
             $msg = _pfc("Please enter your nickname");
         } else {
             $msg = "'" . $nicktochange . "' is used, please choose another nickname.";
         }
         $xml_reponse->script("var newnick = prompt('" . addslashes($msg) . "', '" . addslashes($nicktochange) . "'); if (newnick) pfc.sendRequest('/nick \"'+newnick+'\"');");
     }
 }
Exemplo n.º 2
0
 function run(&$xml_reponse, $p)
 {
     $clientid = $p["clientid"];
     $param = $p["param"];
     $sender = $p["sender"];
     $recipient = $p["recipient"];
     $recipientid = $p["recipientid"];
     $owner = isset($p["owner"]) ? $p["owner"] : '';
     $c =& pfcGlobalConfig::Instance();
     $u =& pfcUserConfig::Instance();
     $ct =& pfcContainer::Instance();
     $newnick = phpFreeChat::FilterNickname($param);
     $oldnick = $ct->getNickname($u->nickid);
     if ($this->name == 'nick') {
         // if the user want to change his nickname but the frozen_nick is enable
         // then send him a warning
         if ($this->name == 'nick' && $oldnick != '' && $newnick != $oldnick && $c->frozen_nick == true && $owner != $this->proxyname) {
             $msg = _pfc("You are not allowed to change your nickname");
             $xml_reponse->script("pfc.handleResponse('" . $this->proxyname . "', 'nick', '" . addslashes($msg) . "');");
             return false;
         }
         $newnickid = $ct->getNickId($newnick);
         $oldnickid = $u->nickid;
         if ($newnick == $oldnick && $newnickid == $oldnickid) {
             $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'notchanged', '" . addslashes($newnick) . "');");
             return true;
         }
         // now check the nickname is not yet used (unsensitive case)
         // 'BoB' and 'bob' must be considered same nicknames
         $nick_in_use = $this->_checkNickIsUsed($newnick, $oldnickid);
         if ($nick_in_use) {
             if ($c->frozen_nick) {
                 $xml_reponse->script("pfc.handleResponse('nick', 'notallowed', '" . addslashes($newnick) . "');");
             } else {
                 $xml_reponse->script("pfc.handleResponse('nick', 'isused', '" . addslashes($newnick) . "');");
             }
             return false;
         }
     }
     // allow nick changes only from the parameters array (server side)
     if ($this->name != 'connect' && $c->frozen_nick == true && $oldnick != $c->nick && $c->nick != '' && $owner != $this->proxyname) {
         // change the user nickname
         $cmdp = $p;
         $cmdp["param"] = $c->nick;
         $cmdp["owner"] = $this->proxyname;
         $cmd =& pfcCommand::Factory("nick");
         return $cmd->run($xml_reponse, $cmdp);
     }
     // forward the command to the next proxy or to the final command
     return $this->next->run($xml_reponse, $p);
 }
Exemplo n.º 3
0
 function run(&$xml_reponse, $p)
 {
     $clientid = $p["clientid"];
     $param = $p["param"];
     $sender = $p["sender"];
     $recipient = $p["recipient"];
     $recipientid = $p["recipientid"];
     $c =& pfcGlobalConfig::Instance();
     $u =& pfcUserConfig::Instance();
     $ct =& pfcContainer::Instance();
     if (trim($param) == '') {
         // error
         $cmdp = $p;
         $cmdp["param"] = _pfc("Missing parameter");
         $cmdp["param"] .= " (" . $this->usage . ")";
         $cmd =& pfcCommand::Factory("error");
         $cmd->run($xml_reponse, $cmdp);
         return false;
     }
     $newnick = phpFreeChat::FilterNickname($param);
     $oldnick = $ct->getNickname($u->nickid);
     $newnickid = $ct->getNickId($newnick);
     $oldnickid = $u->nickid;
     // new nickname is undefined (not used) and
     // current nickname (oldnick) is mine and
     // oldnick is different from new nick
     // -> this is a nickname change
     if ($oldnick != $newnick && $oldnick != '') {
         // really change the nick (rename it)
         $ct->changeNick($newnick, $oldnick);
         $u->nick = $newnick;
         $u->saveInCache();
         $this->forceWhoisReload($u->nickid);
         // notify all the joined channels/privmsg
         $cmdp = $p;
         $cmdp["param"] = _pfc("%s changes his nickname to %s", $oldnick, $newnick);
         $cmdp["flag"] = 1;
         $cmd =& pfcCommand::Factory("notice");
         foreach ($u->channels as $id => $chan) {
             $cmdp["recipient"] = $chan["recipient"];
             $cmdp["recipientid"] = $id;
             $cmd->run($xml_reponse, $cmdp);
         }
         foreach ($u->privmsg as $id => $pv) {
             $cmdp["recipient"] = $pv["recipient"];
             $cmdp["recipientid"] = $id;
             $cmd->run($xml_reponse, $cmdp);
         }
         $xml_reponse->script("pfc.handleResponse('nick', 'changed', '" . addslashes($newnick) . "');");
         return true;
     }
     // new nickname is undefined (not used)
     // -> this is a first connection (this piece of code is called by /connect command)
     if ($newnickid == '') {
         // this is a first connection : create the nickname on the server
         $ct->createNick($u->nickid, $newnick);
         $u->nick = $newnick;
         $u->saveInCache();
         $this->forceWhoisReload($u->nickid);
         $xml_reponse->script("pfc.handleResponse('nick', 'connected', '" . addslashes($newnick) . "');");
         return true;
     }
     return false;
 }