XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
index.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'] = 'system_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  xoops_loadLanguage('user');
42  if ($GLOBALS['xoopsConfig']['usercookie']) {
43  $GLOBALS['xoopsTpl']->assign('lang_rememberme', _US_REMEMBERME);
44  }
45  $GLOBALS['xoopsTpl']->assign('lang_password', _PASSWORD);
46  $GLOBALS['xoopsTpl']->assign('lang_notregister', _US_NOTREGISTERED);
47  $GLOBALS['xoopsTpl']->assign('lang_lostpassword', _US_LOSTPASSWORD);
48  $GLOBALS['xoopsTpl']->assign('lang_noproblem', _US_NOPROBLEM);
49  $GLOBALS['xoopsTpl']->assign('lang_youremail', _US_YOUREMAIL);
50  $GLOBALS['xoopsTpl']->assign('lang_sendpassword', _US_SENDPASSWORD);
51  $GLOBALS['xoopsTpl']->assign('mailpasswd_token', $GLOBALS['xoopsSecurity']->createToken());
52  include 'footer.php';
53  exit();
54  }
55  if (!empty($_GET['xoops_redirect']) ) {
56  $redirect = trim($_GET['xoops_redirect']);
57  $isExternal = false;
58  if ($pos = strpos($redirect, '://')) {
59  $xoopsLocation = substr(XOOPS_URL, strpos( XOOPS_URL, '://' ) + 3);
60  if (strcasecmp(substr($redirect, $pos + 3, strlen($xoopsLocation)), $xoopsLocation)) {
61  $isExternal = true;
62  }
63  }
64  if (!$isExternal ) {
65  header('Location: ' . $redirect);
66  exit();
67  }
68  }
69  header('Location: ./userinfo.php?uid=' . $GLOBALS['xoopsUser']->getVar('uid'));
70  exit();
71 }
72 
73 if ($op == 'login') {
74  include_once $GLOBALS['xoops']->path('include/checklogin.php');
75  exit();
76 }
77 
78 if ($op == 'logout') {
79  $message = '';
80  $_SESSION = array();
81  session_destroy();
82  setcookie($GLOBALS['xoopsConfig']['usercookie'], 0, - 1, '/');
83  setcookie($GLOBALS['xoopsConfig']['usercookie'], 0, -1, '/', XOOPS_COOKIE_DOMAIN, 0);
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 $GLOBALS['xoops']->path('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 ?>