-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkbase_stats.php
More file actions
346 lines (330 loc) · 14.9 KB
/
Copy pathkbase_stats.php
File metadata and controls
346 lines (330 loc) · 14.9 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
<?php
require_once("../../class2.php");
if (!defined('e107_INIT'))
{
exit;
}
require_once("includes/kbase_class.php");
if (!is_object($kbase_obj)) {
$kbase_obj=new KBASE;
}
if (!$kbase_obj->kbase_viewstats)
{
require_once(HEADERF);
print "Not permitted to view stats";
require_once(FOOTERF);
exit;
}
$barl = (file_exists(THEME . "images/barl.png") ? THEME . "images/barl.png" : e_PLUGIN . "poll/images/barl.png");
$barr = (file_exists(THEME . "images/barr.png") ? THEME . "images/barr.png" : e_PLUGIN . "poll/images/barr.png");
$bar = (file_exists(THEME . "images/bar.png") ? THEME . "images/bar.png" : e_PLUGIN . "poll/images/bar.png");
require_once(HEADERF);
// Top Items
// Top 10 popular authors
// top 10 popular books
// top 10 rated books
// top 10 rated authors
$kbase_gen = new convert;
$kbase_dlurl = e_BASE;
$numkbases = $sql->db_Count("kbase", "(*)", "where kbase_approved > 0", false);
$numcats = $sql->db_Count("kbase_info", "(*)", "where kbase_info_parent>0", false);
$sql->db_Select("kbase", "sum(kbase_views) as numviews", "where kbase_approved>0", false);
$kbase_row = $sql->db_Fetch();
$numviews = $kbase_row['numviews'];
$sql->db_Select("kbase", "sum(kbase_unique) as numunique", "where kbase_approved>0", false);
$kbase_row = $sql->db_Fetch();
$numunique = $kbase_row['numunique'];
$kbase_arg = "select count(c.comment_item_id) as numcom from #comments as c
left join #kbase as m on comment_item_id =kbase_id
where kbase_approved > 0 and comment_type='3'";
$sql->db_Select_gen($kbase_arg, false);
$kbase_row = $sql->db_Fetch();
$numcom = $kbase_row['numcom'];
$latedl .= "
<table class='fborder' style='width:100%;'>
<tr>
<td class='fcaption' colspan='4'>" . KBASELAN_110 . "</td>
</tr>";
if (file_exists("./images/kbase_logo.png"))
{
$latedl .= "<tr><td class='forumheader3' colspan='4' style='text-align:center;'><img src='./images/kbase_logo.png' alt='logo' title='' /></td></tr>";
}
$latedl .= "
<tr>
<td class='forumheader' colspan='4'>" . KBASELAN_109 . "</td>
</tr>
<tr>
<td class='forumheader3' colspan='2'>" . KBASELAN_107 . "</td>
<td class='forumheader3' colspan='2'>" . $numkbases . "</td>
</tr>
<tr>
<td class='forumheader3' colspan='2'>" . KBASELAN_108 . "</td>
<td class='forumheader3' colspan='2'>" . $numcats . "</td>
</tr>
<tr>
<td class='forumheader3' colspan='2'>" . KBASELAN_111 . "</td>
<td class='forumheader3' colspan='2'>" . $numviews . "</td>
</tr>
<tr>
<td class='forumheader3' colspan='2'>" . KBASELAN_112 . "</td>
<td class='forumheader3' colspan='2'>" . $numunique . "</td>
</tr>
<tr>
<td class='forumheader3' colspan='2'>" . KBASELAN_113 . "</td>
<td class='forumheader3' colspan='2'>" . $numcom . "</td>
</tr> ";
// ********************************************************************
// ********************************************************************
// Top 10 by views
// ********************************************************************
// ********************************************************************
$latedl .= "
<tr>
<td class='forumheader' colspan='4'>" . KBASELAN_120 . "</td>
</tr>
<tr>
<td class='forumheader2' style='width:45%;'>" . KBASELAN_121 . "</td>
<td class='forumheader2' style='width:5%;'>" . KBASELAN_122 . "</td>
<td class='forumheader2' style='width:10%;'>" . KBASELAN_123 . "</td>
<td class='forumheader2' style='width:40%;'> </td>
</tr>";
// Get top 10 by views
$sql->db_Select("kbase", "kbase_id,kbase_question,kbase_views,kbase_parent", "where kbase_approved>0 order by kbase_views desc limit 0,10", "nowhere", false);
while ($kbase_row = $sql->db_Fetch())
{
$percentage = round((($kbase_row['kbase_views'] / $numviews) * 100), 2);
$latedl .= "
<tr>
<td class='forumheader3' ><a href='" . e_PLUGIN . "kbase/kbase.php?0.cat.".$kbase_row['kbase_parent']."." . $kbase_row['kbase_id'] . "'><strong>" . $tp->toHTML($kbase_row['kbase_question']) . "</strong></a></td>
<td class='forumheader3' >" . $kbase_row['kbase_views'] . "</td>
<td class='forumheader3' >" . $percentage . "</td>
<td class='forumheader3'>
<div style='background-image: url($barl); width: 5px; height: 14px; float: left;'></div>
<div style='background-image: url($bar); width: " . intval($percentage) / 2 . "%; height: 14px; float: left;'></div>
<div style='background-image: url($barr); width: 5px; height: 14px; float: left;'></div>
</td>
</tr>";
} // while
// end // Top 10 by views
// ********************************************************************
// ********************************************************************
// Top 10 by unique views
// ********************************************************************
// ********************************************************************
$latedl .= "
<tr>
<td class='forumheader' colspan='4'>" . KBASELAN_124 . "</td>
</tr>
<tr>
<td class='forumheader2' style='width:45%;'>" . KBASELAN_121 . "</td>
<td class='forumheader2' style='width:5%;'>" . KBASELAN_122 . "</td>
<td class='forumheader2' style='width:10%;'>" . KBASELAN_123 . "</td>
<td class='forumheader2' style='width:40%;'> </td>
</tr>";
// Get top 10 by unique views
$sql->db_Select("kbase", "kbase_id,kbase_question,kbase_unique,kbase_parent", "where kbase_approved>0 order by kbase_unique desc limit 0,10", "nowhere", false);
while ($kbase_row = $sql->db_Fetch())
{
$percentage = round((($kbase_row['kbase_unique'] / $numunique) * 100), 2);
$latedl .= "
<tr>
<td class='forumheader3' ><a href='" . e_PLUGIN . "kbase/kbase.php?0.cat.".$kbase_row['kbase_parent']."." . $kbase_row['kbase_id'] . "'><strong>" . $tp->toHTML($kbase_row['kbase_question']) . "</strong></a></td>
<td class='forumheader3' >" . $kbase_row['kbase_unique'] . "</td>
<td class='forumheader3' >" . $percentage . "</td>
<td class='forumheader3'>
<div style='background-image: url($barl); width: 5px; height: 14px; float: left;'></div>
<div style='background-image: url($bar); width: " . intval($percentage) / 2 . "%; height: 14px; float: left;'></div>
<div style='background-image: url($barr); width: 5px; height: 14px; float: left;'></div>
</td>
</tr>";
} // while
// end // Top 10 by views
// ********************************************************************
// ********************************************************************
// Top 10 posters
// ********************************************************************
// ********************************************************************
$latedl .= "
<tr>
<td class='forumheader' colspan='4'>" . KBASELAN_125 . "</td>
</tr>
<tr>
<td class='forumheader2' style='width:45%;'>" . KBASELAN_127 . "</td>
<td class='forumheader2' style='width:5%;'>" . KBASELAN_126 . "</td>
<td class='forumheader2' style='width:10%;'>" . KBASELAN_123 . "</td>
<td class='forumheader2' style='width:40%;'> </td>
</tr>";
// Get top 10 authors
$sql->db_Select("kbase", "kbase_author, count(kbase_author) as numpost", "where kbase_approved > 0 group by kbase_author order by numpost desc limit 0,10", "nowhere", false);
while ($kbase_row = $sql->db_Fetch())
{
$percentage = round((($kbase_row['numpost'] / $numkbases) * 100), 2);
$kbase_tmp = explode(".", $kbase_row['kbase_author'], 2);
$latedl .= "
<tr>
<td class='forumheader3' ><a href='" . "../../user.php?id." . $kbase_tmp[0] . "'><strong>" . $tp->toFORM($kbase_tmp[1]) . "</strong></a></td>
<td class='forumheader3' >" . $kbase_row['numpost'] . "</td>
<td class='forumheader3' >" . $percentage . "</td>
<td class='forumheader3'>
<div style='background-image: url($barl); width: 5px; height: 14px; float: left;'></div>
<div style='background-image: url($bar); width: " . intval($percentage) / 2 . "%; height: 14px; float: left;'></div>
<div style='background-image: url($barr); width: 5px; height: 14px; float: left;'></div>
</td>
</tr>";
} // while
// end // Top 10 posters
// ********************************************************************
if ($KBASE_PREF['kbase_rating'] > 0)
{
// ********************************************************************
// Top 10 by rating
// ********************************************************************
// ********************************************************************
$latedl .= "
<tr>
<td class='forumheader' colspan='4'>" . KBASELAN_128 . "</td>
</tr>
<tr>
<td class='forumheader2' style='width:45%;'>" . KBASELAN_121 . "</td>
<td class='forumheader2' style='width:5%;'>" . KBASELAN_130 . "</td>
<td class='forumheader2' style='width:10%;'>" . KBASELAN_123 . "</td>
<td class='forumheader2' style='width:40%;'> </td>
</tr>";
// Get top 10 authors
$kbase_arg = "select r.*,m.*, r.rate_rating/r.rate_votes as rating from #rate as r
left join #kbase as m on rate_itemid=kbase_id
where rate_table='kbase' and kbase_approved > 0
order by rating desc
limit 0,10";
$sql->db_Select_gen($kbase_arg, false);
while ($kbase_row = $sql->db_Fetch())
{
$percentage = round((($kbase_row['rating'] / 10) * 100), 2);
$latedl .= "
<tr>
<td class='forumheader3' ><a href='" . e_PLUGIN . "kbase/kbase.php?0.cat.".$kbase_row['kbase_parent']."." . $kbase_row['kbase_id'] . "' ><strong>" . $tp->toFORM($kbase_row['kbase_question']) . "</strong></a></td>
<td class='forumheader3' >" . $kbase_row['rating'] . "</td>
<td class='forumheader3' >" . $percentage . "</td>
<td class='forumheader3'>
<div style='background-image: url($barl); width: 5px; height: 14px; float: left;'></div>
<div style='background-image: url($bar); width: " . intval($percentage) / 2 . "%; height: 14px; float: left;'></div>
<div style='background-image: url($barr); width: 5px; height: 14px; float: left;'></div>
</td>
</tr>";
} // while
// end // Top 10 by rating
// ********************************************************************
}
// Top 10 by comments
// ********************************************************************
// ********************************************************************
$latedl .= "
<tr>
<td class='forumheader' colspan='4'>" . KBASELAN_129 . "</td>
</tr>
<tr>
<td class='forumheader2' style='width:45%;'>" . KBASELAN_121 . "</td>
<td class='forumheader2' style='width:5%;'>" . KBASELAN_132 . "</td>
<td class='forumheader2' style='width:10%;'>" . KBASELAN_123 . "</td>
<td class='forumheader2' style='width:40%;'> </td>
</tr>";
// Get top 10 recipes by comments
$kbase_arg = "select count(c.comment_item_id) as numpost,m.* from #comments as c
left join #kbase as m on comment_item_id =kbase_id
where kbase_approved > 0 and comment_type='3' group by comment_item_id order by numpost desc limit 0,10";
$sql->db_Select_gen($kbase_arg, false);
while ($kbase_row = $sql->db_Fetch())
{
$percentage = round((($kbase_row['numpost'] / $numcom) * 100), 2);
$latedl .= "
<tr>
<td class='forumheader3' ><a href='" . e_PLUGIN . "kbase/kbase.php?0.cat.".$kbase_row['kbase_parent']."." . $kbase_row['kbase_id'] . "' ><strong>" . $tp->toFORM($kbase_row['kbase_question']) . "</strong></a></td>
<td class='forumheader3' >" . $kbase_row['numpost'] . "</td>
<td class='forumheader3' >" . $percentage . "</td>
<td class='forumheader3'>
<div style='background-image: url($barl); width: 5px; height: 14px; float: left;'></div>
<div style='background-image: url($bar); width: " . intval($percentage) / 2 . "%; height: 14px; float: left;'></div>
<div style='background-image: url($barr); width: 5px; height: 14px; float: left;'></div>
</td>
</tr>";
} // while
// end // Top 10 by comments
// ********************************************************************
// Top 10 Categories by KBASE
// ********************************************************************
// ********************************************************************
$latedl .= "
<tr>
<td class='forumheader' colspan='4'>" . KBASELAN_133 . "</td>
</tr>
<tr>
<td class='forumheader2' style='width:45%;'>" . KBASELAN_131 . "</td>
<td class='forumheader2' style='width:5%;'>" . KBASELAN_126 . "</td>
<td class='forumheader2' style='width:10%;'>" . KBASELAN_123 . "</td>
<td class='forumheader2' style='width:40%;'> </td>
</tr>";
// Get top categories by number of recipes
$kbase_arg = "select COUNT(r.kbase_id) as numpost,c.*,r.* from #kbase_info as c
left join #kbase as r on kbase_info_id=kbase_parent
where kbase_approved > 0
group by kbase_info_id
order by numpost desc
limit 0,10";
$sql->db_Select_gen($kbase_arg, false);
while ($kbase_row = $sql->db_Fetch())
{
$percentage = round((($kbase_row['numpost'] / $numkbases) * 100), 2);
$latedl .= "
<tr>
<td class='forumheader3' ><a href='" . e_PLUGIN . "kbase/kbase.php?0.cat.".$kbase_row['kbase_parent'].".0' ><strong>" . $tp->toFORM($kbase_row['kbase_info_title']) . "</strong></a></td>
<td class='forumheader3' >" . $kbase_row['numpost'] . "</td>
<td class='forumheader3' >" . $percentage . "</td>
<td class='forumheader3'>
<div style='background-image: url($barl); width: 5px; height: 14px; float: left;'></div>
<div style='background-image: url($bar); width: " . intval($percentage) / 2 . "%; height: 14px; float: left;'></div>
<div style='background-image: url($barr); width: 5px; height: 14px; float: left;'></div>
</td>
</tr>";
} // while
// end // top categories by number of kbases
// ********************************************************************
// Top 10 Categories by views
// ********************************************************************
// ********************************************************************
$latedl .= "
<tr>
<td class='forumheader' colspan='4'>" . KBASELAN_134 . "</td>
</tr>
<tr>
<td class='forumheader2' style='width:45%;'>" . KBASELAN_131 . "</td>
<td class='forumheader2' style='width:5%;'>" . KBASELAN_122 . "</td>
<td class='forumheader2' style='width:10%;'>" . KBASELAN_123 . "</td>
<td class='forumheader2' style='width:40%;'> </td>
</tr>";
// Get top 10 categories by views
$kbase_arg = "select sum(kbase_views) as numpost,c.*,r.* from #kbase_info as c
left join #kbase as r on kbase_info_id=kbase_parent
where kbase_approved>0 and kbase_views>0
group by kbase_info_id
order by numpost desc
limit 0,10";
$sql->db_Select_gen($kbase_arg, false);
while ($kbase_row = $sql->db_Fetch())
{
$percentage = round((($kbase_row['numpost'] / $numviews) * 100), 2);
$latedl .= "
<tr>
<td class='forumheader3' ><a href='" . e_PLUGIN . "kbase/kbase.php?0.cat.".$kbase_row['kbase_parent'].".0' ><strong>" . $tp->toFORM($kbase_row['kbase_info_title']) . "</strong></a></td>
<td class='forumheader3' >" . $kbase_row['numpost'] . "</td>
<td class='forumheader3' >" . $percentage . "</td>
<td class='forumheader3'>
<div style='background-image: url($barl); width: 5px; height: 14px; float: left;'></div>
<div style='background-image: url($bar); width: " . intval($percentage) / 2 . "%; height: 14px; float: left;'></div>
<div style='background-image: url($barr); width: 5px; height: 14px; float: left;'></div>
</td>
</tr>";
} // while
$latedl .= "</table>";
$ns->tablerender(KBASELAN_110, $latedl);
require_once(FOOTERF);
?>