commit | author | age
|
3e083b
|
1 |
<?php |
B |
2 |
|
|
3 |
/** |
|
4 |
* 文章分类 |
|
5 |
*/ |
|
6 |
|
|
7 |
|
|
8 |
define('IN_ECS', true); |
|
9 |
|
|
10 |
require(dirname(__FILE__) . '/includes/init.php'); |
|
11 |
|
|
12 |
if ((DEBUG_MODE & 2) != 2) |
|
13 |
{ |
|
14 |
$smarty->caching = true; |
|
15 |
} |
|
16 |
|
|
17 |
/* 清除缓存 */ |
|
18 |
clear_cache_files(); |
|
19 |
|
|
20 |
/*------------------------------------------------------ */ |
|
21 |
//-- INPUT |
|
22 |
/*------------------------------------------------------ */ |
|
23 |
|
|
24 |
/* 获得指定的分类ID */ |
|
25 |
|
|
26 |
// change_start |
|
27 |
|
|
28 |
if (!empty($_GET['id']) && preg_match('/^-?[1-9]\d*$/', $_REQUEST['id'])) |
|
29 |
{ |
|
30 |
$cat_id = intval($_GET['id']); |
|
31 |
} |
|
32 |
elseif (!empty($_GET['category']) && preg_match('/^-?[1-9]\d*$/', $_REQUEST['category'])) |
|
33 |
{ |
|
34 |
$cat_id = intval($_GET['category']); |
|
35 |
} |
|
36 |
|
|
37 |
// change_end |
|
38 |
else |
|
39 |
{ |
|
40 |
ecs_header("Location: ./\n"); |
|
41 |
|
|
42 |
exit; |
|
43 |
} |
|
44 |
|
|
45 |
/* 获得当前页码 */ |
|
46 |
$page = !empty($_REQUEST['page']) && intval($_REQUEST['page']) > 0 ? intval($_REQUEST['page']) : 1; |
|
47 |
|
|
48 |
/*------------------------------------------------------ */ |
|
49 |
|
|
50 |
/* 获得页面的缓存ID */ |
|
51 |
$cache_id = sprintf('%X', crc32($cat_id . '-' . $page . '-' . $_CFG['lang'])); |
|
52 |
|
|
53 |
if (!$smarty->is_cached('article_cat.dwt', $cache_id)) |
|
54 |
{ |
|
55 |
/* 如果页面没有被缓存则重新获得页面的内容 */ |
|
56 |
|
|
57 |
assign_template('a', array($cat_id)); |
|
58 |
$position = assign_ur_here($cat_id); |
|
59 |
$smarty->assign('page_title', $position['title']); // 页面标题 |
|
60 |
$smarty->assign('ur_here', $position['ur_here']); // 当前位置 |
|
61 |
|
|
62 |
$smarty->assign('categories', get_categories_tree(0)); // 分类树 |
|
63 |
$smarty->assign('article_categories', article_categories_tree()); //文章分类树 |
|
64 |
$smarty->assign('helps', get_shop_help()); // 网店帮助 |
|
65 |
$smarty->assign('top_goods', get_top10()); // 销售排行 |
|
66 |
$smarty->assign('best_goods', get_recommend_goods('best')); |
|
67 |
$smarty->assign('new_goods', get_recommend_goods('new')); |
|
68 |
$smarty->assign('hot_goods', get_recommend_goods('hot')); |
|
69 |
$smarty->assign('promotion_goods', get_promote_goods()); |
|
70 |
$smarty->assign('promotion_info', get_promotion_info()); |
|
71 |
$smarty->assign('cat_id', get_cat_id_art($article_id)); |
|
72 |
|
|
73 |
/* Meta */ |
|
74 |
$meta = $db->getRow("SELECT keywords, cat_desc FROM " . $ecs->table('article_cat') . " WHERE cat_id = '$cat_id'"); |
|
75 |
|
|
76 |
if ($meta === false || empty($meta)) |
|
77 |
{ |
|
78 |
/* 如果没有找到任何记录则返回首页 */ |
|
79 |
ecs_header("Location: ./\n"); |
|
80 |
exit; |
|
81 |
} |
|
82 |
|
|
83 |
$smarty->assign('keywords', htmlspecialchars($meta['keywords'])); |
|
84 |
$smarty->assign('description', htmlspecialchars($meta['cat_desc'])); |
|
85 |
|
|
86 |
/* 获得文章总数 */ |
|
87 |
$size = isset($_CFG['article_page_size']) && intval($_CFG['article_page_size']) > 0 ? intval($_CFG['article_page_size']) : 20; |
|
88 |
$count = get_article_count($cat_id); |
|
89 |
$pages = ($count > 0) ? ceil($count / $size) : 1; |
|
90 |
|
|
91 |
if ($page > $pages) |
|
92 |
{ |
|
93 |
$page = $pages; |
|
94 |
} |
|
95 |
$pager['search']['id'] = $cat_id; |
|
96 |
$keywords = ''; |
|
97 |
$goon_keywords = ''; //继续传递的搜索关键词 |
|
98 |
|
|
99 |
/* 获得文章列表 */ |
|
100 |
if (isset($_REQUEST['keywords'])) |
|
101 |
{ |
|
102 |
$keywords = addslashes(htmlspecialchars(urldecode(trim($_REQUEST['keywords'])))); |
|
103 |
$pager['search']['keywords'] = $keywords; |
|
104 |
$search_url = substr(strrchr($_POST['cur_url'], '/'), 1); |
|
105 |
|
|
106 |
$smarty->assign('search_value', stripslashes(stripslashes($keywords))); |
|
107 |
$smarty->assign('search_url', $search_url); |
|
108 |
$count = get_article_count($cat_id, $keywords); |
|
109 |
$pages = ($count > 0) ? ceil($count / $size) : 1; |
|
110 |
if ($page > $pages) |
|
111 |
{ |
|
112 |
$page = $pages; |
|
113 |
} |
|
114 |
|
|
115 |
$goon_keywords = urlencode($_REQUEST['keywords']); |
|
116 |
} |
|
117 |
|
|
118 |
|
|
119 |
/* start */ |
|
120 |
$search_url = "article_cat.php?id=$cat_id"; |
|
121 |
$smarty->assign('search_url', $search_url); |
|
122 |
/* end */ |
|
123 |
|
|
124 |
|
|
125 |
$smarty->assign('artciles_list', get_cat_articles($cat_id, $page, $size ,$keywords)); |
|
126 |
$smarty->assign('cat_id', $cat_id); |
|
127 |
/* 分页 */ |
|
128 |
assign_pager('article_cat', $cat_id, $count, $size, '', '', $page, $goon_keywords); |
|
129 |
assign_dynamic('article_cat'); |
|
130 |
} |
|
131 |
|
|
132 |
$smarty->assign('feed_url', ($_CFG['rewrite'] == 1) ? "feed-typearticle_cat" . $cat_id . ".xml" : 'feed.php?type=article_cat' . $cat_id); // RSS URL |
|
133 |
|
|
134 |
$smarty->display('article_cat.dwt', $cache_id); |
|
135 |
function get_cat_id_art($article_id){ |
|
136 |
$sql = "select cat_id from " .$GLOBALS['ecs']->table('article'). " where article_id = '$article_id'"; |
|
137 |
$a = $GLOBALS['db']->getOne($sql); |
|
138 |
$sql = "select parent_id from" .$GLOBALS['ecs']->table('article_cat'). " where cat_id = '$a'"; |
|
139 |
return $GLOBALS['db']->getOne($sql); |
|
140 |
} |
|
141 |
|
|
142 |
/* 增加_start */ |
|
143 |
make_html(); |
|
144 |
/* 增加_end*/ |
|
145 |
?> |