Exemple #1
0
 private function _transTime($time)
 {
     $year = substr($time, 0, 4);
     $month = substr($time, 4, 2);
     $day = substr($time, 6, 2);
     $hour = substr($time, 8, 2);
     $minute = substr($time, 10, 2);
     $second = substr($time, 12, 2);
     return sns::gettime(mktime($hour, $minute, $second, $month, $day, $year));
 }
Exemple #2
0
 /**
  * 
  * 获取备份记录
  * @param $user_id
  */
 public function get_backup_history($user_id, $device_id = '', $num = 1)
 {
     $setters = array('uid' => $user_id);
     $result = $history = array();
     $table = $this->get_table($user_id, 'backup_history');
     $sql = "SELECT device_id,batch_number,phone_model,backup_total_sms,dateline FROM {$table} WHERE uid='{$user_id}' ";
     if ($device_id) {
         $sql .= " AND device_id='{$device_id}' ";
     }
     $sql .= "ORDER BY dateline DESC LIMIT {$num}";
     $query = $this->db->query($sql);
     $result = $query->result_array(FALSE);
     if ($query->count() > 0) {
         foreach ($result as $key => $var) {
             $history[$key] = $var;
             $history[$key]['dateline_alias'] = sns::gettime($var['dateline']);
             $history[$key]['device_alias'] = Brand_Model::instance()->get_by_model($var['phone_model']);
         }
     }
     return array_values($history);
 }
Exemple #3
0
 public function saveComment($status_id, $content, $feed_uid, $client_id = 0, $reply_commentid = 0, $uid = 0, $group_member = array())
 {
     $this->at2id = array();
     $comment_at = array();
     $isall = 0;
     if (strpos($content, '@全部成员(0)') !== false) {
         $isall = 1;
     }
     $addfeed = new Feed_Model();
     $doc = $addfeed->findFeed($status_id);
     $this->group_id = (int) $doc['group_id'];
     $content = preg_replace_callback('#\\b(https?)://[-A-Z0-9+&\\#/%?=~_|!:,.;]*[-A-Z0-9+&\\#/%=~_|]#i', array($this, 'bulid_hyperlinks'), $content);
     $content = preg_replace_callback('/@([^@]+?)\\(([0-9]*)\\)/', array($this, 'bulid_user_hyperlinks'), $content);
     $comment_at = $this->at2id;
     $time = time();
     $typeid = 4;
     $feed_uid = $doc['owner_uid'];
     $uid = $uid == 0 ? $this->uid : $uid;
     $content_link = $addfeed->atLink($content, $this->at2id);
     $m = new MongoClient(Kohana::config('uap.mongodb'));
     $comment_id = md5($status_id . '_' . $feed_uid . '_' . microtime());
     $addTime = microtime(true) * 10000;
     $col = $this->m->selectCollection('im_user');
     //右侧聊天窗口start
     $arr = $col->find(array('feedid' => $status_id));
     if (!empty($arr)) {
         $source_name = api::get_source_name($client_id);
         $immsg = array("kind" => "im", "data" => array("id" => $comment_id, "statuses_id" => $status_id, "owner_uid" => $feed_uid, "user" => array('id' => $uid, 'name' => sns::getrealname($uid), 'avatar' => sns::getavatar($uid)), "datetime" => $addTime, "created_at" => sns::gettime($time), "source_name" => $source_name == 'MOMO网站' ? '' : $source_name, "text" => $content_link));
         $uid_string = '';
         foreach ($arr as $v) {
             if ($v['uid'] == $uid) {
                 continue;
             }
             if (strlen($uid_string) > 200) {
                 $this->mq_send(json_encode($immsg), substr($uid_string, 0, -1));
                 $uid_string = '';
             }
             $uid_string .= $v['uid'] . '.';
         }
         $this->mq_send(json_encode($immsg), substr($uid_string, 0, -1));
     }
     //右侧聊天窗口end
     $client_id = $client_id ? $client_id : 0;
     $realname = sns::getrealname($uid);
     $array = array('id' => $comment_id, 'feedid' => $status_id, 'content' => $content, 'at' => $this->at2id, 'addtime' => $addTime, 'uid' => intval($uid), 'realname' => $realname, 'client_id' => intval($client_id), 'owner' => intval($feed_uid));
     $this->comment->insert($array);
     if ($doc) {
     }
     $typeid = $doc['typeid'];
     $sended_uid = array();
     //回复某人
     if ($reply_commentid) {
         $reply_comment = $this->comment->findOne(array('id' => $reply_commentid));
         $is_reply = false;
         if ($reply_comment['uid'] && count($this->at2id) > 0) {
             foreach ($this->at2id as $key => $var) {
                 if ($var['id'] == $reply_comment['uid']) {
                     $is_reply = true;
                     $reply_key = key;
                     continue;
                 }
             }
             if ($is_reply) {
                 $sended_uid[] = $reply_comment['uid'];
                 unset($comment_at[$reply_key]);
                 $addfeed->addAboutme($reply_comment['uid'], $this->uid, $typeid, $comment_id, $content, $this->at2id, $status_id, 6, $reply_comment);
             }
         }
     }
     //评论动态
     if ($feed_uid != $this->uid && $reply_uid != $feed_uid) {
         if (!in_array($feed_uid, $sended_uid)) {
             $sended_uid[] = $feed_uid;
             $addfeed->addAboutme($feed_uid, $this->uid, $typeid, $comment_id, $content, $this->at2id, $status_id, 1);
         }
     }
     //群组评论动态
     if (count($group_member) > 0) {
         foreach ($group_member as $member) {
             if (!in_array($member['uid'], $sended_uid) && $member['uid'] != $this->uid) {
                 $sended_uid[] = $member['uid'];
                 $addfeed->addAboutme($member['uid'], $this->uid, $typeid, $comment_id, $content, $this->at2id, $status_id, 1);
             }
         }
     }
     //动态中@某人
     if (!empty($comment_at) && count($comment_at) > 0) {
         foreach ($comment_at as $key => $var) {
             if ($var['id'] != $feed_uid && !in_array($var['id'], $sended_uid) && !$var['group_id']) {
                 $sended_uid[] = $var['id'];
                 $addfeed->addAboutme($var['id'], $this->uid, $typeid, $comment_id, $content, $this->at2id, $status_id, 3);
             }
         }
     }
     $comment_list = array('id' => $comment_id, 'uid' => intval($uid), 'name' => $realname, 'created_at' => intval($time), 'text' => $content, 'at' => $this->at2id, 'source' => $client_id, 'im' => 0);
     $isbubble = $feed_uid == Kohana::config('uap.xiaomo') ? false : true;
     $addfeed->addFeedComment($status_id, $comment_list, $isbubble);
     $addfeed->updateFeed($status_id);
     $addfeed->delHidden($status_id);
     $addfeed->mo_sms('comment', $status_id, $comment_id, $this->at2mo);
     $return = array("success" => true, "data" => array("id" => $comment_id, "text" => $content_link));
     return $return;
 }