diff options
author | Carlo <carlos94@tiscali.it> | 2012-08-28 10:02:27 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2012-11-09 12:10:53 +0100 |
commit | 53e9bab237470e827243fcf3743eb7ca3d9ee346 (patch) | |
tree | 5f9e9c6108acb9673a57b0cb9adba93dd75c28ee /phpBB/install/database_update.php | |
parent | 399662d2afa58dfd631128e3eac033d90464f794 (diff) | |
download | forums-53e9bab237470e827243fcf3743eb7ca3d9ee346.tar forums-53e9bab237470e827243fcf3743eb7ca3d9ee346.tar.gz forums-53e9bab237470e827243fcf3743eb7ca3d9ee346.tar.bz2 forums-53e9bab237470e827243fcf3743eb7ca3d9ee346.tar.xz forums-53e9bab237470e827243fcf3743eb7ca3d9ee346.zip |
[ticket/10897] Update bots during phpBB update
PHPBB3-10897
Diffstat (limited to 'phpBB/install/database_update.php')
-rw-r--r-- | phpBB/install/database_update.php | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 099ab6aeb5..0343e0dc86 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2119,6 +2119,76 @@ function change_database_data(&$no_updates, $version) AND module_basename = \'profile\' AND module_mode = \'signature\''; _sql($sql, $errored, $error_ary); + + $bots_to_update = array( + 'Baidu [Spider]' => array('Baiduspider', ''), + 'Exabot [Bot]' => array('Exabot', ''), + 'Voyager [Bot]' => array('voyager/', ''), + 'W3C [Validator]' => array('W3C_Validator', ''), + ); + + $bots_to_delete = array( + 'NG-Search [Bot]', + 'Nutch/CVS [Bot]', + 'OmniExplorer [Bot]', + 'Seekport [Bot]', + 'Synoo [Bot]', + 'WiseNut [Bot]', + ); + + foreach($bots_to_update as $bot_name => $bot_array) + { + list($bot_agent, $bot_ip) = $bot_array; + + $bot_name_clean = utf8_clean_string($bot_name); + + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . " + WHERE username_clean = '" . $db->sql_escape($bot_name_clean) . "'"; + $result = $db->sql_query($sql); + $is_user = (bool) $db->sql_fetchfield('user_id'); + $db->sql_freeresult($result); + + if ($is_user) + { + $sql = 'UPDATE ' . BOTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( + 'bot_agent' => (string) $bot_agent, + 'bot_ip' => (string) $bot_ip, + )) . " WHERE bot_name = '" . $db->sql_escape($bot_name) . "'"; + + _sql($sql, $errored, $error_ary); + } + } + + if (!function_exists('user_delete')) + { + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + } + + foreach($bots_to_delete as $bot_name) + { + $bot_name_clean = utf8_clean_string($bot_name); + + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . " + WHERE username_clean = '" . $db->sql_escape($bot_name_clean) . "'"; + $result = $db->sql_query($sql); + $bot_user_id = $db->sql_fetchfield('user_id'); + $is_user = (bool) $bot_user_id; + $db->sql_freeresult($result); + + if ($is_user) + { + $sql = 'DELETE FROM ' . BOTS_TABLE . " + WHERE bot_name = '" . $db->sql_escape($bot_name) . "'"; + + _sql($sql, $errored, $error_ary); + + user_delete('remove', $bot_user_id); + } + } + + $no_updates = false; break; } } |