1
|
|
|
<?php |
2
|
|
|
/************************************************************************** |
3
|
|
|
********** English Wikipedia Account Request Interface ********** |
4
|
|
|
*************************************************************************** |
5
|
|
|
** Wikipedia Account Request Graphic Design by Charles Melbye, ** |
6
|
|
|
** which is licensed under a Creative Commons ** |
7
|
|
|
** Attribution-Noncommercial-Share Alike 3.0 United States License. ** |
8
|
|
|
** ** |
9
|
|
|
** All other code are released under the Public Domain ** |
10
|
|
|
** by the ACC Development Team. ** |
11
|
|
|
** ** |
12
|
|
|
** See CREDITS for the list of developers. ** |
13
|
|
|
***************************************************************************/ |
14
|
|
|
|
15
|
|
|
class StatsMain extends StatisticsPage |
16
|
|
|
{ |
17
|
|
|
protected function execute() |
18
|
|
|
{ |
19
|
|
|
global $smarty, $filepath; |
20
|
|
|
|
21
|
|
|
$files = scandir($filepath . "/includes/statistics/"); |
22
|
|
|
|
23
|
|
|
$statsPageDefinitions = preg_grep("/php$/", $files); |
|
|
|
|
24
|
|
|
|
25
|
|
|
$statsPages = array(); |
26
|
|
|
|
27
|
|
|
foreach ($statsPageDefinitions as $i) { |
28
|
|
|
// TODO: is this require still needed? AutoLoader ftw. |
29
|
|
|
require_once($filepath . "/includes/statistics/" . $i); |
30
|
|
|
$expld = explode('.', $i); |
31
|
|
|
$className = $expld[0]; |
32
|
|
|
|
33
|
|
|
/** @var StatisticsPage $statsPageObject */ |
34
|
|
|
$statsPageObject = new $className; |
35
|
|
|
|
36
|
|
|
if ($statsPageObject->hideFromMenu() === false) { |
37
|
|
|
$statsPages[] = $statsPageObject; |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
$this->smallStats(); |
42
|
|
|
|
43
|
|
|
$smarty->assign("statsPages", $statsPages); |
44
|
|
|
|
45
|
|
|
$graphList = array("day", "2day", "4day", "week", "2week", "month", "3month"); |
46
|
|
|
$smarty->assign("graphList", $graphList); |
47
|
|
|
|
48
|
|
|
return $smarty->fetch("statistics/main.tpl"); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function getPageTitle() |
52
|
|
|
{ |
53
|
|
|
return "Account Creation Statistics"; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function getPageName() |
57
|
|
|
{ |
58
|
|
|
return "Main"; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function isProtected() |
62
|
|
|
{ |
63
|
|
|
return true; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function requiresWikiDatabase() |
67
|
|
|
{ |
68
|
|
|
return false; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function requiresSimpleHtmlEnvironment() |
72
|
|
|
{ |
73
|
|
|
return false; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function hideFromMenu() |
77
|
|
|
{ |
78
|
|
|
return true; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Gets the relevant statistics from the database for the small statistics table |
83
|
|
|
*/ |
84
|
|
|
private function smallStats() |
85
|
|
|
{ |
86
|
|
|
global $smarty; |
87
|
|
|
|
88
|
|
|
$database = gGetDb(); |
89
|
|
|
$requestsQuery = "SELECT COUNT(*) FROM request WHERE status = :status AND emailconfirm = 'Confirmed';"; |
90
|
|
|
|
91
|
|
|
$requestsStatement = $database->prepare($requestsQuery); |
92
|
|
|
|
93
|
|
|
// TODO: use the request states thing here. |
94
|
|
|
|
95
|
|
|
// Open Requests |
96
|
|
|
$requestsStatement->execute(array(":status" => "Open")); |
97
|
|
|
$open = $requestsStatement->fetchColumn(); |
98
|
|
|
$requestsStatement->closeCursor(); |
99
|
|
|
$smarty->assign("statsOpen", $open); |
100
|
|
|
|
101
|
|
|
// Admin Requests |
102
|
|
|
$requestsStatement->execute(array(":status" => "Flagged users")); |
103
|
|
|
$admin = $requestsStatement->fetchColumn(); |
104
|
|
|
$requestsStatement->closeCursor(); |
105
|
|
|
$smarty->assign("statsAdmin", $admin); |
106
|
|
|
|
107
|
|
|
// Checkuser Requests |
108
|
|
|
$requestsStatement->execute(array(":status" => "Checkuser")); |
109
|
|
|
$checkuser = $requestsStatement->fetchColumn(); |
110
|
|
|
$requestsStatement->closeCursor(); |
111
|
|
|
$smarty->assign("statsCheckuser", $checkuser); |
112
|
|
|
|
113
|
|
|
// Unconfirmed requests |
114
|
|
|
$unconfirmedStatement = $database->query("SELECT COUNT(*) FROM request WHERE emailconfirm != 'Confirmed' AND emailconfirm != '';"); |
115
|
|
|
$unconfirmed = $unconfirmedStatement->fetchColumn(); |
116
|
|
|
$unconfirmedStatement->closeCursor(); |
117
|
|
|
$smarty->assign("statsUnconfirmed", $unconfirmed); |
118
|
|
|
|
119
|
|
|
$userStatusStatement = $database->prepare("SELECT COUNT(*) FROM user WHERE status = :status;"); |
120
|
|
|
|
121
|
|
|
// Admin users |
122
|
|
|
$userStatusStatement->execute(array(":status" => "Admin")); |
123
|
|
|
$adminusers = $userStatusStatement->fetchColumn(); |
124
|
|
|
$userStatusStatement->closeCursor(); |
125
|
|
|
$smarty->assign("statsAdminUsers", $adminusers); |
126
|
|
|
|
127
|
|
|
// Users |
128
|
|
|
$userStatusStatement->execute(array(":status" => "User")); |
129
|
|
|
$users = $userStatusStatement->fetchColumn(); |
130
|
|
|
$userStatusStatement->closeCursor(); |
131
|
|
|
$smarty->assign("statsUsers", $users); |
132
|
|
|
|
133
|
|
|
// Suspended users |
134
|
|
|
$userStatusStatement->execute(array(":status" => "Suspended")); |
135
|
|
|
$suspendedUsers = $userStatusStatement->fetchColumn(); |
136
|
|
|
$userStatusStatement->closeCursor(); |
137
|
|
|
$smarty->assign("statsSuspendedUsers", $suspendedUsers); |
138
|
|
|
|
139
|
|
|
// New users |
140
|
|
|
$userStatusStatement->execute(array(":status" => "New")); |
141
|
|
|
$newUsers = $userStatusStatement->fetchColumn(); |
142
|
|
|
$userStatusStatement->closeCursor(); |
143
|
|
|
$smarty->assign("statsNewUsers", $newUsers); |
144
|
|
|
|
145
|
|
|
// Most comments on a request |
146
|
|
|
$mostCommentsStatement = $database->query("SELECT request FROM comment GROUP BY request ORDER BY COUNT(*) DESC LIMIT 1;"); |
147
|
|
|
$mostComments = $mostCommentsStatement->fetchColumn(); |
148
|
|
|
$mostCommentsStatement->closeCursor(); |
149
|
|
|
$smarty->assign("mostComments", $mostComments); |
150
|
|
|
} |
151
|
|
|
} |
152
|
|
|
|