aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/develop
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/develop')
-rw-r--r--phpBB/develop/add_permissions.php417
-rw-r--r--phpBB/develop/adjust_avatars.php147
-rw-r--r--phpBB/develop/adjust_bbcodes.php174
-rw-r--r--phpBB/develop/adjust_magic_urls.php126
-rw-r--r--phpBB/develop/adjust_sizes.php132
-rw-r--r--phpBB/develop/adjust_smilies.php130
-rw-r--r--phpBB/develop/adjust_uids.php129
-rw-r--r--phpBB/develop/adjust_usernames.php52
-rw-r--r--phpBB/develop/benchmark.php462
-rw-r--r--phpBB/develop/calc_email_hash.php76
-rw-r--r--phpBB/develop/change_smiley_ref.php62
-rwxr-xr-xphpBB/develop/collect_cache_stats.sh3
-rw-r--r--phpBB/develop/create_schema_files.php2048
-rw-r--r--phpBB/develop/create_variable_overview.php547
-rw-r--r--phpBB/develop/fill.php190
-rwxr-xr-xphpBB/develop/fix_files.sh29
-rw-r--r--phpBB/develop/generate_utf_casefold.php156
-rw-r--r--phpBB/develop/generate_utf_confusables.php240
-rw-r--r--phpBB/develop/generate_utf_tables.php572
-rw-r--r--phpBB/develop/lang_duplicates.php140
-rw-r--r--phpBB/develop/merge_attachment_tables.php80
-rw-r--r--phpBB/develop/merge_post_tables.php209
-rw-r--r--phpBB/develop/mysql_upgrader.php1400
-rw-r--r--phpBB/develop/nuke-db.php58
-rw-r--r--phpBB/develop/regex.php83
-rw-r--r--phpBB/develop/repair_bots.php151
-rw-r--r--phpBB/develop/search_fill.php129
-rw-r--r--phpBB/develop/unicode_testing.php120
-rw-r--r--phpBB/develop/update_email_hash.php57
-rw-r--r--phpBB/develop/utf_normalizer_test.php391
30 files changed, 8510 insertions, 0 deletions
diff --git a/phpBB/develop/add_permissions.php b/phpBB/develop/add_permissions.php
new file mode 100644
index 0000000000..035c23f49c
--- /dev/null
+++ b/phpBB/develop/add_permissions.php
@@ -0,0 +1,417 @@
+<?php
+// -------------------------------------------------------------
+//
+// $Id$
+//
+// FILENAME : add_permissions.php
+// STARTED : Sat Nov 06, 2004
+// COPYRIGHT : � 2004 phpBB Group
+// WWW : http://www.phpbb.com/
+// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
+//
+// -------------------------------------------------------------
+
+//
+// Security message:
+//
+// This script is potentially dangerous.
+// Remove or comment the next line (die(".... ) to enable this script.
+// Do NOT FORGET to either remove this script or disable it after you have used it.
+//
+die("Please read the first lines of this script for instructions on how to enable it");
+
+
+// This script adds missing permissions
+$db = $dbhost = $dbuser = $dbpasswd = $dbport = $dbname = '';
+
+define('IN_PHPBB', 1);
+define('ANONYMOUS', 1);
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+$phpbb_root_path='./../';
+include($phpbb_root_path . 'config.'.$phpEx);
+require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.'.$phpEx);
+require($phpbb_root_path . 'includes/db/' . $dbms . '.'.$phpEx);
+include($phpbb_root_path . 'includes/functions.'.$phpEx);
+
+define('ACL_NEVER', 0);
+define('ACL_YES', 1);
+define('ACL_NO', -1);
+
+define('ACL_GROUPS_TABLE', $table_prefix.'acl_groups');
+define('ACL_OPTIONS_TABLE', $table_prefix.'acl_options');
+define('ACL_USERS_TABLE', $table_prefix.'acl_users');
+define('GROUPS_TABLE', $table_prefix.'groups');
+define('USERS_TABLE', $table_prefix.'users');
+
+$cache = new acm();
+$db = new sql_db();
+
+// Connect to DB
+$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
+
+// auth => is_local, is_global
+$f_permissions = array(
+ 'f_' => array(1, 0),
+ 'f_list' => array(1, 0),
+ 'f_read' => array(1, 0),
+ 'f_post' => array(1, 0),
+ 'f_reply' => array(1, 0),
+ 'f_edit' => array(1, 0),
+ 'f_user_lock' => array(1, 0),
+ 'f_delete' => array(1, 0),
+ 'f_bump' => array(1, 0),
+ 'f_poll' => array(1, 0),
+ 'f_vote' => array(1, 0),
+ 'f_votechg' => array(1, 0),
+ 'f_announce'=> array(1, 0),
+ 'f_sticky' => array(1, 0),
+ 'f_attach' => array(1, 0),
+ 'f_download'=> array(1, 0),
+ 'f_icons' => array(1, 0),
+ 'f_bbcode' => array(1, 0),
+ 'f_smilies' => array(1, 0),
+ 'f_img' => array(1, 0),
+ 'f_flash' => array(1, 0),
+ 'f_sigs' => array(1, 0),
+ 'f_search' => array(1, 0),
+ 'f_email' => array(1, 0),
+ 'f_print' => array(1, 0),
+ 'f_ignoreflood' => array(1, 0),
+ 'f_postcount' => array(1, 0),
+ 'f_noapprove'=> array(1, 0),
+ 'f_report' => array(1, 0),
+ 'f_subscribe' => array(1, 0),
+);
+
+$m_permissions = array(
+ 'm_' => array(1, 1),
+ 'm_edit' => array(1, 1),
+ 'm_delete' => array(1, 1),
+ 'm_move' => array(1, 1),
+ 'm_lock' => array(1, 1),
+ 'm_split' => array(1, 1),
+ 'm_merge' => array(1, 1),
+ 'm_approve' => array(1, 1),
+ 'm_unrate' => array(1, 1),
+ 'm_auth' => array(1, 1),
+ 'm_ip' => array(1, 1),
+ 'm_info' => array(1, 1),
+);
+
+$a_permissions = array(
+ 'a_' => array(0, 1),
+ 'a_server' => array(0, 1),
+ 'a_board' => array(0, 1),
+ 'a_clearlogs' => array(0, 1),
+ 'a_words' => array(0, 1),
+ 'a_icons' => array(0, 1),
+ 'a_bbcode' => array(0, 1),
+ 'a_attach' => array(0, 1),
+ 'a_email' => array(0, 1),
+ 'a_styles' => array(0, 1),
+ 'a_user' => array(0, 1),
+ 'a_useradd' => array(0, 1),
+ 'a_userdel' => array(0, 1),
+ 'a_ranks' => array(0, 1),
+ 'a_ban' => array(0, 1),
+ 'a_names' => array(0, 1),
+ 'a_group' => array(0, 1),
+ 'a_groupadd'=> array(0, 1),
+ 'a_groupdel'=> array(0, 1),
+ 'a_forum' => array(0, 1),
+ 'a_forumadd'=> array(0, 1),
+ 'a_forumdel'=> array(0, 1),
+ 'a_prune' => array(0, 1),
+ 'a_auth' => array(0, 1),
+ 'a_authmods'=> array(0, 1),
+ 'a_authadmins' => array(0, 1),
+ 'a_authusers' => array(0, 1),
+ 'a_authgroups' => array(0, 1),
+ 'a_authdeps'=> array(0, 1),
+ 'a_backup' => array(0, 1),
+ 'a_restore' => array(0, 1),
+ 'a_search' => array(0, 1),
+ 'a_events' => array(0, 1),
+ 'a_cron' => array(0, 1),
+);
+
+$u_permissions = array(
+ 'u_' => array(0, 1),
+ 'u_sendemail' => array(0, 1),
+ 'u_readpm' => array(0, 1),
+ 'u_sendpm' => array(0, 1),
+ 'u_sendim' => array(0, 1),
+ 'u_hideonline' => array(0, 1),
+ 'u_viewonline' => array(0, 1),
+ 'u_viewprofile' => array(0, 1),
+ 'u_chgavatar' => array(0, 1),
+ 'u_chggrp' => array(0, 1),
+ 'u_chgemail' => array(0, 1),
+ 'u_chgname' => array(0, 1),
+ 'u_chgpasswd' => array(0, 1),
+ 'u_chgcensors' => array(0, 1),
+ 'u_search' => array(0, 1),
+ 'u_savedrafts' => array(0, 1),
+ 'u_download' => array(0, 1),
+ 'u_attach' => array(0, 1),
+ 'u_sig' => array(0, 1),
+ 'u_pm_attach' => array(0, 1),
+ 'u_pm_bbcode' => array(0, 1),
+ 'u_pm_smilies' => array(0, 1),
+ 'u_pm_download' => array(0, 1),
+ 'u_pm_edit' => array(0, 1),
+ 'u_pm_printpm' => array(0, 1),
+ 'u_pm_emailpm' => array(0, 1),
+ 'u_pm_forward' => array(0, 1),
+ 'u_pm_delete' => array(0, 1),
+ 'u_pm_img' => array(0, 1),
+ 'u_pm_flash' => array(0, 1),
+);
+
+echo "<p><b>Determining existing permissions</b></p>\n";
+
+$sql = 'SELECT auth_option_id, auth_option FROM ' . ACL_OPTIONS_TABLE;
+$result = $db->sql_query($sql);
+
+$remove_auth_options = array();
+while ($row = $db->sql_fetchrow($result))
+{
+ if (!in_array($row['auth_option'], array_keys(${substr($row['auth_option'], 0, 2) . 'permissions'})))
+ {
+ $remove_auth_options[$row['auth_option']] = $row['auth_option_id'];
+ }
+ unset(${substr($row['auth_option'], 0, 2) . 'permissions'}[$row['auth_option']]);
+}
+$db->sql_freeresult($result);
+
+if (sizeof($remove_auth_options))
+{
+ $db->sql_query('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id IN (' . implode(', ', $remove_auth_options) . ')');
+ $db->sql_query('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id IN (' . implode(', ', $remove_auth_options) . ')');
+ $db->sql_query('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id IN (' . implode(', ', $remove_auth_options) . ')');
+
+ echo '<p><b>Removed the following auth options... [<i>' . implode(', ', array_keys($remove_auth_options)) . "</i>]</b></p>\n\n";
+}
+
+$prefixes = array('f_', 'a_', 'm_', 'u_');
+
+foreach ($prefixes as $prefix)
+{
+ $var = $prefix . 'permissions';
+ if (sizeof($$var))
+ {
+ foreach ($$var as $auth_option => $l_ary)
+ {
+ $sql_ary = array(
+ 'auth_option' => $auth_option,
+ 'is_local' => $l_ary[0],
+ 'is_global' => $l_ary[1]
+ );
+
+ $db->sql_query('INSERT INTO ' . ACL_OPTIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
+
+ echo "<p><b>Adding $auth_option...</b></p>\n";
+
+ mass_auth('group', 0, 'guests', $auth_option, ACL_NEVER);
+ mass_auth('group', 0, 'inactive', $auth_option, ACL_NEVER);
+ mass_auth('group', 0, 'inactive_coppa', $auth_option, ACL_NEVER);
+ mass_auth('group', 0, 'registered_coppa', $auth_option, ACL_NEVER);
+ mass_auth('group', 0, 'registered', $auth_option, (($prefix != 'm_' && $prefix != 'a_') ? ACL_YES : ACL_NEVER));
+ mass_auth('group', 0, 'global_moderators', $auth_option, (($prefix != 'a_') ? ACL_YES : ACL_NEVER));
+ mass_auth('group', 0, 'administrators', $auth_option, ACL_YES);
+ mass_auth('group', 0, 'bots', $auth_option, (($prefix != 'm_' && $prefix != 'a_') ? ACL_YES : ACL_NEVER));
+ }
+ }
+}
+
+$sql = 'UPDATE ' . USERS_TABLE . " SET user_permissions = ''";
+$db->sql_query($sql);
+
+$cache->destroy('_acl_options');
+
+echo "<p><b>Done</b></p>\n";
+
+/*
+ $ug_type = user|group
+ $forum_id = forum ids (array|int|0) -> 0 == all forums
+ $ug_id = [int] user_id|group_id : [string] usergroup name
+ $acl_list = [string] acl entry : [array] acl entries
+ $setting = ACL_YES|ACL_NEVER|ACL_NO
+*/
+function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting)
+{
+ global $db;
+ static $acl_option_ids, $group_ids;
+
+ if ($ug_type == 'group' && is_string($ug_id))
+ {
+ if (!isset($group_ids[$ug_id]))
+ {
+ $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . "
+ WHERE group_name = '" . strtoupper($ug_id) . "'";
+ $result = $db->sql_query_limit($sql, 1);
+ $id = (int) $db->sql_fetchfield('group_id', 0, $result);
+ $db->sql_freeresult($result);
+
+ if (!$id)
+ {
+ return;
+ }
+
+ $group_ids[$ug_id] = $id;
+ }
+
+ $ug_id = (int) $group_ids[$ug_id];
+ }
+
+ // Build correct parameters
+ $auth = array();
+
+ if (!is_array($acl_list))
+ {
+ $auth = array($acl_list => $setting);
+ }
+ else
+ {
+ foreach ($acl_list as $auth_option)
+ {
+ $auth[$auth_option] = $setting;
+ }
+ }
+ unset($acl_list);
+
+ if (!is_array($forum_id))
+ {
+ $forum_id = array($forum_id);
+ }
+
+ // Set any flags as required
+ foreach ($auth as $auth_option => $acl_setting)
+ {
+ $flag = substr($auth_option, 0, strpos($auth_option, '_') + 1);
+ if (empty($auth[$flag]))
+ {
+ $auth[$flag] = $acl_setting;
+ }
+ }
+
+ if (!is_array($acl_option_ids) || empty($acl_option_ids))
+ {
+ $sql = 'SELECT auth_option_id, auth_option
+ FROM ' . ACL_OPTIONS_TABLE;
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $acl_option_ids[$row['auth_option']] = $row['auth_option_id'];
+ }
+ $db->sql_freeresult($result);
+ }
+
+ $sql_forum = 'AND a.forum_id IN (' . implode(', ', array_map('intval', $forum_id)) . ')';
+
+ $sql = ($ug_type == 'user') ? 'SELECT o.auth_option_id, o.auth_option, a.forum_id, a.auth_setting FROM ' . ACL_USERS_TABLE . ' a, ' . ACL_OPTIONS_TABLE . " o WHERE a.auth_option_id = o.auth_option_id $sql_forum AND a.user_id = $ug_id" : 'SELECT o.auth_option_id, o.auth_option, a.forum_id, a.auth_setting FROM ' . ACL_GROUPS_TABLE . ' a, ' . ACL_OPTIONS_TABLE . " o WHERE a.auth_option_id = o.auth_option_id $sql_forum AND a.group_id = $ug_id";
+ $result = $db->sql_query($sql);
+
+ $cur_auth = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $cur_auth[$row['forum_id']][$row['auth_option_id']] = $row['auth_setting'];
+ }
+ $db->sql_freeresult($result);
+
+ $table = ($ug_type == 'user') ? ACL_USERS_TABLE : ACL_GROUPS_TABLE;
+ $id_field = $ug_type . '_id';
+
+ $sql_ary = array();
+ foreach ($forum_id as $forum)
+ {
+ foreach ($auth as $auth_option => $setting)
+ {
+ $auth_option_id = $acl_option_ids[$auth_option];
+
+ if (!$auth_option_id)
+ {
+ continue;
+ }
+
+ switch ($setting)
+ {
+ case ACL_NO:
+ if (isset($cur_auth[$forum][$auth_option_id]))
+ {
+ $sql_ary['delete'][] = "DELETE FROM $table
+ WHERE forum_id = $forum
+ AND auth_option_id = $auth_option_id
+ AND $id_field = $ug_id";
+ }
+ break;
+
+ default:
+ if (!isset($cur_auth[$forum][$auth_option_id]))
+ {
+ $sql_ary['insert'][] = "$ug_id, $forum, $auth_option_id, $setting";
+ }
+ else if ($cur_auth[$forum][$auth_option_id] != $setting)
+ {
+ $sql_ary['update'][] = "UPDATE " . $table . "
+ SET auth_setting = $setting
+ WHERE $id_field = $ug_id
+ AND forum_id = $forum
+ AND auth_option_id = $auth_option_id";
+ }
+ }
+ }
+ }
+ unset($cur_auth);
+
+ $sql = '';
+ foreach ($sql_ary as $sql_type => $sql_subary)
+ {
+ switch ($sql_type)
+ {
+ case 'insert':
+ switch ($db->sql_layer)
+ {
+ case 'mysql':
+ case 'mysql4':
+ $sql = 'VALUES ' . implode(', ', preg_replace('#^(.*?)$#', '(\1)', $sql_subary));
+ break;
+
+ case 'mssql':
+ case 'sqlite':
+ $sql = implode(' UNION ALL ', preg_replace('#^(.*?)$#', 'SELECT \1', $sql_subary));
+ break;
+
+ default:
+ foreach ($sql_subary as $sql)
+ {
+ $sql = "INSERT INTO $table ($id_field, forum_id, auth_option_id, auth_setting) VALUES ($sql)";
+ $result = $db->sql_query($sql);
+ $sql = '';
+ }
+ }
+
+ if ($sql != '')
+ {
+ $sql = "INSERT INTO $table ($id_field, forum_id, auth_option_id, auth_setting) $sql";
+ $result = $db->sql_query($sql);
+ }
+ break;
+
+ case 'update':
+ case 'delete':
+ foreach ($sql_subary as $sql)
+ {
+ $result = $db->sql_query($sql);
+ $sql = '';
+ }
+ break;
+ }
+ unset($sql_ary[$sql_type]);
+ }
+ unset($sql_ary);
+
+}
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/adjust_avatars.php b/phpBB/develop/adjust_avatars.php
new file mode 100644
index 0000000000..81599e694b
--- /dev/null
+++ b/phpBB/develop/adjust_avatars.php
@@ -0,0 +1,147 @@
+<?php
+/**
+* Corrects avatar filenames to match the new avatar delivery method.
+*
+* You should make a backup from your users table and the avatar directory in case something goes wrong
+*/
+die("Please read the first lines of this script for instructions on how to enable it");
+
+set_time_limit(0);
+
+define('IN_PHPBB', true);
+$phpbb_root_path = './../';
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+include($phpbb_root_path . 'common.'.$phpEx);
+
+// Start session management
+$user->session_begin();
+$auth->acl($user->data);
+$user->setup();
+
+$echos = 0;
+
+if (!isset($config['avatar_salt']))
+{
+ $cache->purge();
+ if (!isset($config['avatar_salt']))
+ {
+ die('database not up to date');
+ }
+ die('database not up to date');
+}
+
+// let's start with the users using a group_avatar.
+$sql = 'SELECT group_id, group_avatar
+ FROM ' . GROUPS_TABLE . '
+ WHERE group_avatar_type = ' . AVATAR_UPLOAD;
+
+// We'll skip these, so remember them
+$group_avatars = array();
+
+echo '<br /> Updating groups' . "\n";
+
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $new_avatar_name = adjust_avatar($row['group_avatar'], 'g' . $row['group_id']);
+ $group_avatars[] = $new_avatar_name;
+
+ // failure is probably due to the avatar name already being adjusted
+ if ($new_avatar_name !== false)
+ {
+ $sql = 'UPDATE ' . USERS_TABLE . "
+ SET user_avatar = '" . $db->sql_escape($new_avatar_name) . "'
+ WHERE user_avatar = '" . $db->sql_escape($row['group_avatar']) . "'
+ AND user_avatar_type = " . AVATAR_UPLOAD;
+ $db->sql_query($sql);
+
+ $sql = 'UPDATE ' . GROUPS_TABLE . "
+ SET group_avatar = '" . $db->sql_escape($new_avatar_name) . "'
+ WHERE group_id = {$row['group_id']}";
+ $db->sql_query($sql);
+ }
+ else
+ {
+ echo '<br /> Failed updating group ' . $row['group_id'] . "\n";
+ }
+
+ if ($echos > 200)
+ {
+ echo '<br />' . "\n";
+ $echos = 0;
+ }
+
+ echo '.';
+ $echos++;
+
+ flush();
+}
+$db->sql_freeresult($result);
+
+$sql = 'SELECT user_id, username, user_avatar, user_avatar_type
+ FROM ' . USERS_TABLE . '
+ WHERE user_avatar_type = ' . AVATAR_UPLOAD . '
+ AND ' . $db->sql_in_set('user_avatar', $group_avatars, true, true);
+$result = $db->sql_query($sql);
+
+echo '<br /> Updating users' . "\n";
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $new_avatar_name = adjust_avatar($row['user_avatar'], $row['user_id']);
+
+ // failure is probably due to the avatar name already being adjusted
+ if ($new_avatar_name !== false)
+ {
+ $sql = 'UPDATE ' . USERS_TABLE . "
+ SET user_avatar = '" . $db->sql_escape($new_avatar_name) . "'
+ WHERE user_id = {$row['user_id']}";
+ $db->sql_query($sql);
+ }
+ else
+ {
+ // nuke this avatar
+ $sql = 'UPDATE ' . USERS_TABLE . "
+ SET user_avatar = '', user_avatar_type = 0
+ WHERE user_id = {$row['user_id']}";
+ $db->sql_query($sql);
+ echo '<br /> Failed updating user ' . $row['user_id'] . "\n";
+ }
+
+ if ($echos > 200)
+ {
+ echo '<br />' . "\n";
+ $echos = 0;
+ }
+
+ echo '.';
+ $echos++;
+
+ flush();
+}
+
+$db->sql_freeresult($result);
+
+echo 'FINISHED';
+
+// Done
+$db->sql_close();
+
+function adjust_avatar($old_name, $midfix)
+{
+ global $config, $phpbb_root_path;
+
+ $avatar_path = $phpbb_root_path . $config['avatar_path'];
+ $extension = strtolower(substr(strrchr($old_name, '.'), 1));
+ $new_name = $config['avatar_salt'] . '_' . $midfix . '.' . $extension;
+
+ if (@file_exists($avatar_path . '/' . $old_name) && @is_writable($avatar_path . '/' . $old_name) && @is_writable($avatar_path . '/' . $new_name))
+ {
+ @rename($avatar_path . '/' . $old_name, $avatar_path . '/' . $new_name);
+ return $midfix . '.' . $extension;
+ }
+ return false;
+}
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/adjust_bbcodes.php b/phpBB/develop/adjust_bbcodes.php
new file mode 100644
index 0000000000..f06f0112ab
--- /dev/null
+++ b/phpBB/develop/adjust_bbcodes.php
@@ -0,0 +1,174 @@
+<?php
+/**
+* Only adjust bitfields, do not rewrite text...
+* All new parsings have the img, flash and quote modes set to true
+*
+* You should make a backup from your users, posts and privmsgs table in case something goes wrong
+* Forum descriptions and rules need to be re-submitted manually.
+*/
+die("Please read the first lines of this script for instructions on how to enable it");
+
+set_time_limit(0);
+
+define('IN_PHPBB', true);
+$phpbb_root_path = './../';
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+include($phpbb_root_path . 'common.'.$phpEx);
+include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
+
+// Start session management
+$user->session_begin();
+$auth->acl($user->data);
+$user->setup();
+
+$echos = 0;
+
+// Adjust user signatures
+$message_parser = new parse_message();
+$message_parser->mode = 'sig';
+$message_parser->bbcode_init();
+
+$sql = 'SELECT user_id, user_sig, user_sig_bbcode_uid, user_sig_bbcode_bitfield
+ FROM ' . USERS_TABLE;
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ // Convert bbcodes back to their normal form
+ if ($row['user_sig_bbcode_uid'] && $row['user_sig'])
+ {
+ decode_message($row['user_sig'], $row['user_sig_bbcode_uid']);
+
+ $message_parser->message = $row['user_sig'];
+
+ $message_parser->prepare_bbcodes();
+ $message_parser->parse_bbcode();
+
+ $bitfield = $message_parser->bbcode_bitfield;
+
+ $sql = 'UPDATE ' . USERS_TABLE . " SET user_sig_bbcode_bitfield = '" . $db->sql_escape($bitfield) . "'
+ WHERE user_id = " . $row['user_id'];
+ $db->sql_query($sql);
+
+ if ($echos > 200)
+ {
+ echo '<br />' . "\n";
+ $echos = 0;
+ }
+
+ echo '.';
+ $echos++;
+
+ flush();
+ }
+ else
+ {
+ $sql = 'UPDATE ' . USERS_TABLE . " SET user_sig_bbcode_bitfield = ''
+ WHERE user_id = " . $row['user_id'];
+ $db->sql_query($sql);
+ }
+}
+$db->sql_freeresult($result);
+
+
+// Now adjust posts
+
+$message_parser = new parse_message();
+$message_parser->mode = 'post';
+$message_parser->bbcode_init();
+
+// Update posts
+$sql = 'SELECT post_id, post_text, bbcode_uid, enable_bbcode, enable_smilies, enable_sig
+ FROM ' . POSTS_TABLE;
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ // Convert bbcodes back to their normal form
+ if ($row['enable_bbcode'])
+ {
+ decode_message($row['post_text'], $row['bbcode_uid']);
+
+ $message_parser->message = $row['post_text'];
+
+ $message_parser->prepare_bbcodes();
+ $message_parser->parse_bbcode();
+
+ $bitfield = $message_parser->bbcode_bitfield;
+
+ $sql = 'UPDATE ' . POSTS_TABLE . " SET bbcode_bitfield = '" . $db->sql_escape($bitfield) . "'
+ WHERE post_id = " . $row['post_id'];
+ $db->sql_query($sql);
+
+ if ($echos > 200)
+ {
+ echo '<br />' . "\n";
+ $echos = 0;
+ }
+
+ echo '.';
+ $echos++;
+
+ flush();
+ }
+ else
+ {
+ $sql = 'UPDATE ' . POSTS_TABLE . " SET bbcode_bitfield = ''
+ WHERE post_id = " . $row['post_id'];
+ $db->sql_query($sql);
+ }
+}
+$db->sql_freeresult($result);
+
+// Now to the private messages
+$message_parser = new parse_message();
+$message_parser->mode = 'post';
+$message_parser->bbcode_init();
+
+// Update pms
+$sql = 'SELECT msg_id, message_text, bbcode_uid, enable_bbcode
+ FROM ' . PRIVMSGS_TABLE;
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ // Convert bbcodes back to their normal form
+ if ($row['enable_bbcode'])
+ {
+ decode_message($row['message_text'], $row['bbcode_uid']);
+
+ $message_parser->message = $row['message_text'];
+
+ $message_parser->prepare_bbcodes();
+ $message_parser->parse_bbcode();
+
+ $bitfield = $message_parser->bbcode_bitfield;
+
+ $sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET bbcode_bitfield = '" . $db->sql_escape($bitfield) . "'
+ WHERE msg_id = " . $row['msg_id'];
+ $db->sql_query($sql);
+
+ if ($echos > 200)
+ {
+ echo '<br />' . "\n";
+ $echos = 0;
+ }
+
+ echo '.';
+ $echos++;
+
+ flush();
+ }
+ else
+ {
+ $sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET bbcode_bitfield = ''
+ WHERE msg_id = " . $row['msg_id'];
+ $db->sql_query($sql);
+ }
+}
+$db->sql_freeresult($result);
+
+// Done
+$db->sql_close();
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/adjust_magic_urls.php b/phpBB/develop/adjust_magic_urls.php
new file mode 100644
index 0000000000..1430a47a12
--- /dev/null
+++ b/phpBB/develop/adjust_magic_urls.php
@@ -0,0 +1,126 @@
+<?php
+/**
+* Adds class="postlink" to magic urls
+*
+* You should make a backup from your users, posts and privmsgs table in case something goes wrong
+* Forum descriptions and rules need to be re-submitted manually.
+*/
+die("Please read the first lines of this script for instructions on how to enable it");
+
+set_time_limit(0);
+
+define('IN_PHPBB', true);
+$phpbb_root_path = './../';
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+include($phpbb_root_path . 'common.'.$phpEx);
+
+// Start session management
+$user->session_begin();
+$auth->acl($user->data);
+$user->setup();
+
+$echos = 0;
+
+$replace = array(
+ '<!-- l --><a href="',
+ '<!-- m --><a href="',
+ '<!-- w --><a href="',
+);
+$with = array(
+ '<!-- l --><a class="postlink-local" href="',
+ '<!-- m --><a class="postlink" href="',
+ '<!-- w --><a class="postlink" href="',
+);
+
+// Adjust user signatures
+$sql = 'SELECT user_id, user_sig
+ FROM ' . USERS_TABLE;
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $new_content = str_replace($replace, $with, $row['user_sig']);
+
+ if ($new_content != $row['user_sig'])
+ {
+ $sql = 'UPDATE ' . USERS_TABLE . " SET user_sig = '" . $db->sql_escape($new_content) . "'
+ WHERE user_id = " . $row['user_id'];
+ $db->sql_query($sql);
+
+ if ($echos > 200)
+ {
+ echo '<br />' . "\n";
+ $echos = 0;
+ }
+
+ echo '.';
+ $echos++;
+
+ flush();
+ }
+}
+$db->sql_freeresult($result);
+
+
+// Now adjust posts
+$sql = 'SELECT post_id, post_text
+ FROM ' . POSTS_TABLE;
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $new_content = str_replace($replace, $with, $row['post_text']);
+
+ if ($row['post_text'] != $new_content)
+ {
+ $sql = 'UPDATE ' . POSTS_TABLE . " SET post_text = '" . $db->sql_escape($new_content) . "'
+ WHERE post_id = " . $row['post_id'];
+ $db->sql_query($sql);
+
+ if ($echos > 200)
+ {
+ echo '<br />' . "\n";
+ $echos = 0;
+ }
+
+ echo '.';
+ $echos++;
+
+ flush();
+ }
+}
+$db->sql_freeresult($result);
+
+// Now to the private messages
+$sql = 'SELECT msg_id, message_text
+ FROM ' . PRIVMSGS_TABLE;
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $new_content = str_replace($replace, $with, $row['message_text']);
+
+ if ($row['message_text'] != $new_content)
+ {
+ $sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET bbcode_bitfield = '" . $db->sql_escape($new_content) . "'
+ WHERE msg_id = " . $row['msg_id'];
+ $db->sql_query($sql);
+
+ if ($echos > 200)
+ {
+ echo '<br />' . "\n";
+ $echos = 0;
+ }
+
+ echo '.';
+ $echos++;
+
+ flush();
+ }
+}
+$db->sql_freeresult($result);
+
+// Done
+$db->sql_close();
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/adjust_sizes.php b/phpBB/develop/adjust_sizes.php
new file mode 100644
index 0000000000..7d72813056
--- /dev/null
+++ b/phpBB/develop/adjust_sizes.php
@@ -0,0 +1,132 @@
+<?php
+/**
+* Only adjust the [size] bbcode tag from pc to percent.
+*
+* You should make a backup from your users, posts and privmsgs table in case something goes wrong
+* Forum descriptions and rules need to be re-submitted manually if they use the [size] tag.
+*
+* Since we limit the match to the sizes from 0 to 29 no newly applied sizes should be affected...
+*/
+die("Please read the first lines of this script for instructions on how to enable it");
+
+set_time_limit(0);
+@ini_set('memory_limit', '128M');
+
+define('IN_PHPBB', true);
+$phpbb_root_path = './../';
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+include($phpbb_root_path . 'common.'.$phpEx);
+
+// Start session management
+$user->session_begin();
+$auth->acl($user->data);
+$user->setup();
+
+$echos = 0;
+
+function replace_size($matches)
+{
+ return '[size=' . ceil(100.0 * (((double) $matches[1])/12.0)) . ':' . $matches[2] . ']';
+}
+
+// Adjust user signatures
+$sql = 'SELECT user_id, user_sig, user_sig_bbcode_uid
+ FROM ' . USERS_TABLE;
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $bbcode_uid = $row['user_sig_bbcode_uid'];
+
+ // Only if a bbcode uid is present, the signature present and a size tag used...
+ if ($bbcode_uid && $row['user_sig'] && strpos($row['user_sig'], '[size=') !== false)
+ {
+ $row['user_sig'] = preg_replace_callback('/\[size=(\d*):(' . $bbcode_uid . ')\]/', 'replace_size', $row['user_sig']);
+
+ $sql = 'UPDATE ' . USERS_TABLE . " SET user_sig = '" . $db->sql_escape($row['user_sig']) . "'
+ WHERE user_id = " . $row['user_id'];
+ $db->sql_query($sql);
+
+ if ($echos > 200)
+ {
+ echo '<br />' . "\n";
+ $echos = 0;
+ }
+
+ echo '.';
+ $echos++;
+
+ flush();
+ }
+}
+$db->sql_freeresult($result);
+
+
+// Now adjust posts
+$sql = 'SELECT post_id, post_text, bbcode_uid, enable_bbcode
+ FROM ' . POSTS_TABLE;
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $bbcode_uid = $row['bbcode_uid'];
+
+ // Only if a bbcode uid is present, bbcode enabled and a size tag used...
+ if ($row['enable_bbcode'] && $bbcode_uid && strpos($row['post_text'], '[size=') !== false)
+ {
+ $row['post_text'] = preg_replace_callback('/\[size=(\d*):' . $bbcode_uid . '\]/', 'replace_size', $row['post_text']);
+
+ $sql = 'UPDATE ' . POSTS_TABLE . " SET post_text = '" . $db->sql_escape($row['post_text']) . "'
+ WHERE post_id = " . $row['post_id'];
+ $db->sql_query($sql);
+
+ if ($echos > 200)
+ {
+ echo '<br />' . "\n";
+ $echos = 0;
+ }
+
+ echo '.';
+ $echos++;
+
+ flush();
+ }
+}
+$db->sql_freeresult($result);
+
+// Now to the private messages
+$sql = 'SELECT msg_id, message_text, bbcode_uid, enable_bbcode
+ FROM ' . PRIVMSGS_TABLE;
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $bbcode_uid = $row['bbcode_uid'];
+
+ // Only if a bbcode uid is present, bbcode enabled and a size tag used...
+ if ($row['enable_bbcode'] && $bbcode_uid && strpos($row['message_text'], '[size=') !== false)
+ {
+ $row['message_text'] = preg_replace_callback('/\[size=(\d*):' . $bbcode_uid . '\]/', 'replace_size', $row['message_text']);
+
+ $sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET message_text = '" . $db->sql_escape($row['message_text']) . "'
+ WHERE msg_id = " . $row['msg_id'];
+ $db->sql_query($sql);
+
+ if ($echos > 200)
+ {
+ echo '<br />' . "\n";
+ $echos = 0;
+ }
+
+ echo '.';
+ $echos++;
+
+ flush();
+ }
+}
+$db->sql_freeresult($result);
+
+// Done
+$db->sql_close();
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/adjust_smilies.php b/phpBB/develop/adjust_smilies.php
new file mode 100644
index 0000000000..774c8834f6
--- /dev/null
+++ b/phpBB/develop/adjust_smilies.php
@@ -0,0 +1,130 @@
+<?php
+/**
+* Updates smilies that were changed to the new ones
+*/
+die("Please read the first lines of this script for instructions on how to enable it");
+
+set_time_limit(0);
+
+define('IN_PHPBB', true);
+$phpbb_root_path = './../';
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+include($phpbb_root_path . 'common.'.$phpEx);
+
+// Start session management
+$user->session_begin();
+$auth->acl($user->data);
+$user->setup();
+
+$echos = 0;
+
+$replace = array(
+ '<img src="{SMILIES_PATH}/icon_biggrin.gif',
+ '<img src="{SMILIES_PATH}/icon_confused.gif',
+ '<img src="{SMILIES_PATH}/icon_sad.gif',
+ '<img src="{SMILIES_PATH}/icon_smile.gif',
+ '<img src="{SMILIES_PATH}/icon_surprised.gif',
+ '<img src="{SMILIES_PATH}/icon_wink.gif',
+);
+
+$with = array(
+ '<img src="{SMILIES_PATH}/icon_e_biggrin.gif',
+ '<img src="{SMILIES_PATH}/icon_e_confused.gif',
+ '<img src="{SMILIES_PATH}/icon_e_sad.gif',
+ '<img src="{SMILIES_PATH}/icon_e_smile.gif',
+ '<img src="{SMILIES_PATH}/icon_e_surprised.gif',
+ '<img src="{SMILIES_PATH}/icon_e_wink.gif',
+);
+
+// Adjust user signatures
+$sql = 'SELECT user_id, user_sig
+ FROM ' . USERS_TABLE;
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $new_content = str_replace($replace, $with, $row['user_sig']);
+
+ if ($new_content != $row['user_sig'])
+ {
+ $sql = 'UPDATE ' . USERS_TABLE . " SET user_sig = '" . $db->sql_escape($new_content) . "'
+ WHERE user_id = " . $row['user_id'];
+ $db->sql_query($sql);
+
+ if ($echos > 200)
+ {
+ echo '<br />' . "\n";
+ $echos = 0;
+ }
+
+ echo '.';
+ $echos++;
+
+ flush();
+ }
+}
+$db->sql_freeresult($result);
+
+
+// Now adjust posts
+$sql = 'SELECT post_id, post_text
+ FROM ' . POSTS_TABLE;
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $new_content = str_replace($replace, $with, $row['post_text']);
+
+ if ($row['post_text'] != $new_content)
+ {
+ $sql = 'UPDATE ' . POSTS_TABLE . " SET post_text = '" . $db->sql_escape($new_content) . "'
+ WHERE post_id = " . $row['post_id'];
+ $db->sql_query($sql);
+
+ if ($echos > 200)
+ {
+ echo '<br />' . "\n";
+ $echos = 0;
+ }
+
+ echo '.';
+ $echos++;
+
+ flush();
+ }
+}
+$db->sql_freeresult($result);
+
+// Now to the private messages
+$sql = 'SELECT msg_id, message_text
+ FROM ' . PRIVMSGS_TABLE;
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $new_content = str_replace($replace, $with, $row['message_text']);
+
+ if ($row['message_text'] != $new_content)
+ {
+ $sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET bbcode_bitfield = '" . $db->sql_escape($new_content) . "'
+ WHERE msg_id = " . $row['msg_id'];
+ $db->sql_query($sql);
+
+ if ($echos > 200)
+ {
+ echo '<br />' . "\n";
+ $echos = 0;
+ }
+
+ echo '.';
+ $echos++;
+
+ flush();
+ }
+}
+$db->sql_freeresult($result);
+
+// Done
+$db->sql_close();
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/adjust_uids.php b/phpBB/develop/adjust_uids.php
new file mode 100644
index 0000000000..d301f3cadb
--- /dev/null
+++ b/phpBB/develop/adjust_uids.php
@@ -0,0 +1,129 @@
+<?php
+/**
+* Repair bbcodes converted with RC6
+*
+* You should make a backup from your users, posts and privmsgs table in case something goes wrong
+* Forum descriptions and rules need to be re-submitted manually
+*
+*/
+die("Please read the first lines of this script for instructions on how to enable it");
+
+set_time_limit(0);
+@ini_set('memory_limit', '512M');
+
+define('IN_PHPBB', true);
+$phpbb_root_path = './../';
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+include($phpbb_root_path . 'common.'.$phpEx);
+
+// Start session management
+$user->session_begin();
+$auth->acl($user->data);
+$user->setup();
+
+$echos = 0;
+
+
+// Adjust user signatures
+$sql = 'SELECT user_id, user_sig, user_sig_bbcode_uid
+ FROM ' . USERS_TABLE . '
+ ORDER BY user_id ASC';
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $bbcode_uid = $row['user_sig_bbcode_uid'];
+
+ // Only if a bbcode uid is present, the signature present and a size tag used...
+ if (!empty($bbcode_uid) && strpos($row['user_sig'], $bbcode_uid) === false)
+ {
+ $row['user_sig'] = preg_replace('/\:[0-9a-z]{8}\]/', ":$bbcode_uid]", $row['user_sig']);
+
+ $sql = 'UPDATE ' . USERS_TABLE . " SET user_sig = '" . $db->sql_escape($row['user_sig']) . "'
+ WHERE user_id = " . $row['user_id'];
+ $db->sql_query($sql);
+
+ if ($echos > 200)
+ {
+ echo '<br />User: ' . "{$row['user_id']}\n";
+ $echos = 0;
+ }
+
+ echo '.';
+ $echos++;
+
+ flush();
+ }
+}
+$db->sql_freeresult($result);
+
+
+// Now adjust posts
+$sql = 'SELECT post_id, post_text, bbcode_uid, enable_bbcode
+ FROM ' . POSTS_TABLE . '
+ ORDER BY post_id ASC';
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $bbcode_uid = $row['bbcode_uid'];
+
+ // Only if a bbcode uid is present, bbcode enabled and a size tag used...
+ if ($row['enable_bbcode'] && !empty($bbcode_uid) && strpos($row['post_text'], $bbcode_uid) === false)
+ {
+ $row['post_text'] = preg_replace('/\:[0-9a-z]{8}\]/', ":$bbcode_uid]", $row['post_text']);
+
+ $sql = 'UPDATE ' . POSTS_TABLE . " SET post_text = '" . $db->sql_escape($row['post_text']) . "'
+ WHERE post_id = " . $row['post_id'];
+ $db->sql_query($sql);
+
+ if ($echos > 200)
+ {
+ echo '<br />Post: ' . "{$row['post_id']} \n";
+ $echos = 0;
+ }
+
+ echo '.';
+ $echos++;
+
+ flush();
+ }
+}
+$db->sql_freeresult($result);
+
+// Now to the private messages
+$sql = 'SELECT msg_id, message_text, bbcode_uid, enable_bbcode
+ FROM ' . PRIVMSGS_TABLE;
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $bbcode_uid = $row['bbcode_uid'];
+
+ // Only if a bbcode uid is present, bbcode enabled and a size tag used...
+ if ($row['enable_bbcode'] && !empty($bbcode_uid) && strpos($row['message_text'], $bbcode_uid) === false)
+ {
+ $row['message_text'] = preg_replace('/\:[0-9a-z]{8}\]/', ":$bbcode_uid]", $row['message_text']);
+
+ $sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET message_text = '" . $db->sql_escape($row['message_text']) . "'
+ WHERE msg_id = " . $row['msg_id'];
+ $db->sql_query($sql);
+
+ if ($echos > 200)
+ {
+ echo '<br />' . "\n";
+ $echos = 0;
+ }
+
+ echo '.';
+ $echos++;
+
+ flush();
+ }
+}
+$db->sql_freeresult($result);
+
+// Done
+$db->sql_close();
+echo 'done';
+?> \ No newline at end of file
diff --git a/phpBB/develop/adjust_usernames.php b/phpBB/develop/adjust_usernames.php
new file mode 100644
index 0000000000..1afa77af16
--- /dev/null
+++ b/phpBB/develop/adjust_usernames.php
@@ -0,0 +1,52 @@
+<?php
+/**
+* Adjust username_clean column.
+*
+* You should make a backup from your users table in case something goes wrong
+*/
+die("Please read the first lines of this script for instructions on how to enable it");
+
+set_time_limit(0);
+
+define('IN_PHPBB', true);
+$phpbb_root_path = './../';
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+include($phpbb_root_path . 'common.'.$phpEx);
+
+// Start session management
+$user->session_begin();
+$auth->acl($user->data);
+$user->setup();
+
+$echos = 0;
+
+$sql = 'SELECT user_id, username
+ FROM ' . USERS_TABLE;
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $sql = 'UPDATE ' . USERS_TABLE . "
+ SET username_clean = '" . $db->sql_escape(utf8_clean_string($row['username'])) . "'
+ WHERE user_id = " . $row['user_id'];
+ $db->sql_query($sql);
+
+ if ($echos > 200)
+ {
+ echo '<br />' . "\n";
+ $echos = 0;
+ }
+
+ echo '.';
+ $echos++;
+
+ flush();
+}
+$db->sql_freeresult($result);
+
+echo 'FINISHED';
+
+// Done
+$db->sql_close();
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/benchmark.php b/phpBB/develop/benchmark.php
new file mode 100644
index 0000000000..5bbe6f53be
--- /dev/null
+++ b/phpBB/develop/benchmark.php
@@ -0,0 +1,462 @@
+<?php
+
+//
+// Security message:
+//
+// This script is potentially dangerous.
+// Remove or comment the next line (die(".... ) to enable this script.
+// Do NOT FORGET to either remove this script or disable it after you have used it.
+//
+die("Please read the first lines of this script for instructions on how to enable it");
+
+//
+// Do not change anything below this line.
+//
+
+
+$phpbb_root_path = "../";
+include($phpbb_root_path . 'extension.inc');
+include($phpbb_root_path . 'common.'.$phpEx);
+include($phpbb_root_path . 'includes/post.'.$phpEx);
+include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
+
+srand ((double) microtime() * 1000000);
+set_time_limit(240*60);
+
+// Here's the text we stick in posts..
+$bigass_text = '
+phpBB BBCode test suite v0.0.2
+auto-linkification:
+http://something.com
+www.something.com
+nate@phpbb.com
+http://something.com/foo.php?this=that&theother=some%20encoded%20string is a link.
+[code]
+Simple code block with some <html> <tags>.
+[/code]
+[b]bolded[/b], [i]italic[/i]
+[email]james@totalgeek.org[/email]
+[url=http://www.totalgeek.org]totalgeek.org[/url]
+[url]www.totalgeek.org[/url]
+[list]
+[*] This is the first bulleted item.
+[*] This is the second bulleted item.
+[/list]
+[list=A]
+[*] This is the first bulleted item.
+[*] This is the second bulleted item.
+[/list]
+[quote]
+And a quote!
+[/quote]
+';
+
+
+// The script expects the ID's in the tables to sequential (1,2,3,4,5),
+// so no holes please (1,4,5,8)...
+$nr_of_users = nrof(USERS_TABLE);
+$nr_of_cats = nrof(CATEGORIES_TABLE);
+$nr_of_forums = nrof(FORUMS_TABLE);
+$nr_of_posts = nrof(POSTS_TABLE);
+
+$u = $users;
+
+$starttime = microtime();
+
+$usercreationcount = 0;
+while($users > 0)
+{
+
+ $name = "testuser_" . substr(md5(uniqid(rand())), 0, 10);
+ if (make_user($name))
+ {
+ $usercreationcount++;
+ $users--;
+ }
+ if (($usercreationcount % 500) == 0)
+ {
+ echo "status: $usercreationcount <br>\n";
+ flush();
+ }
+
+}
+
+if ($posts > 0)
+{
+ filldb($posts);
+}
+
+$endtime = microtime();
+
+if ($submit="" || !isset($submit))
+{
+ ?>
+Hello, welcome to this little phpBB Benchmarking script :)<p>
+
+At the moment there are:<br>
+
+<table>
+<tr><td align="right"><?php echo $nr_of_users?></td><td>Users</td></tr>
+<tr><td align="right"><?php echo $nr_of_forums?></td><td>Forums</td></tr>
+<tr><td align="right"><?php echo $nr_of_posts?></td><td>Posts</td></tr>
+</table>
+<p>
+What do you want to create?<p>
+
+<form method="get" action="<?php echo $PHP_SELF?>">
+<input type="text" name="users" size="3"> Users<br>
+<input type="text" name="posts" size="3"> Posts/topics (optional: post size in <input type="text" name="size" size="3"> bytes)<br>
+<input type="submit" name="submit">
+</form>
+
+ <?php
+}
+else
+{
+
+ list ($starttime_msec,$starttime_sec) = explode(" ",$starttime);
+ list ($endtime_msec,$endtime_sec) = explode(" ",$endtime);
+ $timetaken_sec = ($endtime_sec+$endtime_msec) - ($starttime_sec+$starttime_msec);
+ print "<B>TIME TAKEN : ".$timetaken_sec."s</B><BR>\n";
+
+ print "<p>\n<a href=\"$PHP_SELF\">Back to the overview page</a>\n";
+}
+
+
+function filldb($newposts)
+{
+ global $nr_of_forums;
+ global $nr_of_users;
+
+ $forum_topic_counts = array();
+
+ for ($i = 1; $i <= $nr_of_forums; $i++)
+ {
+ $forum_topic_counts[$i] = get_topic_count($i);
+ }
+
+ for($i = 0; $i < $newposts; $i++)
+ {
+ $userid = rand(2, $nr_of_users - 1);
+ $forum = rand(1,$nr_of_forums);
+
+ if ((rand(0,30) < 1) || ($forum_topic_count[$forum] == 0))
+ {
+ // create a new topic 1 in 30 times (or when there are none);
+ $topic = make_topic($userid, "Testing topic $i", $forum);
+ $forum_topic_count[$forum]++;
+ }
+ else
+ {
+ // Otherwise create a reply(posting) somewhere.
+ $topic = get_smallest_topic($forum);
+ create_posting($userid, $topic, $forum, "reply");
+ }
+
+ if (($i % 1000) == 0)
+ {
+ echo "status: $i <br>";
+ flush();
+ }
+
+ }
+}
+
+
+function get_smallest_topic($forum_id)
+{
+ global $db;
+
+ $sql = "SELECT topic_id
+ FROM " . TOPICS_TABLE . "
+ WHERE (forum_id = $forum_id)
+ ORDER BY topic_replies ASC LIMIT 1";
+ if($result = $db->sql_query($sql))
+ {
+ $row = $db->sql_fetchrow($result);
+ $topic_id = $row['topic_id'];
+
+ unset($result);
+ unset($row);
+ return $topic_id;
+ }
+ else
+ {
+ message_die(GENERAL_ERROR, "Couldn't get smallest topic.", "", __LINE__, __FILE__, $sql);
+ }
+
+}
+
+
+function get_topic_count($forum_id)
+{
+ global $db;
+
+ $sql = "SELECT forum_topics
+ FROM " . FORUMS_TABLE . "
+ WHERE (forum_id = $forum_id)";
+ if($result = $db->sql_query($sql))
+ {
+ $row = $db->sql_fetchrow($result);
+ $topic_count = $row['forum_topics'];
+
+ unset($result);
+ unset($row);
+ return $topic_count;
+ }
+ else
+ {
+ message_die(GENERAL_ERROR, "Couldn't get topic count.", "", __LINE__, __FILE__, $sql);
+ }
+
+}
+
+
+function make_topic($user_id, $subject, $forum_id)
+{
+ global $db;
+ $topic_type = POST_NORMAL;
+ $topic_vote = 0;
+ $current_time = time();
+
+ $sql = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote)
+ VALUES ('$subject', $user_id, $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_vote)";
+
+ if( $result = $db->sql_query($sql, BEGIN_TRANSACTION) )
+ {
+ $new_topic_id = $db->sql_nextid();
+ }
+ else
+ {
+ message_die(GENERAL_ERROR, "Error inserting data into topics table", "", __LINE__, __FILE__, $sql);
+ }
+
+ create_posting($user_id, $new_topic_id, $forum_id);
+
+ return $new_topic_id;
+}
+
+
+
+function create_posting($userid, $topic_id, $forum, $mode='newtopic')
+{
+ $message = generatepost();
+
+ return make_post($topic_id, $forum, $userid, "", $message, $mode);
+
+}
+
+
+
+function make_post($new_topic_id, $forum_id, $user_id, $post_username, $text, $mode='newtopic')
+{
+ global $db;
+ $current_time = time();
+ $user_ip = "ac100202";
+ $bbcode_on = 1;
+ $html_on = 1;
+ $smilies_on = 1;
+ $attach_sig = 1;
+ $bbcode_uid = make_bbcode_uid();
+
+ $post_subject = 'random subject';
+
+ $post_message = prepare_message($text, $html_on, $bbcode_on, $smilies_on, $bbcode_uid);
+
+ $sql = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, attach_id, icon_id, post_username, post_time, poster_ip, post_approved, bbcode_uid, enable_bbcode, enable_html, enable_smilies, enable_sig, post_subject, post_text)
+ VALUES ($new_topic_id, $forum_id, $user_id, 0, 0, '$post_username', $current_time, '$user_ip', 1, '$bbcode_uid', $bbcode_on, $html_on, $smilies_on, $attach_sig, '$post_subject', '$post_message')";
+ $result = $db->sql_query($sql);
+
+ if ($result)
+ {
+ $new_post_id = $db->sql_nextid();
+
+ $sql = "UPDATE " . TOPICS_TABLE . "
+ SET topic_last_post_id = $new_post_id";
+ if($mode == "reply")
+ {
+ $sql .= ", topic_replies = topic_replies + 1 ";
+ }
+ $sql .= " WHERE topic_id = $new_topic_id";
+
+ if($db->sql_query($sql))
+ {
+ $sql = "UPDATE " . FORUMS_TABLE . "
+ SET forum_last_post_id = $new_post_id, forum_posts = forum_posts + 1";
+ if($mode == "newtopic")
+ {
+ $sql .= ", forum_topics = forum_topics + 1";
+ }
+ $sql .= " WHERE forum_id = $forum_id";
+
+ if($db->sql_query($sql))
+ {
+ $sql = "UPDATE " . USERS_TABLE . "
+ SET user_posts = user_posts + 1
+ WHERE user_id = " . $user_id;
+
+ if($db->sql_query($sql, END_TRANSACTION))
+ {
+ // SUCCESS.
+ return true;
+ }
+ else
+ {
+ message_die(GENERAL_ERROR, "Error updating users table", "", __LINE__, __FILE__, $sql);
+ }
+ }
+ else
+ {
+ message_die(GENERAL_ERROR, "Error updating forums table", "", __LINE__, __FILE__, $sql);
+ }
+ }
+ else
+ {
+ // Rollback
+ if($db->sql_layer == "mysql")
+ {
+ $sql = "DELETE FROM " . POSTS_TABLE . "
+ WHERE post_id = $new_post_id";
+ $db->sql_query($sql);
+ }
+ message_die(GENERAL_ERROR, "Error updating topics table", "", __LINE__, __FILE__, $sql);
+ }
+ }
+ else
+ {
+ message_die(GENERAL_ERROR, "Error inserting data into posts table", "", __LINE__, __FILE__, $sql);
+ }
+}
+
+
+function generatepost($size=850)
+{
+ global $bigass_text;
+ // Returns a string with a length between $size and $size*0.2
+ $size = rand(0.2*$size, $size);
+
+ $textsize = strlen($bigass_text);
+ $currentsize = 0;
+ // Add whole $text multiple times
+ while($currentsize < $size && $size-$currentsize <= $textsize)
+ {
+ $message .= $bigass_text;
+ $currentsize += $textsize;
+ }
+ // Add the remainder number of chars and return it.
+ $message .= substr($bigass_text, 0, $size-$currentsize);
+
+ return (addslashes($message));
+}
+
+
+function nrof($table)
+{
+ global $db;
+ $sql = "SELECT count(*) AS counted FROM $table";
+ $result = $db->sql_query($sql);
+ $topics = $db->sql_fetchrow($result);
+ return $topics[counted];
+}
+
+
+function make_user($username)
+{
+ global $db, $board_config;
+
+ $password = md5("benchpass");
+ $email = "nobody@localhost";
+ $icq = "12345678";
+ $website = "http://www.phpbb.com";
+ $occupation = "phpBB tester";
+ $location = "phpBB world hq";
+ $interests = "Eating, sleeping, living, and breathing phpBB";
+ $signature = "$username: phpBB tester.";
+ $signature_bbcode_uid = "";
+ $avatar_filename = "";
+ $viewemail = 0;
+ $aim = 0;
+ $yim = 0;
+ $msn = 0;
+ $attachsig = 1;
+ $allowsmilies = 1;
+ $allowhtml = 1;
+ $allowbbcode = 1;
+ $allowviewonline = 1;
+ $notifyreply = 0;
+ $notifypm = 0;
+ $user_timezone = $board_config['board_timezone'];
+ $user_dateformat = $board_config['default_dateformat'];
+ $user_lang = $board_config['default_lang'];
+ $user_style = $board_config['default_style'];
+
+
+ $sql = "SELECT MAX(user_id) AS total
+ FROM " . USERS_TABLE;
+ if($result = $db->sql_query($sql))
+ {
+ $row = $db->sql_fetchrow($result);
+ $new_user_id = $row['total'] + 1;
+
+ unset($result);
+ unset($row);
+ }
+ else
+ {
+ message_die(GENERAL_ERROR, "Couldn't obtained next user_id information.", "", __LINE__, __FILE__, $sql);
+ }
+
+ $sql = "SELECT MAX(group_id) AS total
+ FROM " . GROUPS_TABLE;
+ if($result = $db->sql_query($sql))
+ {
+ $row = $db->sql_fetchrow($result);
+ $new_group_id = $row['total'] + 1;
+
+ unset($result);
+ unset($row);
+ }
+ else
+ {
+ message_die(GENERAL_ERROR, "Couldn't obtained next user_id information.", "", __LINE__, __FILE__, $sql);
+ }
+
+
+ $sql = "INSERT INTO " . USERS_TABLE . " (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmilies, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey)
+ VALUES ($new_user_id, '$username', " . time() . ", '$password', '$email', '$icq', '$website', '$occupation', '$location', '$interests', '$signature', '$signature_bbcode_uid', '$avatar_filename', $viewemail, '$aim', '$yim', '$msn', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $user_timezone, '$user_dateformat', '$user_lang', $user_style, 0, 1, ";
+
+
+ $sql .= "1, '')";
+
+ if($result = $db->sql_query($sql, BEGIN_TRANSACTION))
+ {
+ $sql = "INSERT INTO " . GROUPS_TABLE . " (group_id, group_name, group_description, group_single_user, group_moderator)
+ VALUES ($new_group_id, '', 'Personal User', 1, 0)";
+ if($result = $db->sql_query($sql))
+ {
+ $sql = "INSERT INTO " . USER_GROUP_TABLE . " (user_id, group_id, user_pending)
+ VALUES ($new_user_id, $new_group_id, 0)";
+ if($result = $db->sql_query($sql, END_TRANSACTION))
+ {
+
+ // SUCCESS.
+ return true;
+ }
+ else
+ {
+ message_die(GENERAL_ERROR, "Couldn't insert data into user_group table", "", __LINE__, __FILE__, $sql);
+ }
+ }
+ else
+ {
+ message_die(GENERAL_ERROR, "Couldn't insert data into groups table", "", __LINE__, __FILE__, $sql);
+ }
+ }
+ else
+ {
+ message_die(GENERAL_ERROR, "Couldn't insert data into users table", "", __LINE__, __FILE__, $sql);
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/calc_email_hash.php b/phpBB/develop/calc_email_hash.php
new file mode 100644
index 0000000000..a67b0f52a3
--- /dev/null
+++ b/phpBB/develop/calc_email_hash.php
@@ -0,0 +1,76 @@
+<?php
+// -------------------------------------------------------------
+//
+// $Id$
+//
+// FILENAME : calc_email_hash.php
+// STARTED : Tue Feb 03, 2004
+// COPYRIGHT : � 2004 phpBB Group
+// WWW : http://www.phpbb.com/
+// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
+//
+// -------------------------------------------------------------
+
+//
+// Security message:
+//
+// This script is potentially dangerous.
+// Remove or comment the next line (die(".... ) to enable this script.
+// Do NOT FORGET to either remove this script or disable it after you have used it.
+//
+die("Please read the first lines of this script for instructions on how to enable it");
+@set_time_limit(300);
+
+$db = $dbhost = $dbuser = $dbpasswd = $dbport = $dbname = '';
+
+define('IN_PHPBB', 1);
+define('ANONYMOUS', 1);
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+$phpbb_root_path='./../';
+include($phpbb_root_path . 'config.'.$phpEx);
+require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.'.$phpEx);
+require($phpbb_root_path . 'includes/db/' . $dbms . '.'.$phpEx);
+include($phpbb_root_path . 'includes/functions.'.$phpEx);
+
+$cache = new acm();
+$db = new sql_db();
+
+// Connect to DB
+$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
+
+$start = 0;
+do
+{
+ // Batch query for group members, call group_user_del
+ $sql = "SELECT user_id, user_email
+ FROM {$table_prefix}users
+ LIMIT $start, 100";
+ $result = $db->sql_query($sql);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ do
+ {
+ $sql = "UPDATE {$table_prefix}users
+ SET user_email_hash = " . (crc32(strtolower($row['user_email'])) . strlen($row['user_email'])) . '
+ WHERE user_id = ' . $row['user_id'];
+ $db->sql_query($sql);
+
+ $start++;
+ }
+ while ($row = $db->sql_fetchrow($result));
+
+ echo "<br />Batch -> $start\n";
+ flush();
+ }
+ else
+ {
+ $start = 0;
+ }
+ $db->sql_freeresult($result);
+}
+while ($start);
+
+echo "<p><b>Done</b></p>\n";
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/change_smiley_ref.php b/phpBB/develop/change_smiley_ref.php
new file mode 100644
index 0000000000..db65dd52d4
--- /dev/null
+++ b/phpBB/develop/change_smiley_ref.php
@@ -0,0 +1,62 @@
+<?php
+/***************************************************************************
+ * merge_clean_posts.php
+ * -------------------
+ * begin : Tuesday, February 25, 2003
+ * copyright : (C) 2003 The phpBB Group
+ * email : support@phpbb.com
+ *
+ * $Id$
+ *
+ ***************************************************************************/
+
+/***************************************************************************
+ *
+ * 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.
+ *
+ ***************************************************************************/
+
+//
+// Security message:
+//
+// This script is potentially dangerous.
+// Remove or comment the next line (die(".... ) to enable this script.
+// Do NOT FORGET to either remove this script or disable it after you have used it.
+//
+die("Please read the first lines of this script for instructions on how to enable it");
+
+@set_time_limit(2400);
+
+// This script adds missing permissions
+$db = $dbhost = $dbuser = $dbpasswd = $dbport = $dbname = '';
+
+define('IN_PHPBB', 1);
+define('ANONYMOUS', 1);
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+$phpbb_root_path='./../';
+include($phpbb_root_path . 'config.'.$phpEx);
+require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.'.$phpEx);
+require($phpbb_root_path . 'includes/db/' . $dbms . '.'.$phpEx);
+include($phpbb_root_path . 'includes/functions.'.$phpEx);
+
+$cache = new acm();
+$db = new $sql_db();
+
+// Connect to DB
+$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
+
+$sql = "SELECT post_id, post_text FROM {$table_prefix}posts WHERE post_text LIKE '%{SMILE_PATH}%'";
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $db->sql_query("UPDATE {$table_prefix}posts SET post_text = '" . $db->sql_escape(str_replace('{SMILE_PATH}', '{SMILIES_PATH}', $row['post_text'])) . "' WHERE post_id = " . $row['post_id']);
+}
+$db->sql_freeresult($result);
+
+echo "<p><b>Done</b></p>\n";
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/collect_cache_stats.sh b/phpBB/develop/collect_cache_stats.sh
new file mode 100755
index 0000000000..5bb31c5173
--- /dev/null
+++ b/phpBB/develop/collect_cache_stats.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+DIR=$(dirname "$0")/../cache;
+cat "$DIR/sql_*.php" | grep '/* SELECT' | sed 's,/\* ,,;s, \*/,,' | sort
diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php
new file mode 100644
index 0000000000..b9017937c8
--- /dev/null
+++ b/phpBB/develop/create_schema_files.php
@@ -0,0 +1,2048 @@
+<?php
+/**
+*
+* @package phpBB3
+* @version $Id$
+* @copyright (c) 2006 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+* This file creates new schema files for every database.
+* The filenames will be prefixed with an underscore to not overwrite the current schema files.
+*
+* If you overwrite the original schema files please make sure you save the file with UNIX linefeeds.
+*/
+
+die("Please read the first lines of this script for instructions on how to enable it");
+
+@set_time_limit(0);
+
+$schema_path = './../install/schemas/';
+
+if (!is_writable($schema_path))
+{
+ die('Schema path not writable');
+}
+
+$schema_data = get_schema_struct();
+$dbms_type_map = array(
+ 'mysql_41' => array(
+ 'INT:' => 'int(%d)',
+ 'BINT' => 'bigint(20)',
+ 'UINT' => 'mediumint(8) UNSIGNED',
+ 'UINT:' => 'int(%d) UNSIGNED',
+ 'TINT:' => 'tinyint(%d)',
+ 'USINT' => 'smallint(4) UNSIGNED',
+ 'BOOL' => 'tinyint(1) UNSIGNED',
+ 'VCHAR' => 'varchar(255)',
+ 'VCHAR:' => 'varchar(%d)',
+ 'CHAR:' => 'char(%d)',
+ 'XSTEXT' => 'text',
+ 'XSTEXT_UNI'=> 'varchar(100)',
+ 'STEXT' => 'text',
+ 'STEXT_UNI' => 'varchar(255)',
+ 'TEXT' => 'text',
+ 'TEXT_UNI' => 'text',
+ 'MTEXT' => 'mediumtext',
+ 'MTEXT_UNI' => 'mediumtext',
+ 'TIMESTAMP' => 'int(11) UNSIGNED',
+ 'DECIMAL' => 'decimal(5,2)',
+ 'DECIMAL:' => 'decimal(%d,2)',
+ 'PDECIMAL' => 'decimal(6,3)',
+ 'PDECIMAL:' => 'decimal(%d,3)',
+ 'VCHAR_UNI' => 'varchar(255)',
+ 'VCHAR_UNI:'=> 'varchar(%d)',
+ 'VCHAR_CI' => 'varchar(255)',
+ 'VARBINARY' => 'varbinary(255)',
+ ),
+
+ 'mysql_40' => array(
+ 'INT:' => 'int(%d)',
+ 'BINT' => 'bigint(20)',
+ 'UINT' => 'mediumint(8) UNSIGNED',
+ 'UINT:' => 'int(%d) UNSIGNED',
+ 'TINT:' => 'tinyint(%d)',
+ 'USINT' => 'smallint(4) UNSIGNED',
+ 'BOOL' => 'tinyint(1) UNSIGNED',
+ 'VCHAR' => 'varbinary(255)',
+ 'VCHAR:' => 'varbinary(%d)',
+ 'CHAR:' => 'binary(%d)',
+ 'XSTEXT' => 'blob',
+ 'XSTEXT_UNI'=> 'blob',
+ 'STEXT' => 'blob',
+ 'STEXT_UNI' => 'blob',
+ 'TEXT' => 'blob',
+ 'TEXT_UNI' => 'blob',
+ 'MTEXT' => 'mediumblob',
+ 'MTEXT_UNI' => 'mediumblob',
+ 'TIMESTAMP' => 'int(11) UNSIGNED',
+ 'DECIMAL' => 'decimal(5,2)',
+ 'DECIMAL:' => 'decimal(%d,2)',
+ 'PDECIMAL' => 'decimal(6,3)',
+ 'PDECIMAL:' => 'decimal(%d,3)',
+ 'VCHAR_UNI' => 'blob',
+ 'VCHAR_UNI:'=> array('varbinary(%d)', 'limit' => array('mult', 3, 255, 'blob')),
+ 'VCHAR_CI' => 'blob',
+ 'VARBINARY' => 'varbinary(255)',
+ ),
+
+ 'firebird' => array(
+ 'INT:' => 'INTEGER',
+ 'BINT' => 'DOUBLE PRECISION',
+ 'UINT' => 'INTEGER',
+ 'UINT:' => 'INTEGER',
+ 'TINT:' => 'INTEGER',
+ 'USINT' => 'INTEGER',
+ 'BOOL' => 'INTEGER',
+ 'VCHAR' => 'VARCHAR(255) CHARACTER SET NONE',
+ 'VCHAR:' => 'VARCHAR(%d) CHARACTER SET NONE',
+ 'CHAR:' => 'CHAR(%d) CHARACTER SET NONE',
+ 'XSTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE',
+ 'STEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE',
+ 'TEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE',
+ 'MTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE',
+ 'XSTEXT_UNI'=> 'VARCHAR(100) CHARACTER SET UTF8',
+ 'STEXT_UNI' => 'VARCHAR(255) CHARACTER SET UTF8',
+ 'TEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8',
+ 'MTEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8',
+ 'TIMESTAMP' => 'INTEGER',
+ 'DECIMAL' => 'DOUBLE PRECISION',
+ 'DECIMAL:' => 'DOUBLE PRECISION',
+ 'PDECIMAL' => 'DOUBLE PRECISION',
+ 'PDECIMAL:' => 'DOUBLE PRECISION',
+ 'VCHAR_UNI' => 'VARCHAR(255) CHARACTER SET UTF8',
+ 'VCHAR_UNI:'=> 'VARCHAR(%d) CHARACTER SET UTF8',
+ 'VCHAR_CI' => 'VARCHAR(255) CHARACTER SET UTF8',
+ 'VARBINARY' => 'CHAR(255) CHARACTER SET NONE',
+ ),
+
+ 'mssql' => array(
+ 'INT:' => '[int]',
+ 'BINT' => '[float]',
+ 'UINT' => '[int]',
+ 'UINT:' => '[int]',
+ 'TINT:' => '[int]',
+ 'USINT' => '[int]',
+ 'BOOL' => '[int]',
+ 'VCHAR' => '[varchar] (255)',
+ 'VCHAR:' => '[varchar] (%d)',
+ 'CHAR:' => '[char] (%d)',
+ 'XSTEXT' => '[varchar] (1000)',
+ 'STEXT' => '[varchar] (3000)',
+ 'TEXT' => '[varchar] (8000)',
+ 'MTEXT' => '[text]',
+ 'XSTEXT_UNI'=> '[varchar] (100)',
+ 'STEXT_UNI' => '[varchar] (255)',
+ 'TEXT_UNI' => '[varchar] (4000)',
+ 'MTEXT_UNI' => '[text]',
+ 'TIMESTAMP' => '[int]',
+ 'DECIMAL' => '[float]',
+ 'DECIMAL:' => '[float]',
+ 'PDECIMAL' => '[float]',
+ 'PDECIMAL:' => '[float]',
+ 'VCHAR_UNI' => '[varchar] (255)',
+ 'VCHAR_UNI:'=> '[varchar] (%d)',
+ 'VCHAR_CI' => '[varchar] (255)',
+ 'VARBINARY' => '[varchar] (255)',
+ ),
+
+ 'oracle' => array(
+ 'INT:' => 'number(%d)',
+ 'BINT' => 'number(20)',
+ 'UINT' => 'number(8)',
+ 'UINT:' => 'number(%d)',
+ 'TINT:' => 'number(%d)',
+ 'USINT' => 'number(4)',
+ 'BOOL' => 'number(1)',
+ 'VCHAR' => 'varchar2(255)',
+ 'VCHAR:' => 'varchar2(%d)',
+ 'CHAR:' => 'char(%d)',
+ 'XSTEXT' => 'varchar2(1000)',
+ 'STEXT' => 'varchar2(3000)',
+ 'TEXT' => 'clob',
+ 'MTEXT' => 'clob',
+ 'XSTEXT_UNI'=> 'varchar2(300)',
+ 'STEXT_UNI' => 'varchar2(765)',
+ 'TEXT_UNI' => 'clob',
+ 'MTEXT_UNI' => 'clob',
+ 'TIMESTAMP' => 'number(11)',
+ 'DECIMAL' => 'number(5, 2)',
+ 'DECIMAL:' => 'number(%d, 2)',
+ 'PDECIMAL' => 'number(6, 3)',
+ 'PDECIMAL:' => 'number(%d, 3)',
+ 'VCHAR_UNI' => 'varchar2(765)',
+ 'VCHAR_UNI:'=> array('varchar2(%d)', 'limit' => array('mult', 3, 765, 'clob')),
+ 'VCHAR_CI' => 'varchar2(255)',
+ 'VARBINARY' => 'raw(255)',
+ ),
+
+ 'sqlite' => array(
+ 'INT:' => 'int(%d)',
+ 'BINT' => 'bigint(20)',
+ 'UINT' => 'INTEGER UNSIGNED', //'mediumint(8) UNSIGNED',
+ 'UINT:' => 'INTEGER UNSIGNED', // 'int(%d) UNSIGNED',
+ 'TINT:' => 'tinyint(%d)',
+ 'USINT' => 'INTEGER UNSIGNED', //'mediumint(4) UNSIGNED',
+ 'BOOL' => 'INTEGER UNSIGNED', //'tinyint(1) UNSIGNED',
+ 'VCHAR' => 'varchar(255)',
+ 'VCHAR:' => 'varchar(%d)',
+ 'CHAR:' => 'char(%d)',
+ 'XSTEXT' => 'text(65535)',
+ 'STEXT' => 'text(65535)',
+ 'TEXT' => 'text(65535)',
+ 'MTEXT' => 'mediumtext(16777215)',
+ 'XSTEXT_UNI'=> 'text(65535)',
+ 'STEXT_UNI' => 'text(65535)',
+ 'TEXT_UNI' => 'text(65535)',
+ 'MTEXT_UNI' => 'mediumtext(16777215)',
+ 'TIMESTAMP' => 'INTEGER UNSIGNED', //'int(11) UNSIGNED',
+ 'DECIMAL' => 'decimal(5,2)',
+ 'DECIMAL:' => 'decimal(%d,2)',
+ 'PDECIMAL' => 'decimal(6,3)',
+ 'PDECIMAL:' => 'decimal(%d,3)',
+ 'VCHAR_UNI' => 'varchar(255)',
+ 'VCHAR_UNI:'=> 'varchar(%d)',
+ 'VCHAR_CI' => 'varchar(255)',
+ 'VARBINARY' => 'blob',
+ ),
+
+ 'postgres' => array(
+ 'INT:' => 'INT4',
+ 'BINT' => 'INT8',
+ 'UINT' => 'INT4', // unsigned
+ 'UINT:' => 'INT4', // unsigned
+ 'USINT' => 'INT2', // unsigned
+ 'BOOL' => 'INT2', // unsigned
+ 'TINT:' => 'INT2',
+ 'VCHAR' => 'varchar(255)',
+ 'VCHAR:' => 'varchar(%d)',
+ 'CHAR:' => 'char(%d)',
+ 'XSTEXT' => 'varchar(1000)',
+ 'STEXT' => 'varchar(3000)',
+ 'TEXT' => 'varchar(8000)',
+ 'MTEXT' => 'TEXT',
+ 'XSTEXT_UNI'=> 'varchar(100)',
+ 'STEXT_UNI' => 'varchar(255)',
+ 'TEXT_UNI' => 'varchar(4000)',
+ 'MTEXT_UNI' => 'TEXT',
+ 'TIMESTAMP' => 'INT4', // unsigned
+ 'DECIMAL' => 'decimal(5,2)',
+ 'DECIMAL:' => 'decimal(%d,2)',
+ 'PDECIMAL' => 'decimal(6,3)',
+ 'PDECIMAL:' => 'decimal(%d,3)',
+ 'VCHAR_UNI' => 'varchar(255)',
+ 'VCHAR_UNI:'=> 'varchar(%d)',
+ 'VCHAR_CI' => 'varchar_ci',
+ 'VARBINARY' => 'bytea',
+ ),
+);
+
+// A list of types being unsigned for better reference in some db's
+$unsigned_types = array('UINT', 'UINT:', 'USINT', 'BOOL', 'TIMESTAMP');
+$supported_dbms = array('firebird', 'mssql', 'mysql_40', 'mysql_41', 'oracle', 'postgres', 'sqlite');
+
+foreach ($supported_dbms as $dbms)
+{
+ $fp = fopen($schema_path . '_' . $dbms . '_schema.sql', 'wt');
+
+ $line = '';
+
+ // Write Header
+ switch ($dbms)
+ {
+ case 'mysql_40':
+ case 'mysql_41':
+ $line = "#\n# \$I" . "d: $\n#\n\n";
+ break;
+
+ case 'firebird':
+ $line = "#\n# \$I" . "d: $\n#\n\n";
+ $line .= custom_data('firebird') . "\n";
+ break;
+
+ case 'sqlite':
+ $line = "#\n# \$I" . "d: $\n#\n\n";
+ $line .= "BEGIN TRANSACTION;\n\n";
+ break;
+
+ case 'mssql':
+ $line = "/*\n\n \$I" . "d: $\n\n*/\n\n";
+ $line .= "BEGIN TRANSACTION\nGO\n\n";
+ break;
+
+ case 'oracle':
+ $line = "/*\n\n \$I" . "d: $\n\n*/\n\n";
+ $line .= custom_data('oracle') . "\n";
+ break;
+
+ case 'postgres':
+ $line = "/*\n\n \$I" . "d: $\n\n*/\n\n";
+ $line .= "BEGIN;\n\n";
+ $line .= custom_data('postgres') . "\n";
+ break;
+ }
+
+ fwrite($fp, $line);
+
+ foreach ($schema_data as $table_name => $table_data)
+ {
+ // Write comment about table
+ switch ($dbms)
+ {
+ case 'mysql_40':
+ case 'mysql_41':
+ case 'firebird':
+ case 'sqlite':
+ fwrite($fp, "# Table: '{$table_name}'\n");
+ break;
+
+ case 'mssql':
+ case 'oracle':
+ case 'postgres':
+ fwrite($fp, "/*\n\tTable: '{$table_name}'\n*/\n");
+ break;
+ }
+
+ // Create Table statement
+ $generator = $textimage = false;
+ $line = '';
+
+ switch ($dbms)
+ {
+ case 'mysql_40':
+ case 'mysql_41':
+ case 'firebird':
+ case 'oracle':
+ case 'sqlite':
+ case 'postgres':
+ $line = "CREATE TABLE {$table_name} (\n";
+ break;
+
+ case 'mssql':
+ $line = "CREATE TABLE [{$table_name}] (\n";
+ break;
+ }
+
+ // Table specific so we don't get overlap
+ $modded_array = array();
+
+ // Write columns one by one...
+ foreach ($table_data['COLUMNS'] as $column_name => $column_data)
+ {
+ // Get type
+ if (strpos($column_data[0], ':') !== false)
+ {
+ list($orig_column_type, $column_length) = explode(':', $column_data[0]);
+ if (!is_array($dbms_type_map[$dbms][$orig_column_type . ':']))
+ {
+ $column_type = sprintf($dbms_type_map[$dbms][$orig_column_type . ':'], $column_length);
+ }
+ else
+ {
+ if (isset($dbms_type_map[$dbms][$orig_column_type . ':']['rule']))
+ {
+ switch ($dbms_type_map[$dbms][$orig_column_type . ':']['rule'][0])
+ {
+ case 'div':
+ $column_length /= $dbms_type_map[$dbms][$orig_column_type . ':']['rule'][1];
+ $column_length = ceil($column_length);
+ $column_type = sprintf($dbms_type_map[$dbms][$orig_column_type . ':'][0], $column_length);
+ break;
+ }
+ }
+
+ if (isset($dbms_type_map[$dbms][$orig_column_type . ':']['limit']))
+ {
+ switch ($dbms_type_map[$dbms][$orig_column_type . ':']['limit'][0])
+ {
+ case 'mult':
+ $column_length *= $dbms_type_map[$dbms][$orig_column_type . ':']['limit'][1];
+ if ($column_length > $dbms_type_map[$dbms][$orig_column_type . ':']['limit'][2])
+ {
+ $column_type = $dbms_type_map[$dbms][$orig_column_type . ':']['limit'][3];
+ $modded_array[$column_name] = $column_type;
+ }
+ else
+ {
+ $column_type = sprintf($dbms_type_map[$dbms][$orig_column_type . ':'][0], $column_length);
+ }
+ break;
+ }
+ }
+ }
+ $orig_column_type .= ':';
+ }
+ else
+ {
+ $orig_column_type = $column_data[0];
+ $column_type = $dbms_type_map[$dbms][$column_data[0]];
+ if ($column_type == 'text' || $column_type == 'blob')
+ {
+ $modded_array[$column_name] = $column_type;
+ }
+ }
+
+ // Adjust default value if db-dependant specified
+ if (is_array($column_data[1]))
+ {
+ $column_data[1] = (isset($column_data[1][$dbms])) ? $column_data[1][$dbms] : $column_data[1]['default'];
+ }
+
+ switch ($dbms)
+ {
+ case 'mysql_40':
+ case 'mysql_41':
+ $line .= "\t{$column_name} {$column_type} ";
+
+ // For hexadecimal values do not use single quotes
+ if (!is_null($column_data[1]) && substr($column_type, -4) !== 'text' && substr($column_type, -4) !== 'blob')
+ {
+ $line .= (strpos($column_data[1], '0x') === 0) ? "DEFAULT {$column_data[1]} " : "DEFAULT '{$column_data[1]}' ";
+ }
+ $line .= 'NOT NULL';
+
+ if (isset($column_data[2]))
+ {
+ if ($column_data[2] == 'auto_increment')
+ {
+ $line .= ' auto_increment';
+ }
+ else if ($dbms === 'mysql_41' && $column_data[2] == 'true_sort')
+ {
+ $line .= ' COLLATE utf8_unicode_ci';
+ }
+ }
+
+ $line .= ",\n";
+ break;
+
+ case 'sqlite':
+ if (isset($column_data[2]) && $column_data[2] == 'auto_increment')
+ {
+ $line .= "\t{$column_name} INTEGER PRIMARY KEY ";
+ $generator = $column_name;
+ }
+ else
+ {
+ $line .= "\t{$column_name} {$column_type} ";
+ }
+
+ $line .= 'NOT NULL ';
+ $line .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}'" : '';
+ $line .= ",\n";
+ break;
+
+ case 'firebird':
+ $line .= "\t{$column_name} {$column_type} ";
+
+ if (!is_null($column_data[1]))
+ {
+ $line .= 'DEFAULT ' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ' ';
+ }
+
+ $line .= 'NOT NULL';
+
+ // This is a UNICODE column and thus should be given it's fair share
+ if (preg_match('/^X?STEXT_UNI|VCHAR_(CI|UNI:?)/', $column_data[0]))
+ {
+ $line .= ' COLLATE UNICODE';
+ }
+
+ $line .= ",\n";
+
+ if (isset($column_data[2]) && $column_data[2] == 'auto_increment')
+ {
+ $generator = $column_name;
+ }
+ break;
+
+ case 'mssql':
+ if ($column_type == '[text]')
+ {
+ $textimage = true;
+ }
+
+ $line .= "\t[{$column_name}] {$column_type} ";
+
+ if (!is_null($column_data[1]))
+ {
+ // For hexadecimal values do not use single quotes
+ if (strpos($column_data[1], '0x') === 0)
+ {
+ $line .= 'DEFAULT (' . $column_data[1] . ') ';
+ }
+ else
+ {
+ $line .= 'DEFAULT (' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ') ';
+ }
+ }
+
+ if (isset($column_data[2]) && $column_data[2] == 'auto_increment')
+ {
+ $line .= 'IDENTITY (1, 1) ';
+ }
+
+ $line .= 'NOT NULL';
+ $line .= " ,\n";
+ break;
+
+ case 'oracle':
+ $line .= "\t{$column_name} {$column_type} ";
+ $line .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}' " : '';
+
+ // In Oracle empty strings ('') are treated as NULL.
+ // Therefore in oracle we allow NULL's for all DEFAULT '' entries
+ $line .= ($column_data[1] === '') ? ",\n" : "NOT NULL,\n";
+
+ if (isset($column_data[2]) && $column_data[2] == 'auto_increment')
+ {
+ $generator = $column_name;
+ }
+ break;
+
+ case 'postgres':
+ $line .= "\t{$column_name} {$column_type} ";
+
+ if (isset($column_data[2]) && $column_data[2] == 'auto_increment')
+ {
+ $line .= "DEFAULT nextval('{$table_name}_seq'),\n";
+
+ // Make sure the sequence will be created before creating the table
+ $line = "CREATE SEQUENCE {$table_name}_seq;\n\n" . $line;
+ }
+ else
+ {
+ $line .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}' " : '';
+ $line .= "NOT NULL";
+
+ // Unsigned? Then add a CHECK contraint
+ if (in_array($orig_column_type, $unsigned_types))
+ {
+ $line .= " CHECK ({$column_name} >= 0)";
+ }
+
+ $line .= ",\n";
+ }
+ break;
+ }
+ }
+
+ switch ($dbms)
+ {
+ case 'firebird':
+ // Remove last line delimiter...
+ $line = substr($line, 0, -2);
+ $line .= "\n);;\n\n";
+ break;
+
+ case 'mssql':
+ $line = substr($line, 0, -2);
+ $line .= "\n) ON [PRIMARY]" . (($textimage) ? ' TEXTIMAGE_ON [PRIMARY]' : '') . "\n";
+ $line .= "GO\n\n";
+ break;
+ }
+
+ // Write primary key
+ if (isset($table_data['PRIMARY_KEY']))
+ {
+ if (!is_array($table_data['PRIMARY_KEY']))
+ {
+ $table_data['PRIMARY_KEY'] = array($table_data['PRIMARY_KEY']);
+ }
+
+ switch ($dbms)
+ {
+ case 'mysql_40':
+ case 'mysql_41':
+ case 'postgres':
+ $line .= "\tPRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . "),\n";
+ break;
+
+ case 'firebird':
+ $line .= "ALTER TABLE {$table_name} ADD PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . ");;\n\n";
+ break;
+
+ case 'sqlite':
+ if ($generator === false || !in_array($generator, $table_data['PRIMARY_KEY']))
+ {
+ $line .= "\tPRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . "),\n";
+ }
+ break;
+
+ case 'mssql':
+ $line .= "ALTER TABLE [{$table_name}] WITH NOCHECK ADD \n";
+ $line .= "\tCONSTRAINT [PK_{$table_name}] PRIMARY KEY CLUSTERED \n";
+ $line .= "\t(\n";
+ $line .= "\t\t[" . implode("],\n\t\t[", $table_data['PRIMARY_KEY']) . "]\n";
+ $line .= "\t) ON [PRIMARY] \n";
+ $line .= "GO\n\n";
+ break;
+
+ case 'oracle':
+ $line .= "\tCONSTRAINT pk_{$table_name} PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . "),\n";
+ break;
+ }
+ }
+
+ switch ($dbms)
+ {
+ case 'oracle':
+ // UNIQUE contrains to be added?
+ if (isset($table_data['KEYS']))
+ {
+ foreach ($table_data['KEYS'] as $key_name => $key_data)
+ {
+ if (!is_array($key_data[1]))
+ {
+ $key_data[1] = array($key_data[1]);
+ }
+
+ if ($key_data[0] == 'UNIQUE')
+ {
+ $line .= "\tCONSTRAINT u_phpbb_{$key_name} UNIQUE (" . implode(', ', $key_data[1]) . "),\n";
+ }
+ }
+ }
+
+ // Remove last line delimiter...
+ $line = substr($line, 0, -2);
+ $line .= "\n)\n/\n\n";
+ break;
+
+ case 'postgres':
+ // Remove last line delimiter...
+ $line = substr($line, 0, -2);
+ $line .= "\n);\n\n";
+ break;
+
+ case 'sqlite':
+ // Remove last line delimiter...
+ $line = substr($line, 0, -2);
+ $line .= "\n);\n\n";
+ break;
+ }
+
+ // Write Keys
+ if (isset($table_data['KEYS']))
+ {
+ foreach ($table_data['KEYS'] as $key_name => $key_data)
+ {
+ if (!is_array($key_data[1]))
+ {
+ $key_data[1] = array($key_data[1]);
+ }
+
+ switch ($dbms)
+ {
+ case 'mysql_40':
+ case 'mysql_41':
+ $line .= ($key_data[0] == 'INDEX') ? "\tKEY" : '';
+ $line .= ($key_data[0] == 'UNIQUE') ? "\tUNIQUE" : '';
+ foreach ($key_data[1] as $key => $col_name)
+ {
+ if (isset($modded_array[$col_name]))
+ {
+ switch ($modded_array[$col_name])
+ {
+ case 'text':
+ case 'blob':
+ $key_data[1][$key] = $col_name . '(255)';
+ break;
+ }
+ }
+ }
+ $line .= ' ' . $key_name . ' (' . implode(', ', $key_data[1]) . "),\n";
+ break;
+
+ case 'firebird':
+ $line .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : '';
+ $line .= ($key_data[0] == 'UNIQUE') ? 'CREATE UNIQUE INDEX' : '';
+
+ $line .= ' ' . $table_name . '_' . $key_name . ' ON ' . $table_name . '(' . implode(', ', $key_data[1]) . ");;\n";
+ break;
+
+ case 'mssql':
+ $line .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : '';
+ $line .= ($key_data[0] == 'UNIQUE') ? 'CREATE UNIQUE INDEX' : '';
+ $line .= " [{$key_name}] ON [{$table_name}]([" . implode('], [', $key_data[1]) . "]) ON [PRIMARY]\n";
+ $line .= "GO\n\n";
+ break;
+
+ case 'oracle':
+ if ($key_data[0] == 'UNIQUE')
+ {
+ continue;
+ }
+
+ $line .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : '';
+
+ $line .= " {$table_name}_{$key_name} ON {$table_name} (" . implode(', ', $key_data[1]) . ")\n";
+ $line .= "/\n";
+ break;
+
+ case 'sqlite':
+ $line .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : '';
+ $line .= ($key_data[0] == 'UNIQUE') ? 'CREATE UNIQUE INDEX' : '';
+
+ $line .= " {$table_name}_{$key_name} ON {$table_name} (" . implode(', ', $key_data[1]) . ");\n";
+ break;
+
+ case 'postgres':
+ $line .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : '';
+ $line .= ($key_data[0] == 'UNIQUE') ? 'CREATE UNIQUE INDEX' : '';
+
+ $line .= " {$table_name}_{$key_name} ON {$table_name} (" . implode(', ', $key_data[1]) . ");\n";
+ break;
+ }
+ }
+ }
+
+ switch ($dbms)
+ {
+ case 'mysql_40':
+ // Remove last line delimiter...
+ $line = substr($line, 0, -2);
+ $line .= "\n);\n\n";
+ break;
+
+ case 'mysql_41':
+ // Remove last line delimiter...
+ $line = substr($line, 0, -2);
+ $line .= "\n) CHARACTER SET `utf8` COLLATE `utf8_bin`;\n\n";
+ break;
+
+ // Create Generator
+ case 'firebird':
+ if ($generator !== false)
+ {
+ $line .= "\nCREATE GENERATOR {$table_name}_gen;;\n";
+ $line .= 'SET GENERATOR ' . $table_name . "_gen TO 0;;\n\n";
+
+ $line .= 'CREATE TRIGGER t_' . $table_name . ' FOR ' . $table_name . "\n";
+ $line .= "BEFORE INSERT\nAS\nBEGIN\n";
+ $line .= "\tNEW.{$generator} = GEN_ID({$table_name}_gen, 1);\nEND;;\n\n";
+ }
+ break;
+
+ case 'oracle':
+ if ($generator !== false)
+ {
+ $line .= "\nCREATE SEQUENCE {$table_name}_seq\n/\n\n";
+
+ $line .= "CREATE OR REPLACE TRIGGER t_{$table_name}\n";
+ $line .= "BEFORE INSERT ON {$table_name}\n";
+ $line .= "FOR EACH ROW WHEN (\n";
+ $line .= "\tnew.{$generator} IS NULL OR new.{$generator} = 0\n";
+ $line .= ")\nBEGIN\n";
+ $line .= "\tSELECT {$table_name}_seq.nextval\n";
+ $line .= "\tINTO :new.{$generator}\n";
+ $line .= "\tFROM dual;\nEND;\n/\n\n";
+ }
+ break;
+ }
+
+ fwrite($fp, $line . "\n");
+ }
+
+ $line = '';
+
+ // Write custom function at the end for some db's
+ switch ($dbms)
+ {
+ case 'mssql':
+ $line = "\nCOMMIT\nGO\n\n";
+ break;
+
+ case 'sqlite':
+ $line = "\nCOMMIT;";
+ break;
+
+ case 'postgres':
+ $line = "\nCOMMIT;";
+ break;
+ }
+
+ fwrite($fp, $line);
+ fclose($fp);
+}
+
+
+/**
+* Define the basic structure
+* The format:
+* array('{TABLE_NAME}' => {TABLE_DATA})
+* {TABLE_DATA}:
+* COLUMNS = array({column_name} = array({column_type}, {default}, {auto_increment}))
+* PRIMARY_KEY = {column_name(s)}
+* KEYS = array({key_name} = array({key_type}, {column_name(s)})),
+*
+* Column Types:
+* INT:x => SIGNED int(x)
+* BINT => BIGINT
+* UINT => mediumint(8) UNSIGNED
+* UINT:x => int(x) UNSIGNED
+* TINT:x => tinyint(x)
+* USINT => smallint(4) UNSIGNED (for _order columns)
+* BOOL => tinyint(1) UNSIGNED
+* VCHAR => varchar(255)
+* CHAR:x => char(x)
+* XSTEXT_UNI => text for storing 100 characters (topic_title for example)
+* STEXT_UNI => text for storing 255 characters (normal input field with a max of 255 single-byte chars) - same as VCHAR_UNI
+* TEXT_UNI => text for storing 3000 characters (short text, descriptions, comments, etc.)
+* MTEXT_UNI => mediumtext (post text, large text)
+* VCHAR:x => varchar(x)
+* TIMESTAMP => int(11) UNSIGNED
+* DECIMAL => decimal number (5,2)
+* DECIMAL: => decimal number (x,2)
+* PDECIMAL => precision decimal number (6,3)
+* PDECIMAL: => precision decimal number (x,3)
+* VCHAR_UNI => varchar(255) BINARY
+* VCHAR_CI => varchar_ci for postgresql, others VCHAR
+*/
+function get_schema_struct()
+{
+ $schema_data = array();
+
+ $schema_data['phpbb_attachments'] = array(
+ 'COLUMNS' => array(
+ 'attach_id' => array('UINT', NULL, 'auto_increment'),
+ 'post_msg_id' => array('UINT', 0),
+ 'topic_id' => array('UINT', 0),
+ 'in_message' => array('BOOL', 0),
+ 'poster_id' => array('UINT', 0),
+ 'is_orphan' => array('BOOL', 1),
+ 'physical_filename' => array('VCHAR', ''),
+ 'real_filename' => array('VCHAR', ''),
+ 'download_count' => array('UINT', 0),
+ 'attach_comment' => array('TEXT_UNI', ''),
+ 'extension' => array('VCHAR:100', ''),
+ 'mimetype' => array('VCHAR:100', ''),
+ 'filesize' => array('UINT:20', 0),
+ 'filetime' => array('TIMESTAMP', 0),
+ 'thumbnail' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => 'attach_id',
+ 'KEYS' => array(
+ 'filetime' => array('INDEX', 'filetime'),
+ 'post_msg_id' => array('INDEX', 'post_msg_id'),
+ 'topic_id' => array('INDEX', 'topic_id'),
+ 'poster_id' => array('INDEX', 'poster_id'),
+ 'is_orphan' => array('INDEX', 'is_orphan'),
+ ),
+ );
+
+ $schema_data['phpbb_acl_groups'] = array(
+ 'COLUMNS' => array(
+ 'group_id' => array('UINT', 0),
+ 'forum_id' => array('UINT', 0),
+ 'auth_option_id' => array('UINT', 0),
+ 'auth_role_id' => array('UINT', 0),
+ 'auth_setting' => array('TINT:2', 0),
+ ),
+ 'KEYS' => array(
+ 'group_id' => array('INDEX', 'group_id'),
+ 'auth_opt_id' => array('INDEX', 'auth_option_id'),
+ 'auth_role_id' => array('INDEX', 'auth_role_id'),
+ ),
+ );
+
+ $schema_data['phpbb_acl_options'] = array(
+ 'COLUMNS' => array(
+ 'auth_option_id' => array('UINT', NULL, 'auto_increment'),
+ 'auth_option' => array('VCHAR:50', ''),
+ 'is_global' => array('BOOL', 0),
+ 'is_local' => array('BOOL', 0),
+ 'founder_only' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => 'auth_option_id',
+ 'KEYS' => array(
+ 'auth_option' => array('UNIQUE', 'auth_option'),
+ ),
+ );
+
+ $schema_data['phpbb_acl_roles'] = array(
+ 'COLUMNS' => array(
+ 'role_id' => array('UINT', NULL, 'auto_increment'),
+ 'role_name' => array('VCHAR_UNI', ''),
+ 'role_description' => array('TEXT_UNI', ''),
+ 'role_type' => array('VCHAR:10', ''),
+ 'role_order' => array('USINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'role_id',
+ 'KEYS' => array(
+ 'role_type' => array('INDEX', 'role_type'),
+ 'role_order' => array('INDEX', 'role_order'),
+ ),
+ );
+
+ $schema_data['phpbb_acl_roles_data'] = array(
+ 'COLUMNS' => array(
+ 'role_id' => array('UINT', 0),
+ 'auth_option_id' => array('UINT', 0),
+ 'auth_setting' => array('TINT:2', 0),
+ ),
+ 'PRIMARY_KEY' => array('role_id', 'auth_option_id'),
+ 'KEYS' => array(
+ 'ath_op_id' => array('INDEX', 'auth_option_id'),
+ ),
+ );
+
+ $schema_data['phpbb_acl_users'] = array(
+ 'COLUMNS' => array(
+ 'user_id' => array('UINT', 0),
+ 'forum_id' => array('UINT', 0),
+ 'auth_option_id' => array('UINT', 0),
+ 'auth_role_id' => array('UINT', 0),
+ 'auth_setting' => array('TINT:2', 0),
+ ),
+ 'KEYS' => array(
+ 'user_id' => array('INDEX', 'user_id'),
+ 'auth_option_id' => array('INDEX', 'auth_option_id'),
+ 'auth_role_id' => array('INDEX', 'auth_role_id'),
+ ),
+ );
+
+ $schema_data['phpbb_banlist'] = array(
+ 'COLUMNS' => array(
+ 'ban_id' => array('UINT', NULL, 'auto_increment'),
+ 'ban_userid' => array('UINT', 0),
+ 'ban_ip' => array('VCHAR:40', ''),
+ 'ban_email' => array('VCHAR_UNI:100', ''),
+ 'ban_start' => array('TIMESTAMP', 0),
+ 'ban_end' => array('TIMESTAMP', 0),
+ 'ban_exclude' => array('BOOL', 0),
+ 'ban_reason' => array('VCHAR_UNI', ''),
+ 'ban_give_reason' => array('VCHAR_UNI', ''),
+ ),
+ 'PRIMARY_KEY' => 'ban_id',
+ 'KEYS' => array(
+ 'ban_end' => array('INDEX', 'ban_end'),
+ 'ban_user' => array('INDEX', array('ban_userid', 'ban_exclude')),
+ 'ban_email' => array('INDEX', array('ban_email', 'ban_exclude')),
+ 'ban_ip' => array('INDEX', array('ban_ip', 'ban_exclude')),
+ ),
+ );
+
+ $schema_data['phpbb_bbcodes'] = array(
+ 'COLUMNS' => array(
+ 'bbcode_id' => array('TINT:3', 0),
+ 'bbcode_tag' => array('VCHAR:16', ''),
+ 'bbcode_helpline' => array('VCHAR_UNI', ''),
+ 'display_on_posting' => array('BOOL', 0),
+ 'bbcode_match' => array('TEXT_UNI', ''),
+ 'bbcode_tpl' => array('MTEXT_UNI', ''),
+ 'first_pass_match' => array('MTEXT_UNI', ''),
+ 'first_pass_replace' => array('MTEXT_UNI', ''),
+ 'second_pass_match' => array('MTEXT_UNI', ''),
+ 'second_pass_replace' => array('MTEXT_UNI', ''),
+ ),
+ 'PRIMARY_KEY' => 'bbcode_id',
+ 'KEYS' => array(
+ 'display_on_post' => array('INDEX', 'display_on_posting'),
+ ),
+ );
+
+ $schema_data['phpbb_bookmarks'] = array(
+ 'COLUMNS' => array(
+ 'topic_id' => array('UINT', 0),
+ 'user_id' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => array('topic_id', 'user_id'),
+ );
+
+ $schema_data['phpbb_bots'] = array(
+ 'COLUMNS' => array(
+ 'bot_id' => array('UINT', NULL, 'auto_increment'),
+ 'bot_active' => array('BOOL', 1),
+ 'bot_name' => array('STEXT_UNI', ''),
+ 'user_id' => array('UINT', 0),
+ 'bot_agent' => array('VCHAR', ''),
+ 'bot_ip' => array('VCHAR', ''),
+ ),
+ 'PRIMARY_KEY' => 'bot_id',
+ 'KEYS' => array(
+ 'bot_active' => array('INDEX', 'bot_active'),
+ ),
+ );
+
+ $schema_data['phpbb_config'] = array(
+ 'COLUMNS' => array(
+ 'config_name' => array('VCHAR', ''),
+ 'config_value' => array('VCHAR_UNI', ''),
+ 'is_dynamic' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => 'config_name',
+ 'KEYS' => array(
+ 'is_dynamic' => array('INDEX', 'is_dynamic'),
+ ),
+ );
+
+ $schema_data['phpbb_confirm'] = array(
+ 'COLUMNS' => array(
+ 'confirm_id' => array('CHAR:32', ''),
+ 'session_id' => array('CHAR:32', ''),
+ 'confirm_type' => array('TINT:3', 0),
+ 'code' => array('VCHAR:8', ''),
+ 'seed' => array('UINT:10', 0),
+ 'attempts' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => array('session_id', 'confirm_id'),
+ 'KEYS' => array(
+ 'confirm_type' => array('INDEX', 'confirm_type'),
+ ),
+ );
+
+ $schema_data['phpbb_disallow'] = array(
+ 'COLUMNS' => array(
+ 'disallow_id' => array('UINT', NULL, 'auto_increment'),
+ 'disallow_username' => array('VCHAR_UNI:255', ''),
+ ),
+ 'PRIMARY_KEY' => 'disallow_id',
+ );
+
+ $schema_data['phpbb_drafts'] = array(
+ 'COLUMNS' => array(
+ 'draft_id' => array('UINT', NULL, 'auto_increment'),
+ 'user_id' => array('UINT', 0),
+ 'topic_id' => array('UINT', 0),
+ 'forum_id' => array('UINT', 0),
+ 'save_time' => array('TIMESTAMP', 0),
+ 'draft_subject' => array('STEXT_UNI', ''),
+ 'draft_message' => array('MTEXT_UNI', ''),
+ ),
+ 'PRIMARY_KEY' => 'draft_id',
+ 'KEYS' => array(
+ 'save_time' => array('INDEX', 'save_time'),
+ ),
+ );
+
+ $schema_data['phpbb_extensions'] = array(
+ 'COLUMNS' => array(
+ 'extension_id' => array('UINT', NULL, 'auto_increment'),
+ 'group_id' => array('UINT', 0),
+ 'extension' => array('VCHAR:100', ''),
+ ),
+ 'PRIMARY_KEY' => 'extension_id',
+ );
+
+ $schema_data['phpbb_extension_groups'] = array(
+ 'COLUMNS' => array(
+ 'group_id' => array('UINT', NULL, 'auto_increment'),
+ 'group_name' => array('VCHAR_UNI', ''),
+ 'cat_id' => array('TINT:2', 0),
+ 'allow_group' => array('BOOL', 0),
+ 'download_mode' => array('BOOL', 1),
+ 'upload_icon' => array('VCHAR', ''),
+ 'max_filesize' => array('UINT:20', 0),
+ 'allowed_forums' => array('TEXT', ''),
+ 'allow_in_pm' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => 'group_id',
+ );
+
+ $schema_data['phpbb_forums'] = array(
+ 'COLUMNS' => array(
+ 'forum_id' => array('UINT', NULL, 'auto_increment'),
+ 'parent_id' => array('UINT', 0),
+ 'left_id' => array('UINT', 0),
+ 'right_id' => array('UINT', 0),
+ 'forum_parents' => array('MTEXT', ''),
+ 'forum_name' => array('STEXT_UNI', ''),
+ 'forum_desc' => array('TEXT_UNI', ''),
+ 'forum_desc_bitfield' => array('VCHAR:255', ''),
+ 'forum_desc_options' => array('UINT:11', 7),
+ 'forum_desc_uid' => array('VCHAR:8', ''),
+ 'forum_link' => array('VCHAR_UNI', ''),
+ 'forum_password' => array('VCHAR_UNI:40', ''),
+ 'forum_style' => array('UINT', 0),
+ 'forum_image' => array('VCHAR', ''),
+ 'forum_rules' => array('TEXT_UNI', ''),
+ 'forum_rules_link' => array('VCHAR_UNI', ''),
+ 'forum_rules_bitfield' => array('VCHAR:255', ''),
+ 'forum_rules_options' => array('UINT:11', 7),
+ 'forum_rules_uid' => array('VCHAR:8', ''),
+ 'forum_topics_per_page' => array('TINT:4', 0),
+ 'forum_type' => array('TINT:4', 0),
+ 'forum_status' => array('TINT:4', 0),
+ 'forum_posts' => array('UINT', 0),
+ 'forum_topics' => array('UINT', 0),
+ 'forum_topics_real' => array('UINT', 0),
+ 'forum_last_post_id' => array('UINT', 0),
+ 'forum_last_poster_id' => array('UINT', 0),
+ 'forum_last_post_subject' => array('STEXT_UNI', ''),
+ 'forum_last_post_time' => array('TIMESTAMP', 0),
+ 'forum_last_poster_name'=> array('VCHAR_UNI', ''),
+ 'forum_last_poster_colour'=> array('VCHAR:6', ''),
+ 'forum_flags' => array('TINT:4', 32),
+ 'forum_options' => array('UINT:20', 0),
+ 'display_subforum_list' => array('BOOL', 1),
+ 'display_on_index' => array('BOOL', 1),
+ 'enable_indexing' => array('BOOL', 1),
+ 'enable_icons' => array('BOOL', 1),
+ 'enable_prune' => array('BOOL', 0),
+ 'prune_next' => array('TIMESTAMP', 0),
+ 'prune_days' => array('UINT', 0),
+ 'prune_viewed' => array('UINT', 0),
+ 'prune_freq' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'forum_id',
+ 'KEYS' => array(
+ 'left_right_id' => array('INDEX', array('left_id', 'right_id')),
+ 'forum_lastpost_id' => array('INDEX', 'forum_last_post_id'),
+ ),
+ );
+
+ $schema_data['phpbb_forums_access'] = array(
+ 'COLUMNS' => array(
+ 'forum_id' => array('UINT', 0),
+ 'user_id' => array('UINT', 0),
+ 'session_id' => array('CHAR:32', ''),
+ ),
+ 'PRIMARY_KEY' => array('forum_id', 'user_id', 'session_id'),
+ );
+
+ $schema_data['phpbb_forums_track'] = array(
+ 'COLUMNS' => array(
+ 'user_id' => array('UINT', 0),
+ 'forum_id' => array('UINT', 0),
+ 'mark_time' => array('TIMESTAMP', 0),
+ ),
+ 'PRIMARY_KEY' => array('user_id', 'forum_id'),
+ );
+
+ $schema_data['phpbb_forums_watch'] = array(
+ 'COLUMNS' => array(
+ 'forum_id' => array('UINT', 0),
+ 'user_id' => array('UINT', 0),
+ 'notify_status' => array('BOOL', 0),
+ ),
+ 'KEYS' => array(
+ 'forum_id' => array('INDEX', 'forum_id'),
+ 'user_id' => array('INDEX', 'user_id'),
+ 'notify_stat' => array('INDEX', 'notify_status'),
+ ),
+ );
+
+ $schema_data['phpbb_groups'] = array(
+ 'COLUMNS' => array(
+ 'group_id' => array('UINT', NULL, 'auto_increment'),
+ 'group_type' => array('TINT:4', 1),
+ 'group_founder_manage' => array('BOOL', 0),
+ 'group_skip_auth' => array('BOOL', 0),
+ 'group_name' => array('VCHAR_CI', ''),
+ 'group_desc' => array('TEXT_UNI', ''),
+ 'group_desc_bitfield' => array('VCHAR:255', ''),
+ 'group_desc_options' => array('UINT:11', 7),
+ 'group_desc_uid' => array('VCHAR:8', ''),
+ 'group_display' => array('BOOL', 0),
+ 'group_avatar' => array('VCHAR', ''),
+ 'group_avatar_type' => array('TINT:2', 0),
+ 'group_avatar_width' => array('USINT', 0),
+ 'group_avatar_height' => array('USINT', 0),
+ 'group_rank' => array('UINT', 0),
+ 'group_colour' => array('VCHAR:6', ''),
+ 'group_sig_chars' => array('UINT', 0),
+ 'group_receive_pm' => array('BOOL', 0),
+ 'group_message_limit' => array('UINT', 0),
+ 'group_max_recipients' => array('UINT', 0),
+ 'group_legend' => array('BOOL', 1),
+ ),
+ 'PRIMARY_KEY' => 'group_id',
+ 'KEYS' => array(
+ 'group_legend_name' => array('INDEX', array('group_legend', 'group_name')),
+ ),
+ );
+
+ $schema_data['phpbb_icons'] = array(
+ 'COLUMNS' => array(
+ 'icons_id' => array('UINT', NULL, 'auto_increment'),
+ 'icons_url' => array('VCHAR', ''),
+ 'icons_width' => array('TINT:4', 0),
+ 'icons_height' => array('TINT:4', 0),
+ 'icons_order' => array('UINT', 0),
+ 'display_on_posting' => array('BOOL', 1),
+ ),
+ 'PRIMARY_KEY' => 'icons_id',
+ 'KEYS' => array(
+ 'display_on_posting' => array('INDEX', 'display_on_posting'),
+ ),
+ );
+
+ $schema_data['phpbb_lang'] = array(
+ 'COLUMNS' => array(
+ 'lang_id' => array('TINT:4', NULL, 'auto_increment'),
+ 'lang_iso' => array('VCHAR:30', ''),
+ 'lang_dir' => array('VCHAR:30', ''),
+ 'lang_english_name' => array('VCHAR_UNI:100', ''),
+ 'lang_local_name' => array('VCHAR_UNI:255', ''),
+ 'lang_author' => array('VCHAR_UNI:255', ''),
+ ),
+ 'PRIMARY_KEY' => 'lang_id',
+ 'KEYS' => array(
+ 'lang_iso' => array('INDEX', 'lang_iso'),
+ ),
+ );
+
+ $schema_data['phpbb_log'] = array(
+ 'COLUMNS' => array(
+ 'log_id' => array('UINT', NULL, 'auto_increment'),
+ 'log_type' => array('TINT:4', 0),
+ 'user_id' => array('UINT', 0),
+ 'forum_id' => array('UINT', 0),
+ 'topic_id' => array('UINT', 0),
+ 'reportee_id' => array('UINT', 0),
+ 'log_ip' => array('VCHAR:40', ''),
+ 'log_time' => array('TIMESTAMP', 0),
+ 'log_operation' => array('TEXT_UNI', ''),
+ 'log_data' => array('MTEXT_UNI', ''),
+ ),
+ 'PRIMARY_KEY' => 'log_id',
+ 'KEYS' => array(
+ 'log_type' => array('INDEX', 'log_type'),
+ 'log_time' => array('INDEX', 'log_time'),
+ 'forum_id' => array('INDEX', 'forum_id'),
+ 'topic_id' => array('INDEX', 'topic_id'),
+ 'reportee_id' => array('INDEX', 'reportee_id'),
+ 'user_id' => array('INDEX', 'user_id'),
+ ),
+ );
+
+ $schema_data['phpbb_moderator_cache'] = array(
+ 'COLUMNS' => array(
+ 'forum_id' => array('UINT', 0),
+ 'user_id' => array('UINT', 0),
+ 'username' => array('VCHAR_UNI:255', ''),
+ 'group_id' => array('UINT', 0),
+ 'group_name' => array('VCHAR_UNI', ''),
+ 'display_on_index' => array('BOOL', 1),
+ ),
+ 'KEYS' => array(
+ 'disp_idx' => array('INDEX', 'display_on_index'),
+ 'forum_id' => array('INDEX', 'forum_id'),
+ ),
+ );
+
+ $schema_data['phpbb_modules'] = array(
+ 'COLUMNS' => array(
+ 'module_id' => array('UINT', NULL, 'auto_increment'),
+ 'module_enabled' => array('BOOL', 1),
+ 'module_display' => array('BOOL', 1),
+ 'module_basename' => array('VCHAR', ''),
+ 'module_class' => array('VCHAR:10', ''),
+ 'parent_id' => array('UINT', 0),
+ 'left_id' => array('UINT', 0),
+ 'right_id' => array('UINT', 0),
+ 'module_langname' => array('VCHAR', ''),
+ 'module_mode' => array('VCHAR', ''),
+ 'module_auth' => array('VCHAR', ''),
+ ),
+ 'PRIMARY_KEY' => 'module_id',
+ 'KEYS' => array(
+ 'left_right_id' => array('INDEX', array('left_id', 'right_id')),
+ 'module_enabled' => array('INDEX', 'module_enabled'),
+ 'class_left_id' => array('INDEX', array('module_class', 'left_id')),
+ ),
+ );
+
+ $schema_data['phpbb_poll_options'] = array(
+ 'COLUMNS' => array(
+ 'poll_option_id' => array('TINT:4', 0),
+ 'topic_id' => array('UINT', 0),
+ 'poll_option_text' => array('TEXT_UNI', ''),
+ 'poll_option_total' => array('UINT', 0),
+ ),
+ 'KEYS' => array(
+ 'poll_opt_id' => array('INDEX', 'poll_option_id'),
+ 'topic_id' => array('INDEX', 'topic_id'),
+ ),
+ );
+
+ $schema_data['phpbb_poll_votes'] = array(
+ 'COLUMNS' => array(
+ 'topic_id' => array('UINT', 0),
+ 'poll_option_id' => array('TINT:4', 0),
+ 'vote_user_id' => array('UINT', 0),
+ 'vote_user_ip' => array('VCHAR:40', ''),
+ ),
+ 'KEYS' => array(
+ 'topic_id' => array('INDEX', 'topic_id'),
+ 'vote_user_id' => array('INDEX', 'vote_user_id'),
+ 'vote_user_ip' => array('INDEX', 'vote_user_ip'),
+ ),
+ );
+
+ $schema_data['phpbb_posts'] = array(
+ 'COLUMNS' => array(
+ 'post_id' => array('UINT', NULL, 'auto_increment'),
+ 'topic_id' => array('UINT', 0),
+ 'forum_id' => array('UINT', 0),
+ 'poster_id' => array('UINT', 0),
+ 'icon_id' => array('UINT', 0),
+ 'poster_ip' => array('VCHAR:40', ''),
+ 'post_time' => array('TIMESTAMP', 0),
+ 'post_approved' => array('BOOL', 1),
+ 'post_reported' => array('BOOL', 0),
+ 'enable_bbcode' => array('BOOL', 1),
+ 'enable_smilies' => array('BOOL', 1),
+ 'enable_magic_url' => array('BOOL', 1),
+ 'enable_sig' => array('BOOL', 1),
+ 'post_username' => array('VCHAR_UNI:255', ''),
+ 'post_subject' => array('STEXT_UNI', '', 'true_sort'),
+ 'post_text' => array('MTEXT_UNI', ''),
+ 'post_checksum' => array('VCHAR:32', ''),
+ 'post_attachment' => array('BOOL', 0),
+ 'bbcode_bitfield' => array('VCHAR:255', ''),
+ 'bbcode_uid' => array('VCHAR:8', ''),
+ 'post_postcount' => array('BOOL', 1),
+ 'post_edit_time' => array('TIMESTAMP', 0),
+ 'post_edit_reason' => array('STEXT_UNI', ''),
+ 'post_edit_user' => array('UINT', 0),
+ 'post_edit_count' => array('USINT', 0),
+ 'post_edit_locked' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => 'post_id',
+ 'KEYS' => array(
+ 'forum_id' => array('INDEX', 'forum_id'),
+ 'topic_id' => array('INDEX', 'topic_id'),
+ 'poster_ip' => array('INDEX', 'poster_ip'),
+ 'poster_id' => array('INDEX', 'poster_id'),
+ 'post_approved' => array('INDEX', 'post_approved'),
+ 'post_username' => array('INDEX', 'post_username'),
+ 'tid_post_time' => array('INDEX', array('topic_id', 'post_time')),
+ ),
+ );
+
+ $schema_data['phpbb_privmsgs'] = array(
+ 'COLUMNS' => array(
+ 'msg_id' => array('UINT', NULL, 'auto_increment'),
+ 'root_level' => array('UINT', 0),
+ 'author_id' => array('UINT', 0),
+ 'icon_id' => array('UINT', 0),
+ 'author_ip' => array('VCHAR:40', ''),
+ 'message_time' => array('TIMESTAMP', 0),
+ 'enable_bbcode' => array('BOOL', 1),
+ 'enable_smilies' => array('BOOL', 1),
+ 'enable_magic_url' => array('BOOL', 1),
+ 'enable_sig' => array('BOOL', 1),
+ 'message_subject' => array('STEXT_UNI', ''),
+ 'message_text' => array('MTEXT_UNI', ''),
+ 'message_edit_reason' => array('STEXT_UNI', ''),
+ 'message_edit_user' => array('UINT', 0),
+ 'message_attachment' => array('BOOL', 0),
+ 'bbcode_bitfield' => array('VCHAR:255', ''),
+ 'bbcode_uid' => array('VCHAR:8', ''),
+ 'message_edit_time' => array('TIMESTAMP', 0),
+ 'message_edit_count' => array('USINT', 0),
+ 'to_address' => array('TEXT_UNI', ''),
+ 'bcc_address' => array('TEXT_UNI', ''),
+ 'message_reported' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => 'msg_id',
+ 'KEYS' => array(
+ 'author_ip' => array('INDEX', 'author_ip'),
+ 'message_time' => array('INDEX', 'message_time'),
+ 'author_id' => array('INDEX', 'author_id'),
+ 'root_level' => array('INDEX', 'root_level'),
+ ),
+ );
+
+ $schema_data['phpbb_privmsgs_folder'] = array(
+ 'COLUMNS' => array(
+ 'folder_id' => array('UINT', NULL, 'auto_increment'),
+ 'user_id' => array('UINT', 0),
+ 'folder_name' => array('VCHAR_UNI', ''),
+ 'pm_count' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'folder_id',
+ 'KEYS' => array(
+ 'user_id' => array('INDEX', 'user_id'),
+ ),
+ );
+
+ $schema_data['phpbb_privmsgs_rules'] = array(
+ 'COLUMNS' => array(
+ 'rule_id' => array('UINT', NULL, 'auto_increment'),
+ 'user_id' => array('UINT', 0),
+ 'rule_check' => array('UINT', 0),
+ 'rule_connection' => array('UINT', 0),
+ 'rule_string' => array('VCHAR_UNI', ''),
+ 'rule_user_id' => array('UINT', 0),
+ 'rule_group_id' => array('UINT', 0),
+ 'rule_action' => array('UINT', 0),
+ 'rule_folder_id' => array('INT:11', 0),
+ ),
+ 'PRIMARY_KEY' => 'rule_id',
+ 'KEYS' => array(
+ 'user_id' => array('INDEX', 'user_id'),
+ ),
+ );
+
+ $schema_data['phpbb_privmsgs_to'] = array(
+ 'COLUMNS' => array(
+ 'msg_id' => array('UINT', 0),
+ 'user_id' => array('UINT', 0),
+ 'author_id' => array('UINT', 0),
+ 'pm_deleted' => array('BOOL', 0),
+ 'pm_new' => array('BOOL', 1),
+ 'pm_unread' => array('BOOL', 1),
+ 'pm_replied' => array('BOOL', 0),
+ 'pm_marked' => array('BOOL', 0),
+ 'pm_forwarded' => array('BOOL', 0),
+ 'folder_id' => array('INT:11', 0),
+ ),
+ 'KEYS' => array(
+ 'msg_id' => array('INDEX', 'msg_id'),
+ 'author_id' => array('INDEX', 'author_id'),
+ 'usr_flder_id' => array('INDEX', array('user_id', 'folder_id')),
+ ),
+ );
+
+ $schema_data['phpbb_profile_fields'] = array(
+ 'COLUMNS' => array(
+ 'field_id' => array('UINT', NULL, 'auto_increment'),
+ 'field_name' => array('VCHAR_UNI', ''),
+ 'field_type' => array('TINT:4', 0),
+ 'field_ident' => array('VCHAR:20', ''),
+ 'field_length' => array('VCHAR:20', ''),
+ 'field_minlen' => array('VCHAR', ''),
+ 'field_maxlen' => array('VCHAR', ''),
+ 'field_novalue' => array('VCHAR_UNI', ''),
+ 'field_default_value' => array('VCHAR_UNI', ''),
+ 'field_validation' => array('VCHAR_UNI:20', ''),
+ 'field_required' => array('BOOL', 0),
+ 'field_show_on_reg' => array('BOOL', 0),
+ 'field_show_on_vt' => array('BOOL', 0),
+ 'field_show_profile' => array('BOOL', 0),
+ 'field_hide' => array('BOOL', 0),
+ 'field_no_view' => array('BOOL', 0),
+ 'field_active' => array('BOOL', 0),
+ 'field_order' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'field_id',
+ 'KEYS' => array(
+ 'fld_type' => array('INDEX', 'field_type'),
+ 'fld_ordr' => array('INDEX', 'field_order'),
+ ),
+ );
+
+ $schema_data['phpbb_profile_fields_data'] = array(
+ 'COLUMNS' => array(
+ 'user_id' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'user_id',
+ );
+
+ $schema_data['phpbb_profile_fields_lang'] = array(
+ 'COLUMNS' => array(
+ 'field_id' => array('UINT', 0),
+ 'lang_id' => array('UINT', 0),
+ 'option_id' => array('UINT', 0),
+ 'field_type' => array('TINT:4', 0),
+ 'lang_value' => array('VCHAR_UNI', ''),
+ ),
+ 'PRIMARY_KEY' => array('field_id', 'lang_id', 'option_id'),
+ );
+
+ $schema_data['phpbb_profile_lang'] = array(
+ 'COLUMNS' => array(
+ 'field_id' => array('UINT', 0),
+ 'lang_id' => array('UINT', 0),
+ 'lang_name' => array('VCHAR_UNI', ''),
+ 'lang_explain' => array('TEXT_UNI', ''),
+ 'lang_default_value' => array('VCHAR_UNI', ''),
+ ),
+ 'PRIMARY_KEY' => array('field_id', 'lang_id'),
+ );
+
+ $schema_data['phpbb_ranks'] = array(
+ 'COLUMNS' => array(
+ 'rank_id' => array('UINT', NULL, 'auto_increment'),
+ 'rank_title' => array('VCHAR_UNI', ''),
+ 'rank_min' => array('UINT', 0),
+ 'rank_special' => array('BOOL', 0),
+ 'rank_image' => array('VCHAR', ''),
+ ),
+ 'PRIMARY_KEY' => 'rank_id',
+ );
+
+ $schema_data['phpbb_reports'] = array(
+ 'COLUMNS' => array(
+ 'report_id' => array('UINT', NULL, 'auto_increment'),
+ 'reason_id' => array('USINT', 0),
+ 'post_id' => array('UINT', 0),
+ 'pm_id' => array('UINT', 0),
+ 'user_id' => array('UINT', 0),
+ 'user_notify' => array('BOOL', 0),
+ 'report_closed' => array('BOOL', 0),
+ 'report_time' => array('TIMESTAMP', 0),
+ 'report_text' => array('MTEXT_UNI', ''),
+ ),
+ 'PRIMARY_KEY' => 'report_id',
+ 'KEYS' => array(
+ 'post_id' => array('INDEX', 'post_id'),
+ 'pm_id' => array('INDEX', 'pm_id'),
+ ),
+ );
+
+ $schema_data['phpbb_reports_reasons'] = array(
+ 'COLUMNS' => array(
+ 'reason_id' => array('USINT', NULL, 'auto_increment'),
+ 'reason_title' => array('VCHAR_UNI', ''),
+ 'reason_description' => array('MTEXT_UNI', ''),
+ 'reason_order' => array('USINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'reason_id',
+ );
+
+ $schema_data['phpbb_search_results'] = array(
+ 'COLUMNS' => array(
+ 'search_key' => array('VCHAR:32', ''),
+ 'search_time' => array('TIMESTAMP', 0),
+ 'search_keywords' => array('MTEXT_UNI', ''),
+ 'search_authors' => array('MTEXT', ''),
+ ),
+ 'PRIMARY_KEY' => 'search_key',
+ );
+
+ $schema_data['phpbb_search_wordlist'] = array(
+ 'COLUMNS' => array(
+ 'word_id' => array('UINT', NULL, 'auto_increment'),
+ 'word_text' => array('VCHAR_UNI', ''),
+ 'word_common' => array('BOOL', 0),
+ 'word_count' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'word_id',
+ 'KEYS' => array(
+ 'wrd_txt' => array('UNIQUE', 'word_text'),
+ 'wrd_cnt' => array('INDEX', 'word_count'),
+ ),
+ );
+
+ $schema_data['phpbb_search_wordmatch'] = array(
+ 'COLUMNS' => array(
+ 'post_id' => array('UINT', 0),
+ 'word_id' => array('UINT', 0),
+ 'title_match' => array('BOOL', 0),
+ ),
+ 'KEYS' => array(
+ 'unq_mtch' => array('UNIQUE', array('word_id', 'post_id', 'title_match')),
+ 'word_id' => array('INDEX', 'word_id'),
+ 'post_id' => array('INDEX', 'post_id'),
+ ),
+ );
+
+ $schema_data['phpbb_sessions'] = array(
+ 'COLUMNS' => array(
+ 'session_id' => array('CHAR:32', ''),
+ 'session_user_id' => array('UINT', 0),
+ 'session_forum_id' => array('UINT', 0),
+ 'session_last_visit' => array('TIMESTAMP', 0),
+ 'session_start' => array('TIMESTAMP', 0),
+ 'session_time' => array('TIMESTAMP', 0),
+ 'session_ip' => array('VCHAR:40', ''),
+ 'session_browser' => array('VCHAR:150', ''),
+ 'session_forwarded_for' => array('VCHAR:255', ''),
+ 'session_page' => array('VCHAR_UNI', ''),
+ 'session_viewonline' => array('BOOL', 1),
+ 'session_autologin' => array('BOOL', 0),
+ 'session_admin' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => 'session_id',
+ 'KEYS' => array(
+ 'session_time' => array('INDEX', 'session_time'),
+ 'session_user_id' => array('INDEX', 'session_user_id'),
+ 'session_fid' => array('INDEX', 'session_forum_id'),
+ ),
+ );
+
+ $schema_data['phpbb_sessions_keys'] = array(
+ 'COLUMNS' => array(
+ 'key_id' => array('CHAR:32', ''),
+ 'user_id' => array('UINT', 0),
+ 'last_ip' => array('VCHAR:40', ''),
+ 'last_login' => array('TIMESTAMP', 0),
+ ),
+ 'PRIMARY_KEY' => array('key_id', 'user_id'),
+ 'KEYS' => array(
+ 'last_login' => array('INDEX', 'last_login'),
+ ),
+ );
+
+ $schema_data['phpbb_sitelist'] = array(
+ 'COLUMNS' => array(
+ 'site_id' => array('UINT', NULL, 'auto_increment'),
+ 'site_ip' => array('VCHAR:40', ''),
+ 'site_hostname' => array('VCHAR', ''),
+ 'ip_exclude' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => 'site_id',
+ );
+
+ $schema_data['phpbb_smilies'] = array(
+ 'COLUMNS' => array(
+ 'smiley_id' => array('UINT', NULL, 'auto_increment'),
+ // We may want to set 'code' to VCHAR:50 or check if unicode support is possible... at the moment only ASCII characters are allowed.
+ 'code' => array('VCHAR_UNI:50', ''),
+ 'emotion' => array('VCHAR_UNI:50', ''),
+ 'smiley_url' => array('VCHAR:50', ''),
+ 'smiley_width' => array('USINT', 0),
+ 'smiley_height' => array('USINT', 0),
+ 'smiley_order' => array('UINT', 0),
+ 'display_on_posting'=> array('BOOL', 1),
+ ),
+ 'PRIMARY_KEY' => 'smiley_id',
+ 'KEYS' => array(
+ 'display_on_post' => array('INDEX', 'display_on_posting'),
+ ),
+ );
+
+ $schema_data['phpbb_styles'] = array(
+ 'COLUMNS' => array(
+ 'style_id' => array('UINT', NULL, 'auto_increment'),
+ 'style_name' => array('VCHAR_UNI:255', ''),
+ 'style_copyright' => array('VCHAR_UNI', ''),
+ 'style_active' => array('BOOL', 1),
+ 'template_id' => array('UINT', 0),
+ 'theme_id' => array('UINT', 0),
+ 'imageset_id' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'style_id',
+ 'KEYS' => array(
+ 'style_name' => array('UNIQUE', 'style_name'),
+ 'template_id' => array('INDEX', 'template_id'),
+ 'theme_id' => array('INDEX', 'theme_id'),
+ 'imageset_id' => array('INDEX', 'imageset_id'),
+ ),
+ );
+
+ $schema_data['phpbb_styles_template'] = array(
+ 'COLUMNS' => array(
+ 'template_id' => array('UINT', NULL, 'auto_increment'),
+ 'template_name' => array('VCHAR_UNI:255', ''),
+ 'template_copyright' => array('VCHAR_UNI', ''),
+ 'template_path' => array('VCHAR:100', ''),
+ 'bbcode_bitfield' => array('VCHAR:255', 'kNg='),
+ 'template_storedb' => array('BOOL', 0),
+ 'template_inherits_id' => array('UINT:4', 0),
+ 'template_inherit_path' => array('VCHAR', ''),
+ ),
+ 'PRIMARY_KEY' => 'template_id',
+ 'KEYS' => array(
+ 'tmplte_nm' => array('UNIQUE', 'template_name'),
+ ),
+ );
+
+ $schema_data['phpbb_styles_template_data'] = array(
+ 'COLUMNS' => array(
+ 'template_id' => array('UINT', 0),
+ 'template_filename' => array('VCHAR:100', ''),
+ 'template_included' => array('TEXT', ''),
+ 'template_mtime' => array('TIMESTAMP', 0),
+ 'template_data' => array('MTEXT_UNI', ''),
+ ),
+ 'KEYS' => array(
+ 'tid' => array('INDEX', 'template_id'),
+ 'tfn' => array('INDEX', 'template_filename'),
+ ),
+ );
+
+ $schema_data['phpbb_styles_theme'] = array(
+ 'COLUMNS' => array(
+ 'theme_id' => array('UINT', NULL, 'auto_increment'),
+ 'theme_name' => array('VCHAR_UNI:255', ''),
+ 'theme_copyright' => array('VCHAR_UNI', ''),
+ 'theme_path' => array('VCHAR:100', ''),
+ 'theme_storedb' => array('BOOL', 0),
+ 'theme_mtime' => array('TIMESTAMP', 0),
+ 'theme_data' => array('MTEXT_UNI', ''),
+ ),
+ 'PRIMARY_KEY' => 'theme_id',
+ 'KEYS' => array(
+ 'theme_name' => array('UNIQUE', 'theme_name'),
+ ),
+ );
+
+ $schema_data['phpbb_styles_imageset'] = array(
+ 'COLUMNS' => array(
+ 'imageset_id' => array('UINT', NULL, 'auto_increment'),
+ 'imageset_name' => array('VCHAR_UNI:255', ''),
+ 'imageset_copyright' => array('VCHAR_UNI', ''),
+ 'imageset_path' => array('VCHAR:100', ''),
+ ),
+ 'PRIMARY_KEY' => 'imageset_id',
+ 'KEYS' => array(
+ 'imgset_nm' => array('UNIQUE', 'imageset_name'),
+ ),
+ );
+
+ $schema_data['phpbb_styles_imageset_data'] = array(
+ 'COLUMNS' => array(
+ 'image_id' => array('UINT', NULL, 'auto_increment'),
+ 'image_name' => array('VCHAR:200', ''),
+ 'image_filename' => array('VCHAR:200', ''),
+ 'image_lang' => array('VCHAR:30', ''),
+ 'image_height' => array('USINT', 0),
+ 'image_width' => array('USINT', 0),
+ 'imageset_id' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'image_id',
+ 'KEYS' => array(
+ 'i_d' => array('INDEX', 'imageset_id'),
+ ),
+ );
+
+ $schema_data['phpbb_topics'] = array(
+ 'COLUMNS' => array(
+ 'topic_id' => array('UINT', NULL, 'auto_increment'),
+ 'forum_id' => array('UINT', 0),
+ 'icon_id' => array('UINT', 0),
+ 'topic_attachment' => array('BOOL', 0),
+ 'topic_approved' => array('BOOL', 1),
+ 'topic_reported' => array('BOOL', 0),
+ 'topic_title' => array('STEXT_UNI', '', 'true_sort'),
+ 'topic_poster' => array('UINT', 0),
+ 'topic_time' => array('TIMESTAMP', 0),
+ 'topic_time_limit' => array('TIMESTAMP', 0),
+ 'topic_views' => array('UINT', 0),
+ 'topic_replies' => array('UINT', 0),
+ 'topic_replies_real' => array('UINT', 0),
+ 'topic_status' => array('TINT:3', 0),
+ 'topic_type' => array('TINT:3', 0),
+ 'topic_first_post_id' => array('UINT', 0),
+ 'topic_first_poster_name' => array('VCHAR_UNI', ''),
+ 'topic_first_poster_colour' => array('VCHAR:6', ''),
+ 'topic_last_post_id' => array('UINT', 0),
+ 'topic_last_poster_id' => array('UINT', 0),
+ 'topic_last_poster_name' => array('VCHAR_UNI', ''),
+ 'topic_last_poster_colour' => array('VCHAR:6', ''),
+ 'topic_last_post_subject' => array('STEXT_UNI', ''),
+ 'topic_last_post_time' => array('TIMESTAMP', 0),
+ 'topic_last_view_time' => array('TIMESTAMP', 0),
+ 'topic_moved_id' => array('UINT', 0),
+ 'topic_bumped' => array('BOOL', 0),
+ 'topic_bumper' => array('UINT', 0),
+ 'poll_title' => array('STEXT_UNI', ''),
+ 'poll_start' => array('TIMESTAMP', 0),
+ 'poll_length' => array('TIMESTAMP', 0),
+ 'poll_max_options' => array('TINT:4', 1),
+ 'poll_last_vote' => array('TIMESTAMP', 0),
+ 'poll_vote_change' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => 'topic_id',
+ 'KEYS' => array(
+ 'forum_id' => array('INDEX', 'forum_id'),
+ 'forum_id_type' => array('INDEX', array('forum_id', 'topic_type')),
+ 'last_post_time' => array('INDEX', 'topic_last_post_time'),
+ 'topic_approved' => array('INDEX', 'topic_approved'),
+ 'forum_appr_last' => array('INDEX', array('forum_id', 'topic_approved', 'topic_last_post_id')),
+ 'fid_time_moved' => array('INDEX', array('forum_id', 'topic_last_post_time', 'topic_moved_id')),
+ ),
+ );
+
+ $schema_data['phpbb_topics_track'] = array(
+ 'COLUMNS' => array(
+ 'user_id' => array('UINT', 0),
+ 'topic_id' => array('UINT', 0),
+ 'forum_id' => array('UINT', 0),
+ 'mark_time' => array('TIMESTAMP', 0),
+ ),
+ 'PRIMARY_KEY' => array('user_id', 'topic_id'),
+ 'KEYS' => array(
+ 'forum_id' => array('INDEX', 'forum_id'),
+ ),
+ );
+
+ $schema_data['phpbb_topics_posted'] = array(
+ 'COLUMNS' => array(
+ 'user_id' => array('UINT', 0),
+ 'topic_id' => array('UINT', 0),
+ 'topic_posted' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => array('user_id', 'topic_id'),
+ );
+
+ $schema_data['phpbb_topics_watch'] = array(
+ 'COLUMNS' => array(
+ 'topic_id' => array('UINT', 0),
+ 'user_id' => array('UINT', 0),
+ 'notify_status' => array('BOOL', 0),
+ ),
+ 'KEYS' => array(
+ 'topic_id' => array('INDEX', 'topic_id'),
+ 'user_id' => array('INDEX', 'user_id'),
+ 'notify_stat' => array('INDEX', 'notify_status'),
+ ),
+ );
+
+ $schema_data['phpbb_user_group'] = array(
+ 'COLUMNS' => array(
+ 'group_id' => array('UINT', 0),
+ 'user_id' => array('UINT', 0),
+ 'group_leader' => array('BOOL', 0),
+ 'user_pending' => array('BOOL', 1),
+ ),
+ 'KEYS' => array(
+ 'group_id' => array('INDEX', 'group_id'),
+ 'user_id' => array('INDEX', 'user_id'),
+ 'group_leader' => array('INDEX', 'group_leader'),
+ ),
+ );
+
+ $schema_data['phpbb_users'] = array(
+ 'COLUMNS' => array(
+ 'user_id' => array('UINT', NULL, 'auto_increment'),
+ 'user_type' => array('TINT:2', 0),
+ 'group_id' => array('UINT', 3),
+ 'user_permissions' => array('MTEXT', ''),
+ 'user_perm_from' => array('UINT', 0),
+ 'user_ip' => array('VCHAR:40', ''),
+ 'user_regdate' => array('TIMESTAMP', 0),
+ 'username' => array('VCHAR_CI', ''),
+ 'username_clean' => array('VCHAR_CI', ''),
+ 'user_password' => array('VCHAR_UNI:40', ''),
+ 'user_passchg' => array('TIMESTAMP', 0),
+ 'user_pass_convert' => array('BOOL', 0),
+ 'user_email' => array('VCHAR_UNI:100', ''),
+ 'user_email_hash' => array('BINT', 0),
+ 'user_birthday' => array('VCHAR:10', ''),
+ 'user_lastvisit' => array('TIMESTAMP', 0),
+ 'user_lastmark' => array('TIMESTAMP', 0),
+ 'user_lastpost_time' => array('TIMESTAMP', 0),
+ 'user_lastpage' => array('VCHAR_UNI:200', ''),
+ 'user_last_confirm_key' => array('VCHAR:10', ''),
+ 'user_last_search' => array('TIMESTAMP', 0),
+ 'user_warnings' => array('TINT:4', 0),
+ 'user_last_warning' => array('TIMESTAMP', 0),
+ 'user_login_attempts' => array('TINT:4', 0),
+ 'user_inactive_reason' => array('TINT:2', 0),
+ 'user_inactive_time' => array('TIMESTAMP', 0),
+ 'user_posts' => array('UINT', 0),
+ 'user_lang' => array('VCHAR:30', ''),
+ 'user_timezone' => array('DECIMAL', 0),
+ 'user_dst' => array('BOOL', 0),
+ 'user_dateformat' => array('VCHAR_UNI:30', 'd M Y H:i'),
+ 'user_style' => array('UINT', 0),
+ 'user_rank' => array('UINT', 0),
+ 'user_colour' => array('VCHAR:6', ''),
+ 'user_new_privmsg' => array('INT:4', 0),
+ 'user_unread_privmsg' => array('INT:4', 0),
+ 'user_last_privmsg' => array('TIMESTAMP', 0),
+ 'user_message_rules' => array('BOOL', 0),
+ 'user_full_folder' => array('INT:11', -3),
+ 'user_emailtime' => array('TIMESTAMP', 0),
+ 'user_topic_show_days' => array('USINT', 0),
+ 'user_topic_sortby_type' => array('VCHAR:1', 't'),
+ 'user_topic_sortby_dir' => array('VCHAR:1', 'd'),
+ 'user_post_show_days' => array('USINT', 0),
+ 'user_post_sortby_type' => array('VCHAR:1', 't'),
+ 'user_post_sortby_dir' => array('VCHAR:1', 'a'),
+ 'user_notify' => array('BOOL', 0),
+ 'user_notify_pm' => array('BOOL', 1),
+ 'user_notify_type' => array('TINT:4', 0),
+ 'user_allow_pm' => array('BOOL', 1),
+ 'user_allow_viewonline' => array('BOOL', 1),
+ 'user_allow_viewemail' => array('BOOL', 1),
+ 'user_allow_massemail' => array('BOOL', 1),
+ 'user_options' => array('UINT:11', 230271),
+ 'user_avatar' => array('VCHAR', ''),
+ 'user_avatar_type' => array('TINT:2', 0),
+ 'user_avatar_width' => array('USINT', 0),
+ 'user_avatar_height' => array('USINT', 0),
+ 'user_sig' => array('MTEXT_UNI', ''),
+ 'user_sig_bbcode_uid' => array('VCHAR:8', ''),
+ 'user_sig_bbcode_bitfield' => array('VCHAR:255', ''),
+ 'user_from' => array('VCHAR_UNI:100', ''),
+ 'user_icq' => array('VCHAR:15', ''),
+ 'user_aim' => array('VCHAR_UNI', ''),
+ 'user_yim' => array('VCHAR_UNI', ''),
+ 'user_msnm' => array('VCHAR_UNI', ''),
+ 'user_jabber' => array('VCHAR_UNI', ''),
+ 'user_website' => array('VCHAR_UNI:200', ''),
+ 'user_occ' => array('TEXT_UNI', ''),
+ 'user_interests' => array('TEXT_UNI', ''),
+ 'user_actkey' => array('VCHAR:32', ''),
+ 'user_newpasswd' => array('VCHAR_UNI:40', ''),
+ 'user_form_salt' => array('VCHAR_UNI:32', ''),
+ 'user_new' => array('BOOL', 1),
+ 'user_reminded' => array('TINT:4', 0),
+ 'user_reminded_time' => array('TIMESTAMP', 0),
+ ),
+ 'PRIMARY_KEY' => 'user_id',
+ 'KEYS' => array(
+ 'user_birthday' => array('INDEX', 'user_birthday'),
+ 'user_email_hash' => array('INDEX', 'user_email_hash'),
+ 'user_type' => array('INDEX', 'user_type'),
+ 'username_clean' => array('UNIQUE', 'username_clean'),
+ ),
+ );
+
+ $schema_data['phpbb_warnings'] = array(
+ 'COLUMNS' => array(
+ 'warning_id' => array('UINT', NULL, 'auto_increment'),
+ 'user_id' => array('UINT', 0),
+ 'post_id' => array('UINT', 0),
+ 'log_id' => array('UINT', 0),
+ 'warning_time' => array('TIMESTAMP', 0),
+ ),
+ 'PRIMARY_KEY' => 'warning_id',
+ );
+
+ $schema_data['phpbb_words'] = array(
+ 'COLUMNS' => array(
+ 'word_id' => array('UINT', NULL, 'auto_increment'),
+ 'word' => array('VCHAR_UNI', ''),
+ 'replacement' => array('VCHAR_UNI', ''),
+ ),
+ 'PRIMARY_KEY' => 'word_id',
+ );
+
+ $schema_data['phpbb_zebra'] = array(
+ 'COLUMNS' => array(
+ 'user_id' => array('UINT', 0),
+ 'zebra_id' => array('UINT', 0),
+ 'friend' => array('BOOL', 0),
+ 'foe' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => array('user_id', 'zebra_id'),
+ );
+
+ return $schema_data;
+}
+
+
+/**
+* Data put into the header for various dbms
+*/
+function custom_data($dbms)
+{
+ switch ($dbms)
+ {
+ case 'oracle':
+ return <<<EOF
+/*
+ This first section is optional, however its probably the best method
+ of running phpBB on Oracle. If you already have a tablespace and user created
+ for phpBB you can leave this section commented out!
+
+ The first set of statements create a phpBB tablespace and a phpBB user,
+ make sure you change the password of the phpBB user before you run this script!!
+*/
+
+/*
+CREATE TABLESPACE "PHPBB"
+ LOGGING
+ DATAFILE 'E:\ORACLE\ORADATA\LOCAL\PHPBB.ora'
+ SIZE 10M
+ AUTOEXTEND ON NEXT 10M
+ MAXSIZE 100M;
+
+CREATE USER "PHPBB"
+ PROFILE "DEFAULT"
+ IDENTIFIED BY "phpbb_password"
+ DEFAULT TABLESPACE "PHPBB"
+ QUOTA UNLIMITED ON "PHPBB"
+ ACCOUNT UNLOCK;
+
+GRANT ANALYZE ANY TO "PHPBB";
+GRANT CREATE SEQUENCE TO "PHPBB";
+GRANT CREATE SESSION TO "PHPBB";
+GRANT CREATE TABLE TO "PHPBB";
+GRANT CREATE TRIGGER TO "PHPBB";
+GRANT CREATE VIEW TO "PHPBB";
+GRANT "CONNECT" TO "PHPBB";
+
+COMMIT;
+DISCONNECT;
+
+CONNECT phpbb/phpbb_password;
+*/
+EOF;
+
+ break;
+
+ case 'postgres':
+ return <<<EOF
+/*
+ Domain definition
+*/
+CREATE DOMAIN varchar_ci AS varchar(255) NOT NULL DEFAULT ''::character varying;
+
+/*
+ Operation Functions
+*/
+CREATE FUNCTION _varchar_ci_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) = LOWER($2)' LANGUAGE SQL STRICT;
+CREATE FUNCTION _varchar_ci_not_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) != LOWER($2)' LANGUAGE SQL STRICT;
+CREATE FUNCTION _varchar_ci_less_than(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) < LOWER($2)' LANGUAGE SQL STRICT;
+CREATE FUNCTION _varchar_ci_less_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) <= LOWER($2)' LANGUAGE SQL STRICT;
+CREATE FUNCTION _varchar_ci_greater_than(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) > LOWER($2)' LANGUAGE SQL STRICT;
+CREATE FUNCTION _varchar_ci_greater_equals(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) >= LOWER($2)' LANGUAGE SQL STRICT;
+
+/*
+ Operators
+*/
+CREATE OPERATOR <(
+ PROCEDURE = _varchar_ci_less_than,
+ LEFTARG = varchar_ci,
+ RIGHTARG = varchar_ci,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+
+CREATE OPERATOR <=(
+ PROCEDURE = _varchar_ci_less_equal,
+ LEFTARG = varchar_ci,
+ RIGHTARG = varchar_ci,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+
+CREATE OPERATOR >(
+ PROCEDURE = _varchar_ci_greater_than,
+ LEFTARG = varchar_ci,
+ RIGHTARG = varchar_ci,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+
+CREATE OPERATOR >=(
+ PROCEDURE = _varchar_ci_greater_equals,
+ LEFTARG = varchar_ci,
+ RIGHTARG = varchar_ci,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+
+CREATE OPERATOR <>(
+ PROCEDURE = _varchar_ci_not_equal,
+ LEFTARG = varchar_ci,
+ RIGHTARG = varchar_ci,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR =(
+ PROCEDURE = _varchar_ci_equal,
+ LEFTARG = varchar_ci,
+ RIGHTARG = varchar_ci,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ HASHES,
+ MERGES,
+ SORT1= <);
+
+EOF;
+ break;
+ }
+
+ return '';
+}
+
+echo 'done';
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/create_variable_overview.php b/phpBB/develop/create_variable_overview.php
new file mode 100644
index 0000000000..3782f53e4c
--- /dev/null
+++ b/phpBB/develop/create_variable_overview.php
@@ -0,0 +1,547 @@
+<?php
+// -------------------------------------------------------------
+//
+// $Id$
+//
+// FILENAME : create_variable_overview.php
+// STARTED : Fri Aug 15 2003
+// COPYRIGHT : � 2003 phpBB Group
+// WWW : http://www.phpbb.com/
+// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
+//
+// -------------------------------------------------------------
+
+/*
+ This script generates an index of some template vars and their use within the templates.
+ It writes down all language variables used by various templates.
+*/
+
+//
+// Security message:
+//
+// This script is potentially dangerous.
+// Remove or comment the next line (die(".... ) to enable this script.
+// Do NOT FORGET to either remove this script or disable it after you have used it.
+//
+die("Please read the first lines of this script for instructions on how to enable it");
+
+$directory = '../styles/subSilver/template/';
+$ext = 'html';
+$store_dir = '../store/';
+
+$phpfiles_directories = array('../', '../includes/', '../includes/acm/', '../includes/auth/', '../includes/mcp/', '../includes/ucp/');
+// Template Files beginning with this names are merged together
+$merge = array('gcp', 'login', 'mcp', 'memberlist', 'posting', 'ucp');
+
+if (!is_writable($store_dir))
+{
+ die("Directory $store_dir is not writable!");
+}
+
+$contents = implode('', file('../adm/subSilver.css', filesize('../adm/subSilver.css')));
+$fp = fopen($store_dir . 'subSilver.css', 'w');
+fwrite($fp, $contents);
+fclose($fp);
+
+$html_skeleton = '
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<link rel="stylesheet" href="subSilver.css" type="text/css">
+<style type="text/css">
+<!--
+th { background-image: url(\'cellpic3.gif\') }
+td.cat { background-image: url(\'cellpic1.gif\') }
+//-->
+</style>
+<title>{FILENAME}</title>
+</head>
+<body>
+
+<table width="100%" cellspacing="0" cellpadding="0" border="0">
+ <tr>
+ <td><img src="header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></td>
+ <td width="100%" background="header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">File {FILENAME}</span> &nbsp; &nbsp; &nbsp;</td>
+ </tr>
+</table>
+
+<table width="95%" cellspacing="0" cellpadding="0" border="0" align="center">
+ <tr>
+ <td><br clear="all" />
+
+';
+$html_skeleton .= '<br><a href="./index.html" class="gen">Back to Contents</a><br><br>';
+$html_skeleton .= '<br><a href="#lang" class="gen">Language Variables</a> :: <a href="#includes" class="gen">Includes</a> :: <a href="#cond" class="gen">Conditionals</a><br><a href="#remain" class="gen">Remaining Vars</a> :: <a href="#usedby" class="gen">phpBB File Usage</a> :: <a href="#ref" class="gen">References</a>';
+$html_skeleton .= '<br><br><a name="lang"></a><b>Language Variables</b><br><br>{LANGUAGE_VARIABLES}';
+$html_skeleton .= '<br><br><a name="includes"></a><b>Included Files</b><br><br>{INCLUDES}';
+$html_skeleton .= '<br><br><a name="cond"></a><b>Used Conditionals</b><br><br>{CONDITIONALS}';
+$html_skeleton .= '<br><br><a name="remain"></a><b>Remaining Vars used</b><br><br>{REMAINING_VARS}';
+$html_skeleton .= '<br><br><a name="usedby"></a><b>This Template File is used by the following phpBB Files</b><br><br>{USED_BY}';
+$html_skeleton .= '<br><br><a name="ref"></a><b>References: </b>{SEE_FILES}';
+
+//$html_skeleton .= "</body>\n</html>\n";
+
+$html_skeleton .= '
+<br><br>
+<div class="copyright" align="center">Powered by phpBB 2.2 &copy; <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB Group</a>, 2003</div>
+
+ <br clear="all" /></td>
+ </tr>
+</table>
+
+</body>
+</html>
+';
+
+// Open Language File
+include('../language/en/lang_main.php');
+include('../language/en/lang_admin.php');
+
+$files_to_parse = $php_files = array();
+
+$dhandler = opendir($directory);
+if (!$dhandler)
+{
+ die("Unable to open $directory");
+}
+
+$num = 0;
+while ($file = readdir($dhandler))
+{
+ if (is_file($directory . $file) && preg_match('#\.' . $ext . '$#i', $file))
+ {
+ $files_to_parse[$num]['filename'] = $directory . $file;
+ $files_to_parse[$num]['single_filename'] = $file;
+ $files_to_parse[$num]['destfile'] = str_replace(".{$ext}", '', $file) . '_' . $num . '.html';
+ $file_to_destfile[$file] = $files_to_parse[$num]['destfile'];
+ $num++;
+ }
+}
+closedir($dhandler);
+
+$num = 0;
+foreach ($phpfiles_directories as $directory)
+{
+ $dhandler = opendir($directory);
+ if (!$dhandler)
+ {
+ die("Unable to open $directory");
+ }
+
+ while ($file = readdir($dhandler))
+ {
+ if (is_file($directory . $file) && preg_match('#\.php$#i', $file))
+ {
+ $php_files[$num]['filename'] = $directory . $file;
+ $php_files[$num]['single_filename'] = $file;
+ $num++;
+ }
+ }
+ closedir($dhandler);
+}
+
+$php_files_includes = $lang_references = array();
+
+//$php_files_includes['viewtopic_attach_body.html'][0] = filename
+
+echo '<br>Parsing PHP Files';
+
+// Parse PHP Files and get our filenames
+foreach ($php_files as $file_num => $data)
+{
+ echo '.';
+ flush();
+ $contents = implode('', file($data['filename'], filesize($data['filename'])));
+
+ $html_files = array();
+ preg_match_all('#([a-zA-Z0-9\-_]*?)\.' . $ext . '#s', $contents, $html_files);
+ $html_files = array_unique($html_files[1]);
+
+ foreach ($html_files as $html_file)
+ {
+ $html_file = trim($html_file);
+ if ($html_file != '')
+ {
+ $php_files_includes[$html_file . '.' . $ext][] = $data['filename'];
+ }
+ }
+}
+
+echo '<br>Parsing HTML Files';
+foreach ($files_to_parse as $file_num => $data)
+{
+ echo '.';
+ flush();
+ $contents = implode('', file($data['filename'], filesize($data['filename'])));
+
+ // Language Variables -> [0]:tpl [1]:lang
+ $lang_vars = array();
+ preg_match_all('#{L_([a-z0-9\-_]*?)\}#is', $contents, $lang_vars);
+ $contents = preg_replace('#{L_([a-z0-9\-_]*?)\}#is', '', $contents);
+ $lang_vars[0] = array_unique($lang_vars[0]);
+ $lang_vars[1] = array_unique($lang_vars[1]);
+
+ // Includes
+ $includes = array();
+ preg_match_all('#<!-- INCLUDE ([a-zA-Z0-9\_\-\+\.]+?) -->#s', $contents, $includes);
+ $contents = preg_replace('#<!-- INCLUDE ([a-zA-Z0-9\_\-\+\.]+?) -->#', '', $contents);
+ $includes = $includes[1];
+ $includes = array_unique($includes);
+
+ // IF Conditions
+ $switches = array();
+ preg_match_all('#<!-- [IF]|[ELSEIF] ([a-zA-Z0-9\-_\.]+?) (.*?)?[ ]?-->#', $contents, $switches);
+ $contents = preg_replace('#<!-- [IF]|[ELSEIF] ([a-zA-Z0-9\-_]) (.*?)?[ ]?-->#s', '', $contents);
+ $switches[0] = array_unique($switches[1]); // No resorting please
+ $switches[1] = $switches[2];
+ unset($switches[2]);
+
+ // Remaining Vars
+ $remaining_vars = array();
+ preg_match_all('#{([a-z0-9\-_\.]*?)\}#is', $contents, $remaining_vars);
+ $contents = preg_replace('#{([a-z0-9\-_]*?)\}#is', '', $contents);
+ $remaining_vars = array_unique($remaining_vars[1]);
+ sort($remaining_vars, SORT_STRING);
+
+ // Now build the filename specific site
+ $fp = fopen($store_dir . $data['destfile'], 'w');
+ $html_data = $html_skeleton;
+
+ $html_data = str_replace('{FILENAME}', $data['single_filename'], $html_data);
+
+ // Write up the Language Variables
+ if (count($lang_vars[0]))
+ {
+ $lang_data = '<ul>';
+ for ($num = 0; $num <= count($lang_vars[0]); $num++)
+ {
+ $var = $lang_vars[0][$num];
+ if ($var != '')
+ {
+ $_var = str_replace(array('{', '}'), array('', ''), $var);
+ $lang_references[$_var][] = $data['single_filename'];
+ $lang_data .= '<li>' . $var . '<br>' . "\n" . ((isset($lang[$_var])) ? htmlspecialchars(str_replace("\\'", "'", $lang[$_var])) : '<span style="color:red">No Language Variable available</span>') . '<br></li><br>' . "\n";
+ }
+ }
+ $lang_data .= '</ul>';
+ }
+ else
+ {
+ $lang_data = '<b>NONE</b><br>' . "\n";
+ }
+
+ $html_data = str_replace('{LANGUAGE_VARIABLES}', $lang_data, $html_data);
+
+ // Write up the Includes
+ echo '.';
+ flush();
+ if (count($includes))
+ {
+ $includes_data = '<ul>';
+ $see_files = '';
+ for ($num = 0; $num <= count($includes); $num++)
+ {
+ $var = $includes[$num];
+ if ($var != '')
+ {
+ $includes_data .= '<li><a href="./' . $file_to_destfile[$var] . '" class="gen">' . $var . '</a></li><br>' . "\n";
+ $see_files .= ($see_files != '') ? ' :: ' : '';
+ $see_files .= '<a href="./' . $file_to_destfile[$var] . '" class="gen">' . $var . '</a>';
+ }
+ }
+ $includes_data .= '</ul>';
+ }
+ else
+ {
+ $includes_data = '<b>NONE</b><br>' . "\n";
+ $see_files = '<b>NONE</b>';
+ }
+
+ $html_data = str_replace('{INCLUDES}', $includes_data, $html_data);
+ $html_data = str_replace('{SEE_FILES}', $see_files, $html_data);
+
+ // Write up Conditionals
+ echo '.';
+ flush();
+ if (count($switches[0]))
+ {
+ $conditionals = '<ul>';
+ for ($num = 0; $num <= count($switches[0]); $num++)
+ {
+ $var = trim($switches[0][$num]);
+ if ($var != '')
+ {
+ if ($var == 'not')
+ {
+ $conditionals .= '<li>' . trim($switches[1][$num]) . '<br><b>Negation</b><br>' . "\n";
+ $block_var = explode('.', trim($switches[1][$num]));
+ unset($block_var[0]);
+ }
+ else
+ {
+ $conditionals .= '<li>' . $var . ((trim($switches[1][$num]) != '') ? '<br>' . "\n" . '<i>Compared with</i> -&gt; <b>' . trim($switches[1][$num]) . '</b>' : '') . '<br>' . "\n";
+ $block_var = explode('.', $var);
+ unset($block_var[count($block_var)-1]);
+ }
+
+ if (count($block_var))
+ {
+ for ($_num = count($block_var)-1; $_num >= 0; $_num--)
+ {
+ $conditionals .= ($_num == count($block_var)-1) ? '<i>Element of Block</i> -&gt; <b>' . $block_var[$_num] . '</b><br>' . "\n" : '<i>...which is an element of</i> -&gt; <b>' . $block_var[$_num] . '</b><br>' . "\n";
+ }
+ }
+ $conditionals .= '<br></li>' . "\n";
+ }
+ }
+ $conditionals .= '</ul>';
+ }
+ else
+ {
+ $conditionals = '<b>NONE</b><br>' . "\n";
+ }
+
+ $html_data = str_replace('{CONDITIONALS}', $conditionals, $html_data);
+
+ // Write up Remaining Vars
+ echo '.';
+ flush();
+ if (count($remaining_vars))
+ {
+ $remaining = '<ul>';
+ for ($num = 0; $num <= count($remaining_vars); $num++)
+ {
+ $var = trim($remaining_vars[$num]);
+ if ($var != '')
+ {
+ $remaining .= '<li>' . $var . '<br>' . "\n";
+ $block_var = explode('.', $var);
+ unset($block_var[count($block_var)-1]);
+
+ if (count($block_var))
+ {
+ for ($_num = count($block_var)-1; $_num >= 0; $_num--)
+ {
+ $remaining .= ($_num == count($block_var)-1) ? '<i>Element of Block</i> -&gt; <b>' . $block_var[$_num] . '</b><br>' . "\n" : '<i>...which is an element of</i> -&gt; <b>' . $block_var[$_num] . '</b><br>' . "\n";
+ }
+ }
+ $remaining .= '<br></li>' . "\n";
+ }
+ }
+ $remaining .= '</ul>';
+ }
+ else
+ {
+ $remaining = '<b>NONE</b><br>' . "\n";
+ }
+
+ $html_data = str_replace('{REMAINING_VARS}', $remaining, $html_data);
+
+ if (isset($php_files_includes[$data['single_filename']]) && count($php_files_includes[$data['single_filename']]))
+ {
+ $usedby = '<ul>';
+ foreach ($php_files_includes[$data['single_filename']] as $php_filename)
+ {
+ $usedby .= '<li>' . str_replace('../', '', $php_filename) . '</li>';
+ }
+ $usedby .= '</ul>';
+ }
+ else
+ {
+ $usedby = '<b>NONE</b><br>' . "\n";
+ }
+
+ $html_data = str_replace('{USED_BY}', $usedby, $html_data);
+
+ fwrite($fp, $html_data);
+ fclose($fp);
+}
+
+echo '<br>Store Files';
+
+$fp = fopen($store_dir . 'index.html', 'w');
+
+$html_data = '
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<link rel="stylesheet" href="subSilver.css" type="text/css">
+<style type="text/css">
+<!--
+th { background-image: url(\'cellpic3.gif\') }
+td.cat { background-image: url(\'cellpic1.gif\') }
+//-->
+</style>
+<title>Contents</title>
+</head>
+<body>
+
+<table width="100%" cellspacing="0" cellpadding="0" border="0">
+ <tr>
+ <td><img src="header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></td>
+ <td width="100%" background="header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">Available Template Files</span> &nbsp; &nbsp; &nbsp;</td>
+ </tr>
+</table>
+
+<table width="95%" cellspacing="0" cellpadding="0" border="0" align="center">
+ <tr>
+ <td><br clear="all" />
+<br>This Style Document is 100% auto-generated... no human interaction included. :D<br>
+<h2>phpBB 2.2 Template</h2>
+<br>
+<ol>
+';
+
+sort($files_to_parse);
+foreach ($files_to_parse as $file_num => $data)
+{
+ echo '.';
+ flush();
+ $var = $data['single_filename'];
+ $html_data .= '<li><a href="./' . $file_to_destfile[$var] . '" class="gen">' . $var . '</a></li><br>' . "\n";
+}
+
+$html_data .= '<br><li><a href="./lang_index.html" class="gen">Appendix A: Language Variable Index</a></li><br>';
+
+$html_data .= '
+</ol><br><br>
+<div class="copyright" align="center">Powered by phpBB 2.2 &copy; <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB Group</a>, 2003</div>
+
+ <br clear="all" /></td>
+ </tr>
+</table>
+
+</body>
+</html>
+';
+
+fwrite($fp, $html_data);
+fclose($fp);
+
+// Not only write down all language files, place them into a specific array, named by the template file
+// All Language vars assigned to more than one template will be placed into a common file
+$entry = array();
+$common_fp = fopen($store_dir . 'lang_common.php', 'w');
+fwrite($common_fp, "<?php\n\n \$lang = array(\n");
+
+$fp = fopen($store_dir . 'lang_index.html', 'w');
+
+$html_data = '
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<link rel="stylesheet" href="subSilver.css" type="text/css">
+<style type="text/css">
+<!--
+th { background-image: url(\'cellpic3.gif\') }
+td.cat { background-image: url(\'cellpic1.gif\') }
+//-->
+</style>
+<title>Appendix A :: Language Variable Index</title>
+</head>
+<body>
+
+<table width="100%" cellspacing="0" cellpadding="0" border="0">
+ <tr>
+ <td><img src="header_left.jpg" width="200" height="60" alt="phpBB Logo" title="phpBB Logo" border="0"/></td>
+ <td width="100%" background="header_bg.jpg" height="60" align="right" nowrap="nowrap"><span class="maintitle">Language Variable Index</span> &nbsp; &nbsp; &nbsp;</td>
+ </tr>
+</table>
+
+<table width="95%" cellspacing="0" cellpadding="0" border="0" align="center">
+ <tr>
+ <td><br clear="all" />
+<br><a href="./index.html" class="gen">Back to Contents</a><br><br>
+<br>
+';
+
+echo '<br>Write Language Files';
+
+asort($lang_references);
+ksort($lang_references);
+$_index = '';
+$old_char = '';
+foreach ($lang_references as $lang_var => $filenames)
+{
+ $var = preg_replace('#^L_(.*?)#', '\1', $lang_var);
+ $char = $var{0};
+ if ($old_char != $char)
+ {
+ $old_char = $char;
+ $_index .= ($_index != '') ? ' :: ' : '';
+ $_index .= '<a href="#' . $char . '" class="gen"><b>' . $char . '</b></a>';
+ }
+}
+
+$html_data .= $_index . '<br><br><br>';
+$old_char = '';
+foreach ($lang_references as $lang_var => $filenames)
+{
+ echo '.';
+ flush();
+ $var = preg_replace('#^L_(.*?)#', '\1', $lang_var);
+ $char = $var{0};
+ if ($old_char != $char)
+ {
+ $old_char = $char;
+ $html_data .= '<br><hr><br><a name="' . $char . '"></a><h2>Letter ' . $char . '</h2><br><br>';
+ }
+
+ $html_data .= '<b>' . $lang_var . '</b><ul>';
+
+ if (sizeof($filenames) != 1)
+ {
+ fwrite($common_fp, (($entry['common']) ? ",\n" : '') . "\t'$var' => '" . $lang[$var] . "'");
+ $entry['common'] = true;
+ }
+ else if (sizeof($filenames) == 1)
+ {
+ // Merge logical - hardcoded
+ $fname = (preg_match('#^(' . implode('|', $merge) . ')#', $filenames[0], $match)) ? $match[0] . '.php' : str_replace($ext, 'php', $filenames[0]);
+
+ if (!$lang_fp[$fname])
+ {
+ $lang_fp[$fname] = fopen($store_dir . 'lang_' . $fname, 'w');
+ fwrite($lang_fp[$fname], "<?php\n\n\$lang = array(\n");
+ $entry[$fname] = false;
+ }
+ fwrite($lang_fp[$fname], (($entry[$fname]) ? ",\n" : '') . "\t'$var' => '" . $lang[$var] . "'");
+ $entry[$fname] = true;
+ }
+
+ foreach ($filenames as $f_name)
+ {
+ $var = trim($f_name);
+ $html_data .= '<li><a href="./' . $file_to_destfile[$var] . '" class="gen">' . $var . '</a></li><br>' . "\n";
+ }
+ $html_data .= '</ul><br><br>';
+}
+
+fwrite($common_fp, ")\n);\n?>");
+fclose($common_fp);
+
+foreach ($lang_fp as $filepointer)
+{
+ fwrite($filepointer, ")\n);\n?>");
+ fclose($filepointer);
+}
+
+$html_data .= '
+<br><br>
+<div class="copyright" align="center">Powered by phpBB 2.2 &copy; <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB Group</a>, 2003</div>
+
+ <br clear="all" /></td>
+ </tr>
+</table>
+
+</body>
+</html>
+';
+
+fwrite($fp, $html_data);
+fclose($fp);
+
+echo '<br>Finished!';
+flush();
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/fill.php b/phpBB/develop/fill.php
new file mode 100644
index 0000000000..336e510d06
--- /dev/null
+++ b/phpBB/develop/fill.php
@@ -0,0 +1,190 @@
+<?php
+// -------------------------------------------------------------
+//
+// $Id$
+//
+// FILENAME : fill.php
+// STARTED : Mon Sep 15, 2003
+// COPYRIGHT : � 2001, 2003 phpBB Group
+// WWW : http://www.phpbb.com/
+// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
+//
+// -------------------------------------------------------------
+//
+// Security message:
+//
+// This script is potentially dangerous.
+// Remove or comment the next line (die(".... ) to enable this script.
+// Do NOT FORGET to either remove this script or disable it after you have used it.
+//
+die("Please read the first lines of this script for instructions on how to enable it");
+
+
+define('IN_PHPBB', true);
+$phpbb_root_path = './../';
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+include($phpbb_root_path . 'common.'.$phpEx);
+include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
+
+set_time_limit(0);
+header('Expires: 0');
+ignore_user_abort(true);
+
+// number of topics to create
+$num_topics = 10000;
+
+// number of topics to be generated per call
+$batch_size = 2000;
+
+// max number of posts per topic
+$posts_per_topic = 500;
+
+
+// general vars
+$mode = (isset($_REQUEST['mode'])) ? $_REQUEST['mode'] : 'generate';
+$start = (isset($_REQUEST['start'])) ? intval($_REQUEST['start']) : 0;
+
+switch ($mode)
+{
+ case 'generate':
+ $user_ids = $forum_ids = $topic_rows = array();
+
+ $sql = 'SELECT user_id FROM ' . USERS_TABLE . ' WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ') OR user_id = ' . ANONYMOUS;
+ $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $user_ids[] = $row['user_id'];
+ }
+ $db->sql_freeresult($result);
+
+ $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . ' WHERE forum_type = ' . FORUM_POST;
+ $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $forum_ids[$row['forum_id']] = $row['forum_id'];
+ }
+ $db->sql_freeresult($result);
+
+ if (!$start)
+ {
+ $db->sql_query('TRUNCATE TABLE ' . POSTS_TABLE);
+ $db->sql_query('TRUNCATE TABLE ' . TOPICS_TABLE);
+// $db->sql_query('TRUNCATE TABLE ' . TOPICS_TABLE . '_prefetch');
+ }
+
+ $db->sql_query('LOCK TABLES ' . POSTS_TABLE . ' WRITE, ' . TOPICS_TABLE . ' WRITE');
+
+ for ($topic_id = $start + 1; $topic_id < min($start + $batch_size, $num_topics + 1); ++$topic_id)
+ {
+ $forum_id = array_rand($forum_ids);
+
+ if (count($topic_rows) == 10)
+ {
+ $sql = 'INSERT IGNORE INTO ' . TOPICS_TABLE . " (topic_id, forum_id, topic_title, topic_reported)
+ VALUES " . implode(', ', $topic_rows);
+ $db->sql_query($sql);
+
+ $topic_rows = array();
+ }
+
+ $topic_rows[] = "($topic_id, $forum_id, '$forum_id-$topic_id', " . (($topic_id % 34) ? '0' : '1') . ')';
+
+ $sql = 'INSERT IGNORE INTO ' . POSTS_TABLE . ' (topic_id, forum_id, poster_id, post_subject, post_text, post_username, post_approved, post_time, post_reported)
+ VALUES ';
+
+ $rows = array();
+ $post_time = mt_rand(0, time());
+
+ $num_posts = $posts_per_topic; //mt_rand(1, $posts_per_topic);
+ for ($i = 0; $i < $num_posts; ++$i)
+ {
+ $poster_id = $user_ids[array_rand($user_ids)];
+ $poster_name = ($poster_id == ANONYMOUS) ? rndm_username() : '';
+ $rows[] = "($topic_id, $forum_id, $poster_id, '$forum_id-$topic_id-$i', '$forum_id-$topic_id-$i', '$poster_name', " . (mt_rand(0, 12) ? '1' : '0') . ', ' . ($post_time + $i * 60) . ', ' . (mt_rand(0, 32) ? '0' : '1') . ')';
+ }
+
+ $db->sql_query($sql . implode(', ', $rows));
+ }
+
+ if (count($topic_rows))
+ {
+ $sql = 'INSERT IGNORE INTO ' . TOPICS_TABLE . " (topic_id, forum_id, topic_title, topic_reported)
+ VALUES " . implode(', ', $topic_rows);
+ $db->sql_query($sql);
+ }
+
+ $db->sql_query('UNLOCK TABLES');
+
+ if ($topic_id >= $num_topics)
+ {
+ echo '<meta http-equiv="refresh" content="10; url=fill.' . $phpEx . '?mode=sync&amp;' . time() . '">And now for something completely different...';
+
+ $db->sql_query('ANALYZE TABLES ' . TOPICS_TABLE . ', ' . POSTS_TABLE);
+ flush();
+ }
+ else
+ {
+ echo '<meta http-equiv="refresh" content="10; url=fill.' . $phpEx . '?start=' . $topic_id . '&amp;' . time() . '">To the next page... (' . $topic_id . '/' . $num_topics . ')';
+ flush();
+ }
+ break;
+
+ case 'sync':
+/* error_reporting(E_ALL);
+ $sync_all = TRUE;
+
+ if ($sync_all)
+ {
+ $s = explode(' ', microtime());
+ sync('topic', '', '', TRUE, FALSE);
+// sync('forum');
+ $e = explode(' ', microtime());
+
+ echo '<pre><b>' . ($e[0] + $e[1] - $s[0] - $s[1]) . '</b></pre>';
+ echo '<a href="fill.' . $phpEx . '">Here we go again</a>';
+ }
+ else
+ {
+ $batch_size = $batch_size * 10;
+ $end = $start + $batch_size;
+
+ $s = explode(' ', microtime());
+ sync('topic', 'range', "topic_id BETWEEN $start AND $end", TRUE, FALSE);
+ $e = explode(' ', microtime());
+
+ echo '<pre>Time taken: <b>' . ($e[0] + $e[1] - $s[0] - $s[1]) . '</b></pre>';
+
+ if ($end < $num_topics)
+ {
+ $start += $batch_size;
+ echo '<meta http-equiv="refresh" content="0; url=fill.' . $phpEx . "?mode=sync&amp;start=$start&amp;" . time() . "\">And now for something completely different... ($start/$num_topics)";
+ }
+ else
+ {
+ echo '<a href="fill.' . $phpEx . '">Here we go again</a>';
+ }
+ }
+
+ if (isset($_GET['explain']))
+ {
+ trigger_error('Done');
+ }
+ */
+}
+
+$db->sql_close();
+
+function rndm_username()
+{
+ static $usernames;
+
+ if (!isset($usernames))
+ {
+ $usernames = get_defined_functions();
+ $usernames = $usernames['internal'];
+ }
+
+ return $usernames[array_rand($usernames)];
+}
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/fix_files.sh b/phpBB/develop/fix_files.sh
new file mode 100755
index 0000000000..782418f504
--- /dev/null
+++ b/phpBB/develop/fix_files.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+#
+# Remove all those annoying ^M characters that Winblows editor's like to add
+# from all files in the current directory and all subdirectories.
+#
+# Written by: Jonathan Haase.
+#
+# UPDATE: 7/31/2001: fix so that it doesn't touch things in the images directory
+#
+# UPDATE: 12/15/2003: Fix so that it doesn't touch any "non-text" files
+#
+
+find . > FILELIST.$$
+grep -sv FILELIST FILELIST.$$ > FILELIST2.$$
+grep -sv $(basename $0) FILELIST2.$$ > FILELIST.$$
+grep -sv "^\.$" FILELIST.$$ > FILELIST2.$$
+file -f FILELIST2.$$ |grep text | sed -e 's/^\([^\:]*\)\:.*$/\1/' > FILELIST
+file -f FILELIST2.$$ |grep -sv text | sed -e 's/^\([^\:]*\)\:.*$/Not Modifying file: \1/'
+rm FILELIST2.$$
+rm FILELIST.$$
+
+for i in $(cat FILELIST); do
+ if [ -f $i ]; then
+ sed -e s/
+//g $i > $i.tmp
+ mv $i.tmp $i
+ fi
+done
+rm FILELIST
diff --git a/phpBB/develop/generate_utf_casefold.php b/phpBB/develop/generate_utf_casefold.php
new file mode 100644
index 0000000000..89c4aec01a
--- /dev/null
+++ b/phpBB/develop/generate_utf_casefold.php
@@ -0,0 +1,156 @@
+<?php
+/**
+*
+* @package phpBB3
+* @version $Id$
+* @copyright (c) 2005 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+if (php_sapi_name() != 'cli')
+{
+ die("This program must be run from the command line.\n");
+}
+
+//
+// Security message:
+//
+// This script is potentially dangerous.
+// Remove or comment the next line (die(".... ) to enable this script.
+// Do NOT FORGET to either remove this script or disable it after you have used it.
+//
+die("Please read the first lines of this script for instructions on how to enable it");
+
+set_time_limit(0);
+
+define('IN_PHPBB', true);
+$phpbb_root_path = '../';
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+
+echo "Checking for required files\n";
+download('http://unicode.org/Public/UNIDATA/CaseFolding.txt');
+echo "\n";
+
+
+/**
+* Load the CaseFolding table
+*/
+echo "Loading CaseFolding\n";
+$unidata = file_get_contents('CaseFolding.txt');
+
+
+function utf8_chr($cp)
+{
+ if ($cp > 0xFFFF)
+ {
+ return chr(0xF0 | ($cp >> 18)) . chr(0x80 | (($cp >> 12) & 0x3F)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F));
+ }
+ else if ($cp > 0x7FF)
+ {
+ return chr(0xE0 | ($cp >> 12)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F));
+ }
+ else if ($cp > 0x7F)
+ {
+ return chr(0xC0 | ($cp >> 6)) . chr(0x80 | ($cp & 0x3F));
+ }
+ else
+ {
+ return chr($cp);
+ }
+}
+
+preg_match_all('/^([0-9A-F]+); ([CFS]); ([0-9A-F]+(?: [0-9A-F]+)*);/im', $unidata, $array, PREG_SET_ORDER);
+
+$uniarray = array();
+
+foreach ($array as $value)
+{
+ $uniarray[$value[2]][utf8_chr(hexdec((string)$value[1]))] = implode(array_map('utf8_chr', array_map('hexdec', explode(' ', $value[3]))));
+}
+
+foreach ($uniarray as $idx => $contents)
+{
+ echo "Writing to case_fold_$idx.$phpEx\n";
+ $fp = fopen($phpbb_root_path . 'includes/utf/data/case_fold_' . strtolower($idx) . '.' . $phpEx, 'wb');
+ fwrite($fp, '<?php return ' . my_var_export($contents) . ';');
+ fclose($fp);
+}
+
+/**
+* Return a parsable string representation of a variable
+*
+* This is function is limited to array/strings/integers
+*
+* @param mixed $var Variable
+* @return string PHP code representing the variable
+*/
+function my_var_export($var)
+{
+ if (is_array($var))
+ {
+ $lines = array();
+
+ foreach ($var as $k => $v)
+ {
+ $lines[] = my_var_export($k) . '=>' . my_var_export($v);
+ }
+
+ return 'array(' . implode(',', $lines) . ')';
+ }
+ else if (is_string($var))
+ {
+ return "'" . str_replace(array('\\', "'"), array('\\\\', "\\'"), $var) . "'";
+ }
+ else
+ {
+ return $var;
+ }
+}
+
+/**
+* Download a file to the develop/ dir
+*
+* @param string $url URL of the file to download
+* @return void
+*/
+function download($url)
+{
+ global $phpbb_root_path;
+
+ if (file_exists($phpbb_root_path . 'develop/' . basename($url)))
+ {
+ return;
+ }
+
+ echo 'Downloading from ', $url, ' ';
+
+ if (!$fpr = fopen($url, 'rb'))
+ {
+ die("Can't download from $url\nPlease download it yourself and put it in the develop/ dir, kthxbai");
+ }
+
+ if (!$fpw = fopen($phpbb_root_path . 'develop/' . basename($url), 'wb'))
+ {
+ die("Can't open develop/" . basename($url) . " for output... please check your permissions or something");
+ }
+
+ $i = 0;
+ $chunk = 32768;
+ $done = '';
+
+ while (!feof($fpr))
+ {
+ $i += fwrite($fpw, fread($fpr, $chunk));
+ echo str_repeat("\x08", strlen($done));
+
+ $done = ($i >> 10) . ' KiB';
+ echo $done;
+ }
+ fclose($fpr);
+ fclose($fpw);
+
+ echo "\n";
+}
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/generate_utf_confusables.php b/phpBB/develop/generate_utf_confusables.php
new file mode 100644
index 0000000000..f79471afc6
--- /dev/null
+++ b/phpBB/develop/generate_utf_confusables.php
@@ -0,0 +1,240 @@
+<?php
+/**
+*
+* @package phpBB3
+* @version $Id$
+* @copyright (c) 2005 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+if (php_sapi_name() != 'cli')
+{
+ die("This program must be run from the command line.\n");
+}
+
+//
+// Security message:
+//
+// This script is potentially dangerous.
+// Remove or comment the next line (die(".... ) to enable this script.
+// Do NOT FORGET to either remove this script or disable it after you have used it.
+//
+die("Please read the first lines of this script for instructions on how to enable it");
+
+set_time_limit(0);
+
+define('IN_PHPBB', true);
+$phpbb_root_path = '../';
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+
+echo "Checking for required files\n";
+download('http://unicode.org/reports/tr39/data/confusables.txt');
+download('http://unicode.org/Public/UNIDATA/CaseFolding.txt');
+echo "\n";
+
+
+/**
+* Load the confusables table
+*/
+echo "Loading confusables\n";
+$unidata = file_get_contents('confusables.txt');
+
+/**
+* Load the CaseFolding table
+*/
+echo "Loading CaseFolding\n";
+$casefolds = file_get_contents('CaseFolding.txt');
+
+
+function utf8_chr($cp)
+{
+ if ($cp > 0xFFFF)
+ {
+ return chr(0xF0 | ($cp >> 18)) . chr(0x80 | (($cp >> 12) & 0x3F)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F));
+ }
+ else if ($cp > 0x7FF)
+ {
+ return chr(0xE0 | ($cp >> 12)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F));
+ }
+ else if ($cp > 0x7F)
+ {
+ return chr(0xC0 | ($cp >> 6)) . chr(0x80 | ($cp & 0x3F));
+ }
+ else
+ {
+ return chr($cp);
+ }
+}
+
+preg_match_all('/^([0-9A-F]+) ;\s((?:[0-9A-F]+ )*);.*?$/im', $unidata, $array, PREG_SET_ORDER);
+preg_match_all('/^([0-9A-F]+); ([CFS]); ([0-9A-F]+(?: [0-9A-F]+)*);/im', $casefolds, $casefold_array);
+
+// some that we defined ourselves
+$uniarray = array(
+ "\xC2\xA1" => "\x69", // EXCLAMATION MARK, INVERTED => LATIN SMALL LETTER I
+ "\xC7\x83" => "\x21", // LATIN LETTER RETROFLEX CLICK => EXCLAMATION MARK
+ "\xCE\xB1" => "\x61", // GREEK SMALL LETTER ALPHA => LATIN SMALL LETTER A
+ "\xE1\x9A\x80" => "\x20", // OGHAM SPACE MARK
+
+ "\xC2\xAD" => '', // HYPHEN, SOFT => empty string
+ "\xDB\x9D" => '', // ARABIC END OF AYAH
+ "\xDC\x8F" => '', // SYRIAC ABBREVIATION MARK
+ "\xE1\xA0\x86" => '', // MONGOLIAN TODO SOFT HYPHEN
+ "\xE1\xA0\x8E" => '', // MONGOLIAN VOWEL SEPARATOR
+ "\xE2\x80\x8B" => '', // ZERO WIDTH SPACE
+ "\xE2\x80\x8C" => '', // ZERO WIDTH NON-JOINER
+ "\xE2\x80\x8D" => '', // ZERO WIDTH JOINER
+ "\xE2\x80\xA8" => '', // LINE SEPARATOR
+ "\xE2\x80\xA9" => '', // PARAGRAPH SEPARATOR
+ "\xE2\x81\xA0" => '', // WORD JOINER
+ "\xE2\x81\xA1" => '', // FUNCTION APPLICATION
+ "\xE2\x81\xA2" => '', // INVISIBLE TIMES
+ "\xE2\x81\xA3" => '', // INVISIBLE SEPARATOR
+ "\xE2\x81\xAA" => '', // [CONTROL CHARACTERS]
+ "\xE2\x81\xAB" => '', // [CONTROL CHARACTERS]
+ "\xE2\x81\xAC" => '', // [CONTROL CHARACTERS]
+ "\xE2\x81\xAD" => '', // [CONTROL CHARACTERS]
+ "\xE2\x81\xAE" => '', // [CONTROL CHARACTERS]
+ "\xE2\x81\xAF" => '', // [CONTROL CHARACTERS]
+ "\xEF\xBB\xBF" => '', // ZERO WIDTH NO-BREAK SPACE
+ "\xEF\xBF\xB9" => '', // [CONTROL CHARACTERS]
+ "\xEF\xBF\xBA" => '', // [CONTROL CHARACTERS]
+ "\xEF\xBF\xBB" => '', // [CONTROL CHARACTERS]
+ "\xEF\xBF\xBC" => '', // [CONTROL CHARACTERS]
+ "\xF0\x9D\x85\xB3" => '', // [MUSICAL CONTROL CHARACTERS]
+ "\xF0\x9D\x85\xB4" => '', // [MUSICAL CONTROL CHARACTERS]
+ "\xF0\x9D\x85\xB5" => '', // [MUSICAL CONTROL CHARACTERS]
+ "\xF0\x9D\x85\xB6" => '', // [MUSICAL CONTROL CHARACTERS]
+ "\xF0\x9D\x85\xB7" => '', // [MUSICAL CONTROL CHARACTERS]
+ "\xF0\x9D\x85\xB8" => '', // [MUSICAL CONTROL CHARACTERS]
+ "\xF0\x9D\x85\xB9" => '', // [MUSICAL CONTROL CHARACTERS]
+ "\xF0\x9D\x85\xBA" => '', // [MUSICAL CONTROL CHARACTERS]
+);
+
+$copy = $uniarray;
+
+foreach ($array as $value)
+{
+ $temp_hold = implode(array_map('utf8_chr', array_map('hexdec', explode(' ', trim($value[2])))));
+
+ if (isset($copy[utf8_chr(hexdec((string)$value[1]))]))
+ {
+ $num = '';
+ $string = utf8_chr(hexdec((string)$value[1]));
+ for ($i = 0; $i < strlen($string); $i++)
+ {
+ $num .= '\x' . str_pad(base_convert(ord($string[$i]), 10, 16), 2, '0', STR_PAD_LEFT);
+ }
+ echo $num . "\n";
+ if ($uniarray[$string] != $temp_hold)
+ {
+ echo " --> $string\n";
+ echo " --> " . $temp_hold . "\n";
+ }
+ }
+
+ // do some tests for things that transform into something with the number one
+ if (strpos($temp_hold, utf8_chr(0x0031)) !== false)
+ {
+ // any kind of letter L?
+ if (strpos($value[0], 'LETTER L') !== false || strpos($value[0], 'IOTA') !== false || strpos($value[0], 'SMALL L ') !== false || preg_match('/SMALL LIGATURE [^L]*L /', $value[0]))
+ {
+ // replace all of the mappings that transform some sort of letter l to number one instead to some sort of letter l to latin small letter l
+ $temp_hold = str_replace(utf8_chr(0x0031), utf8_chr(0x006C), $temp_hold);
+ }
+ }
+
+ // uppercased chars that were folded do not exist in this universe,
+ // no amount of normalization could ever "trick" this into not working
+ if (in_array($value[1], $casefold_array[1]))
+ {
+ continue;
+ }
+
+ $uniarray[utf8_chr(hexdec((string)$value[1]))] = $temp_hold;
+}
+
+echo "Writing to confusables.$phpEx\n";
+
+$fp = fopen($phpbb_root_path . 'includes/utf/data/confusables.' . $phpEx, 'wb');
+fwrite($fp, '<?php return ' . my_var_export($uniarray) . ';');
+fclose($fp);
+
+/**
+* Return a parsable string representation of a variable
+*
+* This is function is limited to array/strings/integers
+*
+* @param mixed $var Variable
+* @return string PHP code representing the variable
+*/
+function my_var_export($var)
+{
+ if (is_array($var))
+ {
+ $lines = array();
+
+ foreach ($var as $k => $v)
+ {
+ $lines[] = my_var_export($k) . '=>' . my_var_export($v);
+ }
+
+ return 'array(' . implode(',', $lines) . ')';
+ }
+ else if (is_string($var))
+ {
+ return "'" . str_replace(array('\\', "'"), array('\\\\', "\\'"), $var) . "'";
+ }
+ else
+ {
+ return $var;
+ }
+}
+
+/**
+* Download a file to the develop/ dir
+*
+* @param string $url URL of the file to download
+* @return void
+*/
+function download($url)
+{
+ global $phpbb_root_path;
+
+ if (file_exists($phpbb_root_path . 'develop/' . basename($url)))
+ {
+ return;
+ }
+
+ echo 'Downloading from ', $url, ' ';
+
+ if (!$fpr = fopen($url, 'rb'))
+ {
+ die("Can't download from $url\nPlease download it yourself and put it in the develop/ dir, kthxbai");
+ }
+
+ if (!$fpw = fopen($phpbb_root_path . 'develop/' . basename($url), 'wb'))
+ {
+ die("Can't open develop/" . basename($url) . " for output... please check your permissions or something");
+ }
+
+ $i = 0;
+ $chunk = 32768;
+ $done = '';
+
+ while (!feof($fpr))
+ {
+ $i += fwrite($fpw, fread($fpr, $chunk));
+ echo str_repeat("\x08", strlen($done));
+
+ $done = ($i >> 10) . ' KiB';
+ echo $done;
+ }
+ fclose($fpr);
+ fclose($fpw);
+
+ echo "\n";
+}
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/generate_utf_tables.php b/phpBB/develop/generate_utf_tables.php
new file mode 100644
index 0000000000..3d5188163d
--- /dev/null
+++ b/phpBB/develop/generate_utf_tables.php
@@ -0,0 +1,572 @@
+<?php
+/**
+*
+* @package phpBB3
+* @version $Id$
+* @copyright (c) 2005 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+if (php_sapi_name() != 'cli')
+{
+ die("This program must be run from the command line.\n");
+}
+
+//
+// Security message:
+//
+// This script is potentially dangerous.
+// Remove or comment the next line (die(".... ) to enable this script.
+// Do NOT FORGET to either remove this script or disable it after you have used it.
+//
+die("Please read the first lines of this script for instructions on how to enable it");
+
+set_time_limit(0);
+
+define('IN_PHPBB', true);
+$phpbb_root_path = '../';
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+
+echo "Checking for required files\n";
+download('http://www.unicode.org/Public/UNIDATA/CompositionExclusions.txt');
+download('http://www.unicode.org/Public/UNIDATA/DerivedNormalizationProps.txt');
+download('http://www.unicode.org/Public/UNIDATA/UnicodeData.txt');
+echo "\n";
+
+require_once($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx);
+$file_contents = array();
+
+/**
+* Generate some Hangul/Jamo stuff
+*/
+echo "\nGenerating Hangul and Jamo tables\n";
+for ($i = 0; $i < UNICODE_HANGUL_LCOUNT; ++$i)
+{
+ $utf_char = cp_to_utf(UNICODE_HANGUL_LBASE + $i);
+ $file_contents['utf_normalizer_common']['utf_jamo_index'][$utf_char] = $i * UNICODE_HANGUL_VCOUNT * UNICODE_HANGUL_TCOUNT + UNICODE_HANGUL_SBASE;
+ $file_contents['utf_normalizer_common']['utf_jamo_type'][$utf_char] = UNICODE_JAMO_L;
+}
+
+for ($i = 0; $i < UNICODE_HANGUL_VCOUNT; ++$i)
+{
+ $utf_char = cp_to_utf(UNICODE_HANGUL_VBASE + $i);
+ $file_contents['utf_normalizer_common']['utf_jamo_index'][$utf_char] = $i * UNICODE_HANGUL_TCOUNT;
+ $file_contents['utf_normalizer_common']['utf_jamo_type'][$utf_char] = UNICODE_JAMO_V;
+}
+
+for ($i = 0; $i < UNICODE_HANGUL_TCOUNT; ++$i)
+{
+ $utf_char = cp_to_utf(UNICODE_HANGUL_TBASE + $i);
+ $file_contents['utf_normalizer_common']['utf_jamo_index'][$utf_char] = $i;
+ $file_contents['utf_normalizer_common']['utf_jamo_type'][$utf_char] = UNICODE_JAMO_T;
+}
+
+/**
+* Load the CompositionExclusions table
+*/
+echo "Loading CompositionExclusion\n";
+$fp = fopen('CompositionExclusions.txt', 'rt');
+
+$exclude = array();
+while (!feof($fp))
+{
+ $line = fgets($fp, 1024);
+
+ if (!strpos(' 0123456789ABCDEFabcdef', $line[0]))
+ {
+ continue;
+ }
+
+ $cp = strtok($line, ' ');
+
+ if ($pos = strpos($cp, '..'))
+ {
+ $start = hexdec(substr($cp, 0, $pos));
+ $end = hexdec(substr($cp, $pos + 2));
+
+ for ($i = $start; $i < $end; ++$i)
+ {
+ $exclude[$i] = 1;
+ }
+ }
+ else
+ {
+ $exclude[hexdec($cp)] = 1;
+ }
+}
+fclose($fp);
+
+/**
+* Load QuickCheck tables
+*/
+echo "Generating QuickCheck tables\n";
+$fp = fopen('DerivedNormalizationProps.txt', 'rt');
+
+while (!feof($fp))
+{
+ $line = fgets($fp, 1024);
+
+ if (!strpos(' 0123456789ABCDEFabcdef', $line[0]))
+ {
+ continue;
+ }
+
+ $p = array_map('trim', explode(';', strtok($line, '#')));
+
+ /**
+ * Capture only NFC_QC, NFKC_QC
+ */
+ if (!preg_match('#^NFK?C_QC$#', $p[1]))
+ {
+ continue;
+ }
+
+ if ($pos = strpos($p[0], '..'))
+ {
+ $start = hexdec(substr($p[0], 0, $pos));
+ $end = hexdec(substr($p[0], $pos + 2));
+ }
+ else
+ {
+ $start = $end = hexdec($p[0]);
+ }
+
+ if ($start >= UTF8_HANGUL_FIRST && $end <= UTF8_HANGUL_LAST)
+ {
+ /**
+ * We do not store Hangul syllables in the array
+ */
+ continue;
+ }
+
+ if ($p[2] == 'M')
+ {
+ $val = UNICODE_QC_MAYBE;
+ }
+ else
+ {
+ $val = UNICODE_QC_NO;
+ }
+
+ if ($p[1] == 'NFKC_QC')
+ {
+ $file = 'utf_nfkc_qc';
+ }
+ else
+ {
+ $file = 'utf_nfc_qc';
+ }
+
+ for ($i = $start; $i <= $end; ++$i)
+ {
+ /**
+ * The vars have the same name as the file: $utf_nfc_qc is in utf_nfc_qc.php
+ */
+ $file_contents[$file][$file][cp_to_utf($i)] = $val;
+ }
+}
+fclose($fp);
+
+/**
+* Do mappings
+*/
+echo "Loading Unicode decomposition mappings\n";
+$fp = fopen($phpbb_root_path . 'develop/UnicodeData.txt', 'rt');
+
+$map = array();
+while (!feof($fp))
+{
+ $p = explode(';', fgets($fp, 1024));
+ $cp = hexdec($p[0]);
+
+ if (!empty($p[3]))
+ {
+ /**
+ * Store combining class > 0
+ */
+ $file_contents['utf_normalizer_common']['utf_combining_class'][cp_to_utf($cp)] = (int) $p[3];
+ }
+
+ if (!isset($p[5]) || !preg_match_all('#[0-9A-F]+#', strip_tags($p[5]), $m))
+ {
+ continue;
+ }
+
+ if (strpos($p[5], '>'))
+ {
+ $map['NFKD'][$cp] = implode(' ', array_map('hexdec', $m[0]));
+ }
+ else
+ {
+ $map['NFD'][$cp] = $map['NFKD'][$cp] = implode(' ', array_map('hexdec', $m[0]));
+ }
+}
+fclose($fp);
+
+/**
+* Build the canonical composition table
+*/
+echo "Generating the Canonical Composition table\n";
+foreach ($map['NFD'] as $cp => $decomp_seq)
+{
+ if (!strpos($decomp_seq, ' ') || isset($exclude[$cp]))
+ {
+ /**
+ * Singletons are excluded from canonical composition
+ */
+ continue;
+ }
+
+ $utf_seq = implode('', array_map('cp_to_utf', explode(' ', $decomp_seq)));
+
+ if (!isset($file_contents['utf_canonical_comp']['utf_canonical_comp'][$utf_seq]))
+ {
+ $file_contents['utf_canonical_comp']['utf_canonical_comp'][$utf_seq] = cp_to_utf($cp);
+ }
+}
+
+/**
+* Decompose the NF[K]D mappings recursively and prepare the file contents
+*/
+echo "Generating the Canonical and Compatibility Decomposition tables\n\n";
+foreach ($map as $type => $decomp_map)
+{
+ foreach ($decomp_map as $cp => $decomp_seq)
+ {
+ $decomp_map[$cp] = decompose($decomp_map, $decomp_seq);
+ }
+ unset($decomp_seq);
+
+ if ($type == 'NFKD')
+ {
+ $file = 'utf_compatibility_decomp';
+ $var = 'utf_compatibility_decomp';
+ }
+ else
+ {
+ $file = 'utf_canonical_decomp';
+ $var = 'utf_canonical_decomp';
+ }
+
+ /**
+ * Generate the corresponding file
+ */
+ foreach ($decomp_map as $cp => $decomp_seq)
+ {
+ $file_contents[$file][$var][cp_to_utf($cp)] = implode('', array_map('cp_to_utf', explode(' ', $decomp_seq)));
+ }
+}
+
+/**
+* Generate and/or alter the files
+*/
+foreach ($file_contents as $file => $contents)
+{
+ /**
+ * Generate a new file
+ */
+ echo "Writing to $file.$phpEx\n";
+
+ if (!$fp = fopen($phpbb_root_path . 'includes/utf/data/' . $file . '.' . $phpEx, 'wb'))
+ {
+ trigger_error('Cannot open ' . $file . ' for write');
+ }
+
+ fwrite($fp, '<?php');
+ foreach ($contents as $var => $val)
+ {
+ fwrite($fp, "\n\$GLOBALS[" . my_var_export($var) . ']=' . my_var_export($val) . ";");
+ }
+ fclose($fp);
+}
+
+echo "\n*** UTF-8 normalization tables done\n\n";
+
+/**
+* Now we'll generate the files needed by the search indexer
+*/
+echo "Generating search indexer tables\n";
+
+$fp = fopen($phpbb_root_path . 'develop/UnicodeData.txt', 'rt');
+
+$map = array();
+while ($line = fgets($fp, 1024))
+{
+ /**
+ * The current line is split, $m[0] hold the codepoint in hexadecimal and
+ * all other fields numbered as in http://www.unicode.org/Public/UNIDATA/UCD.html#UnicodeData.txt
+ */
+ $m = explode(';', $line);
+
+ /**
+ * @var integer $cp Current char codepoint
+ * @var string $utf_char UTF-8 representation of current char
+ */
+ $cp = hexdec($m[0]);
+ $utf_char = cp_to_utf($cp);
+
+ /**
+ * $m[2] holds the "General Category" of the character
+ * @link http://www.unicode.org/Public/UNIDATA/UCD.html#General_Category_Values
+ */
+ switch ($m[2][0])
+ {
+ case 'L':
+ /**
+ * We allow all letters and map them to their lowercased counterpart on the fly
+ */
+ $map_to_hex = (isset($m[13][0])) ? $m[13] : $m[0];
+
+ if (preg_match('#^LATIN.*(?:LETTER|LIGATURE) ([A-Z]{2}(?![A-Z]))$#', $m[1], $capture))
+ {
+ /**
+ * Special hack for some latin ligatures. Using the name of a character
+ * is bad practice, but for now it works well enough.
+ *
+ * @todo Note that ligatures with combining marks such as U+01E2 are
+ * not supported at this time
+ */
+ $map[$cp] = strtolower($capture[1]);
+ }
+ else if (isset($m[13][0]))
+ {
+ /**
+ * If the letter has a lowercased form, use it
+ */
+ $map[$cp] = hex_to_utf($m[13]);
+ }
+ else
+ {
+ /**
+ * In all other cases, map the letter to itself
+ */
+ $map[$cp] = $utf_char;
+ }
+ break;
+
+ case 'M':
+ /**
+ * We allow all marks, they are mapped to themselves
+ */
+ $map[$cp] = $utf_char;
+ break;
+
+ case 'N':
+ /**
+ * We allow all numbers, but we map them to their numeric value whenever
+ * possible. The numeric value (field #8) is in ASCII already
+ *
+ * @todo Note that fractions such as U+00BD will be converted to something
+ * like "1/2", with a slash. However, "1/2" entered in ASCII is converted
+ * to "1 2". This will have to be fixed.
+ */
+ $map[$cp] = (isset($m[8][0])) ? $m[8] : $utf_char;
+ break;
+
+ default:
+ /**
+ * Everything else is ignored, skip to the next line
+ */
+ continue 2;
+ }
+}
+fclose($fp);
+
+/**
+* Add some cheating
+*/
+$cheats = array(
+ '00DF' => 'ss', # German sharp S
+ '00C5' => 'ae', # Capital A with diaeresis
+ '00E4' => 'ae', # Small A with diaeresis
+ '00D6' => 'oe', # Capital O with diaeresis
+ '00F6' => 'oe', # Small O with diaeresis
+ '00DC' => 'ue', # Capital U with diaeresis
+ '00FC' => 'ue', # Small U with diaeresis
+);
+
+/**
+* Add our "cheat replacements" to the map
+*/
+foreach ($cheats as $hex => $map_to)
+{
+ $map[hexdec($hex)] = $map_to;
+}
+
+/**
+* Split the map into smaller blocks
+*/
+$file_contents = array();
+foreach ($map as $cp => $map_to)
+{
+ $file_contents[$cp >> 11][cp_to_utf($cp)] = $map_to;
+}
+unset($map);
+
+foreach ($file_contents as $idx => $contents)
+{
+ echo "Writing to search_indexer_$idx.$phpEx\n";
+ $fp = fopen($phpbb_root_path . 'includes/utf/data/search_indexer_' . $idx . '.' . $phpEx, 'wb');
+ fwrite($fp, '<?php return ' . my_var_export($contents) . ';');
+ fclose($fp);
+}
+echo "\n*** Search indexer tables done\n\n";
+
+
+die("\nAll done!\n");
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Internal functions //
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+* Decompose a sequence recusively
+*
+* @param array $decomp_map Decomposition mapping, passed by reference
+* @param string $decomp_seq Decomposition sequence as decimal codepoints separated with a space
+* @return string Decomposition sequence, fully decomposed
+*/
+function decompose(&$decomp_map, $decomp_seq)
+{
+ $ret = array();
+ foreach (explode(' ', $decomp_seq) as $cp)
+ {
+ if (isset($decomp_map[$cp]))
+ {
+ $ret[] = decompose($decomp_map, $decomp_map[$cp]);
+ }
+ else
+ {
+ $ret[] = $cp;
+ }
+ }
+
+ return implode(' ', $ret);
+}
+
+
+/**
+* Return a parsable string representation of a variable
+*
+* This is function is limited to array/strings/integers
+*
+* @param mixed $var Variable
+* @return string PHP code representing the variable
+*/
+function my_var_export($var)
+{
+ if (is_array($var))
+ {
+ $lines = array();
+
+ foreach ($var as $k => $v)
+ {
+ $lines[] = my_var_export($k) . '=>' . my_var_export($v);
+ }
+
+ return 'array(' . implode(',', $lines) . ')';
+ }
+ else if (is_string($var))
+ {
+ return "'" . str_replace(array('\\', "'"), array('\\\\', "\\'"), $var) . "'";
+ }
+ else
+ {
+ return $var;
+ }
+}
+
+/**
+* Download a file to the develop/ dir
+*
+* @param string $url URL of the file to download
+* @return void
+*/
+function download($url)
+{
+ global $phpbb_root_path;
+
+ if (file_exists($phpbb_root_path . 'develop/' . basename($url)))
+ {
+ return;
+ }
+
+ echo 'Downloading from ', $url, ' ';
+
+ if (!$fpr = fopen($url, 'rb'))
+ {
+ die("Can't download from $url\nPlease download it yourself and put it in the develop/ dir, kthxbai");
+ }
+
+ if (!$fpw = fopen($phpbb_root_path . 'develop/' . basename($url), 'wb'))
+ {
+ die("Can't open develop/" . basename($url) . " for output... please check your permissions or something");
+ }
+
+ $i = 0;
+ $chunk = 32768;
+ $done = '';
+
+ while (!feof($fpr))
+ {
+ $i += fwrite($fpw, fread($fpr, $chunk));
+ echo str_repeat("\x08", strlen($done));
+
+ $done = ($i >> 10) . ' KiB';
+ echo $done;
+ }
+ fclose($fpr);
+ fclose($fpw);
+
+ echo "\n";
+}
+
+/**
+* Convert a codepoint in hexadecimal to a UTF-8 char
+*
+* @param string $hex Codepoint, in hexadecimal
+* @return string UTF-8 char
+*/
+function hex_to_utf($hex)
+{
+ return cp_to_utf(hexdec($hex));
+}
+
+/**
+* Return a UTF string formed from a sequence of codepoints in hexadecimal
+*
+* @param string $seq Sequence of codepoints, separated with a space
+* @return string UTF-8 string
+*/
+function hexseq_to_utf($seq)
+{
+ return implode('', array_map('hex_to_utf', explode(' ', $seq)));
+}
+
+/**
+* Convert a codepoint to a UTF-8 char
+*
+* @param integer $cp Unicode codepoint
+* @return string UTF-8 string
+*/
+function cp_to_utf($cp)
+{
+ if ($cp > 0xFFFF)
+ {
+ return chr(0xF0 | ($cp >> 18)) . chr(0x80 | (($cp >> 12) & 0x3F)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F));
+ }
+ else if ($cp > 0x7FF)
+ {
+ return chr(0xE0 | ($cp >> 12)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F));
+ }
+ else if ($cp > 0x7F)
+ {
+ return chr(0xC0 | ($cp >> 6)) . chr(0x80 | ($cp & 0x3F));
+ }
+ else
+ {
+ return chr($cp);
+ }
+} \ No newline at end of file
diff --git a/phpBB/develop/lang_duplicates.php b/phpBB/develop/lang_duplicates.php
new file mode 100644
index 0000000000..5be48f69f0
--- /dev/null
+++ b/phpBB/develop/lang_duplicates.php
@@ -0,0 +1,140 @@
+<html>
+ <head>
+ <title>Duplicate Language Keys</title>
+ </head>
+ <body>
+<?php
+//
+// Security message:
+//
+// This script is potentially dangerous.
+// Remove or comment the next line (die(".... ) to enable this script.
+// Do NOT FORGET to either remove this script or disable it after you have used it.
+//
+die("Please read the first lines of this script for instructions on how to enable it");
+
+// -------------------------------------------------------------
+//
+// $Id$
+//
+// @copyright (c) 2005 phpBB Group
+// @license http://opensource.org/licenses/gpl-license.php GNU Public License
+//
+// -------------------------------------------------------------
+// Thanks to arod-1
+
+define('IN_PHPBB', 1);
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+$phpbb_root_path='./../';
+include($phpbb_root_path . 'common.'.$phpEx);
+
+$mode = request_var('mode', '');
+
+$modules = find_modules($phpbb_root_path . 'language/en');
+
+$kkeys = $keys = array();
+$langdir = dirname(__FILE__);
+
+if (isset($lang))
+{
+ unset($lang);
+}
+
+foreach($modules as $module)
+{
+ require_once("$langdir$module");
+ if (isset($lang))
+ {
+ $kkeys[$module] = $lang;
+ $keys[] = $module;
+ unset($lang);
+ }
+}
+
+$equal = $case = $diff = 0;
+$output = array();
+
+while ($module = array_shift($keys))
+{
+ $keys_1 = array_keys($kkeys[$module]);
+
+ foreach ($keys as $other_module)
+ {
+ $keys_2 = array_keys($kkeys[$other_module]);
+
+ foreach(array_intersect($keys_1, $keys_2) as $dup)
+ {
+ if ($kkeys[$module][$dup] == $kkeys[$other_module][$dup])
+ {
+ $compare = "Equal";
+ $equal++;
+ }
+ else if (strcasecmp($kkeys[$module][$dup], $kkeys[$other_module][$dup]) == 0)
+ {
+ $compare = "Differ in case";
+ $case++;
+ }
+ else
+ {
+ $compare = "'{$kkeys[$module][$dup]}' - '{$kkeys[$other_module][$dup]}'";
+ $diff++;
+ }
+
+ $color = '';
+ if ((basename($module) == "common.$phpEx") || (basename($other_module) == "common.$phpEx"))
+ {
+ $color = ' style="color:#B00000;"';
+ }
+
+ switch ($mode)
+ {
+ case 'module':
+ $output[$module][] = "<tr$color><td>" . ((isset($output[$module])) ? '&nbsp;' : "<b>$module</b>" ) . "</td><td>$dup</td><td>$other_module</td><td>$compare</td></tr>";
+ break;
+
+ default:
+ $output[$dup][] = "<tr$color><td><b>$dup</b></td><td>$module</td><td>$other_module</td><td>$compare</td></tr>";
+ break;
+ }
+ }
+ }
+}//var_dump($output);
+
+echo "<p><a href=\"lang_duplicates.php\">By Key</a> <a href=\"lang_duplicates.php?mode=module\">By Module</a></p><p>Equal: <b>$equal</b>, Differ in case only: $case, differ in content: $diff</p>";
+switch ($mode)
+{
+ case 'module':
+ echo "<table cellpadding=\"4\"><tr><th>Key</th><th>First File</th><th>Second File</th><th>Difference</th></tr>";
+ foreach ($output as $module => $html)
+ {
+ echo implode('', $html);
+ }
+ break;
+
+ default:
+ ksort($output);
+ echo "<table cellpadding=\"4\"><tr><th>File</th><th>Key</th><th>Conflicting File</th><th>Difference</th></tr>";
+ foreach ($output as $dup)
+ {
+ echo implode('', $dup);
+ }
+ break;
+}
+
+echo "</table>";
+
+
+function find_modules($dirname)
+{
+ $list = glob("$dirname/*.php");
+
+ foreach(glob("$dirname/*", GLOB_ONLYDIR) as $name)
+ {
+ $list = array_merge($list, find_modules($name));
+ }
+ return $list;
+}
+
+?>
+ </body>
+</html> \ No newline at end of file
diff --git a/phpBB/develop/merge_attachment_tables.php b/phpBB/develop/merge_attachment_tables.php
new file mode 100644
index 0000000000..ae7fe57be4
--- /dev/null
+++ b/phpBB/develop/merge_attachment_tables.php
@@ -0,0 +1,80 @@
+<?php
+// -------------------------------------------------------------
+//
+// $Id$
+//
+// FILENAME : merge_attachment_tables.php
+// STARTED : Tue Nov 04, 2003
+// COPYRIGHT : � 2001, 2003 phpBB Group
+// WWW : http://www.phpbb.com/
+// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
+//
+// -------------------------------------------------------------
+
+//
+// Security message:
+//
+// This script is potentially dangerous.
+// Remove or comment the next line (die(".... ) to enable this script.
+// Do NOT FORGET to either remove this script or disable it after you have used it.
+//
+die("Please read the first lines of this script for instructions on how to enable it");
+
+$db = $dbhost = $dbuser = $dbpasswd = $dbport = $dbname = '';
+
+define('IN_PHPBB', 1);
+define('ANONYMOUS', 1);
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+$phpbb_root_path='./../';
+include($phpbb_root_path . 'config.'.$phpEx);
+require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.'.$phpEx);
+require($phpbb_root_path . 'includes/db/' . $dbms . '.'.$phpEx);
+include($phpbb_root_path . 'includes/functions.'.$phpEx);
+
+$cache = new acm();
+$db = new sql_db();
+
+// Connect to DB
+$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
+
+// Rename the attachments table...
+$sql = "RENAME TABLE {$table_prefix}attachments TO {$table_prefix}attach_temp";
+$db->sql_query($sql);
+
+$sql = "CREATE TABLE {$table_prefix}attachments
+ SELECT d.*, a.post_id, a.user_id_from as poster_id, p.topic_id
+ FROM {$table_prefix}attach_desc d, {$table_prefix}attach_temp a, {$table_prefix}posts p
+ WHERE a.attach_id = d.attach_id
+ AND a.post_id = p.post_id";
+$db->sql_query($sql);
+
+switch ($db->sql_layer)
+{
+ case 'mysql':
+ case 'mysql4':
+ $sql = 'ALTER TABLE ' . $table_prefix . 'attachments
+ ADD PRIMARY KEY (attach_id),
+ ADD INDEX filetime (filetime),
+ ADD INDEX post_id (post_id),
+ ADD INDEX poster_id (poster_id),
+ ADD INDEX physical_filename (physical_filename(10)),
+ ADD INDEX filesize (filesize),
+ ADD INDEX topic_id (topic_id),
+ MODIFY COLUMN attach_id mediumint(8) UNSIGNED NOT NULL auto_increment';
+ break;
+
+ case 'mssql':
+ case 'mssql-odbc':
+ case 'msaccess':
+ break;
+
+ case 'postgresql':
+ break;
+}
+$db->sql_query($sql);
+
+//$db->sql_query("DROP TABLE {$table_prefix}attach_temp");
+
+echo "<p><b>Done</b></p>\n";
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/merge_post_tables.php b/phpBB/develop/merge_post_tables.php
new file mode 100644
index 0000000000..3567a569c6
--- /dev/null
+++ b/phpBB/develop/merge_post_tables.php
@@ -0,0 +1,209 @@
+<?php
+/***************************************************************************
+ * merge_clean_posts.php
+ * -------------------
+ * begin : Tuesday, February 25, 2003
+ * copyright : (C) 2003 The phpBB Group
+ * email : support@phpbb.com
+ *
+ * $Id$
+ *
+ ***************************************************************************/
+
+/***************************************************************************
+ *
+ * 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.
+ *
+ ***************************************************************************/
+
+//
+// Security message:
+//
+// This script is potentially dangerous.
+// Remove or comment the next line (die(".... ) to enable this script.
+// Do NOT FORGET to either remove this script or disable it after you have used it.
+//
+die("Please read the first lines of this script for instructions on how to enable it");
+
+@set_time_limit(2400);
+
+$db = $dbhost = $dbuser = $dbpasswd = $dbport = $dbname = '';
+
+define('IN_PHPBB', 1);
+define('ANONYMOUS', 1);
+$phpbb_root_path='./../';
+include($phpbb_root_path . 'extension.inc');
+include($phpbb_root_path . 'config.'.$phpEx);
+include($phpbb_root_path . 'includes/functions.'.$phpEx);
+require($phpbb_root_path . 'includes/acm/cache_' . $acm_type . '.'.$phpEx);
+include($phpbb_root_path . 'db/' . $dbms . '.'.$phpEx);
+
+$cache = new acm();
+$db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false);
+
+// Just Do it (tm)
+$sql = "RENAME TABLE {$table_prefix}posts TO {$table_prefix}posts_temp";
+$db->sql_query($sql);
+
+$sql = "CREATE TABLE {$table_prefix}posts
+ SELECT p.*, pt.post_subject, pt.post_text, pt.post_checksum, pt.bbcode_bitfield, pt.bbcode_uid
+ FROM {$table_prefix}posts_temp p, {$table_prefix}posts_text pt
+ WHERE pt.post_id = p.post_id";
+$db->sql_query($sql);
+
+switch ($db->sql_layer)
+{
+ case 'mysql':
+ case 'mysql4':
+ $sql = 'ALTER TABLE ' . $table_prefix . 'posts
+ ADD PRIMARY KEY (post_id),
+ ADD INDEX topic_id (topic_id),
+ ADD INDEX poster_ip (poster_ip),
+ ADD INDEX post_approved (post_approved),
+ MODIFY COLUMN post_id mediumint(8) UNSIGNED NOT NULL auto_increment,
+ ADD COLUMN post_encoding varchar(11) DEFAULT \'iso-8859-15\' NOT NULL';
+ break;
+
+ case 'mssql':
+ case 'mssql-odbc':
+ case 'msaccess':
+ break;
+
+ case 'postgresql':
+ break;
+}
+$db->sql_query($sql);
+
+$sql = "UPDATE {$table_prefix}topics SET topic_poster = 1 WHERE topic_poster = 0 OR topic_poster IS NULL";
+$db->sql_query($sql);
+$sql = "UPDATE {$table_prefix}topics SET topic_last_poster_id = 1 WHERE topic_last_poster_id = 0 OR topic_last_poster_id IS NULL";
+$db->sql_query($sql);
+$sql = "UPDATE {$table_prefix}posts SET poster_id = 1 WHERE poster_id = 0 OR poster_id IS NULL";
+$db->sql_query($sql);
+$sql = "UPDATE {$table_prefix}users SET user_id = 1 WHERE user_id = 0";
+$db->sql_query($sql);
+
+$sql = "SELECT t.topic_id
+ FROM {$table_prefix}topics t
+ LEFT JOIN {$table_prefix}posts p ON p.topic_id = t.topic_id
+ WHERE p.topic_id IS NULL";
+$result = $db->sql_query($sql);
+
+if ($row = $db->sql_fetchrow($result))
+{
+ $del_sql = '';
+ do
+ {
+ $del_sql .= (($del_sql != '') ? ', ' : '') . $row['topic_id'];
+ }
+ while ($row = $db->sql_fetchrow($result));
+
+ $sql = "DELETE FROM {$table_prefix}topics
+ WHERE topic_id IN ($del_sql)";
+ $db->sql_query($sql);
+}
+$db->sql_freeresult($result);
+
+$del_sql = '';
+$sql = "SELECT topic_id, MIN(post_id) AS first_post_id, MAX(post_id) AS last_post_id, COUNT(post_id) AS total_posts
+ FROM {$table_prefix}posts
+ GROUP BY topic_id";
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $del_sql .= (($del_sql != '') ? ', ' : '') . $row['topic_id'];
+
+ $sql = "UPDATE {$table_prefix}topics
+ SET topic_first_post_id = " . $row['first_post_id'] . ", topic_last_post_id = " . $row['last_post_id'] . ", topic_replies = " . ($row['total_posts'] - 1) . "
+ WHERE topic_id = " . $row['topic_id'];
+ $db->sql_query($sql);
+}
+$db->sql_freeresult($result);
+
+$sql = "DELETE FROM {$table_prefix}topics WHERE topic_id NOT IN ($del_sql)";
+$db->sql_query($sql);
+
+$topic_count = $post_count = array();
+$sql = "SELECT forum_id, COUNT(topic_id) AS topics
+ FROM {$table_prefix}topics
+ GROUP BY forum_id";
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $topic_count[$row['forum_id']] = $row['topics'];
+}
+$db->sql_freeresult($result);
+
+$sql = "SELECT forum_id, COUNT(post_id) AS posts
+ FROM {$table_prefix}posts
+ GROUP BY forum_id";
+$result = $db->sql_query($sql);
+
+while ($row = $db->sql_fetchrow($result))
+{
+ $post_count[$row['forum_id']] = $row['posts'];
+}
+$db->sql_freeresult($result);
+
+switch ($db->sql_layer)
+{
+ case 'oracle':
+ $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
+ FROM " . $table_prefix . "forums f, " . $table_prefix . "posts p, " . $table_prefix . "users u
+ WHERE p.post_id = f.forum_last_post_id(+)
+ AND u.user_id = p.poster_id(+)";
+ break;
+
+ default:
+ $sql = "SELECT f.forum_id, p.post_time, p.post_username, u.username, u.user_id
+ FROM ((" . $table_prefix . "forums f
+ LEFT JOIN " . $table_prefix . "posts p ON p.post_id = f.forum_last_post_id)
+ LEFT JOIN " . $table_prefix . "users u ON u.user_id = p.poster_id)";
+ break;
+}
+$result = $db->sql_query($sql);
+
+$sql_ary = array();
+while ($row = $db->sql_fetchrow($result))
+{
+ $forum_id = $row['forum_id'];
+
+ $sql_ary[] = "UPDATE " . $table_prefix . "forums
+ SET forum_last_poster_id = " . ((!empty($row['user_id']) && $row['user_id'] != ANONYMOUS) ? $row['user_id'] : ANONYMOUS) . ", forum_last_poster_name = '" . ((!empty($row['user_id']) && $row['user_id'] != ANONYMOUS) ? addslashes($row['username']) : addslashes($row['post_username'])) . "', forum_last_post_time = " . $row['post_time'] . ", forum_posts = " . (($post_count[$forum_id]) ? $post_count[$forum_id] : 0) . ", forum_topics = " . (($topic_count[$forum_id]) ? $topic_count[$forum_id] : 0) . "
+ WHERE forum_id = $forum_id";
+
+ $sql = "SELECT t.topic_id, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
+ FROM " . $table_prefix . "topics t, " . $table_prefix . "users u, " . $table_prefix . "posts p, " . $table_prefix . "posts p2, " . $table_prefix . "users u2
+ WHERE t.forum_id = $forum_id
+ AND u.user_id = t.topic_poster
+ AND p.post_id = t.topic_first_post_id
+ AND p2.post_id = t.topic_last_post_id
+ AND u2.user_id = p2.poster_id";
+ $result2 = $db->sql_query($sql);
+
+ while ($row2 = $db->sql_fetchrow($result2))
+ {
+ $sql_ary[] = "UPDATE " . $table_prefix . "topics
+ SET topic_poster = " . $row2['user_id'] . ", topic_first_poster_name = '" . ((!empty($row2['user_id']) && $row2['user_id'] != ANONYMOUS) ? addslashes($row2['username']) : addslashes($row2['post_username'])) . "', topic_last_poster_id = " . ((!empty($row2['id2']) && $row2['id2'] != ANONYMOUS) ? $row2['id2'] : ANONYMOUS) . ", topic_last_post_time = " . $row2['post_time'] . ", topic_last_poster_name = '" . ((!empty($row2['id2']) && $row2['id2'] != ANONYMOUS) ? addslashes($row2['user2']) : addslashes($row2['post_username2'])) . "'
+ WHERE topic_id = " . $row2['topic_id'];
+ }
+ $db->sql_freeresult($result2);
+
+ unset($row2);
+}
+$db->sql_freeresult($result);
+
+foreach ($sql_ary as $sql)
+{
+ $sql . "<br />";
+ $db->sql_query($sql);
+}
+
+echo "<p><b>Done</b></p>\n";
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/mysql_upgrader.php b/phpBB/develop/mysql_upgrader.php
new file mode 100644
index 0000000000..034c1c0c20
--- /dev/null
+++ b/phpBB/develop/mysql_upgrader.php
@@ -0,0 +1,1400 @@
+<?php
+/**
+*
+* @package phpBB3
+* @version $Id$
+* @copyright (c) 2006 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+* This file creates SQL statements to upgrade phpBB on MySQL 3.x/4.0.x to 4.1.x/5.x
+*
+*/
+
+
+//
+// Security message:
+//
+// This script is potentially dangerous.
+// Remove or comment the next line (die(".... ) to enable this script.
+// Do NOT FORGET to either remove this script or disable it after you have used it.
+//
+die("Please read the first lines of this script for instructions on how to enable it");
+
+define('IN_PHPBB', true);
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+include($phpbb_root_path . 'common.' . $phpEx);
+
+$prefix = $table_prefix;
+
+$newline = "\n";
+
+if (PHP_SAPI !== 'cli')
+{
+ $newline = '<br>';
+}
+
+$sql = 'DESCRIBE ' . POSTS_TABLE . ' post_text';
+$result = $db->sql_query($sql);
+
+$row = $db->sql_fetchrow($result);
+
+$db->sql_freeresult($result);
+
+$mysql_indexer = $drop_index = false;
+
+if (strtolower($row['Type']) === 'mediumtext')
+{
+ $mysql_indexer = true;
+}
+
+if (strtolower($row['Key']) === 'mul')
+{
+ $drop_index = true;
+}
+
+echo "USE $dbname;$newline$newline";
+
+
+@set_time_limit(0);
+
+$schema_data = get_schema_struct();
+$dbms_type_map = array(
+ 'mysql_41' => array(
+ 'INT:' => 'int(%d)',
+ 'BINT' => 'bigint(20)',
+ 'UINT' => 'mediumint(8) UNSIGNED',
+ 'UINT:' => 'int(%d) UNSIGNED',
+ 'TINT:' => 'tinyint(%d)',
+ 'USINT' => 'smallint(4) UNSIGNED',
+ 'BOOL' => 'tinyint(1) UNSIGNED',
+ 'VCHAR' => 'varchar(255)',
+ 'VCHAR:' => 'varchar(%d)',
+ 'CHAR:' => 'char(%d)',
+ 'XSTEXT' => 'text',
+ 'XSTEXT_UNI'=> 'varchar(100)',
+ 'STEXT' => 'text',
+ 'STEXT_UNI' => 'varchar(255)',
+ 'TEXT' => 'text',
+ 'TEXT_UNI' => 'text',
+ 'MTEXT' => 'mediumtext',
+ 'MTEXT_UNI' => 'mediumtext',
+ 'TIMESTAMP' => 'int(11) UNSIGNED',
+ 'DECIMAL' => 'decimal(5,2)',
+ 'DECIMAL:' => 'decimal(%d,2)',
+ 'PDECIMAL' => 'decimal(6,3)',
+ 'PDECIMAL:' => 'decimal(%d,3)',
+ 'VCHAR_UNI' => 'varchar(255)',
+ 'VCHAR_UNI:'=> 'varchar(%d)',
+ 'VCHAR_CI' => 'varchar(255)',
+ 'VARBINARY' => 'varbinary(255)',
+ ),
+
+ 'mysql_40' => array(
+ 'INT:' => 'int(%d)',
+ 'BINT' => 'bigint(20)',
+ 'UINT' => 'mediumint(8) UNSIGNED',
+ 'UINT:' => 'int(%d) UNSIGNED',
+ 'TINT:' => 'tinyint(%d)',
+ 'USINT' => 'smallint(4) UNSIGNED',
+ 'BOOL' => 'tinyint(1) UNSIGNED',
+ 'VCHAR' => 'varbinary(255)',
+ 'VCHAR:' => 'varbinary(%d)',
+ 'CHAR:' => 'binary(%d)',
+ 'XSTEXT' => 'blob',
+ 'XSTEXT_UNI'=> 'blob',
+ 'STEXT' => 'blob',
+ 'STEXT_UNI' => 'blob',
+ 'TEXT' => 'blob',
+ 'TEXT_UNI' => 'blob',
+ 'MTEXT' => 'mediumblob',
+ 'MTEXT_UNI' => 'mediumblob',
+ 'TIMESTAMP' => 'int(11) UNSIGNED',
+ 'DECIMAL' => 'decimal(5,2)',
+ 'DECIMAL:' => 'decimal(%d,2)',
+ 'PDECIMAL' => 'decimal(6,3)',
+ 'PDECIMAL:' => 'decimal(%d,3)',
+ 'VCHAR_UNI' => 'blob',
+ 'VCHAR_UNI:'=> array('varbinary(%d)', 'limit' => array('mult', 3, 255, 'blob')),
+ 'VCHAR_CI' => 'blob',
+ 'VARBINARY' => 'varbinary(255)',
+ ),
+);
+
+foreach ($schema_data as $table_name => $table_data)
+{
+ $table_name = str_replace('phpbb_', $prefix, $table_name);
+ // Write comment about table
+ echo "# Table: '{$table_name}'$newline";
+
+ // Create Table statement
+ $generator = $textimage = false;
+
+ // Do we need to DROP a fulltext index before we alter the table?
+ if ($table_name == ($prefix . 'posts') && $drop_index)
+ {
+ echo "ALTER TABLE {$table_name}{$newline}";
+ echo "DROP INDEX post_text,{$newline}DROP INDEX post_subject,{$newline}DROP INDEX post_content;{$newline}{$newline}";
+ }
+
+ $line = "ALTER TABLE {$table_name} $newline";
+
+ // Table specific so we don't get overlap
+ $modded_array = array();
+
+ // Write columns one by one...
+ foreach ($table_data['COLUMNS'] as $column_name => $column_data)
+ {
+ // Get type
+ if (strpos($column_data[0], ':') !== false)
+ {
+ list($orig_column_type, $column_length) = explode(':', $column_data[0]);
+ $column_type = sprintf($dbms_type_map['mysql_41'][$orig_column_type . ':'], $column_length);
+
+ if (isset($dbms_type_map['mysql_40'][$orig_column_type . ':']['limit'][0]))
+ {
+ switch ($dbms_type_map['mysql_40'][$orig_column_type . ':']['limit'][0])
+ {
+ case 'mult':
+ if (($column_length * $dbms_type_map['mysql_40'][$orig_column_type . ':']['limit'][1]) > $dbms_type_map['mysql_40'][$orig_column_type . ':']['limit'][2])
+ {
+ $modded_array[$column_name] = $column_type;
+ }
+ break;
+ }
+ }
+
+ $orig_column_type .= ':';
+ }
+ else
+ {
+ $orig_column_type = $column_data[0];
+ $other_column_type = $dbms_type_map['mysql_40'][$column_data[0]];
+ if ($other_column_type == 'text' || $other_column_type == 'blob')
+ {
+ $modded_array[$column_name] = $column_type;
+ }
+ $column_type = $dbms_type_map['mysql_41'][$column_data[0]];
+ }
+
+ // Adjust default value if db-dependant specified
+ if (is_array($column_data[1]))
+ {
+ $column_data[1] = (isset($column_data[1][$dbms])) ? $column_data[1][$dbms] : $column_data[1]['default'];
+ }
+
+ $line .= "\tMODIFY {$column_name} {$column_type} ";
+
+ // For hexadecimal values do not use single quotes
+ if (!is_null($column_data[1]) && substr($column_type, -4) !== 'text' && substr($column_type, -4) !== 'blob')
+ {
+ $line .= (strpos($column_data[1], '0x') === 0) ? "DEFAULT {$column_data[1]} " : "DEFAULT '{$column_data[1]}' ";
+ }
+ $line .= 'NOT NULL';
+
+ if (isset($column_data[2]))
+ {
+ if ($column_data[2] == 'auto_increment')
+ {
+ $line .= ' auto_increment';
+ }
+ else if ($column_data[2] == 'true_sort')
+ {
+ $line .= ' COLLATE utf8_unicode_ci';
+ }
+ else if ($column_data[2] == 'no_sort')
+ {
+ $line .= ' COLLATE utf8_bin';
+ }
+ }
+ else if (preg_match('/(?:var)?char|(?:medium)?text/i', $column_type))
+ {
+ $line .= ' COLLATE utf8_bin';
+ }
+
+ $line .= ",$newline";
+ }
+
+ // Write Keys
+ if (isset($table_data['KEYS']))
+ {
+ foreach ($table_data['KEYS'] as $key_name => $key_data)
+ {
+ $temp = '';
+ if (!is_array($key_data[1]))
+ {
+ $key_data[1] = array($key_data[1]);
+ }
+
+ $temp .= ($key_data[0] == 'INDEX') ? "\tADD KEY" : '';
+ $temp .= ($key_data[0] == 'UNIQUE') ? "\tADD UNIQUE" : '';
+ $repair = false;
+ foreach ($key_data[1] as $key => $col_name)
+ {
+ if (isset($modded_array[$col_name]))
+ {
+ $repair = true;
+ }
+ }
+ if ($repair)
+ {
+ $line .= "\tDROP INDEX " . $key_name . ",$newline";
+ $line .= $temp;
+ $line .= ' ' . $key_name . ' (' . implode(', ', $key_data[1]) . "),$newline";
+ }
+ }
+ }
+
+ //$line .= "\tCONVERT TO CHARACTER SET `utf8`$newline";
+ $line .= "\tDEFAULT CHARSET=utf8 COLLATE=utf8_bin;$newline$newline";
+
+ echo $line . "$newline";
+
+ // Do we now need to re-add the fulltext index? ;)
+ if ($table_name == ($prefix . 'posts') && $drop_index)
+ {
+ echo "ALTER TABLE $table_name ADD FULLTEXT (post_subject), ADD FULLTEXT (post_text), ADD FULLTEXT post_content (post_subject, post_text){$newline}";
+ }
+}
+
+/**
+* Define the basic structure
+* The format:
+* array('{TABLE_NAME}' => {TABLE_DATA})
+* {TABLE_DATA}:
+* COLUMNS = array({column_name} = array({column_type}, {default}, {auto_increment}))
+* PRIMARY_KEY = {column_name(s)}
+* KEYS = array({key_name} = array({key_type}, {column_name(s)})),
+*
+* Column Types:
+* INT:x => SIGNED int(x)
+* BINT => BIGINT
+* UINT => mediumint(8) UNSIGNED
+* UINT:x => int(x) UNSIGNED
+* TINT:x => tinyint(x)
+* USINT => smallint(4) UNSIGNED (for _order columns)
+* BOOL => tinyint(1) UNSIGNED
+* VCHAR => varchar(255)
+* CHAR:x => char(x)
+* XSTEXT_UNI => text for storing 100 characters (topic_title for example)
+* STEXT_UNI => text for storing 255 characters (normal input field with a max of 255 single-byte chars) - same as VCHAR_UNI
+* TEXT_UNI => text for storing 3000 characters (short text, descriptions, comments, etc.)
+* MTEXT_UNI => mediumtext (post text, large text)
+* VCHAR:x => varchar(x)
+* TIMESTAMP => int(11) UNSIGNED
+* DECIMAL => decimal number (5,2)
+* DECIMAL: => decimal number (x,2)
+* PDECIMAL => precision decimal number (6,3)
+* PDECIMAL: => precision decimal number (x,3)
+* VCHAR_UNI => varchar(255) BINARY
+* VCHAR_CI => varchar_ci for postgresql, others VCHAR
+*/
+function get_schema_struct()
+{
+ $schema_data = array();
+
+ $schema_data['phpbb_attachments'] = array(
+ 'COLUMNS' => array(
+ 'attach_id' => array('UINT', NULL, 'auto_increment'),
+ 'post_msg_id' => array('UINT', 0),
+ 'topic_id' => array('UINT', 0),
+ 'in_message' => array('BOOL', 0),
+ 'poster_id' => array('UINT', 0),
+ 'is_orphan' => array('BOOL', 1),
+ 'physical_filename' => array('VCHAR', ''),
+ 'real_filename' => array('VCHAR', ''),
+ 'download_count' => array('UINT', 0),
+ 'attach_comment' => array('TEXT_UNI', ''),
+ 'extension' => array('VCHAR:100', ''),
+ 'mimetype' => array('VCHAR:100', ''),
+ 'filesize' => array('UINT:20', 0),
+ 'filetime' => array('TIMESTAMP', 0),
+ 'thumbnail' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => 'attach_id',
+ 'KEYS' => array(
+ 'filetime' => array('INDEX', 'filetime'),
+ 'post_msg_id' => array('INDEX', 'post_msg_id'),
+ 'topic_id' => array('INDEX', 'topic_id'),
+ 'poster_id' => array('INDEX', 'poster_id'),
+ 'is_orphan' => array('INDEX', 'is_orphan'),
+ ),
+ );
+
+ $schema_data['phpbb_acl_groups'] = array(
+ 'COLUMNS' => array(
+ 'group_id' => array('UINT', 0),
+ 'forum_id' => array('UINT', 0),
+ 'auth_option_id' => array('UINT', 0),
+ 'auth_role_id' => array('UINT', 0),
+ 'auth_setting' => array('TINT:2', 0),
+ ),
+ 'KEYS' => array(
+ 'group_id' => array('INDEX', 'group_id'),
+ 'auth_opt_id' => array('INDEX', 'auth_option_id'),
+ 'auth_role_id' => array('INDEX', 'auth_role_id'),
+ ),
+ );
+
+ $schema_data['phpbb_acl_options'] = array(
+ 'COLUMNS' => array(
+ 'auth_option_id' => array('UINT', NULL, 'auto_increment'),
+ 'auth_option' => array('VCHAR:50', ''),
+ 'is_global' => array('BOOL', 0),
+ 'is_local' => array('BOOL', 0),
+ 'founder_only' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => 'auth_option_id',
+ 'KEYS' => array(
+ 'auth_option' => array('UNIQUE', 'auth_option'),
+ ),
+ );
+
+ $schema_data['phpbb_acl_roles'] = array(
+ 'COLUMNS' => array(
+ 'role_id' => array('UINT', NULL, 'auto_increment'),
+ 'role_name' => array('VCHAR_UNI', ''),
+ 'role_description' => array('TEXT_UNI', ''),
+ 'role_type' => array('VCHAR:10', ''),
+ 'role_order' => array('USINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'role_id',
+ 'KEYS' => array(
+ 'role_type' => array('INDEX', 'role_type'),
+ 'role_order' => array('INDEX', 'role_order'),
+ ),
+ );
+
+ $schema_data['phpbb_acl_roles_data'] = array(
+ 'COLUMNS' => array(
+ 'role_id' => array('UINT', 0),
+ 'auth_option_id' => array('UINT', 0),
+ 'auth_setting' => array('TINT:2', 0),
+ ),
+ 'PRIMARY_KEY' => array('role_id', 'auth_option_id'),
+ 'KEYS' => array(
+ 'ath_op_id' => array('INDEX', 'auth_option_id'),
+ ),
+ );
+
+ $schema_data['phpbb_acl_users'] = array(
+ 'COLUMNS' => array(
+ 'user_id' => array('UINT', 0),
+ 'forum_id' => array('UINT', 0),
+ 'auth_option_id' => array('UINT', 0),
+ 'auth_role_id' => array('UINT', 0),
+ 'auth_setting' => array('TINT:2', 0),
+ ),
+ 'KEYS' => array(
+ 'user_id' => array('INDEX', 'user_id'),
+ 'auth_option_id' => array('INDEX', 'auth_option_id'),
+ 'auth_role_id' => array('INDEX', 'auth_role_id'),
+ ),
+ );
+
+ $schema_data['phpbb_banlist'] = array(
+ 'COLUMNS' => array(
+ 'ban_id' => array('UINT', NULL, 'auto_increment'),
+ 'ban_userid' => array('UINT', 0),
+ 'ban_ip' => array('VCHAR:40', ''),
+ 'ban_email' => array('VCHAR_UNI:100', ''),
+ 'ban_start' => array('TIMESTAMP', 0),
+ 'ban_end' => array('TIMESTAMP', 0),
+ 'ban_exclude' => array('BOOL', 0),
+ 'ban_reason' => array('VCHAR_UNI', ''),
+ 'ban_give_reason' => array('VCHAR_UNI', ''),
+ ),
+ 'PRIMARY_KEY' => 'ban_id',
+ 'KEYS' => array(
+ 'ban_end' => array('INDEX', 'ban_end'),
+ 'ban_user' => array('INDEX', array('ban_userid', 'ban_exclude')),
+ 'ban_email' => array('INDEX', array('ban_email', 'ban_exclude')),
+ 'ban_ip' => array('INDEX', array('ban_ip', 'ban_exclude')),
+ ),
+ );
+
+ $schema_data['phpbb_bbcodes'] = array(
+ 'COLUMNS' => array(
+ 'bbcode_id' => array('TINT:3', 0),
+ 'bbcode_tag' => array('VCHAR:16', ''),
+ 'bbcode_helpline' => array('VCHAR_UNI', ''),
+ 'display_on_posting' => array('BOOL', 0),
+ 'bbcode_match' => array('TEXT_UNI', ''),
+ 'bbcode_tpl' => array('MTEXT_UNI', ''),
+ 'first_pass_match' => array('MTEXT_UNI', ''),
+ 'first_pass_replace' => array('MTEXT_UNI', ''),
+ 'second_pass_match' => array('MTEXT_UNI', ''),
+ 'second_pass_replace' => array('MTEXT_UNI', ''),
+ ),
+ 'PRIMARY_KEY' => 'bbcode_id',
+ 'KEYS' => array(
+ 'display_on_post' => array('INDEX', 'display_on_posting'),
+ ),
+ );
+
+ $schema_data['phpbb_bookmarks'] = array(
+ 'COLUMNS' => array(
+ 'topic_id' => array('UINT', 0),
+ 'user_id' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => array('topic_id', 'user_id'),
+ );
+
+ $schema_data['phpbb_bots'] = array(
+ 'COLUMNS' => array(
+ 'bot_id' => array('UINT', NULL, 'auto_increment'),
+ 'bot_active' => array('BOOL', 1),
+ 'bot_name' => array('STEXT_UNI', ''),
+ 'user_id' => array('UINT', 0),
+ 'bot_agent' => array('VCHAR', ''),
+ 'bot_ip' => array('VCHAR', ''),
+ ),
+ 'PRIMARY_KEY' => 'bot_id',
+ 'KEYS' => array(
+ 'bot_active' => array('INDEX', 'bot_active'),
+ ),
+ );
+
+ $schema_data['phpbb_config'] = array(
+ 'COLUMNS' => array(
+ 'config_name' => array('VCHAR', ''),
+ 'config_value' => array('VCHAR_UNI', ''),
+ 'is_dynamic' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => 'config_name',
+ 'KEYS' => array(
+ 'is_dynamic' => array('INDEX', 'is_dynamic'),
+ ),
+ );
+
+ $schema_data['phpbb_confirm'] = array(
+ 'COLUMNS' => array(
+ 'confirm_id' => array('CHAR:32', ''),
+ 'session_id' => array('CHAR:32', ''),
+ 'confirm_type' => array('TINT:3', 0),
+ 'code' => array('VCHAR:8', ''),
+ 'seed' => array('UINT:10', 0),
+ 'attempts' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => array('session_id', 'confirm_id'),
+ 'KEYS' => array(
+ 'confirm_type' => array('INDEX', 'confirm_type'),
+ ),
+ );
+
+ $schema_data['phpbb_disallow'] = array(
+ 'COLUMNS' => array(
+ 'disallow_id' => array('UINT', NULL, 'auto_increment'),
+ 'disallow_username' => array('VCHAR_UNI:255', ''),
+ ),
+ 'PRIMARY_KEY' => 'disallow_id',
+ );
+
+ $schema_data['phpbb_drafts'] = array(
+ 'COLUMNS' => array(
+ 'draft_id' => array('UINT', NULL, 'auto_increment'),
+ 'user_id' => array('UINT', 0),
+ 'topic_id' => array('UINT', 0),
+ 'forum_id' => array('UINT', 0),
+ 'save_time' => array('TIMESTAMP', 0),
+ 'draft_subject' => array('STEXT_UNI', ''),
+ 'draft_message' => array('MTEXT_UNI', ''),
+ ),
+ 'PRIMARY_KEY' => 'draft_id',
+ 'KEYS' => array(
+ 'save_time' => array('INDEX', 'save_time'),
+ ),
+ );
+
+ $schema_data['phpbb_extensions'] = array(
+ 'COLUMNS' => array(
+ 'extension_id' => array('UINT', NULL, 'auto_increment'),
+ 'group_id' => array('UINT', 0),
+ 'extension' => array('VCHAR:100', ''),
+ ),
+ 'PRIMARY_KEY' => 'extension_id',
+ );
+
+ $schema_data['phpbb_extension_groups'] = array(
+ 'COLUMNS' => array(
+ 'group_id' => array('UINT', NULL, 'auto_increment'),
+ 'group_name' => array('VCHAR_UNI', ''),
+ 'cat_id' => array('TINT:2', 0),
+ 'allow_group' => array('BOOL', 0),
+ 'download_mode' => array('BOOL', 1),
+ 'upload_icon' => array('VCHAR', ''),
+ 'max_filesize' => array('UINT:20', 0),
+ 'allowed_forums' => array('TEXT', ''),
+ 'allow_in_pm' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => 'group_id',
+ );
+
+ $schema_data['phpbb_forums'] = array(
+ 'COLUMNS' => array(
+ 'forum_id' => array('UINT', NULL, 'auto_increment'),
+ 'parent_id' => array('UINT', 0),
+ 'left_id' => array('UINT', 0),
+ 'right_id' => array('UINT', 0),
+ 'forum_parents' => array('MTEXT', ''),
+ 'forum_name' => array('STEXT_UNI', ''),
+ 'forum_desc' => array('TEXT_UNI', ''),
+ 'forum_desc_bitfield' => array('VCHAR:255', ''),
+ 'forum_desc_options' => array('UINT:11', 7),
+ 'forum_desc_uid' => array('VCHAR:8', ''),
+ 'forum_link' => array('VCHAR_UNI', ''),
+ 'forum_password' => array('VCHAR_UNI:40', ''),
+ 'forum_style' => array('UINT', 0),
+ 'forum_image' => array('VCHAR', ''),
+ 'forum_rules' => array('TEXT_UNI', ''),
+ 'forum_rules_link' => array('VCHAR_UNI', ''),
+ 'forum_rules_bitfield' => array('VCHAR:255', ''),
+ 'forum_rules_options' => array('UINT:11', 7),
+ 'forum_rules_uid' => array('VCHAR:8', ''),
+ 'forum_topics_per_page' => array('TINT:4', 0),
+ 'forum_type' => array('TINT:4', 0),
+ 'forum_status' => array('TINT:4', 0),
+ 'forum_posts' => array('UINT', 0),
+ 'forum_topics' => array('UINT', 0),
+ 'forum_topics_real' => array('UINT', 0),
+ 'forum_last_post_id' => array('UINT', 0),
+ 'forum_last_poster_id' => array('UINT', 0),
+ 'forum_last_post_subject' => array('STEXT_UNI', ''),
+ 'forum_last_post_time' => array('TIMESTAMP', 0),
+ 'forum_last_poster_name'=> array('VCHAR_UNI', ''),
+ 'forum_last_poster_colour'=> array('VCHAR:6', ''),
+ 'forum_flags' => array('TINT:4', 32),
+ 'forum_options' => array('UINT:20', 0),
+ 'display_subforum_list' => array('BOOL', 1),
+ 'display_on_index' => array('BOOL', 1),
+ 'enable_indexing' => array('BOOL', 1),
+ 'enable_icons' => array('BOOL', 1),
+ 'enable_prune' => array('BOOL', 0),
+ 'prune_next' => array('TIMESTAMP', 0),
+ 'prune_days' => array('UINT', 0),
+ 'prune_viewed' => array('UINT', 0),
+ 'prune_freq' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'forum_id',
+ 'KEYS' => array(
+ 'left_right_id' => array('INDEX', array('left_id', 'right_id')),
+ 'forum_lastpost_id' => array('INDEX', 'forum_last_post_id'),
+ ),
+ );
+
+ $schema_data['phpbb_forums_access'] = array(
+ 'COLUMNS' => array(
+ 'forum_id' => array('UINT', 0),
+ 'user_id' => array('UINT', 0),
+ 'session_id' => array('CHAR:32', ''),
+ ),
+ 'PRIMARY_KEY' => array('forum_id', 'user_id', 'session_id'),
+ );
+
+ $schema_data['phpbb_forums_track'] = array(
+ 'COLUMNS' => array(
+ 'user_id' => array('UINT', 0),
+ 'forum_id' => array('UINT', 0),
+ 'mark_time' => array('TIMESTAMP', 0),
+ ),
+ 'PRIMARY_KEY' => array('user_id', 'forum_id'),
+ );
+
+ $schema_data['phpbb_forums_watch'] = array(
+ 'COLUMNS' => array(
+ 'forum_id' => array('UINT', 0),
+ 'user_id' => array('UINT', 0),
+ 'notify_status' => array('BOOL', 0),
+ ),
+ 'KEYS' => array(
+ 'forum_id' => array('INDEX', 'forum_id'),
+ 'user_id' => array('INDEX', 'user_id'),
+ 'notify_stat' => array('INDEX', 'notify_status'),
+ ),
+ );
+
+ $schema_data['phpbb_groups'] = array(
+ 'COLUMNS' => array(
+ 'group_id' => array('UINT', NULL, 'auto_increment'),
+ 'group_type' => array('TINT:4', 1),
+ 'group_founder_manage' => array('BOOL', 0),
+ 'group_skip_auth' => array('BOOL', 0),
+ 'group_name' => array('VCHAR_CI', ''),
+ 'group_desc' => array('TEXT_UNI', ''),
+ 'group_desc_bitfield' => array('VCHAR:255', ''),
+ 'group_desc_options' => array('UINT:11', 7),
+ 'group_desc_uid' => array('VCHAR:8', ''),
+ 'group_display' => array('BOOL', 0),
+ 'group_avatar' => array('VCHAR', ''),
+ 'group_avatar_type' => array('TINT:2', 0),
+ 'group_avatar_width' => array('USINT', 0),
+ 'group_avatar_height' => array('USINT', 0),
+ 'group_rank' => array('UINT', 0),
+ 'group_colour' => array('VCHAR:6', ''),
+ 'group_sig_chars' => array('UINT', 0),
+ 'group_receive_pm' => array('BOOL', 0),
+ 'group_message_limit' => array('UINT', 0),
+ 'group_max_recipients' => array('UINT', 0),
+ 'group_legend' => array('BOOL', 1),
+ ),
+ 'PRIMARY_KEY' => 'group_id',
+ 'KEYS' => array(
+ 'group_legend_name' => array('INDEX', array('group_legend', 'group_name')),
+ ),
+ );
+
+ $schema_data['phpbb_icons'] = array(
+ 'COLUMNS' => array(
+ 'icons_id' => array('UINT', NULL, 'auto_increment'),
+ 'icons_url' => array('VCHAR', ''),
+ 'icons_width' => array('TINT:4', 0),
+ 'icons_height' => array('TINT:4', 0),
+ 'icons_order' => array('UINT', 0),
+ 'display_on_posting' => array('BOOL', 1),
+ ),
+ 'PRIMARY_KEY' => 'icons_id',
+ 'KEYS' => array(
+ 'display_on_posting' => array('INDEX', 'display_on_posting'),
+ ),
+ );
+
+ $schema_data['phpbb_lang'] = array(
+ 'COLUMNS' => array(
+ 'lang_id' => array('TINT:4', NULL, 'auto_increment'),
+ 'lang_iso' => array('VCHAR:30', ''),
+ 'lang_dir' => array('VCHAR:30', ''),
+ 'lang_english_name' => array('VCHAR_UNI:100', ''),
+ 'lang_local_name' => array('VCHAR_UNI:255', ''),
+ 'lang_author' => array('VCHAR_UNI:255', ''),
+ ),
+ 'PRIMARY_KEY' => 'lang_id',
+ 'KEYS' => array(
+ 'lang_iso' => array('INDEX', 'lang_iso'),
+ ),
+ );
+
+ $schema_data['phpbb_log'] = array(
+ 'COLUMNS' => array(
+ 'log_id' => array('UINT', NULL, 'auto_increment'),
+ 'log_type' => array('TINT:4', 0),
+ 'user_id' => array('UINT', 0),
+ 'forum_id' => array('UINT', 0),
+ 'topic_id' => array('UINT', 0),
+ 'reportee_id' => array('UINT', 0),
+ 'log_ip' => array('VCHAR:40', ''),
+ 'log_time' => array('TIMESTAMP', 0),
+ 'log_operation' => array('TEXT_UNI', ''),
+ 'log_data' => array('MTEXT_UNI', ''),
+ ),
+ 'PRIMARY_KEY' => 'log_id',
+ 'KEYS' => array(
+ 'log_type' => array('INDEX', 'log_type'),
+ 'log_time' => array('INDEX', 'log_time'),
+ 'forum_id' => array('INDEX', 'forum_id'),
+ 'topic_id' => array('INDEX', 'topic_id'),
+ 'reportee_id' => array('INDEX', 'reportee_id'),
+ 'user_id' => array('INDEX', 'user_id'),
+ ),
+ );
+
+ $schema_data['phpbb_moderator_cache'] = array(
+ 'COLUMNS' => array(
+ 'forum_id' => array('UINT', 0),
+ 'user_id' => array('UINT', 0),
+ 'username' => array('VCHAR_UNI:255', ''),
+ 'group_id' => array('UINT', 0),
+ 'group_name' => array('VCHAR_UNI', ''),
+ 'display_on_index' => array('BOOL', 1),
+ ),
+ 'KEYS' => array(
+ 'disp_idx' => array('INDEX', 'display_on_index'),
+ 'forum_id' => array('INDEX', 'forum_id'),
+ ),
+ );
+
+ $schema_data['phpbb_modules'] = array(
+ 'COLUMNS' => array(
+ 'module_id' => array('UINT', NULL, 'auto_increment'),
+ 'module_enabled' => array('BOOL', 1),
+ 'module_display' => array('BOOL', 1),
+ 'module_basename' => array('VCHAR', ''),
+ 'module_class' => array('VCHAR:10', ''),
+ 'parent_id' => array('UINT', 0),
+ 'left_id' => array('UINT', 0),
+ 'right_id' => array('UINT', 0),
+ 'module_langname' => array('VCHAR', ''),
+ 'module_mode' => array('VCHAR', ''),
+ 'module_auth' => array('VCHAR', ''),
+ ),
+ 'PRIMARY_KEY' => 'module_id',
+ 'KEYS' => array(
+ 'left_right_id' => array('INDEX', array('left_id', 'right_id')),
+ 'module_enabled' => array('INDEX', 'module_enabled'),
+ 'class_left_id' => array('INDEX', array('module_class', 'left_id')),
+ ),
+ );
+
+ $schema_data['phpbb_poll_options'] = array(
+ 'COLUMNS' => array(
+ 'poll_option_id' => array('TINT:4', 0),
+ 'topic_id' => array('UINT', 0),
+ 'poll_option_text' => array('TEXT_UNI', ''),
+ 'poll_option_total' => array('UINT', 0),
+ ),
+ 'KEYS' => array(
+ 'poll_opt_id' => array('INDEX', 'poll_option_id'),
+ 'topic_id' => array('INDEX', 'topic_id'),
+ ),
+ );
+
+ $schema_data['phpbb_poll_votes'] = array(
+ 'COLUMNS' => array(
+ 'topic_id' => array('UINT', 0),
+ 'poll_option_id' => array('TINT:4', 0),
+ 'vote_user_id' => array('UINT', 0),
+ 'vote_user_ip' => array('VCHAR:40', ''),
+ ),
+ 'KEYS' => array(
+ 'topic_id' => array('INDEX', 'topic_id'),
+ 'vote_user_id' => array('INDEX', 'vote_user_id'),
+ 'vote_user_ip' => array('INDEX', 'vote_user_ip'),
+ ),
+ );
+
+ $schema_data['phpbb_posts'] = array(
+ 'COLUMNS' => array(
+ 'post_id' => array('UINT', NULL, 'auto_increment'),
+ 'topic_id' => array('UINT', 0),
+ 'forum_id' => array('UINT', 0),
+ 'poster_id' => array('UINT', 0),
+ 'icon_id' => array('UINT', 0),
+ 'poster_ip' => array('VCHAR:40', ''),
+ 'post_time' => array('TIMESTAMP', 0),
+ 'post_approved' => array('BOOL', 1),
+ 'post_reported' => array('BOOL', 0),
+ 'enable_bbcode' => array('BOOL', 1),
+ 'enable_smilies' => array('BOOL', 1),
+ 'enable_magic_url' => array('BOOL', 1),
+ 'enable_sig' => array('BOOL', 1),
+ 'post_username' => array('VCHAR_UNI:255', ''),
+ 'post_subject' => array('STEXT_UNI', '', 'true_sort'),
+ 'post_text' => array('MTEXT_UNI', ''),
+ 'post_checksum' => array('VCHAR:32', ''),
+ 'post_attachment' => array('BOOL', 0),
+ 'bbcode_bitfield' => array('VCHAR:255', ''),
+ 'bbcode_uid' => array('VCHAR:8', ''),
+ 'post_postcount' => array('BOOL', 1),
+ 'post_edit_time' => array('TIMESTAMP', 0),
+ 'post_edit_reason' => array('STEXT_UNI', ''),
+ 'post_edit_user' => array('UINT', 0),
+ 'post_edit_count' => array('USINT', 0),
+ 'post_edit_locked' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => 'post_id',
+ 'KEYS' => array(
+ 'forum_id' => array('INDEX', 'forum_id'),
+ 'topic_id' => array('INDEX', 'topic_id'),
+ 'poster_ip' => array('INDEX', 'poster_ip'),
+ 'poster_id' => array('INDEX', 'poster_id'),
+ 'post_approved' => array('INDEX', 'post_approved'),
+ 'tid_post_time' => array('INDEX', array('topic_id', 'post_time')),
+ ),
+ );
+
+ $schema_data['phpbb_privmsgs'] = array(
+ 'COLUMNS' => array(
+ 'msg_id' => array('UINT', NULL, 'auto_increment'),
+ 'root_level' => array('UINT', 0),
+ 'author_id' => array('UINT', 0),
+ 'icon_id' => array('UINT', 0),
+ 'author_ip' => array('VCHAR:40', ''),
+ 'message_time' => array('TIMESTAMP', 0),
+ 'enable_bbcode' => array('BOOL', 1),
+ 'enable_smilies' => array('BOOL', 1),
+ 'enable_magic_url' => array('BOOL', 1),
+ 'enable_sig' => array('BOOL', 1),
+ 'message_subject' => array('STEXT_UNI', ''),
+ 'message_text' => array('MTEXT_UNI', ''),
+ 'message_edit_reason' => array('STEXT_UNI', ''),
+ 'message_edit_user' => array('UINT', 0),
+ 'message_attachment' => array('BOOL', 0),
+ 'bbcode_bitfield' => array('VCHAR:255', ''),
+ 'bbcode_uid' => array('VCHAR:8', ''),
+ 'message_edit_time' => array('TIMESTAMP', 0),
+ 'message_edit_count' => array('USINT', 0),
+ 'to_address' => array('TEXT_UNI', ''),
+ 'bcc_address' => array('TEXT_UNI', ''),
+ 'message_reported' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => 'msg_id',
+ 'KEYS' => array(
+ 'author_ip' => array('INDEX', 'author_ip'),
+ 'message_time' => array('INDEX', 'message_time'),
+ 'author_id' => array('INDEX', 'author_id'),
+ 'root_level' => array('INDEX', 'root_level'),
+ ),
+ );
+
+ $schema_data['phpbb_privmsgs_folder'] = array(
+ 'COLUMNS' => array(
+ 'folder_id' => array('UINT', NULL, 'auto_increment'),
+ 'user_id' => array('UINT', 0),
+ 'folder_name' => array('VCHAR_UNI', ''),
+ 'pm_count' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'folder_id',
+ 'KEYS' => array(
+ 'user_id' => array('INDEX', 'user_id'),
+ ),
+ );
+
+ $schema_data['phpbb_privmsgs_rules'] = array(
+ 'COLUMNS' => array(
+ 'rule_id' => array('UINT', NULL, 'auto_increment'),
+ 'user_id' => array('UINT', 0),
+ 'rule_check' => array('UINT', 0),
+ 'rule_connection' => array('UINT', 0),
+ 'rule_string' => array('VCHAR_UNI', ''),
+ 'rule_user_id' => array('UINT', 0),
+ 'rule_group_id' => array('UINT', 0),
+ 'rule_action' => array('UINT', 0),
+ 'rule_folder_id' => array('INT:11', 0),
+ ),
+ 'PRIMARY_KEY' => 'rule_id',
+ 'KEYS' => array(
+ 'user_id' => array('INDEX', 'user_id'),
+ ),
+ );
+
+ $schema_data['phpbb_privmsgs_to'] = array(
+ 'COLUMNS' => array(
+ 'msg_id' => array('UINT', 0),
+ 'user_id' => array('UINT', 0),
+ 'author_id' => array('UINT', 0),
+ 'pm_deleted' => array('BOOL', 0),
+ 'pm_new' => array('BOOL', 1),
+ 'pm_unread' => array('BOOL', 1),
+ 'pm_replied' => array('BOOL', 0),
+ 'pm_marked' => array('BOOL', 0),
+ 'pm_forwarded' => array('BOOL', 0),
+ 'folder_id' => array('INT:11', 0),
+ ),
+ 'KEYS' => array(
+ 'msg_id' => array('INDEX', 'msg_id'),
+ 'author_id' => array('INDEX', 'author_id'),
+ 'usr_flder_id' => array('INDEX', array('user_id', 'folder_id')),
+ ),
+ );
+
+ $schema_data['phpbb_profile_fields'] = array(
+ 'COLUMNS' => array(
+ 'field_id' => array('UINT', NULL, 'auto_increment'),
+ 'field_name' => array('VCHAR_UNI', ''),
+ 'field_type' => array('TINT:4', 0),
+ 'field_ident' => array('VCHAR:20', ''),
+ 'field_length' => array('VCHAR:20', ''),
+ 'field_minlen' => array('VCHAR', ''),
+ 'field_maxlen' => array('VCHAR', ''),
+ 'field_novalue' => array('VCHAR_UNI', ''),
+ 'field_default_value' => array('VCHAR_UNI', ''),
+ 'field_validation' => array('VCHAR_UNI:20', ''),
+ 'field_required' => array('BOOL', 0),
+ 'field_show_on_reg' => array('BOOL', 0),
+ 'field_show_on_vt' => array('BOOL', 0),
+ 'field_show_profile' => array('BOOL', 0),
+ 'field_hide' => array('BOOL', 0),
+ 'field_no_view' => array('BOOL', 0),
+ 'field_active' => array('BOOL', 0),
+ 'field_order' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'field_id',
+ 'KEYS' => array(
+ 'fld_type' => array('INDEX', 'field_type'),
+ 'fld_ordr' => array('INDEX', 'field_order'),
+ ),
+ );
+
+ $schema_data['phpbb_profile_fields_data'] = array(
+ 'COLUMNS' => array(
+ 'user_id' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'user_id',
+ );
+
+ $schema_data['phpbb_profile_fields_lang'] = array(
+ 'COLUMNS' => array(
+ 'field_id' => array('UINT', 0),
+ 'lang_id' => array('UINT', 0),
+ 'option_id' => array('UINT', 0),
+ 'field_type' => array('TINT:4', 0),
+ 'lang_value' => array('VCHAR_UNI', ''),
+ ),
+ 'PRIMARY_KEY' => array('field_id', 'lang_id', 'option_id'),
+ );
+
+ $schema_data['phpbb_profile_lang'] = array(
+ 'COLUMNS' => array(
+ 'field_id' => array('UINT', 0),
+ 'lang_id' => array('UINT', 0),
+ 'lang_name' => array('VCHAR_UNI', ''),
+ 'lang_explain' => array('TEXT_UNI', ''),
+ 'lang_default_value' => array('VCHAR_UNI', ''),
+ ),
+ 'PRIMARY_KEY' => array('field_id', 'lang_id'),
+ );
+
+ $schema_data['phpbb_ranks'] = array(
+ 'COLUMNS' => array(
+ 'rank_id' => array('UINT', NULL, 'auto_increment'),
+ 'rank_title' => array('VCHAR_UNI', ''),
+ 'rank_min' => array('UINT', 0),
+ 'rank_special' => array('BOOL', 0),
+ 'rank_image' => array('VCHAR', ''),
+ ),
+ 'PRIMARY_KEY' => 'rank_id',
+ );
+
+ $schema_data['phpbb_reports'] = array(
+ 'COLUMNS' => array(
+ 'report_id' => array('UINT', NULL, 'auto_increment'),
+ 'reason_id' => array('USINT', 0),
+ 'post_id' => array('UINT', 0),
+ 'pm_id' => array('UINT', 0),
+ 'user_id' => array('UINT', 0),
+ 'user_notify' => array('BOOL', 0),
+ 'report_closed' => array('BOOL', 0),
+ 'report_time' => array('TIMESTAMP', 0),
+ 'report_text' => array('MTEXT_UNI', ''),
+ ),
+ 'PRIMARY_KEY' => 'report_id',
+ 'KEYS' => array(
+ 'post_id' => array('INDEX', 'post_id'),
+ 'pm_id' => array('INDEX', 'pm_id'),
+ ),
+ );
+
+ $schema_data['phpbb_reports_reasons'] = array(
+ 'COLUMNS' => array(
+ 'reason_id' => array('USINT', NULL, 'auto_increment'),
+ 'reason_title' => array('VCHAR_UNI', ''),
+ 'reason_description' => array('MTEXT_UNI', ''),
+ 'reason_order' => array('USINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'reason_id',
+ );
+
+ $schema_data['phpbb_search_results'] = array(
+ 'COLUMNS' => array(
+ 'search_key' => array('VCHAR:32', ''),
+ 'search_time' => array('TIMESTAMP', 0),
+ 'search_keywords' => array('MTEXT_UNI', ''),
+ 'search_authors' => array('MTEXT', ''),
+ ),
+ 'PRIMARY_KEY' => 'search_key',
+ );
+
+ $schema_data['phpbb_search_wordlist'] = array(
+ 'COLUMNS' => array(
+ 'word_id' => array('UINT', NULL, 'auto_increment'),
+ 'word_text' => array('VCHAR_UNI', ''),
+ 'word_common' => array('BOOL', 0),
+ 'word_count' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'word_id',
+ 'KEYS' => array(
+ 'wrd_txt' => array('UNIQUE', 'word_text'),
+ 'wrd_cnt' => array('INDEX', 'word_count'),
+ ),
+ );
+
+ $schema_data['phpbb_search_wordmatch'] = array(
+ 'COLUMNS' => array(
+ 'post_id' => array('UINT', 0),
+ 'word_id' => array('UINT', 0),
+ 'title_match' => array('BOOL', 0),
+ ),
+ 'KEYS' => array(
+ 'unq_mtch' => array('UNIQUE', array('word_id', 'post_id', 'title_match')),
+ 'word_id' => array('INDEX', 'word_id'),
+ 'post_id' => array('INDEX', 'post_id'),
+ ),
+ );
+
+ $schema_data['phpbb_sessions'] = array(
+ 'COLUMNS' => array(
+ 'session_id' => array('CHAR:32', ''),
+ 'session_user_id' => array('UINT', 0),
+ 'session_forum_id' => array('UINT', 0),
+ 'session_last_visit' => array('TIMESTAMP', 0),
+ 'session_start' => array('TIMESTAMP', 0),
+ 'session_time' => array('TIMESTAMP', 0),
+ 'session_ip' => array('VCHAR:40', ''),
+ 'session_browser' => array('VCHAR:150', ''),
+ 'session_forwarded_for' => array('VCHAR:255', ''),
+ 'session_page' => array('VCHAR_UNI', ''),
+ 'session_viewonline' => array('BOOL', 1),
+ 'session_autologin' => array('BOOL', 0),
+ 'session_admin' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => 'session_id',
+ 'KEYS' => array(
+ 'session_time' => array('INDEX', 'session_time'),
+ 'session_user_id' => array('INDEX', 'session_user_id'),
+ 'session_fid' => array('INDEX', 'session_forum_id'),
+ ),
+ );
+
+ $schema_data['phpbb_sessions_keys'] = array(
+ 'COLUMNS' => array(
+ 'key_id' => array('CHAR:32', ''),
+ 'user_id' => array('UINT', 0),
+ 'last_ip' => array('VCHAR:40', ''),
+ 'last_login' => array('TIMESTAMP', 0),
+ ),
+ 'PRIMARY_KEY' => array('key_id', 'user_id'),
+ 'KEYS' => array(
+ 'last_login' => array('INDEX', 'last_login'),
+ ),
+ );
+
+ $schema_data['phpbb_sitelist'] = array(
+ 'COLUMNS' => array(
+ 'site_id' => array('UINT', NULL, 'auto_increment'),
+ 'site_ip' => array('VCHAR:40', ''),
+ 'site_hostname' => array('VCHAR', ''),
+ 'ip_exclude' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => 'site_id',
+ );
+
+ $schema_data['phpbb_smilies'] = array(
+ 'COLUMNS' => array(
+ 'smiley_id' => array('UINT', NULL, 'auto_increment'),
+ // We may want to set 'code' to VCHAR:50 or check if unicode support is possible... at the moment only ASCII characters are allowed.
+ 'code' => array('VCHAR_UNI:50', ''),
+ 'emotion' => array('VCHAR_UNI:50', ''),
+ 'smiley_url' => array('VCHAR:50', ''),
+ 'smiley_width' => array('USINT', 0),
+ 'smiley_height' => array('USINT', 0),
+ 'smiley_order' => array('UINT', 0),
+ 'display_on_posting'=> array('BOOL', 1),
+ ),
+ 'PRIMARY_KEY' => 'smiley_id',
+ 'KEYS' => array(
+ 'display_on_post' => array('INDEX', 'display_on_posting'),
+ ),
+ );
+
+ $schema_data['phpbb_styles'] = array(
+ 'COLUMNS' => array(
+ 'style_id' => array('UINT', NULL, 'auto_increment'),
+ 'style_name' => array('VCHAR_UNI:255', ''),
+ 'style_copyright' => array('VCHAR_UNI', ''),
+ 'style_active' => array('BOOL', 1),
+ 'template_id' => array('UINT', 0),
+ 'theme_id' => array('UINT', 0),
+ 'imageset_id' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'style_id',
+ 'KEYS' => array(
+ 'style_name' => array('UNIQUE', 'style_name'),
+ 'template_id' => array('INDEX', 'template_id'),
+ 'theme_id' => array('INDEX', 'theme_id'),
+ 'imageset_id' => array('INDEX', 'imageset_id'),
+ ),
+ );
+
+ $schema_data['phpbb_styles_template'] = array(
+ 'COLUMNS' => array(
+ 'template_id' => array('UINT', NULL, 'auto_increment'),
+ 'template_name' => array('VCHAR_UNI:255', ''),
+ 'template_copyright' => array('VCHAR_UNI', ''),
+ 'template_path' => array('VCHAR:100', ''),
+ 'bbcode_bitfield' => array('VCHAR:255', 'kNg='),
+ 'template_storedb' => array('BOOL', 0),
+ 'template_inherits_id' => array('UINT:4', 0),
+ 'template_inherit_path' => array('VCHAR', ''),
+ ),
+ 'PRIMARY_KEY' => 'template_id',
+ 'KEYS' => array(
+ 'tmplte_nm' => array('UNIQUE', 'template_name'),
+ ),
+ );
+
+ $schema_data['phpbb_styles_template_data'] = array(
+ 'COLUMNS' => array(
+ 'template_id' => array('UINT', 0),
+ 'template_filename' => array('VCHAR:100', ''),
+ 'template_included' => array('TEXT', ''),
+ 'template_mtime' => array('TIMESTAMP', 0),
+ 'template_data' => array('MTEXT_UNI', ''),
+ ),
+ 'KEYS' => array(
+ 'tid' => array('INDEX', 'template_id'),
+ 'tfn' => array('INDEX', 'template_filename'),
+ ),
+ );
+
+ $schema_data['phpbb_styles_theme'] = array(
+ 'COLUMNS' => array(
+ 'theme_id' => array('UINT', NULL, 'auto_increment'),
+ 'theme_name' => array('VCHAR_UNI:255', ''),
+ 'theme_copyright' => array('VCHAR_UNI', ''),
+ 'theme_path' => array('VCHAR:100', ''),
+ 'theme_storedb' => array('BOOL', 0),
+ 'theme_mtime' => array('TIMESTAMP', 0),
+ 'theme_data' => array('MTEXT_UNI', ''),
+ ),
+ 'PRIMARY_KEY' => 'theme_id',
+ 'KEYS' => array(
+ 'theme_name' => array('UNIQUE', 'theme_name'),
+ ),
+ );
+
+ $schema_data['phpbb_styles_imageset'] = array(
+ 'COLUMNS' => array(
+ 'imageset_id' => array('UINT', NULL, 'auto_increment'),
+ 'imageset_name' => array('VCHAR_UNI:255', ''),
+ 'imageset_copyright' => array('VCHAR_UNI', ''),
+ 'imageset_path' => array('VCHAR:100', ''),
+ ),
+ 'PRIMARY_KEY' => 'imageset_id',
+ 'KEYS' => array(
+ 'imgset_nm' => array('UNIQUE', 'imageset_name'),
+ ),
+ );
+
+ $schema_data['phpbb_styles_imageset_data'] = array(
+ 'COLUMNS' => array(
+ 'image_id' => array('UINT', NULL, 'auto_increment'),
+ 'image_name' => array('VCHAR:200', ''),
+ 'image_filename' => array('VCHAR:200', ''),
+ 'image_lang' => array('VCHAR:30', ''),
+ 'image_height' => array('USINT', 0),
+ 'image_width' => array('USINT', 0),
+ 'imageset_id' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'image_id',
+ 'KEYS' => array(
+ 'i_d' => array('INDEX', 'imageset_id'),
+ ),
+ );
+
+ $schema_data['phpbb_topics'] = array(
+ 'COLUMNS' => array(
+ 'topic_id' => array('UINT', NULL, 'auto_increment'),
+ 'forum_id' => array('UINT', 0),
+ 'icon_id' => array('UINT', 0),
+ 'topic_attachment' => array('BOOL', 0),
+ 'topic_approved' => array('BOOL', 1),
+ 'topic_reported' => array('BOOL', 0),
+ 'topic_title' => array('STEXT_UNI', '', 'true_sort'),
+ 'topic_poster' => array('UINT', 0),
+ 'topic_time' => array('TIMESTAMP', 0),
+ 'topic_time_limit' => array('TIMESTAMP', 0),
+ 'topic_views' => array('UINT', 0),
+ 'topic_replies' => array('UINT', 0),
+ 'topic_replies_real' => array('UINT', 0),
+ 'topic_status' => array('TINT:3', 0),
+ 'topic_type' => array('TINT:3', 0),
+ 'topic_first_post_id' => array('UINT', 0),
+ 'topic_first_poster_name' => array('VCHAR_UNI', ''),
+ 'topic_first_poster_colour' => array('VCHAR:6', ''),
+ 'topic_last_post_id' => array('UINT', 0),
+ 'topic_last_poster_id' => array('UINT', 0),
+ 'topic_last_poster_name' => array('VCHAR_UNI', ''),
+ 'topic_last_poster_colour' => array('VCHAR:6', ''),
+ 'topic_last_post_subject' => array('STEXT_UNI', ''),
+ 'topic_last_post_time' => array('TIMESTAMP', 0),
+ 'topic_last_view_time' => array('TIMESTAMP', 0),
+ 'topic_moved_id' => array('UINT', 0),
+ 'topic_bumped' => array('BOOL', 0),
+ 'topic_bumper' => array('UINT', 0),
+ 'poll_title' => array('STEXT_UNI', ''),
+ 'poll_start' => array('TIMESTAMP', 0),
+ 'poll_length' => array('TIMESTAMP', 0),
+ 'poll_max_options' => array('TINT:4', 1),
+ 'poll_last_vote' => array('TIMESTAMP', 0),
+ 'poll_vote_change' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => 'topic_id',
+ 'KEYS' => array(
+ 'forum_id' => array('INDEX', 'forum_id'),
+ 'forum_id_type' => array('INDEX', array('forum_id', 'topic_type')),
+ 'last_post_time' => array('INDEX', 'topic_last_post_time'),
+ 'topic_approved' => array('INDEX', 'topic_approved'),
+ 'forum_appr_last' => array('INDEX', array('forum_id', 'topic_approved', 'topic_last_post_id')),
+ 'fid_time_moved' => array('INDEX', array('forum_id', 'topic_last_post_time', 'topic_moved_id')),
+ ),
+ );
+
+ $schema_data['phpbb_topics_track'] = array(
+ 'COLUMNS' => array(
+ 'user_id' => array('UINT', 0),
+ 'topic_id' => array('UINT', 0),
+ 'forum_id' => array('UINT', 0),
+ 'mark_time' => array('TIMESTAMP', 0),
+ ),
+ 'PRIMARY_KEY' => array('user_id', 'topic_id'),
+ 'KEYS' => array(
+ 'forum_id' => array('INDEX', 'forum_id'),
+ ),
+ );
+
+ $schema_data['phpbb_topics_posted'] = array(
+ 'COLUMNS' => array(
+ 'user_id' => array('UINT', 0),
+ 'topic_id' => array('UINT', 0),
+ 'topic_posted' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => array('user_id', 'topic_id'),
+ );
+
+ $schema_data['phpbb_topics_watch'] = array(
+ 'COLUMNS' => array(
+ 'topic_id' => array('UINT', 0),
+ 'user_id' => array('UINT', 0),
+ 'notify_status' => array('BOOL', 0),
+ ),
+ 'KEYS' => array(
+ 'topic_id' => array('INDEX', 'topic_id'),
+ 'user_id' => array('INDEX', 'user_id'),
+ 'notify_stat' => array('INDEX', 'notify_status'),
+ ),
+ );
+
+ $schema_data['phpbb_user_group'] = array(
+ 'COLUMNS' => array(
+ 'group_id' => array('UINT', 0),
+ 'user_id' => array('UINT', 0),
+ 'group_leader' => array('BOOL', 0),
+ 'user_pending' => array('BOOL', 1),
+ ),
+ 'KEYS' => array(
+ 'group_id' => array('INDEX', 'group_id'),
+ 'user_id' => array('INDEX', 'user_id'),
+ 'group_leader' => array('INDEX', 'group_leader'),
+ ),
+ );
+
+ $schema_data['phpbb_users'] = array(
+ 'COLUMNS' => array(
+ 'user_id' => array('UINT', NULL, 'auto_increment'),
+ 'user_type' => array('TINT:2', 0),
+ 'group_id' => array('UINT', 3),
+ 'user_permissions' => array('MTEXT', ''),
+ 'user_perm_from' => array('UINT', 0),
+ 'user_ip' => array('VCHAR:40', ''),
+ 'user_regdate' => array('TIMESTAMP', 0),
+ 'username' => array('VCHAR_CI', ''),
+ 'username_clean' => array('VCHAR_CI', ''),
+ 'user_password' => array('VCHAR_UNI:40', ''),
+ 'user_passchg' => array('TIMESTAMP', 0),
+ 'user_pass_convert' => array('BOOL', 0),
+ 'user_email' => array('VCHAR_UNI:100', ''),
+ 'user_email_hash' => array('BINT', 0),
+ 'user_birthday' => array('VCHAR:10', ''),
+ 'user_lastvisit' => array('TIMESTAMP', 0),
+ 'user_lastmark' => array('TIMESTAMP', 0),
+ 'user_lastpost_time' => array('TIMESTAMP', 0),
+ 'user_lastpage' => array('VCHAR_UNI:200', ''),
+ 'user_last_confirm_key' => array('VCHAR:10', ''),
+ 'user_last_search' => array('TIMESTAMP', 0),
+ 'user_warnings' => array('TINT:4', 0),
+ 'user_last_warning' => array('TIMESTAMP', 0),
+ 'user_login_attempts' => array('TINT:4', 0),
+ 'user_inactive_reason' => array('TINT:2', 0),
+ 'user_inactive_time' => array('TIMESTAMP', 0),
+ 'user_posts' => array('UINT', 0),
+ 'user_lang' => array('VCHAR:30', ''),
+ 'user_timezone' => array('DECIMAL', 0),
+ 'user_dst' => array('BOOL', 0),
+ 'user_dateformat' => array('VCHAR_UNI:30', 'd M Y H:i'),
+ 'user_style' => array('UINT', 0),
+ 'user_rank' => array('UINT', 0),
+ 'user_colour' => array('VCHAR:6', ''),
+ 'user_new_privmsg' => array('INT:4', 0),
+ 'user_unread_privmsg' => array('INT:4', 0),
+ 'user_last_privmsg' => array('TIMESTAMP', 0),
+ 'user_message_rules' => array('BOOL', 0),
+ 'user_full_folder' => array('INT:11', -3),
+ 'user_emailtime' => array('TIMESTAMP', 0),
+ 'user_topic_show_days' => array('USINT', 0),
+ 'user_topic_sortby_type' => array('VCHAR:1', 't'),
+ 'user_topic_sortby_dir' => array('VCHAR:1', 'd'),
+ 'user_post_show_days' => array('USINT', 0),
+ 'user_post_sortby_type' => array('VCHAR:1', 't'),
+ 'user_post_sortby_dir' => array('VCHAR:1', 'a'),
+ 'user_notify' => array('BOOL', 0),
+ 'user_notify_pm' => array('BOOL', 1),
+ 'user_notify_type' => array('TINT:4', 0),
+ 'user_allow_pm' => array('BOOL', 1),
+ 'user_allow_viewonline' => array('BOOL', 1),
+ 'user_allow_viewemail' => array('BOOL', 1),
+ 'user_allow_massemail' => array('BOOL', 1),
+ 'user_options' => array('UINT:11', 230271),
+ 'user_avatar' => array('VCHAR', ''),
+ 'user_avatar_type' => array('TINT:2', 0),
+ 'user_avatar_width' => array('USINT', 0),
+ 'user_avatar_height' => array('USINT', 0),
+ 'user_sig' => array('MTEXT_UNI', ''),
+ 'user_sig_bbcode_uid' => array('VCHAR:8', ''),
+ 'user_sig_bbcode_bitfield' => array('VCHAR:255', ''),
+ 'user_from' => array('VCHAR_UNI:100', ''),
+ 'user_icq' => array('VCHAR:15', ''),
+ 'user_aim' => array('VCHAR_UNI', ''),
+ 'user_yim' => array('VCHAR_UNI', ''),
+ 'user_msnm' => array('VCHAR_UNI', ''),
+ 'user_jabber' => array('VCHAR_UNI', ''),
+ 'user_website' => array('VCHAR_UNI:200', ''),
+ 'user_occ' => array('TEXT_UNI', ''),
+ 'user_interests' => array('TEXT_UNI', ''),
+ 'user_actkey' => array('VCHAR:32', ''),
+ 'user_newpasswd' => array('VCHAR_UNI:40', ''),
+ 'user_form_salt' => array('VCHAR_UNI:32', ''),
+ 'user_new' => array('BOOL', 1),
+ 'user_reminded' => array('TINT:4', 0),
+ 'user_reminded_time' => array('TIMESTAMP', 0),
+ ),
+ 'PRIMARY_KEY' => 'user_id',
+ 'KEYS' => array(
+ 'user_birthday' => array('INDEX', 'user_birthday'),
+ 'user_email_hash' => array('INDEX', 'user_email_hash'),
+ 'user_type' => array('INDEX', 'user_type'),
+ 'username_clean' => array('UNIQUE', 'username_clean'),
+ ),
+ );
+
+ $schema_data['phpbb_warnings'] = array(
+ 'COLUMNS' => array(
+ 'warning_id' => array('UINT', NULL, 'auto_increment'),
+ 'user_id' => array('UINT', 0),
+ 'post_id' => array('UINT', 0),
+ 'log_id' => array('UINT', 0),
+ 'warning_time' => array('TIMESTAMP', 0),
+ ),
+ 'PRIMARY_KEY' => 'warning_id',
+ );
+
+ $schema_data['phpbb_words'] = array(
+ 'COLUMNS' => array(
+ 'word_id' => array('UINT', NULL, 'auto_increment'),
+ 'word' => array('VCHAR_UNI', ''),
+ 'replacement' => array('VCHAR_UNI', ''),
+ ),
+ 'PRIMARY_KEY' => 'word_id',
+ );
+
+ $schema_data['phpbb_zebra'] = array(
+ 'COLUMNS' => array(
+ 'user_id' => array('UINT', 0),
+ 'zebra_id' => array('UINT', 0),
+ 'friend' => array('BOOL', 0),
+ 'foe' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => array('user_id', 'zebra_id'),
+ );
+
+ return $schema_data;
+}
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/nuke-db.php b/phpBB/develop/nuke-db.php
new file mode 100644
index 0000000000..d7329c3f56
--- /dev/null
+++ b/phpBB/develop/nuke-db.php
@@ -0,0 +1,58 @@
+<?php
+
+//
+// Security message:
+//
+// This script is potentially dangerous.
+// Remove or comment the next line (die(".... ) to enable this script.
+// Do NOT FORGET to either remove this script or disable it after you have used it.
+//
+die("Please read the first lines of this script for instructions on how to enable it");
+
+//
+// Do not change anything below this line.
+//
+
+
+// Just a handy script to completely wipe out the contents of a
+// database.. Use with caution :)
+
+
+if(!isset($submit))
+{
+ ?>
+ <FORM ACTION="<?php echo $PHP_SELF?>" METHOD="post" >
+ <table>
+ <tr>
+ <td>DB host:</td>
+ <td><INPUT TYPE="text" name="dbhost" value="localhost"></td>
+ </tr><tr>
+ <td>DB name:</td>
+ <td><INPUT TYPE="text" name="dbname" value="phpBB"></td>
+ </tr><tr>
+ <td>DB username:</td>
+ <td><INPUT TYPE="text" name="dbuser" value="root"></td>
+ </tr><tr>
+ <td>DB password:</td>
+ <td><INPUT TYPE="password" name="dbpass"></td>
+ </tr></table>
+ <INPUT TYPE="submit" name="submit" value="Submit">
+ </FORM>
+ <?php
+}
+else
+{
+ mysql_connect($dbhost, $dbuser, $dbpass) || die(mysql_error());
+ mysql_select_db($dbname);
+
+ $result = mysql_query("SHOW TABLES");
+ while($row = mysql_fetch_row($result)){
+ $table = $row[0];
+ print "Going to drop $table...";
+ mysql_query("DROP TABLE $table") || die();
+ print "Done.<br>\n";
+ flush();
+ }
+}
+?>
+
diff --git a/phpBB/develop/regex.php b/phpBB/develop/regex.php
new file mode 100644
index 0000000000..4498204b4a
--- /dev/null
+++ b/phpBB/develop/regex.php
@@ -0,0 +1,83 @@
+<?php
+//
+// Security message:
+//
+// This script is potentially dangerous.
+// Remove or comment the next line (die(".... ) to enable this script.
+// Do NOT FORGET to either remove this script or disable it after you have used it.
+//
+die("Please read the first lines of this script for instructions on how to enable it");
+
+
+// IP regular expressions
+
+$dec_octet = '(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])';
+$h16 = '[\dA-F]{1,4}';
+$ipv4 = "(?:$dec_octet\.){3}$dec_octet";
+$ls32 = "(?:$h16:$h16|$ipv4)";
+
+$ipv6_construct = array(
+ array(false, '', '{6}', $ls32),
+ array(false, '::', '{5}', $ls32),
+ array('', ':', '{4}', $ls32),
+ array('{1,2}', ':', '{3}', $ls32),
+ array('{1,3}', ':', '{2}', $ls32),
+ array('{1,4}', ':', '', $ls32),
+ array('{1,5}', ':', false, $ls32),
+ array('{1,6}', ':', false, $h16),
+ array('{1,7}', ':', false, '')
+);
+
+$ipv6 = '(?:';
+foreach ($ipv6_construct as $ip_type)
+{
+ $ipv6 .= '(?:';
+ if ($ip_type[0] !== false)
+ {
+ $ipv6 .= "(?:$h16:)" . $ip_type[0];
+ }
+ $ipv6 .= $ip_type[1];
+ if ($ip_type[2] !== false)
+ {
+ $ipv6 .= "(?:$h16:)" . $ip_type[2];
+ }
+ $ipv6 .= $ip_type[3] . ')|';
+}
+$ipv6 = substr($ipv6, 0, -1) . ')';
+
+echo 'IPv4: ' . $ipv4 . "<br />\nIPv6: " . $ipv6 . "<br />\n";
+
+// URL regular expressions
+
+$pct_encoded = "%[\dA-F]{2}";
+$unreserved = 'a-z0-9\-._~';
+$sub_delims = '!$&\'()*+,;=';
+$pchar = "(?:[$unreserved$sub_delims:@|]+|$pct_encoded)"; // rfc: no "|"
+
+$scheme = '[a-z][a-z\d+\-.]*';
+$reg_name = "(?:[$unreserved$sub_delims:@|]+|$pct_encoded)+"; // rfc: * instead of + and no "|" and no "@" and no ":" (included instead of userinfo)
+//$userinfo = "(?:(?:[$unreserved$sub_delims:]+|$pct_encoded))*";
+$ipv4_simple = '[0-9.]+';
+$ipv6_simple = '\[[a-z0-9.]+:[a-z0-9.]+:[a-z0-9.:]+\]';
+$host = "(?:$reg_name|$ipv4_simple|$ipv6_simple)";
+$port = '\d*';
+//$authority = "(?:$userinfo@)?$host(?::$port)?";
+$authority = "$host(?::$port)?";
+$segment = "$pchar*";
+$path_abempty = "(?:/$segment)*";
+$hier_part = "/{2}$authority$path_abempty";
+$query = "(?:[$unreserved$sub_delims:@/?|]+|$pct_encoded)*"; // pchar | "/" | "?", rfc: no "|"
+$fragment = $query;
+
+$url = "$scheme:$hier_part(?:\?$query)?(?:\#$fragment)?";
+echo 'URL: ' . $url . "<br />\n";
+
+// no scheme, shortened authority, but host has to start with www.
+$www_url = "www\.$reg_name(?::$port)?$path_abempty(?:\?$query)?(?:\#$fragment)?";
+echo 'www.URL: ' . $www_url . "<br />\n";
+
+// no schema and no authority
+$relative_url = "$segment$path_abempty(?:\?$query)?(?:\#$fragment)?";
+echo 'relative URL: ' . $relative_url . "<br />\n";
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/repair_bots.php b/phpBB/develop/repair_bots.php
new file mode 100644
index 0000000000..c5aaa75d9b
--- /dev/null
+++ b/phpBB/develop/repair_bots.php
@@ -0,0 +1,151 @@
+<?php
+/**
+* Rebuild BOTS
+*
+* You should make a backup from your whole database. Things can and will go wrong.
+* This will only work if no BOTs were added.
+*
+*/
+die("Please read the first lines of this script for instructions on how to enable it");
+
+set_time_limit(0);
+
+define('IN_PHPBB', true);
+$phpbb_root_path = './../';
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+include($phpbb_root_path . 'common.'.$phpEx);
+include($phpbb_root_path . '/includes/functions_user.'.$phpEx);
+
+
+// Start session management
+$user->session_begin();
+$auth->acl($user->data);
+$user->setup();
+
+$bots = array(
+ 'AdsBot [Google]' => array('AdsBot-Google', ''),
+ 'Alexa [Bot]' => array('ia_archiver', ''),
+ 'Alta Vista [Bot]' => array('Scooter/', ''),
+ 'Ask Jeeves [Bot]' => array('Ask Jeeves', ''),
+ 'Baidu [Spider]' => array('Baiduspider+(', ''),
+ 'Exabot [Bot]' => array('Exabot/', ''),
+ 'FAST Enterprise [Crawler]' => array('FAST Enterprise Crawler', ''),
+ 'FAST WebCrawler [Crawler]' => array('FAST-WebCrawler/', ''),
+ 'Francis [Bot]' => array('http://www.neomo.de/', ''),
+ 'Gigabot [Bot]' => array('Gigabot/', ''),
+ 'Google Adsense [Bot]' => array('Mediapartners-Google', ''),
+ 'Google Desktop' => array('Google Desktop', ''),
+ 'Google Feedfetcher' => array('Feedfetcher-Google', ''),
+ 'Google [Bot]' => array('Googlebot', ''),
+ 'Heise IT-Markt [Crawler]' => array('heise-IT-Markt-Crawler', ''),
+ 'Heritrix [Crawler]' => array('heritrix/1.', ''),
+ 'IBM Research [Bot]' => array('ibm.com/cs/crawler', ''),
+ 'ICCrawler - ICjobs' => array('ICCrawler - ICjobs', ''),
+ 'ichiro [Crawler]' => array('ichiro/2', ''),
+ 'Majestic-12 [Bot]' => array('MJ12bot/', ''),
+ 'Metager [Bot]' => array('MetagerBot/', ''),
+ 'MSN NewsBlogs' => array('msnbot-NewsBlogs/', ''),
+ 'MSN [Bot]' => array('msnbot/', ''),
+ 'MSNbot Media' => array('msnbot-media/', ''),
+ 'NG-Search [Bot]' => array('NG-Search/', ''),
+ 'Nutch [Bot]' => array('http://lucene.apache.org/nutch/', ''),
+ 'Nutch/CVS [Bot]' => array('NutchCVS/', ''),
+ 'OmniExplorer [Bot]' => array('OmniExplorer_Bot/', ''),
+ 'Online link [Validator]' => array('online link validator', ''),
+ 'psbot [Picsearch]' => array('psbot/0', ''),
+ 'Seekport [Bot]' => array('Seekbot/', ''),
+ 'Sensis [Crawler]' => array('Sensis Web Crawler', ''),
+ 'SEO Crawler' => array('SEO search Crawler/', ''),
+ 'Seoma [Crawler]' => array('Seoma [SEO Crawler]', ''),
+ 'SEOSearch [Crawler]' => array('SEOsearch/', ''),
+ 'Snappy [Bot]' => array('Snappy/1.1 ( http://www.urltrends.com/ )', ''),
+ 'Steeler [Crawler]' => array('http://www.tkl.iis.u-tokyo.ac.jp/~crawler/', ''),
+ 'Synoo [Bot]' => array('SynooBot/', ''),
+ 'Telekom [Bot]' => array('crawleradmin.t-info@telekom.de', ''),
+ 'TurnitinBot [Bot]' => array('TurnitinBot/', ''),
+ 'Voyager [Bot]' => array('voyager/1.0', ''),
+ 'W3 [Sitesearch]' => array('W3 SiteSearch Crawler', ''),
+ 'W3C [Linkcheck]' => array('W3C-checklink/', ''),
+ 'W3C [Validator]' => array('W3C_*Validator', ''),
+ 'WiseNut [Bot]' => array('http://www.WISEnutbot.com', ''),
+ 'YaCy [Bot]' => array('yacybot', ''),
+ 'Yahoo MMCrawler [Bot]' => array('Yahoo-MMCrawler/', ''),
+ 'Yahoo Slurp [Bot]' => array('Yahoo! DE Slurp', ''),
+ 'Yahoo [Bot]' => array('Yahoo! Slurp', ''),
+ 'YahooSeeker [Bot]' => array('YahooSeeker/', ''),
+);
+
+$bot_ids = array();
+user_get_id_name($bot_ids, array_keys($bots), USER_IGNORE);
+foreach($bot_ids as $bot)
+{
+ user_delete('remove', $bot);
+}
+// Done
+add_bots($bots);
+echo 'done';
+
+
+/**
+* Add the search bots into the database
+* This code should be used in execute_last if the source database did not have bots
+* If you are converting bots this function should not be called
+* @todo We might want to look at sharing the bot list between the install code and this code for consistency
+*/
+function add_bots($bots)
+{
+ global $db, $config;
+
+ $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'BOTS'";
+ $result = $db->sql_query($sql);
+ $group_id = (int) $db->sql_fetchfield('group_id', false, $result);
+ $db->sql_freeresult($result);
+ $db->sql_query('TRUNCATE TABLE ' . BOTS_TABLE);
+
+ if (!$group_id)
+ {
+ add_default_groups();
+
+ $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'BOTS'";
+ $result = $db->sql_query($sql);
+ $group_id = (int) $db->sql_fetchfield('group_id', false, $result);
+ $db->sql_freeresult($result);
+
+ }
+
+
+
+
+ foreach ($bots as $bot_name => $bot_ary)
+ {
+ $user_row = array(
+ 'user_type' => USER_IGNORE,
+ 'group_id' => $group_id,
+ 'username' => $bot_name,
+ 'user_regdate' => time(),
+ 'user_password' => '',
+ 'user_colour' => '9E8DA7',
+ 'user_email' => '',
+ 'user_lang' => $config['default_lang'],
+ 'user_style' => 1,
+ 'user_timezone' => 0,
+ 'user_allow_massemail' => 0,
+ );
+
+ $user_id = user_add($user_row);
+
+ if ($user_id)
+ {
+ $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
+ 'bot_active' => 1,
+ 'bot_name' => $bot_name,
+ 'user_id' => $user_id,
+ 'bot_agent' => $bot_ary[0],
+ 'bot_ip' => $bot_ary[1])
+ );
+ $db->sql_query($sql);
+ }
+ }
+}
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/search_fill.php b/phpBB/develop/search_fill.php
new file mode 100644
index 0000000000..371c8c74cc
--- /dev/null
+++ b/phpBB/develop/search_fill.php
@@ -0,0 +1,129 @@
+<?php
+
+//
+// Security message:
+//
+// This script is potentially dangerous.
+// Remove or comment the next line (die(".... ) to enable this script.
+// Do NOT FORGET to either remove this script or disable it after you have used it.
+//
+
+//
+// Security message:
+//
+// This script is potentially dangerous.
+// Remove or comment the next line (die(".... ) to enable this script.
+// Do NOT FORGET to either remove this script or disable it after you have used it.
+//
+die("Please read the first lines of this script for instructions on how to enable it");
+
+//
+// Do not change anything below this line.
+//
+set_time_limit(0);
+
+define('IN_PHPBB', true);
+$phpbb_root_path = '../';
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+include($phpbb_root_path . 'common.'.$phpEx);
+
+// Start session management
+$user->session_begin();
+$auth->acl($user->data);
+$user->setup();
+
+$search_type = $config['search_type'];
+
+if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx))
+{
+ trigger_error('NO_SUCH_SEARCH_MODULE');
+}
+
+require($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx);
+
+$error = false;
+$search = new $search_type($error);
+
+if ($error)
+{
+ trigger_error($error);
+}
+
+print "<html>\n<body>\n";
+
+//
+// Fetch a batch of posts_text entries
+//
+$sql = "SELECT COUNT(*) as total, MAX(post_id) as max_post_id
+ FROM ". POSTS_TABLE;
+if ( !($result = $db->sql_query($sql)) )
+{
+ $error = $db->sql_error();
+ die("Couldn't get maximum post ID :: " . $sql . " :: " . $error['message']);
+}
+
+$max_post_id = $db->sql_fetchrow($result);
+
+$totalposts = $max_post_id['total'];
+$max_post_id = $max_post_id['max_post_id'];
+
+$postcounter = (!isset($HTTP_GET_VARS['batchstart'])) ? 0 : $HTTP_GET_VARS['batchstart'];
+
+$batchsize = 200; // Process this many posts per loop
+$batchcount = 0;
+for(;$postcounter <= $max_post_id; $postcounter += $batchsize)
+{
+ $batchstart = $postcounter + 1;
+ $batchend = $postcounter + $batchsize;
+ $batchcount++;
+
+ $sql = "SELECT *
+ FROM " . POSTS_TABLE . "
+ WHERE post_id
+ BETWEEN $batchstart
+ AND $batchend";
+ if( !($result = $db->sql_query($sql)) )
+ {
+ $error = $db->sql_error();
+ die("Couldn't get post_text :: " . $sql . " :: " . $error['message']);
+ }
+
+ $rowset = $db->sql_fetchrowset($result);
+ $db->sql_freeresult($result);
+
+ $post_rows = sizeof($rowset);
+
+ if( $post_rows )
+ {
+
+ // $sql = "LOCK TABLES ".POST_TEXT_TABLE." WRITE";
+ // $result = $db->sql_query($sql);
+ print "\n<p>\n<a href='{$_SERVER['PHP_SELF']}?batchstart=$batchstart'>Restart from posting $batchstart</a><br>\n";
+
+ // For every post in the batch:
+ for($post_nr = 0; $post_nr < $post_rows; $post_nr++ )
+ {
+ print ".";
+ flush();
+
+ $post_id = $rowset[$post_nr]['post_id'];
+
+ $search->index('post', $rowset[$post_nr]['post_id'], $rowset[$post_nr]['post_text'], $rowset[$post_nr]['post_subject'], $rowset[$post_nr]['poster_id']);
+ }
+ // $sql = "UNLOCK TABLES";
+ // $result = $db->sql_query($sql);
+
+ }
+}
+
+print "<br>Removing common words (words that appear in more than 50% of the posts)<br>\n";
+flush();
+$search->tidy();
+print "Removed words that where too common.<br>";
+
+echo "<br>Done";
+
+?>
+
+</body>
+</html>
diff --git a/phpBB/develop/unicode_testing.php b/phpBB/develop/unicode_testing.php
new file mode 100644
index 0000000000..25a13d1325
--- /dev/null
+++ b/phpBB/develop/unicode_testing.php
@@ -0,0 +1,120 @@
+<?php
+//
+// This file provides some useful functions for debugging the unicode/UTF-8 library
+// It requires utf_tools.php to be loaded
+//
+die("Please read the first lines of this script for instructions on how to enable it");
+
+if (!headers_sent())
+{
+ header('Content-type: text/html; charset=UTF-8');
+}
+
+/**
+ * Converts unicode escape sequences (\u0123) into UTF-8 characters
+ *
+ * @param string A unicode sequence
+ * @return string UTF-8 representation of the given unicode sequence
+ */
+function unicode_to_utf8($string)
+{
+ $utf8 = '';
+ $chars = array();
+ for ($i = 0; $i < strlen($string); $i++)
+ {
+ if (isset($string[$i + 5]) && substr($string, $i, 2) == '\\u' && ctype_xdigit(substr($string, $i + 2, 4)))
+ {
+ $utf8 .= utf8_from_unicode(array(base_convert(substr($string, $i + 2, 4), 16, 10)));
+ $i += 5;
+ }
+ else
+ {
+ $utf8 .= $string[$i];
+ }
+ }
+ return $utf8;
+}
+
+/**
+ * Takes an array of ints representing the Unicode characters and returns
+ * a UTF-8 string.
+ *
+ * @param array $array array of unicode code points representing a string
+ * @return string UTF-8 character string
+ */
+function utf8_from_unicode($array)
+{
+ $str = '';
+ foreach ($array as $value)
+ {
+ $str .= utf8_chr($value);
+ }
+ return $str;
+}
+
+/**
+* Converts a UTF-8 string to unicode code points
+*
+* @param string $text UTF-8 string
+* @return string Unicode code points
+*/
+function utf8_to_unicode($text)
+{
+ return preg_replace_callback(
+ '#[\\xC2-\\xF4][\\x80-\\xBF]?[\\x80-\\xBF]?[\\x80-\\xBF]#',
+ 'utf8_to_unicode_callback',
+ preg_replace_callback(
+ '#[\\x00-\\x7f]#',
+ 'utf8_to_unicode_callback',
+ $text
+ )
+ );
+}
+
+/**
+* Takes a UTF-8 char and replaces it with its unicode escape sequence. Attention, $m is an array
+*
+* @param array $m 0-based numerically indexed array passed by preg_replace_callback()
+* @return string A unicode escape sequence
+*/
+function utf8_to_unicode_callback($m)
+{
+ return '\u' . str_pad(base_convert(utf8_ord($m[0]), 10, 16), 4, '0', STR_PAD_LEFT) . '';
+}
+
+/**
+* A wrapper function for the normalizer which takes care of including the class if required and modifies the passed strings
+* to be in NFKC
+*
+* @param mixed $strings a string or an array of strings to normalize
+* @return mixed the normalized content, preserving array keys if array given.
+*/
+function utf8_normalize_nfkc($strings)
+{
+ if (empty($strings))
+ {
+ return $strings;
+ }
+
+ if (!class_exists('utf_normalizer'))
+ {
+ global $phpbb_root_path, $phpEx;
+ include($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx);
+ }
+
+ if (!is_array($strings))
+ {
+ utf_normalizer::nfkc($strings);
+ }
+ else if (is_array($strings))
+ {
+ foreach ($strings as $key => $string)
+ {
+ utf_normalizer::nfkc($strings[$key]);
+ }
+ }
+
+ return $strings;
+}
+
+?> \ No newline at end of file
diff --git a/phpBB/develop/update_email_hash.php b/phpBB/develop/update_email_hash.php
new file mode 100644
index 0000000000..80fd4bbc17
--- /dev/null
+++ b/phpBB/develop/update_email_hash.php
@@ -0,0 +1,57 @@
+<?php
+/**
+* Corrects user_email_hash values if DB moved from 32-bit system to 64-bit system or vice versa.
+* The CRC32 function in PHP generates different results for both systems.
+* @PHP dev team: no, a hexdec() applied to it does not solve the issue. And please document it.
+*
+*/
+die("Please read the first lines of this script for instructions on how to enable it");
+
+set_time_limit(0);
+
+define('IN_PHPBB', true);
+$phpbb_root_path = './../';
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+include($phpbb_root_path . 'common.' . $phpEx);
+
+// Start session management
+$user->session_begin();
+$auth->acl($user->data);
+$user->setup();
+
+$start = request_var('start', 0);
+$num_items = 1000;
+
+echo '<br />Updating user email hashes' . "\n";
+
+$sql = 'SELECT user_id, user_email
+ FROM ' . USERS_TABLE . '
+ ORDER BY user_id ASC';
+$result = $db->sql_query($sql);
+
+$echos = 0;
+while ($row = $db->sql_fetchrow($result))
+{
+ $echos++;
+
+ $sql = 'UPDATE ' . USERS_TABLE . "
+ SET user_email_hash = '" . $db->sql_escape(phpbb_email_hash($row['user_email'])) . "'
+ WHERE user_id = " . (int) $row['user_id'];
+ $db->sql_query($sql);
+
+ if ($echos == 200)
+ {
+ echo '<br />';
+ $echos = 0;
+ }
+
+ echo '.';
+ flush();
+}
+$db->sql_freeresult($result);
+
+echo 'FINISHED';
+
+// Done
+$db->sql_close();
+?> \ No newline at end of file
diff --git a/phpBB/develop/utf_normalizer_test.php b/phpBB/develop/utf_normalizer_test.php
new file mode 100644
index 0000000000..7705cd6851
--- /dev/null
+++ b/phpBB/develop/utf_normalizer_test.php
@@ -0,0 +1,391 @@
+<?php
+/**
+*
+* @package phpBB3
+* @version $Id$
+* @copyright (c) 2005 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+if (php_sapi_name() != 'cli')
+{
+ die("This program must be run from the command line.\n");
+}
+
+//
+// Security message:
+//
+// This script is potentially dangerous.
+// Remove or comment the next line (die(".... ) to enable this script.
+// Do NOT FORGET to either remove this script or disable it after you have used it.
+//
+die("Please read the first lines of this script for instructions on how to enable it");
+
+set_time_limit(0);
+error_reporting(E_ALL);
+
+define('IN_PHPBB', true);
+$phpbb_root_path = '../';
+$phpEx = substr(strrchr(__FILE__, '.'), 1);
+
+
+/**
+* Let's download some files we need
+*/
+download('http://www.unicode.org/Public/UNIDATA/NormalizationTest.txt');
+download('http://www.unicode.org/Public/UNIDATA/UnicodeData.txt');
+
+/**
+* Those are the tests we run
+*/
+$test_suite = array(
+ /**
+ * NFC
+ * c2 == NFC(c1) == NFC(c2) == NFC(c3)
+ * c4 == NFC(c4) == NFC(c5)
+ */
+ 'NFC' => array(
+ 'c2' => array('c1', 'c2', 'c3'),
+ 'c4' => array('c4', 'c5')
+ ),
+
+ /**
+ * NFD
+ * c3 == NFD(c1) == NFD(c2) == NFD(c3)
+ * c5 == NFD(c4) == NFD(c5)
+ */
+ 'NFD' => array(
+ 'c3' => array('c1', 'c2', 'c3'),
+ 'c5' => array('c4', 'c5')
+ ),
+
+ /**
+ * NFKC
+ * c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5)
+ */
+ 'NFKC' => array(
+ 'c4' => array('c1', 'c2', 'c3', 'c4', 'c5')
+ ),
+
+ /**
+ * NFKD
+ * c5 == NFKD(c1) == NFKD(c2) == NFKD(c3) == NFKD(c4) == NFKD(c5)
+ */
+ 'NFKD' => array(
+ 'c5' => array('c1', 'c2', 'c3', 'c4', 'c5')
+ )
+);
+
+require_once($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx);
+
+$i = $n = 0;
+$failed = false;
+$tested_chars = array();
+
+$fp = fopen($phpbb_root_path . 'develop/NormalizationTest.txt', 'rb');
+while (!feof($fp))
+{
+ $line = fgets($fp);
+ ++$n;
+
+ if ($line[0] == '@')
+ {
+ if ($i)
+ {
+ echo "done\n";
+ }
+
+ $i = 0;
+ echo "\n", substr($line, 1), "\n\n";
+ continue;
+ }
+
+ if (!strpos(' 0123456789ABCDEF', $line[0]))
+ {
+ continue;
+ }
+
+ if (++$i % 100 == 0)
+ {
+ echo $i, ' ';
+ }
+
+ list($c1, $c2, $c3, $c4, $c5) = explode(';', $line);
+
+ if (!strpos($c1, ' '))
+ {
+ /**
+ * We are currently testing a single character, we add it to the list of
+ * characters we have processed so that we can exclude it when testing
+ * for invariants
+ */
+ $tested_chars[$c1] = 1;
+ }
+
+ foreach ($test_suite as $form => $serie)
+ {
+ foreach ($serie as $expected => $tests)
+ {
+ $hex_expected = ${$expected};
+ $utf_expected = hexseq_to_utf($hex_expected);
+
+ foreach ($tests as $test)
+ {
+ $utf_result = $utf_expected;
+ call_user_func(array('utf_normalizer', $form), $utf_result);
+
+ if (strcmp($utf_expected, $utf_result))
+ {
+ $failed = true;
+ $hex_result = utf_to_hexseq($utf_result);
+
+ echo "\nFAILED $expected == $form($test) ($hex_expected != $hex_result)";
+ }
+ }
+ }
+
+ if ($failed)
+ {
+ die("\n\nFailed at line $n\n");
+ }
+ }
+}
+fclose($fp);
+
+/**
+* Test for invariants
+*/
+echo "\n\nTesting for invariants...\n\n";
+
+$fp = fopen($phpbb_root_path . 'develop/UnicodeData.txt', 'rt');
+
+$n = 0;
+while (!feof($fp))
+{
+ if (++$n % 100 == 0)
+ {
+ echo $n, ' ';
+ }
+
+ $line = fgets($fp, 1024);
+
+ if (!$pos = strpos($line, ';'))
+ {
+ continue;
+ }
+
+ $hex_tested = $hex_expected = substr($line, 0, $pos);
+
+ if (isset($tested_chars[$hex_tested]))
+ {
+ continue;
+ }
+
+ $utf_expected = hex_to_utf($hex_expected);
+
+ if ($utf_expected >= UTF8_SURROGATE_FIRST
+ && $utf_expected <= UTF8_SURROGATE_LAST)
+ {
+ /**
+ * Surrogates are illegal on their own, we expect the normalizer
+ * to return a replacement char
+ */
+ $utf_expected = UTF8_REPLACEMENT;
+ $hex_expected = utf_to_hexseq($utf_expected);
+ }
+
+ foreach (array('nfc', 'nfkc', 'nfd', 'nfkd') as $form)
+ {
+ $utf_result = $utf_expected;
+ utf_normalizer::$form($utf_result);
+ $hex_result = utf_to_hexseq($utf_result);
+// echo "$form($utf_expected) == $utf_result\n";
+
+ if (strcmp($utf_expected, $utf_result))
+ {
+ $failed = 1;
+
+ echo "\nFAILED $hex_expected == $form($hex_tested) ($hex_expected != $hex_result)";
+ }
+ }
+
+ if ($failed)
+ {
+ die("\n\nFailed at line $n\n");
+ }
+}
+fclose($fp);
+
+die("\n\nALL TESTS PASSED SUCCESSFULLY\n");
+
+/**
+* Download a file to the develop/ dir
+*
+* @param string $url URL of the file to download
+* @return void
+*/
+function download($url)
+{
+ global $phpbb_root_path;
+
+ if (file_exists($phpbb_root_path . 'develop/' . basename($url)))
+ {
+ return;
+ }
+
+ echo 'Downloading from ', $url, ' ';
+
+ if (!$fpr = fopen($url, 'rb'))
+ {
+ die("Can't download from $url\nPlease download it yourself and put it in the develop/ dir, kthxbai");
+ }
+
+ if (!$fpw = fopen($phpbb_root_path . 'develop/' . basename($url), 'wb'))
+ {
+ die("Can't open develop/" . basename($url) . " for output... please check your permissions or something");
+ }
+
+ $i = 0;
+ $chunk = 32768;
+ $done = '';
+
+ while (!feof($fpr))
+ {
+ $i += fwrite($fpw, fread($fpr, $chunk));
+ echo str_repeat("\x08", strlen($done));
+
+ $done = ($i >> 10) . ' KiB';
+ echo $done;
+ }
+ fclose($fpr);
+ fclose($fpw);
+
+ echo "\n";
+}
+
+/**
+* Convert a UTF string to a sequence of codepoints in hexadecimal
+*
+* @param string $utf UTF string
+* @return integer Unicode codepoints in hex
+*/
+function utf_to_hexseq($str)
+{
+ $pos = 0;
+ $len = strlen($str);
+ $ret = array();
+
+ while ($pos < $len)
+ {
+ $c = $str[$pos];
+ switch ($c & "\xF0")
+ {
+ case "\xC0":
+ case "\xD0":
+ $utf_char = substr($str, $pos, 2);
+ $pos += 2;
+ break;
+
+ case "\xE0":
+ $utf_char = substr($str, $pos, 3);
+ $pos += 3;
+ break;
+
+ case "\xF0":
+ $utf_char = substr($str, $pos, 4);
+ $pos += 4;
+ break;
+
+ default:
+ $utf_char = $c;
+ ++$pos;
+ }
+
+ $hex = dechex(utf_to_cp($utf_char));
+
+ if (!isset($hex[3]))
+ {
+ $hex = substr('000' . $hex, -4);
+ }
+
+ $ret[] = $hex;
+ }
+
+ return strtr(implode(' ', $ret), 'abcdef', 'ABCDEF');
+}
+
+/**
+* Convert a UTF-8 char to its codepoint
+*
+* @param string $utf_char UTF-8 char
+* @return integer Unicode codepoint
+*/
+function utf_to_cp($utf_char)
+{
+ switch (strlen($utf_char))
+ {
+ case 1:
+ return ord($utf_char);
+
+ case 2:
+ return ((ord($utf_char[0]) & 0x1F) << 6) | (ord($utf_char[1]) & 0x3F);
+
+ case 3:
+ return ((ord($utf_char[0]) & 0x0F) << 12) | ((ord($utf_char[1]) & 0x3F) << 6) | (ord($utf_char[2]) & 0x3F);
+
+ case 4:
+ return ((ord($utf_char[0]) & 0x07) << 18) | ((ord($utf_char[1]) & 0x3F) << 12) | ((ord($utf_char[2]) & 0x3F) << 6) | (ord($utf_char[3]) & 0x3F);
+
+ default:
+ die('UTF-8 chars can only be 1-4 bytes long');
+ }
+}
+
+/**
+* Return a UTF string formed from a sequence of codepoints in hexadecimal
+*
+* @param string $seq Sequence of codepoints, separated with a space
+* @return string UTF-8 string
+*/
+function hexseq_to_utf($seq)
+{
+ return implode('', array_map('hex_to_utf', explode(' ', $seq)));
+}
+
+/**
+* Convert a codepoint in hexadecimal to a UTF-8 char
+*
+* @param string $hex Codepoint, in hexadecimal
+* @return string UTF-8 char
+*/
+function hex_to_utf($hex)
+{
+ return cp_to_utf(hexdec($hex));
+}
+
+/**
+* Convert a codepoint to a UTF-8 char
+*
+* @param integer $cp Unicode codepoint
+* @return string UTF-8 string
+*/
+function cp_to_utf($cp)
+{
+ if ($cp > 0xFFFF)
+ {
+ return chr(0xF0 | ($cp >> 18)) . chr(0x80 | (($cp >> 12) & 0x3F)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F));
+ }
+ else if ($cp > 0x7FF)
+ {
+ return chr(0xE0 | ($cp >> 12)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F));
+ }
+ else if ($cp > 0x7F)
+ {
+ return chr(0xC0 | ($cp >> 6)) . chr(0x80 | ($cp & 0x3F));
+ }
+ else
+ {
+ return chr($cp);
+ }
+} \ No newline at end of file