forked from renlok/WeBid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_active_auction.php
174 lines (160 loc) · 6.28 KB
/
edit_active_auction.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
<?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';
$NOW = time();
// Is the seller logged in?
if (!$user->logged_in)
{
$_SESSION['REDIRECT_AFTER_LOGIN'] = 'select_category.php';
header('location: user_login.php');
exit;
}
$query = "SELECT id FROM " . $DBPrefix . "bids WHERE auction = " . intval($_GET['id']);
$res = mysql_query($query);
$system->check_mysql($res, $query, __LINE__, __FILE__);
if (mysql_num_rows($res) > 0) {
header('location: index.php');
exit;
}
if (!isset($_POST['action'])) // already closed auctions
{
// Get Closed auctions data
unset($_SESSION['UPLOADED_PICTURES']);
unset($_SESSION['UPLOADED_PICTURES_SIZE']);
$query = "SELECT * FROM " . $DBPrefix . "auctions WHERE id = " . intval($_GET['id']) . " AND user = " . $user->user_data['id'];
$result = mysql_query($query);
$system->check_mysql($result, $query, __LINE__, __FILE__);
$RELISTEDAUCTION = mysql_fetch_array($result);
$difference = $RELISTEDAUCTION['ends'] - time();
if ($user->user_data['id'] == $RELISTEDAUCTION['user'] && $difference > 0)
{
$_SESSION['SELL_auction_id'] = $RELISTEDAUCTION['id'];
$_SESSION['SELL_starts'] = $RELISTEDAUCTION['starts'] + $system->tdiff;
$_SESSION['SELL_ends'] = $RELISTEDAUCTION['ends'];
$_SESSION['SELL_title'] = $RELISTEDAUCTION['title'];
$_SESSION['SELL_subtitle'] = $RELISTEDAUCTION['subtitle'];
$_SESSION['SELL_description'] = stripslashes($RELISTEDAUCTION['description']);
$_SESSION['SELL_atype'] = $RELISTEDAUCTION['auction_type'];
$_SESSION['SELL_buy_now_only'] = $RELISTEDAUCTION['bn_only'];
$_SESSION['SELL_suspended'] = $RELISTEDAUCTION['suspended'];
$_SESSION['SELL_iquantity'] = $RELISTEDAUCTION['quantity'];
$_SESSION['SELL_is_bold'] = $RELISTEDAUCTION['bold'];
$_SESSION['SELL_is_highlighted'] = $RELISTEDAUCTION['highlighted'];
$_SESSION['SELL_is_featured'] = $RELISTEDAUCTION['featured'];
$_SESSION['SELL_is_taxed'] = $RELISTEDAUCTION['tax'];
$_SESSION['SELL_tax_included'] = $RELISTEDAUCTION['taxinc'];
$_SESSION['SELL_current_fee'] = $RELISTEDAUCTION['current_fee'];
if ($RELISTEDAUCTION['bn_only'] == 'n')
{
$_SESSION['SELL_minimum_bid'] = $system->print_money_nosymbol($RELISTEDAUCTION['minimum_bid']);
}
else
{
$_SESSION['SELL_minimum_bid'] = 0;
}
if (floatval($RELISTEDAUCTION['reserve_price']) > 0)
{
$_SESSION['SELL_reserve_price'] = $system->print_money_nosymbol($RELISTEDAUCTION['reserve_price']);
$_SESSION['SELL_with_reserve'] = 'yes';
}
else
{
$_SESSION['SELL_reserve_price'] = '';
$_SESSION['SELL_with_reserve'] = 'no';
}
$_SESSION['SELL_sellcat1'] = $RELISTEDAUCTION['category'];
$_SESSION['SELL_sellcat2'] = $RELISTEDAUCTION['secondcat'];
if (floatval($RELISTEDAUCTION['buy_now']) > 0)
{
$_SESSION['SELL_buy_now_price'] = $system->print_money_nosymbol($RELISTEDAUCTION['buy_now']);
$_SESSION['SELL_with_buy_now'] = 'yes';
}
else
{
$_SESSION['SELL_buy_now_price'] = '';
$_SESSION['SELL_with_buy_now'] = 'no';
}
$_SESSION['SELL_duration'] = $RELISTEDAUCTION['duration'];
$_SESSION['SELL_relist'] = $RELISTEDAUCTION['relist'];
if (floatval($RELISTEDAUCTION['increment']) > 0)
{
$_SESSION['SELL_increment'] = 2;
$_SESSION['SELL_customincrement'] = $system->print_money_nosymbol($RELISTEDAUCTION['increment']);
}
else
{
$_SESSION['SELL_increment'] = 1;
$_SESSION['SELL_customincrement'] = 0;
}
$_SESSION['SELL_shipping_cost'] = $system->print_money_nosymbol($RELISTEDAUCTION['shipping_cost']);
$_SESSION['SELL_additional_shipping_cost'] = $system->print_money_nosymbol($RELISTEDAUCTION['shipping_cost_additional']);
$_SESSION['SELL_shipping'] = $RELISTEDAUCTION['shipping'];
$_SESSION['SELL_shipping_terms'] = $RELISTEDAUCTION['shipping_terms'];
$_SESSION['SELL_payment'] = explode(', ', $RELISTEDAUCTION['payment']);
$_SESSION['SELL_international'] = $RELISTEDAUCTION['international'];
$_SESSION['SELL_file_uploaded'] = $RELISTEDAUCTION['photo_uploaded'];
$_SESSION['SELL_pict_url'] = $RELISTEDAUCTION['pict_url'];
$_SESSION['SELL_pict_url_temp'] = str_replace('thumb-', '', $RELISTEDAUCTION['pict_url']);
// get gallery images
$UPLOADED_PICTURES = array();
$file_types = array('gif', 'jpg', 'jpeg', 'png');
if (is_dir($upload_path . intval($_GET['id'])))
{
$dir = opendir($upload_path . intval($_GET['id']));
while (($myfile = readdir($dir)) !== false)
{
if ($myfile != '.' && $myfile != '..' && !is_file($myfile))
{
$file_ext = strtolower(substr($myfile, strrpos($myfile, '.') + 1));
if (in_array($file_ext, $file_types) && (strstr($RELISTEDAUCTION['pict_url'], 'thumb-') === false || $RELISTEDAUCTION['pict_url'] != $myfile))
{
$UPLOADED_PICTURES[] = $myfile;
}
}
}
closedir($dir);
}
$_SESSION['UPLOADED_PICTURES'] = $UPLOADED_PICTURES;
if (count($UPLOADED_PICTURES) > 0)
{
if (!file_exists($upload_path . session_id()))
{
umask();
mkdir($upload_path . session_id(), 0777);
}
foreach ($UPLOADED_PICTURES as $k => $v)
{
$system->move_file($uploaded_path . intval($_GET['id']) . '/' . $v, $uploaded_path . session_id() . '/' . $v, false);
}
if (!empty($RELISTEDAUCTION['pict_url']))
{
$system->move_file($uploaded_path . intval($_GET['id']) . '/' . $RELISTEDAUCTION['pict_url'], $uploaded_path . session_id() . '/' . $RELISTEDAUCTION['pict_url'], false);
}
}
$_SESSION['SELL_action'] = 'edit';
if ($_SESSION['SELL_starts'] > $NOW)
{
$_SESSION['editstartdate'] = true;
}
else
{
$_SESSION['editstartdate'] = false;
}
header('location: sell.php?mode=recall');
}
else
{
header('location: index.php');
}
}
?>