[ Index ]

PHP Cross Reference of phpBB-3.3.2-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          'Alexa [Bot]'                => array('ia_archiver', ''),
  62          'Alta Vista [Bot]'            => array('Scooter/', ''),
  63          'Ask Jeeves [Bot]'            => array('Ask Jeeves', ''),
  64          'Baidu [Spider]'            => array('Baiduspider', ''),
  65          'Bing [Bot]'                => array('bingbot/', ''),
  66          'DuckDuckGo [Bot]'            => array('DuckDuckBot/', ''),
  67          'Exabot [Bot]'                => array('Exabot', ''),
  68          'FAST Enterprise [Crawler]'    => array('FAST Enterprise Crawler', ''),
  69          'FAST WebCrawler [Crawler]'    => array('FAST-WebCrawler/', ''),
  70          'Francis [Bot]'                => array('http://www.neomo.de/', ''),
  71          'Gigabot [Bot]'                => array('Gigabot/', ''),
  72          'Google Adsense [Bot]'        => array('Mediapartners-Google', ''),
  73          'Google Desktop'            => array('Google Desktop', ''),
  74          'Google Feedfetcher'        => array('Feedfetcher-Google', ''),
  75          'Google [Bot]'                => array('Googlebot', ''),
  76          'Heise IT-Markt [Crawler]'    => array('heise-IT-Markt-Crawler', ''),
  77          'Heritrix [Crawler]'        => array('heritrix/1.', ''),
  78          'IBM Research [Bot]'        => array('ibm.com/cs/crawler', ''),
  79          'ICCrawler - ICjobs'        => array('ICCrawler - ICjobs', ''),
  80          'ichiro [Crawler]'            => array('ichiro/', ''),
  81          'Majestic-12 [Bot]'            => array('MJ12bot/', ''),
  82          'Metager [Bot]'                => array('MetagerBot/', ''),
  83          'MSN NewsBlogs'                => array('msnbot-NewsBlogs/', ''),
  84          'MSN [Bot]'                    => array('msnbot/', ''),
  85          'MSNbot Media'                => array('msnbot-media/', ''),
  86          'Nutch [Bot]'                => array('http://lucene.apache.org/nutch/', ''),
  87          'Online link [Validator]'    => array('online link validator', ''),
  88          'psbot [Picsearch]'            => array('psbot/0', ''),
  89          'Sensis [Crawler]'            => array('Sensis Web Crawler', ''),
  90          'SEO Crawler'                => array('SEO search Crawler/', ''),
  91          'Seoma [Crawler]'            => array('Seoma [SEO Crawler]', ''),
  92          'SEOSearch [Crawler]'        => array('SEOsearch/', ''),
  93          'Snappy [Bot]'                => array('Snappy/1.1 ( http://www.urltrends.com/ )', ''),
  94          'Steeler [Crawler]'            => array('http://www.tkl.iis.u-tokyo.ac.jp/~crawler/', ''),
  95          'Telekom [Bot]'                => array('crawleradmin.t-info@telekom.de', ''),
  96          'TurnitinBot [Bot]'            => array('TurnitinBot/', ''),
  97          'Voyager [Bot]'                => array('voyager/', ''),
  98          'W3 [Sitesearch]'            => array('W3 SiteSearch Crawler', ''),
  99          'W3C [Linkcheck]'            => array('W3C-checklink/', ''),
 100          'W3C [Validator]'            => array('W3C_Validator', ''),
 101          'YaCy [Bot]'                => array('yacybot', ''),
 102          'Yahoo MMCrawler [Bot]'        => array('Yahoo-MMCrawler/', ''),
 103          'Yahoo Slurp [Bot]'            => array('Yahoo! DE Slurp', ''),
 104          'Yahoo [Bot]'                => array('Yahoo! Slurp', ''),
 105          'YahooSeeker [Bot]'            => array('YahooSeeker/', ''),
 106      );
 107  
 108      /**
 109       * @var \phpbb\db\driver\driver_interface
 110       */
 111      protected $db;
 112  
 113      /**
 114       * @var \phpbb\install\helper\config
 115       */
 116      protected $install_config;
 117  
 118      /**
 119       * @var \phpbb\install\helper\iohandler\iohandler_interface
 120       */
 121      protected $io_handler;
 122  
 123      /**
 124       * @var \phpbb\language\language
 125       */
 126      protected $language;
 127  
 128      /**
 129       * @var string
 130       */
 131      protected $phpbb_root_path;
 132  
 133      /**
 134       * @var string
 135       */
 136      protected $php_ext;
 137  
 138      /**
 139       * Constructor
 140       *
 141       * @param \phpbb\install\helper\config                            $install_config        Installer's config
 142       * @param \phpbb\install\helper\iohandler\iohandler_interface    $iohandler            Input-output handler for the installer
 143       * @param \phpbb\install\helper\container_factory                $container            Installer's DI container
 144       * @param \phpbb\language\language                                $language            Language provider
 145       * @param string                                                $phpbb_root_path    Relative path to phpBB root
 146       * @param string                                                $php_ext            PHP extension
 147       */
 148  	public function __construct(\phpbb\install\helper\config $install_config,
 149                                  \phpbb\install\helper\iohandler\iohandler_interface $iohandler,
 150                                  \phpbb\install\helper\container_factory $container,
 151                                  \phpbb\language\language $language,
 152                                  $phpbb_root_path,
 153                                  $php_ext)
 154      {
 155          parent::__construct(true);
 156  
 157          $this->db                = $container->get('dbal.conn');
 158          $this->install_config    = $install_config;
 159          $this->io_handler        = $iohandler;
 160          $this->language            = $language;
 161          $this->phpbb_root_path    = $phpbb_root_path;
 162          $this->php_ext            = $php_ext;
 163      }
 164  
 165      /**
 166       * {@inheritdoc}
 167       */
 168  	public function run()
 169      {
 170          $this->db->sql_return_on_error(true);
 171  
 172          $sql = 'SELECT group_id
 173              FROM ' . GROUPS_TABLE . "
 174              WHERE group_name = 'BOTS'";
 175          $result = $this->db->sql_query($sql);
 176          $group_id = (int) $this->db->sql_fetchfield('group_id');
 177          $this->db->sql_freeresult($result);
 178  
 179          if (!$group_id)
 180          {
 181              // If we reach this point then something has gone very wrong
 182              $this->io_handler->add_error_message('NO_GROUP');
 183          }
 184  
 185          $i = $this->install_config->get('add_bot_index', 0);
 186          $bot_list = array_slice($this->bot_list, $i);
 187  
 188          foreach ($bot_list as $bot_name => $bot_ary)
 189          {
 190              $user_row = array(
 191                  'user_type'                => USER_IGNORE,
 192                  'group_id'                => $group_id,
 193                  'username'                => $bot_name,
 194                  'user_regdate'            => time(),
 195                  'user_password'            => '',
 196                  'user_colour'            => '9E8DA7',
 197                  'user_email'            => '',
 198                  'user_lang'                => $this->install_config->get('default_lang'),
 199                  'user_style'            => 1,
 200                  'user_timezone'            => 'UTC',
 201                  'user_dateformat'        => $this->language->lang('default_dateformat'),
 202                  'user_allow_massemail'    => 0,
 203                  'user_allow_pm'            => 0,
 204              );
 205  
 206              if (!function_exists('user_add'))
 207              {
 208                  include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
 209              }
 210  
 211              $user_id = user_add($user_row);
 212  
 213              if (!$user_id)
 214              {
 215                  // If we can't insert this user then continue to the next one to avoid inconsistent data
 216                  $this->io_handler->add_error_message('CONV_ERROR_INSERT_BOT');
 217  
 218                  $i++;
 219                  continue;
 220              }
 221  
 222              $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array(
 223                  'bot_active'    => 1,
 224                  'bot_name'        => (string) $bot_name,
 225                  'user_id'        => (int) $user_id,
 226                  'bot_agent'        => (string) $bot_ary[0],
 227                  'bot_ip'        => (string) $bot_ary[1],
 228              ));
 229  
 230              $this->db->sql_query($sql);
 231  
 232              $i++;
 233  
 234              // Stop execution if resource limit is reached
 235              if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0)
 236              {
 237                  break;
 238              }
 239          }
 240  
 241          $this->install_config->set('add_bot_index', $i);
 242  
 243          if ($i < count($this->bot_list))
 244          {
 245              throw new resource_limit_reached_exception();
 246          }
 247      }
 248  
 249      /**
 250       * {@inheritdoc}
 251       */
 252  	static public function get_step_count()
 253      {
 254          return 1;
 255      }
 256  
 257      /**
 258       * {@inheritdoc}
 259       */
 260  	public function get_task_lang_name()
 261      {
 262          return 'TASK_ADD_BOTS';
 263      }
 264  }


Generated: Wed Nov 11 20:28:18 2020 Cross-referenced by PHPXref 0.7.1