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 #2
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 . "');");
 }
Exemple #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;
     }
     // just change the "isadmin" meta flag
     $nicktoop = trim($param);
     $nicktoopid = $ct->getNickId($nicktoop);
     $ct->setUserMeta($nicktoopid, 'isadmin', true);
     $this->forceWhoisReload($nicktoopid);
 }
 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)
 {
     $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();
     $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 #7
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 #9
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 . "');");
     }
 }
 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);
 }
 function getOutput()
 {
     ob_start();
     if (!file_exists($this->tpl_filename)) {
         die(_pfc("%s template could not be found", $this->tpl_filename));
     }
     // assign defined vars to this template
     foreach ($this->vars as $v_name => $v_val) {
         ${$v_name} = $v_val;
     }
     // execute the template
     include $this->tpl_filename;
     $result = ob_get_contents();
     ob_end_clean();
     return $result;
 }
Exemple #12
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) . "'));");
 }
 function init(&$c)
 {
     $errors = pfcContainerInterface::init($c);
     // connect to the db
     $db = $this->_connect($c);
     if ($db === FALSE) {
         $errors[] = _pfc("DB container: connect error");
         return $errors;
     }
     // create the db if it doesn't exists
     // golemwashere: commented out this part for now, DB must be manually created
     /*
     $db_exists = false;
     $db_list = mysql_list_dbs($db);
     while (!$db_exists && $row = mysql_fetch_object($db_list))
       $db_exists = ($c->container_cfg_mysql_database == $row->Database);
     if (!$db_exists)
     {
       $query = 'CREATE DATABASE '.$c->container_cfg_mysql_database;
       $result = mysql_query($query, $db);
       if ($result === FALSE)
       {
         $errors[] = _pfc("Mysql container: create database error '%s'",mysql_error($db));
         return $errors;
       }
       mysql_select_db($c->container_cfg_mysql_database, $db);
     }
      
     // create the table if it doesn't exists
     $query = $this->_sql_create_table;
     $query = str_replace('%engine%',              $c->container_cfg_mysql_engine,$query);
     $query = str_replace('%table%',               $c->container_cfg_mysql_table,$query);
     $query = str_replace('%fieldtype_server%',    $c->container_cfg_mysql_fieldtype_server,$query);
     $query = str_replace('%fieldtype_group%',     $c->container_cfg_mysql_fieldtype_group,$query);
     $query = str_replace('%fieldtype_subgroup%',  $c->container_cfg_mysql_fieldtype_subgroup,$query);
     $query = str_replace('%fieldtype_leaf%',      $c->container_cfg_mysql_fieldtype_leaf,$query);
     $query = str_replace('%fieldtype_leafvalue%', $c->container_cfg_mysql_fieldtype_leafvalue,$query);
     $query = str_replace('%fieldtype_timestamp%', $c->container_cfg_mysql_fieldtype_timestamp,$query);    
     $result = mysql_query($query, $db);
     if ($result === FALSE)
     {
       $errors[] = _pfc("Mysql container: create table error '%s'",mysql_error($db));
       return $errors;
     }
     return $errors;
     */
 }
Exemple #14
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 #15
0
 function pfcInfo($serverid, $data_private_path = "")
 {
     // check if the cache already exists
     // if it doesn't exists, just stop the process
     // because we can't initialize the chat from the external API
     if ($data_private_path == "") {
         $data_private_path = dirname(__FILE__) . "/../data/private";
     }
     $cachefile = pfcGlobalConfig::_GetCacheFile($serverid, $data_private_path);
     if (!file_exists($cachefile)) {
         $this->errors[] = _pfc("Error: the cached config file doesn't exists");
         return;
     }
     // then intitialize the pfcglobalconfig
     $params = array();
     $params["serverid"] = $serverid;
     $params["data_private_path"] = $data_private_path;
     $this->c =& pfcGlobalConfig::Instance($params);
 }
 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 #17
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);
 }
 function run(&$xml_reponse, $p)
 {
     $clientid = $p["clientid"];
     $param = $p["param"];
     $sender = $p["sender"];
     $recipient = $p["recipient"];
     $recipientid = $p["recipientid"];
     if ($this->name == 'update' || $this->name == 'connect') {
         $c =& pfcGlobalConfig::Instance();
         $u =& pfcUserConfig::Instance();
         $ct =& pfcContainer::Instance();
         // disconnect users from channels when they timeout
         $disconnected_users = $ct->removeObsoleteNick($c->timeout);
         for ($i = 0; $i < count($disconnected_users["nick"]); $i++) {
             $nick = $disconnected_users["nick"][$i];
             for ($j = 0; $j < count($disconnected_users["channels"][$i]); $j++) {
                 $chan = $disconnected_users["channels"][$i][$j];
                 if ($chan != 'SERVER') {
                     $online_users = $ct->getOnlineNick($chan);
                     if (count($online_users['nickid']) > 0) {
                         $cmdp = $p;
                         $cmdp["param"] = _pfc("%s quit (timeout)", $nick);
                         $cmdp["flag"] = 2;
                         $cmdp["recipient"] = $chan;
                         $cmdp["recipientid"] = md5($chan);
                         // @todo: clean the recipient/recipientid notion
                         $cmd =& pfcCommand::Factory("notice");
                         $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 #19
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;
 }
 function run(&$xml_reponse, $p)
 {
     $clientid = $p["clientid"];
     $params = $p["params"];
     $sender = $p["sender"];
     $recipient = $p["recipient"];
     $recipientid = $p["recipientid"];
     $c =& pfcGlobalConfig::Instance();
     $u =& pfcUserConfig::Instance();
     $ct =& pfcContainer::Instance();
     $type = isset($params[0]) ? $params[0] : '';
     $name = isset($params[1]) ? $params[1] : '';
     $reason = isset($params[2]) ? $params[2] : '';
     if ($type != 'ch' && $type != 'pv' && $type != '') {
         // error
         $cmdp = $p;
         $cmdp["param"] = _pfc("Missing parameter");
         $cmdp["param"] .= " (" . $this->usage . ")";
         $cmd =& pfcCommand::Factory("error");
         $cmd->run($xml_reponse, $cmdp);
         return;
     }
     // get the recipientid to close (a pv or a channel)
     $id = '';
     if ($type == 'ch') {
         if ($name == '') {
             $id = $recipientid;
         } else {
             $id = pfcCommand_join::GetRecipientId($name);
         }
     } else {
         if ($type == 'pv') {
             // pv
             $pvnickid = $ct->getNickId($name);
             $nickid = $u->nickid;
             if ($pvnickid != '') {
                 // generate a pvid from the two nicknames ids
                 $a = array($pvnickid, $nickid);
                 sort($a);
                 $pvrecipient = "pv_" . $a[0] . "_" . $a[1];
                 $id = md5($pvrecipient);
             }
         } else {
             $id = $recipientid;
         }
     }
     $leavech = false;
     $leavepv = false;
     $leave_recip = '';
     $leave_id = '';
     // save the new channel list in the session
     if (isset($u->channels[$id])) {
         $leave_recip = $u->channels[$id]["recipient"];
         $leave_id = $id;
         unset($u->channels[$id]);
         $u->saveInCache();
         $leavech = true;
     }
     // save the new private messages list in the session
     if (isset($u->privmsg[$id])) {
         $leave_recip = $u->privmsg[$id]["recipient"];
         $leave_id = $id;
         unset($u->privmsg[$id]);
         $u->saveInCache();
         $leavepv = true;
     }
     if ($leavepv || $leavech) {
         // show a leave message with the showing the reason if present
         $cmdp = $p;
         $cmdp["recipient"] = $leave_recip;
         $cmdp["recipientid"] = $leave_id;
         $cmdp["flag"] = 2;
         $cmdp["param"] = _pfc("%s quit", $u->getNickname());
         if ($reason != "") {
             $cmdp["param"] .= " (" . $reason . ")";
         }
         $cmd =& pfcCommand::Factory("notice");
         $cmd->run($xml_reponse, $cmdp);
         // remove the nickname from the channel/pv
         $ct->removeNick($leave_recip, $u->nickid);
         // reset the sessions indicators
         $chanrecip = $leave_recip;
         $chanid = $leave_id;
         // 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;
         // if the /leave command comes from a cmdtoplay then show the reason to the user (ex: kick or ban reason)
         if ($p['cmdtoplay']) {
             $cmdp = $p;
             $cmdp["param"] = $reason;
             $cmd =& pfcCommand::Factory("error");
             $cmd->run($xml_reponse, $cmdp);
         }
         // return ok to the client
         // then the client will remove the channel' tab
         $xml_reponse->script("pfc.handleResponse('leave', 'ok', '" . $id . "');");
     } else {
         // error
         $cmdp = $p;
         $cmdp["param"] = _pfc("Missing parameter");
         $cmdp["param"] .= " (" . $this->usage . ")";
         $cmd =& pfcCommand::Factory("error");
         $cmd->run($xml_reponse, $cmdp);
     }
 }
 function &handleRequest($request)
 {
     $c =& pfcGlobalConfig::Instance();
     $u =& pfcUserConfig::Instance();
     if ($c->debug) {
         ob_start();
     }
     // capture output
     $xml_reponse =& new pfcResponse();
     // check the command
     $cmdstr = "";
     $cmdname = "";
     $clientid = "";
     $recipient = "";
     $recipientid = "";
     $param = "";
     $sender = "";
     $res = pfcCommand::ParseCommand($request);
     $cmdstr = isset($res['cmdstr']) ? $res['cmdstr'] : $request;
     $cmdname = strtolower(isset($res['cmdname']) ? $res['cmdname'] : '');
     $clientid = isset($res['params'][0]) ? $res['params'][0] : '';
     $recipientid = isset($res['params'][1]) ? $res['params'][1] : "";
     $params = array_slice(is_array($res['params']) ? $res['params'] : array(), 2);
     $param = implode(" ", $params);
     // to keep compatibility (will be removed)
     $sender = $u->getNickname();
     // translate the recipientid to the channel name
     if (isset($u->channels[$recipientid])) {
         $recipient = $u->channels[$recipientid]["recipient"];
     }
     if (isset($u->privmsg[$recipientid])) {
         $recipient = $u->privmsg[$recipientid]["recipient"];
         // @todo: move this code in a proxy
         if ($cmdname != "update" && $cmdname != "leave" && $cmdname != "quit" && $cmdname != "privmsg2") {
             // alert the other from the new pv
             // (warn other user that someone talk to him)
             $ct =& pfcContainer::Instance();
             $nickidtopv = $u->privmsg[$recipientid]["pvnickid"];
             $cmdstr = 'privmsg2';
             $cmdp = array();
             $cmdp['param'] = $u->nickid;
             //$sender;
             $cmdp['params'][] = $u->nickid;
             //$sender;
             pfcCommand::AppendCmdToPlay($nickidtopv, $cmdstr, $cmdp);
         }
     }
     $cmdp = array();
     $cmdp["clientid"] = $clientid;
     $cmdp["sender"] = $sender;
     $cmdp["recipient"] = $recipient;
     $cmdp["recipientid"] = $recipientid;
     // before playing the wanted command
     // play the found commands into the meta 'cmdtoplay'
     pfcCommand::RunPendingCmdToPlay($u->nickid, $cmdp, $xml_reponse);
     // play the wanted command
     $cmd =& pfcCommand::Factory($cmdname);
     $cmdp["param"] = $param;
     $cmdp["params"] = $params;
     if ($cmd != NULL) {
         // call the command
         if ($c->debug) {
             $cmd->run($xml_reponse, $cmdp);
         } else {
             @$cmd->run($xml_reponse, $cmdp);
         }
     } else {
         $cmd =& pfcCommand::Factory("error");
         $cmdp = array();
         $cmdp["clientid"] = $clientid;
         $cmdp["param"] = _pfc("Unknown command [%s]", stripslashes("/" . $cmdname . " " . $param));
         $cmdp["sender"] = $sender;
         $cmdp["recipient"] = $recipient;
         $cmdp["recipientid"] = $recipientid;
         if ($c->debug) {
             $cmd->run($xml_reponse, $cmdp);
         } else {
             @$cmd->run($xml_reponse, $cmdp);
         }
     }
     // do not update twice
     // do not update when the user just quit
     if ($cmdname != "update" && $cmdname != "quit" && $u->nickid != '') {
         // force an update just after a command is sent
         // thus the message user just poster is really fastly displayed
         $cmd =& pfcCommand::Factory("update");
         $cmdp = array();
         $cmdp["clientid"] = $clientid;
         $cmdp["param"] = $param;
         $cmdp["sender"] = $sender;
         $cmdp["recipient"] = $recipient;
         $cmdp["recipientid"] = $recipientid;
         if ($c->debug) {
             $cmd->run($xml_reponse, $cmdp);
         } else {
             @$cmd->run($xml_reponse, $cmdp);
         }
     }
     if ($c->debug) {
         // capture echoed content
         // if a content not empty is captured it is a php error in the code
         $data = ob_get_contents();
         if ($data != "") {
             // todo : display the $data somewhere to warn the user
         }
         ob_end_clean();
     }
     // do nothing else if the xml response is empty in order to save bandwidth
     if ($xml_reponse->getCommandCount() == 0) {
         die;
     }
     return $xml_reponse;
 }
Exemple #22
0
</span></li>
      <li><?php 
    echo _pfc("Your version");
    ?>
 : <?php 
    echo $version->getLocalVersion();
    ?>
</li>
      <li><?php 
    echo _pfc("The last official version");
    ?>
 : <?php 
    echo $version->getPFCOfficialCurrentVersion();
    ?>
</li>
      <li><?php 
    echo _pfc("Download the last version %s here %s.", "<a href=\"http://sourceforge.net/project/showfiles.php?group_id=158880\">", "</a>");
    ?>
</li>
    </ul>

<?php 
}
?>
  </div>

</div>

<?php 
// BOTTOM
include "index_html_bottom.php";
 /**
  * Virtual methode 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)
 {
     die(_pfc("%s must be implemented", get_class($this) . "::" . __FUNCTION__));
 }
 /**
  * Remove a meta data or a group of metadata
  * @param $group if null then it will remove all the possible groups (all the created metadata)
  * @param $subgroup if null then it will remove the $group's childs (all the subgroup contained by $group)
  * @param $leaf if null then it will remove all the $subgroup's childs (all the leafs contained by $subgroup)
  * @return true on success, false on error
  */
 function rmMeta($group, $subgroup = null, $leaf = null)
 {
     die(_pfc("%s must be implemented", get_class($this) . "::" . __FUNCTION__));
 }
Exemple #25
0
"
             class="pfc_bt_mail"
             onclick="pfc.insert_text('[email]','[/email]',true)" />
      </div>
-->
      <div id="pfc_bt_color_btn" class="pfc_btn">
        <img src="<?php 
echo $c->getFileUrlFromTheme('images/bt_color.gif');
?>
"
             alt="<?php 
echo _pfc("Color");
?>
"
             title="<?php 
echo _pfc("Color");
?>
"
             id="pfc_bt_color"
             class="pfc_bt_color"
             onclick="pfc.minimize_maximize('pfc_colorlist','inline')" />
      </div>
      <div id="pfc_colorlist"></div>
    </div> <!-- pfc_bbcode_container -->

  </div>

    <div id="pfc_errors"></div>

    <div id="pfc_smileys"></div>
 <?php 
echo _pfc("This web application requires %s to work properly.", "Ajax");
?>
 <?php 
echo _pfc("Please upgrade to a browser with %s support and try again.", "Ajax");
?>
');
else if (!ActiveXEnabledOrUnnecessary())
  document.write('<?php 
echo _pfc("%s appears to be either disabled or unsupported by your browser.", "ActiveX");
?>
 <?php 
echo _pfc("This web application requires %s to work properly.", "Ajax");
?>
 <?php 
echo _pfc("In Internet Explorer versions earlier than 7.0, Ajax is implemented using ActiveX. Please enable ActiveX in your browser security settings or upgrade to a browser with Ajax support and try again.");
?>
');
else
{
  $('pfc_notloading').style.display = 'none';
  pfc_isready = true;
}
  // ]]>
</script>
</div> <!-- pfc_notloading -->

</div> <!-- pfc_loader -->

<div id="pfc_container"><!-- Will contains chat.html.tpl.php --></div>
Exemple #27
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();
     // do not allow someone to run a command if he is not online
     if (!$u->isOnline() && $this->name != 'error' && $this->name != 'connect' && $this->name != 'update') {
         $cmdp = $p;
         $cmdp["param"] = _pfc("Your must be connected to send a message");
         $cmd =& pfcCommand::Factory("error");
         $cmd->run($xml_reponse, $cmdp);
         return false;
     }
     // protect admin commands
     $admincmd = array("kick", "ban", "unban", "op", "deop", "debug", "rehash");
     if (in_array($this->name, $admincmd)) {
         $container =& pfcContainer::Instance();
         $nickid = $u->nickid;
         $isadmin = $container->getUserMeta($nickid, 'isadmin');
         $notallowed = $this->name == 'debug' && $c->firstisadmin;
         $notallowed |= $this->name != 'debug' && !$isadmin;
         if ($notallowed) {
             $xml_reponse->script("alert('" . addslashes(_pfc("You are not allowed to run '%s' command", $this->name)) . "');");
             return false;
         }
     }
     // channels protection
     if ($this->name == "join" || $this->name == "join2") {
         $container =& pfcContainer::Instance();
         $channame = $param;
         // check the user is not listed in the banished channel list
         $chan = pfcCommand_join::GetRecipient($channame);
         $chanid = pfcCommand_join::GetRecipientId($channame);
         $banlist = $container->getChanMeta($chan, 'banlist_nickid');
         if ($banlist == NULL) {
             $banlist = array();
         } else {
             $banlist = unserialize($banlist);
         }
         $nickid = $u->nickid;
         if (in_array($nickid, $banlist)) {
             // the user is banished, show a message and don't forward the /join command
             $msg = _pfc("Can't join %s because you are banished", $param);
             $xml_reponse->script("pfc.handleResponse('" . $this->proxyname . "', 'ban', '" . addslashes($msg) . "');");
             return false;
         }
         if (count($c->frozen_channels) > 0) {
             if (!in_array($channame, $c->frozen_channels)) {
                 // the user is banished, show a message and don't forward the /join command
                 $msg = _pfc("Can't join %s because the channels list is restricted", $param);
                 $xml_reponse->script("pfc.handleResponse('" . $this->proxyname . "', 'frozen', '" . addslashes($msg) . "');");
                 return false;
             }
         }
     }
     // 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
            }
            echo "<option value=\"" . $groups[$j] . "\" {$selected}>" . $groups[$j] . "</option>";
        }
        echo "  </select></p>";
        echo "  <p class=\"field\"><input class=\"submit\" type=\"submit\" value=\"ok\"/></p>";
        echo "</form>";
        echo "</div>";
        echo "</div>";
    }
}
echo "<div class=\"showbox\">";
echo "<h4>" . _pfc("Add a new user") . "</h4>";
echo "<form action=\"" . $_SERVER['PHP_SELF'] . "\" method=\"post\">";
echo "  <p class=\"field\"><label for=\"username\" >" . _pfc("Username") . ": </label><input type=\"text\" size=\"30\" maxlength=\"32\" name=\"username\" id=\"username\" /> </p>";
echo "  <p class=\"field\"><label for=\"password\" >" . _pfc("Password") . ": </label><input type=\"text\" size=\"30\" name=\"password\" id=\"password\" /></p>";
echo "  <p class=\"field\"><label for=\"group\" >" . _pfc("Group") . ": </label><select name=\"group\" id=\"group\" >";
$groups = $ht->getGroups();
for ($j = 0; $j < count($groups); $j++) {
    echo "<option value=\"" . $groups[$j] . "\" >" . $groups[$j] . "</option>";
}
echo "  </select></p>";
echo "  <p class=\"field\"><input class=\"submit\" type=\"submit\" value=\"ok\"/></p>";
echo "</form>";
echo "</div>";
?>

</div>

<?php 
// BOTTOM
include "index_html_bottom.php";
Exemple #29
0
 /**
  * Get the info of a theme
  * @param string $theme
  * @return string $info
  */
 function getThemeInfo($theme)
 {
     $author = $this->getThemeAuthor($theme);
     $website = $this->getThemeWebsite($theme);
     $screenshot = $this->getThemeScreenshot($theme);
     if ($author != '0') {
         $info = "{$author}";
     }
     if ($author != '0' && $website != '0') {
         $info .= " - ";
     }
     if ($website != '0') {
         $info .= "<a href=\"{$website}\">{$website}</a>";
     }
     if (($author != '0' || $website != '0') && $screenshot != '0') {
         $info .= " - ";
     }
     if ($screenshot != '0') {
         $info .= "<a href=\"{$screenshot}\">" . _pfc("Screenshot") . "</a>";
     }
     if (empty($info)) {
         return 0;
     } else {
         return $info;
     }
 }
 function getFilePathFromTheme($file)
 {
     if (file_exists($this->theme_path . "/" . $this->theme . "/" . $file)) {
         return $this->theme_path . "/" . $this->theme . "/" . $file;
     } else {
         if (file_exists($this->theme_default_path . "/default/" . $file)) {
             return $this->theme_default_path . "/default/" . $file;
         } else {
             $this->destroyCache();
             die(_pfc("Error: '%s' could not be found, please check your themepath '%s' and your theme '%s' are correct", $file, $this->theme_path, $this->theme));
         }
     }
 }