mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
Copy 3.0.x branch to trunk
git-svn-id: file:///svn/phpbb/trunk@10211 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
417
phpBB/develop/add_permissions.php
Normal file
417
phpBB/develop/add_permissions.php
Normal file
@@ -0,0 +1,417 @@
|
||||
<?php
|
||||
// -------------------------------------------------------------
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// FILENAME : add_permissions.php
|
||||
// STARTED : Sat Nov 06, 2004
|
||||
// COPYRIGHT : <20> 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);
|
||||
|
||||
}
|
||||
|
||||
?>
|
147
phpBB/develop/adjust_avatars.php
Normal file
147
phpBB/develop/adjust_avatars.php
Normal file
@@ -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;
|
||||
}
|
||||
|
||||
?>
|
174
phpBB/develop/adjust_bbcodes.php
Normal file
174
phpBB/develop/adjust_bbcodes.php
Normal file
@@ -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();
|
||||
|
||||
?>
|
126
phpBB/develop/adjust_magic_urls.php
Normal file
126
phpBB/develop/adjust_magic_urls.php
Normal file
@@ -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();
|
||||
|
||||
?>
|
132
phpBB/develop/adjust_sizes.php
Normal file
132
phpBB/develop/adjust_sizes.php
Normal file
@@ -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();
|
||||
|
||||
?>
|
130
phpBB/develop/adjust_smilies.php
Normal file
130
phpBB/develop/adjust_smilies.php
Normal file
@@ -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();
|
||||
|
||||
?>
|
129
phpBB/develop/adjust_uids.php
Normal file
129
phpBB/develop/adjust_uids.php
Normal file
@@ -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';
|
||||
?>
|
52
phpBB/develop/adjust_usernames.php
Normal file
52
phpBB/develop/adjust_usernames.php
Normal file
@@ -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();
|
||||
|
||||
?>
|
462
phpBB/develop/benchmark.php
Normal file
462
phpBB/develop/benchmark.php
Normal file
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
76
phpBB/develop/calc_email_hash.php
Normal file
76
phpBB/develop/calc_email_hash.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
// -------------------------------------------------------------
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// FILENAME : calc_email_hash.php
|
||||
// STARTED : Tue Feb 03, 2004
|
||||
// COPYRIGHT : <20> 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";
|
||||
|
||||
?>
|
62
phpBB/develop/change_smiley_ref.php
Normal file
62
phpBB/develop/change_smiley_ref.php
Normal file
@@ -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";
|
||||
|
||||
?>
|
3
phpBB/develop/collect_cache_stats.sh
Executable file
3
phpBB/develop/collect_cache_stats.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
DIR=$(dirname "$0")/../cache;
|
||||
cat "$DIR/sql_*.php" | grep '/* SELECT' | sed 's,/\* ,,;s, \*/,,' | sort
|
2048
phpBB/develop/create_schema_files.php
Normal file
2048
phpBB/develop/create_schema_files.php
Normal file
File diff suppressed because it is too large
Load Diff
547
phpBB/develop/create_variable_overview.php
Normal file
547
phpBB/develop/create_variable_overview.php
Normal file
@@ -0,0 +1,547 @@
|
||||
<?php
|
||||
// -------------------------------------------------------------
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// FILENAME : create_variable_overview.php
|
||||
// STARTED : Fri Aug 15 2003
|
||||
// COPYRIGHT : <20> 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> </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 © <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> -> <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> -> <b>' . $block_var[$_num] . '</b><br>' . "\n" : '<i>...which is an element of</i> -> <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> -> <b>' . $block_var[$_num] . '</b><br>' . "\n" : '<i>...which is an element of</i> -> <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> </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 © <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> </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 © <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();
|
||||
|
||||
?>
|
190
phpBB/develop/fill.php
Normal file
190
phpBB/develop/fill.php
Normal file
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
// -------------------------------------------------------------
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// FILENAME : fill.php
|
||||
// STARTED : Mon Sep 15, 2003
|
||||
// COPYRIGHT : <20> 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&' . 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 . '&' . 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&start=$start&" . 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)];
|
||||
}
|
||||
|
||||
?>
|
29
phpBB/develop/fix_files.sh
Executable file
29
phpBB/develop/fix_files.sh
Executable file
@@ -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
|
156
phpBB/develop/generate_utf_casefold.php
Normal file
156
phpBB/develop/generate_utf_casefold.php
Normal file
@@ -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";
|
||||
}
|
||||
|
||||
?>
|
240
phpBB/develop/generate_utf_confusables.php
Normal file
240
phpBB/develop/generate_utf_confusables.php
Normal file
@@ -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";
|
||||
}
|
||||
|
||||
?>
|
572
phpBB/develop/generate_utf_tables.php
Normal file
572
phpBB/develop/generate_utf_tables.php
Normal file
@@ -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);
|
||||
}
|
||||
}
|
140
phpBB/develop/lang_duplicates.php
Normal file
140
phpBB/develop/lang_duplicates.php
Normal file
@@ -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])) ? ' ' : "<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>
|
80
phpBB/develop/merge_attachment_tables.php
Normal file
80
phpBB/develop/merge_attachment_tables.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
// -------------------------------------------------------------
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// FILENAME : merge_attachment_tables.php
|
||||
// STARTED : Tue Nov 04, 2003
|
||||
// COPYRIGHT : <20> 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";
|
||||
|
||||
?>
|
209
phpBB/develop/merge_post_tables.php
Normal file
209
phpBB/develop/merge_post_tables.php
Normal file
@@ -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";
|
||||
|
||||
?>
|
1400
phpBB/develop/mysql_upgrader.php
Normal file
1400
phpBB/develop/mysql_upgrader.php
Normal file
File diff suppressed because it is too large
Load Diff
58
phpBB/develop/nuke-db.php
Normal file
58
phpBB/develop/nuke-db.php
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
83
phpBB/develop/regex.php
Normal file
83
phpBB/develop/regex.php
Normal file
@@ -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";
|
||||
|
||||
?>
|
151
phpBB/develop/repair_bots.php
Normal file
151
phpBB/develop/repair_bots.php
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
129
phpBB/develop/search_fill.php
Normal file
129
phpBB/develop/search_fill.php
Normal file
@@ -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>
|
120
phpBB/develop/unicode_testing.php
Normal file
120
phpBB/develop/unicode_testing.php
Normal file
@@ -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;
|
||||
}
|
||||
|
||||
?>
|
57
phpBB/develop/update_email_hash.php
Normal file
57
phpBB/develop/update_email_hash.php
Normal file
@@ -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();
|
||||
?>
|
391
phpBB/develop/utf_normalizer_test.php
Normal file
391
phpBB/develop/utf_normalizer_test.php
Normal file
@@ -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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user