[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/phpbb/install/module/install_data/task/ -> add_bots.php (source)

   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\install\module\install_data\task;
  15  
  16  use phpbb\install\exception\resource_limit_reached_exception;
  17  
  18  class add_bots extends \phpbb\install\task_base
  19  {
  20      /**
  21       * A list of the web-crawlers/bots we recognise by default
  22       *
  23       * Candidates but not included:
  24       * 'Accoona [Bot]'                'Accoona-AI-Agent/'
  25       * 'ASPseek [Crawler]'            'ASPseek/'
  26       * 'Boitho [Crawler]'            'boitho.com-dc/'
  27       * 'Bunnybot [Bot]'                'powered by www.buncat.de'
  28       * 'Cosmix [Bot]'                'cfetch/'
  29       * 'Crawler Search [Crawler]'    '.Crawler-Search.de'
  30       * 'Findexa [Crawler]'            'Findexa Crawler ('
  31       * 'GBSpider [Spider]'            'GBSpider v'
  32       * 'genie [Bot]'                'genieBot ('
  33       * 'Hogsearch [Bot]'            'oegp v. 1.3.0'
  34       * 'Insuranco [Bot]'            'InsurancoBot'
  35       * 'IRLbot [Bot]'                'http://irl.cs.tamu.edu/crawler'
  36       * 'ISC Systems [Bot]'            'ISC Systems iRc Search'
  37       * 'Jyxobot [Bot]'                'Jyxobot/'
  38       * 'Kraehe [Metasuche]'            '-DIE-KRAEHE- META-SEARCH-ENGINE/'
  39       * 'LinkWalker'                    'LinkWalker'
  40       * 'MMSBot [Bot]'                'http://www.mmsweb.at/bot.html'
  41       * 'Naver [Bot]'                'nhnbot@naver.com)'
  42       * 'NetResearchServer'            'NetResearchServer/'
  43       * 'Nimble [Crawler]'            'NimbleCrawler'
  44       * 'Ocelli [Bot]'                'Ocelli/'
  45       * 'Onsearch [Bot]'                'onCHECK-Robot'
  46       * 'Orange [Spider]'            'OrangeSpider'
  47       * 'Sproose [Bot]'                'http://www.sproose.com/bot'
  48       * 'Susie [Sync]'                '!Susie (http://www.sync2it.com/susie)'
  49       * 'Tbot [Bot]'                    'Tbot/'
  50       * 'Thumbshots [Capture]'        'thumbshots-de-Bot'
  51       * 'Vagabondo [Crawler]'        'http://webagent.wise-guys.nl/'
  52       * 'Walhello [Bot]'                'appie 1.1 (www.walhello.com)'
  53       * 'WissenOnline [Bot]'            'WissenOnline-Bot'
  54       * 'WWWeasel [Bot]'                'WWWeasel Robot v'
  55       * 'Xaldon [Spider]'            'Xaldon WebSpider'
  56       *
  57       * @var array
  58       */
  59      protected $bot_list = array(
  60          'AdsBot [Google]'            => array('AdsBot-Google', ''),
  61          'Ahrefs [Bot]'                => array('AhrefsBot/', ''),
  62          'Alexa [Bot]'                => array('ia_archiver', ''),
  63          'Alta Vista [Bot]'            => array('Scooter/', ''),
  64          'Amazon [Bot]'                => array('Amazonbot/', ''),
  65          'Ask Jeeves [Bot]'            => array('Ask Jeeves', ''),
  66          'Baidu [Spider]'            => array('Baiduspider', ''),
  67          'Bing [Bot]'                => array('bingbot/', ''),
  68          'DuckDuckGo [Bot]'            => array('DuckDuckBot/', ''),
  69          'Exabot [Bot]'                => array('Exabot/', ''),
  70          'FAST Enterprise [Crawler]'    => array('FAST Enterprise Crawler', ''),
  71          'FAST WebCrawler [Crawler]'    => array('FAST-WebCrawler/', ''),
  72          'Francis [Bot]'                => array('http://www.neomo.de/', ''),
  73          'Gigabot [Bot]'                => array('Gigabot/', ''),
  74          'Google Adsense [Bot]'        => array('Mediapartners-Google', ''),
  75          'Google Desktop'            => array('Google Desktop', ''),
  76          'Google Feedfetcher'        => array('Feedfetcher-Google', ''),
  77          'Google [Bot]'                => array('Googlebot', ''),
  78          'Heise IT-Markt [Crawler]'    => array('heise-IT-Markt-Crawler', ''),
  79          'Heritrix [Crawler]'        => array('heritrix/1.', ''),
  80          'IBM Research [Bot]'        => array('ibm.com/cs/crawler', ''),
  81          'ICCrawler - ICjobs'        => array('ICCrawler - ICjobs', ''),
  82          'ichiro [Crawler]'            => array('ichiro/', ''),
  83          'Majestic-12 [Bot]'            => array('MJ12bot/', ''),
  84          'Metager [Bot]'                => array('MetagerBot/', ''),
  85          'MSN NewsBlogs'                => array('msnbot-NewsBlogs/', ''),
  86          'MSN [Bot]'                    => array('msnbot/', ''),
  87          'MSNbot Media'                => array('msnbot-media/', ''),
  88          'NG-Search [Bot]'            => array('NG-Search/', ''),
  89          'Nutch [Bot]'                => array('http://lucene.apache.org/nutch/', ''),
  90          'Nutch/CVS [Bot]'            => array('NutchCVS/', ''),
  91          'OmniExplorer [Bot]'        => array('OmniExplorer_Bot/', ''),
  92          'Online link [Validator]'    => array('online link validator', ''),
  93          'psbot [Picsearch]'            => array('psbot/0', ''),
  94          'Seekport [Bot]'            => array('Seekbot/', ''),
  95          'Semrush [Bot]'                => array('SemrushBot/', ''),
  96          'Sensis [Crawler]'            => array('Sensis Web Crawler', ''),
  97          'SEO Crawler'                => array('SEO search Crawler/', ''),
  98          'Seoma [Crawler]'            => array('Seoma [SEO Crawler]', ''),
  99          'SEOSearch [Crawler]'        => array('SEOsearch/', ''),
 100          'Snappy [Bot]'                => array('Snappy/1.1 ( http://www.urltrends.com/ )', ''),
 101          'Steeler [Crawler]'            => array('http://www.tkl.iis.u-tokyo.ac.jp/~crawler/', ''),
 102          'Synoo [Bot]'                => array('SynooBot/', ''),
 103          'Telekom [Bot]'                => array('crawleradmin.t-info@telekom.de', ''),
 104          'TurnitinBot [Bot]'            => array('TurnitinBot/', ''),
 105          'Voyager [Bot]'                => array('voyager/', ''),
 106          'W3 [Sitesearch]'            => array('W3 SiteSearch Crawler', ''),
 107          'W3C [Linkcheck]'            => array('W3C-checklink/', ''),
 108          'W3C [Validator]'            => array('W3C_*Validator', ''),
 109          'WiseNut [Bot]'                => array('http://www.WISEnutbot.com', ''),
 110          'YaCy [Bot]'                => array('yacybot', ''),
 111          'Yahoo MMCrawler [Bot]'        => array('Yahoo-MMCrawler/', ''),
 112          'Yahoo Slurp [Bot]'            => array('Yahoo! DE Slurp', ''),
 113          'Yahoo [Bot]'                => array('Yahoo! Slurp', ''),
 114          'YahooSeeker [Bot]'            => array('YahooSeeker/', ''),
 115      );
 116  
 117      /**
 118       * @var \phpbb\db\driver\driver_interface
 119       */
 120      protected $db;
 121  
 122      /**
 123       * @var \phpbb\install\helper\config
 124       */
 125      protected $install_config;
 126  
 127      /**
 128       * @var \phpbb\install\helper\iohandler\iohandler_interface
 129       */
 130      protected $io_handler;
 131  
 132      /**
 133       * @var \phpbb\language\language
 134       */
 135      protected $language;
 136  
 137      /**
 138       * @var string
 139       */
 140      protected $phpbb_root_path;
 141  
 142      /**
 143       * @var string
 144       */
 145      protected $php_ext;
 146  
 147      /**
 148       * Constructor
 149       *
 150       * @param \phpbb\install\helper\config                            $install_config        Installer's config
 151       * @param \phpbb\install\helper\iohandler\iohandler_interface    $iohandler            Input-output handler for the installer
 152       * @param \phpbb\install\helper\container_factory                $container            Installer's DI container
 153       * @param \phpbb\language\language                                $language            Language provider
 154       * @param string                                                $phpbb_root_path    Relative path to phpBB root
 155       * @param string                                                $php_ext            PHP extension
 156       */
 157  	public function __construct(\phpbb\install\helper\config $install_config,
 158                                  \phpbb\install\helper\iohandler\iohandler_interface $iohandler,
 159                                  \phpbb\install\helper\container_factory $container,
 160                                  \phpbb\language\language $language,
 161                                  $phpbb_root_path,
 162                                  $php_ext)
 163      {
 164          parent::__construct(true);
 165  
 166          $this->db                = $container->get('dbal.conn');
 167          $this->install_config    = $install_config;
 168          $this->io_handler        = $iohandler;
 169          $this->language            = $language;
 170          $this->phpbb_root_path    = $phpbb_root_path;
 171          $this->php_ext            = $php_ext;
 172      }
 173  
 174      /**
 175       * {@inheritdoc}
 176       */
 177  	public function run()
 178      {
 179          $this->db->sql_return_on_error(true);
 180  
 181          $sql = 'SELECT group_id
 182              FROM ' . GROUPS_TABLE . "
 183              WHERE group_name = 'BOTS'";
 184          $result = $this->db->sql_query($sql);
 185          $group_id = (int) $this->db->sql_fetchfield('group_id');
 186          $this->db->sql_freeresult($result);
 187  
 188          if (!$group_id)
 189          {
 190              // If we reach this point then something has gone very wrong
 191              $this->io_handler->add_error_message('NO_GROUP');
 192          }
 193  
 194          $i = $this->install_config->get('add_bot_index', 0);
 195          $bot_list = array_slice($this->bot_list, $i);
 196  
 197          foreach ($bot_list as $bot_name => $bot_ary)
 198          {
 199              $user_row = array(
 200                  'user_type'                => USER_IGNORE,
 201                  'group_id'                => $group_id,
 202                  'username'                => $bot_name,
 203                  'user_regdate'            => time(),
 204                  'user_password'            => '',
 205                  'user_colour'            => '9E8DA7',
 206                  'user_email'            => '',
 207                  'user_lang'                => $this->install_config->get('default_lang'),
 208                  'user_style'            => 1,
 209                  'user_timezone'            => 'UTC',
 210                  'user_dateformat'        => $this->language->lang('default_dateformat'),
 211                  'user_allow_massemail'    => 0,
 212                  'user_allow_pm'            => 0,
 213              );
 214  
 215              if (!function_exists('user_add'))
 216              {
 217                  include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
 218              }
 219  
 220              $user_id = user_add($user_row);
 221  
 222              if (!$user_id)
 223              {
 224                  // If we can't insert this user then continue to the next one to avoid inconsistent data
 225                  $this->io_handler->add_error_message('CONV_ERROR_INSERT_BOT');
 226  
 227                  $i++;
 228                  continue;
 229              }
 230  
 231              $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array(
 232                  'bot_active'    => 1,
 233                  'bot_name'        => (string) $bot_name,
 234                  'user_id'        => (int) $user_id,
 235                  'bot_agent'        => (string) $bot_ary[0],
 236                  'bot_ip'        => (string) $bot_ary[1],
 237              ));
 238  
 239              $this->db->sql_query($sql);
 240  
 241              $i++;
 242  
 243              // Stop execution if resource limit is reached
 244              if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0)
 245              {
 246                  break;
 247              }
 248          }
 249  
 250          $this->install_config->set('add_bot_index', $i);
 251  
 252          if ($i < count($this->bot_list))
 253          {
 254              throw new resource_limit_reached_exception();
 255          }
 256      }
 257  
 258      /**
 259       * {@inheritdoc}
 260       */
 261  	static public function get_step_count()
 262      {
 263          return 1;
 264      }
 265  
 266      /**
 267       * {@inheritdoc}
 268       */
 269  	public function get_task_lang_name()
 270      {
 271          return 'TASK_ADD_BOTS';
 272      }
 273  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1