/** * 评论列表 */ public function index() { if (!isset($this->category[$this->cid])) { $this->error('栏目不存在'); } if (empty($this->aid)) { $this->error('文章不存在'); } $category = S('category'); $model = S('model'); $contentData = M($model[$category[$this->cid]['mid']]['table_name'])->find($this->aid); if (empty($contentData)) { $this->error('文章不存在', __ROOT__); } $db = M('addon_comment'); $map['cid'] = array('EQ', $this->cid); $map['aid'] = array('EQ', $this->aid); $count = $db->where($map)->count(); $page = new Page($count, 10); $data = M('addon_comment')->field('c.comment_id,c.user_id,icon,username,comment_content,comment_time,praise,cid,aid,status,count(r.reply_id) AS reply_count')->join('__user__ u JOIN __addon_comment__ c ON u.uid=c.user_id LEFT JOIN __addon_comment_reply__ r ON c.comment_id=r.comment_id')->group('c.comment_id')->where($map)->limit($page->limit())->all(); //回复数据 foreach ($data as $id => $d) { $data[$id]['reply'] = M('addon_comment_reply')->join("__addon_comment_reply__ a JOIN __user__ u ON a.user_id=u.uid")->where("comment_id={$d['comment_id']}")->all(); } $this->assign('data', $data); $this->assign('count', $count); $this->assign('page', $page); $this->display(); exit; }
public function index() { $u = preg_replace('@[^\\w]@', '', Q('u')); $pre = C('DB_PREFIX'); $sql = "SELECT uid,nickname,rname,r.rid,spec_num,credits,regtime,logintime,domain,icon FROM {$pre}user AS u\n INNER JOIN {$pre}role AS r ON u.rid=r.rid\n WHERE u.uid='{$u}' OR domain='{$u}'"; if (!($user = M()->query($sql))) { _404('会员不存在'); } $user = $user[0]; //--------------------------增加空间访问次数 if (!isset($_SESSION['uid']) or $_SESSION['uid'] != $user['uid']) { $sql = "UPDATE {$pre}user SET spec_num=spec_num+1"; M()->exe($sql); } //---------------------------获得文章列表 $where = 'uid=' . $user['uid'] . ' AND content_state=1 '; $db = M('content'); $count = $db->where($where)->count(); $page = new Page($count, 10); $data = $db->where($where)->limit($page->limit())->all(); $this->data = $data; $this->page = $page->show(); $this->user = $user; //------------------------------获得访问数据 $guest = $this->getGuest($user['uid']); $this->assign('guest', $guest); $this->display(); }
public function index() { $page = new Page($this->_db->count(), 15); $this->data = $this->_db->limit($page->limit())->order("total DESC")->all(); $this->page = $page->show(); $this->display(); }
public function show() { $cid = Q('cid', 0, 'intval'); $aid = Q('aid', 0, 'intval'); $Model = K('Comment'); $where = "comment_state=1 AND cid={$cid} AND aid={$aid}"; $count = $Model->join()->where($where)->where("pid=0 ")->count(); $page = new Page($count, 15); $data = array(); if ($count) { //获得1级回复的id $result = $Model->where($where)->where("pid=0 ")->limit($page->limit())->order("comment_id desc")->getField('comment_id', true); $comment_id = implode(',', $result); $data = $Model->where("comment_state=1 AND (comment_id IN ({$comment_id}) OR reply_comment_id IN ({$comment_id}))")->order("comment_id ASC")->all(); //设置头像(没有头像的用户使用默认头像) foreach ($data as $n => $d) { if (empty($d['icon'])) { $data[$n]['icon'] = __ROOT__ . "/data/image/user/50-gray.png"; } else { $data[$n]['icon'] = __ROOT__ . '/' . $d['icon']; } } } //获得多层 $data = Data::channelLevel($data, 0, '', 'comment_id'); $this->assign('page', $page->show()); $this->assign('data', $data); $con = $this->fetch('index.php'); if (Q('page')) { echo $con; } else { echo "document.write('<div id=\"hdcomment\">" . preg_replace('@\\r|\\n@mi', '', addslashes($con)) . "</div>')"; } exit; }
/** * 查看订单 * @return [type] [description] */ public function index() { $page = new Page($this->db->count(), 5); $data = $this->db->limit($page->limit())->all(); $this->assign(array('data' => $data, 'page' => $page->show())); $this->display(); }
public function doWebLists() { $Model = new CreditsRecord(); //会员信息 $user = Db::table('member')->where('uid', Session::get('member.uid'))->first(); if ($timerange = q('get.timerange')) { //有筛选时间的 $timerange = explode('至', $timerange); $total = $Model->where('uid', Session::get('member.uid'))->where('credittype', q('get.type'))->where('createtime', '>=', strtotime($timerange[0]))->where('createtime', '<=', strtotime($timerange[1]))->count(); $page = Page::row(8)->make($total); $data = $Model->where('uid', Session::get('member.uid'))->where('credittype', q('get.type'))->where('createtime', '>=', strtotime($timerange[0]))->where('createtime', '<=', strtotime($timerange[1]))->limit(Page::limit())->get(); } else { $total = $Model->where('uid', Session::get('member.uid'))->where('credittype', q('get.type'))->count(); $page = Page::row(8)->make($total); $data = $Model->where('uid', Session::get('member.uid'))->where('credittype', q('get.type'))->limit(Page::limit())->get(); } //收入 $income = $Model->where('num', '>', 0)->where('uid', Session::get('member.uid'))->where('credittype', q('get.type'))->sum('num'); //支出 $expend = $Model->where('num', '<', 0)->where('uid', Session::get('member.uid'))->where('credittype', q('get.type'))->sum('num'); View::with(['income' => $income, 'expend' => $expend]); View::with('page', $page); View::with('user', $user); View::with('data', $data); View::make($this->ucenter_template . '/credit_lists.html'); }
public function index() { $page = new Page($this->_db->count(), 10); $this->page = $page->show(2); $this->article = $this->_db->limit($page->limit())->all(); $this->display(); }
public function index(){ $total = $this->db->totalPro(); $page = new Page($total,2,2); $data = $this->db->allPro($page->limit()); $this->assign('page',$page->show()); $this->assign('goods',$data); $this->display(); }
public function getFavoritesAricle() { $db = M('favorite'); $where = "user_id=" . $_SESSION['user']['uid']; $page = new Page($db->where($where)->count(), 6); $data = $db->where($where)->limit($page->limit())->order('fid DESC')->all(); return array('data' => $data, 'page' => $page->show()); }
/** * 显示列表 */ public function index() { $count = $this->db->count(); $page = new Page($count); $this->page = $page->show(); $upload = $this->db->order("id desc")->limit($page->limit())->all(); $this->assign('upload', $upload); $this->display(); }
public function index() { $db = K('Comment'); $page = new Page($db->count(), 10); $data = $db->limit($page->limit())->all(); $this->assign('data', $data); $this->assign('page', $page->show()); $this->display(); }
public function index() { $ContentModel = ContentViewModel::getInstance($this->_mid); $where = "uid=" . $_SESSION['uid']; $page = new Page($ContentModel->join('category')->where($where)->count(), 15); $data = $ContentModel->join('category')->where($where)->limit($page->limit())->order(array("arc_sort" => "ASC", 'aid' => "DESC"))->all(); $this->assign('data', $data); $this->display(); }
public function index() { $count = $this->db->count(); $page = new Page($count, 10); $data = $this->db->limit($page->limit())->order("comment_id DESC")->all(); $this->assign('data', $data); $this->assign('page', $page->show()); $this->display(); }
public function search() { $word = Q('word'); if (!$word) { $this->error("搜索内容不能为空"); } else { $cid = Q('cid', 0, 'intval'); $mid = $cid ? $modelCache[$categoryCache[$cid]['mid']] : 1; $pre = C('DB_PREFIX'); $seachType = Q('type', 'title'); $modelCache = cache('model'); $categoryCache = cache('category'); $contentModel = ContentViewModel::getInstance($mid); $table = $modelCache[$mid]['table_name']; if ($seachType == 'tag') { $db = M(); $countSql = "SELECT count(*) AS c FROM \n\t\t\t\t\t\t(SELECT distinct(aid) FROM {$pre}tag AS t INNER JOIN {$pre}content_tag AS ct ON t.tid=ct.tid WHERE tag='{$word}' AND mid=1 GROUP BY aid) AS c"; $count = $db->query($countSql); $page = new Page($count[0]['c'], 15); $DataSql = "SELECT * FROM {$pre}category as cat JOIN {$pre}{$table} AS c ON cat.cid = c.cid JOIN {$pre}content_tag AS ct ON c.aid=ct.aid INNER \n\t\t\t\t\t\t\t\t\t\tJOIN {$pre}tag AS t ON t.tid=ct.tid WHERE t.tag='{$word}' LIMIT " . $page->limit(true); $data = $db->query($DataSql); } else { $where = array(); if ($cid) { $where[] = $pre . "category.cid=" . $cid; } if (!empty($_GET['search_begin_time']) && !empty($_GET['search_end_time'])) { $where[] = "addtime>=" . strtotime($_GET['search_begin_time']) . " AND addtime<=" . $_GET['search_end_time']; } switch ($seachType) { case 'title': $where[] = "title like '%{$word}%'"; $count = $contentModel->join('category')->where($where)->count(); $page = new Page($count, 15); $data = $contentModel->join('category')->where($where)->all(); break; case 'description': $where[] = "description like '%{$word}%'"; $count = $contentModel->join('category')->where($where)->count(); $page = new Page($count, 15); $data = $contentModel->join('category')->where($where)->all(); break; case 'username': $where[] = "username like '%{$word}%'"; $count = $contentModel->join('category,user')->where($where)->count(); $page = new Page($count, 15); $data = $contentModel->join('category,user')->where($where)->all(); break; } } $this->assign('searchCategory', $categoryCache); $this->assign('page', $page); $this->assign('data', $data); $this->display(); } }
/** * 好友动态 */ public function friend() { $db = V('user_dynamic'); $db->view = array('user' => array('type' => INNER_JOIN, 'on' => 'user_dynamic.uid=user.uid'), 'user_follow' => array('type' => INNER_JOIN, 'on' => 'user_follow.uid=user_dynamic.uid')); $count = $db->where('fans_uid=' . $_SESSION['uid'])->count(); $page = new Page($count, 9); $this->page = $page->show(); $this->data = $db->where('fans_uid=' . $_SESSION['uid'])->limit($page->limit())->order("did DESC")->all(); $this->display(); }
/** * 文章列表 */ public function content() { $count = $this->_db->where($this->_db->tableFull . '.content_state=0')->count(); $page = new Page($count, 15); $this->page = $page->show(); $this->data = $this->_db->where($this->_db->tableFull . '.content_state=0')->limit($page->limit())->order('updatetime DESC')->all(); $this->mid = $this->_mid; $this->model = $this->_model; $this->display(); }
public function index() { $where = C('DB_PREFIX') . 'favorite.uid=' . $_SESSION['uid']; $count = $this->_db->join()->where($where)->count(); $page = new Page($count, 10); $this->data = $this->_db->where($where)->limit($page->limit())->all(); $this->page = $page->show(); $this->count = $count; $this->display(); }
/** * 评论列表 */ public function index() { $Model = M("comment"); $comment_state = Q('get.comment_state', 1, 'intval'); $count = $Model->where("comment_state={$comment_state}")->count(); $page = new Page($count, 15); $data = $Model->where("comment_state={$comment_state}")->limit($page->limit())->order('comment_id DESC')->all(); $this->assign('page', $page->show()); $this->assign('data', $data); $this->display(); }
public function index() { //顶级分类 $this->topCategory(); //通过cid 面包屑导航 $cid = Q('cid', 0, 'intval'); $data = $this->model->select(); //或许当前分类所有父级分类 $faterData = $this->model->_getFatherCids($cid, $data); //反转数组 $faterData = array_reverse($faterData); $this->assign('fatherData', $faterData); /*筛选*/ //获取所有子分类cid $cids = $this->model->getCids($cid, $data); //压入自己 $cids[] = $cid; //通过cid找到所有商品gid $gids = $this->model->cidtoGid($cids, $cid); if ($gids) { $attr = K('GoodsAttr')->getAttr($gids); $this->assign('attr', $attr); $total = count($attr); $param = isset($_GET['param']) ? explode('-', $_GET['param']) : array_fill(0, $total, 0); //防止用户乱改参数 if (count($param) != $total) { $param = array_fill(0, $total, 0); } $this->assign('param', $param); //通过$param $gids 筛选商品 $lastGids = K('GoodsAttr')->filterGids($param, $gids); } else { $lastGids = array(); } // 显示分类下所有商品 if ($lastGids) { $goods = M('goods')->where("gid IN(" . implode(',', $lastGids) . ")")->select(); } else { $goods = array(); } //分页处理 if ($goods) { $total = count($goods); $pageobj = new Page($total, 8, 5); $page = $pageobj->show(); $goods = M('goods')->where("gid IN(" . implode(',', $lastGids) . ")")->limit($pageobj->limit())->select(); $this->assign('page', $page); } //商品总数 $count = isset($goods) ? count($goods) : 0; $this->assign('count', $count); $this->assign('goods', $goods); $this->display(); }
public function index() { $Model = K('SystemMessage'); //修改状态 $Model->join()->where(array('uid' => $_SESSION['uid']))->save(array('state' => 1)); $count = $Model->where(array('uid' => $_SESSION['uid']))->count(); $page = new Page($count, 10); $this->data = $Model->where(array('uid' => $_SESSION['uid']))->limit($page->limit())->order("mid DESC")->all(); $this->page = $page->show(); $this->display(); }
public function index() { $where = 'to_uid=' . $_SESSION['uid']; $sql = "SELECT count(distinct from_uid) AS c FROM " . C("DB_PREFIX") . "user_message AS um\n WHERE to_uid=" . $_SESSION['uid'] . " ORDER BY mid DESC"; $count = $this->_db->query($sql); $page = new Page($count[0]['c'], 10); $this->data = $this->_db->where($where)->limit($page->limit())->order("mid DESC")->group('from_uid')->all(); $this->page = $page->show(); $this->count = $count; $this->display(); }
public function index() { $map = "mid={$this->mid} and aid={$this->aid}"; $count = $this->db->where($map)->count(); $page = new Page($count, 10); $data = $this->db->limit($page->limit())->where($map)->order('comment_id DESC')->all(); $this->assign('count', $count); $this->assign('data', $data); $this->assign('page', $page->show()); $this->display(); }
public function content() { if (empty($this->_mid)) { $this->error('mid参数错误'); } $ContentModel = ContentViewModel::getInstance($this->_mid); //文章状态 $state = Q('get.state', 1, 'intval'); $where = array(); $where[] = $ContentModel->tableFull . ".content_state={$state}"; //按时间搜索 $search_begin_time = Q('post.search_begin_time', null, 'strtotime'); if ($search_begin_time) { $where[] = "addtime>={$search_begin_time}"; } //按flag搜索 if ($flag = Q('flag')) { $where[] = "find_in_set('{$flag}',flag)"; } //按字段类型 if (isset($_POST['search_type']) && !empty($_POST['search_type']) && !empty($_POST['search_keyword'])) { $search_keyword = $_POST['search_keyword']; switch (strtolower($_POST['search_type'])) { case 1: //标题 $where[] = "title LIKE '%{$search_keyword}%'"; break; case 2: $where[] = "description LIKE '%{$search_keyword}%'"; //简介 break; case 3: //用户名 $where[] = "username ='******'"; break; case 4: //用户uid $where[] = $ContentModel->tableFull . ".uid ={$search_keyword}"; break; } } $search_end_time = Q('post.search_end_time', null, 'strtotime'); if ($search_end_time) { $where[] = "addtime<={$search_end_time}"; } $where[] = C('DB_PREFIX') . "category.cid=" . $this->_cid; $page = new Page($ContentModel->join('user,category')->where($where)->count(), 15); $data = $ContentModel->join('user,category')->where($where)->limit($page->limit())->order(array("arc_sort" => "ASC", 'aid' => "DESC"))->all(); $this->assign('data', $data); $flagCache = cache($this->_mid, false, FLAG_CACHE_PATH); $this->assign('flag', $flagCache); $this->assign('page', $page->show()); $this->display(); }
public function content() { $ContentModel = ContentViewModel::getInstance($this->mid); $where[] = "category.mid=" . $this->mid; $where[] = 'user.uid=' . $_SESSION['user']['uid']; $page = new Page($ContentModel->where($where)->count(), 10); $data = $ContentModel->where($where)->limit($page->limit())->order('arc_sort ASC,addtime DESC')->all(); $this->assign('data', $data); $this->assign('model', $this->model[$this->mid]); $this->assign('page', $page->show()); $this->display(); }
public function content() { $Model = ContentViewModel::getInstance($this->mid); $count = $Model->where('content_status=0')->count(); $page = new Page($count, 15); $data = $Model->where('content_status=0')->limit($page->limit())->order('updatetime DESC')->all(); $this->assign('data', $data); $this->assign('mid', $this->mid); $this->assign('model', $this->model); $this->assign('page', $page->show()); $this->display(); }
public function index() { if ($wd = Q('post.wd')) { go(addon_url('index', array('wd' => $wd))); } $data = array(); if (!($search_history = cookie('search_history'))) { $search_history = array(); } if ($wd = Q('get.wd')) { $ContentModel = $this->db; $where[] = "category.mid=" . $this->mid; //按Tag搜索 if (Q('type') == 'tag') { //当前Tag文章aid if ($aids = K("ContentTag")->getContentAid($this->mid, $wd)) { $where[] = $ContentModel->table . '.aid IN(' . implode(',', $aids) . ')'; } } else { //按文章标签搜索 $where[] = " title like '%{$wd}%'"; } //搜索时间 if ($time = Q('get.time')) { switch ($time) { case 'day': $where[] = 'addtime>' . (time() - 3600 * 24); break; case 'week': $where[] = 'addtime>' . (time() - 3600 * 24 * 7); break; case 'month': $where[] = 'addtime>' . (time() - 3600 * 24 * 7 * 30); break; case 'year': $where[] = 'addtime>' . (time() - 3600 * 24 * 7 * 30 * 12); break; } } $page = new Page($ContentModel->where($where)->count(), 10); $data = $ContentModel->where($where)->limit($page->limit())->order('arc_sort ASC,addtime DESC')->all(); array_unshift($search_history, $wd); $search_history = array_unique($search_history); $search_history = array_slice($search_history, 0, 8); cookie('search_history', $search_history); } $this->assign('data', $data); $this->assign('search_history', $search_history); $this->assign('model', S('model')); //模型 $this->assign('search_word', cookie('search_word')); $this->display(); }
function show() { $db = M("news"); //分页 //查询总条数 $count = $db->count(); //分页对象 $page = new Page($count, 2); $this->assign("page", $page->show()); $data = $db->where($page->limit())->all(); $this->assign("news", $data); $this->display(); }
public function index(){ $this->setSearchWhere(); $this->setOrder(); $total = $this->db->getGoodsTotal(); $page = new Page($total,5); $data = $this->db->getGoods($page->limit()); $goods = $this->disGoods($data); $this->assign('goods',$goods); $this->assign('page',$page->show()); $this->display(); }
public function index() { $user = M('user')->find($this->uid); $this->assign('user', $user); //记录访客信息 $this->assign('guest', $this->RecordGuest()); //文章 $ContentModel = ContentViewModel::getInstance(1); $where[] = 'user.uid=' . $this->uid; $page = new Page($ContentModel->where($where)->count(), 10); $data = $ContentModel->where($where)->limit($page->limit())->order('arc_sort ASC,addtime DESC')->all(); $this->assign('data', $data); $this->assign('page', $page->show()); $this->display(); }
public function index() { $count = $this->db->count(); $page = new Page($count); $this->page = $page->show(); $upload = $this->db->order("id desc")->limit($page->limit())->all(); if ($upload) { foreach ($upload as $id => $v) { if ($v['image'] == 1 && is_file($v['path'])) { $upload[$id]['pic'] = __ROOT__ . '/' . $v['path']; } else { $upload[$id]['pic'] = __GROUP__ . '/static/img/upload-pic.png'; } } } $this->upload = $upload; $this->display(); }