/db_update.php
PHP | 2574 lines | 1841 code | 484 blank | 249 comment | 286 complexity | afa639545f1502687311831e57f3a52d MD5 | raw file
Possible License(s): GPL-2.0
Large files files are truncated, but you can click here to view the full file
- <?php
- /**
- * Copyright (C) 2008-2011 FluxBB
- * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
- * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
- */
- // The FluxBB version this script updates to
- define('UPDATE_TO', '1.4.5');
- define('UPDATE_TO_EVEBB', '1.1.14');
- define('UPDATE_TO_DB_REVISION', 12);
- define('UPDATE_TO_SI_REVISION', 2);
- define('UPDATE_TO_PARSER_REVISION', 2);
- define('MIN_PHP_VERSION', '4.4.0');
- define('MIN_MYSQL_VERSION', '4.1.2');
- define('MIN_PGSQL_VERSION', '7.0.0');
- define('PUN_SEARCH_MIN_WORD', 3);
- define('PUN_SEARCH_MAX_WORD', 20);
- // The MySQL connection character set that was used for FluxBB 1.2 - in 99% of cases this should be detected automatically,
- // but can be overridden using the below constant if required.
- //define('FORUM_DEFAULT_CHARSET', 'latin1');
- // The number of items to process per page view (lower this if the update script times out during UTF-8 conversion)
- define('PER_PAGE', 300);
- // Don't set to UTF-8 until after we've found out what the default character set is
- define('FORUM_NO_SET_NAMES', 1);
- // Make sure we are running at least MIN_PHP_VERSION
- if (!function_exists('version_compare') || version_compare(PHP_VERSION, MIN_PHP_VERSION, '<'))
- exit('You are running PHP version '.PHP_VERSION.'. EveBB '.UPDATE_TO.' requires at least PHP '.MIN_PHP_VERSION.' to run properly. You must upgrade your PHP installation before you can continue.');
- define('PUN_ROOT', dirname(__FILE__).'/');
- // Attempt to load the configuration file config.php
- if (file_exists(PUN_ROOT.'config.php'))
- include PUN_ROOT.'config.php';
- // If we have the 1.3-legacy constant defined, define the proper 1.4 constant so we don't get an incorrect "need to install" message
- if (defined('FORUM'))
- define('PUN', FORUM);
- // If PUN isn't defined, config.php is missing or corrupt
- if (!defined('PUN'))
- {
- header('Location: install.php');
- exit;
- }
- // Enable debug mode
- if (!defined('PUN_DEBUG'))
- define('PUN_DEBUG', 1);
- // Load the functions script
- require PUN_ROOT.'include/functions.php';
- // Load UTF-8 functions
- require PUN_ROOT.'include/utf8/utf8.php';
- // Strip out "bad" UTF-8 characters
- forum_remove_bad_characters();
- // Reverse the effect of register_globals
- forum_unregister_globals();
- // Turn on full PHP error reporting
- error_reporting(E_ALL);
- // Force POSIX locale (to prevent functions such as strtolower() from messing up UTF-8 strings)
- setlocale(LC_CTYPE, 'C');
- // Turn off magic_quotes_runtime
- if (get_magic_quotes_runtime())
- set_magic_quotes_runtime(0);
- // Strip slashes from GET/POST/COOKIE (if magic_quotes_gpc is enabled)
- if (get_magic_quotes_gpc())
- {
- function stripslashes_array($array)
- {
- return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array);
- }
- $_GET = stripslashes_array($_GET);
- $_POST = stripslashes_array($_POST);
- $_COOKIE = stripslashes_array($_COOKIE);
- $_REQUEST = stripslashes_array($_REQUEST);
- }
- // If a cookie name is not specified in config.php, we use the default (forum_cookie)
- if (empty($cookie_name))
- $cookie_name = 'pun_cookie';
- // If the cache directory is not specified, we use the default setting
- if (!defined('FORUM_CACHE_DIR'))
- define('FORUM_CACHE_DIR', PUN_ROOT.'cache/');
- // Turn off PHP time limit
- @set_time_limit(0);
- // Define a few commonly used constants
- define('PUN_UNVERIFIED', 0);
- define('PUN_ADMIN', 1);
- define('PUN_MOD', 2);
- define('PUN_GUEST', 3);
- define('PUN_MEMBER', 4);
- // Load DB abstraction layer and try to connect
- require PUN_ROOT.'include/dblayer/common_db.php';
- // Check what the default character set is - since 1.2 didn't specify any we will use whatever the default was (usually latin1)
- $old_connection_charset = defined('FORUM_DEFAULT_CHARSET') ? FORUM_DEFAULT_CHARSET : $db->get_names();
- // Set the connection to UTF-8 now
- $db->set_names('utf8');
- // Get the forum config
- $result = $db->query('SELECT * FROM '.$db->prefix.'config') or error('Unable to fetch config.', __FILE__, __LINE__, $db->error());
- while ($cur_config_item = $db->fetch_row($result))
- $pun_config[$cur_config_item[0]] = $cur_config_item[1];
- // Load language file
- $default_lang = $pun_config['o_default_lang'];
- if (!file_exists(PUN_ROOT.'lang/'.$default_lang.'/update.php'))
- $default_lang = 'English';
- require PUN_ROOT.'lang/'.$default_lang.'/update.php';
- // Check current version
- $cur_version = $pun_config['o_cur_version'];
- $cur_eve_version = isset($pun_config['o_cur_eve_version']) ? $pun_config['o_cur_eve_version'] : '1.0.0';
- if (version_compare($cur_version, '1.2', '<'))
- error(sprintf($lang_update['Version mismatch error'], $db_name));
- // Do some DB type specific checks
- $mysql = false;
- switch ($db_type)
- {
- case 'mysql':
- case 'mysqli':
- case 'mysql_innodb':
- case 'mysqli_innodb':
- $mysql_info = $db->get_version();
- if (version_compare($mysql_info['version'], MIN_MYSQL_VERSION, '<'))
- error(sprintf($lang_update['You are running error'], 'MySQL', $mysql_info['version'], UPDATE_TO, MIN_MYSQL_VERSION));
- $mysql = true;
- break;
- case 'pgsql':
- $pgsql_info = $db->get_version();
- if (version_compare($pgsql_info['version'], MIN_PGSQL_VERSION, '<'))
- error(sprintf($lang_update['You are running error'], 'PostgreSQL', $pgsql_info['version'], UPDATE_TO, MIN_PGSQL_VERSION));
- break;
- }
- // Check the database, search index and parser revision and the current version
- if (isset($pun_config['o_database_revision']) && $pun_config['o_database_revision'] >= UPDATE_TO_DB_REVISION &&
- isset($pun_config['o_searchindex_revision']) && $pun_config['o_searchindex_revision'] >= UPDATE_TO_SI_REVISION &&
- isset($pun_config['o_parser_revision']) && $pun_config['o_parser_revision'] >= UPDATE_TO_PARSER_REVISION &&
- version_compare($pun_config['o_cur_version'], UPDATE_TO, '>=') &&
- version_compare($pun_config['o_eve_cur_version'], UPDATE_TO_EVEBB, '>='))
- error($lang_update['No update error']);
- $default_style = $pun_config['o_default_style'];
- if (!file_exists(PUN_ROOT.'style/'.$default_style.'.css'))
- $default_style = 'Air';
- // Start a session, used to queue up errors if duplicate users occur when converting from FluxBB v1.2.
- session_start();
- //
- // Determines whether $str is UTF-8 encoded or not
- //
- function seems_utf8($str)
- {
- $str_len = strlen($str);
- for ($i = 0; $i < $str_len; ++$i)
- {
- if (ord($str[$i]) < 0x80) continue; # 0bbbbbbb
- else if ((ord($str[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb
- else if ((ord($str[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb
- else if ((ord($str[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb
- else if ((ord($str[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb
- else if ((ord($str[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b
- else return false; # Does not match any model
- for ($j = 0; $j < $n; ++$j) # n bytes matching 10bbbbbb follow ?
- {
- if ((++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80))
- return false;
- }
- }
- return true;
- }
- //
- // Translates the number from a HTML numeric entity into an UTF-8 character
- //
- function dcr2utf8($src)
- {
- $dest = '';
- if ($src < 0)
- return false;
- else if ($src <= 0x007f)
- $dest .= chr($src);
- else if ($src <= 0x07ff)
- {
- $dest .= chr(0xc0 | ($src >> 6));
- $dest .= chr(0x80 | ($src & 0x003f));
- }
- else if ($src == 0xFEFF)
- {
- // nop -- zap the BOM
- }
- else if ($src >= 0xD800 && $src <= 0xDFFF)
- {
- // found a surrogate
- return false;
- }
- else if ($src <= 0xffff)
- {
- $dest .= chr(0xe0 | ($src >> 12));
- $dest .= chr(0x80 | (($src >> 6) & 0x003f));
- $dest .= chr(0x80 | ($src & 0x003f));
- }
- else if ($src <= 0x10ffff)
- {
- $dest .= chr(0xf0 | ($src >> 18));
- $dest .= chr(0x80 | (($src >> 12) & 0x3f));
- $dest .= chr(0x80 | (($src >> 6) & 0x3f));
- $dest .= chr(0x80 | ($src & 0x3f));
- }
- else
- {
- // out of range
- return false;
- }
- return $dest;
- }
- //
- // Attempts to convert $str from $old_charset to UTF-8. Also converts HTML entities (including numeric entities) to UTF-8 characters
- //
- function convert_to_utf8(&$str, $old_charset)
- {
- if ($str === null || $str == '')
- return false;
- $save = $str;
- // Replace literal entities (for non-UTF-8 compliant html_entity_encode)
- if (version_compare(PHP_VERSION, '5.0.0', '<') && $old_charset == 'ISO-8859-1' || $old_charset == 'ISO-8859-15')
- $str = html_entity_decode($str, ENT_QUOTES, $old_charset);
- if ($old_charset != 'UTF-8' && !seems_utf8($str))
- {
- if (function_exists('iconv'))
- $str = iconv($old_charset == 'ISO-8859-1' ? 'WINDOWS-1252' : 'ISO-8859-1', 'UTF-8', $str);
- else if (function_exists('mb_convert_encoding'))
- $str = mb_convert_encoding($str, 'UTF-8', $old_charset == 'ISO-8859-1' ? 'WINDOWS-1252' : 'ISO-8859-1');
- else if ($old_charset == 'ISO-8859-1')
- $str = utf8_encode($str);
- }
- // Replace literal entities (for UTF-8 compliant html_entity_encode)
- if (version_compare(PHP_VERSION, '5.0.0', '>='))
- $str = html_entity_decode($str, ENT_QUOTES, 'UTF-8');
- // Replace numeric entities
- $str = preg_replace_callback('/&#([0-9]+);/', 'utf8_callback_1', $str);
- $str = preg_replace_callback('/&#x([a-f0-9]+);/i', 'utf8_callback_2', $str);
- // Remove "bad" characters
- $str = remove_bad_characters($str);
- return ($save != $str);
- }
- function utf8_callback_1($matches)
- {
- return dcr2utf8($matches[1]);
- }
- function utf8_callback_2($matches)
- {
- return dcr2utf8(hexdec($matches[1]));
- }
- //
- // Alter a table to be utf8. MySQL only
- // Function based on update_convert_table_utf8() from the Drupal project (http://drupal.org/)
- //
- function alter_table_utf8($table)
- {
- global $mysql, $db;
- static $types;
- if (!$mysql)
- return;
- if (!isset($types))
- {
- $types = array(
- 'char' => 'binary',
- 'varchar' => 'varbinary',
- 'tinytext' => 'tinyblob',
- 'mediumtext' => 'mediumblob',
- 'text' => 'blob',
- 'longtext' => 'longblob'
- );
- }
- // Set table default charset to utf8
- $db->query('ALTER TABLE '.$table.' CHARACTER SET utf8') or error('Unable to set table character set', __FILE__, __LINE__, $db->error());
- // Find out which columns need converting and build SQL statements
- $result = $db->query('SHOW FULL COLUMNS FROM '.$table) or error('Unable to fetch column information', __FILE__, __LINE__, $db->error());
- while ($cur_column = $db->fetch_assoc($result))
- {
- if ($cur_column['Collation'] === null)
- continue;
- list($type) = explode('(', $cur_column['Type']);
- if (isset($types[$type]) && strpos($cur_column['Collation'], 'utf8') === false)
- {
- $allow_null = ($cur_column['Null'] == 'YES');
- $collate = (substr($cur_column['Collation'], -3) == 'bin') ? 'utf8_bin' : 'utf8_general_ci';
- $db->alter_field($table, $cur_column['Field'], preg_replace('/'.$type.'/i', $types[$type], $cur_column['Type']), $allow_null, $cur_column['Default'], null, true) or error('Unable to alter field to binary', __FILE__, __LINE__, $db->error());
- $db->alter_field($table, $cur_column['Field'], $cur_column['Type'].' CHARACTER SET utf8 COLLATE '.$collate, $allow_null, $cur_column['Default'], null, true) or error('Unable to alter field to utf8', __FILE__, __LINE__, $db->error());
- }
- }
- }
- //
- // Safely converts text type columns into utf8
- // If finished returns true, otherwise returns $end_at
- //
- function convert_table_utf8($table, $callback, $old_charset, $key = null, $start_at = null, $error_callback = null)
- {
- global $mysql, $db, $old_connection_charset;
- $finished = true;
- $end_at = 0;
- if ($mysql)
- {
- // Only set up the tables if we are doing this in 1 go, or its the first go
- if ($start_at === null || $start_at == 0)
- {
- // Drop any temp table that exists, in-case it's left over from a failed update
- $db->drop_table($table.'_utf8', true) or error('Unable to drop left over temp table', __FILE__, __LINE__, $db->error());
- // Copy the table
- $db->query('CREATE TABLE '.$table.'_utf8 LIKE '.$table) or error('Unable to create new table', __FILE__, __LINE__, $db->error());
- // Set table default charset to utf8
- alter_table_utf8($table.'_utf8');
- }
- // Change to the old character set so MySQL doesn't attempt to perform conversion on the data from the old table
- $db->set_names($old_connection_charset);
- // Move & Convert everything
- $result = $db->query('SELECT * FROM '.$table.($start_at === null ? '' : ' WHERE '.$key.'>'.$start_at).' ORDER BY '.$key.' ASC'.($start_at === null ? '' : ' LIMIT '.PER_PAGE), false) or error('Unable to select from old table', __FILE__, __LINE__, $db->error());
- // Change back to utf8 mode so we can insert it into the new table
- $db->set_names('utf8');
- while ($cur_item = $db->fetch_assoc($result))
- {
- $cur_item = call_user_func($callback, $cur_item, $old_charset);
- $temp = array();
- foreach ($cur_item as $idx => $value)
- $temp[$idx] = $value === null ? 'NULL' : '\''.$db->escape($value).'\'';
- $db->query('INSERT INTO '.$table.'_utf8('.implode(',', array_keys($temp)).') VALUES ('.implode(',', array_values($temp)).')') or ($error_callback === null ? error('Unable to insert data to new table', __FILE__, __LINE__, $db->error()) : call_user_func($error_callback, $cur_item));
- $end_at = $cur_item[$key];
- }
- // If we aren't doing this all in 1 go and $end_at has a value (i.e. we have processed at least 1 row), figure out if we have more to do or not
- if ($start_at !== null && $end_at > 0)
- {
- $result = $db->query('SELECT 1 FROM '.$table.' WHERE '.$key.'>'.$end_at.' ORDER BY '.$key.' ASC LIMIT 1') or error('Unable to check for next row', __FILE__, __LINE__, $db->error());
- $finished = $db->num_rows($result) == 0;
- }
- // Only swap the tables if we are doing this in 1 go, or its the last go
- if ($finished)
- {
- // Delete old table
- $db->drop_table($table, true) or error('Unable to drop old table', __FILE__, __LINE__, $db->error());
- // Rename table
- $db->query('ALTER TABLE '.$table.'_utf8 RENAME '.$table) or error('Unable to rename new table', __FILE__, __LINE__, $db->error());
- return true;
- }
- return $end_at;
- }
- else
- {
- // Convert everything
- $result = $db->query('SELECT * FROM '.$table.($start_at === null ? '' : ' WHERE '.$key.'>'.$start_at).' ORDER BY '.$key.' ASC'.($start_at === null ? '' : ' LIMIT '.PER_PAGE)) or error('Unable to select from table', __FILE__, __LINE__, $db->error());
- while ($cur_item = $db->fetch_assoc($result))
- {
- $cur_item = call_user_func($callback, $cur_item, $old_charset);
- $temp = array();
- foreach ($cur_item as $idx => $value)
- $temp[] = $idx.'='.($value === null ? 'NULL' : '\''.$db->escape($value).'\'');
- if (!empty($temp))
- $db->query('UPDATE '.$table.' SET '.implode(', ', $temp).' WHERE '.$key.'=\''.$db->escape($cur_item[$key]).'\'') or error('Unable to update data', __FILE__, __LINE__, $db->error());
- $end_at = $cur_item[$key];
- }
- if ($start_at !== null && $end_at > 0)
- {
- $result = $db->query('SELECT 1 FROM '.$table.' WHERE '.$key.'>'.$end_at.' ORDER BY '.$key.' ASC LIMIT 1') or error('Unable to check for next row', __FILE__, __LINE__, $db->error());
- if ($db->num_rows($result) == 0)
- return true;
- return $end_at;
- }
- return true;
- }
- }
- /* EVEBB Updates*/
- /**
- * Installs the tables for poll support.
- */
- function install_poll()
- {
- global $db, $db_type, $pun_config;
- $db->add_field('topics', 'poll_type', 'TINYINT(4)', false, 0) or error('Unable to add poll_type field', __FILE__, __LINE__, $db->error());
- $db->add_field('topics', 'poll_time', 'INT(10) UNSIGNED', false, 0) or error('Unable to add poll_time field', __FILE__, __LINE__, $db->error());
- $db->add_field('topics', 'poll_term', 'TINYINT(4)', false, 0) or error('Unable to add poll_term field', __FILE__, __LINE__, $db->error());
- $db->add_field('topics', 'poll_kol', 'INT(10) UNSIGNED', false, 0) or error('Unable to add poll_kol field', __FILE__, __LINE__, $db->error());
- $schema = array(
- 'FIELDS' => array(
- 'tid' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'question' => array(
- 'datatype' => 'TINYINT(4)',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'field' => array(
- 'datatype' => 'TINYINT(4)',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'choice' => array(
- 'datatype' => 'VARCHAR(255)',
- 'allow_null' => false,
- 'default' => '\'\''
- ),
- 'votes' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false,
- 'default' => '0'
- )
- ),
- 'PRIMARY KEY' => array('tid', 'question', 'field')
- );
- $db->create_table('poll', $schema) or error('Unable to create table poll', __FILE__, __LINE__, $db->error());
- $schema = array(
- 'FIELDS' => array(
- 'tid' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false
- ),
- 'uid' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false
- ),
- 'rez' => array(
- 'datatype' => 'TEXT',
- 'allow_null' => true
- )
- ),
- 'PRIMARY KEY' => array('tid', 'uid')
- );
-
- $db->create_table('poll_voted', $schema) or error('Unable to create table poll_voted', __FILE__, __LINE__, $db->error());
- // Insert config data
- $config = array(
- 'o_poll_enabled' => "'0'",
- 'o_poll_max_ques' => "'3'",
- 'o_poll_max_field' => "'20'",
- 'o_poll_time' => "'60'",
- 'o_poll_term' => "'3'",
- 'o_poll_guest' => "'0'",
- );
- while (list($conf_name, $conf_value) = @each($config))
- {
- $db->query('INSERT INTO '.$db->prefix."config (conf_name, conf_value) VALUES('$conf_name', $conf_value)")
- or error('Unable to insert into table '.$db->prefix.'config. Please check your configuration and try again.');
- }
- forum_clear_cache();
- }
- /**
- * Installs the table for RSS feed support.
- */
- function install_feed() {
- global $db;
- $db->query('CREATE TABLE '.$db->prefix.'feeds ( url varchar(255) NOT NULL default \'\', max int(11) NOT NULL default 0, closed tinyint(1) NOT NULL default 0, forum_id int(11) NOT NULL default 0, last_post INT(10) NOT NULL default 0, num_posts INT(10) NOT NULL default 0, PRIMARY KEY (url) )' );
- } //End install_feed().
- /**
- * This massively long function makes the DB ready for sub forums.
- */
- function install_subforum() {
- global $db;
- $db->add_field('forums', 'parent_forum_id', 'INT', true, 0);
- } //End install_subform().
- /**
- * Installs the tables for the Private Messaging System.
- */
- function install_npms() {
- global $db, $db_type, $pun_config;
-
- $schema = array(
- 'FIELDS' => array(
- 'bl_id' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'bl_user_id' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'bl_user' => array(
- 'datatype' => 'VARCHAR(200)',
- 'allow_null' => false,
- 'default' => '\'\''
- ),
- ),
- 'INDEXES' => array(
- 'bl_id_idx' => array('bl_id'),
- 'bl_user_id_idx' => array('bl_user_id')
- )
- );
- $db->create_table('pms_new_block', $schema) or error('Unable to create pms_new_block table', __FILE__, __LINE__, $db->error());
- $schema = array(
- 'FIELDS' => array(
- 'id' => array(
- 'datatype' => 'SERIAL',
- 'allow_null' => false
- ),
- 'poster' => array(
- 'datatype' => 'VARCHAR(200)',
- 'allow_null' => false,
- 'default' => '\'\''
- ),
- 'poster_id' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false,
- 'default' => '1'
- ),
- 'poster_ip' => array(
- 'datatype' => 'VARCHAR(39)',
- 'allow_null' => true
- ),
- 'message' => array(
- 'datatype' => 'TEXT',
- 'allow_null' => true
- ),
- 'hide_smilies' => array(
- 'datatype' => 'TINYINT(1)',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'posted' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'edited' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => true
- ),
- 'edited_by' => array(
- 'datatype' => 'VARCHAR(200)',
- 'allow_null' => true
- ),
- 'post_seen' => array(
- 'datatype' => 'TINYINT(1)',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'post_new' => array(
- 'datatype' => 'TINYINT(1)',
- 'allow_null' => false,
- 'default' => '1'
- ),
- 'topic_id' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false,
- 'default' => '0'
- )
- ),
- 'PRIMARY KEY' => array('id'),
- 'INDEXES' => array(
- 'topic_id_idx' => array('topic_id'),
- 'multi_idx' => array('poster_id', 'topic_id')
- )
- );
- $db->create_table('pms_new_posts', $schema) or error('Unable to create pms_new_posts table', __FILE__, __LINE__, $db->error());
- $schema = array(
- 'FIELDS' => array(
- 'id' => array(
- 'datatype' => 'SERIAL',
- 'allow_null' => false
- ),
- 'topic' => array(
- 'datatype' => 'VARCHAR(255)',
- 'allow_null' => false,
- 'default' => '\'\''
- ),
- 'starter' => array(
- 'datatype' => 'VARCHAR(200)',
- 'allow_null' => false,
- 'default' => '\'\''
- ),
- 'starter_id' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'to_user' => array(
- 'datatype' => 'VARCHAR(200)',
- 'allow_null' => false,
- 'default' => '\'\''
- ),
- 'to_id' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'replies' => array(
- 'datatype' => 'MEDIUMINT(8) UNSIGNED',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'last_posted' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'last_poster' => array(
- 'datatype' => 'TINYINT(1)',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'see_st' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'see_to' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'topic_st' => array(
- 'datatype' => 'TINYINT(4)',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'topic_to' => array(
- 'datatype' => 'TINYINT(4)',
- 'allow_null' => false,
- 'default' => '0'
- ),
- ),
- 'PRIMARY KEY' => array('id'),
- 'INDEXES' => array(
- 'multi_idx_st' => array('starter_id', 'topic_st'),
- 'multi_idx_to' => array('to_id', 'topic_to')
- )
- );
- $db->create_table('pms_new_topics', $schema) or error('Unable to create pms_new_topics table', __FILE__, __LINE__, $db->error());
- $db->add_field('groups', 'g_pm', 'TINYINT(1)', false, 1) or error('Unable to add g_pm field', __FILE__, __LINE__, $db->error());
- $db->add_field('groups', 'g_pm_limit', 'INT(10) UNSIGNED', false, 100) or error('Unable to add g_pm_limit field', __FILE__, __LINE__, $db->error());
- $db->add_field('users', 'messages_enable', 'TINYINT(1)', false, 1) or error('Unable to add messages_enable field', __FILE__, __LINE__, $db->error());
- $db->add_field('users', 'messages_email', 'TINYINT(1)', false, 0) or error('Unable to add messages_email field', __FILE__, __LINE__, $db->error());
- $db->add_field('users', 'messages_flag', 'TINYINT(1)', false, 0) or error('Unable to add messages_flag field', __FILE__, __LINE__, $db->error());
- $db->add_field('users', 'messages_new', 'INT(10) UNSIGNED', false, 0) or error('Unable to add messages_new field', __FILE__, __LINE__, $db->error());
- $db->add_field('users', 'messages_all', 'INT(10) UNSIGNED', false, 0) or error('Unable to add messages_all field', __FILE__, __LINE__, $db->error());
- $db->add_field('users', 'pmsn_last_post', 'INT(10) UNSIGNED', true) or error('Unable to add pmsn_last_post field', __FILE__, __LINE__, $db->error());
- $db->query('UPDATE '.$db->prefix.'groups SET g_pm_limit=0 WHERE g_id='.PUN_ADMIN) or error('Unable to merge groups', __FILE__, __LINE__, $db->error());
- // Insert config data
- $config = array(
- 'o_pms_enabled' => '1',
- 'o_pms_min_kolvo' => '0',
- 'o_pms_flasher' => '0',
- );
-
- while (list($conf_name, $conf_value) = @each($config))
- {
- if (!array_key_exists($conf_name, $pun_config))
- $db->query('INSERT INTO '.$db->prefix."config (conf_name, conf_value) VALUES('$conf_name', $conf_value)")
- or error('Unable to insert into table '.$db->prefix.'config. Please check your configuration and try again.');
- }
- // Delete all .php files in the cache (someone might have visited the forums while we were updating and thus, generated incorrect cache files)
- forum_clear_cache();
- } //End install_npms().
- /**
- * Installs the database for the attachements.
- */
- function install_attach($basepath='')
- {
- global $db, $db_type, $pun_config, $mod_version;
- //include PUN_ROOT.'include/attach/attach_incl.php';
- //first check so that the path seems reasonable
- if(!((substr($basepath,0,1) == '/' || substr($basepath,1,1) == ':') && substr($basepath,-1) == '/'))
- error('The pathname specified doesn\'t comply with the rules set. Go back and make sure that it\'s the complete path, and that it ends with a slash and that it either start with a slash (example: "/home/username/attachments/", on *nix servers (unix, linux, bsd, solaris etc.)) or a driveletter (example: "C:/webpages/attachments/" on windows servers)');
- // create the files table
- $schema_files = array(
- 'FIELDS' => array(
- 'id' => array(
- 'datatype' => 'SERIAL',
- 'allow_null' => false
- ),
- 'owner' => array(
- 'datatype' => 'INT(10)',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'post_id' => array(
- 'datatype' => 'INT(10)',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'filename' => array(
- 'datatype' => 'VARCHAR(255)',
- 'allow_null' => false,
- ),
- 'extension' => array(
- 'datatype' => 'VARCHAR(64)',
- 'allow_null' => false,
- ),
- 'mime' => array(
- 'datatype' => 'VARCHAR(64)',
- 'allow_null' => false
- ),
- 'location' => array(
- 'datatype' => 'TEXT',
- 'allow_null' => false
- ),
- 'size' => array(
- 'datatype' => 'INT(10)',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'downloads' => array(
- 'datatype' => 'INT(10)',
- 'allow_null' => false,
- 'default' => '0'
- )
- ),
- 'PRIMARY KEY' => array('id'),
- );
-
- $db->create_table('attach_2_files', $schema_files) or error('Unable to create table "attach_2_files"', __FILE__, __LINE__, $db->error());
-
-
- // create the files table
- $schema_rules = array(
- 'FIELDS' => array(
- 'id' => array(
- 'datatype' => 'SERIAL',
- 'allow_null' => false
- ),
- 'forum_id' => array(
- 'datatype' => 'INT(10)',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'group_id' => array(
- 'datatype' => 'INT(10)',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'rules' => array(
- 'datatype' => 'INT(10)',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'size' => array(
- 'datatype' => 'INT(10)',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'per_post' => array(
- 'datatype' => 'TINYINT(4)',
- 'allow_null' => false,
- 'default' => '1'
- ),
- 'file_ext' => array(
- 'datatype' => 'TEXT',
- 'allow_null' => false
- ),
- ),
- 'PRIMARY KEY' => array('id'),
- );
-
- $db->create_table('attach_2_rules', $schema_rules) or error('Unable to create table "attach_2_rules"', __FILE__, __LINE__, $db->error());
-
- //ok path could be correct, try to make a subfolder :D
- $newname = attach_generate_pathname($basepath);
- if(!attach_create_subfolder($newname,$basepath))
- error('Unable to create new subfolder with name "'.$newname.'", make sure php has write access to that folder!',__FILE__,__LINE__);
-
-
- // ok, add the stuff needed in the config cache
- $attach_config = array( 'attach_always_deny' => 'html"htm"php"php3"php4"php5"exe"com"bat',
- 'attach_basefolder' => $basepath,
- 'attach_create_orphans' => '1',
- 'attach_cur_version' => $mod_version,
- 'attach_icon_folder' => 'img/attach/',
- 'attach_icon_extension' => 'txt"log"doc"pdf"wav"mp3"ogg"avi"mpg"mpeg"png"jpg"jpeg"gif"zip"rar"7z"gz"tar',
- 'attach_icon_name' => 'text.png"text.png"doc.png"doc.png"audio.png"audio.png"audio.png"video.png"video.png"video.png"image.png"image.png"image.png"image.png"compress.png"compress.png"compress.png"compress.png"compress.png',
- 'attach_max_size' => '100000',
- 'attach_subfolder' => $newname,
- 'attach_use_icon' => '1');
-
- foreach($attach_config AS $key => $value)
- $db->query("INSERT INTO ".$db->prefix."config (conf_name, conf_value) VALUES ('$key', '".$db->escape($value)."')") or error('Unable to add column "'.$key.'" to config table', __FILE__, __LINE__, $db->error());
- // and now, update the cache...
- require_once PUN_ROOT.'include/cache.php';
- generate_config_cache();
- } //End install_attach()
- function attach_create_subfolder($newfolder='',$basepath){
-
- // check to see if that folder is there already, then just update the config ...
- if(!is_dir($basepath.$newfolder)){
- // if the folder doesn't exist, try to create it
- if(!mkdir($basepath.$newfolder,0755))
- error('Unable to create new subfolder with name \''.$basepath.$newfolder.'\' with mode 0755',__FILE__,__LINE__);
- // create a .htaccess and index.html file in the new subfolder
- if(!copy($basepath.'.htaccess', $basepath.$newfolder.'/.htaccess'))
- error('Unable to copy .htaccess file to new subfolder with name \''.$basepath.$newfolder.'\'',__FILE__,__LINE__);
- if(!copy($basepath.'index.html', $basepath.$newfolder.'/index.html'))
- error('Unable to copy index.html file to new subfolder with name \''.$basepath.$newfolder.'\'',__FILE__,__LINE__);
- // if the folder was created continue
- }
- // return true if everything has gone as planned, return false if the new folder could not be created (rights etc?)
- return true;
- }
- function attach_generate_pathname($storagepath=''){
- if(strlen($storagepath)!=0){
- //we have to check so that path doesn't exist already...
- $not_unique=true;
- while($not_unique){
- $newdir = attach_generate_pathname();
- if(!is_dir($storagepath.$newdir))return $newdir;
- }
- }else
- return substr(md5(time().'54ÂŁ7 k3yw0rd, r3pl4ce |f U w4nt t0'),0,32);
- }
- function attach_generate_filename($storagepath, $messagelenght=0, $filesize=0){
- $not_unique=true;
- while($not_unique){
- $newfile = md5(attach_generate_pathname().$messagelenght.$filesize.'Some more salt keyworbs, change if you want to').'.attach';
- if(!is_file($storagepath.$newfile))return $newfile;
- }
- }
- function update_forum_perm($forum_id) {
- global $db;
- //This 'fills in' blank permissions, used for multi-group joins.
- //I personally prefer to work on *some* data than assume something based on a lack of data.
-
- $result = $db->query('SELECT g_id, g_read_board, g_post_replies, g_post_topics FROM '.$db->prefix.'groups WHERE g_id!='.PUN_ADMIN) or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());
- while ($cur_group = $db->fetch_assoc($result)) {
-
- $sql = "SELECT * FROM ".$db->prefix."forum_perms WHERE group_id=".$cur_group['g_id']." AND forum_id=".$forum_id;
- if (!$perms = $db->query($sql)) {
- continue;
- } //End if.
-
-
- if ($db->num_rows($perms) == 0) {
- $read_forum_new = '0';
- $post_replies_new = '0';
- $post_topics_new = '0';
- } else {
- $perms = $db->fetch_assoc($perms);
- $read_forum_new = ($perms['read_forum'] != '') ? $perms['read_forum'] : '0';
- $post_replies_new = ($perms['post_replies'] != '') ? $perms['post_replies'] : '0';
- $post_topics_new = ($perms['post_topics'] != '') ? $perms['post_topics'] : '0';
- } //End if - else.
-
- $fields = array(
- 'forum_id' => $forum_id,
- 'group_id' => $cur_group['g_id'],
- 'read_forum' => $read_forum_new,
- 'post_replies' => $post_replies_new,
- 'post_topics' => $post_topics_new
- );
-
- if (!$db->insert_or_update($fields, array('forum_id', 'group_id'), $db->prefix.'forum_perms')) {
- if (defined('PUN_DEBUG')) {
- error('Unable to add group to table.', __FILE__, __LINE__, $db->error());
- } //End if.
- $log .= "[".$cur_group['g_id']."]: Unable to add permissions [".$old_group."].\n";
- continue;
- } //End if.
- }
- } //End update_forum_perm().
- /* EVEBB Updates*/
- header('Content-type: text/html; charset=utf-8');
- // Empty all output buffers and stop buffering
- while (@ob_end_clean());
- $stage = isset($_REQUEST['stage']) ? $_REQUEST['stage'] : '';
- $old_charset = isset($_REQUEST['req_old_charset']) ? str_replace('ISO8859', 'ISO-8859', strtoupper($_REQUEST['req_old_charset'])) : 'ISO-8859-1';
- $start_at = isset($_REQUEST['start_at']) ? intval($_REQUEST['start_at']) : 0;
- $query_str = '';
- // Show form
- if (empty($stage))
- {
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title><?php echo $lang_update['Update'] ?></title>
- <link rel="stylesheet" type="text/css" href="style/<?php echo $default_style ?>.css" />
- </head>
- <body onload="document.getElementById('install').req_db_type.focus();document.getElementById('install').start.disabled=false;">
- <div id="pundb_update" class="pun">
- <div class="top-box"><div><!-- Top Corners --></div></div>
- <div class="punwrap">
- <div id="brdheader" class="block">
- <div class="box">
- <div id="brdtitle" class="inbox">
- <h1><span><?php echo $lang_update['Update'] ?></span></h1>
- <div id="brddesc"><p><?php echo $lang_update['Update message'] ?></p><p><strong><?php echo $lang_update['Note']; ?></strong> <?php echo $lang_update['Members message']; ?></p></div>
- </div>
- </div>
- </div>
- <div id="brdmain">
- <div class="blockform">
- <h2><span><?php echo $lang_update['Update'] ?></span></h2>
- <div class="box">
- <form method="post" action="db_update.php">
- <div class="inform">
- <input type="hidden" name="stage" value="evebb" />
- <fieldset>
- <legend><?php echo $lang_update['Administrator only'] ?></legend>
- <div class="infldset">
- <p><?php echo $lang_update['Database password info'] ?></p>
- <p><strong><?php echo $lang_update['Note']; ?></strong> <?php echo $lang_update['Database password note'] ?></p>
- <label class="required"><strong><?php echo $lang_update['Database password'] ?> <span><?php echo $lang_update['Required'] ?></span></strong><br /><input type="password" id="req_db_pass" name="req_db_pass" /><br /></label>
- </div>
- </fieldset>
- </div>
- <div class="inform">
- <div class="forminfo">
- <p><?php echo $lang_update['Intro 1'] ?></p>
- <p><?php echo $lang_update['Intro 2'] ?></p>
- <?php
- if (strpos($cur_version, '1.2') === 0)
- {
- if (!function_exists('iconv') && !function_exists('mb_convert_encoding'))
- {
- ?>
- <p><?php echo $lang_update['No charset conversion'] ?></p>
- <?php
- }
- ?>
- </div>
- </div>
- <div class="inform">
- <div class="forminfo">
- <p><?php echo $lang_update['Enable conversion'] ?></p>
- <p><?php echo $lang_update['Current character set'] ?></p>
- </div>
- <fieldset>
- <legend><?php echo $lang_update['Charset conversion'] ?></legend>
- <div class="infldset">
- <div class="rbox">
- <label><input type="checkbox" name="convert_charset" value="1" checked="checked" /><?php echo $lang_update['Enable conversion label'] ?><br /></label>
- </div>
- <label>
- <strong><?php echo $lang_update['Current character set label'] ?></strong><br /><?php echo $lang_update['Current character set info'] ?><br />
- <input type="text" name="req_old_charset" size="12" maxlength="20" value="<?php echo $old_charset ?>" /><br />
- </label>
- </div>
- </fieldset>
- <?php
- }
- else
- echo "\t\t\t\t".'</div>'."\n";
- ?>
- </div>
- <p class="buttons"><input type="submit" name="start" value="<?php echo $lang_update['Start update'] ?>" /></p>
- </form>
- </div>
- </div>
- </div>
- </div>
- <div class="end-box"><div><!-- Bottom Corners --></div></div>
- </div>
- </body>
- </html>
- <?php
- $db->end_transaction();
- $db->close();
- exit;
- }
- // Read the lock file
- $lock = file_exists(FORUM_CACHE_DIR.'db_update.lock') ? trim(file_get_contents(FORUM_CACHE_DIR.'db_update.lock')) : false;
- $lock_error = false;
- // Generate or fetch the UID - this confirms we have a valid admin
- if (isset($_POST['req_db_pass']))
- {
- $req_db_pass = strtolower(trim($_POST['req_db_pass']));
- switch ($db_type)
- {
- // For SQLite we compare against the database file name, since the password is left blank
- case 'sqlite':
- if ($req_db_pass != strtolower($db_name))
- error(sprintf($lang_update['Invalid file error'], 'config.php'));
- break;
- // For everything else, check the password matches
- default:
- if ($req_db_pass != strtolower($db_password))
- error(sprintf($lang_update['Invalid password error'], 'config.php'));
- break;
- }
- // Generate a unique id to identify this session, only if this is a valid session
- $uid = pun_hash($req_db_pass.'|'.uniqid(rand(), true));
- if ($lock) // We already have a lock file
- $lock_error = true;
- else // Create the lock file
- {
- $fh = @fopen(FORUM_CACHE_DIR.'db_update.lock', 'wb');
- if (!$fh)
- error(sprintf($lang_update['Unable to lock error'], 'cache'));
- fwrite($fh, $uid);
- fclose($fh);
- }
- }
- else if (isset($_GET['uid']))
- {
- $uid = trim($_GET['uid']);
- if (!$lock || $lock != $uid) // The lock doesn't exist or doesn't match the given UID
- $lock_error = true;
- }
- else
- error($lang_update['No password error']);
- // If there is an error with the lock file
- if ($lock_error)
- error(sprintf($lang_update['Script runs error'], FORUM_CACHE_DIR.'db_update.lock'));
- switch ($stage)
- {
-
- case 'evebb':
- $query_str = '?stage=start';
-
- /*EveBB runs first*/
-
- //Updates for mods.
-
- // If we don't have the teamspeak3 table, create it
- if (!$db->table_exists('teamspeak3')) {
- $schema = array(
- 'FIELDS' => array(
- 'user_id' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'username' => array(
- 'datatype' => 'VARCHAR(100)',
- 'allow_null' => false
- ),
- 'token' => array(
- 'datatype' => 'VARCHAR(100)',
- 'allow_null' => false
- )
- ),
- 'PRIMARY KEY' => array('user_id')
- );
- $db->create_table('teamspeak3', $schema) or error('Unable to create teamspeak3 table', __FILE__, __LINE__, $db->error());
- } //End if.
-
- //Only install the mods if they aren't already installed.
- if (!$db->table_exists('pms_new_block')) {
- install_npms();
- } //End if.
-
- if (!$db->field_exists('api_auth', 'cak_type')) {
- $db->add_field('api_auth', 'cak_type', 'INT(10) UNSIGNED', false, '0', null)
- or error('Unable to add CAK Type field.', __FILE__, __LINE__, $db->error());
- } //End if.
-
- if (!$db->field_exists('forums', 'parent_forum_id')) {
- install_subforum();
- } //End if.
-
- if (!$db->table_exists('attach_2_files')) {
- install_attach(rtrim(dirname(__FILE__), '/\\') . DIRECTORY_SEPARATOR.'attachments/');
- } //End if,
-
- if (!$db->table_exists('feeds')) {
- install_feed();
- } //End if.
- if (!$db->table_exists('poll')) {
- install_poll();
- } //End if.
-
- if (!$db->table_exists('session')) {
- //Session table
- $schema = array(
- 'FIELDS' => array(
- 'user_id' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false,
- 'default' => '0'
- ),
- 'token' => array(
- 'datatype' => 'VARCHAR(32)',
- 'allow_null' => false
- ),
- 'stamp' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false
- ),
- 'length' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false
- ),
- 'ip' => array(
- 'datatype' => 'VARCHAR(32)',
- 'allow_null' => false
- )
- ),
- 'PRIMARY KEY' => array('user_id')
- );
-
- $db->create_table('session', $schema) or error('Unable to create session table', __FILE__, __LINE__, $db->error());
- } //End is.
-
- if (version_compare($cur_eve_version, '1.1.1', '<=')) {
- //Update/insert new configs.
-
- $db->drop_table('api_skill_queue');
-
- $schema = array(
- 'FIELDS' => array(
- 'character_id' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false
- ),
- 'queuePosition' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false
- ),
- 'typeID' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false
- ),
- 'level' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false
- ),
- 'startSP' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false
- ),
- 'endSP' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false
- ),
- 'startTime' => array(
- 'datatype' => 'VARCHAR(25)',
- 'allow_null' => false
- ),
- 'endTime' => array(
- 'datatype' => 'VARCHAR(25)',
- 'allow_null' => false
- ),
- 'last_update' => array(
- 'datatype' => 'INT(10) UNSIGNED',
- 'allow_null' => false
- )
- ),
- 'PRIMARY KEY' => array('character_id', 'typeID', 'queuePosition')
- );
-
- $db->create_table('api_skill_queue', $schema) or error('Unable to create skill queue table', __FILE__, __LINE__, $db->error());
-
- $db->insert_or_update(
- array('conf_name' => 'o_eve_cak_mask', 'conf_value' => '33947656'), //Fields
- 'conf_name', //Primary Key
- $db->prefix.'config' //Table
- );
-
- $db->insert_or_update(
- array('conf_name' => 'o_eve_cak_type', 'conf_value' => '1'), //Fields
- 'conf_name', //Primary Key
- $db->prefix.'config' //Table
- );
-
- $db->insert_or_update(
- array('conf_name' => 'o_eve_use_image_server', 'conf_value' => '0'), //Fields
- 'conf_name', //Primary Key
- $db->prefix.'config' //Table
- );
-
- $db->insert_or_update(
- array('conf_name' => 'o_eve_char_pic_size', 'conf_value' => '128'), //Fields
- 'conf_name', //Primary Key
- $db->prefix.'config' //Table
- );
-
- if (!function_exists('generate_config_cache')) {
- include(PUN_ROOT.'include/cache.php');
- } //End if.
- generate_config_cache();
-
- } //End if.
-
- if (version_compare($cur_eve_version, '1.0.0', '<=')) {
- $db->insert_or_update(
- array('conf_name' => 'o_hide_stats', 'conf_value' => '0'), //Fields
- 'conf_name', //Primary Key
- $db->prefix.'config' //Table
- );
-
- $db->insert_or_update(
- array('conf_name' => 'o_default_style', 'conf_value' => 'evebbgray'), //Fields
- 'conf_name', //Primary Key
- $db->prefix.'config' //Table
- );
-
- $db->insert_or_update(
- array('conf_name' => 'o_allow_style', 'conf_value' => '1'), //Fields
- 'conf_name', //Primary Key
- $db->prefix.'config' //Table
- );
-
- if (!function_exists('generate_config_cache')) {
- include(PUN_ROOT.'include/cache.php');
- } //End if.
- generate_config_cache();
-
- //Update permissions, this is not a -terrible- thing to have fail, so we'll let it.
- //You can manually do this via the forum page.
- $sql = "SELECT id FROM ".$db->prefix."forums";
- if ($result = $db->query($sql)) {
- while ($row = $db->fetch_row($result)) {
- update_forum_perm($row[0]);
- } //End while loop().
- } //End if.
-
- } //End if.
-
- //The version we want to update to.
- $db->insert_or_update(
- array('conf_name' => 'o_cur_eve_version', 'conf_value' => UPDATE_TO_EVEBB), //Fields
- 'conf_name', //Primary Key
- $db->prefix.'config' //Table
- );
-
-
- break;
- // Start by updating the database structure
- case 'start':
- $query_str = '?stage=preparse_posts';
- // If we don't need to update the database, skip this stage
- if (isset($pun_config['o_database_revision']) && $pun_config['o_database_revision'] >= UPDATE_TO_DB_REVISION)
- break;
- // Make all email fields VARCHAR(80)
- $db->alter_field('bans', 'email', 'VARCHAR(80)', true) or error('Unable to alter email field', __FILE__, __LINE__, $db->error());
- $db->alter_field('posts', 'poster_email', 'VARCHAR(80)', true) or error('Unable to alter poster_email field', __FILE__, __LINE__, $db->error());
- $db->alter_field('users', 'email', 'VARCHAR(80)', false, '') or error('Unable to alter email field', __FILE__, __LINE__, $db->error());
- $db->alter_field('users', 'jabber', 'VARCHAR(80)', true) or error('Unable to alter jabber field', __FILE__, __LINE__, $db->error());
- $db->alter_field('users', 'msn', 'VARCHAR(80)', true) or error('Unable to alter msn field', __FILE__, __LINE__, $db->error());
- $db->alter_field('users', 'activate_string', 'VARCHAR(80)', true) or error('Unable to alter activate_string field', __FILE__, __LINE__, $db->error());
- // Make all IP fields VARCHAR(39) to support IPv6
- $db->alter_field('posts', 'poster_ip', 'VARCHAR(39)', true) or error('Unable to alter poster_ip field', __FILE__, __LINE__, $db->error());
- $db->alter_field('users', 'registration_ip', 'VARCHAR(39)', false, '0.0.0.0') or error('Unable to alter registration_ip field', __FILE__, __LINE__, $db->error());
- // Make the message field MEDIUMTEXT to allow proper conversion of 65535 character posts to UTF-8
- $db->alter_field('posts', 'message', 'MEDIUMTEXT', true) or error('Unable to alter message field', __FILE__, __LINE__, $db->error());
- // Add the DST option to the users table
- $db->add_field('users', 'dst', 'TINYINT(1)', false, 0, 'timezone') or error('Unable to add dst field', __FILE__, __LINE__, $db->error());
- // Add the last_post field to the online table
- $db->add_field('online', 'last_post', 'INT(10) UNSIGNED', true, null, null) or error('Unable to add last_post field', __FILE__, __LINE__, $db->error());
- // Add the last_search field to the online table
- $db->add_field('online', 'last_search', 'INT(10) UNSIGNED', true, null, null) or error('Unable to add last_search field', __FILE__, __LINE__, $db->error());
- // Add the last_search column to the users table
- $db->add_field('users', 'last_search', 'INT(10) UNSIGNED', true, null, 'last_post') or error('Unable to add last_search field', __FILE__, __LINE__, $db->error());
- // Drop use_avatar column from users table
- $db->drop_field('users', 'use_avatar') or error('Unable to drop use_avatar field', __FILE__, __LINE__, $db->error());
- // Drop save_pass column from users table
- $db->drop_field('users', 'save_pass') or error('Unable to drop save_pass field', __FILE__, __LINE__, $db->error());
- // Drop g_edit_subjects_interval column from groups table
- $db->drop_field('groups', 'g_edit_subjects_interval');
- // Add database revision number
- if (!array_key_exists('o_database_revision', $pun_config))
- $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_database_revision\', \'0\')') or error('Unable to insert config value \'o_database_revision\'', __FILE__, __LINE__, $db->error());
- // Add search index revision number
- if (!array_key_exists('o_searchindex_revision', $pun_config))
- $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_searchindex_revision\', \'0\')') or error('Unable to insert config value \'o_searchindex_revision\'', __FILE__, __LINE__, $db->error());
- // Add parser revision number
- if (!array_key_exists('o_parser_revision', $pun_config))
- $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_parser_revision\', \'0\')') or error('Unable to insert config value \'o_parser_revision\'', __FILE__, __LINE__, $db->error());
- // Add default email setting option
- if (!array_key_exists('o_default_email_setting', $pun_config))
- $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_default_email_setting\', \'1\')') or error('Unable to insert config value \'o_default_email_setting\'', __FILE__, __LINE__, $db->error());
- // Make sure we have o_additional_navlinks (was added in 1.2.1)
- if (!array_key_exists('o_additional_navlinks', $pun_config))
- $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_additional_navlinks\', \'\')') or error('Unable to insert config value \'o_additional_navlinks\'', __FILE__, __LINE__, $db->error());
- // Insert new config option o_topic_views
- if (!array_key_exists('o_topic_views', $pun_config))
- $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_topic_views\', \'1\')') or error('Unable to insert config value \'o_topic_views\'', __FILE__, __LINE__, $db->error());
- // Insert new config option o_signatures
- if (!array_key_exists('o_signatures', $pun_config))
- $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_signatures\', \'1\')') or error('Unable to insert config value \'o_signatures\'', __FILE__, __LINE__, $db->error());
- // Insert new config option o_smtp_ssl
- if (!array_key_exists('o_smtp_ssl', $pun_config))
- $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_smtp_ssl\', \'0\')') or error('Unable to insert config value \'o_smtp_ssl\'', __FILE__, __LINE__, $db->error());
- // Insert new config option o_default_dst
- if (!array_key_exists('o_default_dst', $pun_config))
- $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_default_dst\', \'0\')') or error('Unable to insert config value \'o_default_dst\'', __FILE__, __LINE__, $db->error());
- // Insert new config option o_quote_depth
- if (!array_key_exists('o_quote_depth', $pun_config))
- $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_quote_depth\', \'3\')') or error('Unable to insert config value \'o_quote_depth\'', __FILE__, __LINE__, $db->error());
- // Insert new config option o_feed_type
- if (!array_key_exists('o_feed_type', $pun_config))
- $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_feed_type\', \'2\')') or error('Unable to i…
Large files files are truncated, but you can click here to view the full file