當前位置: 首頁>>代碼示例>>PHP>>正文


PHP phpFreeChat::PostFilterMsg方法代碼示例

本文整理匯總了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;
 }
開發者ID:codethics,項目名稱:proteoerp,代碼行數:76,代碼來源:getnewmsg.class.php


注:本文中的phpFreeChat::PostFilterMsg方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。