aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/install/database_update.php
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2012-11-09 12:59:05 +0100
committerAndreas Fischer <bantu@phpbb.com>2012-11-09 13:40:48 +0100
commit60ea1c10ef0038fdb00fd38253d4b7407215e699 (patch)
treef7ea2c297a8014816ec34874ae94b5c1194e79bb /phpBB/install/database_update.php
parent54700f5ba24fe944616e017c3c2ff9c09c312445 (diff)
downloadforums-60ea1c10ef0038fdb00fd38253d4b7407215e699.tar
forums-60ea1c10ef0038fdb00fd38253d4b7407215e699.tar.gz
forums-60ea1c10ef0038fdb00fd38253d4b7407215e699.tar.bz2
forums-60ea1c10ef0038fdb00fd38253d4b7407215e699.tar.xz
forums-60ea1c10ef0038fdb00fd38253d4b7407215e699.zip
[ticket/10897] Combine bot updates and bot delete.
PHPBB3-10897
Diffstat (limited to 'phpBB/install/database_update.php')
-rw-r--r--phpBB/install/database_update.php71
1 files changed, 31 insertions, 40 deletions
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index b8bf85e283..f7980ab1be 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -2120,49 +2120,30 @@ function change_database_data(&$no_updates, $version)
AND module_mode = \'signature\'';
_sql($sql, $errored, $error_ary);
- // Update bot list
- // Bot name to bot user agent map
- $bots_to_update = array(
- 'Baidu [Spider]' => 'Baiduspider',
- 'Exabot [Bot]' => 'Exabot',
- 'Voyager [Bot]' => 'voyager/',
- 'W3C [Validator]' => 'W3C_Validator',
- );
-
- foreach ($bots_to_update 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)
- {
- $sql = 'UPDATE ' . BOTS_TABLE . '
- SET bot_agent = ' . $db->sql_escape($bot_agent) . "
- WHERE user_id = $bot_user_id";
- _sql($sql, $errored, $error_ary);
- }
- }
-
+ // Update bots
if (!function_exists('user_delete'))
{
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
}
- $bots_to_delete = array(
- 'NG-Search [Bot]',
- 'Nutch/CVS [Bot]',
- 'OmniExplorer [Bot]',
- 'Seekport [Bot]',
- 'Synoo [Bot]',
- 'WiseNut [Bot]',
+ $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_to_delete as $bot_name)
+ foreach ($bots_updates as $bot_name => $bot_agent)
{
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . '
@@ -2174,11 +2155,21 @@ function change_database_data(&$no_updates, $version)
if ($bot_user_id)
{
- $sql = 'DELETE FROM ' . BOTS_TABLE . "
- WHERE user_id = $bot_user_id";
- _sql($sql, $errored, $error_ary);
+ 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);
+ 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);
+ }
}
}