public function index()
 {
     $indexList = D('weiba_post')->where('is_del=0 AND top=2')->order('is_index_time desc')->findAll();
     foreach ($indexList as &$v) {
         $imgList = matchImages($v['content']);
         if ($imgList) {
             $v['index_img_url'] = $imgList[0];
         }
     }
     $this->assign('indexList', $indexList);
     $order = '`top` desc,FIELD(recommend+digest,0,1,2) desc,last_reply_time desc';
     $map['is_del'] = 0;
     $map['is_index'] = 0;
     $list = D('weiba_post')->where($map)->order($order)->limit(20)->select();
     $this->assign('list', $list);
     // 推荐微吧
     if (!($weibalist = S('rec_weibalist'))) {
         $weibalist = D('weiba')->where('is_del=0 and status=1')->order('recommend desc,follower_count desc,thread_count')->limit(4)->select();
         S('rec_weibalist', $weibalist);
     }
     $this->assign('weibalist', $weibalist);
     //dump($indexList);
     $this->display();
 }
Пример #2
0
 /**
  * 热帖推荐
  * @param integer limit 获取微吧条数
  * @return void
  */
 private function _post_recommend($limit)
 {
     $db_prefix = C('DB_PREFIX');
     $sql = "SELECT a.* FROM `{$db_prefix}weiba_post` a, `{$db_prefix}weiba` b WHERE a.weiba_id=b.weiba_id AND ( b.`is_del` = 0 ) AND ( a.`recommend` = 1 ) AND ( a.`is_del` = 0 ) ORDER BY a.recommend_time desc LIMIT " . $limit;
     $post_recommend = D('weiba_post')->query($sql);
     $weiba_ids = getSubByKey($post_recommend, 'weiba_id');
     $nameArr = $this->_getWeibaName($weiba_ids);
     foreach ($post_recommend as $k => $v) {
         $post_recommend[$k]['weiba'] = $nameArr[$v['weiba_id']];
         $post_recommend[$k]['user'] = model('User')->getUserInfo($v['post_uid']);
         $post_recommend[$k]['replyuser'] = model('User')->getUserInfo($v['last_reply_uid']);
         $images = matchImages($v['content']);
         $images[0] && ($post_recommend[$k]['image'] = array_slice($images, 0, 5));
     }
     // dump($post_recommend);exit;
     $this->assign('post_recommend', $post_recommend);
 }
Пример #3
0
 /**
  * index
  * 好友的广场
  *
  * @access public
  * @return void
  */
 public function index()
 {
     $setting = model('Xdata')->lget('square');
     $map = array();
     if ($setting['channel'] == '1') {
         //频道
         $setting['channelid'] = explode(',', $setting['channelid']);
         $map['status'] = 1;
         if (!$setting['channelid']) {
             $list = D('Channel', 'channel')->where($map)->order('rand()')->limit(8)->findAll();
         } else {
             $map['feed_channel_link_id'] = array('in', $setting['channelid']);
             $list = D('Channel', 'channel')->where($map)->order('rand()')->limit(8)->findAll();
         }
         $feedIds = getSubByKey($list, 'feed_id');
         // 获取分享信息
         $feedInfo = model('Feed')->getFeeds($feedIds);
         $feedInfos = array();
         foreach ($feedInfo as $val) {
             $feedInfos[$val['feed_id']] = $val;
         }
         $cmap['c.feed_id'] = array('IN', $feedIds);
         $categoryInfo = D()->table('`' . C('DB_PREFIX') . 'channel` AS c LEFT JOIN `' . C('DB_PREFIX') . 'channel_category` AS cc ON cc.channel_category_id = c.channel_category_id')->field('c.`feed_id`,c.`feed_channel_link_id`, c.`status`, cc.channel_category_id, cc.`title`')->where($cmap)->findAll();
         $categoryInfos = array();
         foreach ($categoryInfo as $val) {
             $categoryInfos[$val['feed_id']][] = $val;
         }
         // 组装信息
         foreach ($list as &$value) {
             $info = @unserialize($feedInfos[$value['feed_id']]['feed_data']);
             $value['uid'] = $feedInfos[$value['feed_id']]['user_info']['uid'];
             $value['uname'] = $feedInfos[$value['feed_id']]['user_info']['uname'];
             $image = matchImages($feedInfos[$value['feed_id']]['body']);
             $value['img'] = '';
             if ($feedInfos[$value['feed_id']]['type'] == 'postimage') {
                 if ($info['attach_id']) {
                     $value['img'] = getImageUrlByAttachId($info['attach_id'][0], 236, 177, true);
                 }
             }
             $value['content'] = $info['body'] ? t($info['body']) : t($info['content']);
             $value['comment_count'] = $feedInfos[$value['feed_id']]['comment_count'];
             $value['digg_count'] = $feedInfos[$value['feed_id']]['digg_count'];
             $value['categoryInfo'] = $categoryInfos[$value['feed_id']];
         }
         $this->assign('channel', $list);
     }
     $map = array();
     if ($setting['weiba'] == '1') {
         $setting['weibaid'] = str_replace(",", ',', $setting['weibaid']);
         $setting['weibaid'] = explode(',', $setting['weibaid']);
         $weibaId = array();
         foreach ($setting['weibaid'] as $k => $vo) {
             $vo = intval(trim($vo));
             if ($vo > 0 && !in_array($vo, $weibaId)) {
                 $weibaId[] = $vo;
             }
         }
         $weiba = M('weiba');
         $map['is_del'] = 0;
         $map['status'] = 1;
         if ($weibaId) {
             $map['weiba_id'] = array('in', $weibaId);
             $order = 'field(weiba_id,' . implode(',', $weibaId) . ')';
             $weiba_recommend = $weiba->where($map)->order($order)->limit(6)->select();
         }
         if (!$weibaId || !$weiba_recommend) {
             $weiba_recommend = array();
         }
         //当推荐微吧不足3 或 6 时自动补齐
         $count = count($weiba_recommend);
         if ($count < 3 || $count > 3 && $count < 6) {
             if ($count != 0) {
                 $map['weiba_id'] = array('not in', $weibaId);
             } elseif (isset($map['weiba_id'])) {
                 unset($map['weiba_id']);
             }
             $order = 'recommend DESC,follower_count DESC';
             $weiba->where($map)->order($order);
             $limit = ($count < 3 ? 3 : 6) - $count;
             $array = $weiba->limit($limit)->select();
             $weiba_recommend = array_merge($weiba_recommend, $array);
         }
         foreach ($weiba_recommend as $k => $v) {
             $weiba_recommend[$k]['logo'] = getImageUrlByAttachId($v['logo']);
             //帖子推荐
             $sql = "SELECT post_id,title FROM `" . C('DB_PREFIX') . "weiba_post` WHERE weiba_id=" . $v['weiba_id'] . " AND ( `is_del` = 0 ) ORDER BY recommend desc,recommend_time desc,post_time desc LIMIT 3";
             $weiba_post = M('weiba_post')->query($sql);
             if ($weiba_post) {
                 foreach ($weiba_post as $kk => $vv) {
                     $weiba_post[$kk]['title'] = t($vv['title']);
                 }
                 $weiba_recommend[$k]['post'] = $weiba_post;
             }
         }
         $this->assign('weiba_recommend', $weiba_recommend);
         //精彩帖子
         $maps['is_del'] = 0;
         //剔除不符合微吧ID
         $fwid = D('weiba')->where('is_del=1 OR status=0')->order($order)->select();
         $fids = getSubByKey($fwid, 'weiba_id');
         if ($fids) {
             $maps['weiba_id'] = array('not in', $fids);
         }
         //首页推荐帖子
         $order = 'is_index_time desc';
         $maps['is_index'] = 1;
         $list = D('weiba_post')->field("weiba_id,post_id,title,content,index_img")->where($maps)->order($order)->select();
         //如果首页推荐帖子不够6个,获取全局置顶,吧内置顶,最新回复帖子
         if (count($list) < 6) {
             $limit = 6 - count($list);
             $post_ids = getSubByKey($list, 'post_id');
             $maps['post_id'] = array('not in', $post_ids);
             $maps['is_index'] = 0;
             $order = 'top desc,last_reply_time desc';
             $_list = D('weiba_post')->field("post_id,title,content")->where($maps)->order($order)->limit($limit)->select();
         }
         $weiba_hot = array_merge($list, $_list);
         if ($weiba_hot[0]['index_img'] != null) {
             //首页帖子图片换成缩略图
             $index_img = model('Attach')->getAttachById($weiba_hot[0]['index_img']);
             $weiba_hot[0]['index_img'] = getImageUrl($index_img['save_path'] . $index_img['save_name'], '290', '100', true, false);
         }
         foreach ($weiba_hot as $key => &$value) {
             $value['content'] = t($value['content']);
         }
         $this->assign("weiba_hot", $weiba_hot);
     } else {
         $this->assign('weiba_recommend', '');
     }
     if ($setting['relateduser'] == '1') {
         //最新认证用户
         $user_recommend = model('RelatedUser')->getRelatedUserSquare(6);
         foreach ($user_recommend as $k => $vo) {
             // 用户兴趣
             $tags = model('Tag')->setAppName('public')->setAppTable('user')->getAppTags($vo['userInfo']['uid']);
             //$user_recommend[$k]['userInfo']['tags'] =  implode (',',$tags);
             $user_recommend[$k]['userInfo']['tags'] = $tags;
         }
         $this->assign('user_recommend', $user_recommend);
         //后台推荐认证用户
         $setting = model('Xdata')->lget('square');
         $_user_recommend_verified = D('user_verified')->where('verified=1 and uid=' . $setting['user_recommend_uid'])->find();
         $setting = model('Xdata')->lget('square');
         //用户数据
         $_user_recommend = model("User")->getUserInfo($_user_recommend_verified['uid']);
         $_user_recommend['verified_info'] = $_user_recommend_verified;
         //用户组图标
         $icon = getSubByKey($_user_recommend['user_group'], 'user_group_icon', array('user_group_id', $_user_recommend['verified_info']['usergroup_id']));
         $icon = array_pop($icon);
         $_user_recommend['verified_info']['icon'] = basename(substr($icon, 0, strpos($icon, '.')));
         $this->assign('_user_recommend', $_user_recommend);
         //用户分享配图
         $_user_recommend_feedimages = $this->getUserAttachData($_user_recommend_verified['uid']);
         foreach ($_user_recommend_feedimages as $key => &$value) {
             $value['src'] = getImageUrl($value['savepath'], '103', '100', true, false);
             $value['uid'] = $_user_recommend_verified['uid'];
         }
         $this->assign('_user_recommend_feedimages', $_user_recommend_feedimages);
         //用户最新帖子
         $pmap['post_uid'] = $_user_recommend_verified['uid'];
         $pmap['is_del'] = 0;
         $_user_recommend_posts = D('weiba_post')->field("post_id,title")->where($pmap)->limit(5)->order('post_time desc')->select();
         $this->assign('_user_recommend_posts', $_user_recommend_posts);
     }
     $this->display();
 }
Пример #4
0
 public function insert()
 {
     $title = $_POST['title'];
     $content = $_POST['content'];
     if (empty($title) || empty($content)) {
         $this->error('日志不能为空!');
         exit;
     }
     $dao = D('Blog');
     $dao->title = $title;
     $dao->content = $content;
     $dao->cTime = time();
     $dao->userId = $this->mid;
     //$dao->tagIds	=	$this->addTag($_POST['tags']);
     if ($result = $dao->add()) {
         /* 可以插入日志标签 * /
         				$this->addTagIndex($_POST['tags'],$result);
         			/**/
         /* add_user_feed */
         $feedTitle = "添加了新日志";
         $blogImages = matchImages(stripslashes($content));
         if ($blogImages) {
             $feedInfo .= "<a href=\"/Blog/content/id/{$result}\"><img src=\"" . WEB_PUBLIC_URL . "/Thumb/?w=100&h=100&t=f&url={$blogImages[0]}\" alt=\"{$title}\" /></a>";
         }
         $feedInfo .= "<strong><a href=\"/Blog/content/id/{$result}\">{$title}</a></strong><br />" . getBlogShort($content);
         $this->addUserFeed($this->mid, 'add', 'blog', $result, $feedTitle, $feedInfo);
         /* /add_user_feed */
         header('location:' . __APP__ . '/blog/' . $result);
         //$this->success("添加日志成功!",$result);
     } else {
         $this->error("添加日志失败!");
     }
 }
Пример #5
0
 /**
  * doUpdate
  * 执行更新日志动作
  * @access public
  * @return void
  */
 public function doUpdate()
 {
     if (empty($_POST['title'])) {
         $this->error("请填写标题");
     }
     if (mb_strlen($_POST['title'], 'UTF-8') > 25) {
         $this->error("标题不能大于25个字符");
     }
     $content = text(html_entity_decode(h(t($_POST['content']))));
     if (empty($_POST['content']) || empty($content)) {
         $this->error("日志内容不能为空");
     }
     $userName = $this->blog->getOneName(intval($_POST['uid']));
     $id = intval($_POST['id']);
     //检查更新合法化
     if (!model('UserGroup')->isAdmin($this->mid) && $this->blog->where('id = ' . $id)->getField('uid') != $this->mid) {
         $this->error(L('error_no_role'));
     }
     $data = $this->__getPost();
     $data['content'] = $data['content'];
     $images = matchImages($data['content']);
     $data['cover'] = $images[0];
     $save = $this->blog->doSaveBlog($data, $id);
     if ($save) {
         // redirect(U('blog/Index/show', array('id'=>$id, 'mid'=>$this->mid)));
         $res['id'] = $id;
         $res['mid'] = intval($_POST['uid']);
         exit($this->ajaxReturn($res, '发布成功', 1));
     } else {
         $this->error("修改失败");
     }
 }
 public function doAddNotice()
 {
     $title = text($_POST['title']);
     if (empty($title)) {
         $this->error("请填写标题");
     }
     if (mb_strlen($title, 'UTF-8') > 25) {
         $this->error("标题不得大于25个字符");
     }
     $content = text(html_entity_decode($_POST['content']));
     //检查是否为空
     if (empty($_POST['content']) || empty($content)) {
         $this->error("请填写内容");
     }
     //得到发布任务人的名字
     $userName = $this->task->getOneName($this->mid);
     //处理发布任务的数据
     $data = $this->__getNoticePost();
     $data['cTime'] = time();
     //添加任务
     $add = $this->taskNotice->add($data);
     //如果是有自动保存的数据。删除自动保存数据
     if (isset($_POST['saveId']) && !empty($_POST['saveId'])) {
         $mention = D('TaskOutline');
         $mention->where('id = ' . $_POST['saveId'])->delete();
     }
     if ($add) {
         X('Credit')->setUserCredit($this->mid, 'add_notice');
         $this->assign('jumpUrl', U('task/Index/showNotice', array('id' => $add, 'mid' => $this->mid)));
         $html = '【' . text($data['title']) . '】' . getShort($content, 80) . U('task/Index/showNotice', array('id' => $add, 'mid' => $this->mid));
         $images = matchImages($data['content']);
         $image = $images[0] ? $images[0] : false;
         $this->ajaxData = array('url' => U('task/Index/showNotice', array('id' => $add, 'mid' => $this->mid)), 'id' => $add, 'html' => $html, 'image' => $image, 'title' => t($_POST['title']));
         $this->assign('jumpUrl', U('task/Index/notices'));
         $this->success('发表成功');
     } else {
         $this->error("添加失败");
     }
 }
Пример #7
0
function getBlogTitleImage($id)
{
    $dao = D('Blog');
    $content = $dao->find($id)->content;
    $content = stripslashes($content);
    $images = matchImages($content);
    if (false === $images) {
        $retrun = false;
    } else {
        $retrun = $images[0];
    }
    return $retrun;
}