| 1 | <?php |
|---|
| 2 | // $Id: user.php,v 1.2.6.1 2005/03/30 15:49:04 onokazu Exp $ |
|---|
| 3 | // ------------------------------------------------------------------------ // |
|---|
| 4 | // XOOPS - PHP Content Management System // |
|---|
| 5 | // Copyright (c) 2000 XOOPS.org // |
|---|
| 6 | // <http://www.xoops.org/> // |
|---|
| 7 | // ------------------------------------------------------------------------ // |
|---|
| 8 | // This program is free software; you can redistribute it and/or modify // |
|---|
| 9 | // it under the terms of the GNU General Public License as published by // |
|---|
| 10 | // the Free Software Foundation; either version 2 of the License, or // |
|---|
| 11 | // (at your option) any later version. // |
|---|
| 12 | // // |
|---|
| 13 | // You may not change or alter any portion of this comment or credits // |
|---|
| 14 | // of supporting developers from this source code or any supporting // |
|---|
| 15 | // source code which is considered copyrighted (c) material of the // |
|---|
| 16 | // original comment or credit authors. // |
|---|
| 17 | // // |
|---|
| 18 | // This program is distributed in the hope that it will be useful, // |
|---|
| 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|---|
| 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|---|
| 21 | // GNU General Public License for more details. // |
|---|
| 22 | // // |
|---|
| 23 | // You should have received a copy of the GNU General Public License // |
|---|
| 24 | // along with this program; if not, write to the Free Software // |
|---|
| 25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|---|
| 26 | // ------------------------------------------------------------------------ // |
|---|
| 27 | |
|---|
| 28 | $xoopsOption['pagetype'] = 'user'; |
|---|
| 29 | include 'mainfile.php'; |
|---|
| 30 | |
|---|
| 31 | $op = 'main'; |
|---|
| 32 | |
|---|
| 33 | if ( isset($_POST['op']) ) { |
|---|
| 34 | $op = trim($_POST['op']); |
|---|
| 35 | } elseif ( isset($_GET['op']) ) { |
|---|
| 36 | $op = trim($_GET['op']); |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | if ($op == 'main') { |
|---|
| 40 | if ( !$xoopsUser ) { |
|---|
| 41 | $xoopsOption['template_main'] = 'system_userform.html'; |
|---|
| 42 | include 'header.php'; |
|---|
| 43 | $xoopsTpl->assign('lang_login', _LOGIN); |
|---|
| 44 | $xoopsTpl->assign('lang_username', _USERNAME); |
|---|
| 45 | if (isset($_COOKIE[$xoopsConfig['usercookie']])) { |
|---|
| 46 | $xoopsTpl->assign('usercookie', $_COOKIE[$xoopsConfig['usercookie']]); |
|---|
| 47 | } |
|---|
| 48 | if (isset($_GET['xoops_redirect'])) { |
|---|
| 49 | $xoopsTpl->assign('redirect_page', htmlspecialchars(trim($_GET['xoops_redirect']), ENT_QUOTES)); |
|---|
| 50 | } |
|---|
| 51 | $xoopsTpl->assign('lang_password', _PASSWORD); |
|---|
| 52 | $xoopsTpl->assign('lang_notregister', _US_NOTREGISTERED); |
|---|
| 53 | $xoopsTpl->assign('lang_lostpassword', _US_LOSTPASSWORD); |
|---|
| 54 | $xoopsTpl->assign('lang_noproblem', _US_NOPROBLEM); |
|---|
| 55 | $xoopsTpl->assign('lang_youremail', _US_YOUREMAIL); |
|---|
| 56 | $xoopsTpl->assign('lang_sendpassword', _US_SENDPASSWORD); |
|---|
| 57 | include 'footer.php'; |
|---|
| 58 | } elseif ( $xoopsUser ) { |
|---|
| 59 | header('Location: '.XOOPS_URL.'/userinfo.php?uid='.$xoopsUser->getVar('uid')); |
|---|
| 60 | } |
|---|
| 61 | exit(); |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | if ($op == 'login') { |
|---|
| 65 | include_once XOOPS_ROOT_PATH.'/include/checklogin.php'; |
|---|
| 66 | exit(); |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | if ($op == 'logout') { |
|---|
| 70 | $message = ''; |
|---|
| 71 | $_SESSION = array(); |
|---|
| 72 | session_destroy(); |
|---|
| 73 | if ($xoopsConfig['use_mysession'] && $xoopsConfig['session_name'] != '') { |
|---|
| 74 | setcookie($xoopsConfig['session_name'], '', time()- 3600, '/', '', 0); |
|---|
| 75 | } |
|---|
| 76 | // autologin hack GIJ (clear autologin cookies) |
|---|
| 77 | $xoops_cookie_path = defined('XOOPS_COOKIE_PATH') ? XOOPS_COOKIE_PATH : preg_replace( '?http://[^/]+(/.*)$?' , "$1" , XOOPS_URL ) ; |
|---|
| 78 | if( $xoops_cookie_path == XOOPS_URL ) $xoops_cookie_path = '/' ; |
|---|
| 79 | setcookie('autologin_uname', '', time() - 3600, $xoops_cookie_path, '', 0); |
|---|
| 80 | setcookie('autologin_pass', '', time() - 3600, $xoops_cookie_path, '', 0); |
|---|
| 81 | setcookie('autologin_uname', '', time() - 3600, '/', '', 0); // |
|---|
| 82 | setcookie('autologin_pass', '', time() - 3600, '/', '', 0); // for older auto login hacks (should be removed) |
|---|
| 83 | // end of autologin hack GIJ |
|---|
| 84 | // clear entry from online users table |
|---|
| 85 | if (is_object($xoopsUser)) { |
|---|
| 86 | $online_handler =& xoops_gethandler('online'); |
|---|
| 87 | $online_handler->destroy($xoopsUser->getVar('uid')); |
|---|
| 88 | } |
|---|
| 89 | $message = _US_LOGGEDOUT.'<br />'._US_THANKYOUFORVISIT; |
|---|
| 90 | redirect_header('index.php', 1, $message); |
|---|
| 91 | exit(); |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | if ($op == 'actv') { |
|---|
| 95 | $id = intval($_GET['id']); |
|---|
| 96 | $actkey = trim($_GET['actkey']); |
|---|
| 97 | if (empty($id)) { |
|---|
| 98 | redirect_header('index.php',1,''); |
|---|
| 99 | exit(); |
|---|
| 100 | } |
|---|
| 101 | $member_handler =& xoops_gethandler('member'); |
|---|
| 102 | $thisuser =& $member_handler->getUser($id); |
|---|
| 103 | if (!is_object($thisuser)) { |
|---|
| 104 | exit(); |
|---|
| 105 | } |
|---|
| 106 | if ($thisuser->getVar('actkey') != $actkey) { |
|---|
| 107 | redirect_header('index.php',5,_US_ACTKEYNOT); |
|---|
| 108 | } else { |
|---|
| 109 | if ($thisuser->getVar('level') > 0 ) { |
|---|
| 110 | redirect_header('user.php',5,_US_ACONTACT); |
|---|
| 111 | } else { |
|---|
| 112 | if (false != $member_handler->activateUser($thisuser)) { |
|---|
| 113 | $config_handler =& xoops_gethandler('config'); |
|---|
| 114 | $xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER); |
|---|
| 115 | if ($xoopsConfigUser['activation_type'] == 2) { |
|---|
| 116 | $myts =& MyTextSanitizer::getInstance(); |
|---|
| 117 | $xoopsMailer =& getMailer(); |
|---|
| 118 | $xoopsMailer->useMail(); |
|---|
| 119 | $xoopsMailer->setTemplate('activated.tpl'); |
|---|
| 120 | $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']); |
|---|
| 121 | $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); |
|---|
| 122 | $xoopsMailer->assign('SITEURL', XOOPS_URL."/"); |
|---|
| 123 | $xoopsMailer->setToUsers($thisuser); |
|---|
| 124 | $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); |
|---|
| 125 | $xoopsMailer->setFromName($xoopsConfig['sitename']); |
|---|
| 126 | $xoopsMailer->setSubject(sprintf(_US_YOURACCOUNT,$xoopsConfig['sitename'])); |
|---|
| 127 | include 'header.php'; |
|---|
| 128 | if ( !$xoopsMailer->send() ) { |
|---|
| 129 | printf(_US_ACTVMAILNG, $thisuser->getVar('uname')); |
|---|
| 130 | } else { |
|---|
| 131 | printf(_US_ACTVMAILOK, $thisuser->getVar('uname')); |
|---|
| 132 | } |
|---|
| 133 | include 'footer.php'; |
|---|
| 134 | } else { |
|---|
| 135 | redirect_header('user.php',5,_US_ACTLOGIN); |
|---|
| 136 | } |
|---|
| 137 | } else { |
|---|
| 138 | redirect_header('index.php',5,'Activation failed!'); |
|---|
| 139 | } |
|---|
| 140 | } |
|---|
| 141 | } |
|---|
| 142 | exit(); |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | if ($op == 'delete') { |
|---|
| 146 | $config_handler =& xoops_gethandler('config'); |
|---|
| 147 | $xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER); |
|---|
| 148 | if (!$xoopsUser || $xoopsConfigUser['self_delete'] != 1) { |
|---|
| 149 | redirect_header('index.php',5,_US_NOPERMISS); |
|---|
| 150 | exit(); |
|---|
| 151 | } else { |
|---|
| 152 | $groups = $xoopsUser->getGroups(); |
|---|
| 153 | if (in_array(XOOPS_GROUP_ADMIN, $groups)){ |
|---|
| 154 | // users in the webmasters group may not be deleted |
|---|
| 155 | redirect_header('user.php', 5, _US_ADMINNO); |
|---|
| 156 | exit(); |
|---|
| 157 | } |
|---|
| 158 | $ok = !isset($_POST['ok']) ? 0 : intval($_POST['ok']); |
|---|
| 159 | if ($ok != 1) { |
|---|
| 160 | include 'header.php'; |
|---|
| 161 | xoops_confirm(array('op' => 'delete', 'ok' => 1), 'user.php', _US_SURETODEL.'<br/>'._US_REMOVEINFO); |
|---|
| 162 | include 'footer.php'; |
|---|
| 163 | } else { |
|---|
| 164 | $del_uid = $xoopsUser->getVar("uid"); |
|---|
| 165 | $member_handler =& xoops_gethandler('member'); |
|---|
| 166 | if (false != $member_handler->deleteUser($xoopsUser)) { |
|---|
| 167 | $online_handler =& xoops_gethandler('online'); |
|---|
| 168 | $online_handler->destroy($del_uid); |
|---|
| 169 | xoops_notification_deletebyuser($del_uid); |
|---|
| 170 | redirect_header('index.php', 5, _US_BEENDELED); |
|---|
| 171 | } |
|---|
| 172 | redirect_header('index.php',5,_US_NOPERMISS); |
|---|
| 173 | } |
|---|
| 174 | exit(); |
|---|
| 175 | } |
|---|
| 176 | } |
|---|
| 177 | ?> |
|---|