XOOPS  2.6.0
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 
13 
27 include __DIR__ . '/mainfile.php';
28 
31 $xoops->events()->triggerEvent('core.user.start');
32 
33 $xoops->loadLanguage('user');
34 
35 // from $_POST we use keys: op, ok
37  'post',
38  array(
39  array('op','string'),
40  array('ok', 'boolean', 0, false),
41  ),
42  'op' // require op parameter to return results
43 );
44 if (!$clean_input) {
45  // no valid $_POST, use $_GET and set defaults
46  // from $_GET we use keys: op, xoops_redirect, id, actkey
48  'get',
49  array(
50  array('op','string','main',true),
51  array('xoops_redirect', 'weburl', '', true),
52  array('id', 'int', 0, false),
53  array('actkey', 'string', '', true),
54  )
55  );
56 }
57 $op = $clean_input['op'];
58 
59 if ($op == 'login') {
60  include_once $xoops->path('include/checklogin.php');
61  exit();
62 }
63 
64 if ($op == 'main') {
65  if (!$xoops->isUser()) {
66  $xoops->header('module:system/system_userform.tpl');
67  $xoops->tpl()->assign('xoops_pagetitle', XoopsLocale::A_LOGIN);
68  $xoops->theme()->addMeta(
69  'meta',
70  'keywords',
72  );
73  $xoops->theme()->addMeta(
74  'meta',
75  'description',
76  XoopsLocale::Q_LOST_YOUR_PASSWORD . " " . XoopsLocale::NO_PROBLEM_ENTER_EMAIL_WE_HAVE_ON_FILE
77  );
78  $xoops->tpl()->assign('lang_login', XoopsLocale::A_LOGIN);
79  $xoops->tpl()->assign('lang_username', XoopsLocale::C_USERNAME);
80  if (isset($clean_input['xoops_redirect'])) {
81  $xoops->tpl()->assign('redirect_page', htmlspecialchars($clean_input['xoops_redirect'], ENT_QUOTES));
82  }
83  if ($xoops->getConfig('usercookie')) {
84  $xoops->tpl()->assign('lang_rememberme', XoopsLocale::REMEMBER_ME);
85  }
86  $xoops->tpl()->assign('lang_password', XoopsLocale::C_PASSWORD);
87  $xoops->tpl()->assign('lang_lostpassword', XoopsLocale::Q_LOST_YOUR_PASSWORD);
88  $xoops->tpl()->assign('lang_noproblem', XoopsLocale::NO_PROBLEM_ENTER_EMAIL_WE_HAVE_ON_FILE);
89  $xoops->tpl()->assign('lang_youremail', XoopsLocale::C_YOUR_EMAIL);
90  $xoops->tpl()->assign('lang_sendpassword', XoopsLocale::SEND_PASSWORD);
91  $xoops->tpl()->assign('mailpasswd_token', $xoops->security()->createToken());
92  $xoops->footer();
93  }
94  if (!empty($clean_input['xoops_redirect'])) {
95  $redirect = $clean_input['xoops_redirect'];
96  $isExternal = false;
97  if ($pos = strpos($redirect, '://')) {
98  $xoopsLocation = substr($xoops_url, strpos($xoops_url, '://') + 3);
99  if (strcasecmp(substr($redirect, $pos + 3, strlen($xoopsLocation)), $xoopsLocation)) {
100  $isExternal = true;
101  }
102  }
103  if (!$isExternal) {
104  header('Location: ' . $redirect);
105  exit();
106  }
107  }
108  header('Location: ' . $xoops_url . '/userinfo.php?uid=' . $xoopsUser->getVar('uid'));
109  exit();
110 }
111 
112 if ($op == 'logout') {
113  $message = '';
114  $xoops->session()->user()->recordUserLogout();
115  // clear entry from online users table
116  if ($xoops->isUser()) {
117  $xoops->getHandlerOnline()->destroy($xoops->user->getVar('uid'));
118  }
120  $xoops->redirect($xoops_url . '/', 1, $message);
121 }
122 
123 if ($op == 'delete') {
124  $xoopsConfigUser = $xoops->getConfigs();
125  if (!$xoops->isUser() || $xoopsConfigUser['self_delete'] != 1) {
126  $xoops->redirect('index.php', 5, XoopsLocale::E_NO_ACTION_PERMISSION);
127  } else {
128  $groups = $xoops->user->getGroups();
129  if (in_array(FixedGroups::ADMIN, $groups)) {
130  // users in the webmasters group may not be deleted
132  }
133  $ok = !isset($clean_input['ok']) ? 0 : $clean_input['ok'];
134  if ($ok != 1) {
135  $xoops->header();
136  echo $xoops->confirm(
137  array('op' => 'delete', 'ok' => 1),
138  'user.php',
140  );
141  $xoops->footer();
142  } else {
143  $del_uid = $xoops->user->getVar("uid");
144  $member_handler = $xoops->getHandlerMember();
145  if (false != $member_handler->deleteUser($xoops->user)) {
146  $xoops->getHandlerOnline()->destroy($del_uid);
147  //todo, use preload here?
148  if ($xoops->isActiveModule('notifications')) {
149  Notifications::getInstance()->getHandlerNotification()->unsubscribeByUser($del_uid);
150  }
151  $xoops->redirect('index.php', 5, XoopsLocale::S_YOUR_ACCOUNT_DELETED);
152  }
153  $xoops->redirect('index.php', 5, XoopsLocale::E_NO_ACTION_PERMISSION);
154  }
155  }
156 }
const E_NO_ACTION_PERMISSION
Definition: en_US.php:352
if($uname== ''||$pass== '') $member_handler
Definition: checklogin.php:44
const Q_ARE_YOU_SURE_TO_DELETE_ACCOUNT
Definition: en_US.php:928
$xoopsConfigUser
Definition: register.php:33
static getInstance()
Definition: Xoops.php:160
const C_YOUR_EMAIL
Definition: en_US.php:198
static getInstance()
Definition: helper.php:47
const A_LOGIN
Definition: en_US.php:102
$clean_input
Definition: user.php:36
const S_YOU_ARE_NOW_LOGGED_OUT
Definition: en_US.php:1038
static gather($source, $input_map, $require=false)
const E_USER_IN_WEBMASTER_GROUP_CANNOT_BE_REMOVED
Definition: en_US.php:376
const THIS_WILL_REMOVE_ALL_YOUR_INFO
Definition: en_US.php:1047
exit
Definition: browse.php:104
$redirect
Definition: header.php:37
const C_USERNAME
Definition: en_US.php:194
const Q_LOST_YOUR_PASSWORD
Definition: en_US.php:932
const NO_PROBLEM_ENTER_EMAIL_WE_HAVE_ON_FILE
Definition: en_US.php:866
global $xoopsUser
Definition: config.php:132
const SEND_PASSWORD
Definition: en_US.php:978
static get($name)
const PASSWORD
Definition: en_US.php:895
const S_YOUR_ACCOUNT_DELETED
Definition: en_US.php:1035
$groups
if(!$clean_input) $op
Definition: user.php:57
const S_THANK_YOU_FOR_VISITING_OUR_SITE
Definition: en_US.php:1032
const USERNAME
Definition: en_US.php:1079
const C_PASSWORD
Definition: en_US.php:188
$xoops
Definition: user.php:29
$xoops_url
Definition: user.php:30
const REMEMBER_ME
Definition: en_US.php:952