$custom['all'] = $DETDB->count('users'); $custom['body'] = get_users(array('cols' => 'ID, login, code, display_name, groups_ID', 'offset' => $PAGE->content['offset'], 'limit' => $PAGE->content['limit'])); return $custom; })); add_action(array('code' => 'ajax_delete_user', 'function' => 'ajax_delete_user', 'rule' => 'admin_ajax, admin_users', 'category' => 'admin', 'function' => function ($params = null) { if (isset($params['window']['pre_window']['value']) && $params['window']['pre_window']['type'] == 'ID' && delete_user($params['window']['pre_window']['value'])) { echo ajax_make_res('success', 'Пользователь успешно удалён', 'Успех!'); } else { echo ajax_make_res('error', 'Произошла неизвестная ошибка', 'Ошибка!'); } })); add_action(array('code' => 'ajax_add_user_group', 'rule' => 'admin_ajax, admin_users', 'category' => 'admin', 'function' => function ($params = null) { if (isset($params['window']['input'])) { $params = $params['window']['input']; } if ($params !== null && isset($params['code']) && add_user_group($params)) { echo ajax_make_res('reload', "Группа {$params['code']} успешно добавлена", 'Успех!'); } else { echo ajax_make_res('error', 'Проверьте правильность заполненных полей', 'Ошибка!'); } })); add_action(array('code' => 'ajax_get_user_group', 'rule' => 'admin_ajax, admin_users', 'category' => 'admin', 'function' => function ($params = null) { if (isset($params['button']['pre']['value']) && $params['button']['pre']['type'] == 'ID') { $params = $params['button']['pre']['value']; if ($res = get_user_group($params, 'code, name')) { echo ajax_make_res(array('data' => $res)); die; } } echo ajax_make_res('error', 'Произошла неизвестная ошибка', 'Ошибка!'); }));
$_REQUEST['group_rights'][$right['name']] = array('id' => $id, 'permission' => $right['permission']); } } else { if (isset($_REQUEST['save'])) { $group_users = get_request('group_users', array()); $group_rights = get_request('group_rights', array()); if (isset($_REQUEST['usrgrpid'])) { $action = AUDIT_ACTION_UPDATE; DBstart(); $result = update_user_group($_REQUEST['usrgrpid'], $_REQUEST['gname'], $_REQUEST['users_status'], $_REQUEST['gui_access'], $group_users, $group_rights); $result = DBend($result); show_messages($result, S_GROUP_UPDATED, S_CANNOT_UPDATE_GROUP); } else { $action = AUDIT_ACTION_ADD; DBstart(); $result = add_user_group($_REQUEST['gname'], $_REQUEST['users_status'], $_REQUEST['gui_access'], $group_users, $group_rights); $result = DBend($result); show_messages($result, S_GROUP_ADDED, S_CANNOT_ADD_GROUP); } if ($result) { add_audit($action, AUDIT_RESOURCE_USER_GROUP, 'Group name [' . $_REQUEST['gname'] . ']'); unset($_REQUEST['form']); } } else { if (isset($_REQUEST['delete_selected']) && isset($_REQUEST['group_groupid'])) { $result = false; $group_groupid = get_request('group_groupid', array()); DBstart(); foreach ($group_groupid as $usrgrpid) { if (!($group = get_group_by_usrgrpid($usrgrpid))) { continue;
/** * Регистрация пользователя в БД users * @return mixed */ protected function regUser() { $u_data = $this->u_data; $config = $this->config; $user = $this->user; $root_path = $this->root_path; $php_ext = $this->php_ext; global $phpbb_container; $u_data["verified_email"] = isset($u_data["verified_email"]) ? $u_data["verified_email"] : -1; if ($config['require_activation'] == USER_ACTIVATION_DISABLE || ($config['require_activation'] == USER_ACTIVATION_SELF && $u_data["verified_email"] == -1 || $config['require_activation'] == USER_ACTIVATION_ADMIN) && !$config['email_enable']) { $this->sendMessage(array('title' => $this->user->lang['ULOGIN_REG_ERROR'], 'msg' => $user->lang['UCP_REGISTER_DISABLE'], 'type' => 'error')); return false; } // DNSBL check if ($config['check_dnsbl']) { if (($dnsbl = $user->check_dnsbl('register')) !== false) { $this->sendMessage(array('title' => $this->user->lang['ULOGIN_REG_ERROR'], 'msg' => sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]), 'type' => 'error')); return false; } } $group_id = $this->model->getGroupId(); if (($config['require_activation'] == USER_ACTIVATION_SELF && $u_data["verified_email"] == -1 || $config['require_activation'] == USER_ACTIVATION_ADMIN) && $config['email_enable']) { $user_type = USER_INACTIVE; $user_actkey = gen_rand_string(mt_rand(6, 10)); $user_inactive_reason = INACTIVE_REGISTER; $user_inactive_time = time(); } else { $user_type = USER_NORMAL; $user_actkey = ''; $user_inactive_reason = 0; $user_inactive_time = 0; } // Instantiate passwords manager $passwords_manager = $phpbb_container->get('passwords.manager'); $login = $this->generateNickname(isset($u_data['first_name']) ? $u_data['first_name'] : '', isset($u_data['last_name']) ? $u_data['last_name'] : '', isset($u_data['nickname']) ? $u_data['nickname'] : '', isset($u_data['bdate']) ? $u_data['bdate'] : ''); $password = md5($u_data['identity'] . time() . rand()); $password = substr($password, 0, 12); $user_row = array('username' => $login, 'user_password' => $passwords_manager->hash($password), 'user_email' => $u_data['email'], 'user_birthday' => isset($u_data['bdate']) ? date('d-m-Y', strtotime($u_data['bdate'])) : '', 'group_id' => (int) $group_id, 'user_timezone' => $this->config['board_timezone'], 'user_lang' => basename($user->lang_name), 'user_ip' => $user->ip, 'user_regdate' => time(), 'user_type' => $user_type, 'user_actkey' => $user_actkey, 'user_inactive_reason' => $user_inactive_reason, 'user_inactive_time' => $user_inactive_time); if ($config['new_member_post_limit']) { $user_row['user_new'] = 1; } // Register user... include_once $root_path . 'includes/functions_user.' . $php_ext; $user_id = user_add($user_row); // This should not happen, because the required variables are listed above... if ($user_id === false) { $this->sendMessage(array('title' => $this->user->lang['ULOGIN_REG_ERROR'], 'msg' => $this->user->lang['ULOGIN_REG_ERROR_TEXT'], 'type' => 'error')); return false; } // Adds a user to the specified group include_once $root_path . 'includes/functions_convert.' . $php_ext; add_user_group($config['ulogin_group_id'], $user_id); if ($config['require_activation'] == USER_ACTIVATION_SELF && $u_data["verified_email"] == -1 && $config['email_enable']) { $message = $user->lang['ACCOUNT_INACTIVE']; $email_template = 'user_welcome_inactive'; } else { if ($config['require_activation'] == USER_ACTIVATION_ADMIN && $config['email_enable']) { $message = $user->lang['ACCOUNT_INACTIVE_ADMIN']; $email_template = 'admin_welcome_inactive'; } else { $message = $user->lang['ACCOUNT_ADDED']; $email_template = 'user_welcome'; } } if ($config['email_enable']) { include_once $root_path . 'includes/functions_messenger.' . $php_ext; $messenger = new \messenger(false); $template_lang = basename($user->lang_name); $template_path = dirname(dirname(__FILE__)) . '/language/'; $template_path .= $template_lang . '/email'; if (!file_exists($template_path . '/' . $email_template . '.txt')) { $template_lang = 'en'; $template_path = dirname(dirname(__FILE__)) . '/language/'; $template_path .= $template_lang . '/email'; } $messenger->template($email_template, $template_lang, $template_path); $messenger->to($u_data['email'], $login); $messenger->anti_abuse_headers($config, $user); $server_url = generate_board_url(); $messenger->assign_vars(array('WELCOME_MSG' => htmlspecialchars_decode(sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename'])), 'USERNAME' => htmlspecialchars_decode($login), 'PASSWORD' => htmlspecialchars_decode($password), 'U_ACTIVATE' => "{$server_url}/ucp.{$php_ext}?mode=activate&u={$user_id}&k={$user_actkey}")); $messenger->send(NOTIFY_EMAIL); } if ($config['require_activation'] == USER_ACTIVATION_ADMIN) { $phpbb_notifications = $phpbb_container->get('notification_manager'); $phpbb_notifications->add_notifications('notification.type.admin_activate_user', array('user_id' => $user_id, 'user_actkey' => $user_row['user_actkey'], 'user_regdate' => $user_row['user_regdate'])); } if ($user_type == USER_INACTIVE) { $this->sendMessage(array('title' => "", 'msg' => $message, 'type' => 'success')); return false; } return $user_id; }