本文整理汇总了PHP中phpFreeChat::PostFilterMsg方法的典型用法代码示例。如果您正苦于以下问题:PHP phpFreeChat::PostFilterMsg方法的具体用法?PHP phpFreeChat::PostFilterMsg怎么用?PHP phpFreeChat::PostFilterMsg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpFreeChat
的用法示例。
在下文中一共展示了phpFreeChat::PostFilterMsg方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
// do nothing if the recipient is not defined
if ($recipient == "") {
return;
}
// check this methode is not being called
if (isset($_SESSION["pfc_lock_readnewmsg_" . $c->getId() . "_" . $clientid])) {
// kill the lock if it has been created more than 10 seconds ago
$last_10sec = time() - 10;
$last_lock = $_SESSION["pfc_lock_readnewmsg_" . $c->getId() . "_" . $clientid];
if ($last_lock < $last_10sec) {
$_SESSION["pfc_lock_" . $c->getId() . "_" . $clientid] = 0;
}
if ($_SESSION["pfc_lock_readnewmsg_" . $c->getId() . "_" . $clientid] != 0) {
exit;
}
}
// create a new lock
$_SESSION["pfc_lock_readnewmsg_" . $c->getId() . "_" . $clientid] = time();
// read the last from_id value
$container =& pfcContainer::Instance();
$from_id_sid = "pfc_from_id_" . $c->getId() . "_" . $clientid . "_" . $recipientid;
$from_id = 0;
if (isset($_SESSION[$from_id_sid])) {
$from_id = $_SESSION[$from_id_sid];
} else {
$from_id = $container->getLastId($recipient) - $c->max_msg - 1;
if ($from_id < 0) {
$from_id = 0;
}
}
// check if this is the first time you get messages
$oldmsg_sid = "pfc_oldmsg_" . $c->getId() . "_" . $clientid . "_" . $recipientid;
$oldmsg = false;
if (isset($_SESSION[$oldmsg_sid])) {
unset($_SESSION[$oldmsg_sid]);
$oldmsg = true;
}
$new_msg = $container->read($recipient, $from_id);
$new_from_id = $new_msg["new_from_id"];
$data = $new_msg["data"];
// transform new message in html format
$js = array();
$data_sent = false;
foreach ($data as $d) {
$m_id = $d["id"];
$m_date = gmdate($c->date_format, $d["timestamp"] + $c->time_offset);
$m_time = gmdate($c->time_format, $d["timestamp"] + $c->time_offset);
$m_sender = $d["sender"];
$m_recipientid = $recipientid;
$m_cmd = $d["cmd"];
$m_param = phpFreeChat::PostFilterMsg($d["param"]);
$js[] = array($m_id, $m_date, $m_time, $m_sender, $m_recipientid, $m_cmd, $m_param, gmdate($c->date_format, time() + $c->time_offset) == $m_date ? 1 : 0, $oldmsg ? 1 : 0);
// is it a new message in the current session or is it a part of the history
$data_sent = true;
}
if (count($js) != 0) {
require_once dirname(__FILE__) . '/../pfcjson.class.php';
$json = new pfcJSON();
$js = $json->encode($js);
$xml_reponse->script("pfc.handleResponse('" . $this->name . "', 'ok', (" . $js . "));");
}
if ($data_sent) {
// store the new msg id
$_SESSION[$from_id_sid] = $new_from_id;
}
// remove the lock
$_SESSION["pfc_lock_readnewmsg_" . $c->getId() . "_" . $clientid] = 0;
}