Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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: 01.05.2026, 11:27 - Dateigröße: 3.89 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(
021              '\phpbb\db\migration\data\v310\rc6',
022              '\phpbb\db\migration\data\v310\avatars',
023          );
024      }
025   
026      public function update_data()
027      {
028          return array(
029              array('custom', array(array(&$this, 'update_bing_bot'))),
030              array('custom', array(array(&$this, 'update_bots'))),
031          );
032      }
033   
034      public function update_bing_bot()
035      {
036          $bot_name = 'Bing [Bot]';
037          $bot_name_clean = utf8_clean_string($bot_name);
038   
039          $sql = 'SELECT user_id
040              FROM ' . USERS_TABLE . "
041              WHERE username_clean = '" . $this->db->sql_escape($bot_name_clean) . "'";
042          $result = $this->db->sql_query($sql);
043          $bing_already_added = (bool) $this->db->sql_fetchfield('user_id');
044          $this->db->sql_freeresult($result);
045   
046          if (!$bing_already_added)
047          {
048              $bot_agent = 'bingbot/';
049              $bot_ip = '';
050              $sql = 'SELECT group_id, group_colour
051                  FROM ' . GROUPS_TABLE . "
052                  WHERE group_name = 'BOTS'";
053              $result = $this->db->sql_query($sql);
054              $group_row = $this->db->sql_fetchrow($result);
055              $this->db->sql_freeresult($result);
056   
057              if (!$group_row)
058              {
059                  // default fallback, should never get here
060                  $group_row['group_id'] = 6;
061                  $group_row['group_colour'] = '9E8DA7';
062              }
063   
064              if (!function_exists('user_add'))
065              {
066                  include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
067              }
068   
069              $user_row = array(
070                  'user_type'                => USER_IGNORE,
071                  'group_id'                => $group_row['group_id'],
072                  'username'                => $bot_name,
073                  'user_regdate'            => time(),
074                  'user_password'            => '',
075                  'user_colour'            => $group_row['group_colour'],
076                  'user_email'            => '',
077                  'user_lang'                => $this->config['default_lang'],
078                  'user_style'            => $this->config['default_style'],
079                  'user_timezone'            => 0,
080                  'user_dateformat'        => $this->config['default_dateformat'],
081                  'user_allow_massemail'    => 0,
082              );
083   
084              $user_id = user_add($user_row);
085   
086              $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array(
087                      'bot_active'    => 1,
088                      'bot_name'        => (string) $bot_name,
089                      'user_id'        => (int) $user_id,
090                      'bot_agent'        => (string) $bot_agent,
091                      'bot_ip'        => (string) $bot_ip,
092                  ));
093   
094              $this->sql_query($sql);
095          }
096      }
097   
098      public function update_bots()
099      {
100          // Update bots
101          if (!function_exists('user_delete'))
102          {
103              include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
104          }
105   
106          $bots_updates = array(
107              // Bot Deletions
108              'NG-Search [Bot]'        => false,
109              'Nutch/CVS [Bot]'        => false,
110              'OmniExplorer [Bot]'    => false,
111              'Seekport [Bot]'        => false,
112              'Synoo [Bot]'            => false,
113              'WiseNut [Bot]'            => false,
114   
115              // Bot Updates
116              // Bot name to bot user agent map
117              'Baidu [Spider]'    => 'Baiduspider',
118              'Exabot [Bot]'        => 'Exabot',
119              'Voyager [Bot]'        => 'voyager/',
120              'W3C [Validator]'    => 'W3C_Validator',
121          );
122   
123          foreach ($bots_updates as $bot_name => $bot_agent)
124          {
125              $sql = 'SELECT user_id
126                  FROM ' . USERS_TABLE . '
127                  WHERE user_type = ' . USER_IGNORE . "
128                      AND username_clean = '" . $this->db->sql_escape(utf8_clean_string($bot_name)) . "'";
129              $result = $this->db->sql_query($sql);
130              $bot_user_id = (int) $this->db->sql_fetchfield('user_id');
131              $this->db->sql_freeresult($result);
132   
133              if ($bot_user_id)
134              {
135                  if ($bot_agent === false)
136                  {
137                      $sql = 'DELETE FROM ' . BOTS_TABLE . "
138                          WHERE user_id = $bot_user_id";
139                      $this->sql_query($sql);
140   
141                      user_delete('retain', $bot_user_id);
142                  }
143                  else
144                  {
145                      $sql = 'UPDATE ' . BOTS_TABLE . "
146                          SET bot_agent = '" .  $this->db->sql_escape($bot_agent) . "'
147                          WHERE user_id = $bot_user_id";
148                      $this->sql_query($sql);
149                  }
150              }
151          }
152      }
153  }
154