acl_add_option() public method

.. $options is a hash of form -> $options = array( 'local' => array('option1', 'option2', ...), 'global' => array('optionA', 'optionB', ...) );
public acl_add_option ( $options )
コード例 #1
0
 function install()
 {
     global $phpbb_root_path, $phpEx, $db, $user;
     // Setup $auth_admin class so we can add permission options
     include $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
     $auth_admin = new auth_admin();
     // Add permission for manage cvsdb
     $auth_admin->acl_add_option(array('local' => array(), 'global' => array('a_add_board')));
     $module_data = $this->module();
     $module_basename = substr(strstr($module_data['filename'], '_'), 1);
     $result = $db->sql_query('SELECT module_id FROM ' . MODULES_TABLE . " WHERE module_basename = '{$module_basename}'");
     $module_id = $db->sql_fetchfield('module_id');
     $db->sql_freeresult($result);
     $sql = 'UPDATE ' . MODULES_TABLE . " SET module_auth = 'acl_a_add_board' WHERE module_id = {$module_id}";
     $db->sql_query($sql);
     $config->set('add_user_version', $module_data['version'], false);
     trigger_error(sprintf($user->lang['ADD_USER_MOD_UPDATED'], $module_data['version']));
 }
コード例 #2
0
 /**
  * Load the contents of the schema into the database and then alter it based on what has been input during the installation
  */
 function load_schema($mode, $sub)
 {
     global $cache, $gallery_config, $phpbb_root_path, $phpEx, $template, $user;
     include $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
     $this->page_title = $user->lang['STAGE_CREATE_TABLE'];
     $s_hidden_fields = '';
     $dbms_data = get_dbms_infos();
     $db_schema = $dbms_data['db_schema'];
     $delimiter = $dbms_data['delimiter'];
     // Create the tables
     nv_create_table('phpbb_gallery_albums', $dbms_data);
     nv_create_table('phpbb_gallery_albums_track', $dbms_data);
     nv_create_table('phpbb_gallery_comments', $dbms_data);
     nv_create_table('phpbb_gallery_config', $dbms_data);
     nv_create_table('phpbb_gallery_contests', $dbms_data);
     nv_create_table('phpbb_gallery_favorites', $dbms_data);
     nv_create_table('phpbb_gallery_images', $dbms_data);
     nv_create_table('phpbb_gallery_modscache', $dbms_data);
     nv_create_table('phpbb_gallery_permissions', $dbms_data);
     nv_create_table('phpbb_gallery_rates', $dbms_data);
     nv_create_table('phpbb_gallery_reports', $dbms_data);
     nv_create_table('phpbb_gallery_roles', $dbms_data);
     nv_create_table('phpbb_gallery_users', $dbms_data);
     nv_create_table('phpbb_gallery_watch', $dbms_data);
     // Create columns
     nv_add_column(SESSIONS_TABLE, 'session_album_id', array('UINT', 0));
     nv_add_column(LOG_TABLE, 'album_id', array('UINT', 0));
     nv_add_column(LOG_TABLE, 'image_id', array('UINT', 0));
     nv_add_index(GALLERY_USERS_TABLE, 'pg_palbum_id', array('personal_album_id'));
     nv_add_index(SESSIONS_TABLE, 'session_aid', array('session_album_id'));
     // Set default config
     set_default_config();
     $auth_admin = new auth_admin();
     $auth_admin->acl_add_option(array('local' => array(), 'global' => array('a_gallery_manage', 'a_gallery_albums', 'a_gallery_import', 'a_gallery_cleanup')));
     $cache->destroy('acl_options');
     $template->assign_vars(array('BODY' => $user->lang['STAGE_CREATE_TABLE_EXPLAIN'], 'L_SUBMIT' => $user->lang['NEXT_STEP'], 'S_HIDDEN' => '', 'U_ACTION' => append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&sub=in_progress")));
 }
コード例 #3
0
function change_database_data(&$no_updates, $version)
{
    global $db, $db_tools, $errored, $error_ary, $config, $table_prefix, $phpbb_root_path, $phpEx;
    switch ($version) {
        case '3.0.0':
            $sql = 'UPDATE ' . TOPICS_TABLE . "\n\t\t\t\tSET topic_last_view_time = topic_last_post_time\n\t\t\t\tWHERE topic_last_view_time = 0";
            _sql($sql, $errored, $error_ary);
            // Update smiley sizes
            $smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif');
            foreach ($smileys as $smiley) {
                if (file_exists($phpbb_root_path . 'images/smilies/' . $smiley)) {
                    list($width, $height) = getimagesize($phpbb_root_path . 'images/smilies/' . $smiley);
                    $sql = 'UPDATE ' . SMILIES_TABLE . '
						SET smiley_width = ' . $width . ', smiley_height = ' . $height . "\n\t\t\t\t\t\tWHERE smiley_url = '" . $db->sql_escape($smiley) . "'";
                    _sql($sql, $errored, $error_ary);
                }
            }
            $no_updates = false;
            break;
            // No changes from 3.0.1-RC1 to 3.0.1
        // No changes from 3.0.1-RC1 to 3.0.1
        case '3.0.1-RC1':
            break;
            // changes from 3.0.1 to 3.0.2-RC1
        // changes from 3.0.1 to 3.0.2-RC1
        case '3.0.1':
            set_config('referer_validation', '1');
            set_config('check_attachment_content', '1');
            set_config('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title');
            $no_updates = false;
            break;
            // No changes from 3.0.2-RC1 to 3.0.2-RC2
        // No changes from 3.0.2-RC1 to 3.0.2-RC2
        case '3.0.2-RC1':
            break;
            // No changes from 3.0.2-RC2 to 3.0.2
        // No changes from 3.0.2-RC2 to 3.0.2
        case '3.0.2-RC2':
            break;
            // Changes from 3.0.2 to 3.0.3-RC1
        // Changes from 3.0.2 to 3.0.3-RC1
        case '3.0.2':
            set_config('enable_queue_trigger', '0');
            set_config('queue_trigger_posts', '3');
            set_config('pm_max_recipients', '0');
            // Set maximum number of recipients for the registered users, bots, guests group
            $sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5
				WHERE ' . $db->sql_in_set('group_name', array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA', 'BOTS'));
            _sql($sql, $errored, $error_ary);
            // Not prefilling yet
            set_config('dbms_version', '');
            // Add new permission u_masspm_group and duplicate settings from u_masspm
            include_once $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
            $auth_admin = new auth_admin();
            // Only add the new permission if it does not already exist
            if (empty($auth_admin->acl_options['id']['u_masspm_group'])) {
                $auth_admin->acl_add_option(array('global' => array('u_masspm_group')));
                // Now the tricky part, filling the permission
                $old_id = $auth_admin->acl_options['id']['u_masspm'];
                $new_id = $auth_admin->acl_options['id']['u_masspm_group'];
                $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);
                foreach ($tables as $table) {
                    $sql = 'SELECT *
						FROM ' . $table . '
						WHERE auth_option_id = ' . $old_id;
                    $result = _sql($sql, $errored, $error_ary);
                    $sql_ary = array();
                    while ($row = $db->sql_fetchrow($result)) {
                        $row['auth_option_id'] = $new_id;
                        $sql_ary[] = $row;
                    }
                    $db->sql_freeresult($result);
                    if (sizeof($sql_ary)) {
                        $db->sql_multi_insert($table, $sql_ary);
                    }
                }
                // Remove any old permission entries
                $auth_admin->acl_clear_prefetch();
            }
            /**
            * Do not resync post counts here. An admin may do this later from the ACP
            $start = 0;
            $step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000;
            
            $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = 0';
            _sql($sql, $errored, $error_ary);
            
            do
            {
            	$sql = 'SELECT COUNT(post_id) AS num_posts, poster_id
            		FROM ' . POSTS_TABLE . '
            		WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . '
            			AND post_postcount = 1 AND post_approved = 1
            		GROUP BY poster_id';
            	$result = _sql($sql, $errored, $error_ary);
            
            	if ($row = $db->sql_fetchrow($result))
            	{
            		do
            		{
            			$sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}";
            			_sql($sql, $errored, $error_ary);
            		}
            		while ($row = $db->sql_fetchrow($result));
            
            		$start += $step;
            	}
            	else
            	{
            		$start = 0;
            	}
            	$db->sql_freeresult($result);
            }
            while ($start);
            */
            $sql = 'UPDATE ' . MODULES_TABLE . '
				SET module_auth = \'acl_a_email && cfg_email_enable\'
				WHERE module_class = \'acp\'
					AND module_basename = \'email\'';
            _sql($sql, $errored, $error_ary);
            $no_updates = false;
            break;
            // Changes from 3.0.3-RC1 to 3.0.3
        // Changes from 3.0.3-RC1 to 3.0.3
        case '3.0.3-RC1':
            if ($db->sql_layer == 'oracle') {
                // log_operation is CLOB - but we can change this later
                $sql = 'UPDATE ' . LOG_TABLE . "\n\t\t\t\t\tSET log_operation = 'LOG_DELETE_TOPIC'\n\t\t\t\t\tWHERE log_operation LIKE 'LOG_TOPIC_DELETED'";
                _sql($sql, $errored, $error_ary);
            } else {
                $sql = 'UPDATE ' . LOG_TABLE . "\n\t\t\t\t\tSET log_operation = 'LOG_DELETE_TOPIC'\n\t\t\t\t\tWHERE log_operation = 'LOG_TOPIC_DELETED'";
                _sql($sql, $errored, $error_ary);
            }
            $no_updates = false;
            break;
            // Changes from 3.0.3 to 3.0.4-RC1
        // Changes from 3.0.3 to 3.0.4-RC1
        case '3.0.3':
            // Update the Custom Profile Fields based on previous settings to the new format
            $sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide
					FROM ' . PROFILE_FIELDS_TABLE;
            $result = _sql($sql, $errored, $error_ary);
            while ($row = $db->sql_fetchrow($result)) {
                $sql_ary = array('field_required' => 0, 'field_show_on_reg' => 0, 'field_hide' => 0, 'field_show_profile' => 0);
                if ($row['field_required']) {
                    $sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1;
                } else {
                    if ($row['field_show_on_reg']) {
                        $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1;
                    } else {
                        if ($row['field_hide']) {
                            // Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module
                            $sql_ary['field_hide'] = 1;
                        } else {
                            // equivelant to "none", which is the "Display in user control panel" option
                            $sql_ary['field_show_profile'] = 1;
                        }
                    }
                }
                _sql('UPDATE ' . PROFILE_FIELDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary);
            }
            $no_updates = false;
            break;
            // Changes from 3.0.4-RC1 to 3.0.4
        // Changes from 3.0.4-RC1 to 3.0.4
        case '3.0.4-RC1':
            break;
            // Changes from 3.0.4 to 3.0.5-RC1
        // Changes from 3.0.4 to 3.0.5-RC1
        case '3.0.4':
            // Captcha config variables
            set_config('captcha_gd_wave', 0);
            set_config('captcha_gd_3d_noise', 1);
            set_config('captcha_gd_fonts', 1);
            set_config('confirm_refresh', 1);
            // Maximum number of keywords
            set_config('max_num_search_keywords', 10);
            // Remove static config var and put it back as dynamic variable
            $sql = 'UPDATE ' . CONFIG_TABLE . "\n\t\t\t\tSET is_dynamic = 1\n\t\t\t\tWHERE config_name = 'search_indexing_state'";
            _sql($sql, $errored, $error_ary);
            // Hash old MD5 passwords
            $sql = 'SELECT user_id, user_password
					FROM ' . USERS_TABLE . '
					WHERE user_pass_convert = 1';
            $result = _sql($sql, $errored, $error_ary);
            while ($row = $db->sql_fetchrow($result)) {
                if (strlen($row['user_password']) == 32) {
                    $sql_ary = array('user_password' => phpbb_hash($row['user_password']));
                    _sql('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id'], $errored, $error_ary);
                }
            }
            $db->sql_freeresult($result);
            // Adjust bot entry
            $sql = 'UPDATE ' . BOTS_TABLE . "\n\t\t\t\tSET bot_agent = 'ichiro/'\n\t\t\t\tWHERE bot_agent = 'ichiro/2'";
            _sql($sql, $errored, $error_ary);
            // Before we are able to add a unique key to auth_option, we need to remove duplicate entries
            // We get duplicate entries first
            $sql = 'SELECT auth_option
				FROM ' . ACL_OPTIONS_TABLE . '
				GROUP BY auth_option
				HAVING COUNT(*) >= 2';
            $result = $db->sql_query($sql);
            $auth_options = array();
            while ($row = $db->sql_fetchrow($result)) {
                $auth_options[] = $row['auth_option'];
            }
            $db->sql_freeresult($result);
            // Remove specific auth options
            if (!empty($auth_options)) {
                foreach ($auth_options as $option) {
                    // Select auth_option_ids... the largest id will be preserved
                    $sql = 'SELECT auth_option_id
						FROM ' . ACL_OPTIONS_TABLE . "\n\t\t\t\t\t\tWHERE auth_option = '" . $db->sql_escape($option) . "'\n\t\t\t\t\t\tORDER BY auth_option_id DESC";
                    // sql_query_limit not possible here, due to bug in postgresql layer
                    $result = $db->sql_query($sql);
                    // Skip first row, this is our original auth option we want to preserve
                    $row = $db->sql_fetchrow($result);
                    while ($row = $db->sql_fetchrow($result)) {
                        // Ok, remove this auth option...
                        _sql('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary);
                        _sql('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary);
                        _sql('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary);
                        _sql('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary);
                    }
                    $db->sql_freeresult($result);
                }
            }
            // Now make auth_option UNIQUE, by dropping the old index and adding a UNIQUE one.
            $changes = array('drop_keys' => array(ACL_OPTIONS_TABLE => array('auth_option')));
            $statements = $db_tools->perform_schema_changes($changes);
            foreach ($statements as $sql) {
                _sql($sql, $errored, $error_ary);
            }
            $changes = array('add_unique_index' => array(ACL_OPTIONS_TABLE => array('auth_option' => array('auth_option'))));
            $statements = $db_tools->perform_schema_changes($changes);
            foreach ($statements as $sql) {
                _sql($sql, $errored, $error_ary);
            }
            $no_updates = false;
            break;
            // No changes from 3.0.5-RC1 to 3.0.5
        // No changes from 3.0.5-RC1 to 3.0.5
        case '3.0.5-RC1':
            break;
            // Changes from 3.0.5 to 3.0.6-RC1
        // Changes from 3.0.5 to 3.0.6-RC1
        case '3.0.5':
            // Let's see if the GD Captcha can be enabled... we simply look for what *is* enabled...
            if (!empty($config['captcha_gd']) && !isset($config['captcha_plugin'])) {
                set_config('captcha_plugin', 'phpbb_captcha_gd');
            } else {
                if (!isset($config['captcha_plugin'])) {
                    set_config('captcha_plugin', 'phpbb_captcha_nogd');
                }
            }
            // Entries for the Feed Feature
            set_config('feed_enable', '0');
            set_config('feed_limit', '10');
            set_config('feed_overall_forums', '1');
            set_config('feed_overall_forums_limit', '15');
            set_config('feed_overall_topics', '0');
            set_config('feed_overall_topics_limit', '15');
            set_config('feed_forum', '1');
            set_config('feed_topic', '1');
            set_config('feed_item_statistics', '1');
            // Entries for smiley pagination
            set_config('smilies_per_page', '50');
            // Entry for reporting PMs
            set_config('allow_pm_report', '1');
            // Install modules
            $modules_to_install = array('feed' => array('base' => 'board', 'class' => 'acp', 'title' => 'ACP_FEED_SETTINGS', 'auth' => 'acl_a_board', 'cat' => 'ACP_BOARD_CONFIGURATION', 'after' => array('signature', 'ACP_SIGNATURE_SETTINGS')), 'warnings' => array('base' => 'users', 'class' => 'acp', 'title' => 'ACP_USER_WARNINGS', 'auth' => 'acl_a_user', 'display' => 0, 'cat' => 'ACP_CAT_USERS', 'after' => array('feedback', 'ACP_USER_FEEDBACK')), 'send_statistics' => array('base' => 'send_statistics', 'class' => 'acp', 'title' => 'ACP_SEND_STATISTICS', 'auth' => 'acl_a_server', 'cat' => 'ACP_SERVER_CONFIGURATION'), 'setting_forum_copy' => array('base' => 'permissions', 'class' => 'acp', 'title' => 'ACP_FORUM_PERMISSIONS_COPY', 'auth' => 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth', 'cat' => 'ACP_FORUM_BASED_PERMISSIONS', 'after' => array('setting_forum_local', 'ACP_FORUM_PERMISSIONS')), 'pm_reports' => array('base' => 'pm_reports', 'class' => 'mcp', 'title' => 'MCP_PM_REPORTS_OPEN', 'auth' => 'aclf_m_report', 'cat' => 'MCP_REPORTS'), 'pm_reports_closed' => array('base' => 'pm_reports', 'class' => 'mcp', 'title' => 'MCP_PM_REPORTS_CLOSED', 'auth' => 'aclf_m_report', 'cat' => 'MCP_REPORTS'), 'pm_report_details' => array('base' => 'pm_reports', 'class' => 'mcp', 'title' => 'MCP_PM_REPORT_DETAILS', 'auth' => 'aclf_m_report', 'cat' => 'MCP_REPORTS'));
            _add_modules($modules_to_install);
            // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema)
            $sql = 'SELECT group_id
				FROM ' . GROUPS_TABLE . "\n\t\t\t\tWHERE group_name = 'NEWLY_REGISTERED'";
            $result = $db->sql_query($sql);
            $group_id = (int) $db->sql_fetchfield('group_id');
            $db->sql_freeresult($result);
            if (!$group_id) {
                $sql = 'INSERT INTO ' . GROUPS_TABLE . " (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5)";
                _sql($sql, $errored, $error_ary);
                $group_id = $db->sql_nextid();
            }
            // Insert new user role... at the end of the chain
            $sql = 'SELECT role_id
				FROM ' . ACL_ROLES_TABLE . "\n\t\t\t\tWHERE role_name = 'ROLE_USER_NEW_MEMBER'\n\t\t\t\t\tAND role_type = 'u_'";
            $result = $db->sql_query($sql);
            $u_role = (int) $db->sql_fetchfield('role_id');
            $db->sql_freeresult($result);
            if (!$u_role) {
                $sql = 'SELECT MAX(role_order) as max_order_id
					FROM ' . ACL_ROLES_TABLE . "\n\t\t\t\t\tWHERE role_type = 'u_'";
                $result = $db->sql_query($sql);
                $next_order_id = (int) $db->sql_fetchfield('max_order_id');
                $db->sql_freeresult($result);
                $next_order_id++;
                $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', {$next_order_id})";
                _sql($sql, $errored, $error_ary);
                $u_role = $db->sql_nextid();
                if (!$errored) {
                    // Now add the correct data to the roles...
                    // The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups
                    $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT {$u_role}, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')";
                    _sql($sql, $errored, $error_ary);
                    // Add user role to group
                    $sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ({$group_id}, 0, 0, {$u_role}, 0)";
                    _sql($sql, $errored, $error_ary);
                }
            }
            // Insert new forum role
            $sql = 'SELECT role_id
				FROM ' . ACL_ROLES_TABLE . "\n\t\t\t\tWHERE role_name = 'ROLE_FORUM_NEW_MEMBER'\n\t\t\t\t\tAND role_type = 'f_'";
            $result = $db->sql_query($sql);
            $f_role = (int) $db->sql_fetchfield('role_id');
            $db->sql_freeresult($result);
            if (!$f_role) {
                $sql = 'SELECT MAX(role_order) as max_order_id
					FROM ' . ACL_ROLES_TABLE . "\n\t\t\t\t\tWHERE role_type = 'f_'";
                $result = $db->sql_query($sql);
                $next_order_id = (int) $db->sql_fetchfield('max_order_id');
                $db->sql_freeresult($result);
                $next_order_id++;
                $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES  ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', {$next_order_id})";
                _sql($sql, $errored, $error_ary);
                $f_role = $db->sql_nextid();
                if (!$errored) {
                    $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT {$f_role}, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')";
                    _sql($sql, $errored, $error_ary);
                }
            }
            // Set every members user_new column to 0 (old users) only if there is no one yet (this makes sure we do not execute this more than once)
            $sql = 'SELECT 1
				FROM ' . USERS_TABLE . '
				WHERE user_new = 0';
            $result = $db->sql_query_limit($sql, 1);
            $row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if (!$row) {
                $sql = 'UPDATE ' . USERS_TABLE . ' SET user_new = 0';
                _sql($sql, $errored, $error_ary);
            }
            // Newly registered users limit
            if (!isset($config['new_member_post_limit'])) {
                set_config('new_member_post_limit', !empty($config['enable_queue_trigger']) ? $config['queue_trigger_posts'] : 0);
            }
            if (!isset($config['new_member_group_default'])) {
                set_config('new_member_group_default', 0);
            }
            // To mimick the old "feature" we will assign the forum role to every forum, regardless of the setting (this makes sure there are no "this does not work!!!! YUO!!!" posts...
            // Check if the role is already assigned...
            $sql = 'SELECT forum_id
				FROM ' . ACL_GROUPS_TABLE . '
				WHERE group_id = ' . $group_id . '
					AND auth_role_id = ' . $f_role;
            $result = $db->sql_query($sql);
            $is_options = (int) $db->sql_fetchfield('forum_id');
            $db->sql_freeresult($result);
            // Not assigned at all... :/
            if (!$is_options) {
                // Get postable forums
                $sql = 'SELECT forum_id
					FROM ' . FORUMS_TABLE . '
					WHERE forum_type != ' . FORUM_LINK;
                $result = $db->sql_query($sql);
                while ($row = $db->sql_fetchrow($result)) {
                    _sql('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (' . $group_id . ', ' . (int) $row['forum_id'] . ', 0, ' . $f_role . ', 0)', $errored, $error_ary);
                }
                $db->sql_freeresult($result);
            }
            // Clear permissions...
            include_once $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
            $auth_admin = new auth_admin();
            $auth_admin->acl_clear_prefetch();
            if (!isset($config['allow_avatar'])) {
                if ($config['allow_avatar_upload'] || $config['allow_avatar_local'] || $config['allow_avatar_remote']) {
                    set_config('allow_avatar', '1');
                } else {
                    set_config('allow_avatar', '0');
                }
            }
            if (!isset($config['allow_avatar_remote_upload'])) {
                if ($config['allow_avatar_remote'] && $config['allow_avatar_upload']) {
                    set_config('allow_avatar_remote_upload', '1');
                } else {
                    set_config('allow_avatar_remote_upload', '0');
                }
            }
            // Minimum number of characters
            if (!isset($config['min_post_chars'])) {
                set_config('min_post_chars', '1');
            }
            if (!isset($config['allow_quick_reply'])) {
                set_config('allow_quick_reply', '1');
            }
            // Set every members user_options column to enable
            // bbcode, smilies and URLs for signatures by default
            $sql = 'SELECT user_options
				FROM ' . USERS_TABLE . '
				WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')';
            $result = $db->sql_query_limit($sql, 1);
            $user_option = (int) $db->sql_fetchfield('user_options');
            $db->sql_freeresult($result);
            // Check if we already updated the database by checking bit 15 which we used to store the sig_bbcode option
            if (!($user_option & 1 << 15)) {
                // 229376 is the added value to enable all three signature options
                $sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376';
                _sql($sql, $errored, $error_ary);
            }
            if (!isset($config['delete_time'])) {
                set_config('delete_time', $config['edit_time']);
            }
            $no_updates = false;
            break;
            // No changes from 3.0.6-RC1 to 3.0.6-RC2
        // No changes from 3.0.6-RC1 to 3.0.6-RC2
        case '3.0.6-RC1':
            break;
            // Changes from 3.0.6-RC2 to 3.0.6-RC3
        // Changes from 3.0.6-RC2 to 3.0.6-RC3
        case '3.0.6-RC2':
            // Update the Custom Profile Fields based on previous settings to the new format
            $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . '
				SET field_show_on_vt = 1
				WHERE field_hide = 0
					AND (field_required = 1 OR field_show_on_reg = 1 OR field_show_profile = 1)';
            _sql($sql, $errored, $error_ary);
            $no_updates = false;
            break;
            // No changes from 3.0.6-RC3 to 3.0.6-RC4
        // No changes from 3.0.6-RC3 to 3.0.6-RC4
        case '3.0.6-RC3':
            break;
            // No changes from 3.0.6-RC4 to 3.0.6
        // No changes from 3.0.6-RC4 to 3.0.6
        case '3.0.6-RC4':
            break;
            // Changes from 3.0.6 to 3.0.7-RC1
        // Changes from 3.0.6 to 3.0.7-RC1
        case '3.0.6':
            // ATOM Feeds
            set_config('feed_overall', '1');
            set_config('feed_http_auth', '0');
            set_config('feed_limit_post', (string) (isset($config['feed_limit']) ? (int) $config['feed_limit'] : 15));
            set_config('feed_limit_topic', (string) (isset($config['feed_overall_topics_limit']) ? (int) $config['feed_overall_topics_limit'] : 10));
            set_config('feed_topics_new', !empty($config['feed_overall_topics']) ? '1' : '0');
            set_config('feed_topics_active', !empty($config['feed_overall_topics']) ? '1' : '0');
            // Delete all text-templates from the template_data
            $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . '
				WHERE template_filename ' . $db->sql_like_expression($db->any_char . '.txt');
            _sql($sql, $errored, $error_ary);
            $no_updates = false;
            break;
            // Changes from 3.0.7-RC1 to 3.0.7-RC2
        // Changes from 3.0.7-RC1 to 3.0.7-RC2
        case '3.0.7-RC1':
            $sql = 'SELECT user_id, user_email, user_email_hash
				FROM ' . USERS_TABLE . '
				WHERE user_type <> ' . USER_IGNORE . "\n\t\t\t\t\tAND user_email <> ''";
            $result = $db->sql_query($sql);
            $i = 0;
            while ($row = $db->sql_fetchrow($result)) {
                // Snapshot of the phpbb_email_hash() function
                // We cannot call it directly because the auto updater updates the DB first. :/
                $user_email_hash = sprintf('%u', crc32(strtolower($row['user_email']))) . strlen($row['user_email']);
                if ($user_email_hash != $row['user_email_hash']) {
                    $sql_ary = array('user_email_hash' => $user_email_hash);
                    $sql = 'UPDATE ' . USERS_TABLE . '
						SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
						WHERE user_id = ' . (int) $row['user_id'];
                    _sql($sql, $errored, $error_ary, $i % 100 == 0);
                    ++$i;
                }
            }
            $db->sql_freeresult($result);
            $no_updates = false;
            break;
            // No changes from 3.0.7-RC2 to 3.0.7
        // No changes from 3.0.7-RC2 to 3.0.7
        case '3.0.7-RC2':
            break;
            // No changes from 3.0.7 to 3.0.7-PL1
        // No changes from 3.0.7 to 3.0.7-PL1
        case '3.0.7':
            break;
            // Changes from 3.0.7-PL1 to 3.0.8-RC1
        // Changes from 3.0.7-PL1 to 3.0.8-RC1
        case '3.0.7-PL1':
            // Update file extension group names to use language strings.
            $sql = 'SELECT lang_dir
				FROM ' . LANG_TABLE;
            $result = $db->sql_query($sql);
            $extension_groups_updated = array();
            while ($lang_dir = $db->sql_fetchfield('lang_dir')) {
                $lang_dir = basename($lang_dir);
                // The language strings we need are either in language/.../acp/attachments.php
                // in the update package if we're updating to 3.0.8-RC1 or later,
                // or they are in language/.../install.php when we're updating from 3.0.7-PL1 or earlier.
                // On an already updated board, they can also already be in language/.../acp/attachments.php
                // in the board root.
                $lang_files = array("{$phpbb_root_path}install/update/new/language/{$lang_dir}/acp/attachments.{$phpEx}", "{$phpbb_root_path}language/{$lang_dir}/install.{$phpEx}", "{$phpbb_root_path}language/{$lang_dir}/acp/attachments.{$phpEx}");
                foreach ($lang_files as $lang_file) {
                    if (!file_exists($lang_file)) {
                        continue;
                    }
                    $lang = array();
                    include $lang_file;
                    foreach ($lang as $lang_key => $lang_val) {
                        if (isset($extension_groups_updated[$lang_key]) || strpos($lang_key, 'EXT_GROUP_') !== 0) {
                            continue;
                        }
                        $sql_ary = array('group_name' => substr($lang_key, 10));
                        $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . '
							SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\tWHERE group_name = '" . $db->sql_escape($lang_val) . "'";
                        _sql($sql, $errored, $error_ary);
                        $extension_groups_updated[$lang_key] = true;
                    }
                }
            }
            $db->sql_freeresult($result);
            // Install modules
            $modules_to_install = array('post' => array('base' => 'board', 'class' => 'acp', 'title' => 'ACP_POST_SETTINGS', 'auth' => 'acl_a_board', 'cat' => 'ACP_MESSAGES', 'after' => array('message', 'ACP_MESSAGE_SETTINGS')));
            _add_modules($modules_to_install);
            // update
            $sql = 'UPDATE ' . MODULES_TABLE . '
				SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)\'
				WHERE module_class = \'ucp\'
					AND module_basename = \'profile\'
					AND module_mode = \'avatar\'';
            _sql($sql, $errored, $error_ary);
            // add Bing Bot
            $bot_name = 'Bing [Bot]';
            $bot_name_clean = utf8_clean_string($bot_name);
            $sql = 'SELECT user_id
				FROM ' . USERS_TABLE . "\n\t\t\t\tWHERE username_clean = '" . $db->sql_escape($bot_name_clean) . "'";
            $result = $db->sql_query($sql);
            $bing_already_added = (bool) $db->sql_fetchfield('user_id');
            $db->sql_freeresult($result);
            if (!$bing_already_added) {
                $bot_agent = 'bingbot/';
                $bot_ip = '';
                $sql = 'SELECT group_id, group_colour
					FROM ' . GROUPS_TABLE . "\n\t\t\t\t\tWHERE group_name = 'BOTS'";
                $result = $db->sql_query($sql);
                $group_row = $db->sql_fetchrow($result);
                $db->sql_freeresult($result);
                if (!$group_row) {
                    // default fallback, should never get here
                    $group_row['group_id'] = 6;
                    $group_row['group_colour'] = '9E8DA7';
                }
                if (!function_exists('user_add')) {
                    include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
                }
                $user_row = array('user_type' => USER_IGNORE, 'group_id' => $group_row['group_id'], 'username' => $bot_name, 'user_regdate' => time(), 'user_password' => '', 'user_colour' => $group_row['group_colour'], 'user_email' => '', 'user_lang' => $config['default_lang'], 'user_style' => $config['default_style'], 'user_timezone' => 0, 'user_dateformat' => $config['default_dateformat'], 'user_allow_massemail' => 0);
                $user_id = user_add($user_row);
                $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array('bot_active' => 1, 'bot_name' => (string) $bot_name, 'user_id' => (int) $user_id, 'bot_agent' => (string) $bot_agent, 'bot_ip' => (string) $bot_ip));
                _sql($sql, $errored, $error_ary);
            }
            // end Bing Bot addition
            // Delete shadow topics pointing to not existing topics
            $batch_size = 500;
            // Set of affected forums we have to resync
            $sync_forum_ids = array();
            do {
                $sql_array = array('SELECT' => 't1.topic_id, t1.forum_id', 'FROM' => array(TOPICS_TABLE => 't1'), 'LEFT_JOIN' => array(array('FROM' => array(TOPICS_TABLE => 't2'), 'ON' => 't1.topic_moved_id = t2.topic_id')), 'WHERE' => 't1.topic_moved_id <> 0
								AND t2.topic_id IS NULL');
                $sql = $db->sql_build_query('SELECT', $sql_array);
                $result = $db->sql_query_limit($sql, $batch_size);
                $topic_ids = array();
                while ($row = $db->sql_fetchrow($result)) {
                    $topic_ids[] = (int) $row['topic_id'];
                    $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id'];
                }
                $db->sql_freeresult($result);
                if (!empty($topic_ids)) {
                    $sql = 'DELETE FROM ' . TOPICS_TABLE . '
						WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
                    $db->sql_query($sql);
                }
            } while (sizeof($topic_ids) == $batch_size);
            // Sync the forums we have deleted shadow topics from.
            sync('forum', 'forum_id', $sync_forum_ids, true, true);
            // Unread posts search load switch
            set_config('load_unreads_search', '1');
            // Reduce queue interval to 60 seconds, email package size to 20
            if ($config['queue_interval'] == 600) {
                set_config('queue_interval', '60');
            }
            if ($config['email_package_size'] == 50) {
                set_config('email_package_size', '20');
            }
            $no_updates = false;
            break;
            // No changes from 3.0.8-RC1 to 3.0.8
        // No changes from 3.0.8-RC1 to 3.0.8
        case '3.0.8-RC1':
            break;
            // Changes from 3.0.8 to 3.0.9-RC1
        // Changes from 3.0.8 to 3.0.9-RC1
        case '3.0.8':
            set_config('ip_login_limit_max', '50');
            set_config('ip_login_limit_time', '21600');
            set_config('ip_login_limit_use_forwarded', '0');
            // Update file extension group names to use language strings, again.
            $sql = 'SELECT group_id, group_name
				FROM ' . EXTENSION_GROUPS_TABLE . '
				WHERE group_name ' . $db->sql_like_expression('EXT_GROUP_' . $db->any_char);
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $sql_ary = array('group_name' => substr($row['group_name'], 10));
                $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . '
					SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
					WHERE group_id = ' . $row['group_id'];
                _sql($sql, $errored, $error_ary);
            }
            $db->sql_freeresult($result);
            /*
            * Due to a bug, vanilla phpbb could not create captcha tables
            * in 3.0.8 on firebird. It was possible for board administrators
            * to adjust the code to work. If code was manually adjusted by
            * board administrators, index names would not be the same as
            * what 3.0.9 and newer expect. This code fragment drops captcha
            * tables, destroying all entered Q&A captcha configuration, such
            * that when Q&A is configured next the respective tables will be
            * created with correct index names.
            *
            * If you wish to preserve your Q&A captcha configuration, you can
            * manually rename indexes to the currently expected name:
            * 	phpbb_captcha_questions_lang_iso	=> phpbb_captcha_questions_lang
            * 	phpbb_captcha_answers_question_id	=> phpbb_captcha_answers_qid
            *
            * Again, this needs to be done only if a board was manually modified
            * to fix broken captcha code.
            *
            if ($db_tools->sql_layer == 'firebird')
            {
            	$changes = array(
            		'drop_tables'	=> array(
            			$table_prefix . 'captcha_questions',
            			$table_prefix . 'captcha_answers',
            			$table_prefix . 'qa_confirm',
            		),
            	);
            	$statements = $db_tools->perform_schema_changes($changes);
            
            	foreach ($statements as $sql)
            	{
            		_sql($sql, $errored, $error_ary);
            	}
            }
            */
            $no_updates = false;
            break;
            // No changes from 3.0.9-RC1 to 3.0.9-RC2
        // No changes from 3.0.9-RC1 to 3.0.9-RC2
        case '3.0.9-RC1':
            break;
            // No changes from 3.0.9-RC2 to 3.0.9-RC3
        // No changes from 3.0.9-RC2 to 3.0.9-RC3
        case '3.0.9-RC2':
            break;
            // No changes from 3.0.9-RC3 to 3.0.9-RC4
        // No changes from 3.0.9-RC3 to 3.0.9-RC4
        case '3.0.9-RC3':
            break;
            // No changes from 3.0.9-RC4 to 3.0.9
        // No changes from 3.0.9-RC4 to 3.0.9
        case '3.0.9-RC4':
            break;
            // Changes from 3.0.9 to 3.0.10-RC1
        // Changes from 3.0.9 to 3.0.10-RC1
        case '3.0.9':
            if (!isset($config['email_max_chunk_size'])) {
                set_config('email_max_chunk_size', '50');
            }
            $no_updates = false;
            break;
            // No changes from 3.0.10-RC1 to 3.0.10-RC2
        // No changes from 3.0.10-RC1 to 3.0.10-RC2
        case '3.0.10-RC1':
            break;
            // No changes from 3.0.10-RC2 to 3.0.10-RC3
        // No changes from 3.0.10-RC2 to 3.0.10-RC3
        case '3.0.10-RC2':
            break;
            // No changes from 3.0.10-RC3 to 3.0.10
        // No changes from 3.0.10-RC3 to 3.0.10
        case '3.0.10-RC3':
            break;
            // Changes from 3.0.10 to 3.0.11-RC1
        // Changes from 3.0.10 to 3.0.11-RC1
        case '3.0.10':
            // Updates users having current style a deactivated one
            $sql = 'SELECT style_id
				FROM ' . STYLES_TABLE . '
				WHERE style_active = 0';
            $result = $db->sql_query($sql);
            $deactivated_style_ids = array();
            while ($style_id = $db->sql_fetchfield('style_id', false, $result)) {
                $deactivated_style_ids[] = (int) $style_id;
            }
            $db->sql_freeresult($result);
            if (!empty($deactivated_style_ids)) {
                $sql = 'UPDATE ' . USERS_TABLE . '
					SET user_style = ' . (int) $config['default_style'] . '
					WHERE ' . $db->sql_in_set('user_style', $deactivated_style_ids);
                _sql($sql, $errored, $error_ary);
            }
            // Delete orphan private messages
            $batch_size = 500;
            $sql_array = array('SELECT' => 'p.msg_id', 'FROM' => array(PRIVMSGS_TABLE => 'p'), 'LEFT_JOIN' => array(array('FROM' => array(PRIVMSGS_TO_TABLE => 't'), 'ON' => 'p.msg_id = t.msg_id')), 'WHERE' => 't.user_id IS NULL');
            $sql = $db->sql_build_query('SELECT', $sql_array);
            do {
                $result = $db->sql_query_limit($sql, $batch_size);
                $delete_pms = array();
                while ($row = $db->sql_fetchrow($result)) {
                    $delete_pms[] = (int) $row['msg_id'];
                }
                $db->sql_freeresult($result);
                if (!empty($delete_pms)) {
                    $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
						WHERE ' . $db->sql_in_set('msg_id', $delete_pms);
                    _sql($sql, $errored, $error_ary);
                }
            } while (sizeof($delete_pms) == $batch_size);
            $no_updates = false;
            break;
            // No changes from 3.0.11-RC1 to 3.0.11-RC2
        // No changes from 3.0.11-RC1 to 3.0.11-RC2
        case '3.0.11-RC1':
            break;
            // No changes from 3.0.11-RC2 to 3.0.11
        // No changes from 3.0.11-RC2 to 3.0.11
        case '3.0.11-RC2':
            break;
            // Changes from 3.0.11 to 3.0.12-RC1
        // Changes from 3.0.11 to 3.0.12-RC1
        case '3.0.11':
            $sql = 'UPDATE ' . MODULES_TABLE . '
				SET module_auth = \'acl_u_sig\'
				WHERE module_class = \'ucp\'
					AND module_basename = \'profile\'
					AND module_mode = \'signature\'';
            _sql($sql, $errored, $error_ary);
            // Update bots
            if (!function_exists('user_delete')) {
                include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
            }
            $bots_updates = array('NG-Search [Bot]' => false, 'Nutch/CVS [Bot]' => false, 'OmniExplorer [Bot]' => false, 'Seekport [Bot]' => false, 'Synoo [Bot]' => false, 'WiseNut [Bot]' => false, 'Baidu [Spider]' => 'Baiduspider', 'Exabot [Bot]' => 'Exabot', 'Voyager [Bot]' => 'voyager/', 'W3C [Validator]' => 'W3C_Validator');
            foreach ($bots_updates as $bot_name => $bot_agent) {
                $sql = 'SELECT user_id
					FROM ' . USERS_TABLE . '
					WHERE user_type = ' . USER_IGNORE . "\n\t\t\t\t\t\tAND username_clean = '" . $db->sql_escape(utf8_clean_string($bot_name)) . "'";
                $result = $db->sql_query($sql);
                $bot_user_id = (int) $db->sql_fetchfield('user_id');
                $db->sql_freeresult($result);
                if ($bot_user_id) {
                    if ($bot_agent === false) {
                        $sql = 'DELETE FROM ' . BOTS_TABLE . "\n\t\t\t\t\t\t\tWHERE user_id = {$bot_user_id}";
                        _sql($sql, $errored, $error_ary);
                        user_delete('remove', $bot_user_id);
                    } else {
                        $sql = 'UPDATE ' . BOTS_TABLE . "\n\t\t\t\t\t\t\tSET bot_agent = '" . $db->sql_escape($bot_agent) . "'\n\t\t\t\t\t\t\tWHERE user_id = {$bot_user_id}";
                        _sql($sql, $errored, $error_ary);
                    }
                }
            }
            // Disable receiving pms for bots
            $sql = 'SELECT user_id
				FROM ' . BOTS_TABLE;
            $result = $db->sql_query($sql);
            $bot_user_ids = array();
            while ($row = $db->sql_fetchrow($result)) {
                $bot_user_ids[] = (int) $row['user_id'];
            }
            $db->sql_freeresult($result);
            if (!empty($bot_user_ids)) {
                $sql = 'UPDATE ' . USERS_TABLE . '
					SET user_allow_pm = 0
					WHERE ' . $db->sql_in_set('user_id', $bot_user_ids);
                _sql($sql, $errored, $error_ary);
            }
            /**
             * Update BBCodes that currently use the LOCAL_URL tag
             *
             * To fix http://tracker.phpbb.com/browse/PHPBB3-8319 we changed
             * the second_pass_replace value, so that needs updating for existing ones
             */
            $sql = 'SELECT *
				FROM ' . BBCODES_TABLE . '
				WHERE bbcode_match ' . $db->sql_like_expression($db->any_char . 'LOCAL_URL' . $db->any_char);
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                if (!class_exists('acp_bbcodes')) {
                    phpbb_require_updated('includes/acp/acp_bbcodes.' . $phpEx);
                }
                $bbcode_match = $row['bbcode_match'];
                $bbcode_tpl = $row['bbcode_tpl'];
                $acp_bbcodes = new acp_bbcodes();
                $sql_ary = $acp_bbcodes->build_regexp($bbcode_match, $bbcode_tpl);
                $sql = 'UPDATE ' . BBCODES_TABLE . '
					SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
					WHERE bbcode_id = ' . (int) $row['bbcode_id'];
                $db->sql_query($sql);
            }
            $db->sql_freeresult($result);
            $no_updates = false;
            break;
            // No changes from 3.0.12-RC1 to 3.0.12-RC2
        // No changes from 3.0.12-RC1 to 3.0.12-RC2
        case '3.0.12-RC1':
            break;
            // No changes from 3.0.12-RC2 to 3.0.12-RC3
        // No changes from 3.0.12-RC2 to 3.0.12-RC3
        case '3.0.12-RC2':
            break;
            // No changes from 3.0.12-RC3 to 3.0.12
        // No changes from 3.0.12-RC3 to 3.0.12
        case '3.0.12-RC3':
            break;
            // No changes from 3.0.12 to 3.0.13-RC1
        // No changes from 3.0.12 to 3.0.13-RC1
        case '3.0.12':
            break;
            // No changes from 3.0.13-RC1 to 3.0.13
        // No changes from 3.0.13-RC1 to 3.0.13
        case '3.0.13-RC1':
            break;
            // No changes from 3.0.13 to 3.0.13-PL1
        // No changes from 3.0.13 to 3.0.13-PL1
        case '3.0.13':
            break;
            // No changes from 3.0.13-PL1 to 3.0.14-RC1
        // No changes from 3.0.13-PL1 to 3.0.14-RC1
        case '3.0.13-PL1':
            break;
            // No changes from 3.0.14-RC1 to 3.0.14
        // No changes from 3.0.14-RC1 to 3.0.14
        case '3.0.14-RC1':
            break;
    }
}
コード例 #4
0
/**
* Function where all data changes are executed
*/
function change_database_data(&$no_updates, $version)
{
	global $db, $map_dbms, $errored, $error_ary, $config, $phpbb_root_path, $phpEx;

	switch ($version)
	{
		case '3.0.RC2':

			$smileys = array();

			$sql = 'SELECT smiley_id, code
				FROM ' . SMILIES_TABLE;
			$result = $db->sql_query($sql);

			while ($row = $db->sql_fetchrow($result))
			{
				$smileys[$row['smiley_id']] = $row['code'];
			}
			$db->sql_freeresult($result);

			foreach ($smileys as $id => $code)
			{
				// 2.0 only entitized lt and gt; We need to do something about double quotes.
				if (strchr($code, '"') === false)
				{
					continue;
				}

				$new_code = str_replace('&amp;', '&', $code);
				$new_code = str_replace('&lt;', '<', $new_code);
				$new_code = str_replace('&gt;', '>', $new_code);
				$new_code = utf8_htmlspecialchars($new_code);

				$sql = 'UPDATE ' . SMILIES_TABLE . '
					SET code = \'' . $db->sql_escape($new_code) . '\'
					WHERE smiley_id = ' . (int) $id;
				$db->sql_query($sql);
			}

			$index_list = sql_list_index($map_dbms, ACL_ROLES_DATA_TABLE);

			if (in_array('ath_opt_id', $index_list))
			{
				sql_index_drop($map_dbms, 'ath_opt_id', ACL_ROLES_DATA_TABLE);
				sql_create_index($map_dbms, 'ath_op_id', ACL_ROLES_DATA_TABLE, array('auth_option_id'));
			}

			$no_updates = false;
		break;

		case '3.0.RC3':

			if ($map_dbms === 'postgres')
			{
				$sql = "SELECT SETVAL('" . FORUMS_TABLE . "_seq',(select case when max(forum_id)>0 then max(forum_id)+1 else 1 end from " . FORUMS_TABLE . '));';
				_sql($sql, $errored, $error_ary);
			}

			// we check for:
			// ath_opt_id
			// ath_op_id
			// ACL_ROLES_DATA_TABLE_ath_opt_id
			// we want ACL_ROLES_DATA_TABLE_ath_op_id

			$table_index_fix = array(
				ACL_ROLES_DATA_TABLE => array(
					'ath_opt_id'							=> 'ath_op_id',
					'ath_op_id'								=> 'ath_op_id',
					ACL_ROLES_DATA_TABLE . '_ath_opt_id'	=> 'ath_op_id'
				),
				STYLES_IMAGESET_DATA_TABLE => array(
					'i_id'									=> 'i_d',
					'i_d'									=> 'i_d',
					STYLES_IMAGESET_DATA_TABLE . '_i_id'	=> 'i_d'
				)
			);

			// we need to create some indicies...
			$needed_creation = array();

			foreach ($table_index_fix as $table_name => $index_info)
			{
				$index_list = sql_list_fake($map_dbms, $table_name);
				foreach ($index_info as $bad_index => $good_index)
				{
					if (in_array($bad_index, $index_list))
					{
						// mysql is actually OK, it won't get a hand in this crud
						switch ($map_dbms)
						{
							// last version, mssql had issues with index removal
							case 'mssql':
								$sql = 'DROP INDEX ' . $table_name . '.' . $bad_index;
								_sql($sql, $errored, $error_ary);
							break;

							// last version, firebird, oracle, postgresql and sqlite all got bad index names
							// we got kinda lucky, tho: they all support the same syntax
							case 'firebird':
							case 'oracle':
							case 'postgres':
							case 'sqlite':
								$sql = 'DROP INDEX ' . $bad_index;
								_sql($sql, $errored, $error_ary);
							break;
						}

						// If the good index already exist we do not need to create it again...
						if (($map_dbms == 'mysql_40' || $map_dbms == 'mysql_41') && $bad_index == $good_index)
						{
						}
						else
						{
							$needed_creation[$table_name][$good_index] = 1;
						}
					}
				}
			}

			$new_index_defs = array('ath_op_id' => array('auth_option_id'), 'i_d' => array('imageset_id'));

			foreach ($needed_creation as $bad_table => $index_repair_list)
			{
				foreach ($index_repair_list as $new_index => $garbage)
				{
					sql_create_index($map_dbms, $new_index, $bad_table, $new_index_defs[$new_index]);
				}
			}

			// Make sure empty smiley codes do not exist
			$sql = 'DELETE FROM ' . SMILIES_TABLE . "
				WHERE code = ''";
			_sql($sql, $errored, $error_ary);

			set_config('allow_birthdays', '1');
			set_config('cron_lock', '0', true);

			$no_updates = false;
		break;

		case '3.0.RC4':

			$update_auto_increment = array(
				STYLES_TABLE				=> 'style_id',
				STYLES_TEMPLATE_TABLE		=> 'template_id',
				STYLES_THEME_TABLE			=> 'theme_id',
				STYLES_IMAGESET_TABLE		=> 'imageset_id'
			);

			$sql = 'SELECT *
				FROM ' . STYLES_TABLE . '
				WHERE style_id = 0';
			$result = _sql($sql, $errored, $error_ary);
			$bad_style_row = $db->sql_fetchrow($result);
			$db->sql_freeresult($result);

			if ($bad_style_row)
			{
				$sql = 'SELECT MAX(style_id) as max_id
					FROM ' . STYLES_TABLE;
				$result = _sql($sql, $errored, $error_ary);
				$row = $db->sql_fetchrow($result);
				$db->sql_freeresult($result);

				$proper_id = $row['max_id'] + 1;

				_sql('UPDATE ' . STYLES_TABLE . " SET style_id = $proper_id WHERE style_id = 0", $errored, $error_ary);
				_sql('UPDATE ' . FORUMS_TABLE . " SET forum_style = $proper_id WHERE forum_style = 0", $errored, $error_ary);
				_sql('UPDATE ' . USERS_TABLE . " SET user_style = $proper_id WHERE user_style = 0", $errored, $error_ary);

				$sql = 'SELECT config_value
					FROM ' . CONFIG_TABLE . "
					WHERE config_name = 'default_style'";
				$result = _sql($sql, $errored, $error_ary);
				$style_config = $db->sql_fetchrow($result);
				$db->sql_freeresult($result);

				if ($style_config['config_value'] === '0')
				{
					set_config('default_style', (string) $proper_id);
				}
			}

			$sql = 'SELECT *
				FROM ' . STYLES_TEMPLATE_TABLE . '
				WHERE template_id = 0';
			$result = _sql($sql, $errored, $error_ary);
			$bad_style_row = $db->sql_fetchrow($result);
			$db->sql_freeresult($result);

			if ($bad_style_row)
			{
				$sql = 'SELECT MAX(template_id) as max_id
					FROM ' . STYLES_TEMPLATE_TABLE;
				$result = _sql($sql, $errored, $error_ary);
				$row = $db->sql_fetchrow($result);
				$db->sql_freeresult($result);

				$proper_id = $row['max_id'] + 1;

				_sql('UPDATE ' . STYLES_TABLE . " SET template_id = $proper_id WHERE template_id = 0", $errored, $error_ary);
			}

			$sql = 'SELECT *
				FROM ' . STYLES_THEME_TABLE . '
				WHERE theme_id = 0';
			$result = _sql($sql, $errored, $error_ary);
			$bad_style_row = $db->sql_fetchrow($result);
			$db->sql_freeresult($result);

			if ($bad_style_row)
			{
				$sql = 'SELECT MAX(theme_id) as max_id
					FROM ' . STYLES_THEME_TABLE;
				$result = _sql($sql, $errored, $error_ary);
				$row = $db->sql_fetchrow($result);
				$db->sql_freeresult($result);

				$proper_id = $row['max_id'] + 1;

				_sql('UPDATE ' . STYLES_TABLE . " SET theme_id = $proper_id WHERE theme_id = 0", $errored, $error_ary);
			}

			$sql = 'SELECT *
				FROM ' . STYLES_IMAGESET_TABLE . '
				WHERE imageset_id = 0';
			$result = _sql($sql, $errored, $error_ary);
			$bad_style_row = $db->sql_fetchrow($result);
			$db->sql_freeresult($result);

			if ($bad_style_row)
			{
				$sql = 'SELECT MAX(imageset_id) as max_id
					FROM ' . STYLES_IMAGESET_TABLE;
				$result = _sql($sql, $errored, $error_ary);
				$row = $db->sql_fetchrow($result);
				$db->sql_freeresult($result);

				$proper_id = $row['max_id'] + 1;

				_sql('UPDATE ' . STYLES_TABLE . " SET imageset_id = $proper_id WHERE imageset_id = 0", $errored, $error_ary);
				_sql('UPDATE ' . STYLES_IMAGESET_DATA_TABLE . " SET imageset_id = $proper_id WHERE imageset_id = 0", $errored, $error_ary);
			}

			if ($map_dbms == 'mysql_40' || $map_dbms == 'mysql_41')
			{
				foreach ($update_auto_increment as $auto_table_name => $auto_column_name)
				{
					$sql = "SELECT MAX({$auto_column_name}) as max_id
						FROM {$auto_table_name}";
					$result = _sql($sql, $errored, $error_ary);
					$row = $db->sql_fetchrow($result);
					$db->sql_freeresult($result);

					$max_id = ((int) $row['max_id']) + 1;
					_sql("ALTER TABLE {$auto_table_name} AUTO_INCREMENT = {$max_id}", $errored, $error_ary);
				}
			}
			else if ($map_dbms == 'postgres')
			{
				foreach ($update_auto_increment as $auto_table_name => $auto_column_name)
				{
					$sql = "SELECT SETVAL('" . $auto_table_name . "_seq',(select case when max({$auto_column_name})>0 then max({$auto_column_name})+1 else 1 end from " . $auto_table_name . '));';
					_sql($sql, $errored, $error_ary);
				}

				$sql = 'DROP SEQUENCE ' . STYLES_TEMPLATE_DATA_TABLE . '_seq';
				_sql($sql, $errored, $error_ary);
			}
			else if ($map_dbms == 'firebird')
			{
				$sql = 'DROP TRIGGER t_' . STYLES_TEMPLATE_DATA_TABLE;
				_sql($sql, $errored, $error_ary);

				$sql = 'DROP GENERATOR ' . STYLES_TEMPLATE_DATA_TABLE . '_gen';
				_sql($sql, $errored, $error_ary);
			}
			else if ($map_dbms == 'oracle')
			{
				$sql = 'DROP TRIGGER t_' . STYLES_TEMPLATE_DATA_TABLE;
				_sql($sql, $errored, $error_ary);

				$sql = 'DROP SEQUENCE ' . STYLES_TEMPLATE_DATA_TABLE . '_seq';
				_sql($sql, $errored, $error_ary);
			}
			else if ($map_dbms == 'mssql')
			{
				// we use transactions because we need to have a working DB at the end of all of this
				$db->sql_transaction('begin');

				$sql = 'SELECT *
					FROM ' . STYLES_TEMPLATE_DATA_TABLE;
				$result = _sql($sql, $errored, $error_ary);
				$old_style_rows = array();
				while ($row = $db->sql_fetchrow($result))
				{
					$old_style_rows[] = $row;
				}
				$db->sql_freeresult($result);

				// death to the table, it is evil!
				$sql = 'DROP TABLE ' . STYLES_TEMPLATE_DATA_TABLE;
				_sql($sql, $errored, $error_ary);

				// the table of awesomeness, praise be to it (or something)
				$sql = 'CREATE TABLE [' . STYLES_TEMPLATE_DATA_TABLE . "] (
					[template_id] [int] DEFAULT (0) NOT NULL ,
					[template_filename] [varchar] (100) DEFAULT ('') NOT NULL ,
					[template_included] [varchar] (8000) DEFAULT ('') NOT NULL ,
					[template_mtime] [int] DEFAULT (0) NOT NULL ,
					[template_data] [text] DEFAULT ('') NOT NULL
				) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]";
				_sql($sql, $errored, $error_ary);

				// index? index
				$sql = 'CREATE  INDEX [tid] ON [' . STYLES_TEMPLATE_DATA_TABLE . ']([template_id]) ON [PRIMARY]';
				_sql($sql, $errored, $error_ary);

				// yet another index
				$sql = 'CREATE  INDEX [tfn] ON [' . STYLES_TEMPLATE_DATA_TABLE . ']([template_filename]) ON [PRIMARY]';
				_sql($sql, $errored, $error_ary);

				foreach ($old_style_rows as $return_row)
				{
					_sql('INSERT INTO ' . STYLES_TEMPLATE_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $return_row), $errored, $error_ary);
				}

				$db->sql_transaction('commit');
			}

			// Setting this here again because new installations may not have it...
			set_config('cron_lock', '0', true);
			set_config('ldap_port', '');
			set_config('ldap_user_filter', '');

			$no_updates = false;
		break;

		case '3.0.RC5':

			// In case the user is having the bot mediapartner google "as is", adjust it.
			$sql = 'UPDATE ' . BOTS_TABLE . "
				SET bot_agent = '" . $db->sql_escape('Mediapartners-Google') . "'
				WHERE bot_agent = '" . $db->sql_escape('Mediapartners-Google/') . "'";
			_sql($sql, $errored, $error_ary);

			set_config('form_token_lifetime', '7200');
			set_config('form_token_mintime', '0');
			set_config('min_time_reg', '5');
			set_config('min_time_terms', '2');
			set_config('form_token_sid_guests', '1');

			$db->sql_transaction('begin');

			$sql = 'SELECT forum_id, forum_password
					FROM ' . FORUMS_TABLE;
			$result = _sql($sql, $errored, $error_ary);

			while ($row = $db->sql_fetchrow($result))
			{
				if (!empty($row['forum_password']))
				{
					_sql('UPDATE ' . FORUMS_TABLE . " SET forum_password = '******'forum_password']) . "' WHERE forum_id = {$row['forum_id']}", $errored, $error_ary);
				}
			}
			$db->sql_freeresult($result);

			$db->sql_transaction('commit');

			$no_updates = false;
		break;

		case '3.0.0':

			$sql = 'UPDATE ' . TOPICS_TABLE . "
				SET topic_last_view_time = topic_last_post_time
				WHERE topic_last_view_time = 0";
			_sql($sql, $errored, $error_ary);

			// Update smiley sizes
			$smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif');

			foreach ($smileys as $smiley)
			{
				if (file_exists($phpbb_root_path . 'images/smilies/' . $smiley))
				{
					list($width, $height) = getimagesize($phpbb_root_path . 'images/smilies/' . $smiley);

					$sql = 'UPDATE ' . SMILIES_TABLE . '
						SET smiley_width = ' . $width . ', smiley_height = ' . $height . "
						WHERE smiley_url = '" . $db->sql_escape($smiley) . "'";

					_sql($sql, $errored, $error_ary);
				}
			}

			$no_updates = false;
		break;

		// No changes from 3.0.1-RC1 to 3.0.1
		case '3.0.1-RC1':
		break;

		// changes from 3.0.1 to 3.0.2-RC1
		case '3.0.1':

			set_config('referer_validation', '1');
			set_config('check_attachment_content', '1');
			set_config('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title');

			$no_updates = false;
		break;

		// No changes from 3.0.2-RC1 to 3.0.2-RC2
		case '3.0.2-RC1':
		break;

		// No changes from 3.0.2-RC2 to 3.0.2
		case '3.0.2-RC2':
		break;

		// Changes from 3.0.2 to 3.0.3-RC1
		case '3.0.2':
			set_config('enable_queue_trigger', '0');
			set_config('queue_trigger_posts', '3');

			set_config('pm_max_recipients', '0');

			// Set maximum number of recipients for the registered users, bots, guests group
			$sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5
				WHERE ' . $db->sql_in_set('group_name', array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA', 'BOTS'));
			_sql($sql, $errored, $error_ary);

			// Not prefilling yet
			set_config('dbms_version', '');

			// Add new permission u_masspm_group and duplicate settings from u_masspm
			include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
			$auth_admin = new auth_admin();

			// Only add the new permission if it does not already exist
			if (empty($auth_admin->acl_options['id']['u_masspm_group']))
			{
				$auth_admin->acl_add_option(array('global' => array('u_masspm_group')));

				// Now the tricky part, filling the permission
				$old_id = $auth_admin->acl_options['id']['u_masspm'];
				$new_id = $auth_admin->acl_options['id']['u_masspm_group'];

				$tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);

				foreach ($tables as $table)
				{
					$sql = 'SELECT *
						FROM ' . $table . '
						WHERE auth_option_id = ' . $old_id;
					$result = _sql($sql, $errored, $error_ary);

					$sql_ary = array();
					while ($row = $db->sql_fetchrow($result))
					{
						$row['auth_option_id'] = $new_id;
						$sql_ary[] = $row;
					}
					$db->sql_freeresult($result);

					if (sizeof($sql_ary))
					{
						$db->sql_multi_insert($table, $sql_ary);
					}
				}

				// Remove any old permission entries
				$auth_admin->acl_clear_prefetch();
			}

			/**
			* Do not resync post counts here. An admin may do this later from the ACP
			$start = 0;
			$step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000;

			$sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = 0';
			_sql($sql, $errored, $error_ary);

			do
			{
				$sql = 'SELECT COUNT(post_id) AS num_posts, poster_id
					FROM ' . POSTS_TABLE . '
					WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . '
						AND post_postcount = 1 AND post_approved = 1
					GROUP BY poster_id';
				$result = _sql($sql, $errored, $error_ary);

				if ($row = $db->sql_fetchrow($result))
				{
					do
					{
						$sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}";
						_sql($sql, $errored, $error_ary);
					}
					while ($row = $db->sql_fetchrow($result));

					$start += $step;
				}
				else
				{
					$start = 0;
				}
				$db->sql_freeresult($result);
			}
			while ($start);
			*/

			$sql = 'UPDATE ' . MODULES_TABLE . '
				SET module_auth = \'acl_a_email && cfg_email_enable\'
				WHERE module_class = \'acp\'
					AND module_basename = \'email\'';
			_sql($sql, $errored, $error_ary);

			$no_updates = false;
		break;

		// Changes from 3.0.3-RC1 to 3.0.3
		case '3.0.3-RC1':
			$sql = 'UPDATE ' . LOG_TABLE . "
				SET log_operation = 'LOG_DELETE_TOPIC'
				WHERE log_operation = 'LOG_TOPIC_DELETED'";
			_sql($sql, $errored, $error_ary);

			$no_updates = false;
		break;

		// Changes from 3.0.3 to 3.0.4-RC1
		case '3.0.3':
			// Update the Custom Profile Fields based on previous settings to the new format
			$sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide
					FROM ' . PROFILE_FIELDS_TABLE;
			$result = _sql($sql, $errored, $error_ary);

			while ($row = $db->sql_fetchrow($result))
			{
				$sql_ary = array(
					'field_required'	=> 0,
					'field_show_on_reg'	=> 0,
					'field_hide'		=> 0,
					'field_show_profile'=> 0,
				);

				if ($row['field_required'])
				{
					$sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1;
				}
				else if ($row['field_show_on_reg'])
				{
					$sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1;
				}
				else if ($row['field_hide'])
				{
					// Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module
					$sql_ary['field_hide'] = 1;
				}
				else
				{
					// equivelant to "none", which is the "Display in user control panel" option
					$sql_ary['field_show_profile'] = 1;
				}

				_sql('UPDATE ' . PROFILE_FIELDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary);
			}

			$no_updates = false;
		break;

		// Changes from 3.0.4-RC1 to 3.0.4
		case '3.0.4-RC1':
		break;
	}
}
コード例 #5
0
ファイル: permission.php プロジェクト: phpbb/phpbb-core
    /**
     * Permission Add
     *
     * Add a permission (auth) option
     *
     * @param string $auth_option The name of the permission (auth) option
     * @param bool $global True for checking a global permission setting,
     * 	False for a local permission setting
     * @param int|false $copy_from If set, contains the id of the permission from which to copy the new one.
     * @return null
     */
    public function add($auth_option, $global = true, $copy_from = false)
    {
        if ($this->exists($auth_option, $global)) {
            return;
        }
        // We've added permissions, so set to true to notify the user.
        $this->permissions_added = true;
        if (!class_exists('auth_admin')) {
            include $this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext;
        }
        $auth_admin = new \auth_admin();
        // We have to add a check to see if the !$global (if global, local, and if local, global) permission already exists.  If it does, acl_add_option currently has a bug which would break the ACL system, so we are having a work-around here.
        if ($this->exists($auth_option, !$global)) {
            $sql_ary = array('is_global' => 1, 'is_local' => 1);
            $sql = 'UPDATE ' . ACL_OPTIONS_TABLE . '
				SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\tWHERE auth_option = '" . $this->db->sql_escape($auth_option) . "'";
            $this->db->sql_query($sql);
        } else {
            if ($global) {
                $auth_admin->acl_add_option(array('global' => array($auth_option)));
            } else {
                $auth_admin->acl_add_option(array('local' => array($auth_option)));
            }
        }
        // The permission has been added, now we can copy it if needed
        if ($copy_from && isset($auth_admin->acl_options['id'][$copy_from])) {
            $old_id = $auth_admin->acl_options['id'][$copy_from];
            $new_id = $auth_admin->acl_options['id'][$auth_option];
            $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);
            foreach ($tables as $table) {
                $sql = 'SELECT *
					FROM ' . $table . '
					WHERE auth_option_id = ' . $old_id;
                $result = $this->db->sql_query($sql);
                $sql_ary = array();
                while ($row = $this->db->sql_fetchrow($result)) {
                    $row['auth_option_id'] = $new_id;
                    $sql_ary[] = $row;
                }
                $this->db->sql_freeresult($result);
                if (!empty($sql_ary)) {
                    $this->db->sql_multi_insert($table, $sql_ary);
                }
            }
            $auth_admin->acl_clear_prefetch();
        }
    }
コード例 #6
0
ファイル: phpbb.php プロジェクト: snitchashor/wp-united
    /**
     * transmits new settings from the WP settings panel to phpBB
     */
    public function synchronise_settings($dataToStore)
    {
        global $wpUnited, $cache, $user, $auth, $config, $db, $phpbb_root_path, $phpEx;
        if (empty($dataToStore)) {
            echo "No settings to process";
            return false;
        }
        $fStateChanged = $this->foreground();
        $adminLog = array();
        $adminLog[] = __('Receiving settings from WP-United...', 'wp-united');
        /**
         * MySQL will not allow duplicate column names, so we can suppress errors (we still check anyway)
         */
        $db->sql_return_on_error(true);
        if (!array_key_exists('user_wpuint_id', $user->data)) {
            $sql = 'ALTER TABLE ' . USERS_TABLE . ' 
				  ADD user_wpuint_id VARCHAR(10) NULL DEFAULT NULL';
            @$db->sql_query($sql);
            $adminLog[] = __('Modified USERS Table (Integration ID)', 'wp-united');
        }
        if (!array_key_exists('user_wpublog_id', $user->data)) {
            $sql = 'ALTER TABLE ' . USERS_TABLE . ' 
				ADD user_wpublog_id VARCHAR(10) NULL DEFAULT NULL';
            @$db->sql_query($sql);
            $adminLog[] = __('Modified USERS Table (Blog ID)', 'wp-united');
        }
        //Add an x-posting column to topics
        $sql = 'SELECT * FROM ' . TOPICS_TABLE;
        $result = $db->sql_query_limit($sql, 1);
        $row = (array) $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        if (!array_key_exists('topic_wpu_xpost', $row)) {
            $sql = 'ALTER TABLE ' . TOPICS_TABLE . ' 
				ADD topic_wpu_xpost VARCHAR(10) NULL DEFAULT NULL';
            @$db->sql_query($sql);
            // Add new columns
            $sql = 'ALTER TABLE ' . POSTS_TABLE . ' 
				ADD post_wpu_xpost_parent VARCHAR(10) NULL DEFAULT NULL, 
				ADD post_wpu_xpost_meta1 VARCHAR(255) NULL DEFAULT NULL, 
				ADD post_wpu_xpost_meta2 VARCHAR(255) NULL DEFAULT NULL';
            @$db->sql_query($sql);
            $adminLog[] = __('Modified TOPICS and POSTS Tables (Cross-Posting ability)', 'wp-united');
        }
        $db->sql_return_on_error(false);
        $adminLog[] = __('Adding WP-United Permissions', 'wp-united');
        // Setup $auth_admin class so we can add permission options
        include_once $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
        $auth_admin = new auth_admin();
        // Add permissions
        $auth_admin->acl_add_option(array('local' => array('f_wpu_xpost', 'f_wpu_xpost_comment'), 'global' => array('u_wpu_subscriber', 'u_wpu_contributor', 'u_wpu_author', 'm_wpu_editor', 'a_wpu_administrator')));
        $adminLog[] = __('Storing the new WP-United settings', 'wp-united');
        // this stores the passed-in settings object, which is a bit brittle
        // TODO: ask $wpUnited->settings to store/reload itself, without making it public
        $this->clear_settings();
        $sql = array();
        $sql[] = array('config_name' => 'wpu_location', 'config_value' => $wpUnited->get_plugin_path());
        $dataIn = base64_encode(gzcompress(serialize($dataToStore)));
        $currPtr = 1;
        $chunkStart = 0;
        while ($chunkStart < strlen($dataIn)) {
            $sql[] = array('config_name' => "wpu_settings_{$currPtr}", 'config_value' => substr($dataIn, $chunkStart, 255));
            $chunkStart = $chunkStart + 255;
            $currPtr++;
        }
        $db->sql_multi_insert(CONFIG_TABLE, $sql);
        $cache->destroy('config');
        if ($wpUnited->get_setting('integrateLogin') && $wpUnited->get_setting('avatarsync')) {
            if (!$config['allow_avatar'] || !$config['allow_avatar_remote']) {
                $adminLog[] = __('Updating avatar settings', 'wp-united');
                $sql = 'UPDATE ' . CONFIG_TABLE . ' 
					SET config_value = 1
					WHERE ' . $db->sql_in_set('config_name', array('allow_avatar', 'allow_avatar_remote'));
                $db->sql_query($sql);
                $cache->destroy('config');
            }
        }
        // clear out the WP-United cache on settings change
        $adminLog[] = __('Purging the WP-United cache', 'wp-united');
        $wpuCache = WPU_Cache::getInstance();
        $wpuCache->purge();
        $adminLog[] = __('Completed successfully', 'wp-united');
        // Save the admin log in a nice dropdown in phpBB admin log.
        // Requires a bit of template hacking using JS since we don't want to have to do a mod edit for new script
        // generate unique ID for details ID
        $randSeed = rand(0, 99999);
        $bodyContent = '<div style="display: none; border: 1px solid #cccccc; background-color: #ccccff; padding: 3px;" id="wpulogdets' . $randSeed . '">';
        $bodyContent .= implode("<br />\n\n", $adminLog) . '</div>';
        $ln = "*}<span class='wpulog'><script type=\"text/javascript\">// <![CDATA[\n\t\tvar d = document;\n\t\tfunction wputgl{$randSeed}() {\n\t\t\tvar l = d.getElementById('wpulogdets{$randSeed}');\n\t\t\tvar p = d.getElementById('wpulogexp{$randSeed}'); var n = p.firstChild.nodeValue;\n\t\t\tl.style.display = (n == '-') ? 'none' : 'block';\n\t\t\tp.firstChild.nodeValue = (n == '-') ? '+' : '-';\n\t\t\treturn false;\n\t\t}\n\t\tif(typeof wpual == 'undefined') {\n\t\t\tvar wpual = window.onload;\n\t\t\twindow.onload = function() {\n\t\t\t\tif (typeof wpual == 'function') wpual();\n\t\t\t\ttry {\n\t\t\t\t\tvar hs = d.getElementsByClassName('wpulog');\n\t\t\t\t\tfor(h in hs) {var p = hs[h].parentNode; p.firstChild.nodeValue = ''; p.lastChild.nodeValue = '';}\n\t\t\t\t} catch(e) {}\t  \n\t\t\t};\n\t\t}\n\t\t// ]]>\n\t\t</script>";
        $ln .= '<strong><a href="#" onclick="return wputgl' . $randSeed . '();" title="click to see details">' . __('Changed WP-United Settings (click for details)', 'wp-united') . '<span id="wpulogexp' . $randSeed . '">+</span></a></strong>' . $bodyContent . '</span>{*';
        add_log('admin', $ln);
        $cache->purge();
        $this->restore_state($fStateChanged);
        return true;
    }
コード例 #7
0
ファイル: index.php プロジェクト: paul999/ajax-shoutbox
$delimiter = $available_dbms[$dbms]['DELIM'];
$sql_query = preg_replace('#phpbb_#i', $table_prefix, $table);
$remove_remarks($sql_query);
$sql_query = split_sql_file($sql_query, $delimiter);
foreach ($sql_query as $sql) {
    $db->sql_query($sql);
}
unset($sql_query);
foreach ($config_items as $name => $value) {
    set_config($name, $value);
}
foreach ($config_items_dyn as $name => $value) {
    set_config($name, $value, true);
}
$acl = new auth_admin();
$acl->acl_add_option($permissions);
$error = array();
install_module('acp', 'acp_shoutbox', $error, 'ACP_CAT_DOT_MODS');
add_log('admin', 'LOG_AS_INSTALLED', VERSION);
trigger_error('MOD_INSTALLED');
function generate_sql(&$lineg, $dbms)
{
    global $phpbb_root_path, $phpEx;
    $dbms_type_map = array('mysql_41' => array('INT:' => 'int(%d)', 'BINT' => 'bigint(20)', 'UINT' => 'mediumint(8) UNSIGNED', 'UINT:' => 'int(%d) UNSIGNED', 'TINT:' => 'tinyint(%d)', 'USINT' => 'smallint(4) UNSIGNED', 'BOOL' => 'tinyint(1) UNSIGNED', 'VCHAR' => 'varchar(255)', 'VCHAR:' => 'varchar(%d)', 'CHAR:' => 'char(%d)', 'XSTEXT' => 'text', 'XSTEXT_UNI' => 'varchar(100)', 'STEXT' => 'text', 'STEXT_UNI' => 'varchar(255)', 'TEXT' => 'text', 'TEXT_UNI' => 'text', 'MTEXT' => 'mediumtext', 'MTEXT_UNI' => 'mediumtext', 'TIMESTAMP' => 'int(11) UNSIGNED', 'DECIMAL' => 'decimal(5,2)', 'DECIMAL:' => 'decimal(%d,2)', 'PDECIMAL' => 'decimal(6,3)', 'PDECIMAL:' => 'decimal(%d,3)', 'VCHAR_UNI' => 'varchar(255)', 'VCHAR_UNI:' => 'varchar(%d)', 'VCHAR_CI' => 'varchar(255)', 'VARBINARY' => 'varbinary(255)'), 'mysql_40' => array('INT:' => 'int(%d)', 'BINT' => 'bigint(20)', 'UINT' => 'mediumint(8) UNSIGNED', 'UINT:' => 'int(%d) UNSIGNED', 'TINT:' => 'tinyint(%d)', 'USINT' => 'smallint(4) UNSIGNED', 'BOOL' => 'tinyint(1) UNSIGNED', 'VCHAR' => 'varbinary(255)', 'VCHAR:' => 'varbinary(%d)', 'CHAR:' => 'binary(%d)', 'XSTEXT' => 'blob', 'XSTEXT_UNI' => 'blob', 'STEXT' => 'blob', 'STEXT_UNI' => 'blob', 'TEXT' => 'blob', 'TEXT_UNI' => 'blob', 'MTEXT' => 'mediumblob', 'MTEXT_UNI' => 'mediumblob', 'TIMESTAMP' => 'int(11) UNSIGNED', 'DECIMAL' => 'decimal(5,2)', 'DECIMAL:' => 'decimal(%d,2)', 'PDECIMAL' => 'decimal(6,3)', 'PDECIMAL:' => 'decimal(%d,3)', 'VCHAR_UNI' => 'blob', 'VCHAR_UNI:' => array('varbinary(%d)', 'limit' => array('mult', 3, 255, 'blob')), 'VCHAR_CI' => 'blob', 'VARBINARY' => 'varbinary(255)'), 'firebird' => array('INT:' => 'INTEGER', 'BINT' => 'DOUBLE PRECISION', 'UINT' => 'INTEGER', 'UINT:' => 'INTEGER', 'TINT:' => 'INTEGER', 'USINT' => 'INTEGER', 'BOOL' => 'INTEGER', 'VCHAR' => 'VARCHAR(255) CHARACTER SET NONE', 'VCHAR:' => 'VARCHAR(%d) CHARACTER SET NONE', 'CHAR:' => 'CHAR(%d) CHARACTER SET NONE', 'XSTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', 'STEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', 'TEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', 'MTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', 'XSTEXT_UNI' => 'VARCHAR(100) CHARACTER SET UTF8', 'STEXT_UNI' => 'VARCHAR(255) CHARACTER SET UTF8', 'TEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8', 'MTEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8', 'TIMESTAMP' => 'INTEGER', 'DECIMAL' => 'DOUBLE PRECISION', 'DECIMAL:' => 'DOUBLE PRECISION', 'PDECIMAL' => 'DOUBLE PRECISION', 'PDECIMAL:' => 'DOUBLE PRECISION', 'VCHAR_UNI' => 'VARCHAR(255) CHARACTER SET UTF8', 'VCHAR_UNI:' => 'VARCHAR(%d) CHARACTER SET UTF8', 'VCHAR_CI' => 'VARCHAR(255) CHARACTER SET UTF8', 'VARBINARY' => 'CHAR(255) CHARACTER SET NONE'), 'mssql' => array('INT:' => '[int]', 'BINT' => '[float]', 'UINT' => '[int]', 'UINT:' => '[int]', 'TINT:' => '[int]', 'USINT' => '[int]', 'BOOL' => '[int]', 'VCHAR' => '[varchar] (255)', 'VCHAR:' => '[varchar] (%d)', 'CHAR:' => '[char] (%d)', 'XSTEXT' => '[varchar] (1000)', 'STEXT' => '[varchar] (3000)', 'TEXT' => '[varchar] (8000)', 'MTEXT' => '[text]', 'XSTEXT_UNI' => '[varchar] (100)', 'STEXT_UNI' => '[varchar] (255)', 'TEXT_UNI' => '[varchar] (4000)', 'MTEXT_UNI' => '[text]', 'TIMESTAMP' => '[int]', 'DECIMAL' => '[float]', 'DECIMAL:' => '[float]', 'PDECIMAL' => '[float]', 'PDECIMAL:' => '[float]', 'VCHAR_UNI' => '[varchar] (255)', 'VCHAR_UNI:' => '[varchar] (%d)', 'VCHAR_CI' => '[varchar] (255)', 'VARBINARY' => '[varchar] (255)'), 'oracle' => array('INT:' => 'number(%d)', 'BINT' => 'number(20)', 'UINT' => 'number(8)', 'UINT:' => 'number(%d)', 'TINT:' => 'number(%d)', 'USINT' => 'number(4)', 'BOOL' => 'number(1)', 'VCHAR' => 'varchar2(255)', 'VCHAR:' => 'varchar2(%d)', 'CHAR:' => 'char(%d)', 'XSTEXT' => 'varchar2(1000)', 'STEXT' => 'varchar2(3000)', 'TEXT' => 'clob', 'MTEXT' => 'clob', 'XSTEXT_UNI' => 'varchar2(300)', 'STEXT_UNI' => 'varchar2(765)', 'TEXT_UNI' => 'clob', 'MTEXT_UNI' => 'clob', 'TIMESTAMP' => 'number(11)', 'DECIMAL' => 'number(5, 2)', 'DECIMAL:' => 'number(%d, 2)', 'PDECIMAL' => 'number(6, 3)', 'PDECIMAL:' => 'number(%d, 3)', 'VCHAR_UNI' => 'varchar2(765)', 'VCHAR_UNI:' => array('varchar2(%d)', 'limit' => array('mult', 3, 765, 'clob')), 'VCHAR_CI' => 'varchar2(255)', 'VARBINARY' => 'raw(255)'), 'sqlite' => array('INT:' => 'int(%d)', 'BINT' => 'bigint(20)', 'UINT' => 'INTEGER UNSIGNED', 'UINT:' => 'INTEGER UNSIGNED', 'TINT:' => 'tinyint(%d)', 'USINT' => 'INTEGER UNSIGNED', 'BOOL' => 'INTEGER UNSIGNED', 'VCHAR' => 'varchar(255)', 'VCHAR:' => 'varchar(%d)', 'CHAR:' => 'char(%d)', 'XSTEXT' => 'text(65535)', 'STEXT' => 'text(65535)', 'TEXT' => 'text(65535)', 'MTEXT' => 'mediumtext(16777215)', 'XSTEXT_UNI' => 'text(65535)', 'STEXT_UNI' => 'text(65535)', 'TEXT_UNI' => 'text(65535)', 'MTEXT_UNI' => 'mediumtext(16777215)', 'TIMESTAMP' => 'INTEGER UNSIGNED', 'DECIMAL' => 'decimal(5,2)', 'DECIMAL:' => 'decimal(%d,2)', 'PDECIMAL' => 'decimal(6,3)', 'PDECIMAL:' => 'decimal(%d,3)', 'VCHAR_UNI' => 'varchar(255)', 'VCHAR_UNI:' => 'varchar(%d)', 'VCHAR_CI' => 'varchar(255)', 'VARBINARY' => 'blob'), 'postgres' => array('INT:' => 'INT4', 'BINT' => 'INT8', 'UINT' => 'INT4', 'UINT:' => 'INT4', 'USINT' => 'INT2', 'BOOL' => 'INT2', 'TINT:' => 'INT2', 'VCHAR' => 'varchar(255)', 'VCHAR:' => 'varchar(%d)', 'CHAR:' => 'char(%d)', 'XSTEXT' => 'varchar(1000)', 'STEXT' => 'varchar(3000)', 'TEXT' => 'varchar(8000)', 'MTEXT' => 'TEXT', 'XSTEXT_UNI' => 'varchar(100)', 'STEXT_UNI' => 'varchar(255)', 'TEXT_UNI' => 'varchar(4000)', 'MTEXT_UNI' => 'TEXT', 'TIMESTAMP' => 'INT4', 'DECIMAL' => 'decimal(5,2)', 'DECIMAL:' => 'decimal(%d,2)', 'PDECIMAL' => 'decimal(6,3)', 'PDECIMAL:' => 'decimal(%d,3)', 'VCHAR_UNI' => 'varchar(255)', 'VCHAR_UNI:' => 'varchar(%d)', 'VCHAR_CI' => 'varchar_ci', 'VARBINARY' => 'bytea'));
    // A list of types being unsigned for better reference in some db's
    $unsigned_types = array('UINT', 'UINT:', 'USINT', 'BOOL', 'TIMESTAMP');
    $supported_dbms = array('firebird', 'mssql', 'mysql_40', 'mysql_41', 'oracle', 'postgres', 'sqlite');
    $schema_data = get_schema();
    if ($dbms == 'mysqli' || $dbms == 'mysql4') {
        $dbms = 'mysql_41';
    } else {
コード例 #8
0
/**
 * simplification of auth_admin::acl_add()
 *
 * @param array $local_perms
 * @param array $global_perms
 */
function add_permissions($local_perms = array(), $global_perms = array())
{
    static $auth_admin = false;
    if (!$auth_admin) {
        // if it's not set, include auth_admin and create an object
        if (!class_exists('auth_admin')) {
            global $phpbb_root_path, $phpEx;
            include $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
        }
        $auth_admin = new auth_admin();
    }
    // now let's add 'em
    $auth_admin->acl_add_option(array('local' => !empty($local_perms) && is_array($local_perms) ? $local_perms : array(), 'global' => !empty($global_perms) && is_array($global_perms) ? $global_perms : array()));
}
コード例 #9
0
 /**
  * Create required phpBB Garage
  */
 function add_permissions($mode, $sub)
 {
     global $phpbb_root_path, $phpEx, $lang, $template, $data;
     //Setup $auth_admin class so we can add permission options
     include $phpbb_root_path . '/includes/acp/auth.' . $phpEx;
     $auth_admin = new auth_admin();
     //Lets Add The Required New Permissions
     $phpbbgarage_permissions = array('local' => array(), 'global' => array('u_garage_browse', 'u_garage_search', 'u_garage_add_vehicle', 'u_garage_delete_vehicle', 'u_garage_add_modification', 'u_garage_delete_modification', 'u_garage_add_quartermile', 'u_garage_delete_quartermile', 'u_garage_add_lap', 'u_garage_delete_lap', 'u_garage_add_track', 'u_garage_delete_track', 'u_garage_add_dynorun', 'u_garage_delete_dynorun', 'u_garage_add_insurance', 'u_garage_delete_insurance', 'u_garage_add_service', 'u_garage_delete_service', 'u_garage_add_blog', 'u_garage_delete_blog', 'u_garage_add_business', 'u_garage_add_make_model', 'u_garage_add_product', 'u_garage_rate', 'u_garage_comment', 'u_garage_upload_image', 'u_garage_remote_image', 'u_garage_delete_image', 'u_garage_deny', 'm_garage_edit', 'm_garage_delete', 'm_garage_rating', 'm_garage_approve_vehicle', 'm_garage_approve_make', 'm_garage_approve_model', 'm_garage_approve_business', 'm_garage_approve_quartermile', 'm_garage_approve_dynorun', 'm_garage_approve_guestbook', 'm_garage_approve_lap', 'm_garage_approve_track', 'm_garage_approve_product', 'a_garage_update', 'a_garage_setting', 'a_garage_business', 'a_garage_category', 'a_garage_field', 'a_garage_model', 'a_garage_product', 'a_garage_quota', 'a_garage_tool', 'a_garage_track'));
     $auth_admin->acl_add_option($phpbbgarage_permissions);
 }
コード例 #10
0
ファイル: upgrade.php プロジェクト: snitchashor/wp-united
function wpu_do_upgrade($action)
{
    global $phpbbForum, $wpUnited, $debug, $db, $wpuDebug, $phpbb_root_path, $phpEx;
    switch ($action) {
        /**
         *	UPGRADING <0.9.2.0 TO 0.9.2.0
         *	-----------------------------
         * in this version, we move the cross-posting column from POSTS_TABLE to TOPICS_TABLE
         */
        case 'from <0.9.2.0':
            $wpuDebug->add("Upgrading WP-United {$action}");
            $fStateChanged = $phpbbForum->foreground();
            $db->sql_return_on_error(true);
            $sql = 'ALTER TABLE ' . TOPICS_TABLE . ' 
				ADD topic_wpu_xpost VARCHAR(10) NULL DEFAULT NULL';
            @$db->sql_query($sql);
            //Now copy across data from posts column to topics column
            $sql = 'SELECT post_wpu_xpost, topic_id FROM ' . POSTS_TABLE . ' 
					WHERE post_wpu_xpost > 0';
            if ($result = $db->sql_query($sql)) {
                while ($row = $db->sql_fetchrow($result)) {
                    $sql = 'UPDATE ' . TOPICS_TABLE . ' 
						SET topic_wpu_xpost = ' . (int) $row['post_wpu_xpost'] . '
						WHERE topic_id = ' . (int) $row['topic_id'];
                    @$db->sql_query($sql);
                }
            }
            $db->sql_freeresult($result);
            // Now delete the posts column
            $sql = 'ALTER TABLE ' . POSTS_TABLE . ' DROP COLUMN post_wpu_xpost';
            @$db->sql_query($sql);
            $db->sql_return_on_error(false);
            $phpbbForum->restore_state($fStateChanged);
            // no break!
        // no break!
        case 'from 0.9.2.0-r0':
            $wpuDebug->add("Upgrading WP-United {$action}");
            $fStateChanged = $phpbbForum->foreground();
            $db->sql_return_on_error(true);
            // Add new x-posting columns
            $sql = 'ALTER TABLE ' . POSTS_TABLE . ' 
				ADD post_wpu_xpost_parent VARCHAR(10) NULL DEFAULT NULL, 
				ADD post_wpu_xpost_meta1 VARCHAR(255) NULL DEFAULT NULL, 
				ADD post_wpu_xpost_meta2 VARCHAR(255) NULL DEFAULT NULL';
            @$db->sql_query($sql);
            $db->sql_return_on_error(false);
            $phpbbForum->restore_state($fStateChanged);
            // no break!
        // no break!
        case 'from 0.9.2.0-r1':
            $wpuDebug->add("Upgrading WP-United {$action}");
            $fStateChanged = $phpbbForum->foreground();
            // Setup $auth_admin class so we can add permission options
            include_once $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
            $auth_admin = new auth_admin();
            // Add permissions
            $auth_admin->acl_add_option(array('local' => array('f_wpu_xpost', 'f_wpu_xpost_comment'), 'global' => array('u_wpu_subscriber', 'u_wpu_contributor', 'u_wpu_author', 'm_wpu_editor', 'a_wpu_administrator')));
            $phpbbForum->restore_state($fStateChanged);
        default:
            break;
    }
}
コード例 #11
0
	/**
	* Add permissions groups
	*/
	function add_permissions($mode, $sub)
	{
		global $phpbb_root_path, $phpEx, $db, $errored, $error_ary;

		// Reset permissions
		$sql = 'UPDATE ' . USERS_TABLE . "
			SET user_permissions = '',
				user_perm_from = 0";
		$db->sql_query($sql);

		// Add new permissions u_karma_can, u_karma_view, f_karma_can and f_karma_view
		// and duplicate settings from u_viewprofile
		include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
		$auth_admin = new auth_admin();

		// Add u_karma_can permission, only if it doesn not already exist
		if (!isset($auth_admin->acl_options['id']['u_karma_can']))
		{
			$auth_admin->acl_add_option(array('global' => array('u_karma_can')));

			// Now the tricky part, filling the permission
			$old_id = $auth_admin->acl_options['id']['u_viewprofile'];
			$new_id = $auth_admin->acl_options['id']['u_karma_can'];

			$tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);

			foreach ($tables as $table)
			{
				$sql = 'SELECT *
					FROM ' . $table . '
					WHERE auth_option_id = ' . $old_id;
				$result = $db->sql_query($sql);

				$sql_ary = array();
				while ($row = $db->sql_fetchrow($result))
				{
					$row['auth_option_id'] = $new_id;
					$sql_ary[] = $row;
				}
				$db->sql_freeresult($result);

				if (sizeof($sql_ary))
				{
					$db->sql_multi_insert($table, $sql_ary);
				}
			}

			// Remove any old permission entries
			$auth_admin->acl_clear_prefetch();
		}

		// Add u_karma_view permission, only if it doesn not already exist
		if (!isset($auth_admin->acl_options['id']['u_karma_view']))
		{
			$auth_admin->acl_add_option(array('global' => array('u_karma_view')));

			// Now the tricky part, filling the permission
			$old_id = $auth_admin->acl_options['id']['u_viewprofile'];
			$new_id = $auth_admin->acl_options['id']['u_karma_view'];

			$tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);

			foreach ($tables as $table)
			{
				$sql = 'SELECT *
					FROM ' . $table . '
					WHERE auth_option_id = ' . $old_id;
				$result = $db->sql_query($sql);

				$sql_ary = array();
				while ($row = $db->sql_fetchrow($result))
				{
					$row['auth_option_id'] = $new_id;
					$sql_ary[] = $row;
				}
				$db->sql_freeresult($result);

				if (sizeof($sql_ary))
				{
					$db->sql_multi_insert($table, $sql_ary);
				}
			}

			// Remove any old permission entries
			$auth_admin->acl_clear_prefetch();
		}

		// Add f_karma_can permission, only if it doesn not already exist
		if (!isset($auth_admin->acl_options['id']['f_karma_can']))
		{
			$auth_admin->acl_add_option(array('local' => array('f_karma_can')));

			// Now the tricky part, filling the permission
			$old_id = $auth_admin->acl_options['id']['f_reply'];
			$new_id = $auth_admin->acl_options['id']['f_karma_can'];

			$tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);

			foreach ($tables as $table)
			{
				$sql = 'SELECT *
					FROM ' . $table . '
					WHERE auth_option_id = ' . $old_id;
				$result = $db->sql_query($sql);

				$sql_ary = array();
				while ($row = $db->sql_fetchrow($result))
				{
					$row['auth_option_id'] = $new_id;
					$sql_ary[] = $row;
				}
				$db->sql_freeresult($result);

				if (sizeof($sql_ary))
				{
					$db->sql_multi_insert($table, $sql_ary);
				}
			}

			// Remove any old permission entries
			$auth_admin->acl_clear_prefetch();
		}

		// Add f_karma_view permission, only if it doesn not already exist
		if (!isset($auth_admin->acl_options['id']['f_karma_view']))
		{
			$auth_admin->acl_add_option(array('local' => array('f_karma_view')));

			// Now the tricky part, filling the permission
			$old_id = $auth_admin->acl_options['id']['f_read'];
			$new_id = $auth_admin->acl_options['id']['f_karma_view'];

			$tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);

			foreach ($tables as $table)
			{
				$sql = 'SELECT *
					FROM ' . $table . '
					WHERE auth_option_id = ' . $old_id;
				$result = $db->sql_query($sql);

				$sql_ary = array();
				while ($row = $db->sql_fetchrow($result))
				{
					$row['auth_option_id'] = $new_id;
					$sql_ary[] = $row;
				}
				$db->sql_freeresult($result);

				if (sizeof($sql_ary))
				{
					$db->sql_multi_insert($table, $sql_ary);
				}
			}

			// Remove any old permission entries
			$auth_admin->acl_clear_prefetch();
		}
	}
コード例 #12
0
<?php

include 'sso.php';
$auth_options = ["u_mission_list", "u_mission_admin", "u_member_page", "u_member_admin", "u_front_page_admin"];
$global = true;
if (!class_exists('auth_admin')) {
    global $phpbb_root_path, $phpEx;
    include $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
}
$auth_admin = new auth_admin();
$auth_admin->acl_add_option(array('global' => $auth_options));
コード例 #13
0
$user->setup('mods/garage');
//Get Mode Required For Page
$mode = request_var('mode', '');
$page_title = 'Manage Garage Permissions';
// Output the page
page_header($page_title);
$template->set_filenames(array('body' => 'message_body.html'));
//Setup $auth_admin class so we can add permission options
include $phpbb_root_path . '/includes/acp/auth.' . $phpEx;
$auth_admin = new auth_admin();
//Decide What Mode The User Is Doing
switch ($mode) {
    case 'add':
        //Lets Add The Required New Permissions
        $phpbbgarage_permissions = array('local' => array(), 'global' => array('u_garage_browse', 'u_garage_search', 'u_garage_add_vehicle', 'u_garage_delete_vehicle', 'u_garage_add_modification', 'u_garage_delete_modification', 'u_garage_add_quartermile', 'u_garage_delete_quartermile', 'u_garage_add_lap', 'u_garage_delete_lap', 'u_garage_add_track', 'u_garage_delete_track', 'u_garage_add_dynorun', 'u_garage_delete_dynorun', 'u_garage_add_insurance', 'u_garage_delete_insurance', 'u_garage_add_service', 'u_garage_delete_service', 'u_garage_add_blog', 'u_garage_delete_blog', 'u_garage_add_business', 'u_garage_add_make_model', 'u_garage_add_product', 'u_garage_rate', 'u_garage_comment', 'u_garage_upload_image', 'u_garage_remote_image', 'u_garage_delete_image', 'u_garage_deny', 'm_garage_edit', 'm_garage_delete', 'm_garage_rating', 'm_garage_approve_vehicle', 'm_garage_approve_make', 'm_garage_approve_model', 'm_garage_approve_business', 'm_garage_approve_quartermile', 'm_garage_approve_dynorun', 'm_garage_approve_guestbook', 'm_garage_approve_lap', 'm_garage_approve_track', 'm_garage_approve_product', 'a_garage_setting', 'a_garage_business', 'a_garage_category', 'a_garage_field', 'a_garage_model', 'a_garage_product', 'a_garage_quota', 'a_garage_tool', 'a_garage_track'));
        $auth_admin->acl_add_option($phpbbgarage_permissions);
        //Standard Admin Role
        $role = get_role_by_name('ROLE_ADMIN_STANDARD');
        if ($role) {
            acl_update_role($role['role_id'], array('a_garage_setting', 'a_garage_business', 'a_garage_category', 'a_garage_field', 'a_garage_model', 'a_garage_product', 'a_garage_quota', 'a_garage_tool', 'a_garage_track'));
        }
        //Full Admin Role
        $role = get_role_by_name('ROLE_ADMIN_FULL');
        if ($role) {
            acl_update_role($role['role_id'], array('a_garage_setting', 'a_garage_business', 'a_garage_category', 'a_garage_field', 'a_garage_model', 'a_garage_product', 'a_garage_quota', 'a_garage_tool', 'a_garage_track'));
        }
        //Queue Moderator Role
        $role = get_role_by_name('ROLE_MOD_QUEUE');
        if ($role) {
            acl_update_role($role['role_id'], array('m_garage_approve_vehicle', 'm_garage_approve_make', 'm_garage_approve_model', 'm_garage_approve_business', 'm_garage_approve_quartermile', 'm_garage_approve_dynorun', 'm_garage_approve_guestbook', 'm_garage_approve_lap', 'm_garage_approve_track', 'm_garage_approve_product'));
        }
コード例 #14
0
ファイル: umil.php プロジェクト: poyntesm/phpbbgarage
    /**
     * Permission Add
     *
     * Add a permission (auth) option
     *
     * @param string $auth_option The name of the permission (auth) option
     * @param bool $global True for checking a global permission setting, False for a local permission setting
     *
     * @return result
     */
    function permission_add($auth_option, $global = true)
    {
        // Multicall
        if (is_array($auth_option)) {
            foreach ($auth_option as $params) {
                call_user_func_array(array($this, 'permission_add'), $params);
            }
            return;
        }
        $this->umil_start('PERMISSION_ADD', $auth_option);
        if ($this->permission_exists($auth_option, $global)) {
            return $this->umil_end('PERMISSION_ALREADY_EXISTS', $auth_option);
        }
        // We've added permissions, so set to true to notify the user.
        $this->permissions_added = true;
        if (!class_exists('auth_admin')) {
            global $phpbb_root_path, $phpEx;
            include $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
        }
        $auth_admin = new auth_admin();
        // We have to add a check to see if the !$global (if global, local, and if local, global) permission already exists.  If it does, acl_add_option currently has a bug which would break the ACL system, so we are having a work-around here.
        if ($this->permission_exists($auth_option, !$global)) {
            $sql_ary = array('is_global' => 1, 'is_local' => 1);
            $sql = 'UPDATE ' . ACL_OPTIONS_TABLE . '
				SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
				WHERE auth_option = \'' . $this->db->sql_escape($auth_option) . "'";
            $this->db->sql_query($sql);
        } else {
            if ($global) {
                $auth_admin->acl_add_option(array('global' => array($auth_option)));
            } else {
                $auth_admin->acl_add_option(array('local' => array($auth_option)));
            }
        }
        return $this->umil_end();
    }
コード例 #15
0
ファイル: update.php プロジェクト: EXreaction/User-Blog-Mod
        case 'A6':
        case 'A7':
            $sql = 'ALTER TABLE ' . BLOGS_TABLE . ' ADD blog_real_reply_count MEDIUMINT( 8 ) NOT NULL DEFAULT \'0\'';
            $db->sql_query($sql);
        case 'A8':
            resync_blog('real_reply_count');
            resync_blog('reply_count');
            $sql_array[] = 'CREATE TABLE ' . BLOGS_SUBSCRIPTION_TABLE . ' (
				sub_user_id mediumint(8) UNSIGNED DEFAULT \'0\' NOT NULL,
				sub_type tinyint(1) UNSIGNED DEFAULT \'0\' NOT NULL,
				blog_id mediumint(8) UNSIGNED DEFAULT \'0\' NOT NULL,
				user_id mediumint(8) UNSIGNED DEFAULT \'0\' NOT NULL,
				PRIMARY KEY (sub_user_id)
			)';
            $blog_permissions = array('local' => array(), 'global' => array('m_blogreplyapprove', 'm_blogreplyedit', 'm_blogreplylockedit', 'm_blogreplydelete', 'm_blogreplyreport'));
            $auth_admin->acl_add_option($blog_permissions);
        case 'A9':
            set_config('user_blog_enable', 1, 0);
            set_config('user_blog_custom_profile_enable', 0, 0);
            set_config('user_blog_text_limit', '50', 0);
            set_config('user_blog_user_text_limit', '500', 0);
            set_config('user_blog_inform', '2', 0);
            set_config('user_blog_always_show_blog_url', 0, 0);
        case 'A10':
            $sql_array[] = 'ALTER TABLE ' . BLOGS_TABLE . ' DROP blog_rating, DROP blog_num_ratings';
        case 'A11':
            set_config('user_blog_subscription_enabled', 1, 0);
            $sql_array[] = 'ALTER TABLE ' . BLOGS_SUBSCRIPTION_TABLE . ' DROP PRIMARY KEY ,
				ADD PRIMARY KEY (sub_user_id, sub_type, blog_id, user_id)';
            $sql_array[] = 'ALTER TABLE ' . BLOGS_SUBSCRIPTION_TABLE . ' DROP INDEX sub_type';
        case 'A12':
コード例 #16
0
ファイル: database_update.php プロジェクト: kellanved/phpbb3
function change_database_data(&$no_updates, $version)
{
	global $db, $errored, $error_ary, $config, $phpbb_root_path, $phpEx;

	switch ($version)
	{
		case '3.0.0':

			$sql = 'UPDATE ' . TOPICS_TABLE . "
				SET topic_last_view_time = topic_last_post_time
				WHERE topic_last_view_time = 0";
			_sql($sql, $errored, $error_ary);

			// Update smiley sizes
			$smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif');

			foreach ($smileys as $smiley)
			{
				if (file_exists($phpbb_root_path . 'images/smilies/' . $smiley))
				{
					list($width, $height) = getimagesize($phpbb_root_path . 'images/smilies/' . $smiley);

					$sql = 'UPDATE ' . SMILIES_TABLE . '
						SET smiley_width = ' . $width . ', smiley_height = ' . $height . "
						WHERE smiley_url = '" . $db->sql_escape($smiley) . "'";

					_sql($sql, $errored, $error_ary);
				}
			}

			$no_updates = false;
		break;

		// No changes from 3.0.1-RC1 to 3.0.1
		case '3.0.1-RC1':
		break;

		// changes from 3.0.1 to 3.0.2-RC1
		case '3.0.1':

			set_config('referer_validation', '1');
			set_config('check_attachment_content', '1');
			set_config('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title');

			$no_updates = false;
		break;

		// No changes from 3.0.2-RC1 to 3.0.2-RC2
		case '3.0.2-RC1':
		break;

		// No changes from 3.0.2-RC2 to 3.0.2
		case '3.0.2-RC2':
		break;

		// Changes from 3.0.2 to 3.0.3-RC1
		case '3.0.2':
			set_config('enable_queue_trigger', '0');
			set_config('queue_trigger_posts', '3');

			set_config('pm_max_recipients', '0');

			// Set maximum number of recipients for the registered users, bots, guests group
			$sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5
				WHERE ' . $db->sql_in_set('group_name', array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA', 'BOTS'));
			_sql($sql, $errored, $error_ary);

			// Not prefilling yet
			set_config('dbms_version', '');

			// Add new permission u_masspm_group and duplicate settings from u_masspm
			include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
			$auth_admin = new auth_admin();

			// Only add the new permission if it does not already exist
			if (empty($auth_admin->acl_options['id']['u_masspm_group']))
			{
				$auth_admin->acl_add_option(array('global' => array('u_masspm_group')));

				// Now the tricky part, filling the permission
				$old_id = $auth_admin->acl_options['id']['u_masspm'];
				$new_id = $auth_admin->acl_options['id']['u_masspm_group'];

				$tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);

				foreach ($tables as $table)
				{
					$sql = 'SELECT *
						FROM ' . $table . '
						WHERE auth_option_id = ' . $old_id;
					$result = _sql($sql, $errored, $error_ary);

					$sql_ary = array();
					while ($row = $db->sql_fetchrow($result))
					{
						$row['auth_option_id'] = $new_id;
						$sql_ary[] = $row;
					}
					$db->sql_freeresult($result);

					if (sizeof($sql_ary))
					{
						$db->sql_multi_insert($table, $sql_ary);
					}
				}

				// Remove any old permission entries
				$auth_admin->acl_clear_prefetch();
			}

			/**
			* Do not resync post counts here. An admin may do this later from the ACP
			$start = 0;
			$step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000;

			$sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = 0';
			_sql($sql, $errored, $error_ary);

			do
			{
				$sql = 'SELECT COUNT(post_id) AS num_posts, poster_id
					FROM ' . POSTS_TABLE . '
					WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . '
						AND post_postcount = 1 AND post_approved = 1
					GROUP BY poster_id';
				$result = _sql($sql, $errored, $error_ary);

				if ($row = $db->sql_fetchrow($result))
				{
					do
					{
						$sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}";
						_sql($sql, $errored, $error_ary);
					}
					while ($row = $db->sql_fetchrow($result));

					$start += $step;
				}
				else
				{
					$start = 0;
				}
				$db->sql_freeresult($result);
			}
			while ($start);
			*/

			$sql = 'UPDATE ' . MODULES_TABLE . '
				SET module_auth = \'acl_a_email && cfg_email_enable\'
				WHERE module_class = \'acp\'
					AND module_basename = \'email\'';
			_sql($sql, $errored, $error_ary);

			$no_updates = false;
		break;

		// Changes from 3.0.3-RC1 to 3.0.3
		case '3.0.3-RC1':
			if ($db->sql_layer == 'oracle')
			{
				// log_operation is CLOB - but we can change this later
				$sql = 'UPDATE ' . LOG_TABLE . "
					SET log_operation = 'LOG_DELETE_TOPIC'
					WHERE log_operation LIKE 'LOG_TOPIC_DELETED'";
				_sql($sql, $errored, $error_ary);
			}
			else
			{
				$sql = 'UPDATE ' . LOG_TABLE . "
					SET log_operation = 'LOG_DELETE_TOPIC'
					WHERE log_operation = 'LOG_TOPIC_DELETED'";
				_sql($sql, $errored, $error_ary);
			}

			$no_updates = false;
		break;

		// Changes from 3.0.3 to 3.0.4-RC1
		case '3.0.3':
			// Update the Custom Profile Fields based on previous settings to the new format
			$sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide
					FROM ' . PROFILE_FIELDS_TABLE;
			$result = _sql($sql, $errored, $error_ary);

			while ($row = $db->sql_fetchrow($result))
			{
				$sql_ary = array(
					'field_required'	=> 0,
					'field_show_on_reg'	=> 0,
					'field_hide'		=> 0,
					'field_show_profile'=> 0,
				);

				if ($row['field_required'])
				{
					$sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1;
				}
				else if ($row['field_show_on_reg'])
				{
					$sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1;
				}
				else if ($row['field_hide'])
				{
					// Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module
					$sql_ary['field_hide'] = 1;
				}
				else
				{
					// equivelant to "none", which is the "Display in user control panel" option
					$sql_ary['field_show_profile'] = 1;
				}

				_sql('UPDATE ' . PROFILE_FIELDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary);
			}
			$no_updates = false;

		break;

		// Changes from 3.0.4-RC1 to 3.0.4
		case '3.0.4-RC1':
		break;

		// Changes from 3.0.4 to 3.0.5-RC1
		case '3.0.4':

			// Captcha config variables
			set_config('captcha_gd_wave', 0);
			set_config('captcha_gd_3d_noise', 1);
			set_config('captcha_gd_fonts', 1);
			set_config('confirm_refresh', 1);

			// Maximum number of keywords
			set_config('max_num_search_keywords', 10);

			// Remove static config var and put it back as dynamic variable
			$sql = 'UPDATE ' . CONFIG_TABLE . "
				SET is_dynamic = 1
				WHERE config_name = 'search_indexing_state'";
			_sql($sql, $errored, $error_ary);

			// Hash old MD5 passwords
			$sql = 'SELECT user_id, user_password
					FROM ' . USERS_TABLE . '
					WHERE user_pass_convert = 1';
			$result = _sql($sql, $errored, $error_ary);

			while ($row = $db->sql_fetchrow($result))
			{
				if (strlen($row['user_password']) == 32)
				{
					$sql_ary = array(
						'user_password'	=> phpbb_hash($row['user_password']),
					);

					_sql('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id'], $errored, $error_ary);
				}
			}
			$db->sql_freeresult($result);

			// Adjust bot entry
			$sql = 'UPDATE ' . BOTS_TABLE . "
				SET bot_agent = 'ichiro/'
				WHERE bot_agent = 'ichiro/2'";
			_sql($sql, $errored, $error_ary);


			// Before we are able to add a unique key to auth_option, we need to remove duplicate entries

			// We get duplicate entries first
			$sql = 'SELECT auth_option
				FROM ' . ACL_OPTIONS_TABLE . '
				GROUP BY auth_option
				HAVING COUNT(*) >= 2';
			$result = $db->sql_query($sql);

			$auth_options = array();
			while ($row = $db->sql_fetchrow($result))
			{
				$auth_options[] = $row['auth_option'];
			}
			$db->sql_freeresult($result);

			// Remove specific auth options
			if (!empty($auth_options))
			{
				foreach ($auth_options as $option)
				{
					// Select auth_option_ids... the largest id will be preserved
					$sql = 'SELECT auth_option_id
						FROM ' . ACL_OPTIONS_TABLE . "
						WHERE auth_option = '" . $db->sql_escape($option) . "'
						ORDER BY auth_option_id DESC";
					// sql_query_limit not possible here, due to bug in postgresql layer
					$result = $db->sql_query($sql);

					// Skip first row, this is our original auth option we want to preserve
					$row = $db->sql_fetchrow($result);

					while ($row = $db->sql_fetchrow($result))
					{
						// Ok, remove this auth option...
						_sql('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary);
						_sql('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary);
						_sql('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary);
						_sql('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary);
					}
					$db->sql_freeresult($result);
				}
			}

			// Now make auth_option UNIQUE, by dropping the old index and adding a UNIQUE one.
			$changes = array(
				'drop_keys'			=> array(
					ACL_OPTIONS_TABLE		=> array('auth_option'),
				),
			);

			global $db_tools;

			$statements = $db_tools->perform_schema_changes($changes);

			foreach ($statements as $sql)
			{
				_sql($sql, $errored, $error_ary);
			}

			$changes = array(
				'add_unique_index'	=> array(
					ACL_OPTIONS_TABLE		=> array(
						'auth_option'		=> array('auth_option'),
					),
				),
			);

			$statements = $db_tools->perform_schema_changes($changes);

			foreach ($statements as $sql)
			{
				_sql($sql, $errored, $error_ary);
			}

			$no_updates = false;

		break;

		// No changes from 3.0.5-RC1 to 3.0.5
		case '3.0.5-RC1':
		break;

		// Changes from 3.0.5 to 3.0.6-RC1
		case '3.0.5':
			// Let's see if the GD Captcha can be enabled... we simply look for what *is* enabled...
			if (!empty($config['captcha_gd']) && !isset($config['captcha_plugin']))
			{
				set_config('captcha_plugin', 'phpbb_captcha_gd');
			}
			else if (!isset($config['captcha_plugin']))
			{
				set_config('captcha_plugin', 'phpbb_captcha_nogd');
			}

			// Entries for the Feed Feature
			set_config('feed_enable', '0');
			set_config('feed_limit', '10');

			set_config('feed_overall_forums', '1');
			set_config('feed_overall_forums_limit', '15');

			set_config('feed_overall_topics', '0');
			set_config('feed_overall_topics_limit', '15');

			set_config('feed_forum', '1');
			set_config('feed_topic', '1');
			set_config('feed_item_statistics', '1');

			// Entries for smiley pagination
			set_config('smilies_per_page', '50');

			// Entry for reporting PMs
			set_config('allow_pm_report', '1');

			// Install modules
			$modules_to_install = array(
				'feed'					=> array(
					'base'		=> 'board',
					'class'		=> 'acp',
					'title'		=> 'ACP_FEED_SETTINGS',
					'auth'		=> 'acl_a_board',
					'cat'		=> 'ACP_BOARD_CONFIGURATION',
					'after'		=> array('signature', 'ACP_SIGNATURE_SETTINGS')
				),
				'warnings'				=> array(
					'base'		=> 'users',
					'class'		=> 'acp',
					'title'		=> 'ACP_USER_WARNINGS',
					'auth'		=> 'acl_a_user',
					'display'	=> 0,
					'cat'		=> 'ACP_CAT_USERS',
					'after'		=> array('feedback', 'ACP_USER_FEEDBACK')
				),
				'send_statistics'		=> array(
					'base'		=> 'send_statistics',
					'class'		=> 'acp',
					'title'		=> 'ACP_SEND_STATISTICS',
					'auth'		=> 'acl_a_server',
					'cat'		=> 'ACP_SERVER_CONFIGURATION'
				),
				'setting_forum_copy'	=> array(
					'base'		=> 'permissions',
					'class'		=> 'acp',
					'title'		=> 'ACP_FORUM_PERMISSIONS_COPY',
					'auth'		=> 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth',
					'cat'		=> 'ACP_FORUM_BASED_PERMISSIONS',
					'after'		=> array('setting_forum_local', 'ACP_FORUM_PERMISSIONS')
				),
				'pm_reports'			=> array(
					'base'		=> 'pm_reports',
					'class'		=> 'mcp',
					'title'		=> 'MCP_PM_REPORTS_OPEN',
					'auth'		=> 'aclf_m_report',
					'cat'		=> 'MCP_REPORTS'
				),
				'pm_reports_closed'		=> array(
					'base'		=> 'pm_reports',
					'class'		=> 'mcp',
					'title'		=> 'MCP_PM_REPORTS_CLOSED',
					'auth'		=> 'aclf_m_report',
					'cat'		=> 'MCP_REPORTS'
				),
				'pm_report_details'		=> array(
					'base'		=> 'pm_reports',
					'class'		=> 'mcp',
					'title'		=> 'MCP_PM_REPORT_DETAILS',
					'auth'		=> 'aclf_m_report',
					'cat'		=> 'MCP_REPORTS'
				),
			);

			_add_modules($modules_to_install);

			// Add newly_registered group... but check if it already exists (we always supported running the updater on any schema)
			$sql = 'SELECT group_id
				FROM ' . GROUPS_TABLE . "
				WHERE group_name = 'NEWLY_REGISTERED'";
			$result = $db->sql_query($sql);
			$group_id = (int) $db->sql_fetchfield('group_id');
			$db->sql_freeresult($result);

			if (!$group_id)
			{
				$sql = 'INSERT INTO ' .  GROUPS_TABLE . " (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5)";
				_sql($sql, $errored, $error_ary);

				$group_id = $db->sql_nextid();
			}

			// Insert new user role... at the end of the chain
			$sql = 'SELECT role_id
				FROM ' . ACL_ROLES_TABLE . "
				WHERE role_name = 'ROLE_USER_NEW_MEMBER'
					AND role_type = 'u_'";
			$result = $db->sql_query($sql);
			$u_role = (int) $db->sql_fetchfield('role_id');
			$db->sql_freeresult($result);

			if (!$u_role)
			{
				$sql = 'SELECT MAX(role_order) as max_order_id
					FROM ' . ACL_ROLES_TABLE . "
					WHERE role_type = 'u_'";
				$result = $db->sql_query($sql);
				$next_order_id = (int) $db->sql_fetchfield('max_order_id');
				$db->sql_freeresult($result);

				$next_order_id++;

				$sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', $next_order_id)";
				_sql($sql, $errored, $error_ary);
				$u_role = $db->sql_nextid();

				if (!$errored)
				{
					// Now add the correct data to the roles...
					// The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups
					$sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $u_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')";
					_sql($sql, $errored, $error_ary);

					// Add user role to group
					$sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ($group_id, 0, 0, $u_role, 0)";
					_sql($sql, $errored, $error_ary);
				}
			}

			// Insert new forum role
			$sql = 'SELECT role_id
				FROM ' . ACL_ROLES_TABLE . "
				WHERE role_name = 'ROLE_FORUM_NEW_MEMBER'
					AND role_type = 'f_'";
			$result = $db->sql_query($sql);
			$f_role = (int) $db->sql_fetchfield('role_id');
			$db->sql_freeresult($result);

			if (!$f_role)
			{
				$sql = 'SELECT MAX(role_order) as max_order_id
					FROM ' . ACL_ROLES_TABLE . "
					WHERE role_type = 'f_'";
				$result = $db->sql_query($sql);
				$next_order_id = (int) $db->sql_fetchfield('max_order_id');
				$db->sql_freeresult($result);

				$next_order_id++;

				$sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES  ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', $next_order_id)";
				_sql($sql, $errored, $error_ary);
				$f_role = $db->sql_nextid();

				if (!$errored)
				{
					$sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $f_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')";
					_sql($sql, $errored, $error_ary);
				}
			}

			// Set every members user_new column to 0 (old users) only if there is no one yet (this makes sure we do not execute this more than once)
			$sql = 'SELECT 1
				FROM ' . USERS_TABLE . '
				WHERE user_new = 0';
			$result = $db->sql_query_limit($sql, 1);
			$row = $db->sql_fetchrow($result);
			$db->sql_freeresult($result);

			if (!$row)
			{
				$sql = 'UPDATE ' . USERS_TABLE . ' SET user_new = 0';
				_sql($sql, $errored, $error_ary);
			}

			// Newly registered users limit
			if (!isset($config['new_member_post_limit']))
			{
				set_config('new_member_post_limit', (!empty($config['enable_queue_trigger'])) ? $config['queue_trigger_posts'] : 0);
			}

			if (!isset($config['new_member_group_default']))
			{
				set_config('new_member_group_default', 0);
			}

			// To mimick the old "feature" we will assign the forum role to every forum, regardless of the setting (this makes sure there are no "this does not work!!!! YUO!!!" posts...
			// Check if the role is already assigned...
			$sql = 'SELECT forum_id
				FROM ' . ACL_GROUPS_TABLE . '
				WHERE group_id = ' . $group_id . '
					AND auth_role_id = ' . $f_role;
			$result = $db->sql_query($sql);
			$is_options = (int) $db->sql_fetchfield('forum_id');
			$db->sql_freeresult($result);

			// Not assigned at all... :/
			if (!$is_options)
			{
				// Get postable forums
				$sql = 'SELECT forum_id
					FROM ' . FORUMS_TABLE . '
					WHERE forum_type != ' . FORUM_LINK;
				$result = $db->sql_query($sql);

				while ($row = $db->sql_fetchrow($result))
				{
					_sql('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (' . $group_id . ', ' . (int) $row['forum_id'] . ', 0, ' . $f_role . ', 0)', $errored, $error_ary);
				}
				$db->sql_freeresult($result);
			}

			// Clear permissions...
			include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
			$auth_admin = new auth_admin();
			$auth_admin->acl_clear_prefetch();

			if (!isset($config['allow_avatar']))
			{
				if ($config['allow_avatar_upload'] || $config['allow_avatar_local'] || $config['allow_avatar_remote'])
				{
					set_config('allow_avatar', '1');
				}
				else
				{
					set_config('allow_avatar', '0');
				}
			}

			if (!isset($config['allow_avatar_remote_upload']))
			{
				if ($config['allow_avatar_remote'] && $config['allow_avatar_upload'])
				{
					set_config('allow_avatar_remote_upload', '1');
				}
				else
				{
					set_config('allow_avatar_remote_upload', '0');
				}
			}

			// Minimum number of characters
			if (!isset($config['min_post_chars']))
			{
				set_config('min_post_chars', '1');
			}

			if (!isset($config['allow_quick_reply']))
			{
				set_config('allow_quick_reply', '1');
			}

			// Set every members user_options column to enable
			// bbcode, smilies and URLs for signatures by default
			$sql = 'SELECT user_options
				FROM ' . USERS_TABLE . '
				WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')';
			$result = $db->sql_query_limit($sql, 1);
			$user_option = (int) $db->sql_fetchfield('user_options');
			$db->sql_freeresult($result);

			// Check if we already updated the database by checking bit 15 which we used to store the sig_bbcode option
			if (!($user_option & 1 << 15))
			{
				// 229376 is the added value to enable all three signature options
				$sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376';
				_sql($sql, $errored, $error_ary);
			}

			if (!isset($config['delete_time']))
			{
				set_config('delete_time', $config['edit_time']);
			}

			$no_updates = false;
		break;

		// No changes from 3.0.6-RC1 to 3.0.6-RC2
		case '3.0.6-RC1':
		break;

		// Changes from 3.0.6-RC2 to 3.0.6-RC3
		case '3.0.6-RC2':

			// Update the Custom Profile Fields based on previous settings to the new format
			$sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . '
				SET field_show_on_vt = 1
				WHERE field_hide = 0
					AND (field_required = 1 OR field_show_on_reg = 1 OR field_show_profile = 1)';
			_sql($sql, $errored, $error_ary);
			$no_updates = false;

		break;

		// No changes from 3.0.6-RC3 to 3.0.6-RC4
		case '3.0.6-RC3':
		break;

		// No changes from 3.0.6-RC4 to 3.0.6
		case '3.0.6-RC4':
		break;

		// Changes from 3.0.6 to 3.0.7-RC1
		case '3.0.6':

			// ATOM Feeds
			set_config('feed_overall', '1');
			set_config('feed_http_auth', '0');
			set_config('feed_limit_post', (string) (isset($config['feed_limit']) ? (int) $config['feed_limit'] : 15));
			set_config('feed_limit_topic', (string) (isset($config['feed_overall_topics_limit']) ? (int) $config['feed_overall_topics_limit'] : 10));
			set_config('feed_topics_new', (!empty($config['feed_overall_topics']) ? '1' : '0'));
			set_config('feed_topics_active', (!empty($config['feed_overall_topics']) ? '1' : '0'));

			// Delete all text-templates from the template_data
			$sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . '
				WHERE template_filename ' . $db->sql_like_expression($db->any_char . '.txt');
			_sql($sql, $errored, $error_ary);

			$no_updates = false;
		break;

		// Changes from 3.0.7-RC1 to 3.0.7-RC2
		case '3.0.7-RC1':

			$sql = 'SELECT user_id, user_email, user_email_hash
				FROM ' . USERS_TABLE . '
				WHERE user_type <> ' . USER_IGNORE . "
					AND user_email <> ''";
			$result = $db->sql_query($sql);

			$i = 0;
			while ($row = $db->sql_fetchrow($result))
			{
				// Snapshot of the phpbb_email_hash() function
				// We cannot call it directly because the auto updater updates the DB first. :/
				$user_email_hash = sprintf('%u', crc32(strtolower($row['user_email']))) . strlen($row['user_email']);

				if ($user_email_hash != $row['user_email_hash'])
				{
					$sql_ary = array(
						'user_email_hash'	=> $user_email_hash,
					);

					$sql = 'UPDATE ' . USERS_TABLE . '
						SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
						WHERE user_id = ' . (int) $row['user_id'];
					_sql($sql, $errored, $error_ary, ($i % 100 == 0));

					++$i;
				}
			}
			$db->sql_freeresult($result);

			$no_updates = false;

		break;

		// No changes from 3.0.7-RC2 to 3.0.7
		case '3.0.7-RC2':
		break;

		// No changes from 3.0.7 to 3.0.7-PL1
		case '3.0.7':
		break;
	}
}
コード例 #17
0
{
	/**
	* Add "site" permissions (admin)
	*
	* Add "content" permissions
	*  - post content
	*  - edit (own) content
	*  - delete (own) content
	*  - post comment
	*  - edit (own) comment
	*  - delete (own) comment
	* 
	* 	Moderator permissions work like content permissions (yet to be examined - @todo)
	*/
	$auth_admin->acl_add_option(array(
	    'local'		=> array('f_c_post', 'f_c_edit', 'f_c_delete', 'f_c_com_post', 'f_c_com_edit', 'f_c_com_delete'),
	    'global'	=> array('a_site', 'a_bug_tracker')
	));

	?>

	<p><strong>Oldal és tartalom jogosultságok hozzáadva.</strong></p>
	
	<?php
}

if (version_compare($current_version, '0.0.1', '<='))
{
	set_config('site_version', $updates_to_version);
}

if (version_compare($current_version, '0.0.3', '<='))