[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 namespace phpbb\db\migration\data\v310; 15 16 class bot_update extends \phpbb\db\migration\migration 17 { 18 static public function depends_on() 19 { 20 return array('\phpbb\db\migration\data\v310\rc6'); 21 } 22 23 public function update_data() 24 { 25 return array( 26 array('custom', array(array(&$this, 'update_bing_bot'))), 27 array('custom', array(array(&$this, 'update_bots'))), 28 ); 29 } 30 31 public function update_bing_bot() 32 { 33 $bot_name = 'Bing [Bot]'; 34 $bot_name_clean = utf8_clean_string($bot_name); 35 36 $sql = 'SELECT user_id 37 FROM ' . USERS_TABLE . " 38 WHERE username_clean = '" . $this->db->sql_escape($bot_name_clean) . "'"; 39 $result = $this->db->sql_query($sql); 40 $bing_already_added = (bool) $this->db->sql_fetchfield('user_id'); 41 $this->db->sql_freeresult($result); 42 43 if (!$bing_already_added) 44 { 45 $bot_agent = 'bingbot/'; 46 $bot_ip = ''; 47 $sql = 'SELECT group_id, group_colour 48 FROM ' . GROUPS_TABLE . " 49 WHERE group_name = 'BOTS'"; 50 $result = $this->db->sql_query($sql); 51 $group_row = $this->db->sql_fetchrow($result); 52 $this->db->sql_freeresult($result); 53 54 if (!$group_row) 55 { 56 // default fallback, should never get here 57 $group_row['group_id'] = 6; 58 $group_row['group_colour'] = '9E8DA7'; 59 } 60 61 if (!function_exists('user_add')) 62 { 63 include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); 64 } 65 66 $user_row = array( 67 'user_type' => USER_IGNORE, 68 'group_id' => $group_row['group_id'], 69 'username' => $bot_name, 70 'user_regdate' => time(), 71 'user_password' => '', 72 'user_colour' => $group_row['group_colour'], 73 'user_email' => '', 74 'user_lang' => $this->config['default_lang'], 75 'user_style' => $this->config['default_style'], 76 'user_timezone' => 0, 77 'user_dateformat' => $this->config['default_dateformat'], 78 'user_allow_massemail' => 0, 79 ); 80 81 $user_id = user_add($user_row); 82 83 $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array( 84 'bot_active' => 1, 85 'bot_name' => (string) $bot_name, 86 'user_id' => (int) $user_id, 87 'bot_agent' => (string) $bot_agent, 88 'bot_ip' => (string) $bot_ip, 89 )); 90 91 $this->sql_query($sql); 92 } 93 } 94 95 public function update_bots() 96 { 97 // Update bots 98 if (!function_exists('user_delete')) 99 { 100 include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); 101 } 102 103 $bots_updates = array( 104 // Bot Deletions 105 'NG-Search [Bot]' => false, 106 'Nutch/CVS [Bot]' => false, 107 'OmniExplorer [Bot]' => false, 108 'Seekport [Bot]' => false, 109 'Synoo [Bot]' => false, 110 'WiseNut [Bot]' => false, 111 112 // Bot Updates 113 // Bot name to bot user agent map 114 'Baidu [Spider]' => 'Baiduspider', 115 'Exabot [Bot]' => 'Exabot', 116 'Voyager [Bot]' => 'voyager/', 117 'W3C [Validator]' => 'W3C_Validator', 118 ); 119 120 foreach ($bots_updates as $bot_name => $bot_agent) 121 { 122 $sql = 'SELECT user_id 123 FROM ' . USERS_TABLE . ' 124 WHERE user_type = ' . USER_IGNORE . " 125 AND username_clean = '" . $this->db->sql_escape(utf8_clean_string($bot_name)) . "'"; 126 $result = $this->db->sql_query($sql); 127 $bot_user_id = (int) $this->db->sql_fetchfield('user_id'); 128 $this->db->sql_freeresult($result); 129 130 if ($bot_user_id) 131 { 132 if ($bot_agent === false) 133 { 134 $sql = 'DELETE FROM ' . BOTS_TABLE . " 135 WHERE user_id = $bot_user_id"; 136 $this->sql_query($sql); 137 138 user_delete('retain', $bot_user_id); 139 } 140 else 141 { 142 $sql = 'UPDATE ' . BOTS_TABLE . " 143 SET bot_agent = '" . $this->db->sql_escape($bot_agent) . "' 144 WHERE user_id = $bot_user_id"; 145 $this->sql_query($sql); 146 } 147 } 148 } 149 } 150 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |