|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* You may not change or alter any portion of this comment or credits |
|
4
|
|
|
* of supporting developers from this source code or any supporting source code |
|
5
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
6
|
|
|
* |
|
7
|
|
|
* This program is distributed in the hope that it will be useful, |
|
8
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
|
14
|
|
|
* @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
|
15
|
|
|
* @package |
|
16
|
|
|
* @since |
|
17
|
|
|
* @author XOOPS Development Team |
|
18
|
|
|
* @param mixed $options |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
/****************************************************************************** |
|
22
|
|
|
* Function: b_refercounter_show |
|
23
|
|
|
* Output : Returns the graphical output of site hits |
|
24
|
|
|
***************************************************************************** |
|
25
|
|
|
* @param $options |
|
26
|
|
|
* @return array |
|
27
|
|
|
*/ |
|
28
|
|
|
function b_refercounter_show($options) |
|
29
|
|
|
{ |
|
30
|
|
|
global $xoopsDB, $configHandler, $xoopsStatConfig; |
|
31
|
|
|
|
|
32
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
|
33
|
|
|
$moduleHandler = xoops_getHandler('module'); |
|
34
|
|
|
$xoopsStatModule = $moduleHandler->getByDirname('statistics'); |
|
35
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
|
36
|
|
|
$configHandler = xoops_getHandler('config'); |
|
37
|
|
|
$xoopsStatConfig = $configHandler->getConfigsByCat(0, $xoopsStatModule->getVar('mid')); |
|
38
|
|
|
|
|
39
|
|
|
$showhowmany = $options[0]; |
|
40
|
|
|
$showselfrefer = $options[2]; |
|
41
|
|
|
|
|
42
|
|
|
// get any current blacklist |
|
43
|
|
|
$result = $xoopsDB->queryF('SELECT * FROM ' . $xoopsDB->prefix('stats_refer_blacklist')); |
|
44
|
|
|
[$id, $referer] = $xoopsDB->fetchRow($result); |
|
45
|
|
|
$referblacklist = unserialize(stripslashes($referer)); |
|
46
|
|
|
if (!is_array($referblacklist)) { // something went wrong, or there is no data... |
|
47
|
|
|
$referblacklist = []; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
$block = []; |
|
51
|
|
|
$result = $xoopsDB->queryF('SELECT refer, date, hits, referpath FROM ' . $xoopsDB->prefix('stats_refer') . ' ORDER BY hits DESC'); |
|
52
|
|
|
$referhits = []; |
|
53
|
|
|
$cnt = 0; |
|
54
|
|
|
while (list($refer, $date, $hits, $referpath) = $xoopsDB->fetchRow($result)) { |
|
55
|
|
|
if ((0 == $showselfrefer && !strcmp($refer, $_SERVER['HTTP_HOST'])) || '' == $refer) { |
|
56
|
|
|
continue; |
|
57
|
|
|
} |
|
58
|
|
|
// see if we have a blacklist |
|
59
|
|
|
$blacklisted = false; |
|
60
|
|
|
if ('Allow' !== $xoopsStatConfig['refererspam']) { // make sure they really want them ignored |
|
61
|
|
|
if (count($referblacklist) > 0) { |
|
62
|
|
|
$rbldelimited = '/' . implode('|', $referblacklist) . '/'; |
|
63
|
|
|
if (preg_match($rbldelimited, $refer)) { |
|
64
|
|
|
$blacklisted = true; |
|
|
|
|
|
|
65
|
|
|
continue; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
if (false === $blacklisted) { |
|
71
|
|
|
$referpathparts = explode('|', $referpath); |
|
72
|
|
|
|
|
73
|
|
|
$referhits[$cnt]['pathing'] = $options[1]; |
|
74
|
|
|
$referhits[$cnt]['elipses'] = B_STATS_ELIPSES; |
|
75
|
|
|
$referhits[$cnt]['pathstrip'] = B_STATS_DELPATH; |
|
76
|
|
|
$referhits[$cnt]['pathdns'] = B_STATS_PATHDNS; |
|
77
|
|
|
$referhits[$cnt]['path'] = $referpathparts[0]; |
|
78
|
|
|
$referhits[$cnt]['query'] = $referpathparts[1]; |
|
79
|
|
|
$referhits[$cnt]['fragment'] = $referpathparts[2]; |
|
80
|
|
|
$referhits[$cnt]['refer'] = $refer; |
|
81
|
|
|
$referhits[$cnt]['hits'] = ''; |
|
82
|
|
|
preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})/', $date, $regs); |
|
83
|
|
|
$referhits[$cnt]['year'] = $regs[1]; |
|
84
|
|
|
$referhits[$cnt]['month'] = $regs[2]; |
|
85
|
|
|
$referhits[$cnt]['day'] = $regs[3]; |
|
86
|
|
|
$referhits[$cnt]['hour'] = B_STATS_HOUR . ' ' . $regs[4]; |
|
87
|
|
|
if (mb_strlen($hits) < 3) { |
|
88
|
|
|
$hits = sprintf('%03d', $hits); |
|
89
|
|
|
} |
|
90
|
|
|
for ($i = 0, $iMax = mb_strlen($hits); $i < $iMax; ++$i) { |
|
91
|
|
|
//the <img src> tag |
|
92
|
|
|
$imgsrc = mb_substr($hits, $i, 1); |
|
93
|
|
|
$referhits[$cnt]['hits'] .= '<img src="' . XOOPS_URL . '/modules/statistics/assets/images/' . $imgsrc . '.gif" border = "0">'; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
++$cnt; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
if ($cnt == $showhowmany) { |
|
100
|
|
|
break; |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
$block['counterhead'] = B_STATS_REFERHEAD; |
|
105
|
|
|
$block['referhits'] = $referhits; |
|
106
|
|
|
|
|
107
|
|
|
return $block; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
function b_refercounter_edit($options) |
|
111
|
|
|
{ |
|
112
|
|
|
$inputtag = "<input type='text' name='options[0]' value='" . $options[0] . "'>"; |
|
113
|
|
|
$form = sprintf(B_STATS_REFERDISPLAY, $inputtag); |
|
114
|
|
|
|
|
115
|
|
|
$form .= '<hr>' . B_STATS_REFERERPATH_DISPLAY . '<br><br>' . "<input type='radio' id='options[1]' name='options[1]' value='0'"; |
|
116
|
|
|
if (0 == $options[1]) { // full path |
|
117
|
|
|
$form .= ' checked'; |
|
118
|
|
|
} |
|
119
|
|
|
$form .= '> ' . B_STATS_REFER_FULLPATH . "<br><input type='radio' id='options[1]' name='options[1]' value='1'"; |
|
120
|
|
|
if (1 == $options[1]) { // domain only |
|
121
|
|
|
$form .= ' checked'; |
|
122
|
|
|
} |
|
123
|
|
|
$form .= '> ' . B_STATS_REFER_DOMAIN . "<br><input type='radio' id='options[1]' name='options[1]' value='2'"; |
|
124
|
|
|
if (2 == $options[1]) { // show both |
|
125
|
|
|
$form .= ' checked'; |
|
126
|
|
|
} |
|
127
|
|
|
$form .= '> ' . B_STATS_REFER_ALL; |
|
128
|
|
|
|
|
129
|
|
|
$temp = sprintf(B_STATS_SELFREFERDISPLAY, $_SERVER['HTTP_HOST']); |
|
130
|
|
|
$form .= '<hr>' . $temp . "<br><br><input type='radio' id='options[2]' name='options[2]' value='1'"; |
|
131
|
|
|
if (1 == $options[2]) { |
|
132
|
|
|
$form .= ' checked'; |
|
133
|
|
|
} |
|
134
|
|
|
$form .= '> ' . _YES . "<br><input type='radio' id='options[2]' name='options[2]' value='0'"; |
|
135
|
|
|
if (0 == $options[2]) { |
|
136
|
|
|
$form .= ' checked'; |
|
137
|
|
|
} |
|
138
|
|
|
$form .= '> ' . _NO; |
|
139
|
|
|
|
|
140
|
|
|
return $form; |
|
141
|
|
|
} |
|
142
|
|
|
|