This repository has been archived by the owner on Sep 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 126
/
yourfeedback.php
132 lines (118 loc) · 5.13 KB
/
yourfeedback.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
<?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';
if (!$user->checkAuth()) {
$_SESSION['LOGIN_MESSAGE'] = $MSG['5000'];
$_SESSION['REDIRECT_AFTER_LOGIN'] = 'yourfeedback.php';
header('location: user_login.php');
exit;
}
$query = "SELECT icon FROM " . $DBPrefix . "membertypes WHERE feedbacks <= :feedback ORDER BY feedbacks DESC LIMIT 1;";
$params = array();
$params[] = array(':feedback', $user->user_data['rate_sum'], 'int');
$db->query($query, $params);
$feedback_icon = $db->result('icon');
$query = "SELECT count(*) As COUNT FROM " . $DBPrefix . "feedbacks WHERE rated_user_id = :user_id";
$params = array();
$params[] = array(':user_id', $user->user_data['id'], 'int');
$db->query($query, $params);
$total = $db->result('COUNT');
// get number of pages
if (!isset($_GET['PAGE']) || $_GET['PAGE'] <= 1 || $_GET['PAGE'] == '') {
$OFFSET = 0;
$PAGE = 1;
} else {
$PAGE = intval($_GET['PAGE']);
$OFFSET = ($PAGE - 1) * $system->SETTINGS['perpage'];
}
$PAGES = ($total == 0) ? 1 : ceil($total / $system->SETTINGS['perpage']);
$query = "SELECT feedbacks, icon FROM " . $DBPrefix . "membertypes ORDER BY feedbacks DESC;";
$db->direct_query($query);
$membertypes = $db->fetchAll();
$query = "SELECT f.*, a.title, u.rate_sum, w.winner FROM " . $DBPrefix . "feedbacks f
LEFT OUTER JOIN " . $DBPrefix . "auctions a ON (a.id = f.auction_id)
LEFT JOIN " . $DBPrefix . "users u ON (u.id = f.rated_user_id)
LEFT JOIN " . $DBPrefix . "winners w ON (w.auction = a.id)
WHERE rated_user_id = :user_id
ORDER by feedbackdate DESC
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;
$feed_disp = array();
while ($arrfeed = $db->fetch()) {
foreach ($membertypes as $membertype) {
if ($membertype['feedbacks'] >= $arrfeed['rate_sum']) {
$user_feedback_icon = $membertype['icon'];
break;
}
}
switch ($arrfeed['rate']) {
case 1: $uimg = $system->SETTINGS['siteurl'] . 'images/positive.png';
break;
case - 1: $uimg = $system->SETTINGS['siteurl'] . 'images/negative.png';
break;
case 0: $uimg = $system->SETTINGS['siteurl'] . 'images/neutral.png';
break;
}
$template->assign_block_vars('fbs', array(
'BGCOLOUR' => (!(($i + 1) % 2)) ? '' : 'class="alt-row"',
'IMG' => $uimg,
'USFLINK' => 'profile.php?user_id=' . $arrfeed['winner'] . '&auction_id=' . $arrfeed['auction_id'],
'USERNAME' => $arrfeed['rater_user_nick'],
'USFEED' => $arrfeed['rate_sum'],
'FB_ICON' => $user_feedback_icon,
'FBDATE' => $dt->formatDate($arrfeed['feedbackdate']),
'AUCTION_TITLE' => htmlspecialchars($arrfeed['title']),
'AUCTION_ID' => $arrfeed['auction_id'],
'FEEDBACK' => nl2br($arrfeed['feedback'])
));
$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) ? '<b>' . $COUNTER . '</b>' : '<a href="' . $system->SETTINGS['siteurl'] . 'yourfeedback.php?PAGE=' . $COUNTER . '"><u>' . $COUNTER . '</u></a>'
));
$COUNTER++;
}
}
$template->assign_vars(array(
'USERNICK' => $user->user_data['nick'],
'USERFB' => $user->user_data['rate_sum'],
'USER_FB_ICON' => $feedback_icon,
'PREV' => ($PAGES > 1 && $PAGE > 1) ? '<a href="' . $system->SETTINGS['siteurl'] . 'yourfeedback.php?PAGE=' . $PREV . '"><u>' . $MSG['5119'] . '</u></a> ' : '',
'NEXT' => ($PAGE < $PAGES) ? '<a href="' . $system->SETTINGS['siteurl'] . 'yourfeedback.php?PAGE=' . $NEXT . '"><u>' . $MSG['5120'] . '</u></a>' : '',
'PAGE' => $PAGE,
'PAGES' => $PAGES,
'BGCOLOUR' => (!(($i + 1) % 2)) ? '' : 'class="alt-row"'
));
include 'header.php';
$TMP_usmenutitle = $MSG['25_0223'];
include INCLUDE_PATH . 'user_cp.php';
$template->set_filenames(array(
'body' => 'yourfeedback.tpl'
));
$template->display('body');
include 'footer.php';