1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-24 12:03:21 +01:00
php-phpbb/phpBB/develop/adjust_smilies.php
Meik Sievertsen 2f4a618900 ok... i hope i haven't messed too much with the code and everything is still working.
Changes:
- Ascraeus now uses constants for the phpbb root path and the php extension. This ensures more security for external applications and modifications (no more overwriting of root path and extension possible through insecure mods and register globals enabled) as well as no more globalizing needed.
- A second change implemented here is an additional short-hand-notation for append_sid(). It is allowed to omit the root path and extension now (for example calling append_sid('memberlist')) - in this case the root path and extension get added automatically. The hook is called after these are added.

git-svn-id: file:///svn/phpbb/trunk@8572 89ea8834-ac86-4346-8a33-228a782c2dd0
2008-05-29 12:25:56 +00:00

130 lines
2.7 KiB
PHP

<?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);
define('PHPBB_ROOT_PATH', './../');
define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT);
// 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();
?>