diff options
| author | Oleg Pudeyev <oleg@bsdpower.com> | 2012-11-09 09:22:33 -0500 |
|---|---|---|
| committer | Oleg Pudeyev <oleg@bsdpower.com> | 2012-11-09 09:22:33 -0500 |
| commit | 646d5ef3afd4c6718ff18516c48c9373bccf9ce5 (patch) | |
| tree | af29f7864dbd0aa4eb272940e1a6f645833bfc4b /phpBB/install/database_update.php | |
| parent | 0282fe7024f4cb001d635ebebd98dfdf9af747e8 (diff) | |
| parent | 100acddf55817b400d1d0ef1a34eebcab290ebc8 (diff) | |
| download | forums-646d5ef3afd4c6718ff18516c48c9373bccf9ce5.tar forums-646d5ef3afd4c6718ff18516c48c9373bccf9ce5.tar.gz forums-646d5ef3afd4c6718ff18516c48c9373bccf9ce5.tar.bz2 forums-646d5ef3afd4c6718ff18516c48c9373bccf9ce5.tar.xz forums-646d5ef3afd4c6718ff18516c48c9373bccf9ce5.zip | |
Merge PR #1042 branch 'develop-olympus' into develop
* develop-olympus:
[ticket/10897] Combine bot updates and bot delete.
[ticket/10897] Use same code/query for deleting.
[ticket/10897] Make sure the user we're fetching is a bot.
[ticket/10897] Do not handle IP address. There is no need.
[ticket/10897] Update by user_id instead of bot_name.
[ticket/10897] Move bot delete data to the relevant foreach loop.
[ticket/10897] Add comment about what's going on.
[ticket/10897] Remove unnecessary string casting.
[ticket/10897] Add space after foreach.
[ticket/10897] Update bots during phpBB update
[ticket/10897] Bot list updated
Diffstat (limited to 'phpBB/install/database_update.php')
| -rw-r--r-- | phpBB/install/database_update.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 8cd07b64c6..d83187abe3 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2260,6 +2260,61 @@ function change_database_data(&$no_updates, $version) AND module_basename = \'profile\' AND module_mode = \'signature\''; _sql($sql, $errored, $error_ary); + + // Update bots + if (!function_exists('user_delete')) + { + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + } + + $bots_updates = array( + // Bot Deletions + 'NG-Search [Bot]' => false, + 'Nutch/CVS [Bot]' => false, + 'OmniExplorer [Bot]' => false, + 'Seekport [Bot]' => false, + 'Synoo [Bot]' => false, + 'WiseNut [Bot]' => false, + + // Bot Updates + // Bot name to bot user agent map + 'Baidu [Spider]' => 'Baiduspider', + 'Exabot [Bot]' => 'Exabot', + 'Voyager [Bot]' => 'voyager/', + 'W3C [Validator]' => 'W3C_Validator', + ); + + foreach ($bots_updates as $bot_name => $bot_agent) + { + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . ' + WHERE user_type = ' . USER_IGNORE . " + AND username_clean = '" . $db->sql_escape(utf8_clean_string($bot_name)) . "'"; + $result = $db->sql_query($sql); + $bot_user_id = (int) $db->sql_fetchfield('user_id'); + $db->sql_freeresult($result); + + if ($bot_user_id) + { + if ($bot_agent === false) + { + $sql = 'DELETE FROM ' . BOTS_TABLE . " + WHERE user_id = $bot_user_id"; + _sql($sql, $errored, $error_ary); + + user_delete('remove', $bot_user_id); + } + else + { + $sql = 'UPDATE ' . BOTS_TABLE . " + SET bot_agent = '" . $db->sql_escape($bot_agent) . "' + WHERE user_id = $bot_user_id"; + _sql($sql, $errored, $error_ary); + } + } + } + + $no_updates = false; break; // Changes from 3.1.0-dev to 3.1.0-A1 |
