function run(&$xml_reponse, $p)
 {
     $c =& pfcGlobalConfig::Instance();
     $u =& pfcUserConfig::Instance();
     $ct =& pfcContainer::Instance();
     $banlist = $ct->getChanMeta($p["recipient"], 'banlist_nickid');
     if ($banlist == NULL) {
         $banlist = array();
     } else {
         $banlist = unserialize($banlist);
     }
     $msg = "";
     $msg .= "<p>" . _pfc("The banished user list is:") . "</p>";
     if (count($banlist) > 0) {
         $msg .= "<ul>";
         foreach ($banlist as $b) {
             $n = $ct->getNickname($b);
             $msg .= "<li style=\"margin-left:50px\">" . $n . "</li>";
         }
         $msg .= "</ul>";
     } else {
         $msg .= "<p>(" . _pfc("Empty") . ")</p>";
     }
     $msg .= "<p>" . _pfc("'/unban {nickname}' will unban the user identified by {nickname}") . "</p>";
     $msg .= "<p>" . _pfc("'/unban all'  will unban all the users on this channel") . "</p>";
     $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ok', '" . addslashes($msg) . "');");
 }
 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();
     /**
      * fixes some anoying issues with noflood not detecting user flooding the chat
      * those are notice and invite
      */
     $cmdtocheck = array("send", "nick", "me", "notice", "invite");
     // fixes the count of noflood even if the text posted was empty (Neumann Valle (UTAN))
     if (in_array($this->name, $cmdtocheck) && $param != "") {
         $container =& pfcContainer::Instance();
         $nickid = $u->nickid;
         $isadmin = $container->getUserMeta($nickid, 'isadmin');
         $lastfloodtime = $container->getUserMeta($nickid, 'floodtime');
         $flood_nbmsg = $container->getUserMeta($nickid, 'flood_nbmsg');
         $flood_nbchar = $container->getUserMeta($nickid, 'flood_nbchar');
         $floodtime = time();
         if ($floodtime - $lastfloodtime <= $c->proxies_cfg[$this->proxyname]["delay"]) {
             // update the number of posted message indicator
             $flood_nbmsg++;
             // update the number of posted characteres indicator
             $flood_nbchar += utf8_strlen($param);
         } else {
             $flood_nbmsg = 0;
             $flood_nbchar = 0;
         }
         if (!$isadmin && ($flood_nbmsg > $c->proxies_cfg[$this->proxyname]["msglimit"] || $flood_nbchar > $c->proxies_cfg[$this->proxyname]["charlimit"])) {
             // warn the flooder
             $msg = _pfc("Please don't post so many message, flood is not tolerated");
             $xml_reponse->script("alert('" . addslashes($msg) . "');");
             // kick the flooder
             $cmdp = $p;
             $cmdp["param"] = null;
             $cmdp["params"][0] = "ch";
             $cmdp["params"][1] = $u->channels[$recipientid]["name"];
             $cmdp["params"][2] .= _pfc("kicked from %s by %s", $u->channels[$recipientid]["name"], "noflood");
             $cmd =& pfcCommand::Factory("leave");
             $cmd->run($xml_reponse, $cmdp);
             return false;
         }
         if ($flood_nbmsg == 0) {
             $container->setUserMeta($nickid, 'floodtime', $floodtime);
         }
         $container->setUserMeta($nickid, 'flood_nbmsg', $flood_nbmsg);
         $container->setUserMeta($nickid, 'flood_nbchar', $flood_nbchar);
     }
     // forward the command to the next proxy or to the final command
     $p["clientid"] = $clientid;
     $p["param"] = $param;
     $p["sender"] = $sender;
     $p["recipient"] = $recipient;
     $p["recipientid"] = $recipientid;
     return $this->next->run($xml_reponse, $p);
 }
 function run(&$xml_reponse, $p)
 {
     $clientid = $p["clientid"];
     $msg = $p["param"];
     $sender = $p["sender"];
     $recipient = $p["recipient"];
     $recipientid = $p["recipientid"];
     $flag = isset($p["flag"]) ? $p["flag"] : 7;
     $c =& pfcGlobalConfig::Instance();
     $u =& pfcUserConfig::Instance();
     $ct =& pfcContainer::Instance();
     if ($c->shownotice > 0 && ($c->shownotice & $flag) == $flag) {
         $msg = phpFreeChat::FilterSpecialChar($msg);
         $msg = $flag == 7 ? '(' . $sender . ') ' . $msg : $msg;
         $nick = $ct->getNickname($u->nickid);
         $res = $ct->write($recipient, $nick, "notice", $msg);
         if (is_array($res)) {
             $cmdp = $p;
             $cmdp["param"] = implode(",", $res);
             $cmd =& pfcCommand::Factory("error");
             $cmd->run($xml_reponse, $cmdp);
             return;
         }
     }
 }
 function run(&$xml_reponse, $p)
 {
     $clientid = $p["clientid"];
     $param = $p["param"];
     $sender = $p["sender"];
     $recipient = $p["recipient"];
     $recipientid = $p["recipientid"];
     $u =& pfcUserConfig::Instance();
     $nick = $u->nick;
     $ct =& pfcContainer::Instance();
     $text = trim($param);
     // Call parse roll
     require_once dirname(__FILE__) . '/demo27_dice.class.php';
     $dice = new Dice();
     if (!$dice->check($text)) {
         $result = $dice->error_get();
         $cmdp = $p;
         $cmdp["param"] = "Cmd_roll failed: " . $result;
         $cmd =& pfcCommand::Factory("error");
         $cmd->run($xml_reponse, $cmdp);
     } else {
         $result = $dice->roll();
         $ct->write($recipient, $nick, "send", $result);
     }
 }
Exemple #5
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();
     if ($param != "") {
         require_once dirname(__FILE__) . "/join.class.php";
         $recipient = pfcCommand_join::GetRecipient($param);
         $recipientid = pfcCommand_join::GetRecipientId($param);
     }
     $chanmeta = $this->_getChanMeta($recipient, $recipientid);
     //if (preg_match("/^pv_/", $recipient))
     //$this->trace($xml_reponse, 'who2', $recipient);
     // check if info didn't change since last call
     $sid = "pfc_who2_" . $c->getId() . "_" . $clientid . "_" . $recipientid;
     if (isset($_SESSION[$sid]) && $chanmeta == $_SESSION[$sid]) {
         // do not send the response to save bandwidth
         //$xml_reponse->script("pfc.handleResponse('".$this->name."', 'unchanged', '');");
     } else {
         $_SESSION[$sid] = $chanmeta;
         $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ok', " . $chanmeta . ");");
     }
 }
Exemple #6
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();
     // check the user has not been disconnected from the server by timeout
     // if he has been disconnected, then I reconnect him with /connect command
     if ($u->nick != '' && !$u->isOnline()) {
         $cmd =& pfcCommand::Factory("connect");
         $cmdp = $p;
         $cmdp['params'] = array($u->nick);
         $cmdp['getoldmsg'] = false;
         $cmdp['joinoldchan'] = false;
         $cmd->run($xml_reponse, $cmdp);
     }
     // do not update if user isn't active (didn't connect)
     if ($u->isOnline()) {
         $cmdp = $p;
         // update the user nickname timestamp on the server
         $cmd =& pfcCommand::Factory("updatemynick");
         $cmdp["recipient"] = NULL;
         $cmdp["recipientid"] = NULL;
         $cmd->run($xml_reponse, $cmdp);
         // get other online users on each channels
         $cmd =& pfcCommand::Factory("who2");
         foreach ($u->channels as $id => $chan) {
             $cmdp["recipient"] = $chan["recipient"];
             $cmdp["recipientid"] = $id;
             $cmdp["param"] = '';
             // don't forward the parameter because it will be interpreted as a channel name
             $cmd->run($xml_reponse, $cmdp);
         }
         foreach ($u->privmsg as $id => $pv) {
             $cmdp["recipient"] = $pv["recipient"];
             $cmdp["recipientid"] = $id;
             $cmdp["param"] = '';
             // don't forward the parameter because it will be interpreted as a channel name
             $cmd->run($xml_reponse, $cmdp);
         }
         // get new message posted on each channels
         $cmd =& pfcCommand::Factory("getnewmsg");
         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('update', 'ok', '');");
     } else {
         $xml_reponse->script("pfc.handleResponse('update', 'ko', '');");
     }
 }
 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+'\"');");
     }
 }
Exemple #8
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();
     $ignore = array("updatemynick", "getnewmsg", "notice", "getonlinenick", "error", "update", "asknick");
     $cmdlist = array();
     $dh = opendir(dirname(__FILE__));
     while (false !== ($file = readdir($dh))) {
         if (!preg_match("/^([a-z]+).class.php\$/i", $file, $res)) {
             continue;
         }
         if (!in_array($res[1], $ignore)) {
             $cmdlist[] = $res[1];
         }
     }
     closedir($dh);
     sort($cmdlist);
     $str = _pfc("Here is the command list:") . "<br/>";
     $str .= implode("<br/>", $cmdlist);
     $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ok', '" . $str . "');");
 }
 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();
     $password = trim($param);
     $isadmin = false;
     //     $xml_reponse->script("alert('sender=".$sender."');");
     //     $xml_reponse->script("alert('password="******"');");
     //     $xml_reponse->script("alert('admins=".var_export($c->admins, true)."');");
     if (isset($c->admins[$sender]) && $c->admins[$sender] == $password) {
         $isadmin = true;
     }
     $msg = "";
     if ($isadmin) {
         // ok the current user is an admin, just save the isadmin flag in the metadata
         $ct =& pfcContainer::Instance();
         $ct->setUserMeta($u->nickid, 'isadmin', $isadmin);
         $this->forceWhoisReload($u->nickid);
         $msg .= _pfc("Succesfully identified");
         $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ok', '" . $msg . "');");
     } else {
         $msg .= _pfc("Identification failure");
         $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ko', '" . $msg . "');");
     }
 }
Exemple #10
0
 function run(&$xml_reponse, $p)
 {
     $cmdtocheck = array("send", "me", "notice");
     if (in_array($this->name, $cmdtocheck)) {
         $clientid = $p["clientid"];
         $param = $p["param"];
         $sender = $p["sender"];
         $recipient = $p["recipient"];
         $recipientid = $p["recipientid"];
         $c =& pfcGlobalConfig::Instance();
         $u =& pfcUserConfig::Instance();
         $logpath = $c->proxies_cfg[$this->proxyname]["path"] == "" ? $c->data_private_path . "/logs" : $c->proxies_cfg[$this->proxyname]["path"];
         $logpath .= "/" . $c->getId();
         if (!file_exists($logpath)) {
             @mkdir_r($logpath);
         }
         if (file_exists($logpath) && is_writable($logpath)) {
             $logfile = $logpath . "/chat.log";
             if (is_writable($logpath)) {
                 // @todo write logs in a cleaner structured language (xml, html ... ?)
                 $log = $recipient . "\t";
                 $log .= date("d/m/Y") . "\t";
                 $log .= date("H:i:s") . "\t";
                 $log .= $sender . "\t";
                 $log .= $param . "\n";
                 file_put_contents($logfile, $log, FILE_APPEND | LOCK_EX);
             }
         }
     }
     // forward the command to the next proxy or to the final command
     return $this->next->run($xml_reponse, $p);
 }
Exemple #11
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;
     }
     // just change the "isadmin" meta flag
     $nicktoop = trim($param);
     $nicktoopid = $ct->getNickId($nicktoop);
     $ct->setUserMeta($nicktoopid, 'isadmin', true);
     $this->forceWhoisReload($nicktoopid);
 }
Exemple #12
0
 function run(&$xml_reponse, $p)
 {
     $clientid = $p["clientid"];
     $param = $p["param"];
     $params = $p["params"];
     $sender = $p["sender"];
     $recipient = $p["recipient"];
     $recipientid = $p["recipientid"];
     $c =& pfcGlobalConfig::Instance();
     $u =& pfcUserConfig::Instance();
     $nick = isset($params[0]) ? $params[0] : '';
     $reason = isset($params[1]) ? $params[1] : '';
     if ($reason == '') {
         $reason = _pfc("no reason");
     }
     // to allow unquotted reason
     if (count($params) > 2) {
         for ($x = 2; $x < count($params); $x++) {
             $reason .= " " . $params[$x];
         }
     }
     $channame = $u->channels[$recipientid]["name"];
     if ($nick == '') {
         // error
         $cmdp = $p;
         $cmdp["param"] = _pfc("Missing parameter");
         $cmdp["param"] .= " (" . $this->usage . ")";
         $cmd =& pfcCommand::Factory("error");
         $cmd->run($xml_reponse, $cmdp);
         return;
     }
     $ct =& pfcContainer::Instance();
     $nickidtoban = $ct->getNickId($nick);
     // notify all the channel
     $cmdp = $p;
     $cmdp["param"] = _pfc("%s banished from %s by %s", $nick, $channame, $sender);
     $cmdp["flag"] = 1;
     $cmd =& pfcCommand::Factory("notice");
     $cmd->run($xml_reponse, $cmdp);
     // kick the user (maybe in the future, it will be dissociate in a /kickban command)
     $cmdp = $p;
     $cmdp["params"] = array();
     $cmdp["params"][] = $nick;
     // nickname to kick
     $cmdp["params"][] = $reason;
     // reason
     $cmd =& pfcCommand::Factory("kick");
     $cmd->run($xml_reponse, $cmdp);
     // update the recipient banlist
     $banlist = $ct->getChanMeta($recipient, 'banlist_nickid');
     if ($banlist == NULL) {
         $banlist = array();
     } else {
         $banlist = unserialize($banlist);
     }
     $banlist[] = $nickidtoban;
     // append the nickid to the banlist
     $ct->setChanMeta($recipient, 'banlist_nickid', serialize($banlist));
 }
 function run(&$xml_reponse, $p)
 {
     $clientid = $p["clientid"];
     $param = $p["param"];
     $params = $p["params"];
     $sender = $p["sender"];
     $recipient = $p["recipient"];
     $recipientid = $p["recipientid"];
     $c =& pfcGlobalConfig::Instance();
     // pfcGlobalConfig
     $u =& pfcUserConfig::Instance();
     // pfcUserConfig
     $ct =& pfcContainer::Instance();
     // Connection to the chatbackend
     $nicktoinvite = isset($params[0]) ? $params[0] : '';
     $channeltarget = isset($params[1]) ? $params[1] : $u->channels[$recipientid]["name"];
     // Default: current channel
     if ($nicktoinvite == '' || $channeltarget == '') {
         // Parameters are not ok
         $cmdp = $p;
         $cmdp["params"] = array();
         $cmdp["param"] = _pfc("Missing parameter");
         $cmdp["param"] .= " (" . $this->usage . ")";
         $cmd =& pfcCommand::Factory("error");
         $cmd->run($xml_reponse, $cmdp);
         return;
     }
     // check that the inviter is already in the channeltarget
     if (!$ct->isNickOnline(pfcCommand_join::GetRecipient($channeltarget), $u->nickid)) {
         $cmdp = $p;
         $cmdp["params"] = array();
         $cmdp["param"] = _pfc("You must join %s to invite users in this channel", $channeltarget);
         $cmd =& pfcCommand::Factory("error");
         $cmd->run($xml_reponse, $cmdp);
         return;
     }
     // inviting a user: just add a join command to play to the aimed user metadata.
     $nicktoinvite_id = $ct->getNickId($nicktoinvite);
     $cmdstr = 'join2';
     $cmdp = array();
     $cmdp['param'] = $channeltarget;
     // channel target name
     $cmdp['params'][] = $channeltarget;
     // channel target name
     pfcCommand::AppendCmdToPlay($nicktoinvite_id, $cmdstr, $cmdp);
     // notify the aimed channel that a user has been invited
     $cmdp = array();
     $cmdp["param"] = _pfc("%s was invited by %s", $nicktoinvite, $sender);
     $cmdp["flag"] = 1;
     $cmdp["recipient"] = pfcCommand_join::GetRecipient($channeltarget);
     $cmdp["recipientid"] = pfcCommand_join::GetRecipientId($channeltarget);
     $cmd =& pfcCommand::Factory("notice");
     $cmd->run($xml_reponse, $cmdp);
 }
Exemple #14
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();
     $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ok', '" . $c->version . "');");
 }
 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();
     $ct->updateNick($u->nickid);
 }
Exemple #16
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();
     $cmd =& pfcCommand::Factory("quit");
     $cmd->run($xml_reponse, $p);
     $u->destroy();
 }
 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);
 }
Exemple #18
0
 function run(&$xml_reponse, $p)
 {
     $clientid = $p["clientid"];
     $param = $p["param"];
     $params = $p["params"];
     $sender = $p["sender"];
     $recipient = $p["recipient"];
     $recipientid = $p["recipientid"];
     $c =& pfcGlobalConfig::Instance();
     $u =& pfcUserConfig::Instance();
     $ct =& pfcContainer::Instance();
     $nick = isset($params[0]) ? $params[0] : '';
     $nickid = $ct->getNickId($nick);
     if ($nick == "") {
         // error
         $cmdp = $p;
         $cmdp["param"] = _pfc("Missing parameter");
         $cmdp["param"] .= " (" . $this->usage . ")";
         $cmd =& pfcCommand::Factory("error");
         $cmd->run($xml_reponse, $cmdp);
         return;
     }
     $updated = false;
     $msg = "<p>" . _pfc("Nobody has been unbanished") . "</p>";
     // update the recipient banlist
     $banlist = $ct->getChanMeta($recipient, 'banlist_nickid');
     if ($banlist == NULL) {
         $banlist = array();
     } else {
         $banlist = unserialize($banlist);
     }
     $nb = count($banlist);
     if (in_array($nickid, $banlist)) {
         $banlist = array_diff($banlist, array($nickid));
         $ct->setChanMeta($recipient, 'banlist_nickid', serialize($banlist));
         $updated = true;
         $msg = "<p>" . _pfc("%s has been unbanished", $nick) . "</p>";
     } else {
         if ($nick == "all") {
             $banlist = array();
             $ct->setChanMeta($recipient, 'banlist_nickid', serialize($banlist));
             $updated = true;
             $msg = "<p>" . _pfc("%s users have been unbanished", $nb) . "</p>";
         }
     }
     if ($updated) {
         $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ok', '" . $msg . "');");
     } else {
         $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ko', '" . $msg . "');");
     }
 }
Exemple #19
0
 function run(&$xml_reponse, $p)
 {
     $clientid = $p["clientid"];
     $param = $p["param"];
     $params = $p["params"];
     $sender = $p["sender"];
     $recipient = $p["recipient"];
     $recipientid = $p["recipientid"];
     $c =& pfcGlobalConfig::Instance();
     $u =& pfcUserConfig::Instance();
     $ct =& pfcContainer::Instance();
     //    $xml_reponse->script("trace('".implode(',',$params)."');");
     //    return;
     // get the nickid from the parameters
     // if the run command is whois2 then the parameter is a nickid
     $nickid = '';
     if ($this->name == 'whois2') {
         $nickid = $params[0];
     } else {
         $nickid = $ct->getNickId($params[0]);
     }
     if ($nickid) {
         $usermeta = $ct->getAllUserMeta($nickid);
         $usermeta['nickid'] = $nickid;
         unset($usermeta['cmdtoplay']);
         // used internaly
         // remove private usermeta from the list if the client is not admin
         $isadmin = $ct->getUserMeta($u->nickid, 'isadmin');
         if (!$isadmin) {
             foreach ($c->nickmeta_private as $nmp) {
                 unset($usermeta[$nmp]);
             }
         }
         // sort the list
         $nickmeta_sorted = array();
         $order = array_merge(array_diff(array_keys($usermeta), array_keys($c->nickmeta)), array_keys($c->nickmeta));
         foreach ($order as $o) {
             $nickmeta_sorted[$o] = $usermeta[$o];
         }
         $usermeta = $nickmeta_sorted;
         require_once dirname(__FILE__) . '/../pfcjson.class.php';
         $json = new pfcJSON();
         $js = $json->encode($usermeta);
         $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ok', " . $js . ");");
     } else {
         $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ko','" . $param . "');");
     }
 }
Exemple #20
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();
     $channame = trim($param);
     $chanrecip = pfcCommand_join::GetRecipient($channame);
     $chanid = pfcCommand_join::GetRecipientId($channame);
     if ($channame == "") {
         $cmdp = $p;
         $cmdp["param"] = _pfc("Missing parameter");
         $cmdp["param"] .= " (" . $this->usage . ")";
         $cmd =& pfcCommand::Factory("error");
         $cmd->run($xml_reponse, $cmdp);
         return;
     }
     if (!isset($u->channels[$chanid])) {
         if ($c->max_channels <= count($u->channels)) {
             // the maximum number of joined channels has been reached
             $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'max_channels', Array());");
             return;
         }
         $u->channels[$chanid]["recipient"] = $chanrecip;
         $u->channels[$chanid]["name"] = $channame;
         $u->saveInCache();
         // show a join message
         $cmdp = $p;
         $cmdp["param"] = _pfc("%s joins %s", $u->getNickname(), $channame);
         $cmdp["recipient"] = $chanrecip;
         $cmdp["recipientid"] = $chanid;
         $cmdp["flag"] = 2;
         $cmd =& pfcCommand::Factory("notice");
         $cmd->run($xml_reponse, $cmdp);
     }
     // register the user (and his metadata) in the channel
     $ct =& pfcContainer::Instance();
     //    $ct->createNick($chanrecip, $u->nick, $u->nickid);
     $ct->joinChan($u->nickid, $chanrecip);
     $this->forceWhoisReload($u->nickid);
     // return ok to the client
     // then the client will create a new tab
     $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ok', Array('" . $chanid . "','" . addslashes($channame) . "'));");
 }
Exemple #21
0
 /**
  * Virtual method which must be implemented by concrete commands.
  * It is called by the phpFreeChat::HandleRequest function to execute the wanted command.
  */
 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();
     // toggle away-status.
     $is_away = $ct->getUserMeta($u->nickid, 'away');
     // If it's on, turn it off.
     if ($is_away == 'yes') {
         $ct->setUserMeta($u->nickid, 'away', 'no');
         $is_away = 'no';
         $pfc_msg = "{$u->nick} is back";
         $away_img = $c->getFileUrlFromTheme('images/away-off.gif');
     } else {
         $ct->setUserMeta($u->nickid, 'away', 'yes');
         $is_away = 'yes';
         $pfc_msg = "{$u->nick} is away";
         $away_img = $c->getFileUrlFromTheme('images/away-on.gif');
     }
     // refresh the nick list and nick box with away-status.
     $u->saveInCache();
     $this->forceWhoisReload($u->nickid);
     // notify all the joined channels/privmsg.
     $cmdp = $p;
     //	$cmdp["param"] = _pfc($pfc_msg);
     $cmdp["param"] = $pfc_msg;
     $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);
     }
     // refresh the away button.
     $xml_reponse->script("pfc.handleResponse('" . $this->name . "', '" . $is_away . "', '" . $away_img . "');");
     return;
 }
Exemple #22
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();
     if ($param != "") {
         require_once dirname(__FILE__) . "/join.class.php";
         $recipient = pfcCommand_join::GetRecipient($param);
         $recipientid = pfcCommand_join::GetRecipientId($param);
     }
     $chanmeta = $this->_getChanMeta($recipient, $recipientid);
     $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ok', " . $chanmeta . ");");
 }
Exemple #23
0
 function run(&$xml_reponse, $p)
 {
     $clientid = $p["clientid"];
     $param = $p["param"];
     $params = $p["params"];
     $sender = $p["sender"];
     $recipient = $p["recipient"];
     $recipientid = $p["recipientid"];
     $c =& pfcGlobalConfig::Instance();
     $u =& pfcUserConfig::Instance();
     $nick = isset($params[0]) ? $params[0] : '';
     $reason = isset($params[1]) ? $params[1] : '';
     if ($reason == '') {
         $reason = _pfc("no reason");
     }
     // to allow unquotted reason
     if (count($params) > 2) {
         for ($x = 2; $x < count($params); $x++) {
             $reason .= " " . $params[$x];
         }
     }
     if ($nick == '') {
         // error
         $cmdp = $p;
         $cmdp["param"] = _pfc("Missing parameter");
         $cmdp["param"] .= " (" . $this->usage . ")";
         $cmd =& pfcCommand::Factory("error");
         $cmd->run($xml_reponse, $cmdp);
         return;
     }
     // kicking a user just add a command to play to the aimed user metadata.
     $ct =& pfcContainer::Instance();
     $otherid = $ct->getNickId($nick);
     $channame = $u->channels[$recipientid]["name"];
     $cmdstr = 'leave';
     $cmdp = array();
     $cmdp['flag'] = 4;
     $cmdp['params'][] = 'ch';
     $cmdp['params'][] = $channame;
     // channel name
     $cmdp['params'][] = _pfc("kicked from %s by %s - reason: %s", $channame, $sender, $reason);
     // reason
     pfcCommand::AppendCmdToPlay($otherid, $cmdstr, $cmdp);
 }
Exemple #24
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();
     $nick = $ct->getNickname($u->nickid);
     // leave the channels
     foreach ($u->channels as $id => $chandetail) {
         if ($ct->removeNick($chandetail["recipient"], $u->nickid)) {
             $cmdp = $p;
             $cmdp["param"] = $id;
             $cmdp["recipient"] = $chandetail["recipient"];
             $cmdp["recipientid"] = $id;
             $cmd =& pfcCommand::Factory("leave");
             $cmd->run($xml_reponse, $cmdp);
         }
     }
     // leave the private messages
     foreach ($u->privmsg as $id => $pvdetail) {
         if ($ct->removeNick($pvdetail["recipient"], $u->nickid)) {
             $cmdp = $p;
             $cmdp["param"] = $id;
             $cmdp["recipient"] = $pvdetail["recipient"];
             $cmdp["recipientid"] = $id;
             $cmd =& pfcCommand::Factory("leave");
             $cmd->run($xml_reponse, $cmdp);
         }
     }
     // leave the server
     $ct->removeNick(NULL, $u->nickid);
     /*
     // then set the chat inactive
     $u->active = false;
     $u->saveInCache();
     */
     $xml_reponse->script("pfc.handleResponse('quit', 'ok', '');");
 }
 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();
     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;
     }
     $xml_reponse->redirect($param);
 }
Exemple #26
0
 /**
  * reset the channel identifiers
  */
 function _resetChannelIdentifier($clientid)
 {
     $c =& pfcGlobalConfig::Instance();
     $u =& pfcUserConfig::Instance();
     $ct =& pfcContainer::Instance();
     // reset the channel identifiers
     require_once dirname(__FILE__) . "/join.class.php";
     $channels = array();
     if (count($u->channels) == 0) {
         $channels = $c->channels;
     } else {
         foreach ($u->channels as $chan) {
             $channels[] = $chan["name"];
         }
     }
     foreach ($channels as $channame) {
         $chanrecip = pfcCommand_join::GetRecipient($channame);
         $chanid = pfcCommand_join::GetRecipientId($channame);
         // reset the fromid flag
         $from_id_sid = "pfc_from_id_" . $c->getId() . "_" . $clientid . "_" . $chanid;
         $from_id = $ct->getLastId($chanrecip) - $c->max_msg;
         $_SESSION[$from_id_sid] = $from_id < 0 ? 0 : $from_id;
         // reset the oldmsg flag
         $oldmsg_sid = "pfc_oldmsg_" . $c->getId() . "_" . $clientid . "_" . $chanid;
         $_SESSION[$oldmsg_sid] = true;
     }
     // reset the private messages identifiers
     if (count($u->privmsg) > 0) {
         foreach ($u->privmsg as $recipientid2 => $pv) {
             $recipient2 = $pv['recipient'];
             // reset the fromid flag
             $from_id_sid = "pfc_from_id_" . $c->getId() . "_" . $clientid . "_" . $recipientid2;
             $from_id = $ct->getLastId($recipient2) - $c->max_msg;
             $_SESSION[$from_id_sid] = $from_id < 0 ? 0 : $from_id;
             // reset the oldmsg flag
             $oldmsg_sid = "pfc_oldmsg_" . $c->getId() . "_" . $clientid . "_" . $recipientid2;
             $_SESSION[$oldmsg_sid] = true;
         }
     }
 }
 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();
     if (!isset($_SESSION["nocensor"]) || !$_SESSION["nocensor"]) {
         $cmdtocheck = array("send", "nick", "me");
         if (in_array($this->name, $cmdtocheck)) {
             $words = $c->proxies_cfg[$this->proxyname]["words"];
             $replaceby = $c->proxies_cfg[$this->proxyname]["replaceby"];
             $regex = $c->proxies_cfg[$this->proxyname]["regex"];
             $patterns = array();
             $replacements = array();
             foreach ($words as $w) {
                 if ($regex) {
                     // the words are regular expressions
                     $patterns[] = "/" . $w . "/ie";
                     $replacements[] = "'\\1'.str_repeat('{$replaceby}',strlen('\\2')).'\\3'";
                 } else {
                     // the words are simple words
                     $patterns[] = "/" . preg_quote($w) . "/i";
                     $replacements[] = str_repeat($replaceby, strlen($w));
                 }
             }
             $param = preg_replace($patterns, $replacements, $param);
         }
     }
     // forward the command to the next proxy or to the final command
     $p["clientid"] = $clientid;
     $p["param"] = $param;
     $p["sender"] = $sender;
     $p["recipient"] = $recipient;
     $p["recipientid"] = $recipientid;
     return $this->next->run($xml_reponse, $p);
 }
Exemple #28
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;
     }
     $msg = phpFreeChat::PreFilterMsg($param);
     $ct->write($recipient, "*me*", $this->name, $u->getNickname() . " " . $msg);
 }
Exemple #29
0
 function run(&$xml_reponse, $p)
 {
     $c =& pfcGlobalConfig::Instance();
     $u =& pfcUserConfig::Instance();
     if ($p["param"] == "userconfig") {
         $msg = "";
         $msg .= var_export($u, true);
         $msg = str_replace("\n", "", addslashes(nl2br($msg)));
         $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ok', '" . $msg . "');");
     }
     if ($p["param"] == "globalconfig") {
         $msg = "";
         $msg .= var_export($c, true);
         $msg = str_replace("\n", "", addslashes(nl2br($msg)));
         $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ok', '" . $msg . "');");
     }
     if ($p["param"] == "phpserver") {
         $msg = "";
         $msg .= var_export($_SERVER, true);
         $msg = str_replace("\n", "", addslashes(nl2br($msg)));
         $xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ok', '" . $msg . "');");
     }
 }
Exemple #30
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();
     $nick = $u->getNickname();
     $text_src = phpFreeChat::PreFilterMsg(trim($param));
     $text_src = str_replace(" ", "", $text_src);
     try {
         $p = new Parser($text_src);
         $p->setDebug($ct, $nick, $recipient);
         $ov = $p->Parse();
         $text = $nick . " : " . $text_src . " >> " . $ov->str . " = " . $ov->val;
     } catch (Exception $e) {
         $text = "Error: " . $e->getMessage();
     }
     $ct->write($recipient, $nick, "send", $text);
 }