-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathauction_watch.php
109 lines (99 loc) · 3.06 KB
/
auction_watch.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
<?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';
// If user is not logged in redirect to login page
if (!$user->is_logged_in())
{
$_SESSION['REDIRECT_AFTER_LOGIN'] = 'auction_watch.php';
header('location: user_login.php');
exit;
}
// insert a new watch item
if (isset($_GET['insert']) && $_GET['insert'] == 'true' && !empty($_REQUEST['add']))
{
$requestadd = $system->cleanvars($_REQUEST['add']);
// Check if this keyword is not already added
$auctions = trim($user->user_data['auc_watch']);
unset($match); // just incase
if (!empty($auctions))
{
$checkarray = explode(' ', $requestadd);
$requestadd = '';
foreach ($checkarray as $check)
{
if (strpos($auctions, $check) === false)
{
$requestadd .= $check . ' ';
}
}
}
if (!isset($match) || empty($match))
{
$auction_watch = trim($auctions . ' ' . $requestadd);
$query = "UPDATE " . $DBPrefix . "users SET auc_watch = :auc_watch WHERE id = :id";
$params = array(
array(':auc_watch', $auction_watch, PDO::PARAM_STR),
array(':id', $user->user_data['id'], PDO::PARAM_INT),
);
$db->query($query, $params);
$user->user_data['auc_watch'] = $auction_watch;
}
}
// Delete auction from auction watch
if (isset($_GET['delete']))
{
$auctions = trim($user->user_data['auc_watch']);
$auc_id = split(' ', $auctions);
$auction_watch = '';
for ($j = 0; $j < count($auc_id); $j++)
{
$match = strstr($auc_id[$j], $_GET['delete']);
if ($match)
{
$auction_watch = $auction_watch;
}
else
{
$auction_watch = $auc_id[$j] . ' ' . $auction_watch;
}
}
$auction_watch = trim($auction_watch);
$query = "UPDATE " . $DBPrefix . "users SET auc_watch = :auc_watch WHERE id = :id";
$params = array(
array(':auc_watch', $auction_watch, PDO::PARAM_STR),
array(':id', $user->user_data['id'], PDO::PARAM_INT),
);
$db->query($query, $params);
$user->user_data['auc_watch'] = $auction_watch;
}
$auctions = trim($user->user_data['auc_watch']);
if ($auctions != '')
{
$auction = split(' ', $auctions);
for ($j = 0; $j < count($auction); $j++)
{
$template->assign_block_vars('items', array(
'ITEM' => $auction[$j],
'ITEMENCODE' => urlencode($auction[$j])
));
}
}
include 'header.php';
$TMP_usmenutitle = $MSG['471'];
include $include_path . 'user_cp.php';
$template->set_filenames(array(
'body' => 'auction_watch.tpl'
));
$template->display('body');
include 'footer.php';
?>