Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

bot_update.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 3.84 KiB


 001  <?php
 002  /**
 003  *
 004  * This file is part of the phpBB Forum Software package.
 005  *
 006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
 007  * @license GNU General Public License, version 2 (GPL-2.0)
 008  *
 009  * For full copyright and license information, please see
 010  * the docs/CREDITS.txt file.
 011  *
 012  */
 013   
 014  namespace phpbb\db\migration\data\v310;
 015   
 016  class bot_update extends \phpbb\db\migration\migration
 017  {
 018      static public function depends_on()
 019      {
 020          return array('\phpbb\db\migration\data\v310\rc6');
 021      }
 022   
 023      public function update_data()
 024      {
 025          return array(
 026              array('custom', array(array(&$this, 'update_bing_bot'))),
 027              array('custom', array(array(&$this, 'update_bots'))),
 028          );
 029      }
 030   
 031      public function update_bing_bot()
 032      {
 033          $bot_name = 'Bing [Bot]';
 034          $bot_name_clean = utf8_clean_string($bot_name);
 035   
 036          $sql = 'SELECT user_id
 037              FROM ' . USERS_TABLE . "
 038              WHERE username_clean = '" . $this->db->sql_escape($bot_name_clean) . "'";
 039          $result = $this->db->sql_query($sql);
 040          $bing_already_added = (bool) $this->db->sql_fetchfield('user_id');
 041          $this->db->sql_freeresult($result);
 042   
 043          if (!$bing_already_added)
 044          {
 045              $bot_agent = 'bingbot/';
 046              $bot_ip = '';
 047              $sql = 'SELECT group_id, group_colour
 048                  FROM ' . GROUPS_TABLE . "
 049                  WHERE group_name = 'BOTS'";
 050              $result = $this->db->sql_query($sql);
 051              $group_row = $this->db->sql_fetchrow($result);
 052              $this->db->sql_freeresult($result);
 053   
 054              if (!$group_row)
 055              {
 056                  // default fallback, should never get here
 057                  $group_row['group_id'] = 6;
 058                  $group_row['group_colour'] = '9E8DA7';
 059              }
 060   
 061              if (!function_exists('user_add'))
 062              {
 063                  include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
 064              }
 065   
 066              $user_row = array(
 067                  'user_type'                => USER_IGNORE,
 068                  'group_id'                => $group_row['group_id'],
 069                  'username'                => $bot_name,
 070                  'user_regdate'            => time(),
 071                  'user_password'            => '',
 072                  'user_colour'            => $group_row['group_colour'],
 073                  'user_email'            => '',
 074                  'user_lang'                => $this->config['default_lang'],
 075                  'user_style'            => $this->config['default_style'],
 076                  'user_timezone'            => 0,
 077                  'user_dateformat'        => $this->config['default_dateformat'],
 078                  'user_allow_massemail'    => 0,
 079              );
 080   
 081              $user_id = user_add($user_row);
 082   
 083              $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array(
 084                      'bot_active'    => 1,
 085                      'bot_name'        => (string) $bot_name,
 086                      'user_id'        => (int) $user_id,
 087                      'bot_agent'        => (string) $bot_agent,
 088                      'bot_ip'        => (string) $bot_ip,
 089                  ));
 090   
 091              $this->sql_query($sql);
 092          }
 093      }
 094   
 095      public function update_bots()
 096      {
 097          // Update bots
 098          if (!function_exists('user_delete'))
 099          {
 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  }
 151