forked from imadqbil/Webid_DEV
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
299 lines (273 loc) · 9.9 KB
/
index.php
File metadata and controls
299 lines (273 loc) · 9.9 KB
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
<?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';
// Run cron according to SETTINGS
if ($system->SETTINGS['cron'] == 2)
{
include_once 'cron.php';
}
if ($system->SETTINGS['loginbox'] == 1 && $system->SETTINGS['https'] == 'y' && $_SERVER['HTTPS'] != 'on')
{
$sslurl = str_replace('http://', 'https://', $system->SETTINGS['siteurl']);
$sslurl = (!empty($system->SETTINGS['https_url'])) ? $system->SETTINGS['https_url'] : $sslurl;
header('Location: ' . $sslurl . 'index.php');
exit;
}
$NOW = time();
function ShowFlags()
{
global $system, $LANGUAGES;
$counter = 0;
$flags = '';
foreach ($LANGUAGES as $lang => $value)
{
if ($counter > 3)
{
$flags .= '<br>';
$counter = 0;
}
$flags .= '<a href="?lan=' . $lang . '"><img vspace="2" hspace="2" src="' . $system->SETTINGS['siteurl'] . 'includes/flags/' . $lang . '.gif" border="0" alt="' . $lang . '"></a>';
$counter++;
}
return $flags;
}
// prepare categories list for templates/template
// Prepare categories sorting
if ($system->SETTINGS['catsorting'] == 'alpha')
{
$catsorting = ' ORDER BY cat_name ASC';
}
else
{
$catsorting = ' ORDER BY sub_counter DESC';
}
$query = "SELECT cat_id FROM " . $DBPrefix . "categories WHERE parent_id = -1";
$res = mysql_query($query);
$system->check_mysql($res, $query, __LINE__, __FILE__);
$query = "SELECT * FROM " . $DBPrefix . "categories
WHERE parent_id = " . mysql_result($res, 0) . "
" . $catsorting . "
LIMIT " . $system->SETTINGS['catstoshow'];
$res = mysql_query($query);
$system->check_mysql($res, $query, __LINE__, __FILE__);
while ($row = mysql_fetch_assoc($res))
{
$template->assign_block_vars('cat_list', array(
'CATAUCNUM' => ($row['sub_counter'] != 0) ? '(' . $row['sub_counter'] . ')' : '',
'ID' => $row['cat_id'],
'IMAGE' => (!empty($row['cat_image'])) ? '<img src="' . $row['cat_image'] . '" border=0>' : '',
'COLOUR' => (empty($row['cat_colour'])) ? '#FFFFFF' : $row['cat_colour'],
'NAME' => $category_names[$row['cat_id']]
));
}
// get featured items
$query = "SELECT id, title, current_bid, pict_url, ends, num_bids, minimum_bid, bn_only, buy_now
FROM " . $DBPrefix . "auctions
WHERE closed = 0 AND suspended = 0 AND starts <= " . $NOW . "
AND featured = 'y'
ORDER BY RAND() DESC LIMIT 12";
$res = mysql_query($query);
$system->check_mysql($res, $query, __LINE__, __FILE__);
while($row = mysql_fetch_assoc($res))
{
$ends = $row['ends'];
$difference = $ends - time();
if ($difference > 0)
{
$ends_string = FormatTimeLeft($difference);
}
else
{
$ends_string = $MSG['911'];
}
$high_bid = ($row['num_bids'] == 0) ? $row['minimum_bid'] : $row['current_bid'];
$high_bid = ($row['bn_only'] == 'y') ? $row['buy_now'] : $high_bid;
$template->assign_block_vars('featured', array(
'ENDS' => $ends_string,
'ID' => $row['id'],
'BID' => $system->print_money($high_bid),
'IMAGE' => (!empty($row['pict_url'])) ? 'getthumb.php?w=' . $system->SETTINGS['thumb_show'] . '&fromfile=' . $uploaded_path . $row['id'] . '/' . $row['pict_url'] : 'images/email_alerts/default_item_img.jpg',
'TITLE' => $row['title']
));
}
// get last created auctions
$query = "SELECT id, title, pict_url, starts from " . $DBPrefix . "auctions
WHERE closed = 0 AND suspended = 0
AND starts <= " . $NOW . "
ORDER BY starts DESC
LIMIT " . $system->SETTINGS['lastitemsnumber'];
$res = mysql_query($query);
$system->check_mysql($res, $query, __LINE__, __FILE__);
$i = 0;
while ($row = mysql_fetch_assoc($res))
{
$template->assign_block_vars('auc_last', array(
'BGCOLOUR' => (!($i % 2)) ? '' : 'class="alt-row"',
'DATE' => ArrangeDateNoCorrection($row['starts'] + $system->tdiff),
//added by L
'IMAGE' => (!empty($row['pict_url'])) ? 'getthumb.php?w=' . $system->SETTINGS['thumb_show'] . '&fromfile=' . $uploaded_path . $row['id'] . '/' . $row['pict_url'] : 'images/email_alerts/default_item_img.jpg',
//
'ID' => $row['id'],
'TITLE' => $row['title']
));
$i++;
}
$auc_last = ($i > 0) ? true : false;
// get ending soon auctions
$query = "SELECT ends, id, pict_url, title FROM " . $DBPrefix . "auctions
WHERE closed = 0 AND suspended = 0 AND starts <= " . $NOW . "
ORDER BY ends LIMIT " . $system->SETTINGS['endingsoonnumber'];
$res = mysql_query($query);
$system->check_mysql($res, $query, __LINE__, __FILE__);
$i = 0;
while ($row = mysql_fetch_assoc($res))
{
$ends = $row['ends'];
$difference = $ends - time();
if ($difference > 0)
{
$ends_string = FormatTimeLeft($difference);
}
else
{
$ends_string = $MSG['911'];
}
$template->assign_block_vars('end_soon', array(
'BGCOLOUR' => (!($i % 2)) ? '' : 'class="alt-row"',
'DATE' => $ends_string, //Used for customers not using any javascript.
'TIMELEFT' => $difference, //Used for customers that are using javascript.
'ID' => $row['id'],
//added by L
'IMAGE' => (!empty($row['pict_url'])) ? 'getthumb.php?w=' . $system->SETTINGS['thumb_show'] . '&fromfile=' . $uploaded_path . $row['id'] . '/' . $row['pict_url'] : 'images/email_alerts/default_item_img.jpg',
//
'TITLE' => $row['title']
));
$i++;
}
$end_soon = ($i > 0) ? true : false;
// get hot items
$query = "SELECT a.id, a.title, a.current_bid, a.pict_url, a.ends, a.num_bids, a.minimum_bid
FROM " . $DBPrefix . "auctions a
LEFT JOIN " . $DBPrefix . "auccounter c ON (a.id = c.auction_id)
WHERE closed = 0 AND suspended = 0 AND starts <= " . $NOW . "
ORDER BY c.counter DESC LIMIT " . $system->SETTINGS['hotitemsnumber'];
$res = mysql_query($query);
$system->check_mysql($res, $query, __LINE__, __FILE__);
$i = 0;
while ($row = mysql_fetch_assoc($res))
{
$i++;
$ends = $row['ends'];
$difference = $ends - time();
if ($difference > 0)
{
$ends_string = FormatTimeLeft($difference);
}
else
{
$ends_string = $MSG['911'];
}
$high_bid = ($row['num_bids'] == 0) ? $row['minimum_bid'] : $row['current_bid'];
$template->assign_block_vars('hotitems', array(
'ENDS' => $ends_string,
'TIMELEFT' => $difference,
'ID' => $row['id'],
'BID' => $system->print_money($high_bid),
'IMAGE' => (!empty($row['pict_url'])) ? 'getthumb.php?w=' . $system->SETTINGS['thumb_show'] . '&fromfile=' . $uploaded_path . $row['id'] . '/' . $row['pict_url'] : 'images/email_alerts/default_item_img.jpg',
'TITLE' => $row['title']
));
}
$hot_items = ($i > 0) ? true : false;
//finished auctions
$query = "SELECT a.id, a.title, a.current_bid, a.pict_url, a.ends, a.num_bids, a.minimum_bid
FROM " . $DBPrefix . "auctions a
LEFT JOIN " . $DBPrefix . "auccounter c ON (a.id = c.auction_id)
WHERE closed = 1 AND suspended = 0
LIMIT " . 10;
$res = mysql_query($query);
$system->check_mysql($res, $query, __LINE__, __FILE__);
$i = 0;
while ($row = mysql_fetch_assoc($res))
{
$i++;
$ends = $row['ends'];
$difference = $ends - time();
if ($difference > 0)
{
$ends_string = FormatTimeLeft($difference);
}
else
{
$ends_string = $MSG['911'];
}
$high_bid = ($row['num_bids'] == 0) ? $row['minimum_bid'] : $row['current_bid'];
$template->assign_block_vars('ended', array(
'ENDS' => $ends_string,
'TIMELEFT' => $difference,
'ID' => $row['id'],
'BID' => $system->print_money($high_bid),
'IMAGE' => (!empty($row['pict_url'])) ? 'getthumb.php?w=' . $system->SETTINGS['thumb_show'] . '&fromfile=' . $uploaded_path . $row['id'] . '/' . $row['pict_url'] : 'images/email_alerts/default_item_img.jpg',
'TITLE' => $row['title']
));
}
// Build list of help topics
$query = "SELECT id, category FROM " . $DBPrefix . "faqscat_translated WHERE lang = '" . $language . "' ORDER BY category ASC";
$res = mysql_query($query);
$system->check_mysql($res, $query, __LINE__, __FILE__);
$i = 0;
while ($faqscat = mysql_fetch_assoc($res))
{
$template->assign_block_vars('helpbox', array(
'ID' => $faqscat['id'],
'TITLE' => $faqscat['category']
));
$i++;
}
$helpbox = ($i > 0) ? true : false;
// Build news list
if ($system->SETTINGS['newsbox'] == 1)
{
$query = "SELECT n.title As t, n.new_date, t.* FROM " . $DBPrefix . "news n
LEFT JOIN " . $DBPrefix . "news_translated t ON (t.id = n.id)
WHERE t.lang = '" . $language . "' AND n.suspended = 0
ORDER BY new_date DESC, id DESC LIMIT " . $system->SETTINGS['newstoshow'];
$res = mysql_query($query);
$system->check_mysql($res, $query, __LINE__, __FILE__);
while ($new = mysql_fetch_assoc($res))
{
$template->assign_block_vars('newsbox', array(
'ID' => $new['id'],
'DATE' => FormatDate($new['new_date']),
'TITLE' => (!empty($new['title'])) ? $new['title'] : $new['t']
));
}
}
$template->assign_vars(array(
'FLAGS' => ShowFlags(),
'B_AUC_LAST' => $auc_last,
'B_HOT_ITEMS' => $hot_items,
'B_AUC_ENDSOON' => $end_soon,
'B_HELPBOX' => ($helpbox && $system->SETTINGS['helpbox'] == 1),
'B_MULT_LANGS' => (count($LANGUAGES) > 1),
'B_LOGIN_BOX' => ($system->SETTINGS['loginbox'] == 1),
'B_NEWS_BOX' => ($system->SETTINGS['newsbox'] == 1)
));
include 'header.php';
$template->set_filenames(array(
'body' => 'home.tpl'
));
$template->display('body');
include 'footer.php';
unset($_SESSION['loginerror']);
?>