replace constants with class constants.
[phpbb.git] / phpBB / develop / repair_bots.php
blob6d3e57da57d17af8389c543e9abe156b052c29e8
1 <?php
2 /**
3 * Rebuild BOTS
5 * You should make a backup from your whole database. Things can and will go wrong.
6 * This will only work if no BOTs were added.
8 */
9 die("Please read the first lines of this script for instructions on how to enable it");
11 set_time_limit(0);
13 define('IN_PHPBB', true);
14 define('PHPBB_ROOT_PATH', './../');
15 define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
16 include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT);
17 include(PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT);
20 // Start session management
21 $user->session_begin();
22 $auth->acl($user->data);
23 $user->setup();
25 $bots = array(
26 'AdsBot [Google]' => array('AdsBot-Google', ''),
27 'Alexa [Bot]' => array('ia_archiver', ''),
28 'Alta Vista [Bot]' => array('Scooter/', ''),
29 'Ask Jeeves [Bot]' => array('Ask Jeeves', ''),
30 'Baidu [Spider]' => array('Baiduspider+(', ''),
31 'Exabot [Bot]' => array('Exabot/', ''),
32 'FAST Enterprise [Crawler]' => array('FAST Enterprise Crawler', ''),
33 'FAST WebCrawler [Crawler]' => array('FAST-WebCrawler/', ''),
34 'Francis [Bot]' => array('http://www.neomo.de/', ''),
35 'Gigabot [Bot]' => array('Gigabot/', ''),
36 'Google Adsense [Bot]' => array('Mediapartners-Google', ''),
37 'Google Desktop' => array('Google Desktop', ''),
38 'Google Feedfetcher' => array('Feedfetcher-Google', ''),
39 'Google [Bot]' => array('Googlebot', ''),
40 'Heise IT-Markt [Crawler]' => array('heise-IT-Markt-Crawler', ''),
41 'Heritrix [Crawler]' => array('heritrix/1.', ''),
42 'IBM Research [Bot]' => array('ibm.com/cs/crawler', ''),
43 'ICCrawler - ICjobs' => array('ICCrawler - ICjobs', ''),
44 'ichiro [Crawler]' => array('ichiro/2', ''),
45 'Majestic-12 [Bot]' => array('MJ12bot/', ''),
46 'Metager [Bot]' => array('MetagerBot/', ''),
47 'MSN NewsBlogs' => array('msnbot-NewsBlogs/', ''),
48 'MSN [Bot]' => array('msnbot/', ''),
49 'MSNbot Media' => array('msnbot-media/', ''),
50 'NG-Search [Bot]' => array('NG-Search/', ''),
51 'Nutch [Bot]' => array('http://lucene.apache.org/nutch/', ''),
52 'Nutch/CVS [Bot]' => array('NutchCVS/', ''),
53 'OmniExplorer [Bot]' => array('OmniExplorer_Bot/', ''),
54 'Online link [Validator]' => array('online link validator', ''),
55 'psbot [Picsearch]' => array('psbot/0', ''),
56 'Seekport [Bot]' => array('Seekbot/', ''),
57 'Sensis [Crawler]' => array('Sensis Web Crawler', ''),
58 'SEO Crawler' => array('SEO search Crawler/', ''),
59 'Seoma [Crawler]' => array('Seoma [SEO Crawler]', ''),
60 'SEOSearch [Crawler]' => array('SEOsearch/', ''),
61 'Snappy [Bot]' => array('Snappy/1.1 ( http://www.urltrends.com/ )', ''),
62 'Steeler [Crawler]' => array('http://www.tkl.iis.u-tokyo.ac.jp/~crawler/', ''),
63 'Synoo [Bot]' => array('SynooBot/', ''),
64 'Telekom [Bot]' => array('crawleradmin.t-info@telekom.de', ''),
65 'TurnitinBot [Bot]' => array('TurnitinBot/', ''),
66 'Voyager [Bot]' => array('voyager/1.0', ''),
67 'W3 [Sitesearch]' => array('W3 SiteSearch Crawler', ''),
68 'W3C [Linkcheck]' => array('W3C-checklink/', ''),
69 'W3C [Validator]' => array('W3C_*Validator', ''),
70 'WiseNut [Bot]' => array('http://www.WISEnutbot.com', ''),
71 'YaCy [Bot]' => array('yacybot', ''),
72 'Yahoo MMCrawler [Bot]' => array('Yahoo-MMCrawler/', ''),
73 'Yahoo Slurp [Bot]' => array('Yahoo! DE Slurp', ''),
74 'Yahoo [Bot]' => array('Yahoo! Slurp', ''),
75 'YahooSeeker [Bot]' => array('YahooSeeker/', ''),
78 $bot_ids = array();
79 user_get_id_name($bot_ids, array_keys($bots), phpbb::USER_IGNORE);
80 foreach($bot_ids as $bot)
82 user_delete('remove', $bot);
84 // Done
85 add_bots($bots);
86 echo 'done';
89 /**
90 * Add the search bots into the database
91 * This code should be used in execute_last if the source database did not have bots
92 * If you are converting bots this function should not be called
93 * @todo We might want to look at sharing the bot list between the install code and this code for consistency
95 function add_bots($bots)
97 global $db, $config;
99 $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'BOTS'";
100 $result = $db->sql_query($sql);
101 $group_id = (int) $db->sql_fetchfield('group_id', $result);
102 $db->sql_freeresult($result);
103 $db->sql_query('TRUNCATE TABLE ' . BOTS_TABLE);
105 if (!$group_id)
107 add_default_groups();
109 $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " WHERE group_name = 'BOTS'";
110 $result = $db->sql_query($sql);
111 $group_id = (int) $db->sql_fetchfield('group_id', $result);
112 $db->sql_freeresult($result);
119 foreach ($bots as $bot_name => $bot_ary)
121 $user_row = array(
122 'user_type' => phpbb::USER_IGNORE,
123 'group_id' => $group_id,
124 'username' => $bot_name,
125 'user_regdate' => time(),
126 'user_password' => '',
127 'user_colour' => '9E8DA7',
128 'user_email' => '',
129 'user_lang' => $config['default_lang'],
130 'user_style' => 1,
131 'user_timezone' => 0,
132 'user_allow_massemail' => 0,
135 $user_id = user_add($user_row);
137 if ($user_id)
139 $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
140 'bot_active' => 1,
141 'bot_name' => $bot_name,
142 'user_id' => $user_id,
143 'bot_agent' => $bot_ary[0],
144 'bot_ip' => $bot_ary[1])
146 $db->sql_query($sql);