本文整理汇总了PHP中_pfc函数的典型用法代码示例。如果您正苦于以下问题:PHP _pfc函数的具体用法?PHP _pfc怎么用?PHP _pfc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_pfc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
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=".$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 . "');");
}
}
示例2: run
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 . "');");
}
示例3: run
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);
}
示例4: run
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);
}
示例5: run
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) . "');");
}
示例6: run
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+'\"');");
}
}
示例7: run
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));
}
示例8: run
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);
}
示例9: run
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 . "');");
}
}
示例10: run
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);
}
示例11: getOutput
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;
}
示例12: run
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) . "'));");
}
示例13: init
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;
*/
}
示例14: run
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);
}
示例15: pfcInfo
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);
}