XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
user.php
Go to the documentation of this file.
1 <?php
21 $xoopsOption['pagetype'] = 'user';
22 include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'header.php';
23 
24 $op = 'main';
25 
26 if (isset($_POST['op'])) {
27  $op = trim($_POST['op']);
28 } else if (isset($_GET['op'])) {
29  $op = trim($_GET['op']);
30 }
31 
32 if ( $op == 'main' ) {
33  if (!$GLOBALS['xoopsUser']) {
34  $xoopsOption['template_main'] = 'profile_userform.html';
35  include $GLOBALS['xoops']->path('header.php');
36  $GLOBALS['xoopsTpl']->assign('lang_login', _LOGIN);
37  $GLOBALS['xoopsTpl']->assign('lang_username', _USERNAME);
38  if (isset($_GET['xoops_redirect'])) {
39  $GLOBALS['xoopsTpl']->assign('redirect_page', htmlspecialchars(trim($_GET['xoops_redirect']), ENT_QUOTES));
40  }
41  if ($GLOBALS['xoopsConfig']['usercookie']) {
42  $GLOBALS['xoopsTpl']->assign('lang_rememberme', _US_REMEMBERME);
43  }
44  $GLOBALS['xoopsTpl']->assign('lang_password', _PASSWORD);
45  $GLOBALS['xoopsTpl']->assign('lang_notregister', _US_NOTREGISTERED);
46  $GLOBALS['xoopsTpl']->assign('lang_lostpassword', _US_LOSTPASSWORD);
47  $GLOBALS['xoopsTpl']->assign('lang_noproblem', _US_NOPROBLEM);
48  $GLOBALS['xoopsTpl']->assign('lang_youremail', _US_YOUREMAIL);
49  $GLOBALS['xoopsTpl']->assign('lang_sendpassword', _US_SENDPASSWORD);
50  $GLOBALS['xoopsTpl']->assign('mailpasswd_token', $GLOBALS['xoopsSecurity']->createToken());
51  include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'footer.php';
52  exit();
53  }
54  if (!empty($_GET['xoops_redirect'])) {
55  $redirect = trim($_GET['xoops_redirect']);
56  $isExternal = false;
57  if ($pos = strpos($redirect, '://')) {
58  $xoopsLocation = substr( XOOPS_URL, strpos( XOOPS_URL, '://' ) + 3);
59  if (strcasecmp(substr($redirect, $pos + 3, strlen($xoopsLocation)), $xoopsLocation)) {
60  $isExternal = true;
61  }
62  }
63  if (!$isExternal) {
64  header('Location: ' . $redirect);
65  exit();
66  }
67  }
68  header('Location: ./userinfo.php?uid=' . $GLOBALS['xoopsUser']->getVar('uid'));
69  exit();
70 }
71 
72 if ($op == 'login') {
73  include_once $GLOBALS['xoops']->path('include/checklogin.php');
74  exit();
75 }
76 
77 if ($op == 'logout') {
78  $message = '';
79  // Regenerate a new session id and destroy old session
80  $GLOBALS["sess_handler"]->regenerate_id(true);
81  $_SESSION = array();
82  setcookie($GLOBALS['xoopsConfig']['usercookie'], 0, -1, '/', XOOPS_COOKIE_DOMAIN, 0);
83  setcookie($GLOBALS['xoopsConfig']['usercookie'], 0, - 1, '/');
84  // clear entry from online users table
85  if (is_object($GLOBALS['xoopsUser'])) {
86  $online_handler =& xoops_gethandler('online');
87  $online_handler->destroy($GLOBALS['xoopsUser']->getVar('uid'));
88  }
89  $message = _US_LOGGEDOUT . '<br />' . _US_THANKYOUFORVISIT;
90  redirect_header(XOOPS_URL . '/', 1, $message);
91  exit();
92 }
93 
94 if ($op == 'actv') {
95  $id = intval($_GET['id']);
96  $actkey = trim($_GET['actkey']);
97  redirect_header("activate.php?op=actv&amp;id={$id}&amp;actkey={$actkey}", 1, '');
98  exit();
99 }
100 
101 if ($op == 'delete') {
102  $config_handler =& xoops_gethandler('config');
103  $GLOBALS['xoopsConfigUser'] = $config_handler->getConfigsByCat(XOOPS_CONF_USER);
104  if (!$GLOBALS['xoopsUser'] || $GLOBALS['xoopsConfigUser']['self_delete'] != 1) {
105  redirect_header(XOOPS_URL . '/', 5, _US_NOPERMISS);
106  exit();
107  } else {
108  $groups = $GLOBALS['xoopsUser']->getGroups();
109  if (in_array(XOOPS_GROUP_ADMIN, $groups)){
110  // users in the webmasters group may not be deleted
111  redirect_header(XOOPS_URL . '/', 5, _US_ADMINNO);
112  exit();
113  }
114  $ok = !isset($_POST['ok']) ? 0 : intval($_POST['ok']);
115  if ($ok != 1) {
116  include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'header.php';
117  xoops_confirm(array('op' => 'delete', 'ok' => 1), 'user.php', _US_SURETODEL . '<br/>' . _US_REMOVEINFO);
118  include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'footer.php';
119  } else {
120  $del_uid = $GLOBALS['xoopsUser']->getVar("uid");
121  $member_handler =& xoops_gethandler('member');
122  if (false != $member_handler->deleteUser($GLOBALS['xoopsUser'])) {
123  $online_handler =& xoops_gethandler('online');
124  $online_handler->destroy($del_uid);
126  redirect_header(XOOPS_URL . '/', 5, _US_BEENDELED);
127  }
128  redirect_header(XOOPS_URL . '/', 5, _US_NOPERMISS);
129  }
130  exit();
131  }
132 }
133 ?>