root / branches / phpBB-3_0_0 / phpBB / develop / adjust_smilies.php
History | View | Annotate | Download (2.7 kB)
| 1 | <?php
|
|---|---|
| 2 | /**
|
| 3 | * Updates smilies that were changed to the new ones |
| 4 | */ |
| 5 | die("Please read the first lines of this script for instructions on how to enable it"); |
| 6 | |
| 7 | set_time_limit(0); |
| 8 | |
| 9 | define('IN_PHPBB', true); |
| 10 | $phpbb_root_path = './../'; |
| 11 | $phpEx = substr(strrchr(__FILE__, '.'), 1); |
| 12 | include($phpbb_root_path . 'common.'.$phpEx); |
| 13 | |
| 14 | // Start session management
|
| 15 | $user->session_begin();
|
| 16 | $auth->acl($user->data); |
| 17 | $user->setup();
|
| 18 | |
| 19 | $echos = 0; |
| 20 | |
| 21 | $replace = array( |
| 22 | '<img src="{SMILIES_PATH}/icon_biggrin.gif',
|
| 23 | '<img src="{SMILIES_PATH}/icon_confused.gif',
|
| 24 | '<img src="{SMILIES_PATH}/icon_sad.gif',
|
| 25 | '<img src="{SMILIES_PATH}/icon_smile.gif',
|
| 26 | '<img src="{SMILIES_PATH}/icon_surprised.gif',
|
| 27 | '<img src="{SMILIES_PATH}/icon_wink.gif',
|
| 28 | ); |
| 29 | |
| 30 | $with = array( |
| 31 | '<img src="{SMILIES_PATH}/icon_e_biggrin.gif',
|
| 32 | '<img src="{SMILIES_PATH}/icon_e_confused.gif',
|
| 33 | '<img src="{SMILIES_PATH}/icon_e_sad.gif',
|
| 34 | '<img src="{SMILIES_PATH}/icon_e_smile.gif',
|
| 35 | '<img src="{SMILIES_PATH}/icon_e_surprised.gif',
|
| 36 | '<img src="{SMILIES_PATH}/icon_e_wink.gif',
|
| 37 | ); |
| 38 | |
| 39 | // Adjust user signatures
|
| 40 | $sql = 'SELECT user_id, user_sig |
| 41 | FROM ' . USERS_TABLE; |
| 42 | $result = $db->sql_query($sql); |
| 43 | |
| 44 | while ($row = $db->sql_fetchrow($result)) |
| 45 | {
|
| 46 | $new_content = str_replace($replace, $with, $row['user_sig']); |
| 47 | |
| 48 | if ($new_content != $row['user_sig']) |
| 49 | {
|
| 50 | $sql = 'UPDATE ' . USERS_TABLE . " SET user_sig = '" . $db->sql_escape($new_content) . "' |
| 51 | WHERE user_id = " . $row['user_id']; |
| 52 | $db->sql_query($sql); |
| 53 | |
| 54 | if ($echos > 200) |
| 55 | {
|
| 56 | echo '<br />' . "\n"; |
| 57 | $echos = 0; |
| 58 | } |
| 59 | |
| 60 | echo '.'; |
| 61 | $echos++;
|
| 62 | |
| 63 | flush();
|
| 64 | } |
| 65 | } |
| 66 | $db->sql_freeresult($result); |
| 67 | |
| 68 | |
| 69 | // Now adjust posts
|
| 70 | $sql = 'SELECT post_id, post_text |
| 71 | FROM ' . POSTS_TABLE; |
| 72 | $result = $db->sql_query($sql); |
| 73 | |
| 74 | while ($row = $db->sql_fetchrow($result)) |
| 75 | {
|
| 76 | $new_content = str_replace($replace, $with, $row['post_text']); |
| 77 | |
| 78 | if ($row['post_text'] != $new_content) |
| 79 | {
|
| 80 | $sql = 'UPDATE ' . POSTS_TABLE . " SET post_text = '" . $db->sql_escape($new_content) . "' |
| 81 | WHERE post_id = " . $row['post_id']; |
| 82 | $db->sql_query($sql); |
| 83 | |
| 84 | if ($echos > 200) |
| 85 | {
|
| 86 | echo '<br />' . "\n"; |
| 87 | $echos = 0; |
| 88 | } |
| 89 | |
| 90 | echo '.'; |
| 91 | $echos++;
|
| 92 | |
| 93 | flush();
|
| 94 | } |
| 95 | } |
| 96 | $db->sql_freeresult($result); |
| 97 | |
| 98 | // Now to the private messages
|
| 99 | $sql = 'SELECT msg_id, message_text |
| 100 | FROM ' . PRIVMSGS_TABLE; |
| 101 | $result = $db->sql_query($sql); |
| 102 | |
| 103 | while ($row = $db->sql_fetchrow($result)) |
| 104 | {
|
| 105 | $new_content = str_replace($replace, $with, $row['message_text']); |
| 106 | |
| 107 | if ($row['message_text'] != $new_content) |
| 108 | {
|
| 109 | $sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET bbcode_bitfield = '" . $db->sql_escape($new_content) . "' |
| 110 | WHERE msg_id = " . $row['msg_id']; |
| 111 | $db->sql_query($sql); |
| 112 | |
| 113 | if ($echos > 200) |
| 114 | {
|
| 115 | echo '<br />' . "\n"; |
| 116 | $echos = 0; |
| 117 | } |
| 118 | |
| 119 | echo '.'; |
| 120 | $echos++;
|
| 121 | |
| 122 | flush();
|
| 123 | } |
| 124 | } |
| 125 | $db->sql_freeresult($result); |
| 126 | |
| 127 | // Done
|
| 128 | $db->sql_close();
|
| 129 | |
| 130 | ?> |

