wangtengyu
2018-12-07 f459412e0dac4ed94106da043b4c6f8576bfe496
commit | author | age
3e083b 1 <?php 
B 2
3 define('IN_ECS',true); 
4 require(dirname(__FILE__) .'/includes/init.php'); 
5 if ((DEBUG_MODE &2) != 2) 
6
7 $smarty->caching = true; 
8
9
10 if ( $_REQUEST['action_comm'] == 'save') 
11
12 $goods_id = $_REQUEST['id']; 
13 $cmt_type = $_REQUEST['cmt_type']; 
14 $status = 1 -$GLOBALS['_CFG']['comment_check']; 
15 $user_id = empty($_SESSION['user_id']) ?0 : $_SESSION['user_id']; 
16 $user_name = empty($cmt->username) ?$_SESSION['user_name'] : trim($cmt->username);
17  $user_name = htmlspecialchars($user_name); 
18 $title =  $_POST['comment_title'] ?$_POST['comment_title'] : ''; 
19 $content =  $_POST['content'] ; 
20 $rank =  $_POST['comment_rank']; 
21 $sql = "INSERT INTO ".$GLOBALS['ecs']->table('comment') . 
22 "(comment_type, id_value, email, user_name, title, content, comment_rank, add_time, ip_address, status, parent_id, user_id) VALUES ".
23  "('".$cmt_type."', '".$goods_id."', '', '$user_name', '$title', '".$content."', '".$rank."', ".gmtime().", '".real_ip()."', '$status', '0', '$user_id')";
24  $GLOBALS['db']->query($sql); 
25 $cmid = $GLOBALS['db']->insert_id(); 
26 clear_cache_files(); 
27 $Loaction = 'goods.php?id='.$goods_id ; 
28 ecs_header("Location: $Loaction\n"); 
29
30 $act = !empty($_GET['act']) ?$_GET['act'] : ''; 
31 if ($act == 'cat_rec') 
32
33 $rec_array = array(1 =>'best',2 =>'new',3 =>'hot'); 
34 $rec_type = !empty($_REQUEST['rec_type']) ?intval($_REQUEST['rec_type']) : '1'; 
35 $cat_id = !empty($_REQUEST['cid']) ?intval($_REQUEST['cid']) : '0'; 
36 include_once('includes/cls_json.php'); 
37 $json = new JSON; 
38 $result   = array('error'=>0,'content'=>'','type'=>$rec_type,'cat_id'=>$cat_id);
39  $children = get_children($cat_id); 
40 $smarty->assign($rec_array[$rec_type] .'_goods',get_category_recommend_goods($rec_array[$rec_type],$children));
41  $smarty->assign('cat_rec_sign',1); 
42 $result['content'] = $smarty->fetch('library/recommend_'.$rec_array[$rec_type] .'.lbi');
43  die($json->encode($result)); 
44
45 $cache_id = sprintf('%X',crc32($_SESSION['user_rank'] .'-'.$_CFG['lang'])); 
46 if (true) 
47
48 $goods_id = isset($_REQUEST['id'])  ?intval($_REQUEST['id']) : 0; 
49 assign_template(); 
50 $smarty->assign('id',$goods_id); 
51 $smarty->assign('type',0); 
52 $smarty->assign('keywords',htmlspecialchars($_CFG['shop_keywords'])); 
53 $smarty->assign('description',htmlspecialchars($_CFG['shop_desc'])); 
54 $smarty->assign('flash_theme',$_CFG['flash_theme']); 
55 $smarty->assign('feed_url',($_CFG['rewrite'] == 1) ?'feed.xml': 'feed.php'); 
56 $smarty->assign('categories',get_categories_tree()); 
57 $smarty->assign('helps',get_shop_help()); 
58 $smarty->assign('top_goods',get_top10()); 
59 $smarty->assign('best_goods',get_recommend_goods('best')); 
60 $smarty->assign('new_goods',get_recommend_goods('new')); 
61 $smarty->assign('hot_goods',get_recommend_goods('hot')); 
62 $smarty->assign('promotion_goods',get_promote_goods()); 
63 $smarty->assign('brand_list',get_brands()); 
64 $smarty->assign('promotion_info',get_promotion_info()); 
65 $smarty->assign('shop_notice',$_CFG['shop_notice']); 
66 $smarty->assign('index_ad',$_CFG['index_ad']); 
67 if ($_CFG['index_ad'] == 'cus') 
68
69 $sql = 'SELECT ad_type, content, url FROM '.$ecs->table("ad_custom") .' WHERE ad_status = 1';
70  $ad = $db->getRow($sql,true); 
71 $smarty->assign('ad',$ad); 
72
73 $links = index_get_links(); 
74 $smarty->assign('img_links',$links['img']); 
75 $smarty->assign('txt_links',$links['txt']); 
76 $smarty->assign('data_dir',DATA_DIR); 
77 $cat_recommend_res = $db->getAll("SELECT c.cat_id, c.cat_name, cr.recommend_type FROM ".$ecs->table("cat_recommend") ." AS cr INNER JOIN ".$ecs->table("category") ." AS c ON cr.cat_id=c.cat_id");
78  if (!empty($cat_recommend_res)) 
79
80 $cat_rec_array = array(); 
81 foreach($cat_recommend_res as $cat_recommend_data) 
82
83 $cat_rec[$cat_recommend_data['recommend_type']][] = array('cat_id'=>$cat_recommend_data['cat_id'],'cat_name'=>$cat_recommend_data['cat_name']);
84  } 
85 $smarty->assign('cat_rec',$cat_rec); 
86
87 $sql="select * from ".$GLOBALS['ecs']->table("comment")." where comment_id='$_REQUEST[cmid]' ";
88  $comment_con=$db->getRow($sql); 
89 if($comment_con) 
90
91 $comment_con['add_time']= local_date($GLOBALS['_CFG']['time_format'],$comment_con['add_time']);
92  } 
93 $smarty->assign('comment_con',$comment_con); 
94 assign_dynamic('index'); 
95
96 $position = assign_ur_here($goods['cat_id'],$goods['goods_name']); 
97 $smarty->assign('page_title',$position['title']); 
98 $smarty->assign('ur_here',$position['ur_here']); 
99 $sql = 'SELECT * from '.$GLOBALS['ecs']->table('goods')." where goods_id='$goods_id'";
100  $row = $GLOBALS['db']->getRow($sql); 
101 $smarty->assign('bought_goods',get_also_bought($goods_id)); 
102 $row['goods_nameon']= str_replace("¡¿","",$row['goods_nameon']); 
103 $row['goods_nameon']= str_replace("¡¾","",$row['goods_nameon']); 
104 $smarty->assign('goods',$row); 
105 $smarty->display('comment_add.dwt'); 
106 function index_get_links() 
107
108 $sql = 'SELECT link_logo, link_name, link_url FROM '.$GLOBALS['ecs']->table('friend_link') .' ORDER BY show_order';
109  $res = $GLOBALS['db']->getAll($sql); 
110 $links['img'] = $links['txt'] = array(); 
111 foreach ($res AS $row) 
112
113 if (!empty($row['link_logo'])) 
114
115 $links['img'][] = array('name'=>$row['link_name'], 
116 'url'=>$row['link_url'], 
117 'logo'=>$row['link_logo']); 
118
119 else 
120
121 $links['txt'][] = array('name'=>$row['link_name'], 
122 'url'=>$row['link_url']); 
123
124
125 return $links; 
126
127 function get_promote_goods_pro($cat_id = array(0)) 
128
129 for( $i=0;$i<count($cat_id);$i++) { 
130 if( $i<count($cat_id)-1 ) { 
131 $search .=  get_children($cat_id[$i]) ."OR ".get_extension_goods(get_children($cat_id[$i])) .' OR ';
132  } 
133 else { 
134 $search .=  get_children($cat_id[$i]) ."OR ".get_extension_goods(get_children($cat_id[$i]));
135  } 
136
137 $time = gmtime(); 
138 $order_type = $GLOBALS['_CFG']['recommend_order']; 
139 $num = 12; 
140 $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, '.
141  "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ". 
142 "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, b.brand_name, ".
143  "g.is_best, g.is_new, g.is_hot, g.is_promote, RAND() AS rnd ". 
144 'FROM '.$GLOBALS['ecs']->table('goods') .' AS g '. 
145 'LEFT JOIN '.$GLOBALS['ecs']->table('brand') .' AS b ON b.brand_id = g.brand_id '.
146  "LEFT JOIN ".$GLOBALS['ecs']->table('member_price') ." AS mp ". 
147 "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ". 
148 'WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 '. 
149 " AND g.is_promote = 1 AND promote_start_date <= '$time' AND promote_end_date >= '$time'".
150  "AND (".$search .") "; 
151 $sql .= $order_type == 0 ?' ORDER BY g.sort_order, g.last_update DESC': ' ORDER BY rnd';
152  $sql .= " LIMIT $num "; 
153 $result = $GLOBALS['db']->getAll($sql); 
154 $goods = array(); 
155 foreach ($result AS $idx =>$row) 
156
157 if ($row['promote_price'] >0) 
158
159 $promote_price = bargain_price($row['promote_price'],$row['promote_start_date'],$row['promote_end_date']);
160  $goods[$idx]['promote_price'] = $promote_price >0 ?price_format($promote_price) : '';
161  } 
162 else 
163
164 $goods[$idx]['promote_price'] = ''; 
165
166 $goods[$idx]['id']           = $row['goods_id']; 
167 $goods[$idx]['name']         = $row['goods_name']; 
168 $goods[$idx]['brief']        = $row['goods_brief']; 
169 $goods[$idx]['brand_name']   = $row['brand_name']; 
170 $goods[$idx]['goods_style_name']   = add_style($row['goods_name'],$row['goods_name_style']);
171  $goods[$idx]['short_name']   = $GLOBALS['_CFG']['goods_name_length'] >0 ?sub_str($row['goods_name'],$GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
172  $goods[$idx]['short_style_name']   = add_style($goods[$idx]['short_name'],$row['goods_name_style']);
173  $goods[$idx]['market_price'] = price_format($row['market_price']); 
174 $goods[$idx]['shop_price']   = price_format($row['shop_price']); 
175 $goods[$idx]['thumb']        = get_image_path($row['goods_id'],$row['goods_thumb'],true);
176  $goods[$idx]['goods_img']    = get_image_path($row['goods_id'],$row['goods_img']);
177  $goods[$idx]['url']          = build_uri('goods',array('gid'=>$row['goods_id']),$row['goods_name']);
178  $time = gmtime(); 
179 if ($time >= $row['promote_start_date'] &&$time <= $row['promote_end_date']) 
180
181 $goods[$idx]['gmt_end_time']  = local_date('M d, Y H:i:s',$row['promote_end_date']);
182  } 
183 else 
184
185 $goods[$idx]['gmt_end_time'] = 0; 
186
187
188 return $goods; 
189
190 function get_also_bought($goods_id) 
191
192 $sql = 'SELECT COUNT(b.goods_id ) AS num, g.goods_id, g.goods_name, g.goods_brief, g.goods_thumb, g.goods_img, g.shop_price, g.promote_price, g.promote_start_date, g.promote_end_date '.
193  'FROM '.$GLOBALS['ecs']->table('order_goods') .' AS a '. 
194 'LEFT JOIN '.$GLOBALS['ecs']->table('order_goods') .' AS b ON b.order_id = a.order_id '.
195  'LEFT JOIN '.$GLOBALS['ecs']->table('goods') .' AS g ON g.goods_id = b.goods_id '.
196  "WHERE a.goods_id = '$goods_id' AND b.goods_id <> '$goods_id' AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ".
197  'GROUP BY b.goods_id '. 
198 'ORDER BY num DESC '. 
199 'LIMIT '.$GLOBALS['_CFG']['bought_goods']; 
200 $res = $GLOBALS['db']->query($sql); 
201 $key = 0; 
202 $arr = array(); 
203 while ($row = $GLOBALS['db']->fetchRow($res)) 
204
205 $arr[$key]['goods_brief']    = $row['goods_brief']; 
206 $arr[$key]['goods_id']    = $row['goods_id']; 
207 $arr[$key]['goods_name']  = $row['goods_name']; 
208 $arr[$key]['short_name']  = $GLOBALS['_CFG']['goods_name_length'] >0 ? 
209 sub_str($row['goods_name'],$GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
210  $arr[$key]['goods_thumb'] = get_image_path($row['goods_id'],$row['goods_thumb'],true);
211  $arr[$key]['goods_img']   = get_image_path($row['goods_id'],$row['goods_img']);
212  $arr[$key]['shop_price']  = price_format($row['shop_price']); 
213 $arr[$key]['url']         = build_uri('goods',array('gid'=>$row['goods_id']),$row['goods_name']);
214  if ($row['promote_price'] >0) 
215
216 $arr[$key]['promote_price'] = bargain_price($row['promote_price'],$row['promote_start_date'],$row['promote_end_date']);
217  $arr[$key]['formated_promote_price'] = price_format($arr[$key]['promote_price']);
218  } 
219 else 
220
221 $arr[$key]['promote_price'] = 0; 
222
223 $key++; 
224
225 return $arr; 
226
227 function http() 
228
229 return (isset($_SERVER['HTTPS']) &&(strtolower($_SERVER['HTTPS']) != 'off')) ?'https://': 'http://';
230  } 
231 function get_domain() 
232
233 $protocol = http(); 
234 if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) 
235
236 $host = $_SERVER['HTTP_X_FORWARDED_HOST']; 
237
238 elseif (isset($_SERVER['HTTP_HOST'])) 
239
240 $host = $_SERVER['HTTP_HOST']; 
241
242 else 
243
244 if (isset($_SERVER['SERVER_PORT'])) 
245
246 $port = ':'.$_SERVER['SERVER_PORT']; 
247 if ((':80'== $port &&'http://'== $protocol) ||(':443'== $port &&'https://'== $protocol))
248  { 
249 $port = ''; 
250
251
252 else 
253
254 $port = ''; 
255
256 if (isset($_SERVER['SERVER_NAME'])) 
257
258 $host = $_SERVER['SERVER_NAME'] .$port; 
259
260 elseif (isset($_SERVER['SERVER_ADDR'])) 
261
262 $host = $_SERVER['SERVER_ADDR'] .$port; 
263
264
265 return $protocol .$host; 
266
267
268 ?>