This repository has been archived by the owner on Sep 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 125
/
rss.php
158 lines (137 loc) · 6.21 KB
/
rss.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
<?php
/***************************************************************************
* copyright : (C) 2008 - 2017 WeBid
* site : http://www.webidsupport.com/
***************************************************************************/
/***************************************************************************
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. Although none of the code may be
* sold. If you have been sold this script, get a refund.
***************************************************************************/
include 'common.php';
include MAIN_PATH . 'language/' . $language . '/categories.inc.php';
$yesterday = (new DateTime('- 1 day', $dt->UTCtimezone))->format('Y-m-d H:i:s');
$tomorrow = (new DateTime('+ 1 day', $dt->UTCtimezone))->format('Y-m-d H:i:s');
$catscontrol = new MPTTcategories();
$user_id = (isset($_REQUEST['user_id'])) ? intval($_REQUEST['user_id']) : 0;
$feed = (isset($_GET['feed'])) ? intval($_GET['feed']) : '';
$params = array();
switch ($feed) {
case 1:
$RSStitle = $MSG['924']; // items listed in the last 24 hours
$postdate = 'starts';
$sort = 'DESC';
$subquery = 'a.starts <= CURRENT_TIMESTAMP AND a.starts > :starts';
$params[] = array(':starts', $yesterday, 'str');
break;
case 2:
$RSStitle = $MSG['925']; // items closing in 24 hours or less
$postdate = 'ends';
$sort = 'ASC';
$subquery = 'a.starts <= CURRENT_TIMESTAMP AND a.ends <= :ends';
$params[] = array(':ends', $tomorrow, 'str');
break;
case 3:
$RSStitle = $MSG['926']; // items over 300.00
$postdate = 'ends';
$sort = 'ASC';
$subquery = 'a.starts <= CURRENT_TIMESTAMP AND (a.current_bid >= 300 OR a.minimum_bid >= 300 OR a.buy_now >= 300)';
break;
case 4:
$RSStitle = $MSG['927']; // items over 1000.00
$postdate = 'ends';
$sort = 'ASC';
$subquery = 'a.starts <= CURRENT_TIMESTAMP AND (a.current_bid >= 1000 OR a.minimum_bid >= 1000 OR a.buy_now >= 1000)';
break;
case 5:
$RSStitle = $MSG['928'];
$postdate = 'starts';
$sort = 'DESC';
$subquery = 'a.starts <= CURRENT_TIMESTAMP AND (a.current_bid <= 10 OR a.buy_now <= 10)';
break;
case 6:
$RSStitle = $MSG['929']; // items with 10 or more bids
$postdate = 'starts';
$sort = 'DESC';
$subquery = 'a.starts <= CURRENT_TIMESTAMP AND a.num_bids >= 10';
break;
case 7:
$RSStitle = $MSG['930']; // items with 25 or more bids
$postdate = 'starts';
$sort = 'DESC';
$subquery = 'a.starts <= CURRENT_TIMESTAMP AND a.num_bids >= 25';
break;
case 8:
$RSStitle = $MSG['931']; // item with a Buy Now
$postdate = 'starts';
$sort = 'DESC';
$subquery = 'a.starts <= CURRENT_TIMESTAMP AND a.buy_now > 0';
break;
default:
$postdate = 'starts';
if ($user_id > 0) {
$query = "SELECT nick FROM " . $DBPrefix . "users WHERE id = :user_id";
$db->query($query, array(array(':user_id', $user_id, 'int')));
$username = $db->result('nick');
$RSStitle = sprintf($MSG['932'], $username);
$sort = 'DESC';
$subquery = 'a.starts <= CURRENT_TIMESTAMP AND a.ends > CURRENT_TIMESTAMP AND a.user = :user_id';
$params[] = array(':user_id', $user_id, 'int');
} else {
$RSStitle = $MSG['924'];
$sort = 'DESC';
$subquery = 'a.starts <= CURRENT_TIMESTAMP AND a.starts > :starts';
$params[] = array(':starts', $yesterday, 'str');
}
break;
}
$query = "SELECT a.*, u.nick from " . $DBPrefix . "auctions a
LEFT JOIN " . $DBPrefix . "users u ON (u.id = a.user)
WHERE a.closed = 0 AND a.suspended = 0 AND " . $subquery . "
ORDER BY " . $postdate . " " . $sort . " LIMIT :perpage";
$params[] = array(':perpage', $system->SETTINGS['perpage'], 'int');
$db->query($query, $params);
$aution_data_all = $db->fetchall();
foreach ($aution_data_all as $auction_data) {
$query = "SELECT left_id, right_id, level FROM " . $DBPrefix . "categories WHERE cat_id = :cat_id";
$params = array(
array(':cat_id', $auction_data['category'], 'int'),
);
$db->query($query, $params);
$parent_node = $db->result();
$cat_value = '';
$crumbs = $catscontrol->get_bread_crumbs($parent_node['left_id'], $parent_node['right_id']);
for ($i = 0; $i < count($crumbs); $i++) {
if ($crumbs[$i]['cat_id'] > 0) {
if ($i > 0) {
$cat_value .= ' / ';
}
$cat_value .= '<a href="' . $system->SETTINGS['siteurl'] . 'browse.php?id=' . $crumbs[$i]['cat_id'] . '">' . $category_names[$crumbs[$i]['cat_id']] . '</a>';
}
}
$template->assign_block_vars('rss', array(
'PRICE' => str_replace(array('<b>', '</b>'), '', $system->print_money(($auction_data['num_bids'] == 0) ? $auction_data['minimum_bid'] : $auction_data['current_bid'], true, false)),
'TITLE' => htmlspecialchars($auction_data['title']),
'URL' => $system->SETTINGS['siteurl'] . 'item.php?id=' . $auction_data['id'],
'DESC' => $auction_data['description'],
'USER' => $auction_data['nick'],
'POSTED' => $dt->formatDate($auction_data['starts'], 'Y-m-d\TH:i:s-00:00'),
//'POSTED' => date('D, j M Y H:i:s \G\M\T', $auction_data['starts']),
'CAT' => $cat_value
));
}
$template->assign_vars(array(
'XML' => '<?xml version="1.0" encoding="' . $CHARSET . '"?>', //as the template parser doesnt like <? tags
'PAGE_TITLE' => $system->SETTINGS['sitename'],
'SITEURL' => $system->SETTINGS['siteurl'],
'DESCRIPTIONTAG' => $system->SETTINGS['descriptiontag'],
'FEED' => $feed,
'RSSTITLE' => $RSStitle
));
header('Content-Type: application/rss+xml;charset= ' . $CHARSET);
$template->set_filenames(array(
'body' => 'rss.tpl'
));
$template->display('body');