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 BootstrapSkin |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* Summary of $tagstack |
19
|
|
|
* @var string[] |
20
|
|
|
*/ |
21
|
|
|
private static $tagstack = array(); |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Summary of displayPublicHeader |
25
|
|
|
*/ |
26
|
|
|
public static function displayPublicHeader() |
27
|
|
|
{ |
28
|
|
|
global $smarty; |
29
|
|
|
$smarty->display("header-external.tpl"); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Summary of displayInternalHeader |
34
|
|
|
*/ |
35
|
|
|
public static function displayInternalHeader() |
36
|
|
|
{ |
37
|
|
|
// userid |
38
|
|
|
// username |
39
|
|
|
// sitenotice |
40
|
|
|
global $smarty, $session; |
41
|
|
|
|
42
|
|
|
$userid = isset($_SESSION['userID']) ? $_SESSION['userID'] : 0; |
43
|
|
|
$user = isset($_SESSION['user']) ? $_SESSION['user'] : ""; |
44
|
|
|
$sitenotice = InterfaceMessage::get(InterfaceMessage::SITENOTICE); |
45
|
|
|
$smarty->assign("userid", $userid); |
46
|
|
|
$smarty->assign("username", $user); |
47
|
|
|
$smarty->assign("sitenotice", $sitenotice); |
48
|
|
|
$smarty->assign("alerts", SessionAlert::retrieve()); |
49
|
|
|
$smarty->display("header-internal.tpl"); |
50
|
|
|
|
51
|
|
|
if ($userid != 0) { |
52
|
|
|
User::getCurrent()->touchLastLogin(); |
53
|
|
|
|
54
|
|
|
$session->forceLogout($_SESSION['userID']); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Prints the public interface footer to the screen. |
60
|
|
|
*/ |
61
|
|
|
public static function displayPublicFooter() |
62
|
|
|
{ |
63
|
|
|
global $smarty; |
64
|
|
|
|
65
|
|
|
// close all declared open tags |
66
|
|
|
while (count(self::$tagstack) != 0) { |
67
|
|
|
echo array_pop(self::$tagstack); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
$online = ''; |
71
|
|
|
$smarty->assign("onlineusers", $online); |
72
|
|
|
$smarty->assign("tailscript", null); |
73
|
|
|
|
74
|
|
|
$smarty->display("footer.tpl"); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Prints the internal interface footer to the screen. |
80
|
|
|
* |
81
|
|
|
* @param string|null $tailscript JavaScript to append to the page, usually so it can call jQuery |
82
|
|
|
* @throws Exception |
83
|
|
|
*/ |
84
|
|
|
public static function displayInternalFooter($tailscript = null) |
85
|
|
|
{ |
86
|
|
|
global $smarty; |
87
|
|
|
|
88
|
|
|
// close all declared open tags |
89
|
|
|
while (count(self::$tagstack) != 0) { |
90
|
|
|
echo array_pop(self::$tagstack); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
$last5min = time() - 300; |
94
|
|
|
$last5mins = date("Y-m-d H:i:s", $last5min); |
95
|
|
|
|
96
|
|
|
$database = gGetDb(); |
97
|
|
|
$statement = $database->prepare("SELECT * FROM user WHERE lastactive > :lastfive;"); |
98
|
|
|
$statement->execute(array(":lastfive" => $last5mins)); |
99
|
|
|
$resultSet = $statement->fetchAll(PDO::FETCH_CLASS, "User"); |
100
|
|
|
$resultSetCount = count($resultSet); |
101
|
|
|
|
102
|
|
|
$creators = implode( |
103
|
|
|
", ", |
104
|
|
|
array_map( |
105
|
|
|
function($arg) |
106
|
|
|
{ |
107
|
|
|
/** @var User $arg */ |
108
|
|
|
return |
109
|
|
|
"<a href=\"statistics.php?page=Users&user=" |
110
|
|
|
. $arg->getId() |
111
|
|
|
. "\">" |
112
|
|
|
. htmlentities($arg->getUsername()) |
113
|
|
|
. "</a>"; |
114
|
|
|
}, |
115
|
|
|
$resultSet |
116
|
|
|
) |
117
|
|
|
); |
118
|
|
|
|
119
|
|
|
// not equal to one, as zero uses the plural form too. |
120
|
|
|
if ($resultSetCount != 1) { |
121
|
|
|
$onlinemessage = $resultSetCount . " Account Creators currently online (past 5 minutes): $creators"; |
122
|
|
|
} |
123
|
|
|
else { |
124
|
|
|
$onlinemessage = $resultSetCount . " Account Creator currently online (past 5 minutes): $creators"; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
$online = '<p class="span6 text-right"><small>' . $onlinemessage . '</small></p>'; |
128
|
|
|
|
129
|
|
|
if (isset($_SESSION['user'])) { |
130
|
|
|
$smarty->assign("onlineusers", $online); |
131
|
|
|
} |
132
|
|
|
else { |
133
|
|
|
$emptystring = ""; |
134
|
|
|
$smarty->assign("onlineusers", $emptystring); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
$smarty->assign("tailscript", $tailscript); |
138
|
|
|
|
139
|
|
|
$smarty->display("footer.tpl"); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Summary of displayAlertBox |
144
|
|
|
* @param string $message Message to show |
145
|
|
|
* @param string $type Alert type - use bootstrap css class |
146
|
|
|
* @param string $header the header of the box |
147
|
|
|
* @param bool $block Whether to make this a block or not |
148
|
|
|
* @param bool $closeable add a close button |
149
|
|
|
* @param bool $return return the content as a string, or display it. |
150
|
|
|
* @param bool $centre centre the box in the page, like a dialog. |
151
|
|
|
* @return null|string |
152
|
|
|
* @throws Exception |
153
|
|
|
* @throws SmartyException |
154
|
|
|
*/ |
155
|
|
|
public static function displayAlertBox( |
156
|
|
|
$message, |
157
|
|
|
$type = "", |
158
|
|
|
$header = "", |
159
|
|
|
$block = false, |
160
|
|
|
$closeable = true, |
161
|
|
|
$return = false, |
162
|
|
|
$centre = false |
163
|
|
|
) { |
164
|
|
|
global $smarty; |
165
|
|
|
$smarty->assign("alertmessage", $message); |
166
|
|
|
$smarty->assign("alerttype", $type); |
167
|
|
|
$smarty->assign("alertheader", $header); |
168
|
|
|
$smarty->assign("alertblock", $block); |
169
|
|
|
$smarty->assign("alertclosable", $closeable); |
170
|
|
|
|
171
|
|
|
$returnData = $smarty->fetch("alert.tpl"); |
172
|
|
|
|
173
|
|
|
if ($centre) { |
174
|
|
|
$returnData = '<div class="row-fluid"><div class="span8 offset2">' . $returnData . '</div></div>'; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
if ($return) { |
178
|
|
|
return $returnData; |
179
|
|
|
} |
180
|
|
|
else { |
181
|
|
|
echo $returnData; |
182
|
|
|
return null; |
183
|
|
|
} |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* Prints the account request form to the screen. |
188
|
|
|
* @deprecated |
189
|
|
|
*/ |
190
|
|
|
public static function displayRequestForm( ) |
191
|
|
|
{ |
192
|
|
|
global $smarty; |
193
|
|
|
$smarty->display("request-form.tpl"); |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* Push a close tag onto the tag stack. |
198
|
|
|
* |
199
|
|
|
* This will ensure that all tags are closed when you show the footer. |
200
|
|
|
* |
201
|
|
|
* @param string $tag The closing tag to display |
202
|
|
|
*/ |
203
|
|
|
public static function pushTagStack($tag) |
204
|
|
|
{ |
205
|
|
|
array_push(self::$tagstack, $tag); |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* Remove an item from the tagstack |
210
|
|
|
* @return string |
211
|
|
|
*/ |
212
|
|
|
public static function popTagStack() |
213
|
|
|
{ |
214
|
|
|
return array_pop(self::$tagstack); |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
public static function displayAccessDenied() |
218
|
|
|
{ |
219
|
|
|
self::displayAlertBox( |
220
|
|
|
"I'm sorry, but you do not have permission to access this page.", |
221
|
|
|
"alert-error", |
222
|
|
|
"Access Denied", |
223
|
|
|
true, |
224
|
|
|
false); |
225
|
|
|
} |
226
|
|
|
} |
227
|
|
|
|