// // ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // // the Free Software Foundation; either version 2 of the License, or // // (at your option) any later version. // // // // You may not change or alter any portion of this comment or credits // // of supporting developers from this source code or any supporting // // source code which is considered copyrighted (c) material of the // // original comment or credit authors. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License for more details. // // // // You should have received a copy of the GNU General Public License // // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // // Author: Kazumi Ono (AKA onokazu) // // URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // // Project: The XOOPS Project // // ------------------------------------------------------------------------- // if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) { exit("Access Denied"); } $op = 'mod_users'; include_once XOOPS_ROOT_PATH."/modules/system/admin/users/users.php"; if (isset($_GET['op'])) { $op = trim($_GET['op']); if (isset($_GET['uid'])) { $uid = intval($_GET['uid']); } } elseif (!empty($_POST['op'])) { $op = $_POST['op']; } switch ($op) { case "modifyUser": modifyUser($uid); break; case "updateUser": if(!XoopsMultiTokenHandler::quickValidate('users_updateUser')) system_users_error("Ticket Error"); $myts =& MyTextSanitizer::getInstance(); $uid = !empty($_POST['uid']) ? intval($_POST['uid']) : 0; $username = !empty($_POST['username']) ? $myts->stripSlashesGPC(trim($_POST['username'])) : ''; if ($uid > 0 && $username != '') { $member_handler =& xoops_gethandler('member'); $edituser =& $member_handler->getUser($uid); $myts =& MyTextSanitizer::getInstance(); if ($edituser->getVar('uname') != $username && $member_handler->getUserCount(new Criteria('uname', addslashes($username))) > 0) { xoops_cp_header(); echo 'User name '.htmlspecialchars($username).' already exists'; xoops_cp_footer(); exit(); } else { $edituser->setVar("name", $_POST['name']); $edituser->setVar("uname", $_POST['username']); $edituser->setVar("email", $_POST['email']); if (!empty($_POST['url'])) { $edituser->setVar("url", formatURL($_POST['url'])); } // $edituser->setVar("user_avatar", $_POST['user_avatar']); $edituser->setVar("user_icq", $_POST['user_icq']); $edituser->setVar("user_from", $_POST['user_from']); $edituser->setVar("user_sig", $_POST['user_sig']); $user_viewemail = !empty($_POST['user_viewemail']) ? 1 : 0; $edituser->setVar("user_viewemail", $user_viewemail); $edituser->setVar("user_aim", $_POST['user_aim']); $edituser->setVar("user_yim", $_POST['user_yim']); $edituser->setVar("user_msnm", $_POST['user_msnm']); $edituser->setVar("attachsig", (empty($_POST['attachsig']) ? 0 : 1)); $edituser->setVar("timezone_offset", $_POST['timezone_offset']); // $edituser->setVar("theme", $_POST['theme']); $edituser->setVar("uorder", $_POST['uorder']); $edituser->setVar("umode", $_POST['umode']); $edituser->setVar("notify_method", $_POST['notify_method']); $edituser->setVar("notify_mode", $_POST['notify_mode']); $edituser->setVar("bio", $_POST['bio']); $edituser->setVar("rank", $_POST['rank']); $edituser->setVar("user_occ", $_POST['user_occ']); $edituser->setVar("user_intrest", $_POST['user_intrest']); $edituser->setVar('user_mailok', $_POST['user_mailok']); if ($_POST['pass2'] != "") { if ( $_POST['pass'] != $_POST['pass2'] ) { xoops_cp_header(); echo ""._AM_STNPDNM.""; xoops_cp_footer(); exit(); } $edituser->setVar("pass", md5($_POST['pass'])); } if (!$member_handler->insertUser($edituser)) { xoops_cp_header(); echo $edituser->getHtmlErrors(); xoops_cp_footer(); exit(); } else { if (!empty($_POST['groups'])) { $oldgroups = $edituser->getGroups(); //If the edited user is the current user and the current user WAS in the webmaster's group and is NOT in the new groups array if ($edituser->getVar('uid') == $xoopsUser->getVar('uid') && (in_array(XOOPS_GROUP_ADMIN, $oldgroups)) && !in_array(XOOPS_GROUP_ADMIN, $groups)) { //Add the webmaster's group to the groups array to prevent accidentally removing oneself from the webmaster's group array_push($_POST['groups'], XOOPS_GROUP_ADMIN); } $member_handler =& xoops_gethandler('member'); foreach ($oldgroups as $groupid) { $member_handler->removeUsersFromGroup($groupid, array($edituser->getVar('uid'))); } foreach ($_POST['groups'] as $groupid) { $member_handler->addUserToGroup($groupid, $edituser->getVar('uid')); } } } } } redirect_header("admin.php?fct=users",1,_AM_DBUPDATED); break; case "delUser": xoops_cp_header(); $member_handler =& xoops_gethandler('member'); $userdata =& $member_handler->getUser($uid); xoops_token_confirm(array('fct' => 'users', 'op' => 'delUserConf', 'del_uid' => $userdata->getVar('uid')), 'admin.php', sprintf(_AM_AYSYWTDU,$userdata->getVar('uname'))); xoops_cp_footer(); break; case "delete_many": xoops_cp_header(); $count = count($_POST['memberslist_id']); $token=&XoopsSingleTokenHandler::quickCreate('users_deletemany'); if ( $count > 0 ) { $list = $hidden = ''; for ( $i = 0; $i < $count; $i++ ) { $id = intval($_POST['memberslist_id'][$i]); if ($id > 0) { $list .= ", ".htmlspecialchars($_POST['memberslist_uname'][$id]).""; $hidden .= "\n"; } } echo "