private function filterWeibo($aType, $param)
 {
     if ($aType == 'concerned') {
         $followList = D('Follow')->getFollowList();
         $param['where']['uid'] = array('in', $followList);
     }
     if ($aType == 'hot') {
         $hot_left = modC('HOT_LEFT', 3);
         $time_left = get_some_day($hot_left);
         $param['where']['create_time'] = array('gt', $time_left);
         $param['order'] = 'comment_count desc';
         $this->assign('tab', 'hot');
     }
     return $param;
 }
 private function filterWeibo($aType, $param)
 {
     if ($aType == 'concerned') {
         $followList = D('Follow')->getFollowList();
         $param['where']['uid'] = array('in', $followList);
     }
     if ($aType == 'hot') {
         $hot_left = modC('HOT_LEFT', 3);
         $time_left = get_some_day($hot_left);
         $param['where']['create_time'] = array('gt', $time_left);
         $param['order'] = 'comment_count desc';
         $this->assign('tab', 'hot');
     }
     if ($aType == 'fav') {
         $map_fav['app_name'] = 'Weibo';
         $map_fav['table'] = 'weibo';
         $map_fav['uid'] = get_uid();
         $support = D('Support')->where($map_fav)->field('row')->select();
         $param['where']['id'] = array('in', implode(',', getSubByKey($support, 'row')));
         $param['order'] = 'create_time desc';
     }
     return $param;
 }
 public function getRank($type)
 {
     $time = get_some_day(0);
     $time_yesterday = get_some_day(1);
     $memberModel = M('Member');
     switch ($type) {
         case 'today':
             $list = $this->where(array('create_time' => array('egt', $time)))->order('create_time asc')->limit(5)->select();
             break;
         case 'con':
             $uids = $this->where(array('create_time' => array('egt', $time_yesterday)))->field('uid')->select();
             $uids = getSubByKey($uids, 'uid');
             $list = $memberModel->where(array('uid' => array('in', $uids)))->field('uid,con_check')->order('con_check desc,uid asc')->limit(5)->select();
             break;
         case 'total':
             $list = $memberModel->field('uid,total_check')->order('total_check desc,uid asc')->limit(5)->select();
             break;
     }
     foreach ($list as &$v) {
         $v['user'] = query_user(array('avatar32', 'avatar64', 'space_url', 'nickname', 'uid'), $v['uid']);
     }
     unset($v);
     return $list;
 }
 public function ranking()
 {
     $aPage = I('get.page', 1, 'intval');
     $aOrder = I('get.order', 'total_check', 'op_t');
     $checkInfoModel = D('Addons://CheckIn/CheckIn');
     $memberModel = D('Member');
     $limit = 50;
     if ($aOrder == 'today') {
         $user_list = $checkInfoModel->field('uid,create_time')->page($aPage, $limit)->where(array('create_time' => array('egt', get_some_day(0))))->order('create_time asc, uid asc')->select();
         $totalCount = $checkInfoModel->where(array('create_time' => array('egt', get_some_day(0))))->count();
         foreach ($user_list as $key => &$val) {
             $val['ranking'] = ($aPage - 1) * $limit + $key + 1;
             if ($val['ranking'] <= 3) {
                 $val['ranking'] = '<span style="color:#EB7112;">' . $val['ranking'] . '</span>';
             }
             $val['status'] = '<span>已签到 ' . friendlyDate($val['create_time']) . '</span>';
             $user = query_user(array('uid', 'nickname', 'total_check', 'con_check'), $val['uid']);
             $val = array_merge($val, $user);
         }
         unset($key, $val);
     } else {
         $user_list = $memberModel->field('uid,nickname,total_check,con_check')->page($aPage, $limit)->order($aOrder . ' desc,uid asc')->select();
         $totalCount = $memberModel->count();
         foreach ($user_list as $key => &$val) {
             $val['ranking'] = ($aPage - 1) * $limit + $key + 1;
             if ($val['ranking'] <= 3) {
                 $val['ranking'] = '<span style="color:#EB7112;">' . $val['ranking'] . '</span>';
             }
             $check = $checkInfoModel->getCheck($val['uid']);
             if ($check) {
                 $val['status'] = '<span>已签到 ' . friendlyDate($check['create_time']) . '</span>';
             } else {
                 $val['status'] = '<span style="color: #BDBDBD;">未签到</span>';
             }
         }
     }
     foreach ($user_list as &$u) {
         $temp_user = query_user(array('nickname'), $u['uid']);
         $u['nickname'] = $temp_user['nickname'];
     }
     unset($u);
     $this->assign('user_list', $user_list);
     $this->assign('totalCount', $totalCount);
     if (is_login()) {
         //获取用户信息
         $user_info = query_user(array('uid', 'nickname', 'space_url', 'avatar64', 'con_check', 'total_check'), is_login());
         $check = $checkInfoModel->getCheck(is_login());
         if ($check) {
             $user_info['is_sign'] = $check['create_time'];
         } else {
             $user_info['is_sign'] = 0;
         }
         if ($aOrder == 'today') {
             $ranking = $checkInfoModel->field('uid')->where(array('create_time' => array('egt', get_some_day(0))))->order('create_time asc, uid asc')->select();
         } else {
             $ranking = $memberModel->field('uid')->order($aOrder . ' desc,uid asc')->select();
         }
         $ranking = getSubByKey($ranking, 'uid');
         if (array_search(is_login(), $ranking) === false) {
             $user_info['ranking'] = count($ranking) + 1;
         } else {
             $user_info['ranking'] = array_search(is_login(), $ranking) + 1;
         }
         $this->assign('user_info', $user_info);
     }
     $this->assign('order', $aOrder);
     $this->display(T('Addons://CheckIn@CheckIn/ranking'));
 }
 public function doCheckIn()
 {
     $time = get_some_day(0);
     $uid = is_login();
     $model = $this->checkInModel();
     $memberModel = M('Member');
     $check = $model->getCheck($uid);
     if (!$check) {
         $model->addCheck($uid);
         $memberModel->where(array('uid' => $uid))->setInc('total_check');
         $model->checkYesterday($uid);
         clean_query_user_cache($uid, array('con_check', 'total_check'));
         S('check_rank_today_' . $time, null);
         S('check_rank_con_' . $time, null);
         S('check_rank_total_' . $time, null);
         return true;
     } else {
         return false;
     }
 }
 /**
  * 加载更多热门微博
  */
 public function addMoreHotWeibo()
 {
     $aPage = I('post.page', 1, 'op_t');
     $aCount = I('post.count', 10, 'op_t');
     $hot_left = modC('HOT_LEFT', 3);
     $time_left = get_some_day($hot_left);
     $time_left = get_some_day($hot_left);
     $param['create_time'] = array('gt', $time_left);
     $param['status'] = 1;
     $param['is_top'] = 0;
     $weibo = D('Weibo')->where(array('status' => 1, $param))->page($aPage, $aCount)->order('comment_count desc')->select();
     $support['appname'] = 'Weibo';
     //查找是否点赞
     $support['table'] = 'weibo';
     $support['uid'] = is_login();
     $is_zan = D('Support')->where($support)->select();
     $is_zan = array_column($is_zan, 'row');
     foreach ($weibo as &$v) {
         $v['user'] = query_user(array('nickname', 'avatar64', 'uid'), $v['uid']);
         $v['rand_title'] = mob_get_head_title($v['uid']);
         $v['support'] = D('Support')->where(array('appname' => 'Weibo', 'table' => 'weibo', 'row' => $v['id']))->count();
         if ($v['type'] === "repost") {
             $v['content'] = A('Mob/WeiboType')->fetchRepost($v);
         } else {
             if ($v['type'] === "xiami" || $v['type'] == "video") {
                 $v['content'] = Hook::exec('Addons\\Insert' . ucfirst($v['type']) . '\\Insert' . ucfirst($v['type']) . 'Addon', 'fetch' . ucfirst($v['type']), $v);
             } else {
                 $v['content'] = parse_weibo_mobile_content($v['content']);
             }
         }
         if (empty($v['from'])) {
             $v['from'] = "网站端";
         }
         $v['data'] = unserialize($v['data']);
         //字符串转换成数组,获取微博源ID
         if ($v['data']['sourceId']) {
             //判断是否是源微博
             $v['sourceId'] = $v['data']['sourceId'];
             $v['is_sourceId'] = '1';
         } else {
             $v['sourceId'] = $v['id'];
             $v['is_sourceId'] = '0';
         }
         $v['sourceId_user'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->find();
         //源微博用户名
         $v['sourceId_user'] = $v['sourceId_user']['uid'];
         $v['sourceId_user'] = query_user(array('nickname', 'uid'), $v['sourceId_user']);
         $v['sourceId_content'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('content')->find();
         //源微博内容
         if (!is_null($v['sourceId_content'])) {
             $v['sourceId_content'] = parse_weibo_mobile_content($v['sourceId_content']['content']);
             //把表情显示出来。
         }
         $v['sourceId_repost_count'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('repost_count')->find();
         //源微博转发数
         $v['sourceId_from'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('from')->find();
         //源微博来源
         if (empty($v['sourceId_from']['from'])) {
             $v['sourceId_from'] = "网站端";
         } else {
             $v['sourceId_from'] = "手机网页版";
         }
         $v['sourceId_img'] = D('Weibo')->where(array('status' => 1, 'id' => $v['sourceId']))->field('data')->find();
         //为了获取源微图片
         $v['sourceId_img'] = unserialize($v['sourceId_img']['data']);
         $v['sourceId_img'] = explode(',', $v['sourceId_img']['attach_ids']);
         //把attach_ids里的图片ID转出来
         foreach ($v['sourceId_img'] as &$b) {
             $v['sourceId_img_path'][] = getThumbImageById($b, 100, 100);
             //获得缩略图
             //获得原图
             $bi = M('Picture')->where(array('status' => 1))->getById($b);
             if (!is_bool(strpos($bi['path'], 'http://'))) {
                 $v['sourceId_img_big'][] = $bi['path'];
             } else {
                 $v['sourceId_img_big'][] = getRootUrl() . substr($bi['path'], 1);
             }
         }
         $v['cover_url'] = explode(',', $v['data']['attach_ids']);
         //把attach_ids里的图片ID转出来
         foreach ($v['cover_url'] as &$a) {
             $v['img_path'][] = getThumbImageById($a, 100, 100);
             //获得原图
             $bi = M('Picture')->where(array('status' => 1))->getById($b);
             if (!is_bool(strpos($bi['path'], 'http://'))) {
                 $v['sourceId_img_big'][] = $bi['path'];
             } else {
                 $v['sourceId_img_big'][] = getRootUrl() . substr($bi['path'], 1);
             }
         }
         if (in_array($v['id'], $is_zan)) {
             //判断是否已经点赞
             $v['is_support'] = '1';
         } else {
             $v['is_support'] = '0';
         }
         if (empty($v['data']['attach_ids'])) {
             //判断是否是图片
             $v['is_img'] = '0';
         } else {
             $v['is_img'] = '1';
         }
         if (empty($v['sourceId_img']['0'])) {
             $v['sourceId_is_img'] = '0';
         } else {
             $v['sourceId_is_img'] = '1';
         }
     }
     if ($weibo) {
         $data['html'] = "";
         foreach ($weibo as $val) {
             $this->assign("vl", $val);
             $data['html'] .= $this->fetch("_weibolist");
             $data['status'] = 1;
         }
     } else {
         $data['stutus'] = 0;
     }
     $this->ajaxReturn($data);
 }