forked from sumatej/WeBid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
yourauctions_s.php
168 lines (151 loc) · 6.51 KB
/
yourauctions_s.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
<?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';
$user_message = '';
// If user is not logged in redirect to login page
if (!$user->checkAuth()) {
$_SESSION['LOGIN_MESSAGE'] = $MSG['5000'];
$_SESSION['REDIRECT_AFTER_LOGIN'] = 'yourauctions_s.php';
header('location: user_login.php');
exit;
}
// check if the user can access this page
$user->checkSuspended();
// DELETE OR CLOSE OPEN AUCTIONS
if (isset($_POST['action']) && $_POST['action'] == 'delopenauctions') {
if (isset($_POST['O_delete']) && is_array($_POST['O_delete']) && count($_POST['O_delete']) > 0) {
foreach ($_POST['O_delete'] as $k => $v) {
$removed = 0;
$v = intval($v);
// Pictures Gallery
if (is_dir(UPLOAD_PATH . $v)) {
if ($dir = opendir(UPLOAD_PATH . $v)) {
while ($file = readdir($dir)) {
if ($file != '.' && $file != '..') {
@unlink(UPLOAD_PATH . $v . '/' . $file);
}
}
closedir($dir);
rmdir(UPLOAD_PATH . $v);
}
}
// remove auction
$query = "DELETE FROM " . $DBPrefix . "auctions WHERE id = :auc_id";
$params = array();
$params[] = array(':auc_id', $v, 'int');
$db->query($query, $params);
$removed++;
}
$query = "UPDATE " . $DBPrefix . "counters SET auctions = (auctions - :removed)";
$params = array();
$params[] = array(':removed', $removed, 'int');
$db->query($query, $params);
$user_message .= sprintf($MSG['1145'], count($_POST['O_delete']));
}
}
// Retrieve active auctions from the database
$query = "SELECT count(id) as COUNT FROM " . $DBPrefix . "auctions WHERE user = :user_id AND suspended != 0";
$params = array();
$params[] = array(':user_id', $user->user_data['id'], 'int');
$db->query($query, $params);
$TOTALAUCTIONS = $db->result('COUNT');
if (!isset($_GET['PAGE']) || $_GET['PAGE'] < 0 || empty($_GET['PAGE'])) {
$OFFSET = 0;
$PAGE = 1;
} else {
$PAGE = intval($_GET['PAGE']);
$OFFSET = ($PAGE - 1) * $system->SETTINGS['perpage'];
}
$PAGES = ($TOTALAUCTIONS == 0) ? 1 : ceil($TOTALAUCTIONS / $system->SETTINGS['perpage']);
// Handle columns sorting variables
if (!isset($_SESSION['sa_ord']) && empty($_GET['sa_ord'])) {
$_SESSION['sa_ord'] = 'title';
$_SESSION['sa_type'] = 'asc';
} elseif (!empty($_GET['sa_ord'])) {
// check oa_ord && oa_type are valid
$_SESSION['sa_ord'] = (in_array($_GET['sa_ord'], array('title', 'num_bids', 'current_bid'))) ? $_GET['sa_ord'] : 'title';
$_SESSION['sa_type'] = (in_array($_GET['sa_type'], array('asc', 'desc'))) ? $_GET['sa_type'] : 'asc';
} elseif (isset($_SESSION['sa_ord']) && empty($_GET['sa_ord'])) {
$_SESSION['sa_nexttype'] = $_SESSION['sa_type'];
}
if (!isset($_SESSION['sa_nexttype']) || $_SESSION['sa_nexttype'] == 'desc') {
$_SESSION['sa_nexttype'] = 'asc';
} else {
$_SESSION['sa_nexttype'] = 'desc';
}
if (!isset($_SESSION['sa_type']) || $_SESSION['sa_type'] == 'desc') {
$_SESSION['sa_type_img'] = '<img src="images/arrow_up.gif" align="center" hspace="2" border="0" />';
} else {
$_SESSION['sa_type_img'] = '<img src="images/arrow_down.gif" align="center" hspace="2" border="0" />';
}
$query = "SELECT id, title, current_bid, num_bids, relist, relisted, current_bid, suspended
FROM " . $DBPrefix . "auctions
WHERE user = :user_id
AND suspended != 0
ORDER BY " . $_SESSION['sa_ord'] . " " . $_SESSION['sa_type'] . " LIMIT :offset, :perpage";
$params = array();
$params[] = array(':user_id', $user->user_data['id'], 'int');
$params[] = array(':offset', $OFFSET, 'int');
$params[] = array(':perpage', $system->SETTINGS['perpage'], 'int');
$db->query($query, $params);
$i = 0;
while ($item = $db->fetch()) {
$template->assign_block_vars('items', array(
'BGCOLOUR' => (!($i % 2)) ? '' : 'class="alt-row"',
'ID' => $item['id'],
'TITLE' => htmlspecialchars($item['title']),
'BID' => $system->print_money($item['current_bid']),
'BIDS' => $item['num_bids'],
'RELIST' => $item['relist'],
'RELISTED' => $item['relisted'],
'SUSPENDED' => $item['suspended'],
'B_HASNOBIDS' => ($item['current_bid'] == 0)
));
$i++;
}
// get pagenation
$PREV = intval($PAGE - 1);
$NEXT = intval($PAGE + 1);
if ($PAGES > 1) {
$LOW = $PAGE - 5;
if ($LOW <= 0) {
$LOW = 1;
}
$COUNTER = $LOW;
while ($COUNTER <= $PAGES && $COUNTER < ($PAGE + 6)) {
$template->assign_block_vars('pages', array(
'PAGE' => ($PAGE == $COUNTER) ? '<a><b>' . $COUNTER . '</b></a>' : '<a href="' . $system->SETTINGS['siteurl'] . 'yourauctions_s.php?PAGE=' . $COUNTER . '"><u>' . $COUNTER . '</u></a>'
));
$COUNTER++;
}
}
$template->assign_vars(array(
'BGCOLOUR' => (!($i % 2)) ? '' : 'class="alt-row"',
'ORDERCOL' => $_SESSION['sa_ord'],
'ORDERNEXT' => $_SESSION['sa_nexttype'],
'ORDERTYPEIMG' => $_SESSION['sa_type_img'],
'USER_MESSAGE' => $user_message,
'PREV' => ($PAGES > 1 && $PAGE > 1) ? '<a href="' . $system->SETTINGS['siteurl'] . 'yourauctions_s.php?PAGE=' . $PREV . '"><u>' . $MSG['5119'] . '</u></a> ' : '',
'NEXT' => ($PAGE < $PAGES) ? '<a href="' . $system->SETTINGS['siteurl'] . 'yourauctions_s.php?PAGE=' . $NEXT . '"><u>' . $MSG['5120'] . '</u></a>' : '',
'PAGE' => $PAGE,
'PAGES' => $PAGES,
'B_AREITEMS' => ($i > 0)
));
include 'header.php';
$TMP_usmenutitle = $MSG['2__0056'];
include INCLUDE_PATH . 'user_cp.php';
$template->set_filenames(array(
'body' => 'yourauctions_s.tpl'
));
$template->display('body');
include 'footer.php';