• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP update_last_username函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

    function main($id, $mode)
    {
        global $config, $phpbb_root_path, $phpEx;
        global $db, $user, $auth, $template;
        $user_id = request_var('u', 0);
        $key = request_var('k', '');
        $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey
			FROM ' . USERS_TABLE . "\n\t\t\tWHERE user_id = {$user_id}";
        $result = $db->sql_query($sql);
        $user_row = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        if (!$user_row) {
            trigger_error('NO_USER');
        }
        if ($user_row['user_type'] != USER_INACTIVE && !$user_row['user_newpasswd']) {
            meta_refresh(3, append_sid("{$phpbb_root_path}index.{$phpEx}"));
            trigger_error('ALREADY_ACTIVATED');
        }
        if ($user_row['user_actkey'] != $key) {
            trigger_error('WRONG_ACTIVATION');
        }
        $update_password = $user_row['user_newpasswd'] ? true : false;
        if ($update_password) {
            $sql_ary = array('user_type' => USER_NORMAL, 'user_actkey' => '', 'user_password' => $user_row['user_newpasswd'], 'user_newpasswd' => '');
            $sql = 'UPDATE ' . USERS_TABLE . '
				SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
				WHERE user_id = ' . $user_row['user_id'];
            $db->sql_query($sql);
        }
        if (!$update_password) {
            include_once $phpbb_root_path . 'includes/functions_user.' . $phpEx;
            // Now we need to demote the user from the inactive group and add him to the registered group
            user_active_flip($user_row['user_id'], $user_row['user_type'], '', $user_row['username'], true);
            // Update last username
            update_last_username();
            set_config('num_users', $config['num_users'] + 1, true);
        }
        if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !$update_password) {
            include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
            $messenger = new messenger(false);
            $messenger->template('admin_welcome_activated', $user_row['user_lang']);
            $messenger->replyto($config['board_contact']);
            $messenger->to($user_row['user_email'], $user_row['username']);
            $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
            $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
            $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
            $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
            $messenger->assign_vars(array('SITENAME' => $config['sitename'], 'USERNAME' => html_entity_decode($user_row['username']), 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig'])));
            $messenger->send($user_row['user_notify_type']);
            $message = 'ACCOUNT_ACTIVE_ADMIN';
        } else {
            $message = !$update_password ? 'ACCOUNT_ACTIVE' : 'PASSWORD_ACTIVATED';
        }
        meta_refresh(3, append_sid("{$phpbb_root_path}index.{$phpEx}"));
        trigger_error($user->lang[$message]);
    }
开发者ID:yunsite,项目名称:gloryroad,代码行数:56,代码来源:ucp_activate.php


示例2: main


//.........这里部分代码省略.........
                                $user_actkey = gen_rand_string(10);
                                $key_len = 54 - strlen($server_url);
                                $key_len = $key_len > 6 ? $key_len : 6;
                                $user_actkey = substr($user_actkey, 0, $key_len);
                                if ($user_row['user_type'] != USER_INACTIVE) {
                                    user_active_flip($user_id, $user_row['user_type'], $user_actkey, $user_row['username']);
                                }
                                $messenger = new messenger(false);
                                $messenger->template('user_resend_inactive', $user_row['user_lang']);
                                $messenger->replyto($config['board_contact']);
                                $messenger->to($user_row['user_email'], $user_row['username']);
                                $messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
                                $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
                                $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
                                $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
                                $messenger->assign_vars(array('SITENAME' => $config['sitename'], 'WELCOME_MSG' => sprintf($user->lang['WELCOME_SUBJECT'], $config['sitename']), 'USERNAME' => html_entity_decode($user_row['username']), 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user_row['user_id']}&k={$user_actkey}"));
                                $messenger->send(NOTIFY_EMAIL);
                                add_log('admin', 'LOG_USER_REACTIVATE', $user_row['username']);
                                add_log('user', $user_id, 'LOG_USER_REACTIVATE_USER');
                                trigger_error($user->lang['FORCE_REACTIVATION_SUCCESS'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
                            }
                            break;
                        case 'active':
                            user_active_flip($user_id, $user_row['user_type'], false, $user_row['username']);
                            $message = $user_row['user_type'] == USER_INACTIVE ? 'USER_ADMIN_ACTIVATED' : 'USER_ADMIN_DEACTIVED';
                            $log = $user_row['user_type'] == USER_INACTIVE ? 'LOG_USER_ACTIVE' : 'LOG_USER_INACTIVE';
                            add_log('user', $user_id, $log . '_USER');
                            if ($user_row['user_type'] == USER_INACTIVE) {
                                set_config('num_users', $config['num_users'] + 1, true);
                            } else {
                                set_config('num_users', $config['num_users'] - 1, true);
                            }
                            // Update latest username
                            update_last_username();
                            trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
                            break;
                        case 'delsig':
                            $sql_ary = array('user_sig' => '', 'user_sig_bbcode_uid' => '', 'user_sig_bbcode_bitfield' => 0);
                            $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}";
                            $db->sql_query($sql);
                            add_log('admin', 'LOG_USER_DEL_SIG', $user_row['username']);
                            add_log('user', $user_id, 'LOG_USER_DEL_SIG_USER');
                            trigger_error($user->lang['USER_ADMIN_SIG_REMOVED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
                            break;
                        case 'delavatar':
                            $sql_ary = array('user_avatar' => '', 'user_avatar_type' => 0, 'user_avatar_width' => 0, 'user_avatar_height' => 0);
                            $sql = 'UPDATE ' . USERS_TABLE . '
								SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\t\tWHERE user_id = {$user_id}";
                            $db->sql_query($sql);
                            // Delete old avatar if present
                            if ($user_row['user_avatar'] && $user_row['user_avatar_type'] != AVATAR_GALLERY) {
                                avatar_delete($user_row['user_avatar']);
                            }
                            add_log('admin', 'LOG_USER_DEL_AVATAR', $user_row['username']);
                            add_log('user', $user_id, 'LOG_USER_DEL_AVATAR_USER');
                            trigger_error($user->lang['USER_ADMIN_AVATAR_REMOVED'] . adm_back_link($this->u_action . '&amp;u=' . $user_id));
                            break;
                        case 'delposts':
                            if (confirm_box(true)) {
                                $sql = 'SELECT topic_id, COUNT(post_id) AS total_posts
									FROM ' . POSTS_TABLE . "\n\t\t\t\t\t\t\t\t\tWHERE poster_id = {$user_id}\n\t\t\t\t\t\t\t\t\tGROUP BY topic_id";
                                $result = $db->sql_query($sql);
                                $topic_id_ary = array();
                                while ($row = $db->sql_fetchrow($result)) {
                                    $topic_id_ary[$row['topic_id']] = $row['total_posts'];
                                }
开发者ID:yunsite,项目名称:gloryroad,代码行数:67,代码来源:acp_users.php


示例3: main


//.........这里部分代码省略.........
                        if (!$auth->acl_get('a_board')) {
                            trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
                        }
                        $sql = 'SELECT COUNT(post_id) AS stat
							FROM ' . POSTS_TABLE . '
							WHERE post_visibility = ' . ITEM_APPROVED;
                        $result = $db->sql_query($sql);
                        $config->set('num_posts', (int) $db->sql_fetchfield('stat'), false);
                        $db->sql_freeresult($result);
                        $sql = 'SELECT COUNT(topic_id) AS stat
							FROM ' . TOPICS_TABLE . '
							WHERE topic_visibility = ' . ITEM_APPROVED;
                        $result = $db->sql_query($sql);
                        $config->set('num_topics', (int) $db->sql_fetchfield('stat'), false);
                        $db->sql_freeresult($result);
                        $sql = 'SELECT COUNT(user_id) AS stat
							FROM ' . USERS_TABLE . '
							WHERE user_type IN (' . USER_NORMAL . ',' . USER_FOUNDER . ')';
                        $result = $db->sql_query($sql);
                        $config->set('num_users', (int) $db->sql_fetchfield('stat'), false);
                        $db->sql_freeresult($result);
                        $sql = 'SELECT COUNT(attach_id) as stat
							FROM ' . ATTACHMENTS_TABLE . '
							WHERE is_orphan = 0';
                        $result = $db->sql_query($sql);
                        $config->set('num_files', (int) $db->sql_fetchfield('stat'), false);
                        $db->sql_freeresult($result);
                        $sql = 'SELECT SUM(filesize) as stat
							FROM ' . ATTACHMENTS_TABLE . '
							WHERE is_orphan = 0';
                        $result = $db->sql_query($sql);
                        $config->set('upload_dir_size', (double) $db->sql_fetchfield('stat'), false);
                        $db->sql_freeresult($result);
                        if (!function_exists('update_last_username')) {
                            include $phpbb_root_path . "includes/functions_user.{$phpEx}";
                        }
                        update_last_username();
                        $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESYNC_STATS');
                        if ($request->is_ajax()) {
                            trigger_error('RESYNC_STATS_SUCCESS');
                        }
                        break;
                    case 'user':
                        if (!$auth->acl_get('a_board')) {
                            trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
                        }
                        // Resync post counts
                        $start = $max_post_id = 0;
                        // Find the maximum post ID, we can only stop the cycle when we've reached it
                        $sql = 'SELECT MAX(forum_last_post_id) as max_post_id
							FROM ' . FORUMS_TABLE;
                        $result = $db->sql_query($sql);
                        $max_post_id = (int) $db->sql_fetchfield('max_post_id');
                        $db->sql_freeresult($result);
                        // No maximum post id? :o
                        if (!$max_post_id) {
                            $sql = 'SELECT MAX(post_id) as max_post_id
								FROM ' . POSTS_TABLE;
                            $result = $db->sql_query($sql);
                            $max_post_id = (int) $db->sql_fetchfield('max_post_id');
                            $db->sql_freeresult($result);
                        }
                        // Still no maximum post id? Then we are finished
                        if (!$max_post_id) {
                            $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_RESYNC_POSTCOUNTS');
                            break;
开发者ID:MrAdder,项目名称:phpbb,代码行数:67,代码来源:acp_main.php


示例4: user_active_flip

/**
* Flips user_type from active to inactive and vice versa, handles group membership updates
*
* @param string $mode can be flip for flipping from active/inactive, activate or deactivate
*/
function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
{
    global $config, $db, $user, $auth;
    $deactivated = $activated = 0;
    $sql_statements = array();
    if (!is_array($user_id_ary)) {
        $user_id_ary = array($user_id_ary);
    }
    if (!sizeof($user_id_ary)) {
        return;
    }
    $sql = 'SELECT user_id, group_id, user_type, user_inactive_reason
		FROM ' . USERS_TABLE . '
		WHERE ' . $db->sql_in_set('user_id', $user_id_ary);
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        $sql_ary = array();
        if ($row['user_type'] == USER_IGNORE || $row['user_type'] == USER_FOUNDER || $mode == 'activate' && $row['user_type'] != USER_INACTIVE || $mode == 'deactivate' && $row['user_type'] == USER_INACTIVE) {
            continue;
        }
        if ($row['user_type'] == USER_INACTIVE) {
            $activated++;
        } else {
            $deactivated++;
            // Remove the users session key...
            $user->reset_login_keys($row['user_id']);
        }
        $sql_ary += array('user_type' => $row['user_type'] == USER_NORMAL ? USER_INACTIVE : USER_NORMAL, 'user_inactive_time' => $row['user_type'] == USER_NORMAL ? time() : 0, 'user_inactive_reason' => $row['user_type'] == USER_NORMAL ? $reason : 0);
        $sql_statements[$row['user_id']] = $sql_ary;
    }
    $db->sql_freeresult($result);
    if (sizeof($sql_statements)) {
        foreach ($sql_statements as $user_id => $sql_ary) {
            $sql = 'UPDATE ' . USERS_TABLE . '
				SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
				WHERE user_id = ' . $user_id;
            $db->sql_query($sql);
        }
        $auth->acl_clear_prefetch(array_keys($sql_statements));
    }
    if ($deactivated) {
        set_config('num_users', $config['num_users'] - $deactivated, true);
    }
    if ($activated) {
        set_config('num_users', $config['num_users'] + $activated, true);
    }
    // Update latest username
    update_last_username();
}
开发者ID:Phatboy82,项目名称:phpbbgarage,代码行数:54,代码来源:functions_user.php


示例5: main

    function main($id, $mode)
    {
        global $config, $db, $user, $auth, $template;
        global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
        $action = request_var('action', '');
        $mark = isset($_REQUEST['mark']) ? implode(', ', request_var('mark', array(0))) : '';
        if ($mark) {
            switch ($action) {
                case 'activate':
                case 'delete':
                    if (!$auth->acl_get('a_user')) {
                        trigger_error($user->lang['NO_ADMIN']);
                    }
                    $sql = 'SELECT username 
						FROM ' . USERS_TABLE . "\n\t\t\t\t\t\tWHERE user_id IN ({$mark})";
                    $result = $db->sql_query($sql);
                    $user_affected = array();
                    while ($row = $db->sql_fetchrow($result)) {
                        $user_affected[] = $row['username'];
                    }
                    $db->sql_freeresult($result);
                    if ($action == 'activate') {
                        include_once $phpbb_root_path . 'includes/functions_user.' . $phpEx;
                        $mark_ary = explode(', ', $mark);
                        foreach ($mark_ary as $user_id) {
                            user_active_flip($user_id, USER_INACTIVE);
                        }
                        set_config('num_users', $config['num_users'] + sizeof($mark_ary), true);
                        // Update latest username
                        update_last_username();
                    } else {
                        if ($action == 'delete') {
                            if (!$auth->acl_get('a_userdel')) {
                                trigger_error($user->lang['NO_ADMIN']);
                            }
                            $sql = 'DELETE FROM ' . USER_GROUP_TABLE . " WHERE user_id IN ({$mark})";
                            $db->sql_query($sql);
                            $sql = 'DELETE FROM ' . USERS_TABLE . " WHERE user_id IN ({$mark})";
                            $db->sql_query($sql);
                            add_log('admin', 'LOG_INDEX_' . strtoupper($action), implode(', ', $user_affected));
                        }
                    }
                    break;
                case 'remind':
                    if (!$auth->acl_get('a_user')) {
                        trigger_error($user->lang['NO_ADMIN']);
                    }
                    if (empty($config['email_enable'])) {
                        trigger_error($user->lang['EMAIL_DISABLED']);
                    }
                    $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type, user_regdate, user_actkey 
						FROM ' . USERS_TABLE . " \n\t\t\t\t\t\tWHERE user_id IN ({$mark})";
                    $result = $db->sql_query($sql);
                    if ($row = $db->sql_fetchrow($result)) {
                        // Send the messages
                        include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
                        $messenger = new messenger();
                        $board_url = generate_board_url() . "/ucp.{$phpEx}?mode=activate";
                        $sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
                        $usernames = array();
                        do {
                            $messenger->template('user_remind_inactive', $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' => $sig, 'USERNAME' => html_entity_decode($row['username']), 'SITENAME' => $config['sitename'], 'REGISTER_DATE' => $user->format_date($row['user_regdate']), 'U_ACTIVATE' => "{$board_url}&mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey']));
                            $messenger->send($row['user_notify_type']);
                            $usernames[] = $row['username'];
                        } while ($row = $db->sql_fetchrow($result));
                        $messenger->save_queue();
                        add_log('admin', 'LOG_INDEX_REMIND', implode(', ', $usernames));
                        unset($usernames);
                    }
                    $db->sql_freeresult($result);
                    break;
            }
        }
        switch ($action) {
            case 'online':
                if (!$auth->acl_get('a_board')) {
                    trigger_error($user->lang['NO_ADMIN']);
                }
                set_config('record_online_users', 1, true);
                set_config('record_online_date', time(), true);
                add_log('admin', 'LOG_RESET_ONLINE');
                break;
            case 'stats':
                if (!$auth->acl_get('a_board')) {
                    trigger_error($user->lang['NO_ADMIN']);
                }
                $sql = 'SELECT COUNT(post_id) AS stat 
					FROM ' . POSTS_TABLE . '
					WHERE post_approved = 1';
                $result = $db->sql_query($sql);
                $row = $db->sql_fetchrow($result);
                $db->sql_freeresult($result);
                set_config('num_posts', (int) $row['stat'], true);
                $sql = 'SELECT COUNT(topic_id) AS stat
					FROM ' . TOPICS_TABLE . '
					WHERE topic_approved = 1';
//.........这里部分代码省略.........
开发者ID:yunsite,项目名称:gloryroad,代码行数:101,代码来源:acp_main.php


示例6: main


//.........这里部分代码省略.........
                        if (!$auth->acl_get('a_board')) {
                            trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
                        }
                        $sql = 'SELECT COUNT(post_id) AS stat
							FROM ' . POSTS_TABLE . '
							WHERE post_approved = 1';
                        $result = $db->sql_query($sql);
                        set_config('num_posts', (int) $db->sql_fetchfield('stat'), true);
                        $db->sql_freeresult($result);
                        $sql = 'SELECT COUNT(topic_id) AS stat
							FROM ' . TOPICS_TABLE . '
							WHERE topic_approved = 1';
                        $result = $db->sql_query($sql);
                        set_config('num_topics', (int) $db->sql_fetchfield('stat'), true);
                        $db->sql_freeresult($result);
                        $sql = 'SELECT COUNT(user_id) AS stat
							FROM ' . USERS_TABLE . '
							WHERE user_type IN (' . USER_NORMAL . ',' . USER_FOUNDER . ')';
                        $result = $db->sql_query($sql);
                        set_config('num_users', (int) $db->sql_fetchfield('stat'), true);
                        $db->sql_freeresult($result);
                        $sql = 'SELECT COUNT(attach_id) as stat
							FROM ' . ATTACHMENTS_TABLE . '
							WHERE is_orphan = 0';
                        $result = $db->sql_query($sql);
                        set_config('num_files', (int) $db->sql_fetchfield('stat'), true);
                        $db->sql_freeresult($result);
                        $sql = 'SELECT SUM(filesize) as stat
							FROM ' . ATTACHMENTS_TABLE . '
							WHERE is_orphan = 0';
                        $result = $db->sql_query($sql);
                        set_config('upload_dir_size', (double) $db->sql_fetchfield('stat'), true);
                        $db->sql_freeresult($result);
                        if (!function_exists('update_last_username')) {
                            include $phpbb_root_path . "includes/functions_user.{$phpEx}";
                        }
                        update_last_username();
                        add_log('admin', 'LOG_RESYNC_STATS');
                        break;
                    case 'user':
                        if (!$auth->acl_get('a_board')) {
                            trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
                        }
                        // Resync post counts
                        $start = $max_post_id = 0;
                        // Find the maximum post ID, we can only stop the cycle when we've reached it
                        $sql = 'SELECT MAX(forum_last_post_id) as max_post_id
							FROM ' . FORUMS_TABLE;
                        $result = $db->sql_query($sql);
                        $max_post_id = (int) $db->sql_fetchfield('max_post_id');
                        $db->sql_freeresult($result);
                        // No maximum post id? :o
                        if (!$max_post_id) {
                            $sql = 'SELECT MAX(post_id)
								FROM ' . POSTS_TABLE;
                            $result = $db->sql_query($sql);
                            $max_post_id = (int) $db->sql_fetchfield('max_post_id');
                            $db->sql_freeresult($result);
                        }
                        // Still no maximum post id? Then we are finished
                        if (!$max_post_id) {
                            add_log('admin', 'LOG_RESYNC_POSTCOUNTS');
                            break;
                        }
                        $step = $config['num_posts'] ? max((int) ($config['num_posts'] / 5), 20000) : 20000;
                        $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_posts = 0');
开发者ID:BackupTheBerlios,项目名称:phpbb-hu-svn,代码行数:67,代码来源:acp_main.php


示例7: user_active_flip

/**
* Flips user_type from active to inactive and vice versa, handles group membership updates
*
* @param string $mode can be flip for flipping from active/inactive, activate or deactivate
*/
function user_active_flip($mode, $user_id_ary, $reason = INACTIVE_MANUAL)
{
    global $config, $db, $user, $auth, $phpbb_dispatcher;
    $deactivated = $activated = 0;
    $sql_statements = array();
    if (!is_array($user_id_ary)) {
        $user_id_ary = array($user_id_ary);
    }
    if (!sizeof($user_id_ary)) {
        return;
    }
    $sql = 'SELECT user_id, group_id, user_type, user_inactive_reason
		FROM ' . USERS_TABLE . '
		WHERE ' . $db->sql_in_set('user_id', $user_id_ary);
    $result = $db->sql_query($sql);
    while ($row = $db->sql_fetchrow($result)) {
        $sql_ary = array();
        if ($row['user_type'] == USER_IGNORE || $row['user_type'] == USER_FOUNDER || $mode == 'activate' && $row['user_type'] != USER_INACTIVE || $mode == 'deactivate' && $row['user_type'] == USER_INACTIVE) {
            continue;
        }
        if ($row['user_type'] == USER_INACTIVE) {
            $activated++;
        } else {
            $deactivated++;
            // Remove the users session key...
            $user->reset_login_keys($row['user_id']);
        }
        $sql_ary += array('user_type' => $row['user_type'] == USER_NORMAL ? USER_INACTIVE : USER_NORMAL, 'user_inactive_time' => $row['user_type'] == USER_NORMAL ? time() : 0, 'user_inactive_reason' => $row['user_type'] == USER_NORMAL ? $reason : 0);
        $sql_statements[$row['user_id']] = $sql_ary;
    }
    $db->sql_freeresult($result);
    /**
     * Check or modify activated/deactivated users data before submitting it to the database
     *
     * @event core.user_active_flip_before
     * @var	string	mode			User type changing mode, can be: flip|activate|deactivate
     * @var	int		reason			Reason for changing user type, can be: INACTIVE_REGISTER|INACTIVE_PROFILE|INACTIVE_MANUAL|INACTIVE_REMIND
     * @var	int		activated		The number of users to be activated
     * @var	int		deactivated		The number of users to be deactivated
     * @var	array	user_id_ary		Array with user ids to change user type
     * @var	array	sql_statements	Array with users data to submit to the database, keys: user ids, values: arrays with user data
     * @since 3.1.4-RC1
     */
    $vars = array('mode', 'reason', 'activated', 'deactivated', 'user_id_ary', 'sql_statements');
    extract($phpbb_dispatcher->trigger_event('core.user_active_flip_before', compact($vars)));
    if (sizeof($sql_statements)) {
        foreach ($sql_statements as $user_id => $sql_ary) {
            $sql = 'UPDATE ' . USERS_TABLE . '
				SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
				WHERE user_id = ' . $user_id;
            $db->sql_query($sql);
        }
        $auth->acl_clear_prefetch(array_keys($sql_statements));
    }
    /**
     * Perform additional actions after the users have been activated/deactivated
     *
     * @event core.user_active_flip_after
     * @var	string	mode			User type changing mode, can be: flip|activate|deactivate
     * @var	int		reason			Reason for changing user type, can be: INACTIVE_REGISTER|INACTIVE_PROFILE|INACTIVE_MANUAL|INACTIVE_REMIND
     * @var	int		activated		The number of users to be activated
     * @var	int		deactivated		The number of users to be deactivated
     * @var	array	user_id_ary		Array with user ids to change user type
     * @var	array	sql_statements	Array with users data to submit to the database, keys: user ids, values: arrays with user data
     * @since 3.1.4-RC1
     */
    $vars = array('mode', 'reason', 'activated', 'deactivated', 'user_id_ary', 'sql_statements');
    extract($phpbb_dispatcher->trigger_event('core.user_active_flip_after', compact($vars)));
    if ($deactivated) {
        set_config_count('num_users', $deactivated * -1, true);
    }
    if ($activated) {
        set_config_count('num_users', $activated, true);
    }
    // Update latest username
    update_last_username();
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:82,代码来源:functions_user.php


示例8: run_tool


//.........这里部分代码省略.........
    {
        global $config, $user, $db, $cache;
        $user->add_lang('ucp');
        if (!check_form_key('merge_users')) {
            $error[] = 'FORM_INVALID';
            return;
        }
        $source_name = utf8_normalize_nfc(request_var('source_name', '', true));
        $source_id = utf8_normalize_nfc(request_var('source_id', 0));
        $target_name = utf8_normalize_nfc(request_var('target_name', '', true));
        $target_id = utf8_normalize_nfc(request_var('target_id', 0));
        $delete = request_var('delete', false);
        // Check that one source field and one target field is filled in.
        if (!$source_name && empty($source_id) || !$target_name && empty($target_id)) {
            if (!$source_name && !$source_id) {
                $error[] = 'NO_SOURCE_USER';
            }
            if (!$target_name && !$target_id) {
                $error[] = 'NO_TARGET_USER';
            }
            return;
        }
        // Check if both source fields or both target fields are filled in.
        if ($source_name && $source_id || $target_name && $target_id) {
            if ($source_name && $source_id) {
                $error[] = 'BOTH_SOURCE_USER';
            }
            if ($target_name && $target_id) {
                $error[] = 'BOTH_TARGET_USER';
            }
            return;
        }
        $sql = 'SELECT user_id, user_type
			FROM ' . USERS_TABLE . '
			WHERE ' . ($source_name ? 'username_clean = \'' . $db->sql_escape(utf8_clean_string($source_name)) . '\'' : 'user_id = ' . (int) $source_id);
        $result = $db->sql_query($sql);
        $source = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        $sql = 'SELECT user_id, user_type
			FROM ' . USERS_TABLE . '
			WHERE ' . ($target_name ? 'username_clean = \'' . $db->sql_escape(utf8_clean_string($target_name)) . '\'' : 'user_id = ' . (int) $target_id);
        $result = $db->sql_query($sql);
        $target = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        if (!$source || !$target) {
            if (!$source) {
                $error[] = 'NO_SOURCE_USER';
            }
            if (!$target) {
                $error[] = 'NO_TARGET_USER';
            }
            return;
        }
        if ($source['user_id'] == $target['user_id']) {
            $error[] = 'MERGE_USERS_SAME_USERS';
            return;
        }
        if ($source['user_type'] != $target['user_type']) {
            if ($source['user_type'] == USER_FOUNDER || $target['user_type'] == USER_FOUNDER) {
                // Cannot merge a founder with a non founder or vice versa
                $error[] = 'MERGE_USERS_BOTH_FOUNDERS';
                return;
            } else {
                if ($source['user_type'] == USER_IGNORE || $target['user_type'] == USER_IGNORE) {
                    // Cannot merge a bot with a non bot or vice versa
                    $error[] = 'MERGE_USERS_BOTH_IGNORE';
                    return;
                }
            }
        }
        $source = (int) $source['user_id'];
        $target = (int) $target['user_id'];
        // Needed for the merge
        include PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT;
        $result = $this->merge($source, $target);
        if (is_string($result)) {
            $error[] = $result;
            return;
        }
        $db->sql_transaction('begin');
        foreach ($result as $sql) {
            $db->sql_query($sql);
        }
        $db->sql_transaction('commit');
        // Delete source user
        if ($delete) {
            user_delete('remove', $source, $post_username = false);
        }
        $sql = 'SELECT DISTINCT group_id
			FROM ' . USER_GROUP_TABLE . "\n\t\t\tWHERE user_id IN ({$source}, {$target})";
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            group_update_listings((int) $row['group_id']);
        }
        $db->sql_freeresult($result);
        // Update data
        update_last_username();
        $cache->destroy('sql', MODERATOR_CACHE_TABLE);
        trigger_error('MERGE_USERS_MERGED');
    }
开发者ID:melvingb,项目名称:phpbb3.1-STK,代码行数:101,代码来源:merge_users.php


示例9: user_update

 public function user_update($phpbb_vars, $old_name)
 {
     global $phpbb_root_path, $phpEx, $db, $config, $user, $auth, $cache, $template;
     //fail presumtion
     $phpbb_result = "FAIL";
     //general info
     $this->init(false);
     //user functions
     require_once $phpbb_root_path . "includes/functions_user." . $phpEx;
     //get user_id if possible
     // w produkcjach Hanza/Neart Email jest niezmienny
     if (!isset($phpbb_vars["user_id"])) {
         if (!($phpbb_vars["user_id"] = $this->get_user_id_from_name($phpbb_vars["username"]))) {
             return $phpbb_result;
         }
     }
     $this->get_table_fields(USERS_TABLE);
     $phpbb_vars['username_clean'] = utf8_clean_string($phpbb_vars['username']);
     $ignore_fields = array("user_id");
     //if(isset($phpbb_vars["user_password"])) $phpbb_vars["user_password"] = md5($phpbb_vars["user_password"]);
     if (isset($phpbb_vars["user_newpasswd"])) {
         $phpbb_vars["user_newpasswd"] = md5($phpbb_vars["user_newpasswd"]);
     }
     $sql = "";
     //generate sql
     for ($i = 0; $i < count($this->table_fields[USERS_TABLE]); $i++) {
         if (isset($phpbb_vars[$this->table_fields[USERS_TABLE][$i]]) && !in_array($this->table_fields[USERS_TABLE][$i], $ignore_fields)) {
             $sql .= ", " . $this->table_fields[USERS_TABLE][$i] . " = '" . $db->sql_escape($phpbb_vars[$this->table_fields[USERS_TABLE][$i]]) . "'";
         }
     }
     if (strlen($sql) != 0) {
         $db->sql_query("UPDATE " . USERS_TABLE . " SET " . substr($sql, 2) . " WHERE user_id = '" . $phpbb_vars["user_id"] . "'");
         $phpbb_result = "SUCCESS";
     }
     user_update_name($old_name, $phpbb_vars["username"]);
     update_last_username();
     return $phpbb_result;
 }
开发者ID:hukumonline,项目名称:idh,代码行数:38,代码来源:Forum.php


示例10: user_delete

/**
* Remove User
*/
function user_delete($mode, $user_id, $post_username = false)
{
    global $config, $db, $user, $auth;
    $db->sql_transaction('begin');
    switch ($mode) {
        case 'retain':
            $sql = 'UPDATE ' . FORUMS_TABLE . '
				SET forum_last_poster_id = ' . ANONYMOUS . ($post_username !== false ? ", forum_last_poster_name = '" . $db->sql_escape($post_username) . "'" : '') . "\n\t\t\t\tWHERE forum_last_poster_id = {$user_id}";
            $db->sql_query($sql);
            $sql = 'UPDATE ' . POSTS_TABLE . '
				SET poster_id = ' . ANONYMOUS . ($post_username !== false ? ", post_username = '" . $db->sql_escape($post_username) . "'" : '') . "\n\t\t\t\tWHERE poster_id = {$user_id}";
            $db->sql_query($sql);
            $sql = 'UPDATE ' . TOPICS_TABLE . '
				SET topic_poster = ' . ANONYMOUS . "\n\t\t\t\tWHERE topic_poster = {$user_id}";
            $db->sql_query($sql);
            $sql = 'UPDATE ' . TOPICS_TABLE . '
				SET topic_last_poster_id = ' . ANONYMOUS . ($post_username !== false ? ", topic_last_poster_name = '" . $db->sql_escape($post_username) . "'" : '') . "\n\t\t\t\tWHERE topic_last_poster_id = {$user_id}";
            $db->sql_query($sql);
            break;
        case 'remove':
            if (!function_exists('delete_posts')) {
                global $phpbb_root_path, $phpEx;
                include_once $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
            }
            $sql = 'SELECT topic_id, COUNT(post_id) AS total_posts
				FROM ' . POSTS_TABLE . "\n\t\t\t\tWHERE poster_id = {$user_id}\n\t\t\t\tGROUP BY topic_id";
            $result = $db->sql_query($sql);
            $topic_id_ary = array();
            while ($row = $db->sql_fetchrow($result)) {
                $topic_id_ary[$row['topic_id']] = $row['total_posts'];
            }
            $db->sql_freeresult($result);
            if (sizeof($topic_id_ary)) {
                $sql = 'SELECT topic_id, topic_replies, topic_replies_real
					FROM ' . TOPICS_TABLE . '
					WHERE topic_id IN (' . implode(', ', array_keys($topic_id_ary)) . ')';
                $result = $db->sql_query($sql);
                $del_topic_ary = array();
                while ($row = $db->sql_fetchrow($result)) {
                    if (max($row['topic_replies'], $row['topic_replies_real']) + 1 == $topic_id_ary[$row['topic_id']]) {
                        $del_topic_ary[] = $row['topic_id'];
                    }
                }
                $db->sql_freeresult($result);
                if (sizeof($del_topic_ary)) {
                    $sql = 'DELETE FROM ' . TOPICS_TABLE . '
						WHERE topic_id IN (' . implode(', ', $del_topic_ary) . ')';
                    $db->sql_query($sql);
                }
            }
            // Delete posts, attachments, etc.
            delete_posts('poster_id', $user_id);
            break;
    }
    $table_ary = array(USERS_TABLE, USER_GROUP_TABLE, TOPICS_WATCH_TABLE, FORUMS_WATCH_TABLE, ACL_USERS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, FORUMS_TRACK_TABLE);
    foreach ($table_ary as $table) {
        $sql = "DELETE FROM {$table}\n\t\t\tWHERE user_id = {$user_id}";
        $db->sql_query($sql);
    }
    // Reset newest user info if appropriate
    if ($config['newest_user_id'] == $user_id) {
        update_last_username();
    }
    set_config('num_users', $config['num_users'] - 1, true);
    $db->sql_transaction('commit');
    return false;
}
开发者ID:yunsite,项目名称:gloryroad,代码行数:70,代码来源:functions_user.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP update_lastmod函数代码示例发布时间:2022-05-23
下一篇:
PHP update_item函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap