/**
  * 主页右钩子
  */
 public function home_index_left_feedtop()
 {
     $list = $this->model('FeedTop')->getFeedTopList(1);
     $close_feeds = $_SESSION['feed_top_' . $this->mid];
     foreach ($list as $k => $v) {
         if (!in_array($v['feed_id'], $close_feeds)) {
             $list[$k]['feed_info'] = model('Feed')->get($v['feed_id']);
         } else {
             unset($list[$k]);
         }
     }
     foreach ($list as &$v) {
         switch ($v['feed_info']['app']) {
             case 'weiba':
                 $v['feed_info']['from'] = getFromClient(0, $v['feed_info']['app'], '微吧');
                 break;
             case 'tipoff':
                 $v['feed_info']['from'] = getFromClient(0, $v['feed_info']['app'], '爆料');
                 break;
             default:
                 $v['feed_info']['from'] = getFromClient($v['feed_info']['from'], $v['feed_info']['app']);
                 break;
         }
         !isset($uids[$v['feed_info']['uid']]) && $v['feed_info']['uid'] != $GLOBALS['ts']['mid'] && ($uids[] = $v['feed_info']['uid']);
     }
     $this->assign('data', $list);
     // 赞微博
     $feed_ids = getSubByKey($list, 'feed_id');
     $diggArr = model('FeedDigg')->checkIsDigg($feed_ids, $GLOBALS['ts']['mid']);
     $this->assign('diggArr', $diggArr);
     $this->display('feedtop');
 }
 /**
  * 主页右钩子
  */
 public function home_index_left_feedtop()
 {
     $list = $this->model('FeedTop')->getFeedTopList(1);
     $close_feeds = $_SESSION['feed_top_' . $this->mid];
     foreach ($list as $k => $v) {
         if (!in_array($v['feed_id'], $close_feeds)) {
             $list[$k]['feed_info'] = model('Feed')->get($v['feed_id']);
         } else {
             unset($list[$k]);
         }
     }
     foreach ($list as $k => &$v) {
         if ($v['feed_info']['is_del'] == 1) {
             $this->model('FeedTop')->doDel($v['id']);
             unset($list[$k]);
             continue;
         }
         switch ($v['feed_info']['app']) {
             case 'weiba':
                 $v['feed_info']['from'] = getFromClient(0, $v['feed_info']['app'], '微吧');
                 break;
             case 'tipoff':
                 $v['feed_info']['from'] = getFromClient(0, $v['feed_info']['app'], '爆料');
                 break;
             default:
                 $v['feed_info']['from'] = getFromClient($v['feed_info']['from'], $v['feed_info']['app']);
                 break;
         }
         !isset($uids[$v['feed_info']['uid']]) && $v['feed_info']['uid'] != $GLOBALS['ts']['mid'] && ($uids[] = $v['feed_info']['uid']);
     }
     $this->assign('data', $list);
     $cancomment_old_type = array('post', 'repost', 'postimage', 'postfile', 'weiba_post', 'weiba_repost', 'blog_post', 'blog_repost', 'event_post', 'event_repost', 'vote_post', 'vote_repost', 'photo_post', 'photo_repost');
     $this->assign('cancomment_old_type', $cancomment_old_type);
     $uids = array();
     foreach ($list as $item) {
         $uids[] = $item['feed_info']['uid'];
     }
     if (!empty($uids)) {
         $map = array();
         $map['uid'] = $GLOBALS['ts']['mid'];
         $map['fid'] = array('in', $uids);
         $followUids = model('Follow')->where($map)->getAsFieldArray('fid');
         $this->assign('followUids', $followUids);
         $remarkHash = model('Follow')->getRemarkHash($GLOBALS['ts']['mid']);
         $this->assign('remarkHash', $remarkHash);
     }
     // 赞分享
     $feed_ids = getSubByKey($list, 'feed_id');
     $diggArr = model('FeedDigg')->checkIsDigg($feed_ids, $GLOBALS['ts']['mid']);
     $this->assign('diggArr', $diggArr);
     $this->display('feedtop');
 }
 public function detail_cyj()
 {
     if ($_GET['weibo_id']) {
         $data['id'] = intval($_GET['weibo_id']);
     } elseif ($_GET['id']) {
         $data['id'] = intval($_GET['id']);
     }
     $detail = api('WeiboStatuses')->data($data)->show();
     $detail['userGroupData'] = $this->_usergroup($detail['uid']);
     $map['source_id'] = $data['id'];
     $map['uid'] = $this->mid;
     $detail['iscoll']['colled'] = model('Collection')->where($map)->count() ? 1 : 0;
     $detail['favorited'] = $detail['iscoll']['colled'];
     // $detail['is_favorite'] = api('Favorites')->data($data)->isFavorite() ? 1 : 0;
     // $detail['content'] = wapFormatContent($detail['content'], false, urlencode($this->_self_url));
     // $detail = $this->__formatByContent($detail);
     // optimize data
     if (($detail['type'] === 'repost' && $detail['api_source']['is_del'] === '0' || $detail['type'] === 'repost' && $detail['transpond_data']['api_source']['is_del'] === '0') && isset($detail['transpond_data']['feed_content'])) {
         switch ($detail['transpond_data']['type']) {
             case 'postimage':
                 $detail['type'] = 'repost-postimage';
                 break;
             case 'postfile':
                 $detail['type'] = 'repost-postfile';
                 foreach ($detail['transpond_data']['attach'] as $k => $v) {
                     if ($v['size'] > 1024 && $v['size'] < 1024 * 1024) {
                         $detail['transpond_data']['attach'][$k]['size'] = round($v['size'] / 1024, 2) . 'K';
                     } else {
                         if ($v['size'] < 1024) {
                             $detail['transpond_data']['attach'][$k]['size'] .= 'B';
                         } else {
                             $detail['transpond_data']['attach'][$k]['size'] = round($v['size'] / 1024 / 1024, 2) . 'M';
                         }
                     }
                 }
                 break;
             case 'postvideo':
                 $detail['type'] = 'repost-postvideo';
                 break;
         }
     } else {
         if (($detail['api_source']['is_del'] === '1' || $detail['transpond_data']['api_source']['is_del'] === '1') && $detail['type'] === 'repost') {
             $detail['type'] = 'repost-removed';
         } else {
             if ($detail['type'] === 'postfile') {
                 foreach ($detail['attach'] as $k => $v) {
                     if ($v['size'] > 1024 && $v['size'] < 1024 * 1024) {
                         $detail['attach'][$k]['size'] = round($v['size'] / 1024, 2) . 'K';
                     } else {
                         if ($v['size'] < 1024) {
                             $detail['attach'][$k]['size'] .= 'B';
                         } else {
                             $detail['attach'][$k]['size'] = round($v['size'] / 1024 / 1024, 2) . 'M';
                         }
                     }
                 }
             } else {
                 if ($detail['type'] === 'weiba_repost') {
                     if ($detail['api_source']['is_del'] === '1' || $detail['transpond_data']['is_del'] === '1') {
                         $detail['type'] = 'weiba_repost-removed';
                     }
                 }
             }
         }
     }
     $detail['from'] = getFromClient($detail['from'], $detail['app']);
     if ($detail['type'] == 'postvideo') {
         // $weibolist[$k]['content'] = $v['source_body'];
         $detail['content'] = $detail['feed_content'] ? $detail['feed_content'] : $detail['source_body'];
         $detail['content'] = wapDetailCYJContent($detail['content'], true, $self_url, "视频");
     } else {
         $detail['content'] = wapDetailCYJContent($detail['content'], true, $self_url);
     }
     // 非视频分享
     if ($detail['transpond_data']['content']) {
         if (strpos($weibolist[$k]['type'], 'video')) {
             $detail['transpond_data']['content'] = wapDetailCYJContent($detail['transpond_data']['content'], true, $self_url, "视频");
         } else {
             $detail['transpond_data']['content'] = wapDetailCYJContent($detail['transpond_data']['content'], true, $self_url);
         }
     }
     // 转发分享标志
     $detail['repost'] = $detail['app_row_id'];
     // 如果是转发,看是否有评论当前用户的权限
     $privacy1 = $this->privacy($detail['uid']);
     $detail['cancomment_current'] = 0;
     if ($privacy1 === true || $privacy1['comment_weibo'] == 0) {
         $detail['cancomment_current'] = 1;
     }
     // 判断是否有评论作者或原文作者权限
     $origin_uid = $detail['api_source']['uid'] ? $detail['api_source']['uid'] : 0;
     $detail['cancomment'] = 0;
     // 如果是转发,判断是否有评论给原作者的权限
     if ($origin_uid && $origin_uid != $this->mid) {
         $privacy = $this->privacy($origin_uid);
         if ($privacy === true || $privacy['comment_weibo'] == 0) {
             $detail['cancomment'] = 1;
         }
     }
     $this->assign('feed', $detail);
     // dump($detail);exit;
     // dump($detail);
     $data['page'] = $this->_page;
     $data['count'] = 20;
     $comment = api('WeiboStatuses')->data($data)->comments();
     foreach ($comment as $key => $value) {
         $comment[$key]['level'] = M('credit_user')->where('uid=' . $value['uid'])->find();
         $comment[$key]['userGroupData'] = $this->_usergroup($value['uid']);
     }
     $this->assign('count', $detail['comment_count']);
     $this->assign('comment', $comment);
     $this->assign('headtitle', '分享详情');
     $this->assign('uid', $this->mid);
     // dump($detail['api_source']);
     $this->display('detail_cyj');
 }
Exemple #4
0
 /**
  * 数据库搜索微博
  * @param string $key 关键字
  * @param string $type 微博类型,post、repost、postimage、postfile
  * @param integer $limit 结果集数目
  * @param boolean $forApi 是否返回API数据,默认为false
  * @return array 搜索后的微博数据
  */
 public function searchFeeds($key, $feed_type, $limit, $Stime, $Etime)
 {
     $map['a.is_del'] = 0;
     $map['a.is_audit'] = 1;
     $map['b.feed_content'] = array('LIKE', '%' . t($key) . '%');
     if ($feed_type) {
         $map['a.type'] = $feed_type;
         if ($map['a.type'] == 'post') {
             unset($map['a.type']);
             $map['a.is_repost'] = 0;
         }
     }
     if ($Stime && $Etime) {
         $map['a.publish_time'] = array('between', array($Stime, $Etime));
     }
     $table = "{$this->tablePrefix}feed AS a LEFT JOIN {$this->tablePrefix}feed_data AS b ON a.feed_id = b.feed_id";
     $feedlist = $this->table($table)->field('a.feed_id')->where($map)->order('a.publish_time DESC')->findPage($limit);
     //return D()->getLastSql();exit;
     $feed_ids = getSubByKey($feedlist['data'], 'feed_id');
     $feedlist['data'] = $this->getFeeds($feed_ids);
     foreach ($feedlist['data'] as &$v) {
         switch ($v['app']) {
             case 'weiba':
                 $v['from'] = getFromClient(0, $v['app'], '微吧');
                 break;
             default:
                 $v['from'] = getFromClient($v['from'], $v['app']);
                 break;
         }
         !isset($uids[$v['uid']]) && $v['uid'] != $GLOBALS['ts']['mid'] && ($uids[] = $v['uid']);
     }
     return $feedlist;
 }
 /**
  * 发布微博操作,用于AJAX
  * @return json 发布微博后的结果信息JSON数据
  */
 public function PostFeed()
 {
     // 返回数据格式
     $return = array('status' => 1, 'data' => '');
     // 用户发送内容
     $d['content'] = isset($_POST['content']) ? filter_keyword(h($_POST['content'])) : '';
     // 原始数据内容
     $d['body'] = filter_keyword($_POST['body']);
     //$this->success($d['body']);//测试
     // 安全过滤
     foreach ($_POST as $key => $val) {
         $_POST[$key] = t($_POST[$key]);
     }
     $d['source_url'] = urldecode($_POST['source_url']);
     //应用分享到微博,原资源链接
     // 滤掉话题两端的空白
     $d['body'] = preg_replace("/#[\\s]*([^#^\\s][^#]*[^#^\\s])[\\s]*#/is", '#' . trim("\${1}") . '#', $d['body']);
     // 附件信息
     $d['attach_id'] = trim(t($_POST['attach_id']), "|");
     if (!empty($d['attach_id'])) {
         $d['attach_id'] = explode('|', $d['attach_id']);
         array_map('intval', $d['attach_id']);
     }
     // 发送微博的类型
     $type = t($_POST['type']);
     // 所属应用名称
     $app = isset($_POST['app_name']) ? t($_POST['app_name']) : APP_NAME;
     // 当前动态产生所属的应用
     if (!($data = model('Feed')->put($this->uid, $app, $type, $d))) {
         $return = array('status' => 0, 'data' => model('Feed')->getError());
         exit(json_encode($return));
     }
     // 发布邮件之后添加积分
     model('Credit')->setUserCredit($this->uid, 'add_weibo');
     // 微博来源设置
     $data['from'] = getFromClient($data['from'], $data['app']);
     $this->assign($data);
     // 微博配置
     $weiboSet = model('Xdata')->get('admin_Config:feed');
     $this->assign('weibo_premission', $weiboSet['weibo_premission']);
     $return['data'] = $this->fetch();
     // 微博ID
     $return['feedId'] = $data['feed_id'];
     $return['is_audit'] = $data['is_audit'];
     // 添加话题
     model('FeedTopic')->addTopic(html_entity_decode($d['body'], ENT_QUOTES, 'UTF-8'), $data['feed_id'], $type);
     // 更新用户最后发表的微博
     $last['last_feed_id'] = $data['feed_id'];
     $last['last_post_time'] = $_SERVER['REQUEST_TIME'];
     model('User')->where('uid=' . $this->uid)->save($last);
     $isOpenChannel = model('App')->isAppNameOpen('channel');
     if (!$isOpenChannel) {
         exit(json_encode($return));
     }
     // 添加微博到投稿数据中
     $channelId = t($_POST['channel_id']);
     // 绑定用户
     $bindUserChannel = D('Channel', 'channel')->getCategoryByUserBind($this->mid);
     if (!empty($bindUserChannel)) {
         $channelId = array_merge($bindUserChannel, explode(',', $channelId));
         $channelId = array_filter($channelId);
         $channelId = array_unique($channelId);
         $channelId = implode(',', $channelId);
     }
     // 绑定话题
     $content = html_entity_decode($d['body'], ENT_QUOTES, 'UTF-8');
     $content = str_replace("#", "#", $content);
     preg_match_all("/#([^#]*[^#^\\s][^#]*)#/is", $content, $topics);
     $topics = array_unique($topics[1]);
     foreach ($topics as &$topic) {
         $topic = trim(preg_replace("/#/", '', t($topic)));
     }
     $bindTopicChannel = D('Channel', 'channel')->getCategoryByTopicBind($topics);
     if (!empty($bindTopicChannel)) {
         $channelId = array_merge($bindTopicChannel, explode(',', $channelId));
         $channelId = array_filter($channelId);
         $channelId = array_unique($channelId);
         $channelId = implode(',', $channelId);
     }
     if (!empty($channelId)) {
         // 获取后台配置数据
         $channelConf = model('Xdata')->get('channel_Admin:index');
         $return['is_audit_channel'] = $channelConf['is_audit'];
         // 添加频道数据
         D('Channel', 'channel')->setChannel($data['feed_id'], $channelId, false);
     }
     exit(json_encode($return));
 }
			<?php 
        if ($sourceInfo["feedType"] == "post") {
            ?>
<div class="feed_txt feed_txt_default">
	        <?php 
            echo constant(" 转发原文 *");
            ?>
            <span class="source_info"><?php 
            echo $sourceInfo['source_user_info']['space_link'];
            ?>
<em>&nbsp;&nbsp;<?php 
            echo friendlydate($sourceInfo['publish_time']);
            ?>
<!--&nbsp;<?php 
            echo getFromClient($sourceInfo['from']);
            ?>
--></em></span>
		    <p class="txt-mt" onclick="core.weibo.clickRepost(this);" href="<?php 
            echo U('public/Profile/feed', array('uid' => $sourceInfo['uid'], 'feed_id' => $sourceInfo['feed_id']));
            ?>
"><?php 
            echo msubstr(t($sourceInfo['source_content']), 0, 128);
            ?>
</p>
			</div><?php 
        }
        ?>

		<?php 
    }
 /**
  * 获取评论列表,已在后台被使用
  * @param array $map 查询条件
  * @param string $order 排序条件,默认为comment_id ASC
  * @param integer $limit 结果集数目,默认为10
  * @param boolean $isReply 是否显示回复信息
  * @return array 评论列表信息
  */
 public function getCommentList($map = null, $order = 'comment_id ASC', $limit = 10, $isReply = false)
 {
     !$map['app'] && $this->_app && ($map['app'] = $this->_app);
     !$map['table'] && $this->_app_table && ($map['table'] = $this->_app_table);
     !isset($map['is_del']) && ($map['is_del'] = 0);
     $data = $this->where($map)->order($order)->findPage($limit);
     // dump($data);exit;
     foreach ($data['data'] as $k => &$v) {
         if (!empty($v['to_comment_id']) && $isReply) {
             $replyInfo = $this->getCommentInfo($v['to_comment_id'], false);
             $v['replyInfo'] = '//@{uid=' . $replyInfo['user_info']['uid'] . '|' . $replyInfo['user_info']['uname'] . '}:' . $replyInfo['content'];
         }
         $v['user_info'] = model('User')->getUserInfo($v['uid']);
         $groupData = static_cache('groupdata' . $v['uid']);
         if (!$groupData) {
             $groupData = model('UserGroupLink')->getUserGroupData($v['uid']);
             if (!$groupData) {
                 $groupData = 1;
             }
             static_cache('groupdata' . $v['uid'], $groupData);
         }
         $v['user_info']['groupData'] = $groupData;
         //获取用户组信息
         $v['content'] = parse_html($v['content'] . $v['replyInfo']);
         $v['content'] = formatEmoji(false, $v['content']);
         // 解析emoji
         $v['sourceInfo'] = model('Source')->getCommentSource($v);
         //$v['data'] = unserialize($v['data']);
         $order = strtolower($order);
         if (strpos($order, 'desc')) {
             $v['storey'] = $data['count'] - $k - ($data['nowPage'] - 1) * $limit;
         } else {
             $v['storey'] = $k + 1 + ($data['nowPage'] - 1) * $limit;
         }
         $v['client_type'] = getFromClient($v['client_type'], $v['app']);
     }
     return $data;
 }
 /**
  * 获取指定用户的某条动态
  * 
  * @return void
  */
 public function feed()
 {
     $feed_id = intval($_GET['feed_id']);
     if (empty($feed_id)) {
         $this->error(L('PUBLIC_INFO_ALREADY_DELETE_TIPS'));
     }
     //获取微博信息
     $feedInfo = model('Feed')->get($feed_id);
     if (!$feedInfo) {
         $this->error('该微博不存在或已被删除');
         exit;
     }
     if ($feedInfo['is_audit'] == '0' && $feedInfo['uid'] != $this->mid) {
         $this->error('此微博正在审核');
         exit;
     }
     if ($feedInfo['is_del'] == '1') {
         $this->error(L('PUBLIC_NO_RELATE_WEIBO'));
         exit;
     }
     // 获取用户信息
     $user_info = model('User')->getUserInfo($feedInfo['uid']);
     // 赞功能
     $diggArr = model('FeedDigg')->checkIsDigg($feed_id, $this->mid);
     $data['diggArr'] = $diggArr;
     // 判断隐私设置
     $userPrivacy = $this->privacy($this->uid);
     $data['userPrivacy'] = $userPrivacy;
     if ($userPrivacy['space'] !== 1) {
         $weiboSet = model('Xdata')->get('admin_Config:feed');
         $a['initNums'] = $weiboSet['weibo_nums'];
         $a['weibo_type'] = $weiboSet['weibo_type'];
         $a['weibo_premission'] = $weiboSet['weibo_premission'];
         switch ($feedInfo['app']) {
             case 'weiba':
                 $feedInfo['from'] = getFromClient(0, $feedInfo['app'], '微吧');
                 break;
             default:
                 $feedInfo['from'] = getFromClient($from, $feedInfo['app']);
                 break;
         }
         $data['check'] = $a;
         $data['feedInfo'] = $feedInfo;
         return $data;
     } else {
         return $this->_assignUserInfo($this->uid);
     }
 }
 /**
  * 消息弹出层内容获取
  */
 public function messageContent($type)
 {
     if (!$type) {
         $type = t(empty($_POST['type']) ? $_GET['type'] : $_POST['type']);
     }
     $_POST['type'] = $type;
     switch ($type) {
         // @我的
         case 'at':
             // 获取未读@Me的条数
             $this->assign('unread_atme_count', model('UserData')->where('uid=' . $this->mid . " and `key`='unread_atme'")->getField('value'));
             // 拼装查询条件
             $map['uid'] = $this->mid;
             $d['tab'] = model('Atme')->getTab(null);
             foreach ($d['tab'] as $key => $vo) {
                 if ($key == 'feed') {
                     $d['tabHash']['feed'] = L('PUBLIC_WEIBO');
                 } elseif ($key == 'comment') {
                     $d['tabHash']['comment'] = L('PUBLIC_STREAM_COMMENT');
                 } else {
                     $langKey = 'PUBLIC_APPNAME_' . strtoupper($key);
                     $lang = L($langKey);
                     if ($lang == $langKey) {
                         $d['tabHash'][$key] = ucfirst($key);
                     } else {
                         $d['tabHash'][$key] = $lang;
                     }
                 }
             }
             $this->assign($d);
             !empty($_POST['t']) && ($map['table'] = t($_POST['t']));
             // at类型
             $this->assign('tt', $_POST['t']);
             // 设置应用名称与表名称
             $app_name = isset($_GET['app_name']) ? t($_GET['app_name']) : 'public';
             // $app_table = isset($_GET['app_table']) ? t($_GET['app_table']) : '';
             // 获取@Me分享列表
             $at_list = model('Atme')->setAppName($app_name)->setAppTable($app_table)->getAtmeList($map, $order = 'atme_id DESC', $limit = 20);
             // 赞功能
             $feed_ids = getSubByKey($at_list['data'], 'feed_id');
             $diggArr = model('FeedDigg')->checkIsDigg($feed_ids, $GLOBALS['ts']['mid']);
             $this->assign('diggArr', $diggArr);
             // dump($at_list);exit;
             // 添加Widget参数数据
             foreach ($at_list['data'] as &$val) {
                 if ($val['source_table'] == 'comment') {
                     $val['widget_sid'] = $val['sourceInfo']['source_id'];
                     $val['widget_style'] = $val['sourceInfo']['source_table'];
                     $val['widget_sapp'] = $val['sourceInfo']['app'];
                     $val['widget_suid'] = $val['sourceInfo']['uid'];
                     $val['widget_share_sid'] = $val['sourceInfo']['source_id'];
                 } else {
                     if ($val['is_repost'] == 1) {
                         $val['widget_sid'] = $val['source_id'];
                         $val['widget_stype'] = $val['source_table'];
                         $val['widget_sapp'] = $val['app'];
                         $val['widget_suid'] = $val['uid'];
                         $val['widget_share_sid'] = $val['app_row_id'];
                         $val['widget_curid'] = $val['source_id'];
                         $val['widget_curtable'] = $val['source_table'];
                     } else {
                         $val['widget_sid'] = $val['source_id'];
                         $val['widget_stype'] = $val['source_table'];
                         $val['widget_sapp'] = $val['app'];
                         $val['widget_suid'] = $val['uid'];
                         $val['widget_share_sid'] = $val['source_id'];
                     }
                 }
                 // 获取转发与评论数目
                 if ($val['source_table'] != 'comment') {
                     $feedInfo = model('Feed')->get($val['widget_sid']);
                     $val['repost_count'] = $feedInfo['repost_count'];
                     $val['comment_count'] = $feedInfo['comment_count'];
                 }
                 // 解析数据成网页端显示格式(@xxx 加链接)
                 $val['source_content'] = parse_html($val['source_content']);
                 $val['from'] = getFromClient($val['from'], $val['app']);
             }
             // 获取分享设置
             $weiboSet = model('Xdata')->get('admin_Config:feed');
             $this->assign($weiboSet);
             // 用户@Me未读数目重置
             // model('UserCount')->resetUserCount($this->mid, 'unread_atme', 0);
             $userInfo = model('User')->getUserInfo($this->mid);
             // 分页链接重写
             $at_list['html'] = $this->messagePage($at_list['html']);
             $this->assign($at_list);
             // 消息类型
             $this->assign('type', $type);
             $html = $this->fetch("at");
             break;
             // 我的评论
         // 我的评论
         case 'comment':
             $stype = t($_POST['stype']);
             if (empty($_POST['stype'])) {
                 $stype = $_POST['stype'] = 'receive';
             }
             if ($stype == 'send') {
                 $map['uid'] = $this->uid;
             } else {
                 // 分享配置
                 $weiboSet = model('Xdata')->get('admin_Config:feed');
                 $this->assign('weibo_premission', $weiboSet['weibo_premission']);
                 $keyword = '收到';
                 // 获取未读评论的条数
                 $this->assign('unread_comment_count', model('UserData')->where('uid=' . $this->mid . " and `key`='unread_comment'")->getField('value'));
                 // 收到的
                 $map['_string'] = " (to_uid = '{$this->uid}' OR app_uid = '{$this->uid}') AND uid !=" . $this->uid;
             }
             // 消息类型
             $this->assign('type', $type);
             // 发出的或者收到的
             $this->assign('stype', $stype);
             // $d['tab'] = model('Comment')->getTab($map);
             $d['tab'] = model('Comment')->getTabForApp($map);
             foreach ($d['tab'] as $key => $vo) {
                 if ($key == 'feed') {
                     $d['tabHash']['feed'] = L('PUBLIC_WEIBO');
                 } elseif ($key == 'webpage') {
                     $d['tabHash']['webpage'] = '评论箱';
                 } else {
                     // 微吧
                     strtolower($key) === 'weiba_post' && ($key = 'weiba');
                     $langKey = 'PUBLIC_APPNAME_' . strtoupper($key);
                     $lang = L($langKey);
                     if ($lang == $langKey) {
                         $d['tabHash'][$key] = ucfirst($key);
                     } else {
                         $d['tabHash'][$key] = $lang;
                     }
                 }
             }
             $this->assign($d);
             // 安全过滤
             $t = t($_POST['t']);
             // 评论类型
             $this->assign('tt', $t);
             !empty($t) && ($map['app'] = $t);
             if ($t == 'feed') {
                 $map['app'] = 'public';
             }
             $list = model('Comment')->setAppName(t($_GET['app_name']))->getCommentList($map, 'comment_id DESC', 20, true);
             foreach ($list['data'] as $k => $v) {
                 if ($v['sourceInfo']['app'] == 'weiba') {
                     $list['data'][$k]['sourceInfo']['source_body'] = str_replace($v['sourceInfo']['row_id'], $v['comment_id'], $v['sourceInfo']['source_body']);
                 }
                 if ($v['table'] === 'webpage') {
                     $list['data'][$k]['hasComment'] = false;
                 } else {
                     $list['data'][$k]['hasComment'] = true;
                 }
             }
             model('UserCount')->resetUserCount($this->mid, 'unread_comment', 0);
             // 分页链接重写
             $list['html'] = $this->messagePage($list['html']);
             $this->assign('list', $list);
             $userInfo = model('User')->getUserInfo($this->mid);
             $html = $this->fetch('comment');
             break;
             // 我的私信
         // 我的私信
         case "message":
             $dao = model('Message');
             $list = $dao->getMessageListByUid($this->mid, array(MessageModel::ONE_ON_ONE_CHAT, MessageModel::MULTIPLAYER_CHAT), 20);
             // 设置信息已读(在右上角提示去掉),
             model('Message')->setMessageIsRead(t($POST['id']), $this->mid, 1);
             if ($list['nowPage'] <= 1 && is_array($list['data']) && isset($list['data'][0])) {
                 $only = !isset($list['data'][1]) || $list['data'][1]['new'] <= 0;
                 if ($list['data'][0]['new'] > 0 && $only) {
                     $this->redirect('public/Index/messageContent', array('type' => 'message_detail', 'stype' => $list['data'][0]['type'], 'id' => $list['data'][0]['list_id']));
                     exit;
                 }
             }
             // 重写分页链接
             $list['html'] = $this->messagePage($list['html']);
             $this->assign($list);
             $this->assign('type', $type);
             $userInfo = model('User')->getUserInfo($this->mid);
             $html = $this->fetch('message');
             break;
         case "message_detail":
             $_POST['id'] = intval(empty($_POST['id']) ? $_GET['id'] : $_POST['id']);
             $_POST['stype'] = t(empty($_POST['stype']) ? $_GET['stype'] : $_POST['stype']);
             $message = model('Message')->isMember(t($_POST['id']), $this->mid, true);
             // 验证数据
             if (empty($message)) {
                 $this->error(L('PUBLIC_PRI_MESSAGE_NOEXIST'));
             }
             $message['member'] = model('Message')->getMessageMembers(t($_POST['id']), 'member_uid');
             $message['to'] = array();
             // 添加发送用户ID
             foreach ($message['member'] as $v) {
                 $this->mid != $v['member_uid'] && ($message['to'][] = $v);
             }
             // 设置信息已读(私信列表页去掉new标识)
             model('Message')->setMessageIsRead(t($_POST['id']), $this->mid, 0);
             $message['since_id'] = model('Message')->getSinceMessageId($message['list_id'], $message['message_num']);
             $this->assign('message', $message);
             $this->assign('type', intval($_POST['type']));
             $this->setTitle('与' . $message['to'][0]['user_info']['uname'] . '的私信对话');
             $this->setKeywords('与' . $message['to'][0]['user_info']['uname'] . '的私信对话');
             $html = $this->fetch('message_detail');
             break;
         case "notify":
             $map['uid'] = $this->mid;
             if ($_POST['t'] == 'digg') {
                 $map['node'] = array('eq', 'digg');
             } else {
                 $map['node'] = array('neq', 'digg');
             }
             $list = D('notify_message')->where($map)->order('ctime desc')->findpage(20);
             // 重写分页链接
             $list['html'] = $this->messagePage($list['html']);
             foreach ($list['data'] as $k => $v) {
                 $list['data'][$k]['body'] = parse_html($v['body']);
                 if ($appname != 'public') {
                     $list['data'][$k]['app'] = model('App')->getAppByName($v['appname']);
                 }
                 // 如果为点赞消息,获取发送人的头像
                 if ($_POST['t'] == 'digg') {
                     $from_user = model('User')->getUserInfo($list['data'][$k]['from_uid']);
                     // 头像
                     $list['data'][$k]['from_user_avatar'] = $from_user['avatar_middle'];
                     $list['data'][$k]['from_user'] = $from_user;
                 }
             }
             if ($_POST['t'] == 'digg') {
                 $node = 'digg';
                 model('UserCount')->resetUserCount($this->mid, 'unread_digg', 0);
             } else {
                 $node = array('neq', 'digg');
             }
             model('Notify')->setRead($this->mid, '', $node);
             $this->assign('list', $list);
             $this->assign('type', $type);
             $this->assign('t', $_POST['t']);
             $html = $this->fetch('notify');
             break;
     }
     $data['html'] = $html;
     $this->ajaxReturn($data, '获取内容成功', 1);
 }
 /**
  * 分享排行
  */
 public function weibo()
 {
     $order = intval($_GET['order']);
     switch ($order) {
         case 2:
             $feed_order = 'repost_count desc';
             break;
         case 3:
             $feed_order = 'digg_count desc';
             break;
         default:
             $feed_order = 'comment_count desc';
             break;
     }
     $map['is_del'] = 0;
     $map['is_audit'] = 1;
     $data = model('Feed')->getList($map, 20, $feed_order);
     //赞功能
     $feed_ids = getSubByKey($data['data'], 'feed_id');
     $data['diggArr'] = model('FeedDigg')->checkIsDigg($feed_ids, $GLOBALS['ts']['mid']);
     $data['remarkHash'] = model('Follow')->getRemarkHash($GLOBALS['ts']['mid']);
     foreach ($data['data'] as &$v) {
         switch ($v['app']) {
             case 'weiba':
                 $v['from'] = getFromClient(0, $v['app'], '微吧');
                 break;
             case 'tipoff':
                 $v['from'] = getFromClient(0, $v['app'], '爆料');
                 break;
             default:
                 $v['from'] = getFromClient($v['from'], $v['app']);
                 break;
         }
         !isset($uids[$v['uid']]) && $v['uid'] != $GLOBALS['ts']['mid'] && ($uids[] = $v['uid']);
     }
     if (!empty($uids)) {
         $map = array();
         $map['uid'] = $GLOBALS['ts']['mid'];
         $map['fid'] = array('in', $uids);
         $data['followUids'] = model('Follow')->where($map)->getAsFieldArray('fid');
     } else {
         $data['followUids'] = array();
     }
     $weiboSet = model('Xdata')->get('admin_Config:feed');
     $this->assign($weiboSet);
     $this->assign($data);
     $this->assign('order', $order);
     $cancomment_old_type = array('post', 'repost', 'postimage', 'postfile', 'weiba_post', 'weiba_repost', 'blog_post', 'blog_repost', 'event_post', 'event_repost', 'vote_post', 'vote_repost', 'photo_post', 'photo_repost');
     $this->assign('cancomment_old_type', $cancomment_old_type);
     $this->_rightRank();
     $this->display();
 }
 private function __formatByContent($weibolist)
 {
     $self_url = urlencode($this->_self_url);
     foreach ($weibolist as $k => $v) {
         if ($v['app'] === 'blog' || $v['app'] === 'weiba' || $v['app'] === 'group') {
             unset($weibolist[$k]);
             continue;
         }
         // 转发分享标志
         $weibolist[$k]['repost'] = $v['api_source']['feed_id'] ? $v['api_source']['feed_id'] : $v['app_row_id'];
         // 如果是转发,看是否有评论当前用户的权限
         $privacy1 = $this->privacy($v['uid']);
         $weibolist[$k]['cancomment_current'] = 0;
         if ($privacy1 === true || $privacy1['comment_weibo'] == 0) {
             $weibolist[$k]['cancomment_current'] = 1;
         }
         // 判断是否有评论作者或原文作者权限
         $origin_uid = $v['api_source']['uid'] ? $v['api_source']['uid'] : 0;
         $weibolist[$k]['cancomment'] = 0;
         // 如果是转发,判断是否有评论给原作者的权限
         if ($origin_uid && $origin_uid != $this->mid) {
             $privacy = $this->privacy($origin_uid);
             if ($privacy === true || $privacy['comment_weibo'] == 0) {
                 $weibolist[$k]['cancomment'] = 1;
             }
         }
         $weibolist[$k]['userGroupData'] = $this->_usergroup($v['uid']);
         switch ($v['app']) {
             case 'blog':
                 unset($weibolist[$k]);
                 continue;
                 /*
                  * if($v['feed_id']){
                  * $weibolist[$k]['weibo_id'] = $weibolist[$k]['feed_id'];
                  * // $weibolist[$k]['content'] = wapFormatContent($v['content'], true, $self_url);
                  * // 视频处理
                  * $weibolist[$k]['content'] = wapFormatContent($v['api_source']['content'], true, $self_url);
                  *
                  * //if($v['type'] == 'postvideo'){
                  * // //$weibolist[$k]['content'] = $v['source_body'];
                  * // $weibolist[$k]['content'] = $v['feed_content'] ? $v['feed_content'] : $v['source_body'];
                  * // $weibolist[$k]['content'] = wapFormatContent($weibolist[$k]['content'], true, $self_url, "知识");
                  * //}else{
                  * // $weibolist[$k]['content'] = wapFormatContent($weibolist[$k]['content'], true, $self_url);
                  * //}
                  * // 非视频分享
                  * if ($v['transpond_data']['content']) {
                  * if(strpos($weibolist[$k]['type'], 'video')){
                  * $weibolist[$k]['transpond_data']['content'] = wapFormatContent($v['transpond_data']['content'], true, $self_url, "视频");
                  * }else{
                  * $weibolist[$k]['transpond_data']['content'] = wapFormatContent($v['transpond_data']['content'], true, $self_url);
                  * }
                  * $weibolist[$k]['transpond_data']['weibo_id'] = $weibolist[$k]['transpond_data']['feed_id'];
                  * }else{
                  * $row_id = model('Feed')->where('feed_id='.$v['feed_id'])->getField('app_row_id');
                  * $uid = model('Feed')->where('feed_id='.$row_id)->getField('uid');
                  * $weibolist[$k]['transpond_data'] = model('User')->getUserInfo($this->uid);
                  * }
                  * $weibolist[$k]['ctime'] = date('Y-m-d H:i', $v['publish_time']);
                  * }else{
                  * if($weibolist[$k]['row_id']){
                  * $weibolist[$k]['ctime'] = strtotime($weibolist[$k]['ctime']);
                  * }else{
                  * unset($weibolist[$k]);
                  * }
                  *
                  * }
                  */
                 break;
             case 'public':
                 if ($v['feed_id']) {
                     $weibolist[$k]['weibo_id'] = $weibolist[$k]['feed_id'];
                     // $weibolist[$k]['content'] = wapFormatContent($v['content'], true, $self_url);
                     // 视频处理
                     if ($v['type'] == 'postvideo') {
                         // $weibolist[$k]['content'] = $v['source_body'];
                         $weibolist[$k]['content'] = $v['feed_content'] ? $v['feed_content'] : $v['source_body'];
                         $weibolist[$k]['content'] = wapFormatContent($weibolist[$k]['content'], true, $self_url, "视频");
                     } else {
                         $weibolist[$k]['content'] = wapFormatContent($weibolist[$k]['content'], true, $self_url);
                     }
                     // 非视频分享
                     if ($v['transpond_data']['content']) {
                         if (strpos($weibolist[$k]['type'], 'video')) {
                             $weibolist[$k]['transpond_data']['content'] = wapFormatContent($v['transpond_data']['content'], true, $self_url, "视频");
                         } else {
                             $weibolist[$k]['transpond_data']['content'] = wapFormatContent($v['transpond_data']['content'], true, $self_url);
                         }
                         $weibolist[$k]['transpond_data']['weibo_id'] = $weibolist[$k]['transpond_data']['feed_id'];
                     } else {
                         $row_id = model('Feed')->where('feed_id=' . $v['feed_id'])->getField('app_row_id');
                         $uid = model('Feed')->where('feed_id=' . $row_id)->getField('uid');
                         $weibolist[$k]['transpond_data'] = model('User')->getUserInfo($this->uid);
                     }
                     $weibolist[$k]['ctime'] = date('Y-m-d H:i', $v['publish_time']);
                 } else {
                     if ($weibolist[$k]['row_id']) {
                         $weibolist[$k]['ctime'] = strtotime($weibolist[$k]['ctime']);
                     } else {
                         unset($weibolist[$k]);
                     }
                 }
                 break;
             case 'weiba':
                 $weiba_post = D('WeibaPost', 'weiba')->where('post_id=' . $v['app_row_id'])->find();
                 $weibolist[$k]['weibo_id'] = $weibolist[$k]['feed_id'];
                 $weibolist[$k]['transpond_data'] = $weiba_post;
                 $weibolist[$k]['transpond_data']['weibo_id'] = $weibolist[$k]['feed_id'];
                 $weibolist[$k]['transpond_data']['uname'] = model('User')->where('uid=' . $weiba_post['post_uid'])->getField('uname');
                 $weibolist[$k]['transpond_data']['uid'] = $weiba_post['post_uid'];
                 break;
             default:
                 // code...
                 break;
         }
         // 处理视频链接
         /*
          * if(strpos($weibolist[$k]['type'], 'video')){
          * $weibolist[$k]['content'] = preg_replace("/(.*)<a([^>*])>([^<*])</a>(.*)/i", "\\1<a\\2>视频</a>\\4", $weibolist[$k]['content']);
          * $weibolist[$k]['transpond_data']['content'] = preg_replace("/(.*)<a([^>*])>([^<*])</a>(.*)/i", "\\1<a\\2>视频</a>\\4", $weibolist[$k]['transpond_data']['content']);
          * }
          */
         $weibolist[$k]['from'] = getFromClient($weibolist[$k]['from'], $v['app']);
         $map['source_id'] = $v['feed_id'];
         $map['uid'] = $this->mid;
         $fav = model('Collection')->where($map)->getField('source_id');
         if ($fav) {
             $weibolist[$k]['favorited'] = 1;
         } else {
             $weibolist[$k]['favorited'] = 0;
         }
     }
     return $weibolist;
 }
 public function feed_top_home()
 {
     $uid = intval($_GET['uid']);
     $list = $this->model('FeedTopHome')->getFeedTopHome($uid);
     $this->assign('uid', $uid);
     $this->assign('mid', $this->mid);
     foreach ($list as &$value) {
         $value['feed_info'] = model('Feed')->get($value['feed_id']);
         switch ($value['feed_info']['app']) {
             case 'weiba':
                 $value['feed_info']['from'] = getFromClient(0, $value['feed_info']['app'], '微吧');
                 break;
             case 'tipoff':
                 $value['feed_info']['from'] = getFromClient(0, $value['feed_info']['app'], '爆料');
                 break;
             default:
                 $value['feed_info']['from'] = getFromClient($value['feed_info']['from'], $value['feed_info']['app']);
         }
     }
     $this->assign('data', $list);
     $feed_ids = getSubByKey($list, 'feed_id');
     $diggArr = model('FeedDigg')->checkIsDigg($feed_ids, $this->mid);
     $this->assign('diggArr', $diggArr);
     $cancomment_old_type = array('post', 'repost', 'postimage', 'postfile', 'weiba_post', 'weiba_repost', 'blog_post', 'blog_repost', 'event_post', 'event_repost', 'vote_post', 'vote_repost', 'photo_post', 'photo_repost');
     $this->assign('cancomment_old_type', $cancomment_old_type);
     $uids = array();
     foreach ($list as $item) {
         $uids[] = $item['feed_info']['uid'];
     }
     if (!empty($uids)) {
         $map = array();
         $map['uid'] = $GLOBALS['ts']['mid'];
         $map['fid'] = array('in', $uids);
         $followUids = model('Follow')->where($map)->getAsFieldArray('fid');
         $this->assign('followUids', $followUids);
         $remarkHash = model('Follow')->getRemarkHash($GLOBALS['ts']['mid']);
         $this->assign('remarkHash', $remarkHash);
     }
     $this->display('feedTop');
 }
 public function doPostTrue()
 {
     $uid = $data['user_id'] = $_GET['uid'] <= 0 ? $this->mid : $_GET['uid'];
     $profile = api('User')->data($data)->show();
     $data['id'] = $profile['last_feed']["{$uid}"]['feed_id'];
     $feed = api('WeiboStatuses')->data($data)->show();
     $feed['from'] = getFromClient($feed['from'], 'public');
     // $feed = $this->__formatByContent($feed);
     // dump($feed);
     $this->assign('feed', $feed);
     $this->display('doPostTrue');
 }
 public function getDiggListPage($map, $limit = 20)
 {
     $list = $this->where($map)->order('id desc')->findPage($limit);
     foreach ($list['data'] as &$d) {
         $d['user'] = model('User')->getUserInfo($d['uid']);
         $d['feed'] = model('Feed')->getFeedInfo($d['feed_id']);
         $d['feed']['content'] = parse_html($d['feed']['content']);
         $d['feed']['feed_content'] = parse_html($d['feed']['feed_content']);
         switch ($d['feed']['app']) {
             case 'weiba':
                 $d['feed']['from'] = getFromClient(0, $d['feed']['app'], '微吧');
                 break;
             default:
                 $d['feed']['from'] = getFromClient($d['feed']['from'], $d['feed']['app']);
                 break;
         }
     }
     return $list;
 }
 /**
  * 分享到分享
  * 
  * @example 需要传入的$data值
  *          sid:转发的分享/资源ID
  *          app_name:app名称
  *          content:转发时的内容信息,有时候会有某些标题的资源
  *          body:转发时,自定义写入的内容
  *          type:分享类型(分享原文app_row_table)
  *          comment:是否给原作者评论
  * @param array $data
  *        	分享的相关数据
  * @param string $from
  *        	是否发@给资源作者,默认为share
  * @param array $lessUids
  *        	去掉@用户,默认为null
  * @return array 分享操作后,相关反馈信息数据
  */
 public function shareFeed($data, $from = 'share', $lessUids = null)
 {
     // 返回的数据结果集
     $return = array('status' => 0, 'data' => L('PUBLIC_SHARE_FAILED'));
     // 分享失败
     // 验证数据正确性
     if (empty($data['sid'])) {
         return $return;
     }
     $stable = t($data['type']);
     // 资源所在的表名
     $sid = t($data['sid']);
     $app = isset($data['app_name']) ? $data['app_name'] : APP_NAME;
     // 当前产生分享所属的应用
     $forApi = $data['forApi'] ? true : false;
     // 是否为接口形式
     if (!($oldInfo = model('Source')->getSourceInfo($stable, $sid, $forApi, $app))) {
         $return['data'] = L('PUBLIC_INFO_SHARE_FORBIDDEN');
         // 此信息不可以被分享
         return $return;
     }
     // 内容数据
     $d['content'] = isset($data['content']) ? str_replace(SITE_URL, '[SITE_URL]', $data['content']) : '';
     $d['body'] = str_replace(SITE_URL, '[SITE_URL]', $data['body']);
     // 处理分享类型
     $feedType = 'repost';
     // 默认为普通的转发格式
     if (!empty($oldInfo['feedtype']) && !in_array($oldInfo['feedtype'], array('post', 'postimage', 'postfile'))) {
         $feedType = $oldInfo['feedtype'];
     }
     if ($app != 'public') {
         // 非分享类型内容转发
         $oldInfo['uid'] = $oldInfo['source_user_info']['uid'];
         $oldInfo['sourceInfo']['source_id'] = $oldInfo['feed_id'];
         $feedType = $app . '_repost';
     }
     $d['sourceInfo'] = !empty($oldInfo['sourceInfo']) ? $oldInfo['sourceInfo'] : $oldInfo;
     // 是否发送@上级节点
     $isOther = $from == 'comment' ? false : true;
     // 获取上个节点资源ID
     $d['curid'] = $data['curid'];
     // 获取转发原分享信息
     $appId = $oldInfo['source_id'];
     $appTable = $oldInfo['source_table'];
     $d['from'] = isset($data['from']) ? intval($data['from']) : 0;
     $d['latitude'] = isset($data['latitude']) ? $data['latitude'] : 0;
     $d['longitude'] = isset($data['longitude']) ? $data['longitude'] : 0;
     $d['address'] = isset($data['address']) ? $data['address'] : 0;
     if ($res = model('Feed')->put($GLOBALS['ts']['mid'], $app, $feedType, $d, $appId, $appTable, null, $lessUids, $isOther, 1)) {
         // if($data['comment'] != 0 && $oldInfo['uid'] != $data['comment_touid']) {
         if ($data['comment'] != 0 || $data['comment_old'] != 0) {
             // && $oldInfo['uid'] != $data['comment_touid']
             // 发表评论
             $c['type'] = 2;
             $c['app'] = $app;
             $c['table'] = 'feed';
             $c['app_uid'] = $oldInfo['uid'];
             $c['content'] = !empty($d['body']) ? $d['body'] : $d['content'];
             $c['row_id'] = !empty($oldInfo['sourceInfo']) ? $oldInfo['sourceInfo']['source_id'] : $appId;
             $c['client_type'] = getVisitorClient();
             $notCount = true;
             unlockSubmit();
             $comment_id = model('Comment')->addComment($c, true, $notCount, $lessUids);
             // 同步到微吧
             if ($app == 'weiba') {
                 $postDetail = D('weiba_post')->where('feed_id=' . $c['row_id'])->find();
                 if ($postDetail) {
                     $datas['weiba_id'] = $postDetail['weiba_id'];
                     $datas['post_id'] = $postDetail['post_id'];
                     $datas['post_uid'] = $postDetail['post_uid'];
                     // $datas['to_reply_id'] = $data['to_comment_id']?D('weiba_reply')->where('comment_id='.$data['to_comment_id'])->getField('reply_id'):0;
                     // $datas['to_uid'] = $data['to_uid'];
                     $datas['uid'] = $GLOBALS['ts']['mid'];
                     $datas['ctime'] = time();
                     $datas['content'] = $c['content'];
                     $datas['comment_id'] = $comment_id;
                     if (D('weiba_reply')->add($datas)) {
                         $map['last_reply_uid'] = $this->mid;
                         $map['last_reply_time'] = $datas['ctime'];
                         D('weiba_post')->where('post_id=' . $datas['post_id'])->save($map);
                         // 回复统计数加1
                         D('weiba_post')->where('post_id=' . $datas['post_id'])->setInc('reply_count');
                     }
                 }
             }
         }
         // 添加话题
         model('FeedTopic')->addTopic(html_entity_decode($d['body'], ENT_QUOTES), $res['feed_id'], $feedType);
         // 渲染数据
         $rdata = $res;
         // 渲染完后的结果
         $rdata['feed_id'] = $res['feed_id'];
         $rdata['app_row_id'] = $data['sid'];
         $rdata['app_row_table'] = $data['type'];
         $rdata['app'] = $app;
         $rdata['is_repost'] = 1;
         switch ($app) {
             case 'weiba':
                 $rdata['from'] = getFromClient(0, $app, '微吧');
                 break;
             default:
                 $rdata['from'] = getFromClient($from, $app);
                 break;
         }
         $return['data'] = $rdata;
         $return['status'] = 1;
         // 被分享内容“分享统计”数+1,同时可检测出app,table,row_id 的有效性
         if (!($pk = D($data['type'], $data['app_name'])->getPk())) {
             $pk = $data['type'] . '_id';
         }
         D($data['type'], $data['app_name'])->setInc('repost_count', "`{$pk}`={$data['sid']}", 1);
         if ($data['curid'] != $data['sid'] && !empty($data['curid'])) {
             if (!($pk = D($data['curtable'])->getPk())) {
                 $pk = $data['curtable'] . '_id';
             }
             D($data['curtable'])->setInc('repost_count', "`{$pk}`={$data['curid']}", 1);
             D($data['curtable'])->cleanCache($data['curid']);
         }
         D($data['type'], $data['app_name'])->cleanCache($data['sid']);
     } else {
         $return['data'] = model('Feed')->getError();
     }
     return $return;
 }
 /**
  * 获取指定用户的某条动态
  * @return void
  */
 public function feed()
 {
     if (empty($_GET['feed_id'])) {
         $this->error(L('PUBLIC_INFO_ALREADY_DELETE_TIPS'));
     }
     // 获取用户信息
     $user_info = model('User')->getUserInfo($this->uid);
     //个人空间头部
     $this->_top();
     //判断隐私设置
     $userPrivacy = $this->privacy($this->uid);
     if ($userPrivacy['space'] !== 1) {
         $this->_sidebar();
         $feedInfo = model('Feed')->get(intval($_GET['feed_id']));
         if (!$feedInfo) {
             $this->error('该微博不存在或已被删除');
         }
         if (intval($_GET['uid']) != $feedInfo['uid']) {
             $this->error('参数错误');
         }
         if ($feedInfo['is_audit'] == '0' && $feedInfo['uid'] != $this->mid) {
             $this->error('此微博正在审核');
             exit;
         }
         if ($feedInfo['is_del'] == '1') {
             $this->error(L('PUBLIC_NO_RELATE_WEIBO'));
             exit;
         }
         $weiboSet = model('Xdata')->get('admin_Config:feed');
         $a['initNums'] = $weiboSet['weibo_nums'];
         $a['weibo_type'] = $weiboSet['weibo_type'];
         $a['weibo_premission'] = $weiboSet['weibo_premission'];
         $this->assign($a);
         switch ($feedInfo['app']) {
             case 'weiba':
                 $feedInfo['from'] = getFromClient(0, $feedInfo['app'], '微吧');
                 break;
             default:
                 $feedInfo['from'] = getFromClient($from, $feedInfo['app']);
                 break;
         }
         //$feedInfo['from'] = getFromClient( $feedInfo['from'] , $feedInfo['app']);
         $this->assign('feedInfo', $feedInfo);
     } else {
         $this->_assignUserInfo($this->uid);
     }
     //seo
     $feedContent = unserialize($feedInfo['feed_data']);
     $seo = model('Xdata')->get("admin_Config:seo_feed_detail");
     $replace['content'] = $feedContent['content'];
     $replace['uname'] = $feedInfo['user_info']['uname'];
     $replaces = array_keys($replace);
     foreach ($replaces as &$v) {
         $v = "{" . $v . "}";
     }
     $seo['title'] = str_replace($replaces, $replace, $seo['title']);
     $seo['keywords'] = str_replace($replaces, $replace, $seo['keywords']);
     $seo['des'] = str_replace($replaces, $replace, $seo['des']);
     !empty($seo['title']) && $this->setTitle($seo['title']);
     !empty($seo['keywords']) && $this->setKeywords($seo['keywords']);
     !empty($seo['des']) && $this->setDescription($seo['des']);
     $this->assign('userPrivacy', $userPrivacy);
     $this->display();
 }
 /**
  * 3.0发布微博操作,用于AJAX
  * @return json 发布微博后的结果信息JSON数据
  */
 public function PostFeed()
 {
     if (!$this->ismember) {
         $return = array('status' => 0, 'data' => '抱歉,您不是该群成员');
         exit(json_encode($return));
     }
     // 返回数据格式
     $return = array('status' => 1, 'data' => '');
     //圈子ID
     $gid = intval($_POST['gid']);
     // 用户发送内容
     $d['content'] = isset($_POST['content']) ? filter_keyword(h($_POST['content'])) : '';
     $d['gid'] = $gid;
     // 原始数据内容
     $d['body'] = filter_keyword(h($_POST['body']));
     $d['source_url'] = urldecode($_POST['source_url']);
     //应用分享到微博,原资源链接
     // 滤掉话题两端的空白
     $d['body'] = preg_replace("/#[\\s]*([^#^\\s][^#]*[^#^\\s])[\\s]*#/is", '#' . trim("\${1}") . '#', $d['body']);
     // 附件信息
     $d['attach_id'] = trim(t($_POST['attach_id']), "|");
     !empty($d['attach_id']) && ($d['attach_id'] = explode('|', $d['attach_id']));
     // 发送微博的类型
     $type = t($_POST['type']);
     // 所属应用名称
     //$app = isset($_POST['app_name']) ? t($_POST['app_name']) : APP_NAME;			// 当前动态产生所属的应用
     $app = 'group';
     if ($data = D('GroupFeed')->put($this->uid, $app, $type, $d)) {
         // 发布邮件之后添加积分
         //model('Credit')->setUserCredit($this->uid,'add_weibo');
         // 微博来源设置
         $data['from'] = getFromClient($data['from'], 'public');
         $this->assign($data);
         //微博配置
         $weiboSet = model('Xdata')->get('admin_Config:feed');
         $this->assign('weibo_premission', $weiboSet['weibo_premission']);
         $return['data'] = $this->fetch();
         // // 微博ID
         // $return['feedId'] = $data['feed_id'];
         // $return['is_audit'] = $data['is_audit'];
         // //添加话题
         //          model('FeedTopic')->addTopic(html_entity_decode($d['body'], ENT_QUOTES), $data['feed_id'], $type);
         // //更新用户最后发表的微博
         // $last['last_feed_id'] = $data['feed_id'];
         // $last['last_post_time'] = $_SERVER['REQUEST_TIME'];
         // model( 'User' )->where('uid='.$this->uid)->save($last);
         //         // 添加微博到投稿数据中
         //         $isOpenChannel = model('App')->isAppNameOpen('channel');
         //         if($isOpenChannel) {
         //          $channelId = t($_POST['channel_id']);
         //          // 绑定用户
         //          $bindUserChannel = D('Channel', 'channel')->getCategoryByUserBind($this->mid);
         //          if(!empty($bindUserChannel)) {
         //          	$channelId = array_merge($bindUserChannel, explode(',', $channelId));
         //          	$channelId = array_filter($channelId);
         //          	$channelId = array_unique($channelId);
         //          	$channelId = implode(',', $channelId);
         //          }
         //          // 绑定话题
         //          $content = html_entity_decode($d['body'], ENT_QUOTES);
         //     		$content = str_replace("#", "#", $content);
         // preg_match_all("/#([^#]*[^#^\s][^#]*)#/is", $content, $topics);
         // $topics = array_unique($topics[1]);
         // foreach($topics as &$topic) {
         // 	$topic = trim(preg_replace("/#/",'',t($topic)));
         // }
         // $bindTopicChannel = D('Channel', 'channel')->getCategoryByTopicBind($topics);
         //          if(!empty($bindTopicChannel)) {
         //          	$channelId = array_merge($bindTopicChannel, explode(',', $channelId));
         //          	$channelId = array_filter($channelId);
         //          	$channelId = array_unique($channelId);
         //          	$channelId = implode(',', $channelId);
         //          }
         //          if(!empty($channelId)) {
         //          	D('Channel', 'channel')->setChannel($data['feed_id'], $channelId, false);
         //          }
         //         }
     } else {
         $return = array('status' => 0, 'data' => model('Feed')->getError());
     }
     exit(json_encode($return));
 }
 /**
  * 获取指定用户的某条动态
  * 
  * @return void
  */
 public function feed()
 {
     $feed_id = intval($_GET['feed_id']);
     if (empty($feed_id)) {
         $this->error(L('PUBLIC_INFO_ALREADY_DELETE_TIPS'));
     }
     // 获取用户信息
     $user_info = model('User')->getUserInfo($this->uid);
     // 个人空间头部
     $this->_top();
     // 判断隐私设置
     $userPrivacy = $this->privacy($this->uid);
     if ($userPrivacy['space'] !== 1) {
         $this->_sidebar();
         $feedInfo = model('Feed')->get($feed_id);
         if (!$feedInfo) {
             $this->error('该微博不存在或已被删除');
         }
         // if (intval ( $_GET ['uid'] ) != $feedInfo ['uid'])
         // $this->error ( '参数错误' );
         if ($feedInfo['is_audit'] == '0' && $feedInfo['uid'] != $this->mid) {
             $this->error('此微博正在审核');
             exit;
         }
         if ($feedInfo['is_del'] == '1') {
             $this->error(L('PUBLIC_NO_RELATE_WEIBO'));
             exit;
         }
         $weiboSet = model('Xdata')->get('admin_Config:feed');
         $a['initNums'] = $weiboSet['weibo_nums'];
         $a['weibo_type'] = $weiboSet['weibo_type'];
         $a['weibo_premission'] = $weiboSet['weibo_premission'];
         $this->assign($a);
         if ($feedInfo['from'] == '1') {
             $feedInfo['from'] = getFromClient(6, $feedInfo['app'], '3G版');
         } else {
             switch ($feedInfo['app']) {
                 case 'weiba':
                     $feedInfo['from'] = getFromClient(0, $feedInfo['app'], '微吧');
                     break;
                 default:
                     $feedInfo['from'] = getFromClient($feedInfo['from'], $feedInfo['app']);
                     break;
             }
         }
         // $feedInfo['from'] = getFromClient( $feedInfo['from'] , $feedInfo['app']);
         // 微博图片
         if ($feedInfo['type'] === 'postimage') {
             $var = unserialize($feedInfo['feed_data']);
             $feedInfo['image_body'] = $var['body'];
             if (!empty($var['attach_id'])) {
                 $var['attachInfo'] = model('Attach')->getAttachByIds($var['attach_id']);
                 foreach ($var['attachInfo'] as $ak => $av) {
                     $_attach = array('attach_id' => $av['attach_id'], 'attach_name' => $av['name'], 'attach_url' => getImageUrl($av['save_path'] . $av['save_name']), 'extension' => $av['extension'], 'size' => $av['size']);
                     $_attach['attach_small'] = getImageUrl($av['save_path'] . $av['save_name'], 100, 100, true);
                     $_attach['attach_middle'] = getImageUrl($av['save_path'] . $av['save_name'], 550);
                     $feedInfo['attachInfo'][$ak] = $_attach;
                 }
             }
         }
         $this->assign('feedInfo', $feedInfo);
     } else {
         $this->_assignUserInfo($this->uid);
     }
     // seo
     $feedContent = unserialize($feedInfo['feed_data']);
     $seo = model('Xdata')->get("admin_Config:seo_feed_detail");
     $replace['content'] = $feedContent['content'];
     $replace['uname'] = $feedInfo['user_info']['uname'];
     $replaces = array_keys($replace);
     foreach ($replaces as &$v) {
         $v = "{" . $v . "}";
     }
     $seo['title'] = str_replace($replaces, $replace, $seo['title']);
     $seo['keywords'] = str_replace($replaces, $replace, $seo['keywords']);
     $seo['des'] = str_replace($replaces, $replace, $seo['des']);
     !empty($seo['title']) && $this->setTitle($seo['title']);
     !empty($seo['keywords']) && $this->setKeywords($seo['keywords']);
     !empty($seo['des']) && $this->setDescription($seo['des']);
     $this->assign('userPrivacy', $userPrivacy);
     // 赞功能
     $diggArr = model('FeedDigg')->checkIsDigg($feed_id, $this->mid);
     $this->assign('diggArr', $diggArr);
     $this->display();
 }
 /**
  * 分享到微博
  * @example
  * 需要传入的$data值
  * sid:转发的微博/资源ID
  * app_name:app名称
  * content:转发时的内容信息,有时候会有某些标题的资源
  * body:转发时,自定义写入的内容
  * type:微博类型
  * comment:是否给原作者评论
  * @param array $data 分享的相关数据
  * @param string $from 是否发@给资源作者,默认为share
  * @param array $lessUids 去掉@用户,默认为null
  * @return array 分享操作后,相关反馈信息数据
  */
 public function shareFeed($data, $from = 'share', $lessUids = null)
 {
     // 返回的数据结果集
     $return = array('status' => 0, 'data' => L('PUBLIC_SHARE_FAILED'));
     // 分享失败
     // 验证数据正确性
     if (empty($data['sid'])) {
         return $return;
     }
     // type是资源所在的表名
     $type = t($data['type']);
     // 当前产生微博所属的应用
     $app = isset($data['app_name']) ? $data['app_name'] : APP_NAME;
     // 是否为接口形式
     $forApi = $data['forApi'] ? true : false;
     if (!($oldInfo = model('Source')->getSourceInfo($type, $data['sid'], $forApi, $data['app_name']))) {
         $return['data'] = L('PUBLIC_INFO_SHARE_FORBIDDEN');
         // 此信息不可以被分享
         return $return;
     }
     $d['gid'] = $data['gid'];
     // 内容数据
     $d['content'] = isset($data['content']) ? str_replace(SITE_URL, '[SITE_URL]', $data['content']) : '';
     $d['body'] = str_replace(SITE_URL, '[SITE_URL]', $data['body']);
     $feedType = 'repost';
     // 默认为普通的转发格式
     if (!empty($oldInfo['feedtype']) && !in_array($oldInfo['feedtype'], array('post', 'postimage', 'postfile'))) {
         $feedType = $oldInfo['feedtype'];
     }
     $d['sourceInfo'] = !empty($oldInfo['sourceInfo']) ? $oldInfo['sourceInfo'] : $oldInfo;
     // 是否发送@上级节点
     $isOther = $from == 'comment' ? false : true;
     // 获取上个节点资源ID
     $d['curid'] = $data['curid'];
     // 获取转发原微博信息
     if ($oldInfo['app_row_id'] == 0) {
         $appId = $oldInfo['source_id'];
         $appTable = $oldInfo['source_table'];
     } else {
         $appId = $oldInfo['app_row_id'];
         $appTable = $oldInfo['app_row_table'];
     }
     $d['from'] = isset($data['from']) ? intval($data['from']) : 0;
     if ($res = D('GroupFeed')->put($GLOBALS['ts']['mid'], $app, $feedType, $d, $appId, $appTable, null, $lessUids, $isOther, 1)) {
         if ($data['comment'] != 0 && $oldInfo['uid'] != $data['comment_touid']) {
             // 发表评论
             $c['app'] = $app;
             $c['table'] = $appTable;
             $c['app_uid'] = $oldInfo['uid'];
             $c['content'] = !empty($d['body']) ? $d['body'] : $d['content'];
             $c['row_id'] = !empty($oldInfo['sourceInfo']) ? $oldInfo['sourceInfo']['source_id'] : $appId;
             $c['client_type'] = getVisitorClient();
             $c['gid'] = $d['gid'];
             $notCount = $from == "share" ? true : false;
             $comment_id = D('GroupComment')->addComment($c, false, $notCount, $lessUids);
         }
         //添加话题
         //model('FeedTopic')->addTopic(html_entity_decode($d['body'], ENT_QUOTES, 'UTF-8'), $res['feed_id'], $feedType);
         // 渲染数据
         $rdata = $res;
         // 渲染完后的结果
         $rdata['feed_id'] = $res['feed_id'];
         $rdata['app_row_id'] = $data['sid'];
         $rdata['app_row_table'] = $data['type'];
         $rdata['app'] = $app;
         $rdata['is_repost'] = 1;
         switch ($app) {
             case 'weiba':
                 $rdata['from'] = getFromClient(0, $app, '微吧');
                 break;
             default:
                 $rdata['from'] = getFromClient($from, $app);
                 break;
         }
         $return['data'] = $rdata;
         $return['status'] = 1;
         // 被分享内容“分享统计”数+1,同时可检测出app,table,row_id 的有效性
         if (!($pk = D($data['type'], $data['app_name'])->getPk())) {
             $pk = $data['type'] . '_id';
         }
         D('GroupFeed')->setInc('repost_count', "`feed_id`={$data['sid']}", 1);
         if ($data['curid'] != $data['sid'] && !empty($data['curid'])) {
             // 				if(!$pk = D($data['curtable'])->getPk()) {
             // 					$pk = $data['curtable'].'_id';
             // 				}
             D('GroupFeed')->setInc('repost_count', "`feed_id`={$data['curid']}", 1);
             D('GroupFeed')->cleanCache($data['curid']);
         }
         D('GroupFeed')->cleanCache($data['sid']);
     } else {
         $return['data'] = D('GroupFeed')->getError();
     }
     return $return;
 }
 /**
  * 获取话题分享数据,渲染分享显示页面
  * @param array $var 分享数据相关参数
  * @param string $tpl 渲染的模板
  * @return array 获取分享相关模板数据
  */
 private function getTopicData($var, $tpl = 'FeedList.html')
 {
     $var['cancomment'] = isset($var['cancomment']) ? $var['cancomment'] : 1;
     //$var['cancomment_old_type'] = array('post','repost','postimage','postfile');
     $var['cancomment_old_type'] = array('post', 'repost', 'postimage', 'postfile', 'weiba_post', 'weiba_repost');
     $weiboSet = model('Xdata')->get('admin_Config:feed');
     $var = array_merge($var, $weiboSet);
     $var['remarkHash'] = model('Follow')->getRemarkHash($GLOBALS['ts']['mid']);
     $map = $list = array();
     $type = $var['new'] ? 'new' . $var['type'] : $var['type'];
     //最新的分享与默认分享类型一一对应
     if ($var['loadId'] > 0) {
         //非第一次
         $topics['topic_id'] = $var['topic_id'];
         $topics['feed_id'] = array('lt', intval($var['loadId']));
         $map['feed_id'] = array('in', getSubByKey(D('feed_topic_link')->where($topics)->field('feed_id')->select(), 'feed_id'));
     } else {
         $map['feed_id'] = array('in', getSubByKey(D('feed_topic_link')->where('topic_id=' . $var['topic_id'])->field('feed_id')->select(), 'feed_id'));
     }
     if (!empty($var['feed_type'])) {
         $map['type'] = t($var['feed_type']);
     }
     //$map['is_del'] = 0;
     $map['_string'] = ' (is_audit=1 OR is_audit=0 AND uid=' . $GLOBALS['ts']['mid'] . ') AND is_del = 0 ';
     $list = model('Feed')->getList($map, $this->limitnums);
     //分页的设置
     isset($list['html']) && ($var['html'] = $list['html']);
     if (!empty($list['data'])) {
         $content['firstId'] = $var['firstId'] = $list['data'][0]['feed_id'];
         $content['lastId'] = $var['lastId'] = $list['data'][count($list['data']) - 1]['feed_id'];
         $var['data'] = $list['data'];
         $uids = array();
         foreach ($var['data'] as &$v) {
             switch ($v['app']) {
                 case 'weiba':
                     $v['from'] = getFromClient(0, $v['app'], '微吧');
                     break;
                 default:
                     $v['from'] = getFromClient($v['from'], $v['app']);
                     break;
             }
             !isset($uids[$v['uid']]) && $v['uid'] != $GLOBALS['ts']['mid'] && ($uids[] = $v['uid']);
         }
         if (!empty($uids)) {
             $map = array();
             $map['uid'] = $GLOBALS['ts']['mid'];
             $map['fid'] = array('in', $uids);
             $var['followUids'] = model('Follow')->where($map)->getAsFieldArray('fid');
         } else {
             $var['followUids'] = array();
         }
     }
     $content['pageHtml'] = $list['html'];
     //渲染模版
     $content['html'] = $this->renderFile(dirname(__FILE__) . "/" . $tpl, $var);
     return $content;
 }
 /**
  * 提到我的分享页面
  */
 public function index()
 {
     // 获取未读@Me的条数
     $this->assign('unread_atme_count', model('UserData')->where('uid=' . $this->mid . " and `key`='unread_atme'")->getField('value'));
     // 拼装查询条件
     $map['uid'] = $this->mid;
     $d['tab'] = model('Atme')->getTab(null);
     foreach ($d['tab'] as $key => $vo) {
         if ($key == 'feed') {
             $d['tabHash']['feed'] = L('PUBLIC_WEIBO');
         } elseif ($key == 'comment') {
             $d['tabHash']['comment'] = L('PUBLIC_STREAM_COMMENT');
         } else {
             $langKey = 'PUBLIC_APPNAME_' . strtoupper($key);
             $lang = L($langKey);
             if ($lang == $langKey) {
                 $d['tabHash'][$key] = ucfirst($key);
             } else {
                 $d['tabHash'][$key] = $lang;
             }
         }
     }
     $this->assign($d);
     !empty($_GET['t']) && ($map['table'] = t($_GET['t']));
     // 设置应用名称与表名称
     $app_name = isset($_GET['app_name']) ? t($_GET['app_name']) : 'public';
     // $app_table = isset($_GET['app_table']) ? t($_GET['app_table']) : '';
     // 获取@Me分享列表
     $at_list = model('Atme')->setAppName($app_name)->setAppTable($app_table)->getAtmeList($map);
     // 赞功能
     $feed_ids = getSubByKey($at_list['data'], 'feed_id');
     $diggArr = model('FeedDigg')->checkIsDigg($feed_ids, $GLOBALS['ts']['mid']);
     $this->assign('diggArr', $diggArr);
     // dump($at_list);exit;
     // 添加Widget参数数据
     foreach ($at_list['data'] as &$val) {
         if ($val['source_table'] == 'comment') {
             $val['widget_sid'] = $val['sourceInfo']['source_id'];
             $val['widget_style'] = $val['sourceInfo']['source_table'];
             $val['widget_sapp'] = $val['sourceInfo']['app'];
             $val['widget_suid'] = $val['sourceInfo']['uid'];
             $val['widget_share_sid'] = $val['sourceInfo']['source_id'];
         } elseif ($val['is_repost'] == 1) {
             $val['widget_sid'] = $val['source_id'];
             $val['widget_stype'] = $val['source_table'];
             $val['widget_sapp'] = $val['app'];
             $val['widget_suid'] = $val['uid'];
             $val['widget_share_sid'] = $val['app_row_id'];
             $val['widget_curid'] = $val['source_id'];
             $val['widget_curtable'] = $val['source_table'];
         } else {
             $val['widget_sid'] = $val['source_id'];
             $val['widget_stype'] = $val['source_table'];
             $val['widget_sapp'] = $val['app'];
             $val['widget_suid'] = $val['uid'];
             $val['widget_share_sid'] = $val['source_id'];
         }
         // 获取转发与评论数目
         if ($val['source_table'] != 'comment') {
             $feedInfo = model('Feed')->get($val['widget_sid']);
             $val['repost_count'] = $feedInfo['repost_count'];
             $val['comment_count'] = $feedInfo['comment_count'];
         }
         // 解析数据成网页端显示格式(@xxx 加链接)
         $val['source_content'] = parse_html($val['source_content']);
         $val['from'] = getFromClient($val['from'], $val['app']);
     }
     // 获取分享设置
     $weiboSet = model('Xdata')->get('admin_Config:feed');
     $this->assign($weiboSet);
     // 用户@Me未读数目重置
     // model('UserCount')->resetUserCount($this->mid, 'unread_atme', 0);
     $this->setTitle(L('PUBLIC_MENTION_INDEX'));
     $userInfo = model('User')->getUserInfo($this->mid);
     $this->setKeywords('@提到' . $userInfo['uname'] . '的消息');
     $this->assign($at_list);
     $this->display();
 }
 private function login_vars($data)
 {
     //登陆配置
     $data = model('Xdata')->lget('hook_login_page');
     $logo = explode('|', $data['logo']['logo']);
     $logo[1] && ($data['logo']['logo'] = getImageUrl($logo[1]));
     $map['is_del'] = 0;
     $feedlimit = $data['feed']['feed_num'] ? $data['feed']['feed_num'] : 10;
     switch ($data['feed']['feed_source']) {
         case 2:
             $map['uid'] = array('in', explode(',', $data['feed']['feed_user']));
             break;
         case 3:
             $users = model('UserVerified')->field('uid')->group('uid')->order('id desc')->limit($feedlimit)->findAll();
             $map['uid'] = array('in', getSubByKey($users, 'uid'));
             break;
     }
     $feeds = model('Feed')->where($map)->order("feed_id desc")->limit($feedlimit)->field('feed_id')->findAll();
     $feedids = getSubByKey($feeds, 'feed_id');
     $loginlastfeed = model('Feed')->getFeeds($feedids);
     foreach ($loginlastfeed as &$v) {
         switch ($v['app']) {
             case 'weiba':
                 $v['from'] = getFromClient(0, $v['app'], '微吧');
                 break;
             default:
                 $v['from'] = getFromClient($v['from'], $v['app']);
                 break;
         }
     }
     $data['loginlastfeed'] = $loginlastfeed;
     $limit = $data['user']['user_num'] ? $data['user']['user_num'] : 12;
     switch ($data['user']['user_source']) {
         case 1:
             $users = model('UserData')->where("`key`='follower_count'")->order('`value`+0 desc')->field('uid')->limit($limit)->findAll();
             $uids = getSubByKey($users, 'uid');
             break;
         case 2:
             $uids = explode(',', $data['user']['users']);
             $uids = array_slice($uids, 0, $limit);
             break;
         case 3:
             $users = model('UserVerified')->field('uid')->group('uid')->order('id desc')->limit($limit)->findAll();
             $uids = getSubByKey($users, 'uid');
             break;
         case 4:
             $feedmap['is_del'] = 0;
             $feedmap['is_audit'] = 1;
             $feedmap['is_active'] = 1;
             $feedmap['is_init'] = 1;
             $users = model('User')->where($feedmap)->field('uid')->order('ctime desc')->limit($limit)->findAll();
             $uids = getSubByKey($users, 'uid');
             break;
     }
     $uids = array_unique(array_filter($uids));
     if ($uids) {
         $ulist = model('User')->getUserInfoByUids($uids);
         $data['userlist'] = $ulist;
     }
     $data['navilist'] = model('Navi')->getBottomNav();
     $announcement = model('Xarticle')->where('type=1')->order('id desc')->limit(1)->findAll();
     $data['announcement'] = $announcement;
     if ($data['logo']['weiba_recommend'] != 2) {
         $weiba_recommend = D('weiba')->order('follower_count desc')->where('recommend=1 and is_del=0')->limit(5)->findAll();
         foreach ($weiba_recommend as $k => $v) {
             $weiba_recommend[$k]['logo'] = getImageUrlByAttachId($v['logo']);
         }
         $data['logo']['weiba_recommend_list'] = $weiba_recommend;
     }
     return $data;
 }
 /**
  * 获取话题分享数据,渲染分享显示页面
  *
  * @param  array  $var
  *                     分享数据相关参数
  * @param  string $tpl
  *                     渲染的模板
  * @return array  获取分享相关模板数据
  */
 private function getTopicData(array $var, $tpl = 'FeedList.html')
 {
     /* # 判断 */
     $var['cancomment'] or $var['cancomment'] = 1;
     /* # Old type */
     $var['cancomment_old_type'] = array('post', 'repost', 'postimage', 'postfile', 'weiba_post', 'weiba_repost');
     /* # 合并后台分享设置 */
     $weiboSet = model('Xdata')->get('admin_Config:feed');
     $var = array_merge($var, $weiboSet);
     unset($weiboSet);
     /* # 获取指定用户的备注列表 */
     $var['remarkHash'] = model('Follow')->getRemarkHash($this->mid);
     /* # 初始where条件 */
     $where = '`topic_id` = ' . intval($var['topic_id']);
     /* # load id */
     $var['loadId'] > 0 and $where .= ' AND `feed_id` < ' . intval($var['loadId']);
     /* # 分享条件 */
     $map = array('feed_id' => array('IN', getSubByKey(D('feed_topic_link')->where($where)->field('`feed_id`')->select(), 'feed_id')));
     unset($where);
     /* # 分享类型 */
     empty($var['feed_type']) or $map['feed_type'] = t($var['feed_type']);
     /* # string where */
     $map['_string'] = ' (`is_audit` = 1 OR (is_audit = 0 AND `uid` = ' . $this->mid . ')) AND `is_del` = 0';
     /*$map ['_string'] = ' (is_audit=1 OR is_audit=0 AND uid=' . $GLOBALS ['ts'] ['mid'] . ') AND is_del = 0 ';*/
     /* # 获取分享列表 */
     $list = model('Feed')->getList($map, $this->limitnums);
     unset($map);
     /* # 分页设置 */
     isset($list['html']) and $var['html'] = $list['html'];
     /* # 如果有数据 */
     if (!empty($list['data'])) {
         /* # 第一条ID */
         $first = array_shift($list['data']);
         $content['firstId'] = $var['firstId'] = $first['feed_id'];
         /* # 将第一条数据还原 */
         array_unshift($list['data'], $first);
         unset($first);
         /* # 最后一条 */
         $last = array_pop($list['data']);
         $content['lastId'] = $var['lastId'] = $last['feed_id'];
         /* # 将最后一条数据还原 */
         array_push($list['data'], $last);
         unset($last);
         /* # 数据复制 */
         $var['data'] = $list['data'];
         /* # 赞功能,获取所有分享ID */
         $feed_ids = getSubByKey($var['data'], 'feed_id');
         /* # 指定用户是否赞了指定的分享 */
         $var['diggArr'] = model('FeedDigg')->checkIsDigg($feed_ids, $this->mid);
         unset($feed_ids);
         /* # 定义储存用户uid的数组 */
         $uids = array();
         /* # 遍历数据 */
         foreach ($var['data'] as $key => $value) {
             /* # 判断来自客户端类型 */
             switch ($value['app']) {
                 /* # 判断是否来自微吧 */
                 case 'weiba':
                     $var['data'][$key]['from'] = getFromClient(0, $value['app'], '微吧');
                     break;
                     /* # 其他 */
                 /* # 其他 */
                 default:
                     $var['data'][$key]['from'] = getFromClient($value['from'], $value['app']);
                     break;
             }
             /* # 加入UID */
             if (!in_array($value['uid'], $uids) and $value['uid'] != $this->mid) {
                 array_push($uids, $value['uid']);
             }
             /* # 变量注销 */
             unset($key, $value);
         }
         /* # 默认数据 */
         $var['followUids'] = array();
         /* # 如果存在uids */
         if (!empty($uids)) {
             /* # 创建where条件 */
             $map = array('uid' => $this->mid, 'fid' => array('IN', $uids));
             /* # 取得数据 */
             $var['followUids'] = model('Follow')->where($map)->getAsFieldArray('fid');
             unset($map);
         }
         /* # 注销变量 */
         unset($uids);
     }
     /* # 取得分页数据 */
     $content['pageHtml'] = $list['html'];
     /* # 渲染的模板数据 */
     $content['html'] = $this->renderFile(__DIR__ . '/' . $tpl, $var);
     /* # 注销变量 */
     unset($var, $list);
     /* # 返回数据 */
     return $content;
 }
Exemple #24
0
 /**
  * 发布分享操作,用于AJAX
  *
  * @return json 发布分享后的结果信息JSON数据
  */
 public function PostFeed()
 {
     // 返回数据格式
     $return = array('status' => 1, 'data' => '');
     // 用户发送内容
     $d['content'] = isset($_POST['content']) ? h($_POST['content']) : '';
     $filterContentStatus = filter_words($d['content']);
     if (!$filterContentStatus['status']) {
         exit(json_encode(array('status' => 0, 'data' => $filterContentStatus['data'])));
     }
     $d['content'] = $filterContentStatus['data'];
     ///
     if ($_POST['channel_id'] == '' && $_POST['channel'] == 'channel') {
         $return = array('status' => 0, 'data' => '请选择频道');
         exit(json_encode($return));
     }
     // 原始数据内容
     $filterBodyStatus = filter_words($_POST['body']);
     if (!$filterBodyStatus['status']) {
         $return = array('status' => 0, 'data' => $filterBodyStatus['data']);
         exit(json_encode($return));
     }
     $d['body'] = $filterBodyStatus['data'];
     // 安全过滤
     foreach ($_POST as $key => $val) {
         $_POST[$key] = t($_POST[$key]);
     }
     $d['source_url'] = urldecode($_POST['source_url']);
     // 应用分享到分享,原资源链接
     // 滤掉话题两端的空白
     $d['body'] = preg_replace("/#[\\s]*([^#^\\s][^#]*[^#^\\s])[\\s]*#/is", '#' . trim('${1}') . '#', $d['body']);
     // $numbers = array(41624,41625,41626,41627,41628,41629);
     // shuffle($numbers);
     // // 附件信息
     // if($_POST ['attach_id']==''&&$_POST ['channel_id']!=''){
     // 	$_POST ['attach_id'] = '|'.$numbers[0].'|'.$numbers[1].'|'.$numbers[2].'|';
     // 	$_POST ['type'] = 'postimage';
     // }
     $d['attach_id'] = trim(t($_POST['attach_id']), '|');
     if (!empty($d['attach_id'])) {
         $d['attach_id'] = explode('|', $d['attach_id']);
         if (count($d['attach_id']) == 1 && $_POST['channel_id'] != '' && false) {
             $d['attach_id'][1] = $d['attach_id'][0];
             $d['attach_id'][0] = $numbers[0];
             $_POST['type'] = 'postimage';
         }
         array_map('intval', $d['attach_id']);
     }
     if ($_POST['video_id']) {
         $d['video_id'] = intval($_POST['video_id']);
     }
     // 发送分享的类型
     $type = t($_POST['type']);
     // 附件信息
     // 所属应用名称
     $app = isset($_POST['app_name']) ? t($_POST['app_name']) : APP_NAME;
     // 当前动态产生所属的应用
     if (!($data = model('Feed')->put($this->uid, $app, $type, $d))) {
         $return = array('status' => 0, 'data' => model('Feed')->getError());
         exit(json_encode($return));
     }
     // 发布邮件之后添加积分
     model('Credit')->setUserCredit($this->uid, 'add_weibo');
     // 分享来源设置
     $data['from'] = getFromClient($data['from'], $data['app']);
     $this->assign($data);
     // 分享配置
     $weiboSet = model('Xdata')->get('admin_Config:feed');
     $this->assign('weibo_premission', $weiboSet['weibo_premission']);
     $return['data'] = $this->fetch();
     // 分享ID
     $return['feedId'] = $data['feed_id'];
     $return['is_audit'] = $data['is_audit'];
     // 添加话题
     model('FeedTopic')->addTopic(html_entity_decode($d['body'], ENT_QUOTES, 'UTF-8'), $data['feed_id'], $type);
     // 更新用户最后发表的分享
     $last['last_feed_id'] = $data['feed_id'];
     $last['last_post_time'] = $_SERVER['REQUEST_TIME'];
     model('User')->where('uid=' . $this->uid)->save($last);
     $isOpenChannel = model('App')->isAppNameOpen('channel');
     if (!$isOpenChannel) {
         exit(json_encode($return));
     }
     // 添加分享到投稿数据中
     $channelId = t($_POST['channel_id']);
     // 绑定用户
     $bindUserChannel = D('Channel', 'channel')->getCategoryByUserBind($this->mid);
     if (!empty($bindUserChannel)) {
         $channelId = array_merge($bindUserChannel, explode(',', $channelId));
         $channelId = array_filter($channelId);
         $channelId = array_unique($channelId);
         $channelId = implode(',', $channelId);
     }
     // 绑定话题
     $content = html_entity_decode($d['body'], ENT_QUOTES, 'UTF-8');
     $content = str_replace('#', '#', $content);
     preg_match_all("/#([^#]*[^#^\\s][^#]*)#/is", $content, $topics);
     $topics = array_unique($topics[1]);
     foreach ($topics as &$topic) {
         $topic = trim(preg_replace('/#/', '', t($topic)));
     }
     $bindTopicChannel = D('Channel', 'channel')->getCategoryByTopicBind($topics);
     if (!empty($bindTopicChannel)) {
         $channelId = array_merge($bindTopicChannel, explode(',', $channelId));
         $channelId = array_filter($channelId);
         $channelId = array_unique($channelId);
         $channelId = implode(',', $channelId);
     }
     if (!empty($channelId)) {
         // 获取后台配置数据
         $channelConf = model('Xdata')->get('channel_Admin:index');
         $return['is_audit_channel'] = $channelConf['is_audit'];
         // 添加频道数据
         D('Channel', 'channel')->setChannel($data['feed_id'], $channelId, false);
     }
     exit(json_encode($return));
 }