本文整理汇总了PHP中phpFreeChat::FilterNickname方法的典型用法代码示例。如果您正苦于以下问题:PHP phpFreeChat::FilterNickname方法的具体用法?PHP phpFreeChat::FilterNickname怎么用?PHP phpFreeChat::FilterNickname使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpFreeChat
的用法示例。
在下文中一共展示了phpFreeChat::FilterNickname方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
$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+'\"');");
}
}
示例2: 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);
}
示例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 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;
}