-
Notifications
You must be signed in to change notification settings - Fork 1
/
feed.php
264 lines (230 loc) · 10.4 KB
/
feed.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<?php
/**
* ECSHOP RSS Feed 生成程序
* ============================================================================
* * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。
* 网站地址: http://www.ecshop.com;
* ----------------------------------------------------------------------------
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
* 使用;不允许对程序代码以任何形式任何目的的再发布。
* ============================================================================
* $Author: liubo $
* $Id: feed.php 17217 2011-01-19 06:29:08Z liubo $
*/
define('IN_ECS', true);
define('INIT_NO_USERS', true);
define('INIT_NO_SMARTY', true);
require(dirname(__FILE__) . '/includes/init.php');
require(ROOT_PATH . 'includes/cls_rss.php');
header('Content-Type: application/xml; charset=' . EC_CHARSET);
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Fri, 14 Mar 1980 20:53:00 GMT');
header('Last-Modified: ' . date('r'));
header('Pragma: no-cache');
$ver = isset($_REQUEST['ver']) ? $_REQUEST['ver'] : '2.00';
$cat = isset($_REQUEST['cat']) ? ' AND ' . get_children(intval($_REQUEST['cat'])) : '';
$brd = isset($_REQUEST['brand']) ? ' AND g.brand_id=' . intval($_REQUEST['brand']) . ' ' : '';
$uri = $ecs->url();
$rss = new RSSBuilder(EC_CHARSET, $uri, htmlspecialchars($_CFG['shop_name']), htmlspecialchars($_CFG['shop_desc']), $uri . 'animated_favicon.gif');
$rss->addDCdata('', 'http://www.ecshop.com', date('r'));
if (isset($_REQUEST['type']))
{
if($_REQUEST['type'] == 'group_buy')
{
$now = gmtime();
$sql = 'SELECT act_id, act_name, act_desc, start_time ' .
"FROM " . $GLOBALS['ecs']->table('goods_activity') .
"WHERE act_type = '" . GAT_GROUP_BUY . "' " .
"AND start_time <= '$now' AND is_finished < 3 ORDER BY start_time DESC";
$res = $db->query($sql);
if ($res !== false)
{
while ($row = $db->fetchRow($res))
{
$item_url = build_uri('group_buy', array('gbid' => $row['act_id']), $row['act_name']);
$separator = (strpos($item_url, '?') === false)? '?' : '&';
$about = $uri . $item_url;
$title = htmlspecialchars($row['act_name']);
$link = $uri . $item_url . $separator . 'from=rss';
$desc = htmlspecialchars($row['act_desc']);
$subject = $_LANG['group_buy'];
$date = local_date('r', $row['start_time']);
$rss->addItem($about, $title, $link, $desc, $subject, $date);
}
$rss->outputRSS($ver);
}
}
elseif($_REQUEST['type'] == 'snatch')
{
$now = gmtime();
$sql = 'SELECT act_id, act_name, act_desc, start_time ' .
"FROM " . $GLOBALS['ecs']->table('goods_activity') .
"WHERE act_type = '" . GAT_SNATCH . "' " .
"AND start_time <= '$now' AND is_finished < 3 ORDER BY start_time DESC";
$res = $db->query($sql);
if ($res !== false)
{
while ($row = $db->fetchRow($res))
{
$item_url = build_uri('snatch', array('sid' => $row['act_id']), $row['act_name']);
$separator = (strpos($item_url, '?') === false)? '?' : '&';
$about = $uri . $item_url;
$title = htmlspecialchars($row['act_name']);
$link = $uri . $item_url . $separator . 'from=rss';
$desc = htmlspecialchars($row['act_desc']);
$subject = $_LANG['snatch'];
$date = local_date('r', $row['start_time']);
$rss->addItem($about, $title, $link, $desc, $subject, $date);
}
$rss->outputRSS($ver);
}
}
elseif($_REQUEST['type'] == 'auction')
{
$now = gmtime();
$sql = 'SELECT act_id, act_name, act_desc, start_time ' .
"FROM " . $GLOBALS['ecs']->table('goods_activity') .
"WHERE act_type = '" . GAT_AUCTION . "' " .
"AND start_time <= '$now' AND is_finished < 3 ORDER BY start_time DESC";
$res = $db->query($sql);
if ($res !== false)
{
while ($row = $db->fetchRow($res))
{
$item_url = build_uri('auction', array('auid' => $row['act_id']), $row['act_name']);
$separator = (strpos($item_url, '?') === false)? '?' : '&';
$about = $uri . $item_url;
$title = htmlspecialchars($row['act_name']);
$link = $uri . $item_url . $separator . 'from=rss';
$desc = htmlspecialchars($row['act_desc']);
$subject = $_LANG['auction'];
$date = local_date('r', $row['start_time']);
$rss->addItem($about, $title, $link, $desc, $subject, $date);
}
$rss->outputRSS($ver);
}
}
elseif($_REQUEST['type'] == 'exchange')
{
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_brief, g.last_update ' .
"FROM " . $GLOBALS['ecs']->table('exchange_goods') . " AS eg, " .
$GLOBALS['ecs']->table('goods') . " AS g " .
"WHERE eg.goods_id = g.goods_id";
$res = $db->query($sql);
if ($res !== false)
{
while ($row = $db->fetchRow($res))
{
$item_url = build_uri('exchange_goods', array('gid' => $row['goods_id']), $row['goods_name']);
$separator = (strpos($item_url, '?') === false)? '?' : '&';
$about = $uri . $item_url;
$title = htmlspecialchars($row['goods_name']);
$link = $uri . $item_url . $separator . 'from=rss';
$desc = htmlspecialchars($row['goods_brief']);
$subject = $_LANG['exchange'];
$date = local_date('r', $row['last_update']);
$rss->addItem($about, $title, $link, $desc, $subject, $date);
}
$rss->outputRSS($ver);
}
}
elseif($_REQUEST['type'] == 'activity')
{
$now = gmtime();
$sql = 'SELECT act_id, act_name, start_time ' .
"FROM " . $GLOBALS['ecs']->table('favourable_activity') .
" WHERE start_time <= '$now' AND end_time >= '$now'";
$res = $db->query($sql);
if ($res !== false)
{
while ($row = $db->fetchRow($res))
{
$item_url = 'activity.php';
$separator = (strpos($item_url, '?') === false)? '?' : '&';
$about = $uri . $item_url;
$title = htmlspecialchars($row['act_name']);
$link = $uri . $item_url . $separator . 'from=rss';
$desc = '';
$subject = $_LANG['favourable'];
$date = local_date('r', $row['start_time']);
$rss->addItem($about, $title, $link, $desc, $subject, $date);
}
$rss->outputRSS($ver);
}
}
elseif($_REQUEST['type'] == 'package')
{
$now = gmtime();
$sql = 'SELECT act_id, act_name, act_desc, start_time ' .
"FROM " . $GLOBALS['ecs']->table('goods_activity') .
"WHERE act_type = '" . GAT_PACKAGE . "' " .
"AND start_time <= '$now' AND is_finished < 3 ORDER BY start_time DESC";
$res = $db->query($sql);
if ($res !== false)
{
while ($row = $db->fetchRow($res))
{
$item_url = 'package.php';
$separator = (strpos($item_url, '?') === false)? '?' : '&';
$about = $uri . $item_url;
$title = htmlspecialchars($row['act_name']);
$link = $uri . $item_url . $separator . 'from=rss';
$desc = htmlspecialchars($row['act_desc']);
$subject = $_LANG['remark_package'];
$date = local_date('r', $row['start_time']);
$rss->addItem($about, $title, $link, $desc, $subject, $date);
}
$rss->outputRSS($ver);
}
}
elseif(substr($_REQUEST['type'], 0, 11) == 'article_cat')
{
$sql = 'SELECT article_id, title, author, add_time' .
' FROM ' .$GLOBALS['ecs']->table('article') .
' WHERE is_open = 1 AND ' . get_article_children(substr($_REQUEST['type'], 11)) .
' ORDER BY add_time DESC LIMIT ' . $_CFG['article_page_size'];
$res = $db->query($sql);
if ($res !== false)
{
while ($row = $db->fetchRow($res))
{
$item_url = build_uri('article', array('aid' => $row['article_id']), $row['title']);
$separator = (strpos($item_url, '?') === false)? '?' : '&';
$about = $uri . $item_url;
$title = htmlspecialchars($row['title']);
$link = $uri . $item_url . $separator . 'from=rss';
$desc = '';
$subject = htmlspecialchars($row['author']);
$date = local_date('r', $row['add_time']);
$rss->addItem($about, $title, $link, $desc, $subject, $date);
}
$rss->outputRSS($ver);
}
}
}
else
{
$in_cat = $cat > 0 ? ' AND ' . get_children($cat) : '';
$sql = 'SELECT c.cat_name, g.goods_id, g.goods_name, g.goods_brief, g.last_update ' .
'FROM ' . $ecs->table('category') . ' AS c, ' . $ecs->table('goods') . ' AS g ' .
'WHERE c.cat_id = g.cat_id AND g.is_delete = 0 AND g.is_alone_sale = 1 ' . $brd . $cat .
'ORDER BY g.last_update DESC';
$res = $db->query($sql);
if ($res !== false)
{
while ($row = $db->fetchRow($res))
{
$item_url = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
$separator = (strpos($item_url, '?') === false)? '?' : '&';
$about = $uri . $item_url;
$title = htmlspecialchars($row['goods_name']);
$link = $uri . $item_url . $separator . 'from=rss';
$desc = htmlspecialchars($row['goods_brief']);
$subject = htmlspecialchars($row['cat_name']);
$date = local_date('r', $row['last_update']);
$rss->addItem($about, $title, $link, $desc, $subject, $date);
}
$rss->outputRSS($ver);
}
}
?>