public function index()
 {
     $keywords = isset($_REQUEST['keywords']) && trim($_REQUEST['keywords']) ? trim($_REQUEST['keywords']) : '';
     $keywords = strip_tags(urldecode($keywords));
     $cid = isset($_REQUEST['cid']) ? intval($_REQUEST['cid']) : '';
     $sid = isset($_REQUEST['sid']) ? intval($_REQUEST['sid']) : '';
     $miao_api = $this->miao_client();
     //获取59秒api设置信息
     $page_size = 40;
     if (isset($_GET['p'])) {
         $p = $_GET['p'];
     }
     if (!$p || is_null($p)) {
         $p = 1;
     }
     $data = $miao_api->ListItemsSearch('', $keywords, $cid, $sid, $p, 40);
     $total_results = $data['total_results'];
     //总记录
     $search_list = $data['items_search']['items']['item'];
     if (IsTwoArray($search_list) && count($search_list) > 0) {
         $search_list = array($search_list);
     }
     $item_categories = $data['items_search']['item_categories']['item_category'];
     $search_arr = array();
     if (is_array($search_list)) {
         foreach ($search_list as $val) {
             $val['click_url'] = base64_encode(urlencode($val['click_url']));
             $val['seller_url'] = base64_encode(urlencode($val['seller_url']));
             $val['pic_url'] = str_replace('.jpg', '_210x1000.jpg', $val['pic_url']);
             $search_arr[] = $val;
         }
     }
     //print_r($search_arr);
     import("ORG.Util.Page");
     if ($total_results > 99 * 40) {
         $count = 99 * 40;
     } else {
         $count = $total_results;
     }
     if (count($search_arr) == 0) {
         $search_arr = '';
     }
     $p = new Page($count, $page_size);
     $page = $p->show_1();
     $this->assign('keywords', $keywords);
     $this->assign('page', $page);
     $this->assign('items_list', $search_arr);
     $this->assign('cid', $cid);
     $this->assign('sid', $sid);
     //搜索数据分类
     if (IsTwoArray($item_categories)) {
         $item_categories = array($item_categories);
     }
     $this->assign('item_categories', $item_categories);
     $this->display();
 }
 function get_items_comments($items_id, $pagesize = 8)
 {
     import("ORG.Util.Page");
     $mod = D('items_comments');
     $where = "items_id={$items_id}";
     $count = $mod->where($where)->count();
     $p = new Page($count, $pagesize);
     $list = $mod->relation('user')->where($where)->order("id desc")->limit($p->firstRow . ',' . $p->listRows)->select();
     return array('list' => $list, 'page' => $p->show_1(), 'count' => $count);
 }
Example #3
0
 public function tag()
 {
     $tag_name = isset($_GET['tag']) && trim($_GET['tag']) ? trim(urldecode($_GET['tag'])) : '';
     $p = !empty($_GET['p']) ? intval($_GET['p']) : 1;
     $sp = !empty($_GET['sp']) ? intval($_GET['sp']) : 1;
     $sp > 5 && exit;
     $list_rows = 200;
     $s_list_rows = 40;
     $show_sp = 0;
     $items_mod = D('items');
     $items_cate_mod = D('items_cate');
     $items_tags_mod = D('items_tags');
     import("ORG.Util.Page");
     $sql_where = "1=1";
     if ($tag_name) {
         $tag = $items_tags_mod->where("name='" . $tag_name . "'")->find();
         $sql_where = 'iti.tag_id=' . $tag['id'];
         $this->assign('tag', $tag);
         $this->seo['seo_title'] = !empty($tag['seo_title']) ? $tag['seo_title'] : $tag['name'];
         $this->seo['seo_title'] = $this->seo['seo_title'] . ' - ' . $this->setting['site_name'];
         $this->seo['seo_keys'] = !empty($tag['seo_keys']) ? $tag['seo_keys'] : $tag['name'];
         !empty($cate_info['seo_desc']) && ($this->seo['seo_desc'] = $cate_info['seo_desc']);
     }
     //先计算大的分页
     $count = $items_mod->join("LEFT JOIN " . C('DB_PREFIX') . "items_tags_item as iti ON iti.item_id=" . C('DB_PREFIX') . "items.id")->where($sql_where)->count();
     $count > $s_list_rows && ($show_sp = 1);
     $pager = new Page($count, $list_rows);
     $page = $pager->show_1();
     $first_row = $pager->firstRow + $s_list_rows * ($sp - 1);
     $items_list = $items_mod->relation('items_site')->join("LEFT JOIN " . C('DB_PREFIX') . "items_tags_item as iti ON iti.item_id=" . C('DB_PREFIX') . "items.id")->where($sql_where)->limit($first_row . ',' . $s_list_rows)->order('add_time DESC')->select();
     $this->assign('page', $page);
     $this->assign('p', $p);
     $this->assign('show_sp', $show_sp);
     $this->assign('sp', $sp);
     $this->assign('items_list', $items_list);
     //大分类
     $pcate = $items_cate_mod->where('pid=0')->select();
     $this->assign('pcate', $pcate);
     $this->assign('seo', $this->seo);
     $this->display();
 }
 public function tag()
 {
     $tag_id = isset($_GET['id']) && intval($_GET['id']) ? intval($_GET['id']) : exit;
     $p = !empty($_GET['p']) ? intval($_GET['p']) : 1;
     $sp = !empty($_GET['sp']) ? intval($_GET['sp']) : 1;
     $sp > 5 && exit;
     $list_rows = 200;
     $s_list_rows = 12;
     $show_sp = 0;
     $items_mod = D('items');
     $items_cate_mod = D('items_cate');
     $items_tags_mod = D('items_tags');
     import("ORG.Util.Page");
     $sql_where = '1=1';
     if ($tag_id) {
         $tag = $items_tags_mod->field('id,name')->where("id='" . $tag_id . "'")->find();
         $sql_where = 'iti.tag_id=' . $tag['id'] . ' AND ' . C('DB_PREFIX') . 'items.status=1';
         $this->assign('tag', $tag);
         $this->seo['seo_title'] = !empty($tag['seo_title']) ? $tag['seo_title'] : $tag['name'];
         $this->seo['seo_title'] = $this->seo['seo_title'] . ' - ' . $this->setting['site_name'];
         $this->seo['seo_keys'] = !empty($tag['seo_keys']) ? $tag['seo_keys'] : $tag['name'];
         !empty($tag['seo_desc']) && ($this->seo['seo_desc'] = $tag['seo_desc']);
     }
     //先计算大的分页
     $count = $items_mod->join("LEFT JOIN " . C('DB_PREFIX') . "items_tags_item as iti ON iti.item_id=" . C('DB_PREFIX') . "items.id")->where($sql_where)->count();
     $count > $s_list_rows && ($show_sp = 1);
     $pager = new Page($count, $list_rows);
     $page = $pager->show_1();
     $first_row = $pager->firstRow + $s_list_rows * ($sp - 1);
     $items_list = $items_mod->field('id,title,img,price,likes,comments,seller_name,cash_back_rate')->relation('items_site')->join("LEFT JOIN " . C('DB_PREFIX') . "items_tags_item as iti ON iti.item_id=" . C('DB_PREFIX') . "items.id")->where($sql_where)->limit($first_row . ',' . $s_list_rows)->order('add_time DESC')->select();
     foreach ($items_list as $key => $val) {
         //获取最新的三条评论
         $items_list[$key]['three_comments'] = $this->user_comments_mod->where('pid=' . $val['id'] . ' and status=1')->order("add_time DESC")->limit("0,3")->relation(true)->select();
         //获取三条喜欢此宝贝的人
         $like['items_id'] = $val['id'];
         $items_list[$key]['likelist'] = $this->like_list_mod->where($like)->order('id desc')->limit(3)->select();
         $items_list[$key]['count'] = $this->like_list_mod->where($like)->count();
     }
     $this->assign('page', $page);
     $this->assign('p', $p);
     $this->assign('show_sp', $show_sp);
     $this->assign('sp', $sp);
     $this->assign('items_list', $items_list);
     //大分类
     $pcate = $items_cate_mod->where('pid=0')->select();
     $this->assign('pcate', $pcate);
     $this->assign('seo', $this->seo);
     $this->display();
 }
 function comments()
 {
     import("ORG.Util.Page");
     $user_comments_mod = D('user_comments');
     $act = $_REQUEST['act'];
     $type = $_REQUEST['type'];
     $pid = empty($_REQUEST['pid']) ? 0 : intval($_REQUEST['pid']);
     if ($act == 'add') {
         if (empty($_COOKIE['user']['id'])) {
             exit;
         }
         $data = $user_comments_mod->create();
         $replace = str_replace("\n", " ", $data['info']);
         $data['info'] = htmlspecialchars(ReplaceKeywords($replace));
         $data['add_time'] = time();
         $data['uid'] = $_COOKIE['user']['id'];
         $data['uname'] = $_COOKIE['user']['name'];
         $user_comments_mod->add($data);
         if ($data['type'] == 'item,index') {
             $arr = array('id' => $data['pid'], 'comments' => $this->user_comments_mod->where('pid=' . $data['pid'] . ' and type="item,index"')->count());
             $this->items_mod->save($arr);
         }
         return;
     }
     $where = "type='" . $_REQUEST['type'] . "' and pid={$pid} and status=1";
     $count = $user_comments_mod->where($where)->count();
     $p = new Page($count, 8);
     $list = $user_comments_mod->where($where)->relation('user')->where($where)->order("id desc")->limit($p->firstRow . ',' . $p->listRows)->select();
     $this->assign('comments', array('list' => $list, 'page' => $p->show_1(), 'count' => $count, 'type' => $type));
     if ($this->isAjax()) {
         $this->ajaxReturn(array('list' => $this->fetch('comments_list'), 'count' => $count));
     }
 }
Example #6
0
 function album()
 {
     $this->uc_login_check();
     $user_mod = D('user');
     $items_mod = D("items");
     $album_mod = D('album');
     $album_items_mod = D('album_items');
     $user_follow_mod = D('user_follow');
     $type = empty($_REQUEST['type']) ? 'index' : $_REQUEST['type'];
     $this->assign('type', $type);
     import("ORG.Util.Page");
     if ($type == 'follow') {
         $res = $user_follow_mod->where("uid=" . $this->uid)->select();
         foreach ($res as $key => $val) {
             $ids[] = $val['fans_id'];
         }
         $where = "status='1' and uid in(" . implode(',', $ids) . ")";
     } else {
         $where = "status='1' and uid=" . $this->uid;
     }
     $count = $album_mod->where($where)->count();
     $p = new Page($count, 10);
     $res = $album_mod->where($where)->limit($p->firstRow . ',' . $p->listRows)->order("id desc")->select();
     foreach ($res as $key => $val) {
         $res2 = $album_items_mod->where("pid=" . $val['id'])->order("id desc")->limit("8")->select();
         $items = array();
         $like_num = 0;
         $comment_num = 0;
         foreach ($res2 as $key2 => $val2) {
             $img = $items_mod->field("likes,simg,img")->where("id=" . $val2['items_id'])->find();
             $items[] = $img['img'];
             $like_num = $like_num + $img['likes'];
             $comment_num = $comment_num + $this->user_comments_mod->where('pid=' . $val2['items_id'] . ' and type="item,index"')->count();
         }
         $total_num = intval(8 - count($items));
         for ($num = 0; $num < $total_num; $num++) {
             $items[] = $this->site_root . "data/none_pic_v3.png";
         }
         $res[$key]['items'] = $items;
         $res[$key]['like_num'] = $like_num;
         $res[$key]['comment_num'] = $comment_num;
         $res[$key]['user'] = $user_mod->where('id=' . $val['uid'])->find();
     }
     $this->assign('album_list', $res);
     $this->assign('page', $p->show_1());
     $this->display();
 }
 public function index()
 {
     $id = isset($_GET['id']) && intval($_GET['id']) ? intval($_GET['id']) : $this->error("404");
     $this->assign('items_id', $id);
     $items_mod = D('items');
     //增加浏览次数
     $items_mod->where("id='{$id}'")->setInc('browse_num', 1);
     $items_cate_mod = D('items_cate');
     $items_like_list = M("like_list");
     //喜欢此宝贝的人
     if (!empty($id)) {
         $like['items_id'] = $id;
         $likelist = $items_like_list->where($like)->limit(10)->select();
         $this->assign("likelist", $likelist);
     }
     $item = $items_mod->field('id,uid,cid,sid,item_key,title,bimg,price,likes,comments,browse_num,add_time,cash_back_rate,seller_name')->where("id=" . $id)->find();
     //获取此商品对应的商家logo
     $seller_list = D('seller_list');
     $seller_rel = $seller_list->field('sid,net_logo,name')->where("name='{$item['seller_name']}'")->find();
     //print_r($seller_rel);
     if ($seller_rel) {
         $this->assign('seller_logo', $seller_rel['net_logo']);
     }
     if ($item['sid'] == 2) {
         $iid = substr($item['item_key'], 5);
         //用于判断此商品是否存在,如果不存在执行下架操作 59秒的
     } else {
         $iid = substr($item['item_key'], 7);
         //用于判断此商品是否存在,如果不存在执行下架操作        淘宝的
     }
     $this->assign('iid', $iid);
     $this->assign('sid', $item['sid']);
     $sids = $seller_rel['sid'];
     //动态广告系统
     $miao_api = $this->miao_client();
     //获取59秒api设置信息
     $adv_data = $miao_api->AdsGet($sids, '250x250');
     $ad_rel = $adv_data['ads']['ad'];
     $num = count($ad_rel);
     $i = rand(0, $num - 1);
     if (count($ad_rel) > 0) {
         $this->assign('ad_rel', $ad_rel[$i]);
     }
     //动态广告结束
     $item['items_cate'] = $items_mod->relationGet("items_cate");
     $item['items_site'] = $items_mod->relationGet("items_site");
     $item['items_tags'] = $items_mod->relationGet("items_tags");
     $tag_str = '';
     foreach ($item['items_tags'] as $tag) {
         $tag_str .= $tag['name'] . ' ';
     }
     $this->seo['seo_title'] = !empty($item['seo_title']) ? $item['seo_title'] : $item['title'];
     $this->seo['seo_title'] = $this->seo['seo_title'] . ' - ' . $this->setting['site_name'];
     $this->seo['seo_keys'] = !empty($item['seo_keys']) ? $item['seo_keys'] : $tag_str;
     $item['seo_desc'] && ($this->seo['seo_desc'] = $item['seo_desc']);
     //比如这个商品时女装下面的,则获取父类是女装的商品分类
     $siblings_cate_group = $items_cate_mod->field('id,name,item_nums')->where("pid=" . $item['items_cate']['pid'] . " AND is_hots=1")->limit('0,4')->order("status DESC,ordid DESC")->select();
     foreach ($siblings_cate_group as $key => $val) {
         $siblings_cate_group[$key]['items'] = $this->get_group_items($val['id']);
     }
     //获取对应api商家下面的相关数据
     $items_list = $items_mod->field('id,title,sid,img,price,likes,comments,seller_name,cash_back_rate')->relation('items_site')->where('cid=' . $item['cid'])->limit('0,20')->select();
     //同类商品
     foreach ($items_list as $key => $val) {
         //获取最新的三条评论
         $items_list[$key]['three_comments'] = $this->user_comments_mod->where('pid=' . $val['id'] . ' and status=1')->order("add_time DESC")->limit("0,3")->relation(true)->select();
         //获取三条喜欢此宝贝的人
         $like['items_id'] = $val['id'];
         $items_list[$key]['likelist'] = $this->like_list_mod->where($like)->order('id desc')->limit(3)->select();
         $items_list[$key]['count'] = $this->like_list_mod->where($like)->count();
     }
     $this_cate_group = $this->get_group_items($item['cid']);
     //所在分类展示
     $source_group = $this->get_group_items_bysource($item['sid']);
     //相同来源展示
     $items_mod->where('id=' . $id)->setInc('hits');
     //浏览次
     //判断来源,执行不同的跳转
     if ($item['sid'] == 1) {
         $this->assign('site', 'tao');
     } else {
         if ($item['sid'] == 2) {
             $this->assign('site', 'b2c');
         }
     }
     import("ORG.Util.Page");
     $user_comments_mod = D('user_comments');
     $act = $_REQUEST['act'];
     $type = MODULE_NAME . ',' . ACTION_NAME;
     $pid = empty($_REQUEST['id']) ? 0 : intval($_REQUEST['id']);
     $where = "type='" . $type . "' and pid={$pid} and status=1";
     $count = $user_comments_mod->where($where)->count();
     $p = new Page($count, 8);
     $list = $user_comments_mod->where($where)->relation('user')->where($where)->order("id desc")->limit($p->firstRow . ',' . $p->listRows)->select();
     $this->assign('comments', array('list' => $list, 'page' => $p->show_1(), 'count' => $count));
     if ($this->isAjax()) {
         $this->ajaxReturn(array('list' => $this->fetch('uc:comments_list'), 'count' => $count));
     }
     //$this->assign('seo', $this->seo);
     $this->nav_seo('item', 'items', $_GET['id'], $item['items_tags']);
     $this->assign('item', $item);
     $this->assign('items_list', $items_list);
     $this->assign('siblings_cate_group', $siblings_cate_group);
     $this->assign('this_cate_group', $this_cate_group);
     $this->assign('source_group', $source_group);
     $this->display();
     //保存商品图片
     //此方法有问题
     //        if($this->setting['goods_save_images'] &&$item['sid']==2&& !isImages($item['id'])){
     //            calculation($item["bimg"],ROOT_PATH."/data/items/{$item['id']}/",array('64','210','450'));
     //        }
 }
Example #8
0
 function get_album_list($where, $img_num = 9)
 {
     import("ORG.Util.Page");
     $album_mod = D("album");
     $album_items_mod = D('album_items');
     $items_mod = D("items");
     $items_comments_mod = D("items_comments");
     $items_mod = D("items");
     $p = !empty($_GET['p']) ? intval($_GET['p']) : 1;
     $count = $album_mod->where($where)->count();
     $pager = new Page($count, 20);
     $res = $album_mod->where($where)->limit($pager->firstRow . ',' . $pager->listRows)->order("sort_order desc")->select();
     foreach ($res as $key => $val) {
         $res[$key]['items_num'] = $album_items_mod->where("pid=" . $val['id'])->count();
         $res2 = $album_items_mod->where("pid=" . $val['id'])->order("id desc")->limit("0," . $img_num)->select();
         $items = array();
         $like_num = 0;
         $comment_num = 0;
         foreach ($res2 as $key2 => $val2) {
             $img = $items_mod->field("likes,simg")->where("id=" . $val2['items_id'])->find();
             $items[] = $img['simg'];
             $like_num = $like_num + $img['likes'];
             $comment_num = $comment_num + $items_comments_mod->where('items_id=' . $val2['items_id'])->count();
         }
         $total_num = intval(9 - count($items));
         for ($num = 0; $num < $total_num; $num++) {
             $items[] = $this->site_root . "data/none_pic_v3.png";
         }
         $res[$key]['items'] = $items;
         $res[$key]['like_num'] = $like_num;
         $res[$key]['comment_num'] = $comment_num;
     }
     $this->assign('page', $pager->show_1());
     $this->assign('p', $p);
     $this->assign('album_list', $res);
     $this->display();
 }
 function nocidwaterfall($count, $where, $order = "")
 {
     import("ORG.Util.Page");
     $items_mod = D("items");
     $p = !empty($_GET['p']) ? intval($_GET['p']) : 1;
     $sp = !empty($_GET['sp']) ? intval($_GET['sp']) : 1;
     $sp > $this->setting['waterfall_sp'] && exit;
     $list_rows = $this->setting['waterfall_sp'] * $this->setting['waterfall_items_num'];
     $s_list_rows = $this->setting['waterfall_items_num'];
     $show_sp = 0;
     $count > $s_list_rows && ($show_sp = 1);
     $pager = new Page($count, $list_rows);
     $first_row = $pager->firstRow + $s_list_rows * ($sp - 1);
     $items_list = $items_mod->relation(true)->where($where)->limit($first_row . ',' . $s_list_rows)->order($order)->select();
     //print_r($items_list);
     //获取评论数
     foreach ($items_list as $key => $val) {
         $items_list[$key]['comments_num'] = $this->items_comments_mod->where('items_id=' . $val['id'] . ' and status=1')->count();
         //获取最新的三条评论
         $items_list[$key]['three_comments'] = $this->user_comments_mod->where('pid=' . $val['id'] . ' and status=1')->order("add_time DESC")->limit("0,3")->relation(true)->select();
         //获取三条喜欢此宝贝的人
         $like['items_id'] = $val['id'];
         $items_list[$key]['likelist'] = $this->like_list_mod->where($like)->order('id desc')->limit(3)->select();
         $items_list[$key]['count'] = $this->like_list_mod->where($like)->count();
     }
     //print_r($items_list);
     //获取最新的三条评论
     $this->assign('page', $pager->show_1());
     $this->assign('p', $p);
     $this->assign('show_sp', $show_sp);
     $this->assign('sp', $sp);
     $this->assign('items_list', $items_list);
     if ($this->isAjax() && $sp > 1) {
         header('Content-Type:text/html; charset=utf-8');
         echo $this->fetch('public:nocid_goods_list');
     } else {
         $this->display();
     }
 }