inc_goods.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. CURSCRIPT != 'wap' && exit('FORBIDDEN');
  3. $id = isset($id) ? intval($id) : '';
  4. $catid = isset($catid) ? intval($catid) : '';
  5. $page = isset($page) ? intval($page) : 1;
  6. !ifplugin('goods') && errormsg('管理员已禁用或未安装商品插件...');
  7. require_once MYMPS_ROOT . '/plugin/goods/include/functions.php';
  8. $seo = get_seoset();
  9. $rewrite = $seo['seo_force_goods'];
  10. if ($Catid && $rewrite == 'rewrite') {
  11. $detail = explode('-', $Catid);
  12. if ($detail[0] && in_array($detail[0], array('catid', 'orderby', 'page'))) {
  13. $detail[1] = mhtmlspecialchars($detail[1]);
  14. for ($i = 0; $i < count($detail); $i++) {
  15. $_GET[$detail[$i]] = ${$detail[$i]} = str_replace(array('#@#', '#!#'), array('-', '/'), $detail[++$i]);
  16. }
  17. extract($_GET);
  18. }
  19. $Catid = $detail = NULL;
  20. }
  21. if ($id) {
  22. 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\''))) {
  23. redirectmsg('当前商品不存在或者已经被删除!', '?');
  24. }
  25. $db->query('UPDATE `' . $db_mymps . 'goods` SET hit = hit +1 WHERE goodsid = \'' . $id . '\';');
  26. $goods[tname_uri] = mRewrite('store', array('uid' => $goods[uid]));
  27. $loc = get_location_m('goods', $goods['catid'], $goods['goodsname']);
  28. $page_title = $loc['page_title'];
  29. include mymps_tpl('goods');
  30. }
  31. else {
  32. require_once MYMPS_ROOT . '/plugin/goods/include/functions.php';
  33. $where = ' WHERE onsale = \'1\' ';
  34. if ($catid) {
  35. $catid = intval($catid);
  36. $cat = $db->getRow('SELECT * FROM `' . $db_mymps . 'goods_category` WHERE catid = \'' . $catid . '\'');
  37. if (!$cat) {
  38. $where = NULL;
  39. errormsg('该商品分类不存在或者已删除!');
  40. exit();
  41. }
  42. $goods_children = mymps_get_goods_children($catid);
  43. $where .= ' AND catid IN (' . $goods_children . ')';
  44. }
  45. $goods_cat = goods_category_tree(0);
  46. $perpage = $mayimobile['mobiletopicperpage'] ? $mayimobile['mobiletopicperpage'] : 10;
  47. $param = setparams(array('mod', 'catid'));
  48. $rows_num = $db->getOne('SELECT COUNT(goodsid) FROM `' . $db_mymps . 'goods` ' . $where);
  49. $totalpage = ceil($rows_num / $perpage);
  50. $num = intval($page - 1) * $perpage;
  51. if ($orderby == 'tuijian') {
  52. $orderby2 = ' ORDER BY tuijian DESC ';
  53. }
  54. else if ($orderby == 'cuxiao') {
  55. $orderby2 = ' ORDER BY cuxiao DESC ';
  56. }
  57. else if ($orderby == 'hit') {
  58. $orderby2 = ' ORDER BY hit DESC ';
  59. }
  60. else {
  61. $orderby2 = ' ORDER BY goodsid DESC ';
  62. }
  63. $orderbyarr = array('tuijian' => '按推荐排序', 'cuxiao' => '按促销排序', 'hit' => '按人气排序');
  64. $page1 = page1('SELECT * FROM ' . $db_mymps . 'goods ' . $where . ' ' . $orderby2, $perpage);
  65. foreach ($page1 as $k => $v) {
  66. $list[$v['goodsid']]['goodsid'] = $v['goodsid'];
  67. $list[$v['goodsid']]['goodsname'] = $v['goodsname'];
  68. $list[$v['goodsid']]['goodsnamej'] = $charset == 'gbk' ? iconv('gb2312', 'utf-8', $v['goodsname']) : $v['goodsname'];
  69. $list[$v['goodsid']]['uri_m'] = mRewrite('goods', array('id' => $v[goodsid]));
  70. $list[$v['goodsid']]['nowprice'] = $v['nowprice'];
  71. $list[$v['goodsid']]['oldprice'] = $v['oldprice'];
  72. $list[$v['goodsid']]['cuxiao'] = $v['cuxiao'];
  73. $list[$v['goodsid']]['tuijian'] = $v['tuijian'];
  74. $list[$v['goodsid']]['pre_picture'] = $v['pre_picture'];
  75. $list[$v['goodsid']]['picture'] = $v['picture'];
  76. }
  77. if ($mayi) {
  78. $list = $list ? $list : NULL;
  79. $list = 5.4000000000000004 <= PHP_VERSION ? json_encode($list, JSON_UNESCAPED_SLASHES) : str_replace('\\/', '/', json_encode($list));
  80. echo $list;
  81. exit();
  82. }
  83. $loc = get_location_m('goods', $cat['catid'], $cat['catname']);
  84. $page_title = $loc['page_title'];
  85. $keywords = $cat[catname] ? $cat[catname] . '商品展示' : $pluginsettings['goods']['seokeywords'];
  86. $description = $cat[catname] ? $cat[catname] . '商品展示' : $pluginsettings['goods']['seodescription'];
  87. include mymps_tpl('goods_list');
  88. }
  89. ?>