commit | author | age
|
3e083b
|
1 |
<?php |
B |
2 |
|
|
3 |
/** |
|
4 |
* 搜索程序 |
|
5 |
*/ |
|
6 |
|
|
7 |
define('IN_ECS', true); |
|
8 |
|
|
9 |
define('_SP_', chr(0xFF).chr(0xFE)); |
|
10 |
define('UCS2', 'ucs-2be'); |
|
11 |
|
|
12 |
|
|
13 |
//点击下拉列表进行搜索时,判断搜索类型 |
|
14 |
$type = empty($_REQUEST['type'])? 0 : trim($_REQUEST['type']); |
|
15 |
$keywords = empty($_REQUEST['keywords'])?'':trim($_REQUEST['keywords']); |
|
16 |
|
|
17 |
if(count(explode("'", $keywords)) > 1) |
|
18 |
{ |
|
19 |
header("Location: search.php"); |
|
20 |
exit; |
|
21 |
} |
|
22 |
|
|
23 |
if($type>0){ |
|
24 |
header("Location: stores.php?type=$type&keywords=$keywords\n"); |
|
25 |
exit; |
|
26 |
} |
|
27 |
|
|
28 |
|
|
29 |
if (!function_exists("htmlspecialchars_decode")) |
|
30 |
{ |
|
31 |
function htmlspecialchars_decode($string, $quote_style = ENT_COMPAT) |
|
32 |
{ |
|
33 |
return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style))); |
|
34 |
} |
|
35 |
} |
|
36 |
|
|
37 |
if (empty($_GET['encode'])) |
|
38 |
{ |
|
39 |
$string = array_merge($_GET, $_POST); |
|
40 |
if (get_magic_quotes_gpc()) |
|
41 |
{ |
|
42 |
require(dirname(__FILE__) . '/includes/lib_base.php'); |
|
43 |
//require(dirname(__FILE__) . '/includes/lib_common.php'); |
|
44 |
|
|
45 |
$string = stripslashes_deep($string); |
|
46 |
} |
|
47 |
$string['search_encode_time'] = time(); |
|
48 |
$string = str_replace('+', '%2b', base64_encode(serialize($string))); |
|
49 |
|
|
50 |
header("Location: search.php?encode=$string\n"); |
|
51 |
|
|
52 |
exit; |
|
53 |
} |
|
54 |
else |
|
55 |
{ |
|
56 |
$string = base64_decode(trim($_GET['encode'])); |
|
57 |
if ($string !== false) |
|
58 |
{ |
|
59 |
$string = unserialize($string); |
|
60 |
if ($string !== false) |
|
61 |
{ |
|
62 |
/* 用户在重定向的情况下当作一次访问 */ |
|
63 |
if (!empty($string['search_encode_time'])) |
|
64 |
{ |
|
65 |
if (time() > $string['search_encode_time'] + 2) |
|
66 |
{ |
|
67 |
define('INGORE_VISIT_STATS', true); |
|
68 |
} |
|
69 |
} |
|
70 |
else |
|
71 |
{ |
|
72 |
define('INGORE_VISIT_STATS', true); |
|
73 |
} |
|
74 |
} |
|
75 |
else |
|
76 |
{ |
|
77 |
$string = array(); |
|
78 |
} |
|
79 |
} |
|
80 |
else |
|
81 |
{ |
|
82 |
$string = array(); |
|
83 |
} |
|
84 |
} |
|
85 |
|
|
86 |
require(dirname(__FILE__) . '/includes/init.php'); |
|
87 |
|
|
88 |
$_REQUEST = array_merge($_REQUEST, addslashes_deep($string)); |
|
89 |
|
|
90 |
$_REQUEST['act'] = !empty($_REQUEST['act']) ? trim($_REQUEST['act']) : ''; |
|
91 |
|
|
92 |
|
|
93 |
//判断 弹框登陆 验证码是否显示 |
|
94 |
$captcha = intval($_CFG['captcha']); |
|
95 |
if(($captcha & CAPTCHA_LOGIN) && (! ($captcha & CAPTCHA_LOGIN_FAIL) || (($captcha & CAPTCHA_LOGIN_FAIL) && $_SESSION['login_fail'] > 2)) && gd_version() > 0) |
|
96 |
{ |
|
97 |
$GLOBALS['smarty']->assign('enabled_captcha', 1); |
|
98 |
$GLOBALS['smarty']->assign('rand', mt_rand()); |
|
99 |
} |
|
100 |
/*------------------------------------------------------ */ |
|
101 |
//-- 高级搜索 |
|
102 |
/*------------------------------------------------------ */ |
|
103 |
if ($_REQUEST['act'] == 'advanced_search') |
|
104 |
{ |
|
105 |
$goods_type = !empty($_REQUEST['goods_type']) ? intval($_REQUEST['goods_type']) : 0; |
|
106 |
$attributes = get_seachable_attributes($goods_type); |
|
107 |
$smarty->assign('goods_type_selected', $goods_type); |
|
108 |
$smarty->assign('goods_type_list', $attributes['cate']); |
|
109 |
$smarty->assign('goods_attributes', $attributes['attr']); |
|
110 |
|
|
111 |
assign_template(); |
|
112 |
assign_dynamic('search'); |
|
113 |
$position = assign_ur_here(0, $_LANG['advanced_search']); |
|
114 |
$smarty->assign('page_title', $position['title']); // 页面标题 |
|
115 |
$smarty->assign('ur_here', $position['ur_here']); // 当前位置 |
|
116 |
|
|
117 |
$smarty->assign('categories', get_categories_tree()); // 分类树 |
|
118 |
$smarty->assign('helps', get_shop_help()); // 网店帮助 |
|
119 |
$smarty->assign('top_goods', get_top10()); // 销售排行 |
|
120 |
$smarty->assign('promotion_info', get_promotion_info()); |
|
121 |
$smarty->assign('cat_list', cat_list(0, 0, true, 2, false)); |
|
122 |
$smarty->assign('brand_list', get_brand_list()); |
|
123 |
$smarty->assign('action', 'form'); |
|
124 |
$smarty->assign('use_storage', $_CFG['use_storage']); |
|
125 |
$smarty->assign('cainixihuan', get_cainixihuan()); //猜你喜欢 |
|
126 |
$smarty->display('search.dwt'); |
|
127 |
|
|
128 |
exit; |
|
129 |
} |
|
130 |
/*------------------------------------------------------ */ |
|
131 |
//-- 搜索结果 |
|
132 |
/*------------------------------------------------------ */ |
|
133 |
else |
|
134 |
{ |
|
135 |
$_REQUEST['keywords'] = !empty($_REQUEST['keywords']) ? htmlspecialchars(trim($_REQUEST['keywords'])) : ''; |
|
136 |
$_REQUEST['brand'] = !empty($_REQUEST['brand']) ? intval($_REQUEST['brand']) : 0; |
|
137 |
$_REQUEST['category'] = !empty($_REQUEST['category']) ? intval($_REQUEST['category']) : 0; |
|
138 |
$_REQUEST['min_price'] = !empty($_REQUEST['min_price']) ? intval($_REQUEST['min_price']) : 0; |
|
139 |
$_REQUEST['max_price'] = !empty($_REQUEST['max_price']) ? intval($_REQUEST['max_price']) : 0; |
|
140 |
$_REQUEST['goods_type'] = !empty($_REQUEST['goods_type']) ? intval($_REQUEST['goods_type']) : 0; |
|
141 |
$_REQUEST['sc_ds'] = !empty($_REQUEST['sc_ds']) ? intval($_REQUEST['sc_ds']) : 0; |
|
142 |
$_REQUEST['outstock'] = !empty($_REQUEST['outstock']) ? 1 : 0; |
|
143 |
|
|
144 |
$action = ''; |
|
145 |
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'form') |
|
146 |
{ |
|
147 |
/* 要显示高级搜索栏 */ |
|
148 |
$adv_value['keywords'] = htmlspecialchars(stripcslashes($_REQUEST['keywords'])); |
|
149 |
$adv_value['brand'] = $_REQUEST['brand']; |
|
150 |
$adv_value['min_price'] = $_REQUEST['min_price']; |
|
151 |
$adv_value['max_price'] = $_REQUEST['max_price']; |
|
152 |
$adv_value['category'] = $_REQUEST['category']; |
|
153 |
|
|
154 |
$attributes = get_seachable_attributes($_REQUEST['goods_type']); |
|
155 |
|
|
156 |
/* 将提交数据重新赋值 */ |
|
157 |
foreach ($attributes['attr'] AS $key => $val) |
|
158 |
{ |
|
159 |
if (!empty($_REQUEST['attr'][$val['id']])) |
|
160 |
{ |
|
161 |
if ($val['type'] == 2) |
|
162 |
{ |
|
163 |
$attributes['attr'][$key]['value']['from'] = !empty($_REQUEST['attr'][$val['id']]['from']) ? htmlspecialchars(stripcslashes(trim($_REQUEST['attr'][$val['id']]['from']))) : ''; |
|
164 |
$attributes['attr'][$key]['value']['to'] = !empty($_REQUEST['attr'][$val['id']]['to']) ? htmlspecialchars(stripcslashes(trim($_REQUEST['attr'][$val['id']]['to']))) : ''; |
|
165 |
} |
|
166 |
else |
|
167 |
{ |
|
168 |
$attributes['attr'][$key]['value'] = !empty($_REQUEST['attr'][$val['id']]) ? htmlspecialchars(stripcslashes(trim($_REQUEST['attr'][$val['id']]))) : ''; |
|
169 |
} |
|
170 |
} |
|
171 |
} |
|
172 |
if ($_REQUEST['sc_ds']) |
|
173 |
{ |
|
174 |
$smarty->assign('scck', 'checked'); |
|
175 |
} |
|
176 |
$smarty->assign('adv_val', $adv_value); |
|
177 |
$smarty->assign('goods_type_list', $attributes['cate']); |
|
178 |
$smarty->assign('goods_attributes', $attributes['attr']); |
|
179 |
$smarty->assign('goods_type_selected', $_REQUEST['goods_type']); |
|
180 |
$smarty->assign('cat_list', cat_list(0, $adv_value['category'], true, 2, false)); |
|
181 |
$smarty->assign('brand_list', get_brand_list()); |
|
182 |
$smarty->assign('action', 'form'); |
|
183 |
$smarty->assign('use_storage', $_CFG['use_storage']); |
|
184 |
|
|
185 |
$action = 'form'; |
|
186 |
} |
|
187 |
|
|
188 |
/* 初始化搜索条件 */ |
|
189 |
$keywords = ''; |
|
190 |
$tag_where = ''; |
|
191 |
if (!empty($_REQUEST['keywords'])) |
|
192 |
{ |
|
193 |
|
|
194 |
include_once('includes/lib_splitword.php'); |
|
195 |
$Recordkw = str_replace(array("\'"), array(''), trim($_REQUEST['keywords'])); |
|
196 |
$cfg_soft_lang_www_68ecshop_com = 'utf-8'; |
|
197 |
$sp_www_68ecshop_com = new SplitWord($cfg_soft_lang_www_68ecshop_com, $cfg_soft_lang_www_68ecshop_com); |
|
198 |
$sp_www_68ecshop_com->SetSource($Recordkw, $cfg_soft_lang_www_68ecshop_com, $cfg_soft_lang_www_68ecshop_com); |
|
199 |
$sp_www_68ecshop_com->SetResultType(1); |
|
200 |
$sp_www_68ecshop_com->StartAnalysis(TRUE); |
|
201 |
$word_www_68ecshop_com = $sp_www_68ecshop_com->GetFinallyResult(' '); |
|
202 |
|
|
203 |
$word_www_68ecshop_com = preg_replace("/[ ]{1,}/", " ", trim($word_www_68ecshop_com)); |
|
204 |
$replacef_www_68ecshop_com = explode(' ', $word_www_68ecshop_com); |
|
205 |
|
|
206 |
|
|
207 |
$keywords = 'AND ('; |
|
208 |
$goods_ids = array(); |
|
209 |
foreach ($replacef_www_68ecshop_com AS $key => $val) |
|
210 |
{ |
|
211 |
if ($key > 0 && $key < count($replacef_www_68ecshop_com) && count($replacef_www_68ecshop_com) > 1) |
|
212 |
{ |
|
213 |
$keywords .= " OR "; |
|
214 |
} |
|
215 |
$val = mysql_like_quote(trim($val)); |
|
216 |
$sc_dsad = $_REQUEST['sc_ds'] ? " OR goods_desc LIKE '%$val%'" : ''; |
|
217 |
$keywords .= "(goods_name LIKE '%$val%' OR goods_sn LIKE '%$val%' OR keywords LIKE '%$val%' $sc_dsad)"; |
|
218 |
|
|
219 |
$sql = 'SELECT DISTINCT goods_id FROM ' . $ecs->table('tag') . " WHERE tag_words LIKE '%$val%' "; |
|
220 |
$res = $db->query($sql); |
|
221 |
while ($row = $db->FetchRow($res)) |
|
222 |
{ |
|
223 |
$goods_ids[] = $row['goods_id']; |
|
224 |
} |
|
225 |
} |
|
226 |
|
|
227 |
//$db->autoReplace($ecs->table('keywords'), array('date' => local_date('Y-m-d'), |
|
228 |
//'searchengine' => 'ecshop', 'keyword' => htmlspecialchars_decode(str_replace('%', '', $Recordkw)), 'count' => 1), array('count' => 1)); |
|
229 |
|
|
230 |
|
|
231 |
$keywords .= ')'; |
|
232 |
|
|
233 |
//echo "<pre>"; |
|
234 |
//print_r($goods_ids); |
|
235 |
|
|
236 |
//echo $keywords; |
|
237 |
|
|
238 |
$goods_ids = array_unique($goods_ids); |
|
239 |
$tag_where = implode(',', $goods_ids); |
|
240 |
if (!empty($tag_where)) |
|
241 |
{ |
|
242 |
$tag_where = 'OR g.goods_id ' . db_create_in($tag_where); |
|
243 |
} |
|
244 |
} |
|
245 |
|
|
246 |
$category = !empty($_REQUEST['category']) ? intval($_REQUEST['category']) : 0; |
|
247 |
$categories = ($category > 0) ? ' AND ' . get_children($category) : ''; |
|
248 |
|
|
249 |
$brand = $_REQUEST['brand'] ? " AND brand_id = '$_REQUEST[brand]'" : ''; |
|
250 |
$outstock = !empty($_REQUEST['outstock']) ? " AND g.goods_number > 0 " : ''; |
|
251 |
|
|
252 |
$min_price = $_REQUEST['min_price'] != 0 ? " AND g.shop_price >= '$_REQUEST[min_price]'" : ''; |
|
253 |
$max_price = $_REQUEST['max_price'] != 0 || $_REQUEST['min_price'] < 0 ? " AND g.shop_price <= '$_REQUEST[max_price]'" : ''; |
|
254 |
|
|
255 |
/* 排序、显示方式以及类型 */ |
|
256 |
$default_display_type = $_CFG['show_order_type'] == '0' ? 'list' : ($_CFG['show_order_type'] == '1' ? 'grid' : 'text'); |
|
257 |
$default_sort_order_method = $_CFG['sort_order_method'] == '0' ? 'DESC' : 'ASC'; |
|
258 |
$default_sort_order_type = $_CFG['sort_order_type'] == '0' ? 'goods_id' : ($_CFG['sort_order_type'] == '1' ? 'shop_price' : 'last_update'); |
|
259 |
|
|
260 |
$sort = (isset($_REQUEST['sort']) && in_array(trim(strtolower($_REQUEST['sort'])), array('goods_id', 'shop_price', 'last_update', 'click_count'))) ? trim($_REQUEST['sort']) : $default_sort_order_type; |
|
261 |
$order = (isset($_REQUEST['order']) && in_array(trim(strtoupper($_REQUEST['order'])), array('ASC', 'DESC'))) ? trim($_REQUEST['order']) : $default_sort_order_method; |
|
262 |
$display = (isset($_REQUEST['display']) && in_array(trim(strtolower($_REQUEST['display'])), array('list', 'grid', 'text'))) ? trim($_REQUEST['display']) : (isset($_SESSION['display_search']) ? $_SESSION['display_search'] : $default_display_type); |
|
263 |
|
|
264 |
$_SESSION['display_search'] = $display; |
|
265 |
|
|
266 |
$page = !empty($_REQUEST['page']) && intval($_REQUEST['page']) > 0 ? intval($_REQUEST['page']) : 1; |
|
267 |
$size = !empty($_CFG['page_size']) && intval($_CFG['page_size']) > 0 ? intval($_CFG['page_size']) : 10; |
|
268 |
|
|
269 |
$intromode = ''; //方式,用于决定搜索结果页标题图片 |
|
270 |
|
|
271 |
if (!empty($_REQUEST['intro'])) |
|
272 |
{ |
|
273 |
switch ($_REQUEST['intro']) |
|
274 |
{ |
|
275 |
case 'best': |
|
276 |
$intro = ' AND g.is_best = 1'; |
|
277 |
$intromode = 'best'; |
|
278 |
$ur_here = $_LANG['best_goods']; |
|
279 |
break; |
|
280 |
case 'new': |
|
281 |
$intro = ' AND g.is_new = 1'; |
|
282 |
$intromode ='new'; |
|
283 |
$ur_here = $_LANG['new_goods']; |
|
284 |
break; |
|
285 |
case 'hot': |
|
286 |
$intro = ' AND g.is_hot = 1'; |
|
287 |
$intromode = 'hot'; |
|
288 |
$ur_here = $_LANG['hot_goods']; |
|
289 |
break; |
|
290 |
case 'promotion': |
|
291 |
$time = gmtime(); |
|
292 |
$intro = " AND g.promote_price > 0 AND g.promote_start_date <= '$time' AND g.promote_end_date >= '$time'"; |
|
293 |
$intromode = 'promotion'; |
|
294 |
$ur_here = $_LANG['promotion_goods']; |
|
295 |
break; |
|
296 |
default: |
|
297 |
$intro = ''; |
|
298 |
} |
|
299 |
} |
|
300 |
else |
|
301 |
{ |
|
302 |
$intro = ''; |
|
303 |
} |
|
304 |
|
|
305 |
if (empty($ur_here)) |
|
306 |
{ |
|
307 |
$ur_here = $_LANG['search_goods']; |
|
308 |
} |
|
309 |
|
|
310 |
/*------------------------------------------------------ */ |
|
311 |
//-- 属性检索 |
|
312 |
/*------------------------------------------------------ */ |
|
313 |
$attr_in = ''; |
|
314 |
$attr_num = 0; |
|
315 |
$attr_url = ''; |
|
316 |
$attr_arg = array(); |
|
317 |
|
|
318 |
if (!empty($_REQUEST['attr'])) |
|
319 |
{ |
|
320 |
$sql = "SELECT goods_id, COUNT(*) AS num FROM " . $ecs->table("goods_attr") . " WHERE 0 "; |
|
321 |
foreach ($_REQUEST['attr'] AS $key => $val) |
|
322 |
{ |
|
323 |
if (is_not_null($val) && is_numeric($key)) |
|
324 |
{ |
|
325 |
$attr_num++; |
|
326 |
$sql .= " OR (1 "; |
|
327 |
|
|
328 |
if (is_array($val)) |
|
329 |
{ |
|
330 |
$sql .= " AND attr_id = '$key'"; |
|
331 |
|
|
332 |
if (!empty($val['from'])) |
|
333 |
{ |
|
334 |
$sql .= is_numeric($val['from']) ? " AND attr_value >= " . floatval($val['from']) : " AND attr_value >= '$val[from]'"; |
|
335 |
$attr_arg["attr[$key][from]"] = $val['from']; |
|
336 |
$attr_url .= "&attr[$key][from]=$val[from]"; |
|
337 |
} |
|
338 |
|
|
339 |
if (!empty($val['to'])) |
|
340 |
{ |
|
341 |
$sql .= is_numeric($val['to']) ? " AND attr_value <= " . floatval($val['to']) : " AND attr_value <= '$val[to]'"; |
|
342 |
$attr_arg["attr[$key][to]"] = $val['to']; |
|
343 |
$attr_url .= "&attr[$key][to]=$val[to]"; |
|
344 |
} |
|
345 |
} |
|
346 |
else |
|
347 |
{ |
|
348 |
/* 处理选购中心过来的链接 */ |
|
349 |
$sql .= isset($_REQUEST['pickout']) ? " AND attr_id = '$key' AND attr_value = '" . $val . "' " : " AND attr_id = '$key' AND attr_value LIKE '%" . mysql_like_quote($val) . "%' "; |
|
350 |
$attr_url .= "&attr[$key]=$val"; |
|
351 |
$attr_arg["attr[$key]"] = $val; |
|
352 |
} |
|
353 |
|
|
354 |
$sql .= ')'; |
|
355 |
} |
|
356 |
} |
|
357 |
|
|
358 |
/* 如果检索条件都是无效的,就不用检索 */ |
|
359 |
if ($attr_num > 0) |
|
360 |
{ |
|
361 |
$sql .= " GROUP BY goods_id HAVING num = '$attr_num'"; |
|
362 |
|
|
363 |
$row = $db->getCol($sql); |
|
364 |
if (count($row)) |
|
365 |
{ |
|
366 |
$attr_in = " AND " . db_create_in($row, 'g.goods_id'); |
|
367 |
} |
|
368 |
else |
|
369 |
{ |
|
370 |
$attr_in = " AND 0 "; |
|
371 |
} |
|
372 |
} |
|
373 |
} |
|
374 |
elseif (isset($_REQUEST['pickout'])) |
|
375 |
{ |
|
376 |
/* 从选购中心进入的链接 */ |
|
377 |
$sql = "SELECT DISTINCT(goods_id) FROM " . $ecs->table('goods_attr'); |
|
378 |
$col = $db->getCol($sql); |
|
379 |
//如果商店没有设置商品属性,那么此检索条件是无效的 |
|
380 |
if (!empty($col)) |
|
381 |
{ |
|
382 |
$attr_in = " AND " . db_create_in($col, 'g.goods_id'); |
|
383 |
} |
|
384 |
} |
|
385 |
|
|
386 |
if($_CFG['fulltext_search'] == '0'){ |
|
387 |
|
|
388 |
/* 获得符合条件的商品总数 */ |
|
389 |
$sql = "SELECT COUNT(*) FROM " .$ecs->table('goods'). " AS g ". |
|
390 |
"WHERE g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_virtual=0 $attr_in $categories ". |
|
391 |
"AND (( 1 " . $keywords . $brand . $min_price . $max_price . $intro . $outstock ." ) ".$tag_where." )"; |
|
392 |
$count = $db->getOne($sql); |
|
393 |
|
|
394 |
if ($page == 1 && $Recordkw && $count && !$category) Recordkeyword($Recordkw, $count, 'ecshop'); // 代码修改 |
|
395 |
if($count==0) |
|
396 |
{ |
|
397 |
if (preg_match('/^[a-zA-z]+$/i', $_REQUEST['keywords'])) |
|
398 |
{ |
|
399 |
$sql_www_68ecshop_com = "select keyword from ". $ecs->table('keyword') ." where letter='". $_REQUEST['keywords'] ."' order by items desc limit 0,1"; |
|
400 |
$keyword_www_68ecshop_com = $db->getOne($sql_www_68ecshop_com); |
|
401 |
if($keyword_www_68ecshop_com && $keyword_www_68ecshop_com!=$_REQUEST['keywords']) |
|
402 |
{ |
|
403 |
header('Location: search.php?keywords='.$keyword_www_68ecshop_com.'&keyword_zm='.$_REQUEST['keywords']); |
|
404 |
exit; |
|
405 |
} |
|
406 |
} |
|
407 |
} |
|
408 |
if($_REQUEST['keyword_zm']) |
|
409 |
{ |
|
410 |
$smarty->assign('beizhuxinxi_www_68ecshop_com', '关键词<font color=#cc0000>'.$_REQUEST['keyword_zm'].'</font>搜索结果为零,<br>但是我们为您匹配到了相关关键词<font color=#cc0000>'.$_REQUEST['keywords'].'</font>,下面是它的查询结果!'); |
|
411 |
} |
|
412 |
|
|
413 |
$max_page = ($count> 0) ? ceil($count / $size) : 1; |
|
414 |
if ($page > $max_page) |
|
415 |
{ |
|
416 |
$page = $max_page; |
|
417 |
} |
|
418 |
|
|
419 |
//搜索字符串中出现的特殊字符 |
|
420 |
|
|
421 |
// $ts_string_array = array("*","/"); |
|
422 |
$ts_string_array = array("*","/","."); |
|
423 |
|
|
424 |
|
|
425 |
/* 查询商品 */ |
|
426 |
$sql = "SELECT g.goods_id, g.goods_name, g.market_price, g.click_count, g.goods_number, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ". |
|
427 |
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ". |
|
428 |
"g.promote_price, g.promote_start_date, g.promote_end_date, g.goods_thumb, g.goods_img, g.goods_brief, g.goods_type ". |
|
429 |
"FROM " .$ecs->table('goods'). " AS g ". |
|
430 |
"LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ". |
|
431 |
"ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ". |
|
432 |
"WHERE g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_virtual=0 $attr_in $categories ". |
|
433 |
"AND (( 1 " . $keywords . $brand . $min_price . $max_price . $intro . $outstock . " ) ".$tag_where." ) " . |
|
434 |
|
|
435 |
"ORDER BY if(instr(goods_name,'".$_REQUEST['keywords']."') >0,1,0) desc , $sort $order"; |
|
436 |
|
|
437 |
|
|
438 |
} |
|
439 |
|
|
440 |
|
|
441 |
if($_CFG['fulltext_search'] == '1'){ |
|
442 |
require ( "./includes/sphinxapi.php" ); |
|
443 |
$s = new SphinxClient(); |
|
444 |
$s->SetServer('localhost',9312); |
|
445 |
$s->setLimits (0,1000); |
|
446 |
//$s->SetMatchMode ( SPH_MATCH_ANY); // 分词 |
|
447 |
$result = $s->Query($_REQUEST['keywords'],'goods'); |
|
448 |
if($result){ |
|
449 |
$idarray = array_keys($result['matches']); |
|
450 |
if(empty($idarray)){ |
|
451 |
$idarray = array(); |
|
452 |
foreach($replacef_www_68ecshop_com as $key => $value){ |
|
453 |
$result = $s->Query($value,'goods'); |
|
454 |
$idss = array_keys($result['matches']); |
|
455 |
if(empty($idss)){ |
|
456 |
$idss = array(); |
|
457 |
} |
|
458 |
$idarray = array_merge($idarray,$idss); |
|
459 |
} |
|
460 |
} |
|
461 |
$ids = join(',', $idarray); |
|
462 |
|
|
463 |
if(empty($ids)) $ids = '-1'; |
|
464 |
$sql = "SELECT COUNT(*) FROM " .$ecs->table('goods'). " AS g ". |
|
465 |
"WHERE g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 $attr_in $categories ". |
|
466 |
"AND (( 1 " ."and g.goods_id in ({$ids})"." ) ".$tag_where." )"; |
|
467 |
|
|
468 |
$count = $db->getOne($sql); |
|
469 |
if ($page == 1 && $Recordkw && $count && !$category) Recordkeyword($Recordkw, $count, 'ecshop'); |
|
470 |
if($count==0) |
|
471 |
{ |
|
472 |
if (preg_match('/^[a-zA-z]+$/i', $_REQUEST['keywords'])) |
|
473 |
{ |
|
474 |
$sql = "select keyword from ". $ecs->table('keyword') ." where letter='". $_REQUEST['keywords'] ."' order by items desc limit 0,1"; |
|
475 |
$keyword = $db->getOne($sql); |
|
476 |
if($keyword && $keyword!=$_REQUEST['keywords']) |
|
477 |
{ |
|
478 |
header('Location: search.php?keywords='.$keyword.'&keyword_zm='.$_REQUEST['keywords']); |
|
479 |
exit; |
|
480 |
} |
|
481 |
} |
|
482 |
} |
|
483 |
if($_REQUEST['keyword_zm']) |
|
484 |
{ |
|
485 |
$smarty->assign('beizhuxinxi', '关键词<font color=#cc0000>'.$_REQUEST['keyword_zm'].'</font>搜索结果为零,<br>但是我们为您匹配到了相关关键词<font color=#cc0000>'.$_REQUEST['keywords'].'</font>,下面是它的查询结果!'); |
|
486 |
} |
|
487 |
$max_page = ($count> 0) ? ceil($count / $size) : 1; |
|
488 |
if ($page > $max_page) |
|
489 |
{ |
|
490 |
$page = $max_page; |
|
491 |
} |
|
492 |
|
|
493 |
|
|
494 |
//$sqls = "select * from ecs_goods where goods_id in ({$ids})"; |
|
495 |
$sql = "SELECT g.goods_id, g.goods_name, g.market_price, g.click_count, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ". |
|
496 |
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ". |
|
497 |
"g.promote_price, g.promote_start_date, g.promote_end_date, g.goods_thumb, g.goods_img, g.goods_brief, g.goods_type ". |
|
498 |
"FROM " .$ecs->table('goods'). " AS g ". |
|
499 |
"LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ". |
|
500 |
"ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ". |
|
501 |
"WHERE g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 $attr_in $categories ". |
|
502 |
"AND (( 1 " ."and g.goods_id in ({$ids})". " ) ".$tag_where." ) " . |
|
503 |
"ORDER BY sort_order asc"; |
|
504 |
|
|
505 |
}else{ |
|
506 |
//如果服务关闭则关闭全文搜索功能 |
|
507 |
$sql = "update ".$ecs->table('shop_config')." set value = 0 where code = 'fulltext_search'"; |
|
508 |
$db -> query($sql); |
|
509 |
clear_cache_files(); |
|
510 |
echo "<script>alert('引擎服务未开启,自动关闭全文搜索功能!');location.reload();</script>"; |
|
511 |
exit; |
|
512 |
} |
|
513 |
} |
|
514 |
|
|
515 |
|
|
516 |
|
|
517 |
$res = $db->SelectLimit($sql, $size, ($page - 1) * $size); |
|
518 |
|
|
519 |
$arr = array(); |
|
520 |
while ($row = $db->FetchRow($res)) |
|
521 |
{ |
|
522 |
if ($row['promote_price'] > 0) |
|
523 |
{ |
|
524 |
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']); |
|
525 |
} |
|
526 |
else |
|
527 |
{ |
|
528 |
$promote_price = 0; |
|
529 |
} |
|
530 |
|
|
531 |
/* 处理商品水印图片 */ |
|
532 |
$watermark_img = ''; |
|
533 |
|
|
534 |
if ($promote_price != 0) |
|
535 |
{ |
|
536 |
$watermark_img = "watermark_promote_small"; |
|
537 |
} |
|
538 |
elseif ($row['is_new'] != 0) |
|
539 |
{ |
|
540 |
$watermark_img = "watermark_new_small"; |
|
541 |
} |
|
542 |
elseif ($row['is_best'] != 0) |
|
543 |
{ |
|
544 |
$watermark_img = "watermark_best_small"; |
|
545 |
} |
|
546 |
elseif ($row['is_hot'] != 0) |
|
547 |
{ |
|
548 |
$watermark_img = 'watermark_hot_small'; |
|
549 |
} |
|
550 |
|
|
551 |
if ($watermark_img != '') |
|
552 |
{ |
|
553 |
$arr[$row['goods_id']]['watermark_img'] = $watermark_img; |
|
554 |
} |
|
555 |
|
|
556 |
$arr[$row['goods_id']]['goods_id'] = $row['goods_id']; |
|
557 |
if($display == 'grid') |
|
558 |
{ |
|
559 |
$arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; |
|
560 |
} |
|
561 |
else |
|
562 |
{ |
|
563 |
$arr[$row['goods_id']]['goods_name'] = $row['goods_name']; |
|
564 |
} |
|
565 |
$arr[$row['goods_id']]['goods_name'] = $row['goods_name']; |
|
566 |
|
|
567 |
$arr[$row['goods_id']]['goods_name_www_68ecshop_com'] = $arr[$row['goods_id']]['goods_name']; |
|
568 |
foreach($replacef_www_68ecshop_com as $key_www_68ecshop_com =>$temp_qq) |
|
569 |
{ |
|
570 |
//$replacet[$key_www_68ecshop_com]= '<strong style="color:#cc0000;">'. $temp_qq .'</strong>';; |
|
571 |
|
|
572 |
if(in_array($temp_qq,$ts_string_array)){ |
|
573 |
$arr[$row['goods_id']]['goods_name_www_68ecshop_com'] = preg_replace('/(?!<[^>]*)\\'.$temp_qq.'(?![^<]*>)/i', '<strong style="color:#cc0000;">'. $temp_qq .'</strong>', $arr[$row['goods_id']]['goods_name_www_68ecshop_com']); |
|
574 |
}else{ |
|
575 |
$arr[$row['goods_id']]['goods_name_www_68ecshop_com'] = preg_replace('/(?!<[^>]*)'.$temp_qq.'(?![^<]*>)/i', '<strong style="color:#cc0000;">'. $temp_qq .'</strong>', $arr[$row['goods_id']]['goods_name_www_68ecshop_com']); |
|
576 |
} |
|
577 |
|
|
578 |
} |
|
579 |
|
|
580 |
$arr[$row['goods_id']]['type'] = $row['goods_type']; |
|
581 |
$arr[$row['goods_id']]['market_price'] = price_format($row['market_price']); |
|
582 |
$arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']); |
|
583 |
$arr[$row['goods_id']]['promote_price'] = ($promote_price > 0) ? price_format($promote_price) : ''; |
|
584 |
$arr[$row['goods_id']]['goods_brief'] = $row['goods_brief']; |
|
585 |
$arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); |
|
586 |
$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); |
|
587 |
$arr[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); |
|
588 |
$arr[$row['goods_id']]['evaluation'] = get_evaluation_sum($row['goods_id']); |
|
589 |
$arr[$row['goods_id']]['is_new'] = $row['is_new']; |
|
590 |
$arr[$row['goods_id']]['is_best'] = $row['is_best']; |
|
591 |
$arr[$row['goods_id']]['is_hot'] = $row['is_hot']; |
|
592 |
$arr[$row['goods_id']]['comment_count'] = get_comment_count($row['goods_id']); |
|
593 |
$arr[$row['goods_id']]['count'] = selled_count($row['goods_id']); |
|
594 |
$arr[$row['goods_id']]['click_count'] = $row['click_count']; |
|
595 |
$arr[$row['goods_id']]['goods_number'] = $row['goods_number']; |
|
596 |
|
|
597 |
/* 检查是否已经存在于用户的收藏夹 */ |
|
598 |
$sql = "SELECT COUNT(*) FROM " .$GLOBALS['ecs']->table('collect_goods') . |
|
599 |
" WHERE user_id='$_SESSION[user_id]' AND goods_id = " . $row['goods_id']; |
|
600 |
if ($GLOBALS['db']->GetOne($sql) > 0) |
|
601 |
{ |
|
602 |
$arr[$row['goods_id']]['is_collet'] = 1; |
|
603 |
} |
|
604 |
else |
|
605 |
{ |
|
606 |
$arr[$row['goods_id']]['is_collet'] = 0; |
|
607 |
} |
|
608 |
} |
|
609 |
|
|
610 |
if($display == 'grid') |
|
611 |
{ |
|
612 |
if(count($arr) % 2 != 0) |
|
613 |
{ |
|
614 |
$arr[] = array(); |
|
615 |
} |
|
616 |
} |
|
617 |
$smarty->assign('goods_list', $arr); |
|
618 |
$smarty->assign('category', $category); |
|
619 |
$smarty->assign('keywords', htmlspecialchars(stripslashes($_REQUEST['keywords']))); |
|
620 |
$smarty->assign('search_keywords', stripslashes(htmlspecialchars_decode($_REQUEST['keywords']))); |
|
621 |
$smarty->assign('brand', $_REQUEST['brand']); |
|
622 |
$smarty->assign('min_price', $min_price); |
|
623 |
$smarty->assign('max_price', $max_price); |
|
624 |
$smarty->assign('outstock', $_REQUEST['outstock']); |
|
625 |
|
|
626 |
/* 分页 */ |
|
627 |
$url_format = "search.php?category=$category&keywords=" . urlencode(stripslashes($_REQUEST['keywords'])) . "&brand=" . $_REQUEST['brand']."&action=".$action."&goods_type=" . $_REQUEST['goods_type'] . "&sc_ds=" . $_REQUEST['sc_ds']; |
|
628 |
if (!empty($intromode)) |
|
629 |
{ |
|
630 |
$url_format .= "&intro=" . $intromode; |
|
631 |
} |
|
632 |
if (isset($_REQUEST['pickout'])) |
|
633 |
{ |
|
634 |
$url_format .= '&pickout=1'; |
|
635 |
} |
|
636 |
$url_format .= "&min_price=" . $_REQUEST['min_price'] ."&max_price=" . $_REQUEST['max_price'] . "&sort=$sort"; |
|
637 |
|
|
638 |
$url_format .= "$attr_url&order=$order&page="; |
|
639 |
|
|
640 |
$pager['search'] = array( |
|
641 |
'keywords' => stripslashes(urlencode($_REQUEST['keywords'])), |
|
642 |
'category' => $category, |
|
643 |
'brand' => $_REQUEST['brand'], |
|
644 |
'sort' => $sort, |
|
645 |
'order' => $order, |
|
646 |
'min_price' => $_REQUEST['min_price'], |
|
647 |
'max_price' => $_REQUEST['max_price'], |
|
648 |
'action' => $action, |
|
649 |
'intro' => empty($intromode) ? '' : trim($intromode), |
|
650 |
'goods_type' => $_REQUEST['goods_type'], |
|
651 |
'sc_ds' => $_REQUEST['sc_ds'], |
|
652 |
'outstock' => $_REQUEST['outstock'] |
|
653 |
); |
|
654 |
$pager['search'] = array_merge($pager['search'], $attr_arg); |
|
655 |
|
|
656 |
$pager = get_pager('search.php', $pager['search'], $count, $page, $size); |
|
657 |
$pager['display'] = $display; |
|
658 |
|
|
659 |
$smarty->assign('url_format', $url_format); |
|
660 |
$smarty->assign('pager', $pager); |
|
661 |
|
|
662 |
assign_template(); |
|
663 |
assign_dynamic('search'); |
|
664 |
$position = assign_ur_here(0, $ur_here . ($_REQUEST['keywords'] ? '_' . $_REQUEST['keywords'] : '')); |
|
665 |
$smarty->assign('page_title', $position['title']); // 页面标题 |
|
666 |
$smarty->assign('ur_here', $position['ur_here']); // 当前位置 |
|
667 |
$smarty->assign('intromode', $intromode); |
|
668 |
$smarty->assign('categories', get_categories_tree()); // 分类树 |
|
669 |
$smarty->assign('helps', get_shop_help()); // 网店帮助 |
|
670 |
$smarty->assign('top_goods', get_top10()); // 销售排行 |
|
671 |
$smarty->assign('compare_btn', true); //对比按钮 |
|
672 |
$smarty->assign('promotion_info', get_promotion_info()); |
|
673 |
|
|
674 |
$sql= "select g.cat_id, count(*) AS cat_count from ".$ecs->table('goods')." AS g ". |
|
675 |
"WHERE g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 $attr_in ". |
|
676 |
"AND (( 1 " . $categories . $keywords . $brand . $min_price . $max_price . $intro . $outstock . " ) ".$tag_where." ) " . |
|
677 |
" group by g.cat_id "; |
|
678 |
//echo $sql; |
|
679 |
$res_kcat = $db->query($sql); |
|
680 |
$kcat_list =array(); |
|
681 |
while ($row_kcat=$db->fetchRow($res_kcat)) |
|
682 |
{ |
|
683 |
$kcat_list[$row_kcat['cat_id']] = $row_kcat['cat_count']; |
|
684 |
} |
|
685 |
|
|
686 |
//扩展分类 |
|
687 |
/* |
|
688 |
$sql_k = "select gc.cat_id, count(*) AS cat_count from ".$ecs->table('goods_cat')." AS gc ". |
|
689 |
" left join ". $ecs->table('goods') ." AS g on g.goods_id= gc.goods_id ". |
|
690 |
"WHERE g.is_delete = 0 AND g.is_on_sale = 1 AND g.is_alone_sale = 1 ". |
|
691 |
"AND (1 " . $keywords . " ) ". |
|
692 |
" group by gc.cat_id "; |
|
693 |
//echo $sql_k; |
|
694 |
$res_kcat = $db->query($sql_k); |
|
695 |
while ($row_kcat=$db->fetchRow($res_kcat)) |
|
696 |
{ |
|
697 |
if (array_key_exists($row_kcat['cat_id'], $kcat_list)) |
|
698 |
{ |
|
699 |
$kcat_list[$row_kcat['cat_id']] += $row_kcat['cat_count']; |
|
700 |
} |
|
701 |
else |
|
702 |
{ |
|
703 |
$kcat_list[$row_kcat['cat_id']] = $row_kcat['cat_count']; |
|
704 |
} |
|
705 |
} |
|
706 |
*/ |
|
707 |
|
|
708 |
arsort($kcat_list); |
|
709 |
//echo "<pre>"; |
|
710 |
//print_r($kcat_list); |
|
711 |
$cat_two_arr=array(); |
|
712 |
foreach ($kcat_list as $kkey=>$kkcat) |
|
713 |
{ |
|
714 |
//echo $kkey.":".$kkcat."<br>"; |
|
715 |
$cat_arr = get_parent_cats($kkey); |
|
716 |
|
|
717 |
if(!empty($cat_arr)){ |
|
718 |
|
|
719 |
$anum = count($cat_arr)-1; |
|
720 |
$name = ''; |
|
721 |
krsort($cat_arr); |
|
722 |
|
|
723 |
foreach($cat_arr as $val){ |
|
724 |
$name.= $val['cat_name'].'>'; |
|
725 |
$cat_two_arr[$cat_arr[$anum]['cat_id']][$cat_arr[0]['cat_id']]['name'] = rtrim($name,'>'); |
|
726 |
$cat_two_arr[$cat_arr[$anum]['cat_id']][$cat_arr[0]['cat_id']]['url'] = 'search.php?category='. $val['cat_id'] .'&keywords='.$Recordkw; |
|
727 |
$cat_two_arr[$cat_arr[$anum]['cat_id']][$cat_arr[0]['cat_id']]['count'] = $kkcat; |
|
728 |
} |
|
729 |
|
|
730 |
} |
|
731 |
|
|
732 |
} |
|
733 |
if (strlen($Recordkw)>1) |
|
734 |
{ |
|
735 |
|
|
736 |
//echo "<pre>"; |
|
737 |
//print_r($cat_two_arr); |
|
738 |
$array_ret = array(); |
|
739 |
foreach($cat_two_arr as $key => $key_rrr){ |
|
740 |
$countnum = 0; |
|
741 |
foreach($key_rrr as $val){ |
|
742 |
$countnum += $val['count']; |
|
743 |
} |
|
744 |
$keyword_cat_info = explode('>',$val['name']); |
|
745 |
$url = 'search.php?category='. $key .'&keywords='.$Recordkw; |
|
746 |
$array_ret[$countnum]['name'] = $keyword_cat_info[0]; |
|
747 |
$array_ret[$countnum]['url'] = $url; |
|
748 |
$array_ret[$countnum]['count'] = $countnum; |
|
749 |
} |
|
750 |
ksort($array_ret); |
|
751 |
$last = array_pop($array_ret); |
|
752 |
if(!empty($last)){ |
|
753 |
$sql_r = "SELECT w_id FROM " .$GLOBALS['ecs']->table('keyword'). " WHERE searchengine='ecshop' AND word='$Recordkw' "; |
|
754 |
$w_id = $db->getOne($sql_r); |
|
755 |
if($w_id){ |
|
756 |
$sql_r = "UPDATE " . $ecs->table('keyword') . " SET " . |
|
757 |
"keyword_cat = '".$last['name']."', " . |
|
758 |
"keyword_cat_url = '".$last['url']."', " . |
|
759 |
"keyword_cat_count = '".$last['count']."' " . |
|
760 |
"WHERE w_id = ".$w_id['w_id']; |
|
761 |
$db->query($sql_r); |
|
762 |
} |
|
763 |
} |
|
764 |
|
|
765 |
} |
|
766 |
|
|
767 |
//echo '<pre>'; |
|
768 |
//print_r($cat_two_arr); |
|
769 |
//echo '</pre>'; |
|
770 |
|
|
771 |
$smarty->display('search.dwt'); |
|
772 |
} |
|
773 |
|
|
774 |
/*------------------------------------------------------ */ |
|
775 |
//-- PRIVATE FUNCTION |
|
776 |
/*------------------------------------------------------ */ |
|
777 |
/** |
|
778 |
* |
|
779 |
* |
|
780 |
* @access public |
|
781 |
* @param |
|
782 |
* |
|
783 |
* @return void |
|
784 |
*/ |
|
785 |
function is_not_null($value) |
|
786 |
{ |
|
787 |
if (is_array($value)) |
|
788 |
{ |
|
789 |
return (!empty($value['from'])) || (!empty($value['to'])); |
|
790 |
} |
|
791 |
else |
|
792 |
{ |
|
793 |
return !empty($value); |
|
794 |
} |
|
795 |
} |
|
796 |
|
|
797 |
/** |
|
798 |
* 获得可以检索的属性 |
|
799 |
* |
|
800 |
* @access public |
|
801 |
* @params integer $cat_id |
|
802 |
* @return void |
|
803 |
*/ |
|
804 |
function get_seachable_attributes($cat_id = 0) |
|
805 |
{ |
|
806 |
$attributes = array( |
|
807 |
'cate' => array(), |
|
808 |
'attr' => array() |
|
809 |
); |
|
810 |
|
|
811 |
/* 获得可用的商品类型 */ |
|
812 |
$sql = "SELECT t.cat_id, cat_name FROM " .$GLOBALS['ecs']->table('goods_type'). " AS t, ". |
|
813 |
$GLOBALS['ecs']->table('attribute') ." AS a". |
|
814 |
" WHERE t.cat_id = a.cat_id AND t.enabled = 1 AND a.attr_index > 0 "; |
|
815 |
$cat = $GLOBALS['db']->getAll($sql); |
|
816 |
|
|
817 |
/* 获取可以检索的属性 */ |
|
818 |
if (!empty($cat)) |
|
819 |
{ |
|
820 |
foreach ($cat AS $val) |
|
821 |
{ |
|
822 |
$attributes['cate'][$val['cat_id']] = $val['cat_name']; |
|
823 |
} |
|
824 |
$where = $cat_id > 0 ? ' AND a.cat_id = ' . $cat_id : " AND a.cat_id = " . $cat[0]['cat_id']; |
|
825 |
|
|
826 |
$sql = 'SELECT attr_id, attr_name, attr_input_type, attr_type, attr_values, attr_index, sort_order ' . |
|
827 |
' FROM ' . $GLOBALS['ecs']->table('attribute') . ' AS a ' . |
|
828 |
' WHERE a.attr_index > 0 ' .$where. |
|
829 |
' ORDER BY cat_id, sort_order ASC'; |
|
830 |
$res = $GLOBALS['db']->query($sql); |
|
831 |
|
|
832 |
while ($row = $GLOBALS['db']->FetchRow($res)) |
|
833 |
{ |
|
834 |
if ($row['attr_index'] == 1 && $row['attr_input_type'] == 1) |
|
835 |
{ |
|
836 |
$row['attr_values'] = str_replace("\r", '', $row['attr_values']); |
|
837 |
$options = explode("\n", $row['attr_values']); |
|
838 |
|
|
839 |
$attr_value = array(); |
|
840 |
foreach ($options AS $opt) |
|
841 |
{ |
|
842 |
$attr_value[$opt] = $opt; |
|
843 |
} |
|
844 |
$attributes['attr'][] = array( |
|
845 |
'id' => $row['attr_id'], |
|
846 |
'attr' => $row['attr_name'], |
|
847 |
'options' => $attr_value, |
|
848 |
'type' => 3 |
|
849 |
); |
|
850 |
} |
|
851 |
else |
|
852 |
{ |
|
853 |
$attributes['attr'][] = array( |
|
854 |
'id' => $row['attr_id'], |
|
855 |
'attr' => $row['attr_name'], |
|
856 |
'type' => $row['attr_index'] |
|
857 |
); |
|
858 |
} |
|
859 |
} |
|
860 |
} |
|
861 |
|
|
862 |
return $attributes; |
|
863 |
} |
|
864 |
function get_evaluation_sum($goods_id) |
|
865 |
{ |
|
866 |
$sql = "SELECT count(*) FROM " . $GLOBALS['ecs']->table('comment') . " WHERE status=1 and comment_type =0 and id_value =".$goods_id ;//status=1表示通过了的评论才算 comment_type =0表示针对商品的评价 感谢zhangyh的提醒 |
|
867 |
return $GLOBALS['db']->getOne($sql); |
|
868 |
} |
|
869 |
?> |