Пример #1
0
 public function getChatContentList($userID, $rpUserID)
 {
     $tabelName = "msg_" . $userID % 1000;
     $startTime = JY_getMsTime() - 3 * 24 * 60 * 60 * 1000;
     $sql = "SELECT * FROM {$tabelName} WHERE mUid = ? AND mType = 1 AND mTime > {$startTime} AND mBody LIKE '%{$rpUserID}%' ORDER BY mId DESC LIMIT 50";
     $query = $this->msdb->query($sql, array($userID));
     return $query->result_array();
 }
Пример #2
0
 public function getAssignTopicComment($id, $isCommentID, $pageNo = 1, $pageSize = 10, $all = false)
 {
     //$isCommentID:是不是评论ID,$all:拉取指定时间内的所有评论
     $collection = $this->mongo->comment;
     $commentList = array();
     $data = array();
     $data['commentList'] = array();
     if ($isCommentID) {
         $comment = $collection->findOne(array('_id' => new MongoId($id)));
         array_push($commentList, $comment);
         $data['totalPages'] = 1;
         if (!empty($comment)) {
             $data['commentList'] = $commentList;
         }
     } else {
         if ($all) {
             $lastThreeDays = JY_getMsTime() - 3600 * 48 * 1000;
             $cursor = $collection->find(array("state" => 0, "pubTime" => array('$gt' => $lastThreeDays)));
             $totalNum = $collection->count(array("state" => 0, "pubTime" => array('$gt' => $lastThreeDays)));
         } else {
             $cursor = $collection->find(array("state" => 0, "topicID" => $id));
             $totalNum = $collection->count(array("state" => 0, "topicID" => $id));
         }
         try {
             $cursor = $cursor->skip(($pageNo - 1) * $pageSize);
             $topicCommentObj = $cursor->limit($pageSize + 1);
         } catch (MongoCursorException $e) {
             return array();
         }
         $commentList = array();
         foreach ($topicCommentObj as $comment) {
             $comment['pubTime'] = JY_ms2Date($comment['pubTime']);
             array_push($commentList, $comment);
         }
         $data['totalPages'] = ceil($totalNum / $pageSize);
         if ($totalNum > 0) {
             $data['commentList'] = $commentList;
         }
     }
     return $data;
 }
Пример #3
0
 public function chatPost()
 {
     $content = (string) $this->input->post('txtContent', TRUE);
     $toUserID = $this->input->post('toUserID', TRUE);
     $type = (int) $this->input->post('type', TRUE);
     $userID = "10086";
     $startTime = JY_getMsTime();
     $wbRtnText = $this->xiaoMiChat($toUserID, $type, $content);
     $endTime = JY_getMsTime();
     log_message('debug', "xiaoMiChat:" . isset($wbRtnText['rtn']) ? $wbRtnText['rtn'] : "timeout");
     log_message('debug', "xiaoMiChat:" . $endTime - $startTime);
     if ($wbRtnText) {
         $user = $this->jjuser->get_user_by_id($userID);
         $rtnData = $wbRtnText['data'];
         $data['topicID'] = $rtnData['topicID'];
         $data['pubTime'] = $rtnData['pubTime'];
         $data['user'] = $user;
         $data['content'] = $content;
         if ($type == 1) {
             $data['resUrl'] = $content;
         }
         $this->load->view('chatMsgTmpl', $data);
     }
 }
Пример #4
0
 public function getRedisSetCache($m = "xiaomi", $key = "xiaomi_chat")
 {
     $redis = $this->createRedis($m);
     $rtn = false;
     if ($redis) {
         $rtn = $redis->zRevRangeByScore($key, JY_getMsTime(), JY_getMsTime() - 24 * 60 * 60 * 1000, array('limit' => array(0, -1), 'withscores' => TRUE));
         $redis->close();
     }
     return $rtn;
 }
Пример #5
0
 public function saveUserInbox($fromUserID, $toUserID, $topicID)
 {
     $data = array("userID" => $toUserID, "fromUserID" => $fromUserID, "topicID" => $topicID, "isPingo" => 0, "recvTime" => JY_getMsTime());
     return $this->db->insert('user_inbox', $data, true);
 }
Пример #6
0
function JY_getUploadFileName($salt)
{
    return md5($salt . JY_getMsTime() . rand(100000, 999999));
}