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 session |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
public function forceLogout($uid) |
19
|
|
|
{ |
20
|
|
|
$user = User::getById($uid, gGetDb()); |
21
|
|
|
|
22
|
|
|
if ($user->getForceLogout() == "1") { |
|
|
|
|
23
|
|
|
$_SESSION = array(); |
24
|
|
|
if (isset($_COOKIE[session_name()])) { |
25
|
|
|
setcookie(session_name(), '', time() - 42000, '/'); |
26
|
|
|
} |
27
|
|
|
session_destroy( ); |
28
|
|
|
|
29
|
|
|
BootstrapSkin::displayInternalHeader(); |
30
|
|
|
|
31
|
|
|
echo "You have been forcibly logged out, probably due to being renamed. Please log back in."; |
32
|
|
|
|
33
|
|
|
BootstrapSkin::displayAlertBox("You have been forcibly logged out, probably due to being renamed. Please log back in.", "alert-error", "Logged out", true, false); |
34
|
|
|
|
35
|
|
|
$user->setForceLogout(0); |
|
|
|
|
36
|
|
|
$user->save(); |
37
|
|
|
|
38
|
|
|
BootstrapSkin::displayInternalFooter(); |
39
|
|
|
die(); |
|
|
|
|
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Check the user's security level on page load, and bounce accordingly |
45
|
|
|
* |
46
|
|
|
* @deprecated |
47
|
|
|
*/ |
48
|
|
|
public function checksecurity() |
49
|
|
|
{ |
50
|
|
|
global $secure, $smarty; |
51
|
|
|
|
52
|
|
|
// CommunityUser has no database row, and we really don't want CommunityUser to have oauth credentials... |
53
|
|
|
if (!User::getCurrent()->isCommunityUser()) { |
54
|
|
|
if (User::getCurrent()->getStoredOnWikiName() == "##OAUTH##" |
55
|
|
|
&& User::getCurrent()->getOAuthAccessToken() == null |
56
|
|
|
) { |
57
|
|
|
reattachOAuthAccount(User::getCurrent()); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
if (User::getCurrent()->isOAuthLinked()) { |
61
|
|
|
try { |
62
|
|
|
// test retrieval of the identity |
63
|
|
|
User::getCurrent()->getOAuthIdentity(); |
64
|
|
|
} |
65
|
|
|
catch (TransactionException $ex) { |
66
|
|
|
User::getCurrent()->setOAuthAccessToken(null); |
67
|
|
|
User::getCurrent()->setOAuthAccessSecret(null); |
68
|
|
|
User::getCurrent()->save(); |
69
|
|
|
|
70
|
|
|
reattachOAuthAccount(User::getCurrent()); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
else { |
74
|
|
|
global $enforceOAuth; |
75
|
|
|
|
76
|
|
|
if ($enforceOAuth) { |
77
|
|
|
reattachOAuthAccount(User::getCurrent()); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
if (User::getCurrent()->isNew()) { |
83
|
|
|
BootstrapSkin::displayAlertBox("I'm sorry, but, your account has not been approved by a site administrator yet. Please stand by.", "alert-error", "New account", true, false); |
84
|
|
|
BootstrapSkin::displayInternalFooter(); |
85
|
|
|
die(); |
|
|
|
|
86
|
|
|
} |
87
|
|
|
elseif (User::getCurrent()->isSuspended()) { |
88
|
|
|
$database = gGetDb(); |
89
|
|
|
$suspendstatement = $database->prepare(<<<SQL |
90
|
|
|
SELECT comment |
91
|
|
|
FROM log |
92
|
|
|
WHERE action = 'Suspended' AND objectid = :userid and objecttype = 'User' |
93
|
|
|
ORDER BY timestamp DESC |
94
|
|
|
LIMIT 1; |
95
|
|
|
SQL |
96
|
|
|
); |
97
|
|
|
|
98
|
|
|
$suspendstatement->bindValue(":userid", User::getCurrent()->getId()); |
99
|
|
|
$suspendstatement->execute(); |
100
|
|
|
|
101
|
|
|
$suspendreason = $suspendstatement->fetchColumn(); |
102
|
|
|
$suspendstatement->closeCursor(); |
103
|
|
|
|
104
|
|
|
$smarty->assign("suspendreason", $suspendreason); |
105
|
|
|
$smarty->display("login/suspended.tpl"); |
106
|
|
|
BootstrapSkin::displayInternalFooter(); |
107
|
|
|
die(); |
|
|
|
|
108
|
|
|
} |
109
|
|
|
elseif (User::getCurrent()->isDeclined()) { |
110
|
|
|
$database = gGetDb(); |
111
|
|
|
$suspendstatement = $database->prepare(<<<SQL |
112
|
|
|
SELECT comment |
113
|
|
|
FROM log |
114
|
|
|
WHERE action = 'Declined' AND objectid = :userid and objecttype = 'User' |
115
|
|
|
ORDER BY timestamp DESC |
116
|
|
|
LIMIT 1; |
117
|
|
|
SQL |
118
|
|
|
); |
119
|
|
|
|
120
|
|
|
$suspendstatement->bindValue(":userid", User::getCurrent()->getId()); |
121
|
|
|
$suspendstatement->execute(); |
122
|
|
|
|
123
|
|
|
$suspendreason = $suspendstatement->fetchColumn(); |
124
|
|
|
$suspendstatement->closeCursor(); |
125
|
|
|
|
126
|
|
|
$smarty->assign("suspendreason", $suspendreason); |
127
|
|
|
$smarty->display("login/declined.tpl"); |
128
|
|
|
BootstrapSkin::displayInternalFooter(); |
129
|
|
|
die(); |
|
|
|
|
130
|
|
|
} |
131
|
|
|
elseif ((!User::getCurrent()->isCommunityUser()) && (User::getCurrent()->isUser() || User::getCurrent()->isAdmin())) { |
132
|
|
|
$secure = 1; |
133
|
|
|
} |
134
|
|
|
else { |
135
|
|
|
//die("Not logged in!"); |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
|