forked from renlok/WeBid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rss.php
157 lines (138 loc) · 5.17 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
<?php
/***************************************************************************
* copyright : (C) 2008 - 2013 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';
$NOW = time();
$p24h = time() + (24 * 60 * 60);
$m24h = time() - (24 * 60 * 60);
$catscontrol = new MPTTcategories();
$user_id = (isset($_REQUEST['user_id'])) ? intval($_REQUEST['user_id']) : 0;
$limit = ' LIMIT ' . $system->SETTINGS['perpage'];
$feed = (isset($_GET['feed'])) ? intval($_GET['feed']) : '';
switch ($feed)
{
case 1:
$RSStitle = $MSG['924']; // items listed in the last 24 hours
$postdate = 'starts';
$sort = 'DESC';
$subquery = 'a.starts <= ' . $NOW . ' AND a.starts > ' . $m24h;
break;
case 2:
$RSStitle = $MSG['925']; // items closing in 24 hours or less
$postdate = 'ends';
$sort = 'ASC';
$subquery = 'a.starts <= ' . $NOW . ' AND a.ends <= ' . $p24h;
break;
case 3:
$RSStitle = $MSG['926']; // items over 300.00
$postdate = 'ends';
$sort = 'ASC';
$subquery = 'a.starts <= ' . $NOW . ' 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 <= ' . $NOW . ' 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 <= ' . $NOW . ' 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 <= ' . $NOW . ' AND a.num_bids >= 10';
break;
case 7:
$RSStitle = $MSG['930']; // items with 25 or more bids
$postdate = 'starts';
$sort = 'DESC';
$subquery = 'a.starts <= ' . $NOW . ' AND a.num_bids >= 25';
break;
case 8:
$RSStitle = $MSG['931']; // item with a Buy Now
$postdate = 'starts';
$sort = 'DESC';
$subquery = 'a.starts <= ' . $NOW . ' AND a.buy_now > 0';
break;
default:
$postdate = 'starts';
if ($user_id > 0)
{
$query = "SELECT nick FROM " . $DBPrefix . "users WHERE id = " . $user_id;
$res = mysql_query($query);
$system->check_mysql($res, $query, __LINE__, __FILE__);
$username = mysql_result($res, 0, 'nick');
$sort = 'DESC';
$subquery = 'a.starts <= ' . $NOW . ' AND a.ends > ' . $NOW . ' AND a.user = ' . $user_id;
$RSStitle = sprintf($MSG['932'], $username);
}
else
{
$RSStitle = $MSG['924'];
$sort = 'DESC';
$subquery = 'a.starts <= ' . $NOW . ' AND a.starts > ' . $m24h;
}
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;
$res = mysql_query($query);
$system->check_mysql($res, $query, __LINE__, __FILE__);
while ($auction_data = mysql_fetch_assoc($res))
{
$query = "SELECT left_id, right_id, level FROM " . $DBPrefix . "categories WHERE cat_id = " . $auction_data['category'];
$res_ = mysql_query($query);
$system->check_mysql($res_, $query, __LINE__, __FILE__);
$parent_node = mysql_fetch_assoc($res_);
$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'])),
'TITLE' => $system->uncleanvars($auction_data['title']),
'URL' => $system->SETTINGS['siteurl'] . 'item.php?id=' . $auction_data['id'],
'DESC' => $auction_data['description'],
'USER' => $auction_data['nick'],
'POSTED' => gmdate('Y-m-d\TH:i:s-00:00', $auction_data['starts']),
//'POSTED' => gmdate('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'],
'RSSTITLE' => $RSStitle
));
$template->set_filenames(array(
'body' => 'rss.tpl'
));
$template->display('body');
?>