root / branches / phpBB-3_0_0 / phpBB / develop / adjust_sizes.php
History | View | Annotate | Download (3.3 kB)
| 1 | 7170 | acydburn | <?php
|
|---|---|---|---|
| 2 | 7170 | acydburn | /**
|
| 3 | 7170 | acydburn | * Only adjust the [size] bbcode tag from pc to percent. |
| 4 | 7170 | acydburn | * |
| 5 | 7170 | acydburn | * You should make a backup from your users, posts and privmsgs table in case something goes wrong |
| 6 | 7170 | acydburn | * Forum descriptions and rules need to be re-submitted manually if they use the [size] tag. |
| 7 | 7170 | acydburn | * |
| 8 | 7170 | acydburn | * Since we limit the match to the sizes from 0 to 29 no newly applied sizes should be affected... |
| 9 | 7170 | acydburn | */ |
| 10 | 7170 | acydburn | die("Please read the first lines of this script for instructions on how to enable it"); |
| 11 | 7170 | acydburn | |
| 12 | 7170 | acydburn | set_time_limit(0); |
| 13 | 7170 | acydburn | @ini_set('memory_limit', '128M'); |
| 14 | 7170 | acydburn | |
| 15 | 7170 | acydburn | define('IN_PHPBB', true); |
| 16 | 7170 | acydburn | $phpbb_root_path = './../'; |
| 17 | 7170 | acydburn | $phpEx = substr(strrchr(__FILE__, '.'), 1); |
| 18 | 7170 | acydburn | include($phpbb_root_path . 'common.'.$phpEx); |
| 19 | 7170 | acydburn | |
| 20 | 7170 | acydburn | // Start session management
|
| 21 | 7170 | acydburn | $user->session_begin();
|
| 22 | 7170 | acydburn | $auth->acl($user->data); |
| 23 | 7170 | acydburn | $user->setup();
|
| 24 | 7170 | acydburn | |
| 25 | 7170 | acydburn | $echos = 0; |
| 26 | 7170 | acydburn | |
| 27 | 7172 | naderman | function replace_size($matches) |
| 28 | 7172 | naderman | {
|
| 29 | 7172 | naderman | return '[size=' . ceil(100.0 * (((double) $matches[1])/12.0)) . ':' . $matches[2] . ']'; |
| 30 | 7172 | naderman | } |
| 31 | 7172 | naderman | |
| 32 | 7170 | acydburn | // Adjust user signatures
|
| 33 | 7170 | acydburn | $sql = 'SELECT user_id, user_sig, user_sig_bbcode_uid |
| 34 | 7170 | acydburn | FROM ' . USERS_TABLE; |
| 35 | 7170 | acydburn | $result = $db->sql_query($sql); |
| 36 | 7170 | acydburn | |
| 37 | 7170 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 38 | 7170 | acydburn | {
|
| 39 | 7170 | acydburn | $bbcode_uid = $row['user_sig_bbcode_uid']; |
| 40 | 7170 | acydburn | |
| 41 | 7170 | acydburn | // Only if a bbcode uid is present, the signature present and a size tag used...
|
| 42 | 7170 | acydburn | if ($bbcode_uid && $row['user_sig'] && strpos($row['user_sig'], '[size=') !== false) |
| 43 | 7170 | acydburn | {
|
| 44 | 7183 | naderman | $row['user_sig'] = preg_replace_callback('/\[size=(\d*):(' . $bbcode_uid . ')\]/', 'replace_size', $row['user_sig']); |
| 45 | 7172 | naderman | |
| 46 | 7170 | acydburn | $sql = 'UPDATE ' . USERS_TABLE . " SET user_sig = '" . $db->sql_escape($row['user_sig']) . "' |
| 47 | 7170 | acydburn | WHERE user_id = " . $row['user_id']; |
| 48 | 7170 | acydburn | $db->sql_query($sql); |
| 49 | 7170 | acydburn | |
| 50 | 7170 | acydburn | if ($echos > 200) |
| 51 | 7170 | acydburn | {
|
| 52 | 7170 | acydburn | echo '<br />' . "\n"; |
| 53 | 7170 | acydburn | $echos = 0; |
| 54 | 7170 | acydburn | } |
| 55 | 7170 | acydburn | |
| 56 | 7170 | acydburn | echo '.'; |
| 57 | 7170 | acydburn | $echos++;
|
| 58 | 7170 | acydburn | |
| 59 | 7170 | acydburn | flush();
|
| 60 | 7170 | acydburn | } |
| 61 | 7170 | acydburn | } |
| 62 | 7170 | acydburn | $db->sql_freeresult($result); |
| 63 | 7170 | acydburn | |
| 64 | 7170 | acydburn | |
| 65 | 7170 | acydburn | // Now adjust posts
|
| 66 | 7170 | acydburn | $sql = 'SELECT post_id, post_text, bbcode_uid, enable_bbcode |
| 67 | 7170 | acydburn | FROM ' . POSTS_TABLE; |
| 68 | 7170 | acydburn | $result = $db->sql_query($sql); |
| 69 | 7170 | acydburn | |
| 70 | 7170 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 71 | 7170 | acydburn | {
|
| 72 | 7170 | acydburn | $bbcode_uid = $row['bbcode_uid']; |
| 73 | 7170 | acydburn | |
| 74 | 7170 | acydburn | // Only if a bbcode uid is present, bbcode enabled and a size tag used...
|
| 75 | 7170 | acydburn | if ($row['enable_bbcode'] && $bbcode_uid && strpos($row['post_text'], '[size=') !== false) |
| 76 | 7170 | acydburn | {
|
| 77 | 7172 | naderman | $row['post_text'] = preg_replace_callback('/\[size=(\d*):' . $bbcode_uid . '\]/', 'replace_size', $row['post_text']); |
| 78 | 7170 | acydburn | |
| 79 | 7170 | acydburn | $sql = 'UPDATE ' . POSTS_TABLE . " SET post_text = '" . $db->sql_escape($row['post_text']) . "' |
| 80 | 7170 | acydburn | WHERE post_id = " . $row['post_id']; |
| 81 | 7170 | acydburn | $db->sql_query($sql); |
| 82 | 7170 | acydburn | |
| 83 | 7170 | acydburn | if ($echos > 200) |
| 84 | 7170 | acydburn | {
|
| 85 | 7170 | acydburn | echo '<br />' . "\n"; |
| 86 | 7170 | acydburn | $echos = 0; |
| 87 | 7170 | acydburn | } |
| 88 | 7170 | acydburn | |
| 89 | 7170 | acydburn | echo '.'; |
| 90 | 7170 | acydburn | $echos++;
|
| 91 | 7170 | acydburn | |
| 92 | 7170 | acydburn | flush();
|
| 93 | 7170 | acydburn | } |
| 94 | 7170 | acydburn | } |
| 95 | 7170 | acydburn | $db->sql_freeresult($result); |
| 96 | 7170 | acydburn | |
| 97 | 7170 | acydburn | // Now to the private messages
|
| 98 | 7170 | acydburn | $sql = 'SELECT msg_id, message_text, bbcode_uid, enable_bbcode |
| 99 | 7170 | acydburn | FROM ' . PRIVMSGS_TABLE; |
| 100 | 7170 | acydburn | $result = $db->sql_query($sql); |
| 101 | 7170 | acydburn | |
| 102 | 7170 | acydburn | while ($row = $db->sql_fetchrow($result)) |
| 103 | 7170 | acydburn | {
|
| 104 | 7170 | acydburn | $bbcode_uid = $row['bbcode_uid']; |
| 105 | 7170 | acydburn | |
| 106 | 7170 | acydburn | // Only if a bbcode uid is present, bbcode enabled and a size tag used...
|
| 107 | 7170 | acydburn | if ($row['enable_bbcode'] && $bbcode_uid && strpos($row['message_text'], '[size=') !== false) |
| 108 | 7170 | acydburn | {
|
| 109 | 7172 | naderman | $row['message_text'] = preg_replace_callback('/\[size=(\d*):' . $bbcode_uid . '\]/', 'replace_size', $row['message_text']); |
| 110 | 7170 | acydburn | |
| 111 | 7170 | acydburn | $sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET message_text = '" . $db->sql_escape($row['message_text']) . "' |
| 112 | 7170 | acydburn | WHERE msg_id = " . $row['msg_id']; |
| 113 | 7170 | acydburn | $db->sql_query($sql); |
| 114 | 7170 | acydburn | |
| 115 | 7170 | acydburn | if ($echos > 200) |
| 116 | 7170 | acydburn | {
|
| 117 | 7170 | acydburn | echo '<br />' . "\n"; |
| 118 | 7170 | acydburn | $echos = 0; |
| 119 | 7170 | acydburn | } |
| 120 | 7170 | acydburn | |
| 121 | 7170 | acydburn | echo '.'; |
| 122 | 7170 | acydburn | $echos++;
|
| 123 | 7170 | acydburn | |
| 124 | 7170 | acydburn | flush();
|
| 125 | 7170 | acydburn | } |
| 126 | 7170 | acydburn | } |
| 127 | 7170 | acydburn | $db->sql_freeresult($result); |
| 128 | 7170 | acydburn | |
| 129 | 7170 | acydburn | // Done
|
| 130 | 7170 | acydburn | $db->sql_close();
|
| 131 | 7170 | acydburn | |
| 132 | 7170 | acydburn | ?> |

