当前位置: 首页>>代码示例>>PHP>>正文


PHP user_get_id_name函数代码示例

本文整理汇总了PHP中user_get_id_name函数的典型用法代码示例。如果您正苦于以下问题:PHP user_get_id_name函数的具体用法?PHP user_get_id_name怎么用?PHP user_get_id_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了user_get_id_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_new_author_info

    public function get_new_author_info($username)
    {
        // Who is the new uploader?
        if (!$username) {
            return false;
        }
        $user_id = 0;
        if ($username) {
            if (!function_exists('user_get_id_name')) {
                $this->url->_include('functions_user', 'phpbb');
            }
            user_get_id_name($user_id, $username);
        }
        if (empty($user_id)) {
            return false;
        }
        $sql = 'SELECT username, user_colour, user_id
			FROM ' . USERS_TABLE . '
			WHERE user_id = ' . (int) $user_id[0];
        $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        return $row;
    }
开发者ID:here-we-go,项目名称:phpbbgallery,代码行数:24,代码来源:image.php

示例2: handle_message_list_actions

/**
* For composing messages, handle list actions
*/
function handle_message_list_actions(&$address_list, $remove_u, $remove_g, $add_to, $add_bcc)
{
    global $auth, $db;
    // Delete User [TO/BCC]
    if ($remove_u) {
        $remove_user_id = array_keys($_REQUEST['remove_u']);
        unset($address_list['u'][(int) $remove_user_id[0]]);
    }
    // Delete Group [TO/BCC]
    if ($remove_g) {
        $remove_group_id = array_keys($_REQUEST['remove_g']);
        unset($address_list['g'][(int) $remove_group_id[0]]);
    }
    // Add User/Group [TO]
    if ($add_to || $add_bcc) {
        $type = $add_to ? 'to' : 'bcc';
        // Add Selected Groups
        $group_list = request_var('group_list', array(0));
        if (sizeof($group_list)) {
            foreach ($group_list as $group_id) {
                $address_list['g'][$group_id] = $type;
            }
        }
        // User ID's to add...
        $user_id_ary = array();
        // Build usernames to add
        $usernames = isset($_REQUEST['username']) ? array(request_var('username', '', true)) : array();
        $username_list = request_var('username_list', '', true);
        if ($username_list) {
            $usernames = array_merge($usernames, explode("\n", $username_list));
        }
        // Reveal the correct user_ids
        if (sizeof($usernames)) {
            $user_id_ary = array();
            user_get_id_name($user_id_ary, $usernames);
        }
        // Add Friends if specified
        $friend_list = is_array($_REQUEST['add_' . $type]) ? array_map('intval', array_keys($_REQUEST['add_' . $type])) : array();
        $user_id_ary = array_merge($user_id_ary, $friend_list);
        if (sizeof($user_id_ary)) {
            // We need to check their PM status (do they want to receive PM's?)
            // Only check if not a moderator or admin, since they are allowed to override this user setting
            if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) {
                $sql = 'SELECT user_id
					FROM ' . USERS_TABLE . '
					WHERE user_id IN (' . implode(', ', $user_id_ary) . ')
						AND user_allow_pm = 1';
                $result = $db->sql_query($sql);
                while ($row = $db->sql_fetchrow($result)) {
                    $address_list['u'][$row['user_id']] = $type;
                }
                $db->sql_freeresult($result);
            } else {
                foreach ($user_id_ary as $user_id) {
                    $address_list['u'][$user_id] = $type;
                }
            }
        }
    }
}
开发者ID:yunsite,项目名称:gloryroad,代码行数:63,代码来源:ucp_pm_compose.php

示例3: cleanup

    function cleanup()
    {
        global $auth, $cache, $db, $template, $user, $phpbb_ext_gallery, $table_prefix, $phpbb_container, $request;
        $delete = isset($_POST['delete']) ? true : false;
        $prune = isset($_POST['prune']) ? true : false;
        $submit = isset($_POST['submit']) ? true : false;
        $missing_sources = $request->variable('source', array(0));
        $missing_entries = $request->variable('entry', array(''), true);
        $missing_authors = $request->variable('author', array(0), true);
        $missing_comments = $request->variable('comment', array(0), true);
        $missing_personals = $request->variable('personal', array(0), true);
        $personals_bad = $request->variable('personal_bad', array(0), true);
        $prune_pattern = $request->variable('prune_pattern', array('' => ''), true);
        $move_to_import = $request->variable('move_to_import', 0);
        $new_author = $request->variable('new_author', '');
        $gallery_album = $phpbb_container->get('phpbbgallery.core.album');
        $core_cleanup = $phpbb_container->get('phpbbgallery.acpcleanup.cleanup');
        $gallery_auth = $phpbb_container->get('phpbbgallery.core.auth');
        $gallery_config = $phpbb_container->get('phpbbgallery.core.config');
        // Lets detect if ACP Import exists (find if directory is with RW access)
        $acp_import_installed = false;
        $acp_import_dir = $phpbb_ext_gallery->url->path('import');
        if (file_exists($acp_import_dir) && is_writable($acp_import_dir)) {
            $acp_import_installed = true;
        }
        if ($prune && empty($prune_pattern)) {
            $prune_pattern['image_album_id'] = implode(',', $request->variable('prune_album_ids', array(0)));
            if (isset($_POST['prune_username_check'])) {
                $usernames = $request->variable('prune_usernames', '', true);
                $usernames = explode("\n", $usernames);
                $prune_pattern['image_user_id'] = array();
                if (!empty($usernames)) {
                    if (!function_exists('user_get_id_name')) {
                        $phpbb_ext_gallery->url->_include('functions_user', 'phpbb');
                    }
                    user_get_id_name($user_ids, $usernames);
                    $prune_pattern['image_user_id'] = $user_ids;
                }
                if (isset($_POST['prune_anonymous'])) {
                    $prune_pattern['image_user_id'][] = ANONYMOUS;
                }
                $prune_pattern['image_user_id'] = implode(',', $prune_pattern['image_user_id']);
            }
            if (isset($_POST['prune_time_check'])) {
                $prune_time = explode('-', $request->variable('prune_time', ''));
                if (sizeof($prune_time) == 3) {
                    $prune_pattern['image_time'] = @gmmktime(0, 0, 0, (int) $prune_time[1], (int) $prune_time[2], (int) $prune_time[0]);
                }
            }
            if (isset($_POST['prune_comments_check'])) {
                $prune_pattern['image_comments'] = $request->variable('prune_comments', 0);
            }
            if (isset($_POST['prune_ratings_check'])) {
                $prune_pattern['image_rates'] = $request->variable('prune_ratings', 0);
            }
            if (isset($_POST['prune_rating_avg_check'])) {
                $prune_pattern['image_rate_avg'] = (int) ($request->variable('prune_rating_avg', 0.0) * 100);
            }
        }
        $s_hidden_fields = build_hidden_fields(array('source' => $missing_sources, 'entry' => $missing_entries, 'author' => $missing_authors, 'comment' => $missing_comments, 'personal' => $missing_personals, 'personal_bad' => $personals_bad, 'prune_pattern' => $prune_pattern, 'move_to_import' => $move_to_import));
        if ($submit) {
            $user_id = 1;
            if ($new_author) {
                $user_id = 0;
                if (!function_exists('user_get_id_name')) {
                    $phpbb_ext_gallery->url->_include('functions_user', 'phpbb');
                }
                user_get_id_name($user_id, $new_author);
                if (is_array($user_id) && !empty($user_id)) {
                    $user_id = $user_id[0];
                }
                if (!$user_id) {
                    trigger_error($user->lang('CLEAN_USER_NOT_FOUND', $new_author) . adm_back_link($this->u_action), E_USER_WARNING);
                }
            }
            if ($missing_authors) {
                $sql = 'UPDATE ' . $table_prefix . 'gallery_images
					SET image_user_id = ' . $user_id . ",\n\t\t\t\t\t\timage_user_colour = ''\n\t\t\t\t\tWHERE " . $db->sql_in_set('image_id', $missing_authors);
                $db->sql_query($sql);
            }
            if ($missing_comments) {
                $sql = 'UPDATE ' . $table_prefix . 'gallery_comments
					SET comment_user_id = ' . $user_id . ",\n\t\t\t\t\t\tcomment_user_colour = ''\n\t\t\t\t\tWHERE " . $db->sql_in_set('comment_id', $missing_comments);
                $db->sql_query($sql);
            }
            trigger_error($user->lang['CLEAN_CHANGED'] . adm_back_link($this->u_action));
        }
        if (confirm_box(true)) {
            $message = array();
            if ($missing_entries) {
                if ($acp_import_installed && $move_to_import) {
                    foreach ($missing_entries as $entrie) {
                        copy($phpbb_ext_gallery->url->path('upload') . '/' . $entrie, $phpbb_ext_gallery->url->path('import') . '/' . $entrie);
                    }
                }
                $message[] = $core_cleanup->delete_files($missing_entries);
            }
            if ($missing_sources) {
                $message[] = $core_cleanup->delete_images($missing_sources);
            }
//.........这里部分代码省略.........
开发者ID:here-we-go,项目名称:phpbbgallery,代码行数:101,代码来源:main_module.php

示例4: main

    function main($id, $mode)
    {
        global $db, $user, $auth, $template, $phpbb_container, $request;
        global $config, $phpbb_root_path, $phpEx;
        if (!function_exists('user_get_id_name')) {
            include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
        }
        if (!class_exists('auth_admin')) {
            include $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
        }
        $this->permissions = $phpbb_container->get('acl.permissions');
        $auth_admin = new auth_admin();
        $user->add_lang('acp/permissions');
        add_permission_language();
        $this->tpl_name = 'acp_permissions';
        // Trace has other vars
        if ($mode == 'trace') {
            $user_id = $request->variable('u', 0);
            $forum_id = $request->variable('f', 0);
            $permission = $request->variable('auth', '');
            $this->tpl_name = 'permission_trace';
            if ($user_id && isset($auth_admin->acl_options['id'][$permission]) && $auth->acl_get('a_viewauth')) {
                $this->page_title = sprintf($user->lang['TRACE_PERMISSION'], $this->permissions->get_permission_lang($permission));
                $this->permission_trace($user_id, $forum_id, $permission);
                return;
            }
            trigger_error('NO_MODE', E_USER_ERROR);
        }
        // Copy forum permissions
        if ($mode == 'setting_forum_copy') {
            $this->tpl_name = 'permission_forum_copy';
            if ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')) {
                $this->page_title = 'ACP_FORUM_PERMISSIONS_COPY';
                $this->copy_forum_permissions();
                return;
            }
            trigger_error('NO_MODE', E_USER_ERROR);
        }
        // Set some vars
        $action = $request->variable('action', array('' => 0));
        $action = key($action);
        $action = isset($_POST['psubmit']) ? 'apply_permissions' : $action;
        $all_forums = $request->variable('all_forums', 0);
        $subforum_id = $request->variable('subforum_id', 0);
        $forum_id = $request->variable('forum_id', array(0));
        $username = $request->variable('username', array(''), true);
        $usernames = $request->variable('usernames', '', true);
        $user_id = $request->variable('user_id', array(0));
        $group_id = $request->variable('group_id', array(0));
        $select_all_groups = $request->variable('select_all_groups', 0);
        $form_name = 'acp_permissions';
        add_form_key($form_name);
        // If select all groups is set, we pre-build the group id array (this option is used for other screens to link to the permission settings screen)
        if ($select_all_groups) {
            // Add default groups to selection
            $sql_and = !$config['coppa_enable'] ? " AND group_name <> 'REGISTERED_COPPA'" : '';
            $sql = 'SELECT group_id
				FROM ' . GROUPS_TABLE . '
				WHERE group_type = ' . GROUP_SPECIAL . "\n\t\t\t\t{$sql_and}";
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $group_id[] = $row['group_id'];
            }
            $db->sql_freeresult($result);
        }
        // Map usernames to ids and vice versa
        if ($usernames) {
            $username = explode("\n", $usernames);
        }
        unset($usernames);
        if (sizeof($username) && !sizeof($user_id)) {
            user_get_id_name($user_id, $username);
            if (!sizeof($user_id)) {
                trigger_error($user->lang['SELECTED_USER_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING);
            }
        }
        unset($username);
        // Build forum ids (of all forums are checked or subforum listing used)
        if ($all_forums) {
            $sql = 'SELECT forum_id
				FROM ' . FORUMS_TABLE . '
				ORDER BY left_id';
            $result = $db->sql_query($sql);
            $forum_id = array();
            while ($row = $db->sql_fetchrow($result)) {
                $forum_id[] = (int) $row['forum_id'];
            }
            $db->sql_freeresult($result);
        } else {
            if ($subforum_id) {
                $forum_id = array();
                foreach (get_forum_branch($subforum_id, 'children') as $row) {
                    $forum_id[] = (int) $row['forum_id'];
                }
            }
        }
        // Define some common variables for every mode
        $permission_scope = strpos($mode, '_global') !== false ? 'global' : 'local';
        // Showing introductionary page?
        if ($mode == 'intro') {
//.........这里部分代码省略.........
开发者ID:phpbb,项目名称:phpbb,代码行数:101,代码来源:acp_permissions.php

示例5: get_prune_users

    /**
     * Get user_ids/usernames from those being pruned
     */
    function get_prune_users(&$user_ids, &$usernames)
    {
        global $user, $db, $request;
        $users_by_name = $request->variable('users', '', true);
        $users_by_id = $request->variable('user_ids', array(0));
        $group_id = $request->variable('group_id', 0);
        $posts_on_queue = trim($request->variable('posts_on_queue', '')) === '' ? false : $request->variable('posts_on_queue', 0);
        if ($users_by_name) {
            $users = explode("\n", $users_by_name);
            $where_sql = ' AND ' . $db->sql_in_set('username_clean', array_map('utf8_clean_string', $users));
        } else {
            if (!empty($users_by_id)) {
                $user_ids = $users_by_id;
                user_get_id_name($user_ids, $usernames);
                $where_sql = ' AND ' . $db->sql_in_set('user_id', $user_ids);
            } else {
                $username = $request->variable('username', '', true);
                $email = $request->variable('email', '');
                $active_select = $request->variable('active_select', 'lt');
                $count_select = $request->variable('count_select', 'eq');
                $queue_select = $request->variable('queue_select', 'gt');
                $joined_before = $request->variable('joined_before', '');
                $joined_after = $request->variable('joined_after', '');
                $active = $request->variable('active', '');
                $count = $request->variable('count', '') === '' ? false : $request->variable('count', 0);
                $active = $active ? explode('-', $active) : array();
                $joined_before = $joined_before ? explode('-', $joined_before) : array();
                $joined_after = $joined_after ? explode('-', $joined_after) : array();
                // calculate the conditions required by the join time criteria
                $joined_sql = '';
                if (!empty($joined_before) && !empty($joined_after)) {
                    // if the two entered dates are equal, we need to adjust
                    // so that our time range is a full day instead of 1 second
                    if ($joined_after == $joined_before) {
                        $joined_after[2] += 1;
                    }
                    $joined_sql = ' AND user_regdate BETWEEN ' . gmmktime(0, 0, 0, (int) $joined_after[1], (int) $joined_after[2], (int) $joined_after[0]) . ' AND ' . gmmktime(0, 0, 0, (int) $joined_before[1], (int) $joined_before[2], (int) $joined_before[0]);
                } else {
                    if (empty($joined_before) && !empty($joined_after)) {
                        $joined_sql = ' AND user_regdate > ' . gmmktime(0, 0, 0, (int) $joined_after[1], (int) $joined_after[2], (int) $joined_after[0]);
                    } else {
                        if (empty($joined_after) && !empty($joined_before)) {
                            $joined_sql = ' AND user_regdate < ' . gmmktime(0, 0, 0, (int) $joined_before[1], (int) $joined_before[2], (int) $joined_before[0]);
                        }
                    }
                }
                // implicit else when both arrays are empty do nothing
                if (sizeof($active) && sizeof($active) != 3 || sizeof($joined_before) && sizeof($joined_before) != 3 || sizeof($joined_after) && sizeof($joined_after) != 3) {
                    trigger_error($user->lang['WRONG_ACTIVE_JOINED_DATE'] . adm_back_link($this->u_action), E_USER_WARNING);
                }
                $key_match = array('lt' => '<', 'gt' => '>', 'eq' => '=');
                $sort_by_types = array('username', 'user_email', 'user_posts', 'user_regdate', 'user_lastvisit');
                $where_sql = '';
                $where_sql .= $username ? ' AND username_clean ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($username))) : '';
                $where_sql .= $email ? ' AND user_email ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $email)) . ' ' : '';
                $where_sql .= $joined_sql;
                $where_sql .= $count !== false ? " AND user_posts " . $key_match[$count_select] . ' ' . (int) $count . ' ' : '';
                // First handle pruning of users who never logged in, last active date is 0000-00-00
                if (sizeof($active) && (int) $active[0] == 0 && (int) $active[1] == 0 && (int) $active[2] == 0) {
                    $where_sql .= ' AND user_lastvisit = 0';
                } else {
                    if (sizeof($active) && $active_select != 'lt') {
                        $where_sql .= ' AND user_lastvisit ' . $key_match[$active_select] . ' ' . gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]);
                    } else {
                        if (sizeof($active)) {
                            $where_sql .= ' AND (user_lastvisit > 0 AND user_lastvisit < ' . gmmktime(0, 0, 0, (int) $active[1], (int) $active[2], (int) $active[0]) . ')';
                        }
                    }
                }
            }
        }
        // If no search criteria were provided, go no further.
        if (!$where_sql && !$group_id && $posts_on_queue === false) {
            return;
        }
        // Get bot ids
        $sql = 'SELECT user_id
			FROM ' . BOTS_TABLE;
        $result = $db->sql_query($sql);
        $bot_ids = array();
        while ($row = $db->sql_fetchrow($result)) {
            $bot_ids[] = $row['user_id'];
        }
        $db->sql_freeresult($result);
        // Protect the admin, do not prune if no options are given...
        if ($where_sql) {
            // Do not prune founder members
            $sql = 'SELECT user_id, username
				FROM ' . USERS_TABLE . '
				WHERE user_id <> ' . ANONYMOUS . '
					AND user_type <> ' . USER_FOUNDER . "\n\t\t\t\t{$where_sql}";
            $result = $db->sql_query($sql);
            $user_ids = $usernames = array();
            while ($row = $db->sql_fetchrow($result)) {
                // Do not prune bots and the user currently pruning.
                if ($row['user_id'] != $user->data['user_id'] && !in_array($row['user_id'], $bot_ids)) {
                    $user_ids[] = $row['user_id'];
//.........这里部分代码省略.........
开发者ID:hgchen,项目名称:phpbb,代码行数:101,代码来源:acp_prune.php

示例6: overview


//.........这里部分代码省略.........
                    $confirm = true;
                    $confirm_lang = 'RESYNC_IMAGECOUNTS_CONFIRM';
                    break;
                case 'personals':
                    $confirm = true;
                    $confirm_lang = 'CONFIRM_OPERATION';
                    break;
                case 'stats':
                    $confirm = true;
                    $confirm_lang = 'CONFIRM_OPERATION';
                    break;
                case 'last_images':
                    $confirm = true;
                    $confirm_lang = 'CONFIRM_OPERATION';
                    break;
                case 'reset_rating':
                    $album_id = $request->variable('reset_album_id', 0);
                    $album_data = $phpbb_ext_gallery_core_album->get_info($album_id);
                    $confirm = true;
                    $confirm_lang = sprintf($user->lang['RESET_RATING_CONFIRM'], $album_data['album_name']);
                    break;
                case 'purge_cache':
                    $confirm = true;
                    $confirm_lang = 'GALLERY_PURGE_CACHE_EXPLAIN';
                    break;
                case 'create_pega':
                    $confirm = false;
                    if (!$auth->acl_get('a_board')) {
                        trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
                    }
                    $username = $request->variable('username', '', true);
                    $user_id = 0;
                    if ($username) {
                        if (!function_exists('user_get_id_name')) {
                            $phpbb_ext_gallery->url->_include('functions_user', 'phpbb');
                        }
                        user_get_id_name($user_id, $username);
                    }
                    if (is_array($user_id)) {
                        $user_id = isset($user_id[0]) ? $user_id[0] : 0;
                    }
                    $sql = 'SELECT username, user_colour, user_id
						FROM ' . USERS_TABLE . '
						WHERE user_id = ' . $user_id;
                    $result = $db->sql_query($sql);
                    $user_row = $db->sql_fetchrow($result);
                    $db->sql_freeresult($result);
                    if (!$user_row) {
                        trigger_error($user->lang['NO_USER'] . adm_back_link($this->u_action), E_USER_WARNING);
                    }
                    $image_user = $phpbb_gallery_user->set_user_id($user_row['user_id']);
                    $album_id = $phpbb_gallery_user->get_data('personal_album_id');
                    if ($album_id) {
                        trigger_error($user->lang('PEGA_ALREADY_EXISTS', $user_row['username']) . adm_back_link($this->u_action), E_USER_WARNING);
                    }
                    $phpbb_ext_gallery_core_album->generate_personal_album($user_row['username'], $user_row['user_id'], $user_row['user_colour'], $phpbb_gallery_user);
                    trigger_error($user->lang('PEGA_CREATED', $user_row['username']) . adm_back_link($this->u_action));
                    break;
            }
            if ($confirm) {
                confirm_box(false, $album_id ? $confirm_lang : $user->lang[$confirm_lang], build_hidden_fields(array('i' => $id, 'mode' => $mode, 'action' => $action, 'reset_album_id' => $album_id)));
            }
        } else {
            switch ($action) {
                case 'images':
                    if (!$auth->acl_get('a_board')) {
开发者ID:here-we-go,项目名称:phpbbgallery,代码行数:67,代码来源:main_module.php

示例7: display_options

    function display_options()
    {
        global $template, $user, $db;
        $submit = request_var('sa', false);
        $source_name = request_var('source_name', '', true);
        $target_name = request_var('target_name', '', true);
        $source_id = request_var('source_id', '');
        $target_id = request_var('target_id', '');
        if ($submit) {
            // Check that at least one field is filled in.
            if (!$source_name && empty($source_id) || !$target_name && empty($target_id)) {
                trigger_error('NO_USER', E_USER_WARNING);
            }
            // Not allowed to have both username and user_id filled.
            if ($source_name && $source_id || $target_name && $target_id) {
                trigger_error('BOTH_FIELDS_FILLED', E_USER_WARNING);
            }
            if ($source_name && empty($source_id)) {
                // Get the correct user data and make sure that he exists
                if (!function_exists('user_get_id_name')) {
                    include PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT;
                }
                $result = user_get_id_name($source_id, $source_name);
                // Was a user_id found?
                if (!sizeof($source_id) || $result !== false) {
                    trigger_error('NO_USER', E_USER_WARNING);
                }
                // Drop the arrays
                $source_id = array_shift($source_id);
                $source_name = array_shift($source_name);
                $result = user_get_id_name($target_id, $target_name);
                // Was a user_id found?
                if (!sizeof($target_id) || $result !== false) {
                    trigger_error('NO_USER', E_USER_WARNING);
                }
                // Drop the arrays
                $target_id = array_shift($target_id);
                $target_name = array_shift($target_name);
            }
            if ($target_id == $source_id || $source_name == $target_name) {
                trigger_error('USERS_IDENTICAL', E_USER_WARNING);
            }
            $permissions = array();
            $sql = 'SELECT forum_id, auth_option_id, auth_role_id, auth_setting
				FROM ' . ACL_USERS_TABLE . '
				WHERE user_id = ' . $source_id;
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $row['user_id'] = $target_id;
                $permissions[] = $row;
            }
            $db->sql_freeresult($result);
            $sql = 'SELECT user_permissions
				FROM ' . USERS_TABLE . '
				WHERE user_id = ' . $source_id . '
				AND user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')';
            $result = $db->sql_query($sql);
            $user_permissions = $db->sql_fetchfield('user_permissions');
            $db->sql_freeresult($result);
            $sql = 'UPDATE ' . USERS_TABLE . '
				SET user_permissions = \'' . $user_permissions . '\'
				WHERE user_id = ' . $target_id;
            $db->sql_query($sql);
            if (sizeof($permissions)) {
                $sql = 'DELETE FROM ' . ACL_USERS_TABLE . '
					WHERE user_id = ' . $target_id . '';
                $db->sql_query($sql);
                foreach ($permissions as $key => $data_sql) {
                    $sql = 'INSERT INTO ' . ACL_USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $data_sql);
                    $db->sql_query($sql);
                }
            }
            trigger_error('COPY_USER_PERMISSIONS_OK');
        }
        $template->assign_vars(array('SOURCE_NAME' => $source_name, 'SOURCE_ID' => $source_id, 'TARGET_NAME' => $target_name, 'TARGED_ID' => $target_id, 'U_FIND_USER' => append_sid(PHPBB_ROOT_PATH . 'memberlist.' . PHP_EXT, array('mode' => 'searchuser', 'form' => 'stk', 'field' => 'source_name')), 'U_FIND_TO_USER' => append_sid(PHPBB_ROOT_PATH . 'memberlist.' . PHP_EXT, array('mode' => 'searchuser', 'form' => 'stk', 'field' => 'target_name'))));
        $template->set_filenames(array('body' => 'tools/user_copy_perm.html'));
        page_header($user->lang['USER_COPY_PERM'], false);
        page_footer();
    }
开发者ID:melvingb,项目名称:phpbb3.1-STK,代码行数:79,代码来源:user_copy_perm.php

示例8: import


//.........这里部分代码省略.........
                $todo_images = $todo_images - $images_loop;
            }
            \phpbbgallery\core\album\album::update_info($album_id);
            if (!$todo_images) {
                unlink($gallery_url->_return_file($import_schema, 'import', ''));
                $errors = @file_get_contents($gallery_url->_return_file($import_schema . '_errors', 'import', ''));
                @unlink($gallery_url->_return_file($import_schema . '_errors', 'import', ''));
                if (!$errors) {
                    trigger_error(sprintf($user->lang['IMPORT_FINISHED'], $done_images) . adm_back_link($this->u_action));
                } else {
                    $errors = explode("\n", $errors);
                    trigger_error(sprintf($user->lang['IMPORT_FINISHED_ERRORS'], $done_images - sizeof($errors)) . implode('<br />', $errors) . adm_back_link($this->u_action), E_USER_WARNING);
                }
            } else {
                // Write the new list
                $this->create_import_schema($import_schema, $album_id, $user_data, $start_time, $num_offset, $done_images, $todo_images, $image_name, $filename, $images);
                // Redirect
                $forward_url = $this->u_action . "&amp;import_schema={$import_schema}";
                meta_refresh(1, $forward_url);
                trigger_error(sprintf($user->lang['IMPORT_DEBUG_MES'], $done_images, $todo_images));
            }
        } else {
            if ($submit) {
                if (!check_form_key('acp_gallery')) {
                    trigger_error('FORM_INVALID', E_USER_WARNING);
                }
                if (!$images) {
                    trigger_error('NO_FILE_SELECTED', E_USER_WARNING);
                }
                // Who is the uploader?
                $username = $request->variable('username', '', true);
                $user_id = 0;
                if ($username) {
                    if (!function_exists('user_get_id_name')) {
                        $gallery_url->_include('functions_user', 'phpbb');
                    }
                    user_get_id_name($user_id, $username);
                }
                if (is_array($user_id)) {
                    $user_id = $user_id[0];
                }
                if (!$user_id) {
                    $user_id = $user->data['user_id'];
                }
                $sql = 'SELECT username, user_colour, user_id
				FROM ' . USERS_TABLE . '
				WHERE user_id = ' . $user_id;
                $result = $db->sql_query($sql);
                $user_row = $db->sql_fetchrow($result);
                $db->sql_freeresult($result);
                if (!$user_row) {
                    trigger_error('HACKING_ATTEMPT', E_USER_WARNING);
                }
                $album_id = $request->variable('album_id', 0);
                if (isset($_POST['users_pega'])) {
                    $image_user = $phpbb_container->get('phpbbgallery.core.user');
                    $image_user->set_user_id($user_row['user_id']);
                    if ($user->data['user_id'] != $user_row['user_id']) {
                        $album_id = $image_user->get_data('personal_album_id');
                        if (!$album_id) {
                            // The User has no personal album
                            $album_id = $gallery_album->generate_personal_album($user_row['username'], $user_row['user_id'], $user_row['user_colour'], $image_user);
                        }
                        unset($image_user);
                    } else {
                        $album_id = $image_user->get_data('personal_album_id');
开发者ID:here-we-go,项目名称:phpbbgallery,代码行数:67,代码来源:main_module.php

示例9: group_user_attributes

/**
* This is used to promote (to leader), demote or set as default a member/s
*/
function group_user_attributes($action, $group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $group_attributes = false)
{
    global $db, $auth, $phpbb_root_path, $phpEx, $config;
    // We need both username and user_id info
    user_get_id_name($user_id_ary, $username_ary);
    if (!sizeof($user_id_ary)) {
        return false;
    }
    if (!$group_name) {
        $group_name = get_group_name($group_id);
    }
    switch ($action) {
        case 'demote':
        case 'promote':
            $sql = 'UPDATE ' . USER_GROUP_TABLE . '
				SET group_leader = ' . ($action == 'promote' ? 1 : 0) . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_id IN (" . implode(', ', $user_id_ary) . ')';
            $db->sql_query($sql);
            $log = $action == 'promote' ? 'LOG_GROUP_PROMOTED' : 'LOG_GROUP_DEMOTED';
            break;
        case 'approve':
            // Make sure we only approve those which are pending ;)
            $sql = 'SELECT u.user_id, u.user_email, u.username, u.user_notify_type, u.user_jabber, u.user_lang
				FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug
				WHERE ug.group_id = ' . $group_id . '
					AND ug.user_pending = 1
					AND ug.user_id = u.user_id
					AND ug.user_id IN (' . implode(', ', $user_id_ary) . ')';
            $result = $db->sql_query($sql);
            $user_id_ary = $email_users = array();
            while ($row = $db->sql_fetchrow($result)) {
                $user_id_ary[] = $row['user_id'];
                $email_users[] = $row;
            }
            $db->sql_freeresult($result);
            if (!sizeof($user_id_ary)) {
                return false;
            }
            $sql = 'UPDATE ' . USER_GROUP_TABLE . "\n\t\t\t\tSET user_pending = 0\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_id IN (" . implode(', ', $user_id_ary) . ')';
            $db->sql_query($sql);
            // Send approved email to users...
            include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
            $messenger = new messenger();
            $email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
            foreach ($email_users as $row) {
                $messenger->template('group_approved', $row['user_lang']);
                $messenger->replyto($config['board_email']);
                $messenger->to($row['user_email'], $row['username']);
                $messenger->im($row['user_jabber'], $row['username']);
                $messenger->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'USERNAME' => html_entity_decode($row['username']), 'GROUP_NAME' => html_entity_decode($group_name), 'U_GROUP' => generate_board_url() . "/ucp.{$phpEx}?i=groups&mode=membership"));
                $messenger->send($row['user_notify_type']);
                $messenger->reset();
            }
            $messenger->save_queue();
            $log = 'LOG_USERS_APPROVED';
            break;
        case 'default':
            group_set_user_default($group_id, $user_id_ary, $group_attributes);
            $log = 'LOG_GROUP_DEFAULTS';
            break;
    }
    // Clear permissions cache of relevant users
    $auth->acl_clear_prefetch($user_id_ary);
    add_log('admin', $log, $group_name, implode(', ', $username_ary));
    return true;
}
开发者ID:yunsite,项目名称:gloryroad,代码行数:68,代码来源:functions_user.php

示例10: run_tool

    /**
     * Run Tool
     *
     * Does the actual stuff we want the tool to do after submission
     */
    function run_tool(&$error)
    {
        global $db, $user;
        if (!check_form_key('manage_founders')) {
            trigger_error('FORM_INVALID');
        }
        // Lets do something
        $mode = request_var('mode', '');
        switch ($mode) {
            case 'demote':
                $req_founders = request_var('founders', array(0 => ''));
                if (!sizeof($req_founders)) {
                    trigger_error('NO_USER');
                }
                // Make sure we only have users that do exist
                $req_founders = array_keys($req_founders);
                $founder_ids = array();
                $sql = 'SELECT user_id
					FROM ' . USERS_TABLE . '
					WHERE ' . $db->sql_in_set('user_id', $req_founders) . '
						AND user_type = ' . USER_FOUNDER;
                $result = $db->sql_query($sql);
                while ($row = $db->sql_fetchrow($result)) {
                    $founder_ids[] = $row['user_id'];
                }
                $db->sql_freeresult($result);
                // Remove founder status from these users
                $sql = 'UPDATE ' . USERS_TABLE . '
					SET ' . $db->sql_build_array('UPDATE', array('user_type' => USER_NORMAL)) . '
					WHERE ' . $db->sql_in_set('user_id', $founder_ids);
                $db->sql_query($sql);
                // Did everything to right?
                if (sizeof($founder_ids) == $db->sql_affectedrows()) {
                    trigger_error(sprintf($user->lang['DEMOTE_SUCCESSFULL'], $db->sql_affectedrows()));
                }
                trigger_error($user->lang['DEMOTE_FAILED']);
                break;
            case 'promote':
                $req_username = utf8_normalize_nfc(request_var('username', '', true));
                $req_user_id = utf8_normalize_nfc(request_var('user_id', 0));
                // Check that at least one field is filled in.
                if (!$req_username && empty($req_user_id)) {
                    trigger_error('NO_USER');
                }
                // Not allowed to have both username and user_id filled.
                if ($req_username && $req_user_id) {
                    $error[] = 'BOTH_FIELDS_FILLED';
                    return;
                }
                // Get the correct user data and make sure that he exists
                if (!function_exists('user_get_id_name')) {
                    include PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT;
                }
                $user_id = $username = $user_type = array();
                if (!empty($req_user_id)) {
                    $user_id[] = $req_user_id;
                }
                if (!empty($req_username)) {
                    $username[] = $req_username;
                }
                $user_type[] = USER_NORMAL;
                // Get user_id
                $result = user_get_id_name($user_id, $username, $user_type);
                // Was a user_id found?
                if (!sizeof($user_id) || $result !== false) {
                    trigger_error('NO_USER');
                }
                // Drop the arrays
                $user_id = array_shift($user_id);
                $username = array_shift($username);
                // No user found
                if (!$user_id) {
                    $error[] = 'NO_USER';
                    return;
                }
                // Now promote the guy
                $sql = 'UPDATE ' . USERS_TABLE . '
					SET ' . $db->sql_build_array('UPDATE', array('user_type' => USER_FOUNDER)) . '
					WHERE user_id = ' . (int) $user_id;
                $db->sql_query($sql);
                // Success?
                if ($db->sql_affectedrows() == 1) {
                    trigger_error(sprintf($user->lang['MAKE_FOUNDER_SUCCESS'], append_sid(PHPBB_ROOT_PATH . 'memberlist.' . PHP_EXT, array('mode' => 'viewprofile', 'u' => $user_id[0])), $username));
                }
                trigger_error($user->lang['MAKE_FOUNDER_FAILED']);
                break;
            default:
                trigger_error('NO_MODE');
        }
    }
开发者ID:melvingb,项目名称:phpbb3.1-STK,代码行数:95,代码来源:manage_founders.php

示例11: main

    function main($id, $mode)
    {
        global $db, $cache, $config, $user, $lang, $auth, $template, $cms_admin;
        add_permission_language();
        include_once IP_ROOT_PATH . 'includes/class_auth_admin.' . PHP_EXT;
        $auth_admin = new auth_admin();
        // Set some vars
        $action = request_var('paction', array('' => 0));
        $action = key($action);
        $action = isset($_POST['psubmit']) ? 'apply_permissions' : $action;
        $all_forums = request_var('all_forums', 0);
        $subforum_id = request_var('subforum_id', 0);
        $forum_id = request_var('forum_id', array(0));
        $id_type = request_var('id_type', '');
        $id_types_array = array('forum', 'block', 'layout', 'layout_special');
        $id_type = in_array($id_type, $id_types_array) ? $id_type : $id_types_array[0];
        $this->id_type = $id_type;
        $username = request_var('username', array(''), true);
        $usernames = request_var('usernames', '', true);
        $user_id = request_var('user_id', array(0));
        $group_id = request_var('group_id', array(0));
        $select_all_groups = request_var('select_all_groups', 0);
        $form_name = 'acp_permissions';
        add_form_key($form_name);
        $this->tpl_name = 'cms_permissions.tpl';
        $this->u_action = append_sid($cms_admin->root . '?mode=auth&amp;pmode=' . $mode);
        /*
        // Trace has other vars
        if ($mode == 'trace')
        {
        	$user_id = request_var('u', 0);
        	$forum_id = request_var('f', 0);
        	$permission = request_var('auth', '');
        
        	$this->tpl_name = 'cms_permission_trace.tpl';
        
        	if ($user_id && isset($auth_admin->acl_options['id'][$permission]))
        	{
        		$this->page_title = sprintf($user->lang['TRACE_PERMISSION'], $user->lang['acl_' . $permission]['lang']);
        		$this->permission_trace($user_id, $forum_id, $permission);
        		return;
        	}
        	trigger_error('NO_MODE', E_USER_ERROR);
        }
        */
        // If select all groups is set, we pre-build the group id array (this option is used for other screens to link to the permission settings screen)
        if ($select_all_groups) {
            $sql = 'SELECT group_id
				FROM ' . GROUPS_TABLE . '
				WHERE group_single_user = 0';
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $group_id[] = $row['group_id'];
            }
            $db->sql_freeresult($result);
        }
        // Map usernames to ids and vice versa
        if ($usernames) {
            $username = explode("\n", $usernames);
        }
        unset($usernames);
        if (sizeof($username) && !sizeof($user_id)) {
            user_get_id_name($user_id, $username);
            if (!sizeof($user_id)) {
                trigger_error($user->lang['SELECTED_USER_NOT_EXIST'] . page_back_link($this->u_action), E_USER_WARNING);
            }
        }
        unset($username);
        // Define some common variables for every mode
        $error = array();
        $permission_scope = strpos($mode, '_global') !== false ? 'global' : 'local';
        // Showing introductionary page?
        if ($mode == 'intro') {
            $this->page_title = 'CMS_PERMISSIONS';
            $template->assign_vars(array('S_INTRO' => true));
            return;
        }
        switch ($mode) {
            case 'setting_admin_global':
            case 'setting_mod_global':
                $this->permission_dropdown = strpos($mode, '_admin_') !== false ? array('a_') : array('m_');
                $permission_victim = array('usergroup');
                $this->page_title = $mode == 'setting_admin_global' ? 'CMS_PERMISSIONS_ADMINS' : 'CMS_PERMISSIONS_MODS';
                break;
            case 'setting_cms_user_global':
            case 'setting_cms_group_global':
                $this->permission_dropdown = array('cms_', 'pl_', 'u_');
                $permission_victim = array('usergroup');
                //$permission_victim = ($mode == 'setting_cms_user_global') ? array('user') : array('group');
                $this->page_title = $mode == 'setting_cms_user_global' ? 'CMS_PERMISSIONS_CMS_USERS' : 'CMS_PERMISSIONS_CMS_GROUPS';
                break;
            case 'setting_cms_user_local':
            case 'setting_cms_group_local':
                $this->permission_dropdown = $this->id_type == 'layout' ? array('cmsl_') : ($this->id_type == 'layout_special' ? array('cmss_') : array('cmsb_'));
                $permission_victim = array('cms', 'usergroup');
                //$permission_victim = ($mode == 'setting_cms_user_local') ? array('user') : array('group');
                $this->page_title = $mode == 'setting_cms_user_local' ? 'CMS_PERMISSIONS_CMS_USERS' : 'CMS_PERMISSIONS_CMS_GROUPS';
                break;
            case 'setting_plugins_user_global':
            case 'setting_plugins_group_global':
//.........这里部分代码省略.........
开发者ID:ALTUN69,项目名称:icy_phoenix,代码行数:101,代码来源:class_cms_permissions.php

示例12: view_log


//.........这里部分代码省略.........
                    $sql_forum = $forum_id ? 'AND l.forum_id = ' . intval($forum_id) : '';
                }
            }
            break;
        case 'user':
            $log_type = LOG_USERS;
            $sql_forum = 'AND l.reportee_id = ' . intval($user_id);
            break;
        case 'users':
            $log_type = LOG_USERS;
            $sql_forum = '';
            break;
        case 'critical':
            $log_type = LOG_CRITICAL;
            $sql_forum = '';
            break;
        default:
            return;
    }
    $sql = "SELECT l.*, u.username\n\t\tFROM " . LOG_TABLE . " l, " . USERS_TABLE . " u\n\t\tWHERE l.log_type = {$log_type}\n\t\t\tAND u.user_id = l.user_id\n\t\t\t" . ($limit_days ? "AND l.log_time >= {$limit_days}" : '') . "\n\t\t\t{$sql_forum}\n\t\tORDER BY {$sort_by}";
    $result = $db->sql_query_limit($sql, $limit, $offset);
    $i = 0;
    $log = array();
    while ($row = $db->sql_fetchrow($result)) {
        if ($row['topic_id']) {
            $topic_id_list[] = $row['topic_id'];
        }
        if ($row['reportee_id']) {
            $reportee_id_list[] = $row['reportee_id'];
        }
        $log[$i] = array('id' => $row['log_id'], 'reportee_id' => $row['reportee_id'], 'reportee_username' => '', 'user_id' => $row['user_id'], 'username' => '<a href="' . $profile_url . '&amp;u=' . $row['user_id'] . '">' . $row['username'] . '</a>', 'ip' => $row['log_ip'], 'time' => $row['log_time'], 'forum_id' => $row['forum_id'], 'topic_id' => $row['topic_id'], 'viewforum' => $row['forum_id'] && $auth->acl_get('f_read', $row['forum_id']) ? append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']) : false, 'action' => isset($user->lang[$row['log_operation']]) ? $user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}');
        if (!empty($row['log_data'])) {
            $log_data_ary = unserialize($row['log_data']);
            if (isset($user->lang[$row['log_operation']])) {
                foreach ($log_data_ary as $log_data) {
                    $log_data = str_replace("\n", '<br />', censor_text($log_data));
                    $log[$i]['action'] = preg_replace('#%s#', $log_data, $log[$i]['action'], 1);
                }
            } else {
                $log[$i]['action'] .= '<br />' . implode('', $log_data_ary);
            }
        }
        $i++;
    }
    $db->sql_freeresult($result);
    if (sizeof($topic_id_list)) {
        $topic_id_list = array_unique($topic_id_list);
        // This query is not really needed if move_topics() updates the forum_id field,
        // although it's also used to determine if the topic still exists in the database
        $sql = 'SELECT topic_id, forum_id
			FROM ' . TOPICS_TABLE . '
			WHERE topic_id IN (' . implode(', ', array_map('intval', $topic_id_list)) . ')';
        $result = $db->sql_query($sql);
        $default_forum_id = 0;
        while ($row = $db->sql_fetchrow($result)) {
            if (!$row['forum_id']) {
                if ($auth->acl_getf_global('f_read')) {
                    if (!$default_forum_id) {
                        $sql = 'SELECT forum_id
							FROM ' . FORUMS_TABLE . '
							WHERE forum_type = ' . FORUM_POST;
                        $f_result = $db->sql_query_limit($sql, 1);
                        $default_forum_id = (int) $db->sql_fetchfield('forum_id', false, $f_result);
                        $db->sql_freeresult($f_result);
                    }
                    $is_auth[$row['topic_id']] = $default_forum_id;
                }
            } else {
                if ($auth->acl_get('f_read', $row['forum_id'])) {
                    $is_auth[$row['topic_id']] = $row['forum_id'];
                }
            }
            if ($auth->acl_gets('a_', 'm_', $row['forum_id'])) {
                $is_mod[$row['topic_id']] = $row['forum_id'];
            }
        }
        $db->sql_freeresult($result);
        foreach ($log as $key => $row) {
            $log[$key]['viewtopic'] = isset($is_auth[$row['topic_id']]) ? append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $is_auth[$row['topic_id']] . '&amp;t=' . $row['topic_id']) : false;
            $log[$key]['viewlogs'] = isset($is_mod[$row['topic_id']]) ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=logs&amp;mode=topic_logs&amp;t=' . $row['topic_id'], true, $user->session_id) : false;
        }
    }
    if ($reportee_id_list) {
        $reportee_id_list = array_unique($reportee_id_list);
        $reportee_names_list = array();
        if (!function_exists('user_get_id_name')) {
            include_once $phpbb_root_path . 'includes/functions_user.' . $phpEx;
        }
        user_get_id_name($reportee_id_list, $reportee_names_list);
        foreach ($log as $key => $row) {
            $log[$key]['reportee_username'] = isset($reportee_names_list[$row['reportee_id']]) ? '<a href="' . $profile_url . '&amp;u=' . $row['reportee_id'] . '">' . $reportee_names_list[$row['reportee_id']] . '</a>' : false;
        }
    }
    $sql = 'SELECT COUNT(l.log_id) AS total_entries
		FROM ' . LOG_TABLE . " l\n\t\tWHERE l.log_type = {$log_type}\n\t\t\tAND l.log_time >= {$limit_days}\n\t\t\t{$sql_forum}";
    $result = $db->sql_query($sql);
    $log_count = (int) $db->sql_fetchfield('total_entries');
    $db->sql_freeresult($result);
    return;
}
开发者ID:yunsite,项目名称:gloryroad,代码行数:101,代码来源:functions_admin.php

示例13: request_var

$type = request_var('type', "");
$result = false;
if ($type != "" && $config['eveapi_jabber_masterswitch'] && $config['eveapi_ejabber_switch']) {
    $challenge = request_var('challenge', '');
    if ($challenge == $secret) {
        if ($type == "checkAuth") {
            $user = urldecode(request_var('user', ''));
            $pass = urldecode(request_var('pass', ''));
            $user = str_replace("_", " ", base64_decode($user));
            $pass = base64_decode($pass);
            $result = checkAuth($user, $pass);
        } elseif ($type == "isUser") {
            $user = urldecode(request_var('user', ''));
            $user = base64_decode($user);
            $userArray = array($user);
            $id = user_get_id_name(array(), $userArray, array(0, 3));
            if ($id === false) {
                $result = true;
            }
        }
    }
}
$response_text = $result ? "true" : "false";
header("Content-Type:text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<result>\n";
echo "<response>{$response_text}</response>\n";
echo "</result>\n";
// --------------------------------------------
function checkAuth($username, $password)
{
开发者ID:shibdib,项目名称:API-Registration-Mod-Revisited,代码行数:31,代码来源:forum_side.php

示例14: process_entry_modification

 /**
  * Process modification of own entry
  *
  * @return array errors
  */
 protected function process_entry_modification()
 {
     if (!check_form_key($this->form_key_name)) {
         return array($this->user->lang('FORM_INVALID'));
     }
     if (!$this->request->is_set_post('entries_to_modify')) {
         return array();
     }
     $entry_ids = array_unique(explode(",", $this->request->variable('entries_to_modify', '')));
     $entry_user_id = $real_user_id = $this->user->data['user_id'];
     $errors = array();
     foreach ($entry_ids as $entry_id) {
         $changed = $filled_out = false;
         if ($entry_id == self::ADDUSER_ENTRY_ID) {
             $username = utf8_normalize_nfc($this->request->variable('answer_adduser_username', '', true));
             if ($username == '') {
                 continue;
             }
             $adduser_id = array();
             if (user_get_id_name($adduser_id, $username) == 'NO_USERS') {
                 $errors[] = $this->user->lang('NO_USER');
                 continue;
             }
             $entry_user_id = $adduser_id[0];
             if (!$this->survey->can_add_new_entry($real_user_id, $entry_user_id)) {
                 $errors[] = $this->user->lang('NO_AUTH_OPERATION');
                 continue;
             }
         } else {
             $entry_id = (int) $entry_id;
             if ($entry_id == self::NEW_ENTRY_ID && !$this->survey->can_add_new_entry($real_user_id)) {
                 $errors[] = $this->user->lang('NO_AUTH_OPERATION');
                 continue;
             } else {
                 if ($entry_id != self::NEW_ENTRY_ID && !$this->survey->entry_exists($entry_id)) {
                     continue;
                 } else {
                     if ($entry_id != self::NEW_ENTRY_ID && !$this->survey->can_modify_entry($real_user_id, $this->survey->entries[$entry_id]['user_id'])) {
                         $errors[] = $this->user->lang('NO_AUTH_OPERATION');
                         continue;
                     }
                 }
             }
         }
         $answers = array();
         $abort = false;
         foreach ($this->survey->questions as $question_id => $question) {
             $answers[$question_id] = $this->request->is_set_post("answer_{$entry_id}_{$question_id}") ? $this->request->variable("answer_{$entry_id}_{$question_id}", '', true) : '';
             if ($question['type'] == survey::$QUESTION_TYPES['DROP_DOWN_MENU']) {
                 if (isset($question['choices'][$answers[$question_id]])) {
                     $answers[$question_id] = $question['choices'][$answers[$question_id]]['text'];
                 } else {
                     $answers[$question_id] = '';
                 }
             } else {
                 if ($question['type'] == survey::$QUESTION_TYPES['MULTIPLE_CHOICE']) {
                     $answers_choice_array = array_unique($this->request->variable("answer_{$entry_id}_{$question_id}", array(0)));
                     $answers[$question_id] = array();
                     foreach ($answers_choice_array as $choice_id) {
                         if (isset($question['choices'][$choice_id])) {
                             $answers[$question_id][] = $question['choices'][$choice_id]['text'];
                         }
                     }
                     $answers[$question_id] = implode(",", $answers[$question_id]);
                 }
             }
             $old_exists = $entry_id != self::ADDUSER_ENTRY_ID && $entry_id != self::NEW_ENTRY_ID && isset($this->survey->entries[$entry_id]['answers'][$question_id]);
             $old_value = $old_exists ? $this->survey->entries[$entry_id]['answers'][$question_id] : 0;
             if ($answers[$question_id] != '') {
                 if (!$this->survey->check_answer($answers[$question_id], $question_id)) {
                     $errors[] = $this->user->lang('SURVEY_INVALID_ANSWER');
                     $abort = true;
                     continue;
                 }
                 $filled_out = true;
                 if ($this->survey->has_cap($question_id) && !$this->survey->can_manage($real_user_id)) {
                     $diff = $this->survey->modify_sum_entry($question_id, false, true, $answers[$question_id], $old_exists, $old_value);
                     if ($diff != 0 && $this->survey->cap_exceeded($question_id, $diff)) {
                         $errors[] = $this->user->lang('SURVEY_CAP_EXEEDED', $this->survey->questions[$question_id]['label']);
                         $abort = true;
                         continue;
                     }
                 }
                 if (!$old_exists || $old_value != $answers[$question_id]) {
                     $changed = true;
                 }
             } else {
                 if ($old_exists && $old_value != '') {
                     $changed = true;
                 }
             }
         }
         if ($abort) {
             continue;
         }
//.........这里部分代码省略.........
开发者ID:kilianr,项目名称:phpbb-ext-survey,代码行数:101,代码来源:viewtopic.php

示例15: phpBBchangePassword

 private function phpBBchangePassword($u_name, $new_password)
 {
     $save_sytem_config = $GLOBALS['config'];
     global $phpbb_root_path;
     global $phpEx;
     global $db;
     $phpbb_root_path = $this->_phpbb_src;
     $phpEx = 'php';
     ob_start();
     if (is_readable($this->_phpbb_src . 'config.php') and is_executable($this->_phpbb_src . 'config.php') and is_readable($this->_phpbb_src . 'common.php') and is_executable($this->_phpbb_src . 'common.php') and is_readable($this->_phpbb_src . 'includes/functions_user.php') and is_executable($this->_phpbb_src . 'includes/functions_user.php')) {
         require_once $this->_phpbb_src . 'config.php';
         require_once $this->_phpbb_src . 'common.php';
         require_once $this->_phpbb_src . 'includes/functions_user.php';
     } else {
         return false;
     }
     $username_ary = $u_name;
     user_get_id_name($user_id_ary, $username_ary);
     $isOK = false;
     if (!empty($user_id_ary) && isset($user_id_ary[0])) {
         $uid = $user_id_ary[0];
         $q = "UPDATE " . USERS_TABLE . " SET `user_password` = '" . phpbb_hash($new_password) . "' WHERE `user_id` = " . $uid . " LIMIT 1";
         $isOK = $db->sql_query($q);
     }
     ob_end_clean();
     $GLOBALS['config'] = $save_sytem_config;
     return $isOK;
 }
开发者ID:ValenokPC,项目名称:tabernacms,代码行数:28,代码来源:registerphpbb.php


注:本文中的user_get_id_name函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。