Code: Selecteer alles
<?php
/***************************************************************************
* install.php
* -----------
* begin : 08/10/2004
* copyright : Ptirhiik
* email : ptirhiik@clanmckeen.com
*
* Version : 0.0.8 - 19/01/2005
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
define('IN_PHPBB', true);
define('IN_INSTALL', true);
$phpbb_root_path = './../';
include($phpbb_root_path . 'extension.inc');
//--------------------------
include($phpbb_root_path . 'config.' . $phpEx);
include($phpbb_root_path . 'common.'.$phpEx);
include($config->url('includes/class_forums'));
include($config->url('includes/class_cp'));
// try to modify the database
if ( defined('RUN_CH_INSTALL') )
{
$sql_struct = array();
switch( SQL_LAYER )
{
case 'mysql':
case 'mysql4':
$sql_struct = array(
// forums
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_type CHAR(1) BINARY NOT NULL DEFAULT \'f\' AFTER forum_status',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_main SMALLINT(5) UNSIGNED NOT NULL AFTER forum_status',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD auth_global_announce TINYINT( 2 ) NOT NULL AFTER auth_announce',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_last_title VARCHAR( 255 )',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_last_poster MEDIUMINT( 8 ) NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_last_username VARCHAR( 25 )',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_last_time INT( 11 ) NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_link VARCHAR( 255 )',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_link_hit_count TINYINT( 1 ) NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_link_hit BIGINT(20) UNSIGNED NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_link_start INT(11) NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_style TINYINT( 4 ) NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_nav_icon VARCHAR( 255 )',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_icon VARCHAR( 255 )',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_topics_ppage TINYINT( 2 ) NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_topics_sort VARCHAR( 25 )',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_topics_order VARCHAR( 4 )',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_index_pack TINYINT( 1 ) NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_index_split TINYINT( 1 ) NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_board_box TINYINT( 1 ) NOT NULL',
// auths
'ALTER TABLE ' . AUTH_ACCESS_TABLE . ' ADD auth_global_announce TINYINT( 1 ) NOT NULL AFTER auth_announce',
// auths definitions
'CREATE TABLE ' . AUTHS_DEF_TABLE . ' (
auth_id SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
auth_type CHAR(1) BINARY NOT NULL DEFAULT \'\',
auth_name VARCHAR(50) NOT NULL DEFAULT \'\',
auth_desc VARCHAR(255) NOT NULL DEFAULT \'\',
auth_title TINYINT(1) NOT NULL DEFAULT \'0\',
auth_order MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT \'0\',
PRIMARY KEY (auth_id)
)',
// topics
'ALTER TABLE ' . TOPICS_TABLE . ' ADD topic_sub_title VARCHAR( 255 ) DEFAULT NULL',
'ALTER TABLE ' . TOPICS_TABLE . ' ADD topic_first_username VARCHAR( 25 )',
'ALTER TABLE ' . TOPICS_TABLE . ' ADD topic_last_poster MEDIUMINT( 8 ) NOT NULL',
'ALTER TABLE ' . TOPICS_TABLE . ' ADD topic_last_username VARCHAR( 25 )',
'ALTER TABLE ' . TOPICS_TABLE . ' ADD topic_last_time INT( 11 ) NOT NULL',
'ALTER TABLE ' . TOPICS_TABLE . ' ADD topic_icon SMALLINT( 3 ) UNSIGNED NOT NULL',
'ALTER TABLE ' . TOPICS_TABLE . ' ADD topic_duration INT( 11 ) NOT NULL',
'ALTER TABLE ' . TOPICS_TABLE . ' CHANGE topic_title topic_title VARCHAR( 255 ) NOT NULL',
// posts
'ALTER TABLE ' . POSTS_TABLE . ' ADD post_icon SMALLINT( 3 ) UNSIGNED NOT NULL',
// posts text
'ALTER TABLE ' . POSTS_TEXT_TABLE . ' ADD post_sub_title VARCHAR( 255 ) DEFAULT NULL',
'ALTER TABLE ' . POSTS_TEXT_TABLE . ' CHANGE post_subject post_subject VARCHAR( 255 ) DEFAULT NULL',
// users
'ALTER TABLE ' . USERS_TABLE . ' ADD user_unread_date INT( 11 ) NOT NULL',
'ALTER TABLE ' . USERS_TABLE . ' ADD user_unread_topics TEXT',
'ALTER TABLE ' . USERS_TABLE . ' ADD user_keep_unreads TINYINT( 1 ) NOT NULL',
'ALTER TABLE ' . USERS_TABLE . ' ADD user_topics_sort VARCHAR( 25 ) NOT NULL',
'ALTER TABLE ' . USERS_TABLE . ' ADD user_topics_order VARCHAR( 4 ) NOT NULL',
'ALTER TABLE ' . USERS_TABLE . ' ADD user_smart_date TINYINT( 1 ) NOT NULL',
'ALTER TABLE ' . USERS_TABLE . ' ADD user_board_box TINYINT( 1 ) NOT NULL',
'ALTER TABLE ' . USERS_TABLE . ' ADD user_index_pack TINYINT( 1 ) NOT NULL',
'ALTER TABLE ' . USERS_TABLE . ' ADD user_index_split TINYINT( 1 ) NOT NULL',
'ALTER TABLE ' . USERS_TABLE . ' ADD user_session_logged TINYINT( 1 ) NOT NULL',
// groups
'ALTER TABLE ' . GROUPS_TABLE . ' ADD group_status TINYINT( 2 ) NOT NULL',
'ALTER TABLE ' . GROUPS_TABLE . ' ADD group_user_id MEDIUMINT( 8 ) DEFAULT 0 NOT NULL',
'ALTER TABLE ' . GROUPS_TABLE . ' ADD group_user_list TEXT NOT NULL',
// styles
'ALTER TABLE ' . THEMES_TABLE . ' ADD images_pack VARCHAR( 100 ) NOT NULL AFTER style_name',
'ALTER TABLE ' . THEMES_TABLE . ' ADD custom_tpls VARCHAR( 100 ) NOT NULL AFTER images_pack',
// user cache
'CREATE TABLE ' . USERS_CACHE_TABLE . ' (
user_id MEDIUMINT(8) NOT NULL,
cache_id VARCHAR(5) NOT NULL,
cache_data TEXT,
cache_time INT(11),
PRIMARY KEY ( user_id, cache_id )
)',
// presets names
'CREATE TABLE ' . PRESETS_TABLE . ' (
preset_id MEDIUMINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
preset_type VARCHAR(5) NOT NULL DEFAULT \'\',
preset_name VARCHAR(50) NOT NULL DEFAULT \'\',
PRIMARY KEY ( preset_id )
)',
// presets data
'CREATE TABLE ' . PRESETS_DATA_TABLE . ' (
preset_id MEDIUMINT(5) UNSIGNED NOT NULL DEFAULT \'0\',
preset_auth VARCHAR(50) NOT NULL DEFAULT \'\',
preset_value TINYINT(1) DEFAULT NULL,
PRIMARY KEY ( preset_id, preset_auth )
)',
// messages icons
'CREATE TABLE ' . ICONS_TABLE . ' (
icon_id MEDIUMINT(3) NOT NULL AUTO_INCREMENT,
icon_name VARCHAR(50) NOT NULL DEFAULT \'\',
icon_url VARCHAR(255) NOT NULL DEFAULT \'\',
icon_acl TINYINT(2) NOT NULL DEFAULT \'0\',
icon_types VARCHAR(255) DEFAULT NULL,
icon_order MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT \'0\',
PRIMARY KEY (icon_id)
)',
// control panels fields
'CREATE TABLE ' . CP_FIELDS_TABLE . ' (
field_id MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
field_name VARCHAR(50) NOT NULL DEFAULT \'\',
panel_id MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT \'0\',
field_order MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT \'0\',
field_attr TEXT NOT NULL,
PRIMARY KEY (field_id),
KEY panel_id (panel_id,field_name)
)',
// control panels defs
'CREATE TABLE ' . CP_PANELS_TABLE . ' (
panel_id MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
panel_shortcut VARCHAR(30) NOT NULL DEFAULT \'\',
panel_name VARCHAR(50) NOT NULL DEFAULT \'\',
panel_main MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT \'0\',
panel_order MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT \'0\',
panel_file VARCHAR(50) NOT NULL DEFAULT \'\',
panel_auth_type CHAR(1) BINARY NOT NULL DEFAULT \'\',
panel_auth_name VARCHAR(50) NOT NULL DEFAULT \'\',
panel_hidden TINYINT(1) NOT NULL DEFAULT \'0\',
PRIMARY KEY (panel_id)
)',
// control panels patches
'CREATE TABLE ' . CP_PATCHES_TABLE . ' (
patch_id MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
patch_file VARCHAR(255) NOT NULL DEFAULT \'\',
patch_time int(11) NOT NULL DEFAULT \'0\',
patch_version VARCHAR(25) NOT NULL DEFAULT \'\',
patch_date VARCHAR(8) NOT NULL DEFAULT \'\',
patch_ref VARCHAR(255) NOT NULL DEFAULT \'\',
patch_author VARCHAR(255) NOT NULL DEFAULT \'\',
PRIMARY KEY (patch_id)
)',
// extended auths table
'CREATE TABLE ' . AUTHS_TABLE . ' (
group_id MEDIUMINT(8) NOT NULL DEFAULT \'0\',
obj_type CHAR(1) BINARY NOT NULL DEFAULT \'\',
obj_id MEDIUMINT(8) NOT NULL DEFAULT \'0\',
auth_name VARCHAR(50) NOT NULL DEFAULT \'\',
auth_value TINYINT(1) NOT NULL DEFAULT \'0\',
PRIMARY KEY (group_id,obj_type,obj_id,auth_name),
KEY group_id (group_id,obj_type),
KEY obj_type (obj_type,obj_id)
)',
// config
'ALTER TABLE ' . CONFIG_TABLE . ' ADD config_static SMALLINT(1) UNSIGNED NOT NULL DEFAULT 0',
// indexes addition
'ALTER TABLE ' . TOPICS_TABLE . ' ADD INDEX ( topic_last_time )',
'ALTER TABLE ' . POSTS_TABLE . ' ADD INDEX ( post_icon )',
'ALTER TABLE ' . GROUPS_TABLE . ' ADD INDEX ( group_user_id )',
'ALTER TABLE ' . CONFIG_TABLE . ' ADD INDEX ( config_static )',
);
break;
case 'mssql':
case 'mssql-odbc':
$sql_struct = array(
// forums
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_type CHAR(1) NOT NULL DEFAULT \'f\'',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_main SMALLINT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD auth_global_announce SMALLINT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_last_title VARCHAR( 255 )',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_last_poster BIGINT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_last_username VARCHAR( 25 )',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_last_time INT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_link VARCHAR( 255 )',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_link_hit_count SMALLINT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_link_hit BIGINT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_link_start INT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_style SMALLINT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_nav_icon VARCHAR( 255 )',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_icon VARCHAR( 255 )',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_topics_ppage SMALLINT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_topics_sort VARCHAR( 25 )',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_topics_order VARCHAR( 4 )',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_index_pack SMALLINT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_index_split SMALLINT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . FORUMS_TABLE . ' ADD forum_board_box SMALLINT DEFAULT 0 NOT NULL',
// auths
'ALTER TABLE ' . AUTH_ACCESS_TABLE . ' ADD auth_global_announce SMALLINT DEFAULT 0 NOT NULL',
# auths definitions
'CREATE TABLE ' . AUTHS_DEF_TABLE . ' (
auth_id SMALLINT NOT NULL IDENTITY (1,1),
auth_type CHAR(1) NOT NULL DEFAULT \'\',
auth_name VARCHAR(50) NOT NULL DEFAULT \'\',
auth_desc VARCHAR(255) NOT NULL DEFAULT \'\',
auth_title SMALLINT NOT NULL DEFAULT 0,
auth_order BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (auth_id)
)',
# topics
'ALTER TABLE ' . TOPICS_TABLE . ' ADD topic_sub_title VARCHAR( 255 ) DEFAULT NULL',
'ALTER TABLE ' . TOPICS_TABLE . ' ADD topic_first_username VARCHAR( 25 )',
'ALTER TABLE ' . TOPICS_TABLE . ' ADD topic_last_poster BIGINT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . TOPICS_TABLE . ' ADD topic_last_username VARCHAR( 25 )',
'ALTER TABLE ' . TOPICS_TABLE . ' ADD topic_last_time INT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . TOPICS_TABLE . ' ADD topic_icon SMALLINT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . TOPICS_TABLE . ' ADD topic_duration INT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . TOPICS_TABLE . ' CHANGE topic_title topic_title VARCHAR( 255 ) DEFAULT \'\' NOT NULL',
# posts
'ALTER TABLE ' . POSTS_TABLE . ' ADD post_icon SMALLINT DEFAULT 0 NOT NULL',
# posts text
'ALTER TABLE ' . POSTS_TEXT_TABLE . ' ADD post_sub_title VARCHAR( 255 ) DEFAULT NULL',
'ALTER TABLE ' . POSTS_TEXT_TABLE . ' CHANGE post_subject post_subject VARCHAR( 255 ) DEFAULT NULL',
# users
'ALTER TABLE ' . USERS_TABLE . ' ADD user_unread_date INT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . USERS_TABLE . ' ADD user_unread_topics TEXT',
'ALTER TABLE ' . USERS_TABLE . ' ADD user_keep_unreads SMALLINT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . USERS_TABLE . ' ADD user_topics_sort VARCHAR( 25 ) DEFAULT \'\' NOT NULL',
'ALTER TABLE ' . USERS_TABLE . ' ADD user_topics_order VARCHAR( 4 ) DEFAULT \'\' NOT NULL',
'ALTER TABLE ' . USERS_TABLE . ' ADD user_smart_date SMALLINT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . USERS_TABLE . ' ADD user_board_box SMALLINT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . USERS_TABLE . ' ADD user_index_pack SMALLINT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . USERS_TABLE . ' ADD user_index_split SMALLINT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . USERS_TABLE . ' ADD user_session_logged SMALLINT DEFAULT 0 NOT NULL',
# groups
'ALTER TABLE ' . GROUPS_TABLE . ' ADD group_status SMALLINT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . GROUPS_TABLE . ' ADD group_user_id BIGINT DEFAULT 0 NOT NULL',
'ALTER TABLE ' . GROUPS_TABLE . ' ADD group_user_list TEXT DEFAULT \'\' NOT NULL',
# styles
'ALTER TABLE ' . THEMES_TABLE . ' ADD images_pack VARCHAR( 100 ) DEFAULT \'\' NOT NULL',
'ALTER TABLE ' . THEMES_TABLE . ' ADD custom_tpls VARCHAR( 100 ) DEFAULT \'\' NOT NULL',
# user cache
'CREATE TABLE ' . USERS_CACHE_TABLE . ' (
user_id BIGINT DEFAULT 0 NOT NULL,
cache_id VARCHAR(5) DEFAULT \'\' NOT NULL,
cache_data TEXT,
cache_time INT,
PRIMARY KEY ( user_id, cache_id )
)',
# presets names
'CREATE TABLE ' . PRESETS_TABLE . ' (
preset_id BIGINT NOT NULL IDENTITY (1,1),
preset_type VARCHAR(5) NOT NULL DEFAULT \'\',
preset_name VARCHAR(50) NOT NULL DEFAULT \'\',
PRIMARY KEY ( preset_id )
)',
# presets data
'CREATE TABLE ' . PRESETS_DATA_TABLE . ' (
preset_id BIGINT NOT NULL DEFAULT \'0\',
preset_auth VARCHAR(50) NOT NULL DEFAULT \'\',
preset_value SMALLINT DEFAULT NULL,
PRIMARY KEY ( preset_id, preset_auth )
)',
# messages icons
'CREATE TABLE ' . ICONS_TABLE . ' (
icon_id BIGINT NOT NULL IDENTITY (1,1),
icon_name VARCHAR(50) NOT NULL DEFAULT \'\',
icon_url VARCHAR(255) NOT NULL DEFAULT \'\',
icon_acl SMALLINT NOT NULL DEFAULT \'0\',
icon_types VARCHAR(255) DEFAULT NULL,
icon_order BIGINT NOT NULL DEFAULT \'0\',
PRIMARY KEY (icon_id)
)',
# control panels fields
'CREATE TABLE ' . CP_FIELDS_TABLE . ' (
field_id BIGINT NOT NULL IDENTITY (1,1),
field_name VARCHAR(50) NOT NULL DEFAULT \'\',
panel_id BIGINT NOT NULL DEFAULT \'0\',
field_order BIGINT NOT NULL DEFAULT \'0\',
field_attr TEXT DEFAULT \'\' NOT NULL,
PRIMARY KEY (field_id)
)',
# control panels defs
'CREATE TABLE ' . CP_PANELS_TABLE . ' (
panel_id BIGINT NOT NULL IDENTITY (1,1),
panel_shortcut VARCHAR(30) NOT NULL DEFAULT \'\',
panel_name VARCHAR(50) NOT NULL DEFAULT \'\',
panel_main BIGINT NOT NULL DEFAULT \'0\',
panel_order BIGINT NOT NULL DEFAULT \'0\',
panel_file VARCHAR(50) NOT NULL DEFAULT \'\',
panel_auth_type CHAR(1) NOT NULL DEFAULT \'\',
panel_auth_name VARCHAR(50) NOT NULL DEFAULT \'\',
panel_hidden SMALLINT NOT NULL DEFAULT \'0\',
PRIMARY KEY (panel_id)
)',
# control panels patches
'CREATE TABLE ' . CP_PATCHES_TABLE . ' (
patch_id BIGINT NOT NULL IDENTITY (1,1),
patch_file VARCHAR(255) NOT NULL DEFAULT \'\',
patch_time INT NOT NULL DEFAULT \'0\',
patch_version VARCHAR(25) NOT NULL DEFAULT \'\',
patch_date VARCHAR(8) NOT NULL DEFAULT \'\',
patch_ref VARCHAR(255) NOT NULL DEFAULT \'\',
patch_author VARCHAR(255) NOT NULL DEFAULT \'\',
PRIMARY KEY (patch_id)
)',
# extended auths table
'CREATE TABLE ' . AUTHS_TABLE . ' (
group_id BIGINT NOT NULL DEFAULT \'0\',
obj_type CHAR(1) NOT NULL DEFAULT \'\',
obj_id BIGINT NOT NULL DEFAULT \'0\',
auth_name VARCHAR(50) NOT NULL DEFAULT \'\',
auth_value SMALLINT NOT NULL DEFAULT \'0\',
PRIMARY KEY (group_id,obj_type,obj_id,auth_name)
)',
# config
'ALTER TABLE ' . CONFIG_TABLE . ' ADD config_static SMALLINT NOT NULL DEFAULT 0',
# indexes addition
'CREATE INDEX [IX_cp_fields_CH_1] ON [' . CP_FIELDS_TABLE . ']([panel_id], [field_name]) ON [PRIMARY]',
'CREATE INDEX [IX_auths_CH_1] ON [' . AUTHS_TABLE . ']([group_id], [obj_type]) ON [PRIMARY]',
'CREATE INDEX [IX_auths_CH_2] ON [' . AUTHS_TABLE . ']([obj_type], [obj_id]) ON [PRIMARY]',
'CREATE INDEX [IX_topics_CH_1] ON [' . TOPICS_TABLE . ']([topic_last_time]) ON [PRIMARY]',
'CREATE INDEX [IX_posts_CH_1] ON [' . POSTS_TABLE . ']([post_icon]) ON [PRIMARY]',
'CREATE INDEX [IX_groups_CH_1] ON [' . GROUPS_TABLE . ']([group_user_id]) ON [PRIMARY]',
'CREATE INDEX [IX_config_CH_1] ON [' . CONFIG_TABLE . ']([config_static]) ON [PRIMARY]',
);
break;
default:
die('Please run the SQL part from the mod installation description txt');
break;
}
// run sql modifications
$count_sql_struct = count($sql_struct);
for ( $i = 0; $i < $count_sql_struct; $i++ )
{
$sql = $sql_struct[$i];
if ( !$db->sql_query($sql, false, __LINE__, __FILE__, false) )
{
_output('Modification failed (may be already done) : ' . $sql);
}
}
// read config table
$config->read();
}
//--------------------------
function reorder($forum_id=0)
{
global $subs, $ordered;
$ordered[] = $forum_id;
$count_subs = count($subs[$forum_id]);
for ( $i = 0; $i < $count_subs; $i++ )
{
reorder($subs[$forum_id][$i]);
}
}
function _output($message, $location='', $line='', $file='')
{
echo '<div class="gensmall"><textarea rows="5" cols="100" wrap="virtual">' . ( empty($location) ? '' : '<u><b>location:</b> ' . $location . '</u>' . ( empty($line) ? '' : ' line: ' . $line ) . ( empty($file) ? '' : ' file: ' . $file ) . '<br />');
if ( empty($message) )
{
echo 'Empty';
}
else if ( is_array($message) || is_object($message) )
{
print_r($message);
}
else
{
echo str_replace("\t", ' ', htmlspecialchars($message));
}
echo '</textarea></div>';
}
//--------------------------
class admin_auths_def extends auth_class
{
function move($mode, $auth_id)
{
global $db;
if ( !isset($this->data[$auth_id]) )
{
return;
}
// update the asked row
$sql = 'UPDATE ' . AUTHS_DEF_TABLE . '
SET auth_order = auth_order ' . (($mode == 'moveup') ? '-' : '+') . ' 15
WHERE auth_id = ' . intval($auth_id);
$db->sql_query($sql, false, __LINE__, __FILE__);
// renum all
$this->renum();
}
function import($auth_type)
{
global $error, $error_msg;
switch ( $auth_type )
{
case POST_FORUM_URL:
$this->import_forums();
break;
case POST_PANELS_URL:
$this->import_panels();
break;
case POST_GROUPS_URL:
$this->import_groups();
break;
default:
_error('No_such_auth_type');
break;
}
$this->renum();
}
function import_forums()
{
global $error, $error_msg;
global $db, $config, $user;
// get the max order for the type
$order = 0;
if ( !empty($this->keys[POST_FORUM_URL]) )
{
$tkeys = array_keys($this->keys[POST_FORUM_URL]);
$order = $this->data[ $this->keys[POST_FORUM_URL][ $tkeys[(count($tkeys)-1)] ] ]['auth_order'];
unset($tkeys);
}
// get auths def from forums
include_once($config->url('includes/auth'));
$req_auths_def = get_forums_auths_def();
$no_req_auths_def = array('auth_mod', 'auth_mod_display', 'auth_manage');
$auths_def = array_merge($req_auths_def, $no_req_auths_def);
$count_auths_def = count($auths_def);
// create or update the entries
$db->sql_stack_reset();
$auth_names = array();
for ( $i = 0; $i < $count_auths_def; $i++ )
{
if ( !isset($this->keys[POST_FORUM_URL][ $auths_def[$i] ]) )
{
$order += 10;
$fields = array(
'auth_type' => POST_FORUM_URL,
'auth_name' => $auths_def[$i],
'auth_desc' => ($user->lang($auth_name) != $auth_name) ? $auths_def[$i] : '',
'auth_title' => false,
'auth_order' => $order,
);
$auth_names[] = $auths_def[$i];
$db->sql_stack_statement($fields);
}
}
if ( !empty($db->sql_stack_values) )
{
$db->sql_stack_insert(AUTHS_DEF_TABLE, false, __LINE__, __FILE__);
$this->read(true);
_error('Forums_auths_def_imported');
}
else
{
_error('Forums_auths_def_done');
}
// some requirements have been added : migrate the auths
if ( !empty($auth_names) )
{
$count_auth_names = count($auth_names);
// read authed groups
$sql = 'SELECT *
FROM ' . AUTH_ACCESS_TABLE . '
ORDER BY forum_id';
$result = $db->sql_query($sql, false, __LINE__, __FILE__);
$acls = array();
while ( $row = $db->sql_fetchrow($result) )
{
for ( $i = 0; $i < $count_auth_names; $i++ )
{
$auth_name = $auth_names[$i];
// adjust some auths
if ( $auth_name = 'auth_mod_display' )
{
$row[$auth_name] = $row['auth_mod'];
}
if ( $row[$auth_name] )
{
if ( !isset($acls[ intval($row['forum_id']) ]) )
{
$acls[ $row['forum_id'] ] = array();
}
if ( !isset($acls[ intval($row['forum_id']) ][$auth_name]) )
{
$acls[ intval($row['forum_id']) ][$auth_name] = array();
}
$acls[ intval($row['forum_id']) ][$auth_name][] = intval($row['group_id']);
}
}
}
$db->sql_freeresult($result);
// get forums auths requirements
$t_auth_names = array_flip($auth_names);
$count_no_req_auths_def = count($no_req_auths_def);
for ( $i = 0; $i < $count_no_req_auths_def; $i++ )
{
if ( isset($t_auth_names[ $no_req_auths_def[$i] ]) )
{
unset($t_auth_names[ $no_req_auths_def[$i] ]);
}
}
$t_auth_names = array_flip($t_auth_names);
$sql = 'SELECT forum_id' . (empty($t_auth_names) ? '' : ', ' . implode(', ', $t_auth_names)) . '
FROM ' . FORUMS_TABLE;
$result = $db->sql_query($sql, false, __LINE__, __FILE__);
$db->sql_stack_reset();
while ( $row = $db->sql_fetchrow($result) )
{
// check requirements
for ( $i = 0; $i < $count_auth_names; $i++ )
{
switch ( $auth_names[$i] )
{
case 'auth_mod':
$auth_req = AUTH_ACL;
break;
case 'auth_mod_display':
$auth_req = AUTH_MOD;
break;
case 'auth_manage':
$auth_req = AUTH_ADMIN;
break;
default:
$auth_req = $row[ $auth_names[$i] ];
break;
}
$group_ids = array();
switch ( $auth_req )
{
case AUTH_ALL:
$group_ids[] = GROUP_ANONYMOUS;
case AUTH_REG:
$group_ids[] = GROUP_REGISTERED;
break;
case AUTH_MOD:
case AUTH_ACL:
$auth_name = ($auth_req == AUTH_MOD) ? 'auth_mod' : $auth_names[$i];
if ( !empty($acls[ intval($row['forum_id']) ][$auth_name]) )
{
$group_ids = $acls[ intval($row['forum_id']) ][$auth_name];
}
// we don't want to display admin as moderators
if ( $auth_names[$i] == 'auth_mod_display' )
{
break;
}
case AUTH_ADMIN:
$group_ids[] = GROUP_ADMIN;
break;
}
// build the sql request
if ( !empty($group_ids) )
{
$count_group_ids = count($group_ids);
for ( $j = 0; $j < $count_group_ids; $j++ )
{
$fields = array(
'group_id' => $group_ids[$j],
'obj_type' => POST_FORUM_URL,
'obj_id' => intval($row['forum_id']),
'auth_name' => $auth_names[$i],
'auth_value' => true,
);
$db->sql_stack_statement($fields);
}
}
}
}
$db->sql_freeresult($result);
// create the auths access
if ( !empty($db->sql_stack_values) )
{
$db->sql_stack_insert(AUTHS_TABLE, false, __LINE__, __FILE__);
_error('Forums_auths_imported');
// clear the caches
$sql = 'DELETE FROM ' . USERS_CACHE_TABLE . '
WHERE cache_id LIKE \'' . POST_FORUM_URL . '%\'';
$db->sql_query($sql, false, __LINE__, __FILE__);
// update the forums requirements to AUTH_ACL
$fields = array();
$count_req_auths_def = count($req_auths_def);
for ( $i = 0; $i < $count_req_auths_def; $i++ )
{
$fields[ $req_auths_def[$i] ] = AUTH_ACL;
}
$db->sql_statement($fields);
if ( !empty($fields) )
{
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET ' . $db->sql_update;
$db->sql_query($sql, false, __LINE__, __FILE__);
}
// clear the auths access table to prevent access by a script addressing directly the auths access table
// $sql = 'DELETE FROM ' . AUTH_ACCESS_TABLE;
// $db->sql_query($sql, false, __LINE__, __FILE__);
// update mods status
$moderators = new moderators();
$moderators->set_users_status();
$moderators->read(true);
}
}
}
function import_panels()
{
global $db, $user;
global $error, $error_msg;
// get the max order for the type
$order = 0;
if ( !empty($this->keys[POST_PANELS_URL]) )
{
$tkeys = array_keys($this->keys[POST_PANELS_URL]);
$order = $this->data[ $this->keys[POST_PANELS_URL][ $tkeys[(count($tkeys)-1)] ] ]['auth_order'];
unset($tkeys);
}
// read all panels having auths
$sql = 'SELECT DISTINCT panel_auth_name
FROM ' . CP_PANELS_TABLE . '
WHERE panel_auth_type = \'' . POST_PANELS_URL . '\'
AND panel_auth_name <> \'\'
GROUP BY panel_auth_name';
$result = $db->sql_query($sql, false, __LINE__, __FILE__);
$db->sql_stack_reset();
while ( $row = $db->sql_fetchrow($result) )
{
if ( !isset($this->keys[POST_PANELS_URL][ $row['panel_auth_name'] ]) )
{
$order += 10;
$fields = array(
'auth_type' => POST_PANELS_URL,
'auth_name' => $row['panel_auth_name'],
'auth_desc' => ($user->lang($row['panel_auth_name']) != $row['panel_auth_name']) ? $row['panel_auth_name'] : '',
'auth_title' => false,
'auth_order' => $order,
);
// prepare insert rows
$db->sql_stack_statement($fields);
}
}
if ( !empty($db->sql_stack_values) )
{
$db->sql_stack_insert(AUTHS_DEF_TABLE, false, __LINE__, __FILE__);
$this->read(true);
_error('Panels_auths_def_imported');
}
else
{
_error('Panels_auths_def_done');
}
}
function import_groups()
{
global $db, $user;
global $error, $error_msg;
// get the max order for the type
$order = 0;
if ( !empty($this->keys[POST_GROUPS_URL]) )
{
$tkeys = array_keys($this->keys[POST_GROUPS_URL]);
$order = $this->data[ $this->keys[POST_GROUPS_URL][ $tkeys[(count($tkeys)-1)] ] ]['auth_order'];
unset($tkeys);
}
// get all groups auths def
$auths_def = array();
// read all panels having auths
$sql = 'SELECT DISTINCT panel_auth_name
FROM ' . CP_PANELS_TABLE . '
WHERE panel_auth_type = \'' . POST_GROUPS_URL . '\'
AND panel_auth_name <> \'\'
GROUP BY panel_auth_name';
$result = $db->sql_query($sql, false, __LINE__, __FILE__);
while ( $row = $db->sql_fetchrow($result) )
{
if ( !isset($this->keys[POST_GROUPS_URL][ $row['panel_auth_name'] ]) )
{
$auths_def[ $row['panel_auth_name'] ] = true;
}
}
// get also auths sat on fields
$sql = 'SELECT field_attr
FROM ' . CP_FIELDS_TABLE . '
WHERE field_attr LIKE \'%field_auth%\'
AND field_name <> \'\'';
$result = $db->sql_query($sql, false, __LINE__, __FILE__);
while ( $row = $db->sql_fetchrow($result) )
{
// unpack data
$field = unserialize(stripslashes($row['field_attr']));
// check auths
if ( !empty($field['field_auth']) && !isset($this->keys[POST_GROUPS_URL][ $field['field_auth'] ]) )
{
$auths_def[ $field['field_auth'] ] = true;
}
}
// prepare auths defs creation
$db->sql_stack_reset();
if ( !empty($auths_def) )
{
foreach ( $auths_def as $auth_name => $dummy )
{
$order += 10;
$fields = array(
'auth_type' => POST_GROUPS_URL,
'auth_name' => $auth_name,
'auth_desc' => ($user->lang($auth_name) != $auth_name) ? $auth_name : '',
'auth_title' => false,
'auth_order' => $order,
);
// prepare insert rows
$db->sql_stack_statement($fields);
}
}
// create the relevant added auths def
if ( !empty($db->sql_stack_values) )
{
$db->sql_stack_insert(AUTHS_DEF_TABLE, false, __LINE__, __FILE__);
$this->read(true);
_error('Groups_auths_def_imported');
}
else
{
_error('Groups_auths_def_done');
}
}
}
//--------------------------
//
// Start session management
//
$userdata = session_pagestart($user_ip, -1);
init_userprefs($userdata);
if ( $userdata['user_level'] != ADMIN )
{
if ( !$user->data['session_logged_in'] )
{
header('Location: ./../login.' . $config->ext . '?redirect=./install_cat/install.' . $config->ext);
exit;
}
else
{
die('<hr />The board is currently under maintenance : please retry later. <br /><br />Sorry for the inconvenience, <br />the management.<hr />');
}
}
//
// End session management
//
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $lang['ENCODING']; ?>">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>Categories hierarchy 2.1.0 migration tool</title>
<style type="text/css">
<!--
font,th,td,p { font-family: Verdana, Arial, Helvetica, sans-serif }
.gen {font-size: 12px}
.gensmall {font-size: 11px}
hr { height: 0px; border: solid #D1D7DC 0px; border-top-width: 1px;}
.background { background-color: #FFFFFF; border: 1px #98AAB1 solid; }
//-->
</style>
</head>
<body bgcolor="#E5E5E5" text="#000000" link="#006699" vlink="#5584AA">
<table cellpadding="10" cellspacing="1" border="0" class="background" width="100%"><tr><td>
<div align="center" class="background"><br /><br /><u><b><h1>Categories hierarchy 2.1.0 migration tool</h1></b></u><br /><br /></div>
<?php
if ( !_button('submit') )
{
?>
<form method="post" name="form" action="<?php echo $config->url('install_cat/install'); ?>">
<div class="gen" align="center">Welcome to the Categories hierarchy 2.1.0 migration tool.</div><div align="justify" class="gen"><br /><br />
This tool is designed to fill the new fields added by the mod. It will create some new config entries also, you will be able to access through your Administration Control Panel/Forum management, Forum index edition.
This config entries are made to enable or disable a number of new functionalities, so be sure to visit it after having finish the migration :).
<br /><br /><u>if the tool fails with a runtime overflow error (over 30s) during the topic resynchronization, just run it till all the topics will be synchronized</u><br /><br /></justify>
</div><div align="center" class="gen"><br />
If you are ready to proceed, press:<br /><input type="submit" name="submit" value="Go" /><br /><br />
</form>
<?php
}
else
{
?>
<div align="justify" class="gen"><br /><br />
<?php
//--------------------------
// create config values
//--------------------------
echo '<b>Adding config values...</b><br /><br />';
$sql = 'UPDATE ' . CONFIG_TABLE . '
SET config_static = 1
WHERE config_name NOT IN(\'record_online_users\', \'record_online_date\')';
_output($sql);
$db->sql_query($sql, false, __LINE__, __FILE__);
// config set definition
$config_set = array(
// mod : this one will be done at end to always re-enter the config tool if overtime error
// 'mod_cat_hierarchy' => array('config_value' => '2.1.0f', 'config_static' => 1),
// stats
'stat_total_posts' => array('config_value' => 0, 'config_static' => 0),
'stat_total_topics' => array('config_value' => 0, 'config_static' => 0),
'stat_total_users' => array('config_value' => 0, 'config_static' => 0),
'stat_last_user' => array('config_value' => 0, 'config_static' => 0),
'stat_last_username' => array('config_value' => 0, 'config_static' => 0),
// board level
'site_fav_icon' => array('config_value' => 'images/favicon.ico', 'config_static' => 1),
'keep_unreads' => array('config_value' => 0, 'config_static' => 1),
'keep_unreads_over' => array('config_value' => 0, 'config_static' => 1),
'smart_date' => array('config_value' => 1, 'config_static' => 1),
'smart_date_over' => array('config_value' => 0, 'config_static' => 1),
'icons_path' => array('config_value' => 'images/icons/', 'config_static' => 1),
'topics_split_global' => array('config_value' => 0, 'config_static' => 1),
'topics_split_announces' => array('config_value' => 0, 'config_static' => 1),
'topics_split_stickies' => array('config_value' => 0, 'config_static' => 1),
'default_duration' => array('config_value' => 7, 'config_static' => 1),
'pagination_min' => array('config_value' => 5, 'config_static' => 1),
'pagination_max' => array('config_value' => 11, 'config_static' => 1),
'pagination_percent' => array('config_value' => 10, 'config_static' => 1),
'topic_title_length' => array('config_value' => 60, 'config_static' => 1),
'sub_title_length' => array('config_value' => 100, 'config_static' => 1),
// forum level
'index_fav_icon' => array('config_value' => 'images/favicon.gif', 'config_static' => 1),
'topics_sort' => array('config_value' => 'lastpost', 'config_static' => 1),
'topics_order' => array('config_value' => 'DESC', 'config_static' => 1),
'topics_sort_over' => array('config_value' => 0, 'config_static' => 1),
'last_topic_title_length' => array('config_value' => 25, 'config_static' => 1),
'index_pack' => array('config_value' => 0, 'config_static' => 1),
'index_pack_over' => array('config_value' => 0, 'config_static' => 1),
'index_split' => array('config_value' => 0, 'config_static' => 1),
'index_split_over' => array('config_value' => 0, 'config_static' => 1),
'board_box' => array('config_value' => 1, 'config_static' => 1),
'board_box_over' => array('config_value' => 0, 'config_static' => 1),
// cache (cfg cache, cache path & cache key have to remain dynamic)
'cache_key' => array('config_value' => md5(uniqid(rand())), 'config_static' => 0),
'cache_path' => array('config_value' => 'cache/', 'config_static' => 0),
'cache_disabled_cfg' => array('config_value' => 0, 'config_static' => 0),
'cache_disabled_f' => array('config_value' => 0, 'config_static' => 1),
'cache_disabled_mods' => array('config_value' => 0, 'config_static' => 1),
'cache_disabled_themes' => array('config_value' => 0, 'config_static' => 1),
'cache_disabled_ranks' => array('config_value' => 0, 'config_static' => 1),
'cache_disabled_words' => array('config_value' => 0, 'config_static' => 1),
'cache_disabled_smilies' => array('config_value' => 0, 'config_static' => 1),
'cache_disabled_icons' => array('config_value' => 0, 'config_static' => 1),
'cache_disabled_cp_patches' => array('config_value' => 0, 'config_static' => 1),
'cache_disabled_cp_panels' => array('config_value' => 0, 'config_static' => 1),
// users caches level time markers
'cache_time_f' => array('config_value' => 0, 'config_static' => 1),
'cache_time_m' => array('config_value' => 0, 'config_static' => 1),
'cache_time_g' => array('config_value' => 0, 'config_static' => 1),
'cache_time_fjbox' => array('config_value' => 0, 'config_static' => 1),
// template cache
'cache_disabled_template' => array('config_value' => 0, 'config_static' => 1),
'cache_check_template' => array('config_value' => 1, 'config_static' => 1),
);
// do some cleaning
$sql = 'DELETE FROM ' . CONFIG_TABLE . '
WHERE config_name IN(\'' . implode('\', \'', array_keys($config_set)) . '\')';
$db->sql_query($sql, false, __LINE__, __FILE__);
// re insert config data
$count_config_set = count($config_set);
$db->sql_stack_reset();
foreach ( $config_set as $config_name => $config_data )
{
$fields = array(
'config_name' => $config_name,
'config_value' => $config_data['config_value'],
'config_static' => $config_data['config_static'],
);
$db->sql_stack_statement($fields);
}
$db->sql_stack_insert(CONFIG_TABLE, false, __LINE__, __FILE__);
// recache
$config->read(true);
echo '... config values has been added.<br /><hr /><br /><br />';
//--------------------------
// cats/forums migration
//--------------------------
echo '<b>Creating forums with the categories...</b><br /><br />';
$sql = 'SELECT *
FROM ' . CATEGORIES_TABLE . '
WHERE cat_order <> 0
ORDER BY cat_order';
_output($sql);
$result = $db->sql_query($sql, false, __LINE__, __FILE__);
$cats = array();
while ( $row = $db->sql_fetchrow($result) )
{
$cats[ $row['cat_id'] ] = $row;
}
if ( empty($cats) )
{
echo '--- forums already created<br /><br /><hr /><br /><br />';
}
else
{
// Was a previous version of categories hierarchy installed ?
$c_cat_hierarchy = $f_cat_hierarchy = false;
// cat attached to forum or cat
$sql = 'SELECT cat_main
FROM ' . CATEGORIES_TABLE . '
LIMIT 1';
_output($sql);
$c_cat_hierarchy = ($res = $db->sql_query($sql, false, __LINE__, __FILE__, false));
// forum attached to a forum
if ( $c_cat_hierarchy )
{
$sql = 'SELECT main_type
FROM ' . FORUMS_TABLE . '
LIMIT 1';
_output($sql);
$f_cat_hierarchy = ($res = $db->sql_query($sql, false, __LINE__, __FILE__, false));
echo '--- info: a previous version of Categories hierarchy has been detected<br /><br />';
}
//
// process the cats
//
$sql = 'SELECT MAX(forum_id) as last_forum_id
FROM ' . FORUMS_TABLE;
_output($sql);
$result = $db->sql_query($sql, false, __LINE__, __FILE__);
$row = $db->sql_fetchrow($result);
$forum_id = intval($row['last_forum_id']);
$db->sql_stack_reset();
foreach ( $cats as $cat_id => $cat )
{
$forum_id++;
$cat['forum_id'] = $forum_id;
$cats[$cat_id] = $cat;
$fields = array(
'forum_id' => $cat['forum_id'],
'forum_name' => $cat['cat_title'],
'forum_main' => 0,
'forum_type' => POST_CAT_URL,
'forum_order' => 0,
);
// recover the previous hierarchy
if ( $c_cat_hierarchy )
{
$fields['forum_order'] = intval($cat['cat_order']);
if ( !empty($cat['cat_main']) )
{
if ( $cat['cat_main_type'] == POST_FORUM_URL )
{
$fields['forum_main'] = intval($cat['cat_main']);
}
else if ( isset($cats[ intval($cat['cat_main']) ]) )
{
$fields['forum_main'] = intval($cats[ intval($cat['cat_main']) ]['forum_id']);
}
}
}
// add to the insert statement
$db->sql_stack_statement($fields);
// handle cat hierarchy attachement
$sql_where = $f_cat_hierarchy ? ' AND main_type = \'' . POST_CAT_URL . '\'' : '';
// re-attach forums
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET forum_main = ' . $forum_id . '
WHERE cat_id = ' . $cat_id . $sql_where;
_output($sql);
$db->sql_query($sql, false, __LINE__, __FILE__);
}
$db->sql_stack_insert(FORUMS_TABLE, false, __LINE__, __FILE__);
$sql = 'UPDATE ' . CATEGORIES_TABLE . '
SET cat_order = 0
WHERE cat_id IN(' . implode(', ', array_keys($cats)) . ')';
_output($sql);
$db->sql_query($sql, false, __LINE__, __FILE__);
// reset the forum link counter for previous version of categories hierarchy
if ( $c_cat_hierarchy )
{
$fields = array(
'forum_type' => POST_LINK_URL,
'forum_link_start' => empty($config->data['board_startdate']) ? time() : intval($config->data['board_startdate']),
);
if ( empty($config->data['board_startdate']) )
{
$fields += array(
'forum_link_count' => 0,
);
}
$db->sql_statement($fields);
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET ' . $db->sql_update . '
WHERE (forum_link <> \'\' AND forum_link IS NOT NULL)';
_output($sql);
$db->sql_query($sql, false, __LINE__, __FILE__);
}
echo '... forums created and sub-forums attached<br /><hr /><br /><br />';
}
echo '<b>Re-order forums...</b><br /><br />';
$sql = 'SELECT forum_id, forum_main
FROM ' . FORUMS_TABLE . '
ORDER BY forum_main, forum_order';
_output($sql);
$result = $db->sql_query($sql, false, __LINE__, __FILE__);
$subs = array();
while ( $row = $db->sql_fetchrow($result) )
{
if ( !isset($subs[ $row['forum_id'] ]) )
{
$subs[ $row['forum_id'] ] = array();
}
if ( !isset($subs[ $row['forum_main'] ]) )
{
$subs[ $row['forum_main'] ] = array();
}
$subs[ $row['forum_main'] ][] = $row['forum_id'];
}
$ordered = array();
reorder();
// update all tree order to 0
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET forum_order = 0';
_output($sql);
$db->sql_query($sql, false, __LINE__, __FILE__);
// force type as forum for those missing
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET forum_type = \'' . POST_FORUM_URL . '\'
WHERE forum_type IS NULL OR forum_type = \' \'';
_output($sql);
$db->sql_query($sql, false, __LINE__, __FILE__);
// set the good order
$count_ordered = count($ordered);
$last_order = 0;
for ( $i = 0; $i < $count_ordered; $i++ )
{
if ( !empty($ordered[$i]) )
{
$last_order += 10;
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET forum_order = ' . $last_order . '
WHERE forum_id = ' . $ordered[$i];
_output($sql);
$db->sql_query($sql, false, __LINE__, __FILE__);
}
}
// attach unordered forums to root
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET forum_main = 0
WHERE forum_order = 0';
_output($sql);
$db->sql_query($sql, false, __LINE__, __FILE__);
echo '... forums reorder done<br /><hr /><br /><br />';
// reclaim some memory
if ( !empty($cats) )
{
unset($cats);
}
if ( !empty($subs) )
{
unset($subs);
}
if ( !empty($ordered) )
{
unset($ordered);
}
//--------------------------
// synchronise topics
//--------------------------
// this is the big one
echo '<b>Topic synchronisation...</b><br /><br />';
$sql = 'SELECT t.topic_id, fp.post_username AS first_username, lp.poster_id AS last_poster, lp.post_username AS last_username, lp.post_time AS last_time
FROM ' . TOPICS_TABLE . ' t
LEFT JOIN ' . POSTS_TABLE . ' fp ON fp.post_id = t.topic_first_post_id
LEFT JOIN ' . POSTS_TABLE . ' lp ON lp.post_id = t.topic_last_post_id
WHERE t.topic_last_time = 0
AND t.topic_moved_id = 0';
_output($sql);
$result = $db->sql_query($sql, false, __LINE__, __FILE__);
echo 'remaining : ' . $db->sql_numrows($result) . ' topics<br /><br />';
flush();
while ( $row = $db->sql_fetchrow($result) )
{
$fields = array(
'topic_first_username' => $row['first_username'],
'topic_last_poster' => intval($row['last_poster']),
'topic_last_username' => $row['last_username'],
'topic_last_time' => intval($row['last_time']),
);
$db->sql_statement($fields);
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET ' . $db->sql_update . '
WHERE topic_id = ' . $row['topic_id'];
$db->sql_query($sql, false, __LINE__, __FILE__);
}
echo '... topic synchronisation done<br /><hr /><br /><br />';
//--------------------------
// synchronise last posts in forums
//--------------------------
echo '<b>Forums synchronisation...</b><br /><br />';
$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE;
_output($sql);
$result = $db->sql_query($sql, false, __LINE__, __FILE);
while ( $row = $db->sql_fetchrow($result) )
{
$forums[] = $row['forum_id'];
}
$count_forums = count($forums);
for ( $i = 0; $i < $count_forums; $i++ )
{
$sql = 'SELECT t.topic_title, t.topic_last_post_id, t.topic_last_poster, t.topic_last_username, t.topic_last_time, u.username
FROM ' . TOPICS_TABLE . ' t
LEFT JOIN ' . USERS_TABLE . ' u ON u.user_id = t.topic_last_poster
WHERE forum_id = ' . $forums[$i] . '
ORDER BY t.topic_last_post_id DESC
LIMIT 1';
$result = $db->sql_query($sql, false, __LINE__, __FILE__);
$row = $db->sql_fetchrow($result);
$fields = array(
'forum_last_title' => $row['topic_title'],
'forum_last_poster' => intval($row['topic_last_poster']),
'forum_last_username' => (($row['topic_last_poster'] == ANONYMOUS) || empty($row['username'])) ? $row['topic_last_username'] : $row['username'],
'forum_last_time' => intval($row['topic_last_time']),
);
$db->sql_statement($fields);
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET ' . $db->sql_update . '
WHERE forum_id = ' . $forums[$i];
_output($sql);
$db->sql_query($sql, false, __LINE__, __FILE__);
}
// force global announces auth requirement
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET auth_global_announce = 5
WHERE auth_global_announce = 0';
_output($sql);
$db->sql_query($sql, false, __LINE__, __FILE__);
// recache forums now
$sql = 'DELETE FROM ' . USERS_CACHE_TABLE;
_output($sql);
$db->sql_query($sql, false, __LINE__, __FILE__);
$forums = new forums();
$forums->read(true);
// synchornize the topics & posts count
$sql = 'SELECT COUNT(topic_id) as total_topics
FROM ' . TOPICS_TABLE;
_output($sql);
$result = $db->sql_query($sql, false, __LINE__, __FILE__);
$row = $db->sql_fetchrow($result);
$config->set('stat_total_topics', intval($row['total_topics']));
$sql = 'SELECT COUNT(post_id) as total_posts
FROM ' . POSTS_TABLE;
_output($sql);
$result = $db->sql_query($sql, false, __LINE__, __FILE__);
$row = $db->sql_fetchrow($result);
$config->set('stat_total_posts', intval($row['total_posts']));
echo '... forums synchronisation done<br /><hr /><br /><br />';
//--------------------------
// set topic duration date to never for announces (we don't touch globals if any)
//--------------------------
echo '<b>Announces duration initialisation...</b><br /><br />';
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_duration = topic_time
WHERE topic_duration = 0
AND topic_type = ' . POST_ANNOUNCE;
_output($sql);
$db->sql_query($sql, false, __LINE__, __FILE__);
echo '... announces duration initialisation done<br /><hr /><br /><br />';
//--------------------------
// synchronise users
//--------------------------
echo '<b>Synchronise users...</b><br /><br />';
$sql = 'SELECT user_id, username
FROM ' . USERS_TABLE . '
WHERE user_id <> ' . ANONYMOUS . '
ORDER BY user_id DESC';
_output($sql);
$result = $db->sql_query($sql, false, __LINE__, __FILE__);
$config->set('stat_total_users', intval($db->sql_numrows($result)));
$row = $db->sql_fetchrow($result);
$config->set('stat_last_user', intval($row['user_id']));
$config->set('stat_last_username', $row['username']);
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_unread_topics = NULL, user_unread_date = user_lastvisit';
_output($sql);
$result = $db->sql_query($sql, false, __LINE__, __FILE__);
echo '... users synchronised<br /><hr /><br /><br />';
//--------------------------
// create panels
//--------------------------
echo '<b>create panels...</b><br /><br />';
$cp_panels = new cp_panels();
$cp_panels->read();
$cp_panels->patch();
echo '... panels created<br /><hr /><br /><br />';
//--------------------------
// create auths definitions & import auths settings
//--------------------------
echo '<b>create auths definitions...</b><br /><br />';
$auths_def = new admin_auths_def();
$auths_def->read();
$auths_def->import(POST_FORUM_URL);
$auths_def->import(POST_PANELS_URL);
$auths_def->import(POST_GROUPS_URL);
echo '... auths definitions created<br /><hr /><br /><br />';
//--------------------------
// synchronise users groups list
//--------------------------
echo '<b>Synchronise users groups membership...</b><br /><br />';
$groups = new groups();
$groups->resync_users_list();
echo '... users groups membership synchronised<br /><hr /><br /><br />';
//--------------------------
// auths presets creation
//--------------------------
echo '<b>Permissions presets creation...</b><br /><br />';
$sql = 'DELETE FROM ' . PRESETS_TABLE;
$db->sql_query($sql, false, __LINE__, __FILE__);
$db->sql_stack_reset();
$db->sql_stack_fields = 'preset_id, preset_type, preset_name';
$db->sql_stack_values = array(
'(1, \'f\', \'Preset_read_only\')',
'(2, \'f\', \'Preset_read_post_vote\')',
'(3, \'f\', \'Preset_moderator\')',
'(4, \'f\', \'Preset_moderator_hidden\')',
'(5, \'f\', \'Preset_admin\')',
'(6, \'f\', \'None\')',
'(7, \'m\', \'Preset_access\')',
'(8, \'m\', \'None\')',
'(9, \'g\', \'Preset_admin\')',
'(10, \'g\', \'Preset_view\')',
'(11, \'g\', \'None\')',
);
$db->sql_stack_insert(PRESETS_TABLE, false, __LINE__, __FILE__);
$sql = 'DELETE FROM ' . PRESETS_DATA_TABLE;
$db->sql_query($sql, false, __LINE__, __FILE__);
$db->sql_stack_reset();
$db->sql_stack_fields = 'preset_id, preset_auth, preset_value';
$db->sql_stack_values = array(
'(1, \'auth_read\', 1)', '(1, \'auth_view\', 1)',
'(2, \'auth_delete\', 1)', '(2, \'auth_edit\', 1)', '(2, \'auth_post\', 1)', '(2, \'auth_read\', 1)', '(2, \'auth_reply\', 1)', '(2, \'auth_view\', 1)', '(2, \'auth_vote\', 1)',
'(3, \'auth_announce\', 1)', '(3, \'auth_delete\', 1)', '(3, \'auth_edit\', 1)', '(3, \'auth_global_announce\', 1)', '(3, \'auth_mod\', 1)', '(3, \'auth_mod_display\', 1)', '(3, \'auth_pollcreate\', 1)', '(3, \'auth_post\', 1)', '(3, \'auth_read\', 1)', '(3, \'auth_reply\', 1)', '(3, \'auth_sticky\', 1)', '(3, \'auth_view\', 1)', '(3, \'auth_vote\', 1)',
'(4, \'auth_announce\', 1)', '(4, \'auth_delete\', 1)', '(4, \'auth_edit\', 1)', '(4, \'auth_global_announce\', 1)', '(4, \'auth_mod\', 1)', '(4, \'auth_pollcreate\', 1)', '(4, \'auth_post\', 1)', '(4, \'auth_read\', 1)', '(4, \'auth_reply\', 1)', '(4, \'auth_sticky\', 1)', '(4, \'auth_view\', 1)', '(4, \'auth_vote\', 1)',
'(5, \'auth_announce\', 1)', '(5, \'auth_delete\', 1)', '(5, \'auth_edit\', 1)', '(5, \'auth_global_announce\', 1)', '(5, \'auth_mod\', 1)', '(5, \'auth_pollcreate\', 1)', '(5, \'auth_post\', 1)', '(5, \'auth_read\', 1)', '(5, \'auth_reply\', 1)', '(5, \'auth_sticky\', 1)', '(5, \'auth_view\', 1)', '(5, \'auth_vote\', 1)', '(5, \'auth_manage\', 1)',
'(7, \'access\', 1)',
'(9, \'ucp_edit_i18n\', 1)', '(9, \'ucp_edit_layout\', 1)', '(9, \'ucp_edit_posting\', 1)', '(9, \'ucp_edit_privacy\', 1)', '(9, \'ucp_edit_profile\', 1)', '(9, \'ucp_edit_topicread\', 1)',
'(10, \'ucp_view_profile\', 1)',
);
$db->sql_stack_insert(PRESETS_DATA_TABLE, false, __LINE__, __FILE__);
echo '... permissions presets created<br /><hr /><br /><br />';
//--------------------------
// icons creation
//--------------------------
echo '<b>Messages icons creation...</b><br /><br />';
$sql = 'DELETE FROM ' . ICONS_TABLE;
$db->sql_query($sql, false, __LINE__, __FILE__);
$db->sql_stack_reset();
$db->sql_stack_fields = 'icon_id, icon_name, icon_url, icon_acl, icon_types, icon_order';
$db->sql_stack_values = array(
'(1, \'icon_note\', \'images/icons/icon1.gif\', 0, \'0\', 10)',
'(2, \'icon_important\', \'images/icons/icon2.gif\', 0, \'1\', 20)',
'(3, \'icon_idea\', \'images/icons/icon3.gif\', 0, \'\', 30)',
'(4, \'icon_warning\', \'images/icons/icon4.gif\', 0, \'2, 3\', 40)',
'(5, \'icon_question\', \'images/icons/icon5.gif\', 0, \'\', 50)',
'(6, \'icon_cool\', \'images/icons/icon6.gif\', 0, \'\', 60)',
'(7, \'icon_funny\', \'images/icons/icon7.gif\', 0, \'\', 70)',
'(8, \'icon_angry\', \'images/icons/icon8.gif\', 0, \'\', 80)',
'(9, \'icon_sad\', \'images/icons/icon9.gif\', 0, \'\', 90)',
'(10, \'icon_mocker\', \'images/icons/icon10.gif\', 0, \'\', 100)',
'(11, \'icon_shocked\', \'images/icons/icon11.gif\', 0, \'\', 110)',
'(12, \'icon_complicity\', \'images/icons/icon12.gif\', 0, \'\', 120)',
'(13, \'icon_bad\', \'images/icons/icon13.gif\', 0, \'\', 130)',
'(14, \'icon_great\', \'images/icons/icon14.gif\', 0, \'\', 140)',
'(15, \'icon_disgusting\', \'images/icons/icon15.gif\', 0, \'\', 150)',
'(16, \'icon_winner\', \'images/icons/icon16.gif\', 0, \'\', 160)',
'(17, \'icon_impressed\', \'images/icons/icon17.gif\', 0, \'\', 170)',
'(18, \'icon_roleplay\', \'images/icons/icon18.gif\', 0, \'\', 180)',
'(19, \'icon_fight\', \'images/icons/icon19.gif\', 0, \'\', 190)',
'(20, \'icon_loot\', \'images/icons/icon20.gif\', 0, \'\', 200)',
'(21, \'icon_picture\', \'images/icons/icon21.gif\', 3, \'\', 210)',
'(22, \'icon_calendar\', \'images/icons/icon22.gif\', 3, \'\', 220)',
);
$db->sql_stack_insert(ICONS_TABLE, false, __LINE__, __FILE__);
echo '... messages icons created<br /><hr /><br /><br />';
// mark the install over
$config->set('mod_cat_hierarchy', '2.1.0f', true);
// Achievement message
echo '<br /><hr /><h1><b>All process done.</h1><br />';
echo 'Delete now your install_cat/ directory.</b><hr /><br /><br /><br />';
echo '</div><div align="center" class="gen">Click <a href="' . $config->url('index') . '">Here</a> to return to Board index<br /><br /><br /><hr /><br />';
}
?>
</div><div align="center" class="gensmall"><br /><a href="http://www.phpbb.com/" target="_phpbb" class="gensmall">phpBB</a> © 2001,2002 phpBB Group
</div></form></td></tr></table>
</body>
</html>