goods.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <?php
  2. function mymps_get_goods_location($catid = 0, $str = '')
  3. {
  4. global $db;
  5. global $db_mymps;
  6. global $pluginsettings;
  7. global $mymps_global;
  8. $cat_arr = goods_parent_cats($catid);
  9. $raquo = $GLOBALS['mymps_global']['cfg_raquo'];
  10. $location = '当前位置:<a href="' . $mymps_global['SiteUrl'] . '">' . $mymps_global['SiteCity'] . $GLOBALS['mymps_global']['SiteName'] . '</a>' . ' <code>' . $raquo . '</code> ' . ' <a href="' . Rewrite('goods', array('catid' => 0)) . '">' . $city[cityname] . '商品网购</a>';
  11. $page_title = $pluginsettings['goods']['seotitle'] ? $pluginsettings['goods']['seotitle'] : $mymps_global['SiteCity'] . '商品网购-' . $GLOBALS['mymps_global']['SiteName'];
  12. if (!empty($catid)) {
  13. if (!empty($cat_arr)) {
  14. krsort($cat_arr);
  15. foreach ($cat_arr as $val) {
  16. $page_title = $val['catname'] . ' - ' . $page_title;
  17. $location .= ' <code> ' . $raquo . ' </code> <a href="' . $val['uri'] . '">' . $mymps_global['SiteCity'] . $val['catname'] . '</a>';
  18. }
  19. }
  20. }
  21. if (!empty($str)) {
  22. $page_title = $str . '-' . $page_title;
  23. $location .= ' <code>' . $raquo . '</code> &nbsp;' . $str;
  24. }
  25. $cur = array('page_title' => $page_title, 'location' => $location);
  26. unset($page_title);
  27. unset($cat);
  28. unset($location);
  29. unset($type);
  30. unset($goods_class);
  31. return $cur;
  32. }
  33. define('IN_SMT', true);
  34. define('CURSCRIPT', 'goods');
  35. define('IN_MYMPS', true);
  36. define('DIR_NAV', dirname(__FILE__));
  37. require_once DIR_NAV . '/include/global.php';
  38. require_once MYMPS_DATA . '/config.php';
  39. require_once MYMPS_DATA . '/config.db.php';
  40. require_once MYMPS_INC . '/db.class.php';
  41. !ifplugin(CURSCRIPT) && exit('管理员已禁用或未安装商品插件...');
  42. $id = isset($id) ? intval($id) : '';
  43. $catid = isset($catid) ? intval($catid) : 0;
  44. $page = isset($page) ? intval($page) : 1;
  45. $Catid = isset($Catid) ? checkhtml($Catid) : '';
  46. $seo = get_seoset();
  47. $rewrite = $seo['seo_force_goods'];
  48. if ($rewrite != 'active') {
  49. $mayimobile = get_mobile_settings();
  50. $mayimobile['mobiledomain'] = $mayimobile['mobiledomain'] ? $mayimobile['mobiledomain'] : $mymps_global['SiteUrl'] . '/m';
  51. $mayimobile['mobileuri'] = $mayimobile['mobiledomain'] . ($_SERVER['HTTP_X_ORIGINAL_URL'] ? $_SERVER['HTTP_X_ORIGINAL_URL'] : $_SERVER['REQUEST_URI']);
  52. if ($ifmobile) {
  53. write_msg('', $mayimobile['mobileuri']);
  54. exit();
  55. }
  56. }
  57. if ($Catid && $rewrite == 'rewrite') {
  58. $detail = explode('-', $Catid);
  59. if ($detail[0] && in_array($detail[0], array('catid', 'cuxiao', 'tuijian', 'orderby', 'page'))) {
  60. $detail[1] = mhtmlspecialchars($detail[1]);
  61. for ($i = 0; $i < count($detail); $i++) {
  62. $_GET[$detail[$i]] = ${$detail[$i]} = str_replace(array('#@#', '#!#'), array('-', '/'), $detail[++$i]);
  63. }
  64. extract($_GET);
  65. }
  66. $Catid = $detail = NULL;
  67. }
  68. if (!submit_check(CURSCRIPT . '_submit')) {
  69. require_once DIR_NAV . '/plugin/goods/include/functions.php';
  70. if ($id) {
  71. $goods = $db->getRow('SELECT a.*,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\'');
  72. $goods['tname'] = $goods['tname'] ? $goods['tname'] : $goods['userid'];
  73. $uid = $db->getOne('SELECT id FROM `' . $db_mymps . 'member` WHERE userid = \'' . $goods['userid'] . '\'');
  74. $goods['tname_uri'] = Rewrite('store', array('uid' => $uid, 'action' => 'index'));
  75. if (!$goods['goodsid']) {
  76. write_msg('该商品不存在或者已下架!', 'olmsg');
  77. }
  78. $db->query('UPDATE `' . $db_mymps . 'goods` SET hit = hit + 1 WHERE goodsid = \'' . $id . '\'');
  79. $goods['picture'] = $goods['picture'] ? $goods['picture'] : $mymps_global['SiteUrl'] . '/images/nophoto.gif';
  80. $goods['content'] = replace_insidelink($goods['content'], 'goods');
  81. $loc = mymps_get_goods_location($goods['catid'], $goods['goodsname']);
  82. $page_title = $loc['page_title'];
  83. $location = $loc['location'];
  84. $goods['quhuo'] = textarea_post_change($pluginsettings['goods']['quhuo']);
  85. $goods['fukuan'] = textarea_post_change($pluginsettings['goods']['fukuan']);
  86. $goods['service'] = textarea_post_change($pluginsettings['goods']['service']);
  87. unset($pluginsettings);
  88. $advertisement = get_advertisement('other');
  89. $adveritems = $advertisement['items'];
  90. $advertisement = $advertisement['all'];
  91. $relategoods = mymps_get_goods(7, 1, NULL, $goods['catid']);
  92. globalassign();
  93. include mymps_tpl('view');
  94. }
  95. else {
  96. $advertisement = get_advertisement('other');
  97. $adveritems = $advertisement['items'];
  98. $advertisement = $advertisement['all'];
  99. $where = ' WHERE onsale = \'1\'';
  100. if ($catid) {
  101. $catid = intval($catid);
  102. $cat = $db->getRow('SELECT * FROM `' . $db_mymps . 'goods_category` WHERE catid = \'' . $catid . '\'');
  103. if (!$cat) {
  104. $where = NULL;
  105. write_msg('该商品分类不存在或者已删除!', 'olmsg');
  106. exit();
  107. }
  108. $goods_children = mymps_get_goods_children($catid);
  109. $where .= ' AND catid IN (' . $goods_children . ')';
  110. }
  111. $remai_goods = mymps_get_goods(5, 1, 'remai');
  112. $tuijian_goods = mymps_get_goods(4, 1, 'tuijian');
  113. $loc = mymps_get_goods_location($cat['catid']);
  114. $page_title = $loc['page_title'];
  115. $location = $loc['location'];
  116. $keywords = $pluginsettings[CURSCRIPT]['seokeywords'];
  117. $description = $pluginsettings[CURSCRIPT]['seodescription'];
  118. $goods_cat = goods_category_tree(0);
  119. $where .= $tuijian == '1' ? ' AND tuijian = \'1\'' : '';
  120. $where .= $cuxiao == '1' ? ' AND cuxiao = \'1\'' : '';
  121. $orderby = in_array($orderby, array('dateline', 'hit')) ? $orderby : 'dateline';
  122. $rows_num = $db->getOne('SELECT COUNT(goodsid) FROM `' . $db_mymps . 'goods` ' . $where);
  123. $param = setParam(array('catid', 'orderby', 'tuijian', 'cuxiao'), $rewrite, 'goods-');
  124. $goods = page1('SELECT * FROM `' . $db_mymps . 'goods` ' . $where . ' ORDER BY ' . $orderby . ' DESC', $mymps_global['cfg_page_line']);
  125. foreach ($goods as $k => $v) {
  126. $list[$v['goodsid']]['goodsid'] = $v['goodsid'];
  127. $list[$v['goodsid']]['goodsname'] = $v['goodsname'];
  128. $list[$v['goodsid']]['nowprice'] = $v['nowprice'];
  129. $list[$v['goodsid']]['oldprice'] = $v['oldprice'];
  130. $list[$v['goodsid']]['pre_picture'] = $v['pre_picture'] ? $v['pre_picture'] : '/images/nophoto.gif';
  131. $list[$v['goodsid']]['picture'] = $v['picture'] ? $v['picture'] : '/images/nophoto.gif';
  132. $list[$v['goodsid']]['uri'] = Rewrite('goods', array('id' => $v['goodsid']));
  133. }
  134. $page_view = page2($rewrite);
  135. $uri = array();
  136. $uri['tuijian'] = Rewrite('goods', array('catid' => $cat['catid'], 'tuijian' => '1', 'orderby' => $orderby));
  137. $uri['cuxiao'] = Rewrite('goods', array('catid' => $cat['catid'], 'cuxiao' => '1', 'orderby' => $orderby));
  138. $uri['hit'] = Rewrite('goods', array('catid' => $cat['catid'], 'orderby' => 'hit'));
  139. $uri['dateline'] = Rewrite('goods', array('catid' => $cat['catid']));
  140. globalassign();
  141. include mymps_tpl('index');
  142. }
  143. }
  144. else {
  145. $oname = $oname ? mhtmlspecialchars($oname) : '';
  146. $goodsid = isset($goodsid) ? intval($goodsid) : '';
  147. $ordernum = isset($ordernum) ? intval($ordernum) : '';
  148. $qq = isset($qq) ? mhtmlspecialchars($qq) : '';
  149. $tel = isset($tel) ? mhtmlspecialchars($tel) : '';
  150. $mobile = isset($mobile) ? mhtmlspecialchars($mobile) : '';
  151. $ip = GetIP();
  152. $msg = isset($msg) ? textarea_post_change($msg) : '';
  153. $address = isset($address) ? mhtmlspecialchars($address) : '';
  154. $_COOKIE['goodsorder' . $goodsid] == 1 && write_msg('该商品您已经下过订单了,看看别的商品吧...', 'olmsg');
  155. if (empty($goodsid)) {
  156. write_msg('您要购买的商品不存在或已下架!');
  157. }
  158. if (empty($oname)) {
  159. write_msg('您的姓名不能为空!');
  160. }
  161. $db->query('INSERT INTO `' . $db_mymps . 'goods_order` (goodsid,ordernum,oname,qq,tel,mobile,ip,address,msg,dateline) VALUES (\'' . $goodsid . '\',\'' . $ordernum . '\',\'' . $oname . '\',\'' . $qq . '\',\'' . $tel . '\',\'' . $mobile . '\',\'' . $ip . '\',\'' . $address . '\',\'' . $msg . '\',\'' . $timestamp . '\')');
  162. setcookie('goodsorder' . $goodsid, 1, $timestamp + 180, '/');
  163. write_msg('您的订单已提交成功,我们会尽快与您取得联系!<br /><br /><input value="关闭窗口" type="button" onclick=\'parent.closeopendiv()\' style="margin-left:auto;margin-right:auto;" class="blue">', 'olmsg');
  164. }
  165. is_object($db) && $db->Close();
  166. ?>