commit | author | age
|
3e083b
|
1 |
<?php |
B |
2 |
|
|
3 |
/** |
|
4 |
* ajax |
|
5 |
*/ |
|
6 |
|
|
7 |
define('IN_ECS', true); |
|
8 |
|
|
9 |
require(dirname(__FILE__) . '/includes/init.php'); |
|
10 |
|
|
11 |
if ($_REQUEST['act'] == 'tipword') |
|
12 |
{ |
|
13 |
require(ROOT_PATH . 'includes/cls_json.php'); |
|
14 |
$word_com = json_str_iconv($_REQUEST['word']); |
|
15 |
$json_com = new JSON; |
|
16 |
$result_com = array('error' => 0, 'message' => '', 'content' => ''); |
|
17 |
|
|
18 |
if(!$word_com || strlen($word_com) < 2 || strlen($word_com) > 30) |
|
19 |
{ |
|
20 |
$result_com['error'] = 1; |
|
21 |
die($json_com->encode($result_com)); |
|
22 |
} |
|
23 |
$needle = $replace = array(); |
|
24 |
$word_com = str_replace(array(' ','*', "\'"), array('%', '%', ''), $word_com); |
|
25 |
$needle[] = $word_com; |
|
26 |
$replace[] = '<strong style="color:cc0000;">'.$word_com.'</strong>'; |
|
27 |
$logdb = array(); |
|
28 |
if(preg_match("/^[a-z0-9A-Z]+$/", $word_com)) { |
|
29 |
$sql_qq = "SELECT * FROM " . $ecs->table('keyword') ." WHERE searchengine='ecshop' AND status='1' AND letter LIKE '%$word_com%' ORDER BY total_search DESC"; |
|
30 |
} else { |
|
31 |
$sql_qq = "SELECT * FROM " . $ecs->table('keyword') ." WHERE searchengine='ecshop' AND status='1' AND word LIKE '%$word_com%' ORDER BY total_search DESC"; |
|
32 |
} |
|
33 |
$res_www_68ecshop_com = $db->SelectLimit($sql_qq, 10, 0); |
|
34 |
|
|
35 |
$iii=1; |
|
36 |
while ($rows_www_68ecshop_com = $db->fetchRow($res_www_68ecshop_com)) |
|
37 |
{ |
|
38 |
$rows_www_68ecshop_com['kword'] = str_ireplace($needle, $replace, $rows_www_68ecshop_com['word']); |
|
39 |
|
|
40 |
/* start */ |
|
41 |
if($iii==1 && $rows_www_68ecshop_com['keyword_cat_count']) |
|
42 |
{ |
|
43 |
$rows_www_68ecshop_com['keyword_cat'] = '<a href="' . $rows_www_68ecshop_com['keyword_cat_url'] . '"><font color=#666>在<font color=#cc0000>'. $rows_www_68ecshop_com['keyword_cat'] .'</font>分类中搜索</font></a>'; |
|
44 |
$rows_www_68ecshop_com['keyword_cat_count'] = intval($rows_www_68ecshop_com['keyword_cat_count']); |
|
45 |
} |
|
46 |
$iii=$iii+1; |
|
47 |
/* end */ |
|
48 |
|
|
49 |
$logdb[] = $rows_www_68ecshop_com; |
|
50 |
|
|
51 |
|
|
52 |
} |
|
53 |
$smarty->assign('logdb', $logdb); |
|
54 |
$result_com['content'] = $smarty->fetch('library/search_tip.lbi'); |
|
55 |
die($json_com->encode($result_com)); |
|
56 |
} |
|
57 |
?> |