| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- CURSCRIPT != 'wap' && exit('FORBIDDEN');
- $id = isset($id) ? intval($id) : '';
- $catid = isset($catid) ? intval($catid) : '';
- $page = isset($page) ? intval($page) : 1;
- !ifplugin('goods') && errormsg('管理员已禁用或未安装商品插件...');
- require_once MYMPS_ROOT . '/plugin/goods/include/functions.php';
- $seo = get_seoset();
- $rewrite = $seo['seo_force_goods'];
- if ($Catid && $rewrite == 'rewrite') {
- $detail = explode('-', $Catid);
- if ($detail[0] && in_array($detail[0], array('catid', 'orderby', 'page'))) {
- $detail[1] = mhtmlspecialchars($detail[1]);
- for ($i = 0; $i < count($detail); $i++) {
- $_GET[$detail[$i]] = ${$detail[$i]} = str_replace(array('#@#', '#!#'), array('-', '/'), $detail[++$i]);
- }
- extract($_GET);
- }
- $Catid = $detail = NULL;
- }
- if ($id) {
- if (!($goods = $db->getRow('SELECT a.*,b.id as uid,b.tname FROM ' . $db_mymps . 'goods AS a LEFT JOIN `' . $db_mymps . 'member` AS b ON a.userid = b.userid WHERE goodsid = \'' . $id . '\' AND onsale = \'1\''))) {
- redirectmsg('当前商品不存在或者已经被删除!', '?');
- }
- $db->query('UPDATE `' . $db_mymps . 'goods` SET hit = hit +1 WHERE goodsid = \'' . $id . '\';');
- $goods[tname_uri] = mRewrite('store', array('uid' => $goods[uid]));
- $loc = get_location_m('goods', $goods['catid'], $goods['goodsname']);
- $page_title = $loc['page_title'];
- include mymps_tpl('goods');
- }
- else {
- require_once MYMPS_ROOT . '/plugin/goods/include/functions.php';
- $where = ' WHERE onsale = \'1\' ';
- if ($catid) {
- $catid = intval($catid);
- $cat = $db->getRow('SELECT * FROM `' . $db_mymps . 'goods_category` WHERE catid = \'' . $catid . '\'');
- if (!$cat) {
- $where = NULL;
- errormsg('该商品分类不存在或者已删除!');
- exit();
- }
- $goods_children = mymps_get_goods_children($catid);
- $where .= ' AND catid IN (' . $goods_children . ')';
- }
- $goods_cat = goods_category_tree(0);
- $perpage = $mayimobile['mobiletopicperpage'] ? $mayimobile['mobiletopicperpage'] : 10;
- $param = setparams(array('mod', 'catid'));
- $rows_num = $db->getOne('SELECT COUNT(goodsid) FROM `' . $db_mymps . 'goods` ' . $where);
- $totalpage = ceil($rows_num / $perpage);
- $num = intval($page - 1) * $perpage;
- if ($orderby == 'tuijian') {
- $orderby2 = ' ORDER BY tuijian DESC ';
- }
- else if ($orderby == 'cuxiao') {
- $orderby2 = ' ORDER BY cuxiao DESC ';
- }
- else if ($orderby == 'hit') {
- $orderby2 = ' ORDER BY hit DESC ';
- }
- else {
- $orderby2 = ' ORDER BY goodsid DESC ';
- }
- $orderbyarr = array('tuijian' => '按推荐排序', 'cuxiao' => '按促销排序', 'hit' => '按人气排序');
- $page1 = page1('SELECT * FROM ' . $db_mymps . 'goods ' . $where . ' ' . $orderby2, $perpage);
- foreach ($page1 as $k => $v) {
- $list[$v['goodsid']]['goodsid'] = $v['goodsid'];
- $list[$v['goodsid']]['goodsname'] = $v['goodsname'];
- $list[$v['goodsid']]['goodsnamej'] = $charset == 'gbk' ? iconv('gb2312', 'utf-8', $v['goodsname']) : $v['goodsname'];
- $list[$v['goodsid']]['uri_m'] = mRewrite('goods', array('id' => $v[goodsid]));
- $list[$v['goodsid']]['nowprice'] = $v['nowprice'];
- $list[$v['goodsid']]['oldprice'] = $v['oldprice'];
- $list[$v['goodsid']]['cuxiao'] = $v['cuxiao'];
- $list[$v['goodsid']]['tuijian'] = $v['tuijian'];
- $list[$v['goodsid']]['pre_picture'] = $v['pre_picture'];
- $list[$v['goodsid']]['picture'] = $v['picture'];
- }
- if ($mayi) {
- $list = $list ? $list : NULL;
- $list = 5.4000000000000004 <= PHP_VERSION ? json_encode($list, JSON_UNESCAPED_SLASHES) : str_replace('\\/', '/', json_encode($list));
- echo $list;
- exit();
- }
- $loc = get_location_m('goods', $cat['catid'], $cat['catname']);
- $page_title = $loc['page_title'];
- $keywords = $cat[catname] ? $cat[catname] . '商品展示' : $pluginsettings['goods']['seokeywords'];
- $description = $cat[catname] ? $cat[catname] . '商品展示' : $pluginsettings['goods']['seodescription'];
- include mymps_tpl('goods_list');
- }
- ?>
|