|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Statistics; |
|
4
|
|
|
|
|
5
|
|
|
use XoopsModules\Statistics; |
|
6
|
|
|
use XoopsModules\Statistics\Common; |
|
7
|
|
|
use XoopsModules\Statistics\Constants; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class Utility |
|
11
|
|
|
*/ |
|
12
|
|
|
class Utility extends Common\SysUtility |
|
13
|
|
|
{ |
|
14
|
|
|
//--------------- Custom module methods ----------------------------- |
|
15
|
|
|
|
|
16
|
|
|
public static function getMonthlyStats($year) |
|
17
|
|
|
{ |
|
18
|
|
|
global $xoopsDB, $xoopsTpl; |
|
19
|
|
|
|
|
20
|
|
|
$now = date('d-m-Y'); |
|
21
|
|
|
$dot = explode('-', $now); |
|
22
|
|
|
$nowmonth = $dot[1]; |
|
23
|
|
|
|
|
24
|
|
|
$l_size = getimagesize('assets/images/leftbar.gif'); |
|
25
|
|
|
$m_size = getimagesize('assets/images/mainbar.gif'); |
|
26
|
|
|
$r_size = getimagesize('assets/images/rightbar.gif'); |
|
27
|
|
|
|
|
28
|
|
|
// get monthly stats and display |
|
29
|
|
|
$resultmonth = $xoopsDB->queryF('select sum(hits) as totalhitsmonth from ' . $xoopsDB->prefix('stats_month') . " where year='$year'"); |
|
30
|
|
|
[$totalhitsmonth] = $xoopsDB->fetchRow($resultmonth); |
|
|
|
|
|
|
31
|
|
|
$xoopsDB->freeRecordSet($resultmonth); |
|
32
|
|
|
$result = $xoopsDB->queryF('select month,hits from ' . $xoopsDB->prefix('stats_month') . " where year='$year'"); |
|
33
|
|
|
$xoopsTpl->assign('lang_stat_monthlystats', STATS_MONTHLYSTATS . ' - ' . $year); |
|
34
|
|
|
$xoopsTpl->assign('lang_stat_monthhead', STATS_MONTH); |
|
35
|
|
|
$resulttotal = $xoopsDB->queryF('select hits from ' . $xoopsDB->prefix('stats_year') . " where year='$year'"); |
|
36
|
|
|
[$hitsforyear] = $xoopsDB->fetchRow($resulttotal); |
|
37
|
|
|
$monthlist = []; |
|
38
|
|
|
$i = 0; |
|
39
|
|
|
while (list($month, $hits) = $xoopsDB->fetchRow($result)) { |
|
40
|
|
|
$monthlist[$i]['month'] = getMonth($month); |
|
|
|
|
|
|
41
|
|
|
$monthlist[$i]['hits'] = $hits; |
|
42
|
|
|
if ($month != $nowmonth) { |
|
43
|
|
|
$monthlist[$i]['link'] = "<a href=\"statdetails.php?op=monthlystats&year=$year&month=$month\">" . $monthlist[$i]['month'] . '</a>'; |
|
44
|
|
|
} else { |
|
45
|
|
|
$monthlist[$i]['link'] = ''; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
$midbarsize = mb_substr(100 * $hits / $hitsforyear, 0, 5); |
|
49
|
|
|
$monthlist[$i]['percent'] = $midbarsize . '%'; |
|
50
|
|
|
$m_name = getMonth($month); |
|
51
|
|
|
$monthlist[$i]['graph'] = "<img src=\"assets/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"$m_name - $hits\"><img src=\"assets/images/mainbar.gif\" Alt=\"$m_name - $hits\" height=\"$m_size[1]\" width=\"$midbarsize\"><img src=\"assets/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"$m_name - $hits\">"; |
|
52
|
|
|
++$i; |
|
53
|
|
|
} |
|
54
|
|
|
$xoopsDB->freeRecordSet($result); |
|
55
|
|
|
$xoopsTpl->assign('monthlist', $monthlist); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public static function getDailyStats($year, $month) |
|
59
|
|
|
{ |
|
60
|
|
|
global $xoopsDB, $xoopsTpl; |
|
61
|
|
|
|
|
62
|
|
|
$now = date('d-m-Y'); |
|
63
|
|
|
$dot = explode('-', $now); |
|
64
|
|
|
$nowdate = $dot[0]; |
|
65
|
|
|
|
|
66
|
|
|
$l_size = getimagesize('assets/images/leftbar.gif'); |
|
67
|
|
|
$m_size = getimagesize('assets/images/mainbar.gif'); |
|
68
|
|
|
$r_size = getimagesize('assets/images/rightbar.gif'); |
|
69
|
|
|
|
|
70
|
|
|
// get the daily stats and show |
|
71
|
|
|
$resulttotal = $xoopsDB->queryF('select sum(hits) as totalhitsdate from ' . $xoopsDB->prefix('stats_date') . " where year='$year' and month='$month'"); |
|
72
|
|
|
[$totalhitsdate] = $xoopsDB->fetchRow($resulttotal); |
|
73
|
|
|
$xoopsDB->freeRecordSet($resulttotal); |
|
74
|
|
|
$result = $xoopsDB->queryF('select year,month,date,hits from ' . $xoopsDB->prefix('stats_date') . " where year='$year' and month='$month' order by date"); |
|
75
|
|
|
$total = $xoopsDB->getRowsNum($result); |
|
|
|
|
|
|
76
|
|
|
$xoopsTpl->assign('lang_stat_dailystats', STATS_DAILYSTATS . ' - ' . getMonth($month) . ' - ' . $year); |
|
|
|
|
|
|
77
|
|
|
$xoopsTpl->assign('lang_stat_dailyhead', STATS_DAILY); |
|
78
|
|
|
$dailylist = []; |
|
79
|
|
|
$i = 0; |
|
80
|
|
|
while (list($year, $month, $date, $hits) = $xoopsDB->fetchRow($result)) { |
|
81
|
|
|
$dailylist[$i]['year'] = $year; |
|
82
|
|
|
$dailylist[$i]['month'] = getMonth($month); |
|
83
|
|
|
$dailylist[$i]['date'] = $date; |
|
84
|
|
|
$dailylist[$i]['hits'] = $hits; |
|
85
|
|
|
if ($date != $nowdate) { |
|
86
|
|
|
$dailylist[$i]['link'] = "<a href=\"statdetails.php?op=dailystats&year=$year&month=$month&date=$date\">" . $date . '</a>'; |
|
87
|
|
|
} else { |
|
88
|
|
|
$dailylist[$i]['link'] = ''; |
|
89
|
|
|
} |
|
90
|
|
|
$midbarsize = mb_substr(100 * $hits / $totalhitsdate, 0, 5); |
|
91
|
|
|
$dailylist[$i]['percent'] = $midbarsize . '%'; |
|
92
|
|
|
$dailylist[$i]['graph'] = "<img src=\"assets/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"$date - $hits\"><img src=\"assets/images/mainbar.gif\" Alt=\"$date - $hits\" height=\"$m_size[1]\" width=\"$midbarsize\"><img src=\"assets/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"$date - $hits\">"; |
|
93
|
|
|
++$i; |
|
94
|
|
|
} |
|
95
|
|
|
$xoopsDB->freeRecordSet($result); |
|
96
|
|
|
$xoopsTpl->assign('dailylist', $dailylist); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
public static function getHourlyStats($year, $month, $date) |
|
100
|
|
|
{ |
|
101
|
|
|
global $xoopsDB, $xoopsTpl; |
|
102
|
|
|
|
|
103
|
|
|
$l_size = getimagesize('assets/images/leftbar.gif'); |
|
104
|
|
|
$m_size = getimagesize('assets/images/mainbar.gif'); |
|
105
|
|
|
$r_size = getimagesize('assets/images/rightbar.gif'); |
|
106
|
|
|
|
|
107
|
|
|
$now = date('d-m-Y'); |
|
108
|
|
|
|
|
109
|
|
|
// show hourly stats and display |
|
110
|
|
|
$resulttotal = $xoopsDB->queryF('select sum(hits) as totalhitshour from ' . $xoopsDB->prefix('stats_hour') . " where year='$year' and month='$month' and date='$date'"); |
|
111
|
|
|
[$totalhitshour] = $xoopsDB->fetchRow($resulttotal); |
|
112
|
|
|
$xoopsDB->freeRecordSet($resulttotal); |
|
113
|
|
|
$date_arr = explode('-', $now); |
|
|
|
|
|
|
114
|
|
|
$xoopsTpl->assign('lang_stat_hourlystats', STATS_HOURLYSTATS . ' - ' . getMonth($month) . ' ' . $date . ' ' . $year); |
|
|
|
|
|
|
115
|
|
|
$xoopsTpl->assign('lang_stat_hourlyhead', STATS_HOURLY); |
|
116
|
|
|
$hourlist = []; |
|
117
|
|
|
|
|
118
|
|
|
for ($k = 0; $k <= 23; ++$k) { |
|
119
|
|
|
$result = $xoopsDB->queryF('select hour,hits from ' . $xoopsDB->prefix('stats_hour') . " where year='$year' and month='$month' and date='$date' and hour='$k'"); |
|
120
|
|
|
if (0 == $xoopsDB->getRowsNum($result)) { |
|
121
|
|
|
$hits = 0; |
|
122
|
|
|
$hour = $k; |
|
123
|
|
|
} else { |
|
124
|
|
|
[$hour, $hits] = $xoopsDB->fetchRow($result); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
$a = (($k < 10) ? "0$k" : $k); |
|
128
|
|
|
$hourlist[$k]['hour'] = "$a:00 - $a:59"; |
|
129
|
|
|
|
|
130
|
|
|
$a = ''; |
|
|
|
|
|
|
131
|
|
|
|
|
132
|
|
|
$midbarsize = ((0 == $hits) ? 0 : mb_substr(100 * $hits / $totalhitshour, 0, 5)); |
|
133
|
|
|
$hourlist[$k]['hits'] = $hits; |
|
134
|
|
|
$hourlist[$k]['percent'] = $midbarsize . '%'; |
|
135
|
|
|
$hourlist[$k]['graph'] = "<img src=\"assets/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"$hour - $hits\"><img src=\"assets/images/mainbar.gif\" Alt=\"$hour - $hits\" height=\"$m_size[1]\" width=\"$midbarsize\"><img src=\"assets/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"$hour - $hits\">"; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
$xoopsDB->freeRecordSet($result); |
|
|
|
|
|
|
139
|
|
|
$xoopsTpl->assign('hourlist', $hourlist); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
public static function getBlockedMonthlyStats($year) |
|
143
|
|
|
{ |
|
144
|
|
|
global $xoopsDB, $xoopsTpl; |
|
145
|
|
|
|
|
146
|
|
|
$now = date('d-m-Y'); |
|
147
|
|
|
$dot = explode('-', $now); |
|
148
|
|
|
$nowmonth = $dot[1]; |
|
149
|
|
|
|
|
150
|
|
|
$l_size = getimagesize('assets/images/leftbar.gif'); |
|
151
|
|
|
$m_size = getimagesize('assets/images/mainbar.gif'); |
|
152
|
|
|
$r_size = getimagesize('assets/images/rightbar.gif'); |
|
153
|
|
|
|
|
154
|
|
|
// get monthly stats and display |
|
155
|
|
|
$resultmonth = $xoopsDB->queryF('select sum(hits) as totalhitsmonth from ' . $xoopsDB->prefix('stats_blockedmonth') . " where year='$year'"); |
|
156
|
|
|
[$totalhitsmonth] = $xoopsDB->fetchRow($resultmonth); |
|
|
|
|
|
|
157
|
|
|
$xoopsDB->freeRecordSet($resultmonth); |
|
158
|
|
|
$result = $xoopsDB->queryF('select month,hits from ' . $xoopsDB->prefix('stats_blockedmonth') . " where year='$year'"); |
|
159
|
|
|
$xoopsTpl->assign('lang_stat_monthlystats', STATS_BLOCKEDMONTHLYSTATS . ' - ' . $year); |
|
160
|
|
|
$xoopsTpl->assign('lang_stat_monthhead', STATS_MONTH); |
|
161
|
|
|
$resulttotal = $xoopsDB->queryF('select hits from ' . $xoopsDB->prefix('stats_blockedyear') . " where year='$year'"); |
|
162
|
|
|
[$hitsforyear] = $xoopsDB->fetchRow($resulttotal); |
|
163
|
|
|
$monthlist = []; |
|
164
|
|
|
$i = 0; |
|
165
|
|
|
while (list($month, $hits) = $xoopsDB->fetchRow($result)) { |
|
166
|
|
|
$monthlist[$i]['month'] = getMonth($month); |
|
|
|
|
|
|
167
|
|
|
$monthlist[$i]['hits'] = $hits; |
|
168
|
|
|
if ($month != $nowmonth) { |
|
169
|
|
|
$monthlist[$i]['link'] = "<a href=\"statdetails.php?op=b_monthlystats&year=$year&month=$month\">" . $monthlist[$i]['month'] . '</a>'; |
|
170
|
|
|
} else { |
|
171
|
|
|
$monthlist[$i]['link'] = ''; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
$midbarsize = mb_substr(100 * $hits / $hitsforyear, 0, 5); |
|
175
|
|
|
$monthlist[$i]['percent'] = $midbarsize . '%'; |
|
176
|
|
|
$m_name = getMonth($month); |
|
177
|
|
|
$monthlist[$i]['graph'] = "<img src=\"assets/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"$m_name - $hits\"><img src=\"assets/images/mainbar.gif\" Alt=\"$m_name - $hits\" height=\"$m_size[1]\" width=\"$midbarsize\"><img src=\"assets/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"$m_name - $hits\">"; |
|
178
|
|
|
++$i; |
|
179
|
|
|
} |
|
180
|
|
|
$xoopsDB->freeRecordSet($result); |
|
181
|
|
|
$xoopsTpl->assign('monthlist', $monthlist); |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
public static function getBlockedDailyStats($year, $month) |
|
185
|
|
|
{ |
|
186
|
|
|
global $xoopsDB, $xoopsTpl; |
|
187
|
|
|
|
|
188
|
|
|
$now = date('d-m-Y'); |
|
189
|
|
|
$dot = explode('-', $now); |
|
190
|
|
|
$nowdate = $dot[0]; |
|
191
|
|
|
|
|
192
|
|
|
$l_size = getimagesize('assets/images/leftbar.gif'); |
|
193
|
|
|
$m_size = getimagesize('assets/images/mainbar.gif'); |
|
194
|
|
|
$r_size = getimagesize('assets/images/rightbar.gif'); |
|
195
|
|
|
|
|
196
|
|
|
// get the daily stats and show |
|
197
|
|
|
$resulttotal = $xoopsDB->queryF('select sum(hits) as totalhitsdate from ' . $xoopsDB->prefix('stats_blockeddate') . " where year='$year' and month='$month'"); |
|
198
|
|
|
[$totalhitsdate] = $xoopsDB->fetchRow($resulttotal); |
|
199
|
|
|
$xoopsDB->freeRecordSet($resulttotal); |
|
200
|
|
|
$result = $xoopsDB->queryF('select year,month,date,hits from ' . $xoopsDB->prefix('stats_blockeddate') . " where year='$year' and month='$month' order by date"); |
|
201
|
|
|
$total = $xoopsDB->getRowsNum($result); |
|
|
|
|
|
|
202
|
|
|
$xoopsTpl->assign('lang_stat_dailystats', STATS_BLOCKEDDAILYSTATS . ' - ' . getMonth($month) . ' - ' . $year); |
|
|
|
|
|
|
203
|
|
|
$xoopsTpl->assign('lang_stat_dailyhead', STATS_DAILY); |
|
204
|
|
|
$dailylist = []; |
|
205
|
|
|
$i = 0; |
|
206
|
|
|
while (list($year, $month, $date, $hits) = $xoopsDB->fetchRow($result)) { |
|
207
|
|
|
$dailylist[$i]['year'] = $year; |
|
208
|
|
|
$dailylist[$i]['month'] = getMonth($month); |
|
209
|
|
|
$dailylist[$i]['date'] = $date; |
|
210
|
|
|
$dailylist[$i]['hits'] = $hits; |
|
211
|
|
|
if ($date != $nowdate) { |
|
212
|
|
|
$dailylist[$i]['link'] = "<a href=\"statdetails.php?op=b_dailystats&year=$year&month=$month&date=$date\">" . $date . '</a>'; |
|
213
|
|
|
} else { |
|
214
|
|
|
$dailylist[$i]['link'] = ''; |
|
215
|
|
|
} |
|
216
|
|
|
$midbarsize = mb_substr(100 * $hits / $totalhitsdate, 0, 5); |
|
217
|
|
|
$dailylist[$i]['percent'] = $midbarsize . '%'; |
|
218
|
|
|
$dailylist[$i]['graph'] = "<img src=\"assets/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"$date - $hits\"><img src=\"assets/images/mainbar.gif\" Alt=\"$date - $hits\" height=\"$m_size[1]\" width=\"$midbarsize\"><img src=\"assets/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"$date - $hits\">"; |
|
219
|
|
|
++$i; |
|
220
|
|
|
} |
|
221
|
|
|
$xoopsDB->freeRecordSet($result); |
|
222
|
|
|
$xoopsTpl->assign('dailylist', $dailylist); |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
public static function getBlockedHourlyStats($year, $month, $date) |
|
226
|
|
|
{ |
|
227
|
|
|
global $xoopsDB, $xoopsTpl; |
|
228
|
|
|
|
|
229
|
|
|
$l_size = getimagesize('assets/images/leftbar.gif'); |
|
230
|
|
|
$m_size = getimagesize('assets/images/mainbar.gif'); |
|
231
|
|
|
$r_size = getimagesize('assets/images/rightbar.gif'); |
|
232
|
|
|
|
|
233
|
|
|
$now = date('d-m-Y'); |
|
234
|
|
|
|
|
235
|
|
|
// show hourly stats and display |
|
236
|
|
|
$resulttotal = $xoopsDB->queryF('select sum(hits) as totalhitshour from ' . $xoopsDB->prefix('stats_blockedhour') . " where year='$year' and month='$month' and date='$date'"); |
|
237
|
|
|
[$totalhitshour] = $xoopsDB->fetchRow($resulttotal); |
|
238
|
|
|
$xoopsDB->freeRecordSet($resulttotal); |
|
239
|
|
|
$date_arr = explode('-', $now); |
|
|
|
|
|
|
240
|
|
|
$xoopsTpl->assign('lang_stat_hourlystats', STATS_BLOCKEDHOURLYSTATS . ' - ' . getMonth($month) . ' ' . $date . ' ' . $year); |
|
|
|
|
|
|
241
|
|
|
$xoopsTpl->assign('lang_stat_hourlyhead', STATS_HOURLY); |
|
242
|
|
|
$hourlist = []; |
|
243
|
|
|
|
|
244
|
|
|
for ($k = 0; $k <= 23; ++$k) { |
|
245
|
|
|
$result = $xoopsDB->queryF('select hour,hits from ' . $xoopsDB->prefix('stats_blockedhour') . " where year='$year' and month='$month' and date='$date' and hour='$k'"); |
|
246
|
|
|
if (0 == $xoopsDB->getRowsNum($result)) { |
|
247
|
|
|
$hits = 0; |
|
248
|
|
|
$hour = $k; |
|
249
|
|
|
} else { |
|
250
|
|
|
[$hour, $hits] = $xoopsDB->fetchRow($result); |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
$a = (($k < 10) ? "0$k" : $k); |
|
254
|
|
|
$hourlist[$k]['hour'] = "$a:00 - $a:59"; |
|
255
|
|
|
|
|
256
|
|
|
$a = ''; |
|
|
|
|
|
|
257
|
|
|
|
|
258
|
|
|
$midbarsize = ((0 == $hits) ? 0 : mb_substr(100 * $hits / $totalhitshour, 0, 5)); |
|
259
|
|
|
$hourlist[$k]['hits'] = $hits; |
|
260
|
|
|
$hourlist[$k]['percent'] = $midbarsize . '%'; |
|
261
|
|
|
$hourlist[$k]['graph'] = "<img src=\"assets/images/leftbar.gif\" height=\"$l_size[1]\" width=\"$l_size[0]\" Alt=\"$hour - $hits\"><img src=\"assets/images/mainbar.gif\" Alt=\"$hour - $hits\" height=\"$m_size[1]\" width=\"$midbarsize\"><img src=\"assets/images/rightbar.gif\" height=\"$r_size[1]\" width=\"$r_size[0]\" Alt=\"$hour - $hits\">"; |
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
$xoopsDB->freeRecordSet($result); |
|
|
|
|
|
|
265
|
|
|
$xoopsTpl->assign('hourlist', $hourlist); |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
|
|
public static function getMonth($month) |
|
269
|
|
|
{ |
|
270
|
|
|
switch ($month) { |
|
271
|
|
|
case 1: |
|
272
|
|
|
return STATS_JANUARY; |
|
273
|
|
|
case 2: |
|
274
|
|
|
return STATS_FEBRUARY; |
|
275
|
|
|
case 3: |
|
276
|
|
|
return STATS_MARCH; |
|
277
|
|
|
case 4: |
|
278
|
|
|
return STATS_APRIL; |
|
279
|
|
|
case 5: |
|
280
|
|
|
return STATS_MAY; |
|
281
|
|
|
case 6: |
|
282
|
|
|
return STATS_JUNE; |
|
283
|
|
|
case 7: |
|
284
|
|
|
return STATS_JULY; |
|
285
|
|
|
case 8: |
|
286
|
|
|
return STATS_AUGUST; |
|
287
|
|
|
case 9: |
|
288
|
|
|
return STATS_SEPTEMBER; |
|
289
|
|
|
case 10: |
|
290
|
|
|
return STATS_OCTOBER; |
|
291
|
|
|
case 11: |
|
292
|
|
|
return STATS_NOVEMBER; |
|
293
|
|
|
default: |
|
294
|
|
|
return STATS_DECEMBER; |
|
295
|
|
|
} |
|
296
|
|
|
} |
|
297
|
|
|
|
|
298
|
|
|
/** |
|
299
|
|
|
* adminmenu() |
|
300
|
|
|
* |
|
301
|
|
|
* @param string $header optional : You can gice the menu a nice header |
|
302
|
|
|
* @param string $extra optional : You can gice the menu a nice footer |
|
303
|
|
|
* @param array|string $menu required : This is an array of links. U can |
|
304
|
|
|
* @param int $scount required : This will difine the amount of cells long the menu will have. |
|
305
|
|
|
* NB: using a value of 3 at the moment will break the menu where the cell colours will be off display. |
|
306
|
|
|
*/ |
|
307
|
|
|
public static function stats_adminmenu($header = '', $extra = '', $menu = '', $scount = 4) |
|
308
|
|
|
{ |
|
309
|
|
|
global $xoopsConfig, $xoopsModule; |
|
310
|
|
|
|
|
311
|
|
|
if (empty($menu)) { |
|
312
|
|
|
/** |
|
313
|
|
|
* You can change this part to suit your own module. Defining this here will save you form having to do this each time. |
|
314
|
|
|
*/ |
|
315
|
|
|
|
|
316
|
|
|
$menu = [ |
|
317
|
|
|
STATS_ADMENU1 => XOOPS_URL . '/modules/system/admin.php?fct=preferences&op=showmod&mod=' . $xoopsModule->getVar('mid'), |
|
318
|
|
|
STATS_ADMENU2 => 'index.php?op=' . INFO_GENERAL, |
|
319
|
|
|
STATS_ADMENU3 => 'index.php?op=' . INFO_CREDITS, |
|
320
|
|
|
STATS_ADMENU4 => 'index.php?op=' . INFO_CONFIGURATION, |
|
321
|
|
|
STATS_ADMENU5 => 'index.php?op=' . INFO_MODULES, |
|
322
|
|
|
STATS_ADMENU6 => 'index.php?op=' . INFO_ENVIRONMENT, |
|
323
|
|
|
STATS_ADMENU7 => 'index.php?op=' . INFO_VARIABLES, |
|
324
|
|
|
STATS_ADMENU8 => 'index.php?op=' . INFO_LICENSE, |
|
325
|
|
|
STATS_ADMENU9 => 'index.php?op=' . INFO_ALL, |
|
326
|
|
|
STATS_ADMENU10 => 'index.php?op=remote_addr', |
|
327
|
|
|
STATS_ADMENU11 => 'index.php?op=refer', |
|
328
|
|
|
STATS_ADMENU12 => 'index.php?op=userscreen', |
|
329
|
|
|
]; |
|
330
|
|
|
} |
|
331
|
|
|
|
|
332
|
|
|
$oddnum = [1 => '1', 3 => '3', 5 => '5', 7 => '7', 9 => '9', 11 => '11', 13 => '13']; |
|
333
|
|
|
|
|
334
|
|
|
/** |
|
335
|
|
|
* the amount of cells per menu row |
|
336
|
|
|
*/ |
|
337
|
|
|
$count = 0; |
|
338
|
|
|
/** |
|
339
|
|
|
* Set up the first class |
|
340
|
|
|
*/ |
|
341
|
|
|
$class = 'even'; |
|
342
|
|
|
/** |
|
343
|
|
|
* Sets up the width of each menu cell |
|
344
|
|
|
*/ |
|
345
|
|
|
|
|
346
|
|
|
echo '<h3>' . $header . '</h3>'; |
|
347
|
|
|
echo "<table width = '100%' cellpadding= '2' cellspacing= '1' class='outer'><tr>"; |
|
348
|
|
|
|
|
349
|
|
|
/** |
|
350
|
|
|
* Check to see if $menu is and array |
|
351
|
|
|
*/ |
|
352
|
|
|
if (is_array($menu)) { |
|
353
|
|
|
foreach ($menu as $menutitle => $menulink) { |
|
354
|
|
|
++$count; |
|
355
|
|
|
$width = 100 / $scount; |
|
356
|
|
|
$width = round($width); |
|
357
|
|
|
/** |
|
358
|
|
|
* Menu table begin |
|
359
|
|
|
*/ |
|
360
|
|
|
echo "<td class='$class' align='center' valign='middle' width= $width%>"; |
|
361
|
|
|
echo "<a href='" . $menulink . "'>" . $menutitle . '</a></td>'; |
|
362
|
|
|
|
|
363
|
|
|
/** |
|
364
|
|
|
* Break menu cells to start a new row if $count > $scount |
|
365
|
|
|
*/ |
|
366
|
|
|
if ($count >= $scount) { |
|
367
|
|
|
/** |
|
368
|
|
|
* If $class is the same for the end and start cells, invert $class |
|
369
|
|
|
*/ |
|
370
|
|
|
$class = ('odd' === $class && in_array($count, $oddnum)) ? 'even' : 'odd'; |
|
371
|
|
|
echo '</tr>'; |
|
372
|
|
|
$count = 0; |
|
373
|
|
|
} else { |
|
374
|
|
|
$class = ('even' === $class) ? 'odd' : 'even'; |
|
375
|
|
|
} |
|
376
|
|
|
} |
|
377
|
|
|
/** |
|
378
|
|
|
* checks to see if there are enough cell to fill menu row, if not add empty cells |
|
379
|
|
|
*/ |
|
380
|
|
|
if ($count >= 1) { |
|
381
|
|
|
$counter = 0; |
|
382
|
|
|
while ($counter < $scount - $count) { |
|
383
|
|
|
echo '<td class="' . $class . '"> </td>'; |
|
384
|
|
|
$class = ('even' === $class) ? 'odd' : 'even'; |
|
385
|
|
|
++$counter; |
|
386
|
|
|
} |
|
387
|
|
|
} |
|
388
|
|
|
echo '</table><br>'; |
|
389
|
|
|
} |
|
390
|
|
|
if ($extra) { |
|
391
|
|
|
echo "<div>$extra</div>"; |
|
392
|
|
|
} |
|
393
|
|
|
} |
|
394
|
|
|
|
|
395
|
|
|
} |
|
396
|
|
|
|