-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathuser.php
194 lines (182 loc) · 7.18 KB
/
user.php
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
<?php
/**
* Login page for users, will redirect to userinfo.php if the user is logged in
*
* @copyright http://www.impresscms.org/ The ImpressCMS Project
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License (GPL)
* @package Member
* @subpackage Users
* @version SVN: $Id: user.php 20898 2011-02-27 00:57:00Z skenow $
*/
$xoopsOption['pagetype'] = 'user';
include 'mainfile.php';
include_once ICMS_ROOT_PATH . '/include/functions.php';
$op = (isset($_GET['op']))
? trim(filter_input(INPUT_GET, 'op', FILTER_SANITIZE_STRING))
: ((isset($_POST['op'])) ? trim(filter_input(INPUT_POST, 'op', FILTER_SANITIZE_STRING)) : 'main');
switch ($op) {
default:
case 'main':
if (!icms::$user) {
if($icmsConfigAuth['auth_googleonly']) {
header('Location: ' . authenticationURL($icmsConfigAuth['auth_openid']));
exit();
}
$xoopsOption['template_main'] = 'system_userform.html';
include 'header.php';
$redirect = FALSE;
if (isset($_GET['xoops_redirect'])) {
$redirect = htmlspecialchars(trim($_GET['xoops_redirect']), ENT_QUOTES);
$isExternal = FALSE;
if ($pos = strpos($redirect, '://')) {
$icmsLocation = substr(ICMS_URL, strpos(ICMS_URL, '://') +3);
if (substr($redirect, $pos + 3, strlen($icmsLocation)) != $icmsLocation) {
$redirect = ICMS_URL;
} elseif (substr($redirect, $pos + 3, strlen($icmsLocation)+1) == $icmsLocation . '.') {
$redirect = ICMS_URL;
}
}
}
icms_makeSmarty(array(
'usercookie' => isset($_COOKIE[$icmsConfig['usercookie']]) ? $_COOKIE[$icmsConfig['usercookie']] : FALSE,
'lang_login' => _LOGIN,
'lang_username' => _USERNAME,
'redirect_page' => $redirect,
'lang_password' => _PASSWORD,
'lang_notregister' => _US_NOTREGISTERED,
'lang_lostpassword' => _US_LOSTPASSWORD,
'lang_noproblem' => _US_NOPROBLEM,
'lang_youremail' => _US_YOUREMAIL,
'lang_sendpassword' => _US_SENDPASSWORD,
'lang_rememberme' => _US_REMEMBERME,
'lang_youoid' => _US_OPENID_URL,
'lang_login_oid' => _US_OPENID_LOGIN,
'lang_login_okta' => _US_OKTA_LOGIN,
'lang_back2normoid' => _US_OPENID_NORMAL_LOGIN,
'mailpasswd_token' => icms::$security->createToken(),
'allow_registration' => $icmsConfigUser['allow_register'],
'rememberme' => $icmsConfigUser['remember_me'],
'auth_openid' => $icmsConfigAuth['auth_openid'],
'auth_url' => authenticationURL($icmsConfigAuth['auth_openid']),
'auth_okta' => $icmsConfigAuth['auth_okta'],
'icms_pagetitle' => _LOGIN
));
include 'footer.php';
} elseif (!empty($_GET['xoops_redirect'])) {
$redirect = htmlspecialchars(trim($_GET['xoops_redirect']));
$isExternal = FALSE;
if ($pos = strpos($redirect, '://')) {
$icmsLocation = substr(ICMS_URL, strpos(ICMS_URL, '://') +3);
if (substr($redirect, $pos + 3, strlen($icmsLocation)) != $icmsLocation) {
$redirect = ICMS_URL;
} elseif (substr($redirect, $pos + 3, strlen($icmsLocation)+1) == $icmsLocation . '.') {
$redirect = ICMS_URL;
}
}
header('Location: ' . $redirect);
exit();
} else {
header('Location: ' . ICMS_URL . '/userinfo.php?uid='. (int) icms::$user->getVar('uid'));
exit();
}
exit();
break;
case 'login':
include_once ICMS_ROOT_PATH . '/include/checklogin.php';
exit();
break;
case 'logout':
if (icms::$user) {
$sessHandler = icms::$session;
$sessHandler->sessionClose(icms::$user->getVar('uid'));
}
redirect_header(ICMS_URL . '/index.php', 3, _US_LOGGEDOUT . '<br />' . _US_THANKYOUFORVISIT);
break;
case 'actv':
$id = (int) $_GET['id'];
$actkey = trim(filter_input(INPUT_GET, 'actkey'));
if (empty($id)) {
redirect_header('index.php',1,'');
}
$member_handler = icms::handler('icms_member');
$thisuser =& $member_handler->getUser($id);
if (!is_object($thisuser)) {
exit();
}
if ($thisuser->getVar('actkey') != $actkey) {
redirect_header('index.php',5,_US_ACTKEYNOT);
} else {
if ($thisuser->getVar('level') > 0) {
redirect_header('user.php', 5, _US_ACONTACT, FALSE);
} else {
if (FALSE !== $member_handler->activateUser($thisuser)) {
if ($icmsConfigUser['activation_type'] == 2) {
$icmsMailer = new icms_messaging_Handler();
$icmsMailer->useMail();
$icmsMailer->setTemplate('activated.tpl');
$icmsMailer->assign('SITENAME', $icmsConfig['sitename']);
$icmsMailer->assign('ADMINMAIL', $icmsConfig['adminmail']);
$icmsMailer->assign('SITEURL', ICMS_URL . '/');
$icmsMailer->setToUsers($thisuser);
$icmsMailer->setFromEmail($icmsConfig['adminmail']);
$icmsMailer->setFromName($icmsConfig['sitename']);
$icmsMailer->setSubject(sprintf(_US_YOURACCOUNT, $icmsConfig['sitename']));
include 'header.php';
if (!$icmsMailer->send()) {
printf(_US_ACTVMAILNG, $thisuser->getVar('uname'));
} else {
printf(_US_ACTVMAILOK, $thisuser->getVar('uname'));
}
include 'footer.php';
} else {
$thisuser->sendWelcomeMessage();
redirect_header('user.php', 3, _US_ACTLOGIN, FALSE);
}
} else {
redirect_header('index.php', 3, 'Activation failed!');
}
}
}
exit();
break;
case 'delete':
if (!icms::$user || $icmsConfigUser['self_delete'] != 1) {
redirect_header('index.php',5,_US_NOPERMISS);
} else {
$groups = icms::$user->getGroups();
if (in_array(XOOPS_GROUP_ADMIN, $groups)) {
redirect_header('user.php', 5, _US_ADMINNO);
}
$ok = !isset($_POST['ok']) ? 0 : (int) $_POST['ok'];
if ($ok != 1) {
include 'header.php';
icms_core_Message::confirm(array('op' => 'delete', 'ok' => 1), 'user.php', _US_SURETODEL . '<br/>' . _US_REMOVEINFO);
include 'footer.php';
} else {
$del_uid = (int) icms::$user->getVar('uid');
$member_handler = icms::handler('icms_member');
if (FALSE != $member_handler->deleteUser(icms::$user)) {
$online_handler = icms::handler('icms_core_Online');
$online_handler->destroy($del_uid);
xoops_notification_deletebyuser($del_uid);
redirect_header('index.php', 5, _US_BEENDELED);
}
redirect_header('index.php',5,_US_NOPERMISS);
}
exit();
}
break;
// when users do not have permission, display a message instead of getting into a redirect loop
case 'nopermission':
if (!icms::$user){
redirect_header('index.php', 5, _US_NOPERMISS);
} elseif (!empty($_GET['xoops_redirect'])) {
redirect_header(ICMS_URL."/modules/formulize/application.php?id=all", 5,
"Sorry, you do not have permission to view this page. Please contact your site administrator.");
exit();
} else {
header('Location: ' . ICMS_URL . '/userinfo.php?uid=' . intval(icms::$user->getVar('uid')));
exit();
}
break;
}