diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2007-03-11 15:50:54 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2007-03-11 15:50:54 +0000 |
commit | 70ab9ac72a766f6931371701b5e2c44d95d4e163 (patch) | |
tree | 92d3a936989c132c96d82d151b84a0100c029b82 | |
parent | 3e7ca0bd9fd2ca8d5df5c9436cb08649f6c2f8dc (diff) | |
download | forums-70ab9ac72a766f6931371701b5e2c44d95d4e163.tar forums-70ab9ac72a766f6931371701b5e2c44d95d4e163.tar.gz forums-70ab9ac72a766f6931371701b5e2c44d95d4e163.tar.bz2 forums-70ab9ac72a766f6931371701b5e2c44d95d4e163.tar.xz forums-70ab9ac72a766f6931371701b5e2c44d95d4e163.zip |
script for adjusting [size] tags for already posted signatures, posts and private messages
git-svn-id: file:///svn/phpbb/trunk@7170 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r-- | phpBB/develop/adjust_sizes.php | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/phpBB/develop/adjust_sizes.php b/phpBB/develop/adjust_sizes.php new file mode 100644 index 0000000000..e5d28a14b9 --- /dev/null +++ b/phpBB/develop/adjust_sizes.php @@ -0,0 +1,133 @@ +<?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; + +// 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) + { + $match_size = array('/\[size=[0-7]:' . $bbcode_uid . '\]/', '/\[size=[8-9]:' . $bbcode_uid . '\]/', '/\[size=1[0-2]:' . $bbcode_uid . '\]/', '/\[size=1[3-8]:' . $bbcode_uid . '\]/', '/\[size=(?:[2][0-9]|19):' . $bbcode_uid . '\]/'); + $replace_size = array('[size=50:' . $bbcode_uid . ']', '[size=85:' . $bbcode_uid . ']', '[size=100:' . $bbcode_uid . ']', '[size=150:' . $bbcode_uid . ']', '[size=200:' . $bbcode_uid . ']'); + $row['user_sig'] = preg_replace($match_size, $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) + { + $match_size = array('/\[size=[0-7]:' . $bbcode_uid . '\]/', '/\[size=[8-9]:' . $bbcode_uid . '\]/', '/\[size=1[0-2]:' . $bbcode_uid . '\]/', '/\[size=1[3-8]:' . $bbcode_uid . '\]/', '/\[size=(?:[2][0-9]|19):' . $bbcode_uid . '\]/'); + $replace_size = array('[size=50:' . $bbcode_uid . ']', '[size=85:' . $bbcode_uid . ']', '[size=100:' . $bbcode_uid . ']', '[size=150:' . $bbcode_uid . ']', '[size=200:' . $bbcode_uid . ']'); + $row['post_text'] = preg_replace($match_size, $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) + { + $match_size = array('/\[size=[0-7]:' . $bbcode_uid . '\]/', '/\[size=[8-9]:' . $bbcode_uid . '\]/', '/\[size=1[0-2]:' . $bbcode_uid . '\]/', '/\[size=1[3-8]:' . $bbcode_uid . '\]/', '/\[size=(?:[2][0-9]|19):' . $bbcode_uid . '\]/'); + $replace_size = array('[size=50:' . $bbcode_uid . ']', '[size=85:' . $bbcode_uid . ']', '[size=100:' . $bbcode_uid . ']', '[size=150:' . $bbcode_uid . ']', '[size=200:' . $bbcode_uid . ']'); + $row['message_text'] = preg_replace($match_size, $replace_size, $row['message_text']); + + $sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET message_text = '" . $db->sql_escape($row['message_text']) . "' + WHERE msg_id = " . $row['msg_id']; + $db->sql_query($sql); + + if ($echos > 200) + { + echo '<br />' . "\n"; + $echos = 0; + } + + echo '.'; + $echos++; + + flush(); + } +} +$db->sql_freeresult($result); + +// Done +$db->sql_close(); + +?>
\ No newline at end of file |