XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
user.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
25 include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mainfile.php';
27 $xoopsPreload->triggerEvent('core.user.start');
28 
29 xoops_loadLanguage('user');
30 
31 $op = 'main';
32 if (isset($_POST['op'])) {
33  $op = trim($_POST['op']);
34 } elseif (isset($_GET['op'])) {
35  $op = trim($_GET['op']);
36 }
37 
38 if ($op == 'login') {
39  include_once $GLOBALS['xoops']->path('include/checklogin.php');
40  exit();
41 }
42 
43 if ($op == 'main') {
44  if (!$xoopsUser) {
45  $xoopsOption['template_main'] = 'system_userform.html';
46  include $GLOBALS['xoops']->path('header.php');
47  $xoopsTpl->assign('xoops_pagetitle', _LOGIN);
48  $xoTheme->addMeta('meta', 'keywords', _USERNAME . ", " . _US_PASSWORD . ", " . _US_LOSTPASSWORD);
49  $xoTheme->addMeta('meta', 'description', _US_LOSTPASSWORD . " " . _US_NOPROBLEM);
50  $xoopsTpl->assign('lang_login', _LOGIN);
51  $xoopsTpl->assign('lang_username', _USERNAME);
52  if (isset($_GET['xoops_redirect'])) {
53  $xoopsTpl->assign('redirect_page', htmlspecialchars(trim($_GET['xoops_redirect']), ENT_QUOTES));
54  }
55  if ($xoopsConfig['usercookie']) {
56  $xoopsTpl->assign('lang_rememberme', _US_REMEMBERME);
57  }
58  $xoopsTpl->assign('lang_password', _PASSWORD);
59  $xoopsTpl->assign('lang_notregister', _US_NOTREGISTERED);
60  $xoopsTpl->assign('lang_lostpassword', _US_LOSTPASSWORD);
61  $xoopsTpl->assign('lang_noproblem', _US_NOPROBLEM);
62  $xoopsTpl->assign('lang_youremail', _US_YOUREMAIL);
63  $xoopsTpl->assign('lang_sendpassword', _US_SENDPASSWORD);
64  $xoopsTpl->assign('mailpasswd_token', $GLOBALS['xoopsSecurity']->createToken());
65  include $GLOBALS['xoops']->path('footer.php');
66  exit();
67  }
68  if (!empty($_GET['xoops_redirect'])) {
69  $redirect = trim($_GET['xoops_redirect']);
70  $isExternal = false;
71  if ($pos = strpos($redirect, '://')) {
72  $xoopsLocation = substr(XOOPS_URL, strpos(XOOPS_URL, '://') + 3);
73  if (strcasecmp(substr($redirect, $pos + 3, strlen($xoopsLocation)), $xoopsLocation)) {
74  $isExternal = true;
75  }
76  }
77  if (! $isExternal) {
78  header('Location: ' . $redirect);
79  exit();
80  }
81  }
82  header('Location: ' . XOOPS_URL . '/userinfo.php?uid=' . $xoopsUser->getVar('uid'));
83  exit();
84 }
85 
86 if ($op == 'logout') {
87  $message = '';
88  // Regenerate a new session id and destroy old session
89  $GLOBALS["sess_handler"]->regenerate_id(true);
90  $_SESSION = array();
91  setcookie($xoopsConfig['usercookie'], 0, - 1, '/', XOOPS_COOKIE_DOMAIN, 0);
92  setcookie($xoopsConfig['usercookie'], 0, - 1, '/');
93  // clear entry from online users table
94  if (is_object($xoopsUser)) {
95  $online_handler =& xoops_gethandler('online');
96  $online_handler->destroy($xoopsUser->getVar('uid'));
97  }
98  $message = _US_LOGGEDOUT . '<br />' . _US_THANKYOUFORVISIT;
99  redirect_header('index.php', 1, $message);
100  exit();
101 }
102 
103 if ($op == 'actv') {
104  $GLOBALS['xoopsLogger']->addDeprecated("Deprecated code. The activation is now handled by register.php");
105  $id = intval($_GET['id']);
106  $actkey = trim($_GET['actkey']);
107  redirect_header("register.php?id={$id}&amp;actkey={$actkey}", 1, '');
108  exit();
109 
110  if (empty($id)) {
111  redirect_header('index.php', 1, '');
112  exit();
113  }
114  $member_handler =& xoops_gethandler('member');
115  $thisuser =& $member_handler->getUser($id);
116  if (!is_object($thisuser)) {
117  exit();
118  }
119  if ($thisuser->getVar('actkey') != $actkey) {
120  redirect_header('index.php', 5, _US_ACTKEYNOT);
121  } else {
122  if ($thisuser->getVar('level') > 0) {
123  redirect_header('user.php', 5, _US_ACONTACT, false);
124  } else {
125  if (false != $member_handler->activateUser($thisuser)) {
126  $config_handler =& xoops_gethandler('config');
128  if ($xoopsConfigUser['activation_type'] == 2) {
130  $xoopsMailer =& xoops_getMailer();
131  $xoopsMailer->useMail();
132  $xoopsMailer->setTemplate('activated.tpl');
133  $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']);
134  $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']);
135  $xoopsMailer->assign('SITEURL', XOOPS_URL . "/");
136  $xoopsMailer->setToUsers($thisuser);
137  $xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
138  $xoopsMailer->setFromName($xoopsConfig['sitename']);
139  $xoopsMailer->setSubject(sprintf(_US_YOURACCOUNT, $xoopsConfig['sitename']));
140  include $GLOBALS['xoops']->path('header.php');
141  if (!$xoopsMailer->send()) {
142  printf(_US_ACTVMAILNG, $thisuser->getVar('uname'));
143  } else {
144  printf(_US_ACTVMAILOK, $thisuser->getVar('uname'));
145  }
146  include $GLOBALS['xoops']->path('footer.php');
147  } else {
148  redirect_header('user.php', 5, _US_ACTLOGIN, false);
149  }
150  } else {
151  //TODO remove hardcoded string
152  redirect_header('index.php', 5, 'Activation failed!');
153  }
154  }
155  }
156  exit();
157 }
158 
159 if ($op == 'delete') {
160  $config_handler =& xoops_gethandler('config');
162  if (!$xoopsUser || $xoopsConfigUser['self_delete'] != 1) {
163  redirect_header('index.php', 5, _US_NOPERMISS);
164  exit();
165  } else {
166  $groups = $xoopsUser->getGroups();
167  if (in_array(XOOPS_GROUP_ADMIN, $groups)) {
168  // users in the webmasters group may not be deleted
169  redirect_header('user.php', 5, _US_ADMINNO);
170  exit();
171  }
172  $ok = !isset($_POST['ok']) ? 0 : intval($_POST['ok']);
173  if ($ok != 1) {
174  include $GLOBALS['xoops']->path('header.php');
176  array('op' => 'delete', 'ok' => 1),
177  'user.php',
178  _US_SURETODEL . '<br/>' . _US_REMOVEINFO);
179  include $GLOBALS['xoops']->path('footer.php');
180  } else {
181  $del_uid = $xoopsUser->getVar("uid");
182  $member_handler =& xoops_gethandler('member');
183  if (false != $member_handler->deleteUser($xoopsUser)) {
184  $online_handler =& xoops_gethandler('online');
185  $online_handler->destroy($del_uid);
187  redirect_header('index.php', 5, _US_BEENDELED);
188  }
189  redirect_header('index.php', 5, _US_NOPERMISS);
190  }
191  exit();
192  }
193 }
194 ?>