1
|
|
|
<?php |
2
|
|
|
// |
3
|
|
|
// ------------------------------------------------------------------------ // |
4
|
|
|
// XOOPS - PHP Content Management System // |
5
|
|
|
// Copyright (c) 2000-2020 XOOPS.org // |
6
|
|
|
// <https://xoops.org> // |
7
|
|
|
// ------------------------------------------------------------------------ // |
8
|
|
|
// This program is free software; you can redistribute it and/or modify // |
9
|
|
|
// it under the terms of the GNU General Public License as published by // |
10
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
11
|
|
|
// (at your option) any later version. // |
12
|
|
|
// // |
13
|
|
|
// You may not change or alter any portion of this comment or credits // |
14
|
|
|
// of supporting developers from this source code or any supporting // |
15
|
|
|
// source code which is considered copyrighted (c) material of the // |
16
|
|
|
// original comment or credit authors. // |
17
|
|
|
// // |
18
|
|
|
// This program is distributed in the hope that it will be useful, // |
19
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
20
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
21
|
|
|
// GNU General Public License for more details. // |
22
|
|
|
// // |
23
|
|
|
// You should have received a copy of the GNU General Public License // |
24
|
|
|
// along with this program; if not, write to the Free Software // |
25
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
26
|
|
|
// ------------------------------------------------------------------------ // |
27
|
|
|
// Author: Kazumi Ono (AKA onokazu) // |
28
|
|
|
// URL: http://www.myweb.ne.jp/, https://xoops.org/, http://jp.xoops.org/ // |
29
|
|
|
// Project: XOOPS Project // |
30
|
|
|
// ------------------------------------------------------------------------- // |
31
|
|
|
|
32
|
|
|
use Xmf\Request; |
33
|
|
|
|
34
|
|
|
require_once __DIR__ . '/admin_header.php'; |
35
|
|
|
|
36
|
|
|
$op = $op = Request::getString('op', Request::getCmd('op', '', 'POST'), 'GET'); //!empty($_GET['op'])? $_GET['op'] : (!empty($_POST['op'])?$_POST['op']:""); |
37
|
|
|
|
38
|
|
|
switch ($op) { |
39
|
|
|
case 'delvotes': |
40
|
|
|
$rid = Request::getInt('rid', 0, 'GET'); |
41
|
|
|
$topic_id = Request::getInt('topic_id', 0, 'GET'); |
42
|
|
|
$sql = $GLOBALS['xoopsDB']->queryF('DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_votedata') . " WHERE ratingid = $rid"); |
43
|
|
|
$GLOBALS['xoopsDB']->query($sql); |
44
|
|
|
|
45
|
|
|
$query = 'SELECT rating FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_votedata') . ' WHERE topic_id = ' . $topic_id . ' '; |
46
|
|
|
$voteresult = $GLOBALS['xoopsDB']->query($query); |
47
|
|
|
$votesDB = $GLOBALS['xoopsDB']->getRowsNum($voteresult); |
48
|
|
|
$totalrating = 0; |
49
|
|
|
while (list($rating) = $GLOBALS['xoopsDB']->fetchRow($voteresult)) { |
50
|
|
|
$totalrating += $rating; |
51
|
|
|
} |
52
|
|
|
$finalrating = $totalrating / $votesDB; |
53
|
|
|
$finalrating = number_format($finalrating, 4); |
54
|
|
|
$sql = sprintf('UPDATE `%s` SET rating = %u, votes = %u WHERE topic_id = %u', $GLOBALS['xoopsDB']->prefix('newbb_topics'), $finalrating, $votesDB, $topic_id); |
55
|
|
|
$GLOBALS['xoopsDB']->queryF($sql); |
56
|
|
|
|
57
|
|
|
redirect_header('admin_votedata.php', 1, _AM_NEWBB_VOTEDELETED); |
58
|
|
|
break; |
59
|
|
|
case 'main': |
60
|
|
|
default: |
61
|
|
|
$start = Request::getInt('start', 0, 'POST'); |
62
|
|
|
$useravgrating = '0'; |
63
|
|
|
$uservotes = '0'; |
64
|
|
|
|
65
|
|
|
$sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_votedata') . ' ORDER BY ratingtimestamp DESC'; |
66
|
|
|
$results = $GLOBALS['xoopsDB']->query($sql, 20, $start); |
67
|
|
|
$votes = $GLOBALS['xoopsDB']->getRowsNum($results); |
68
|
|
|
|
69
|
|
|
$sql = 'SELECT rating FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_votedata') . ' '; |
70
|
|
|
$result2 = $GLOBALS['xoopsDB']->query($sql, 20, $start); |
71
|
|
|
$uservotes = $GLOBALS['xoopsDB']->getRowsNum($result2); |
72
|
|
|
$useravgrating = 0; |
73
|
|
|
|
74
|
|
|
while (list($rating2) = $GLOBALS['xoopsDB']->fetchRow($result2)) { |
75
|
|
|
// $useravgrating = $useravgrating + $rating2; |
76
|
|
|
$useravgrating += $rating2; |
77
|
|
|
} |
78
|
|
|
if ($useravgrating > 0) { |
79
|
|
|
// $useravgrating = $useravgrating / $uservotes; |
80
|
|
|
$useravgrating /= $uservotes; |
81
|
|
|
$useravgrating = number_format($useravgrating, 2); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
xoops_cp_header(); |
85
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
86
|
|
|
|
87
|
|
|
echo "<div style='padding: 8px;'>\n |
88
|
|
|
<div><strong>" . _AM_NEWBB_VOTE_USERAVG . ": </strong>$useravgrating</div>\n |
89
|
|
|
<div><strong>" . _AM_NEWBB_VOTE_TOTALRATE . ": </strong>$uservotes</div>\n |
90
|
|
|
<div style='padding: 8px;'>\n |
91
|
|
|
<ul><li> " . _AM_NEWBB_VOTE_DELETEDSC . "</li></ul> |
92
|
|
|
<div>\n |
93
|
|
|
<br>\n |
94
|
|
|
<table width='100%' border='0' cellspacing='1' class='outer'>" . "<tr><td class='odd'> |
95
|
|
|
<table width='100%' cellspacing='1' cellpadding='2' class='outer'>\n |
96
|
|
|
<tr>\n |
97
|
|
|
<th align='center'>" . _AM_NEWBB_VOTE_ID . "</th>\n |
98
|
|
|
<th align='center'>" . _AM_NEWBB_VOTE_USER . "</th>\n |
99
|
|
|
<th align='center'>" . _AM_NEWBB_VOTE_IP . "</th>\n |
100
|
|
|
<th align='center'>" . _AM_NEWBB_VOTE_FILETITLE . "</th>\n |
101
|
|
|
<th align='center'>" . _AM_NEWBB_VOTE_RATING . "</th>\n |
102
|
|
|
<th align='center'>" . _AM_NEWBB_VOTE_DATE . "</th>\n |
103
|
|
|
<th align='center'>" . _AM_NEWBB_ACTION . "</th></tr>\n"; |
104
|
|
|
|
105
|
|
|
if (0 == $votes) { |
106
|
|
|
echo "<tr><td align='center' colspan='7' class='head'>" . _AM_NEWBB_VOTE_NOVOTES . '</td></tr>'; |
107
|
|
|
} |
108
|
|
|
while (list($ratingid, $topic_id, $ratinguser, $rating, $ratinghostname, $ratingtimestamp) = $GLOBALS['xoopsDB']->fetchRow($results)) { |
109
|
|
|
$sql = 'SELECT topic_title FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' WHERE topic_id=' . $topic_id . ' '; |
110
|
|
|
$down_array = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql)); |
111
|
|
|
|
112
|
|
|
$formatted_date = formatTimestamp($ratingtimestamp, _DATESTRING); |
113
|
|
|
$ratinguname = newbbGetUnameFromId($ratinguser, $GLOBALS['xoopsModuleConfig']['show_realname']); |
114
|
|
|
echo " |
115
|
|
|
<tr>\n |
116
|
|
|
<td class='head' align='center'>$ratingid</td>\n |
117
|
|
|
<td class='even' align='center'>$ratinguname</td>\n |
118
|
|
|
<td class='even' align='center' >$ratinghostname</td>\n |
119
|
|
|
<td class='even' align='left'><a href='" . XOOPS_URL . '/modules/newbb/viewtopic.php?topic_id=' . $topic_id . "' target='topic'>" . $myts->htmlSpecialChars($down_array['topic_title']) . "</a></td>\n |
120
|
|
|
<td class='even' align='center'>$rating</td>\n |
121
|
|
|
<td class='even' align='center'>$formatted_date</td>\n |
122
|
|
|
<td class='even' align='center'><strong><a href='admin_votedata.php?op=delvotes&topic_id=$topic_id&rid=$ratingid'>" . newbbDisplayImage('p_delete', _DELETE) . "</a></strong></td>\n |
123
|
|
|
</tr>\n"; |
124
|
|
|
} |
125
|
|
|
echo '</table>'; |
126
|
|
|
echo '</td></tr></table>'; |
127
|
|
|
//Include page navigation |
128
|
|
|
require_once $GLOBALS['xoops']->path('class/pagenav.php'); |
129
|
|
|
$page = ($votes > 10) ? _AM_NEWBB_INDEX_PAGE : ''; |
130
|
|
|
$pagenav = new \XoopsPageNav($page, 20, $start, 'start'); |
|
|
|
|
131
|
|
|
echo '<div align="right" style="padding: 8px;">' . $page . '' . $pagenav->renderImageNav(4) . '</div>'; |
132
|
|
|
echo '<fieldset>'; |
133
|
|
|
echo '<legend> ' . _MI_NEWBB_ADMENU_VOTE . ' </legend>'; |
134
|
|
|
echo _AM_NEWBB_HELP_VOTE_TAB; |
135
|
|
|
echo '</fieldset>'; |
136
|
|
|
break; |
137
|
|
|
} |
138
|
|
|
require_once __DIR__ . '/admin_footer.php'; |
139
|
|
|
|