[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/phpbb/db/migration/data/v30x/ -> release_3_0_5_rc1.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\db\migration\data\v30x;
  15  
  16  use phpbb\db\migration\container_aware_migration;
  17  
  18  class release_3_0_5_rc1 extends container_aware_migration
  19  {
  20  	public function effectively_installed()
  21      {
  22          return phpbb_version_compare($this->config['version'], '3.0.5-RC1', '>=');
  23      }
  24  
  25  	static public function depends_on()
  26      {
  27          return array('\phpbb\db\migration\data\v30x\release_3_0_4');
  28      }
  29  
  30  	public function update_schema()
  31      {
  32          return array(
  33              'change_columns' => array(
  34                  $this->table_prefix . 'forums' => array(
  35                      'forum_style' => array('UINT', 0),
  36                  ),
  37              ),
  38          );
  39      }
  40  
  41  	public function update_data()
  42      {
  43          $search_indexing_state = $this->config['search_indexing_state'];
  44  
  45          return array(
  46              array('config.add', array('captcha_gd_wave', 0)),
  47              array('config.add', array('captcha_gd_3d_noise', 1)),
  48              array('config.add', array('captcha_gd_fonts', 1)),
  49              array('config.add', array('confirm_refresh', 1)),
  50              array('config.add', array('max_num_search_keywords', 10)),
  51              array('config.remove', array('search_indexing_state')),
  52              array('config.add', array('search_indexing_state', $search_indexing_state, true)),
  53              array('custom', array(array(&$this, 'hash_old_passwords'))),
  54              array('custom', array(array(&$this, 'update_ichiro_bot'))),
  55          );
  56      }
  57  
  58  	public function hash_old_passwords()
  59      {
  60          /* @var $passwords_manager \phpbb\passwords\manager */
  61          $passwords_manager = $this->container->get('passwords.manager');
  62  
  63          $sql = 'SELECT user_id, user_password
  64                  FROM ' . $this->table_prefix . 'users
  65                  WHERE user_pass_convert = 1';
  66          $result = $this->db->sql_query($sql);
  67  
  68          while ($row = $this->db->sql_fetchrow($result))
  69          {
  70              if (strlen($row['user_password']) == 32)
  71              {
  72                  $sql_ary = array(
  73                      'user_password'    => '$CP$' . $passwords_manager->hash($row['user_password'], 'passwords.driver.salted_md5'),
  74                  );
  75  
  76                  $this->sql_query('UPDATE ' . $this->table_prefix . 'users SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id']);
  77              }
  78          }
  79          $this->db->sql_freeresult($result);
  80      }
  81  
  82  	public function update_ichiro_bot()
  83      {
  84          // Adjust bot entry
  85          $sql = 'UPDATE ' . $this->table_prefix . "bots
  86              SET bot_agent = 'ichiro/'
  87              WHERE bot_agent = 'ichiro/2'";
  88          $this->sql_query($sql);
  89      }
  90  
  91  	public function remove_duplicate_auth_options()
  92      {
  93          // Before we are able to add a unique key to auth_option, we need to remove duplicate entries
  94          $sql = 'SELECT auth_option
  95              FROM ' . $this->table_prefix . 'acl_options
  96              GROUP BY auth_option
  97              HAVING COUNT(*) >= 2';
  98          $result = $this->db->sql_query($sql);
  99  
 100          $auth_options = array();
 101          while ($row = $this->db->sql_fetchrow($result))
 102          {
 103              $auth_options[] = $row['auth_option'];
 104          }
 105          $this->db->sql_freeresult($result);
 106  
 107          // Remove specific auth options
 108          if (!empty($auth_options))
 109          {
 110              foreach ($auth_options as $option)
 111              {
 112                  // Select auth_option_ids... the largest id will be preserved
 113                  $sql = 'SELECT auth_option_id
 114                      FROM ' . ACL_OPTIONS_TABLE . "
 115                      WHERE auth_option = '" . $this->db->sql_escape($option) . "'
 116                      ORDER BY auth_option_id DESC";
 117                  // sql_query_limit not possible here, due to bug in postgresql layer
 118                  $result = $this->db->sql_query($sql);
 119  
 120                  // Skip first row, this is our original auth option we want to preserve
 121                  $this->db->sql_fetchrow($result);
 122  
 123                  while ($row = $this->db->sql_fetchrow($result))
 124                  {
 125                      // Ok, remove this auth option...
 126                      $this->sql_query('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']);
 127                      $this->sql_query('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']);
 128                      $this->sql_query('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']);
 129                      $this->sql_query('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']);
 130                  }
 131                  $this->db->sql_freeresult($result);
 132              }
 133          }
 134      }
 135  }


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