[ Index ]

PHP Cross Reference of phpBB-3.1.12-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          $passwords_manager = $this->container->get('passwords.manager');
  61          $sql = 'SELECT user_id, user_password
  62                  FROM ' . $this->table_prefix . 'users
  63                  WHERE user_pass_convert = 1';
  64          $result = $this->db->sql_query($sql);
  65  
  66          while ($row = $this->db->sql_fetchrow($result))
  67          {
  68              if (strlen($row['user_password']) == 32)
  69              {
  70                  $sql_ary = array(
  71                      'user_password'    => '$CP$' . $passwords_manager->hash($row['user_password'], 'passwords.driver.salted_md5'),
  72                  );
  73  
  74                  $this->sql_query('UPDATE ' . $this->table_prefix . 'users SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id']);
  75              }
  76          }
  77          $this->db->sql_freeresult($result);
  78      }
  79  
  80  	public function update_ichiro_bot()
  81      {
  82          // Adjust bot entry
  83          $sql = 'UPDATE ' . $this->table_prefix . "bots
  84              SET bot_agent = 'ichiro/'
  85              WHERE bot_agent = 'ichiro/2'";
  86          $this->sql_query($sql);
  87      }
  88  
  89  	public function remove_duplicate_auth_options()
  90      {
  91          // Before we are able to add a unique key to auth_option, we need to remove duplicate entries
  92          $sql = 'SELECT auth_option
  93              FROM ' . $this->table_prefix . 'acl_options
  94              GROUP BY auth_option
  95              HAVING COUNT(*) >= 2';
  96          $result = $this->db->sql_query($sql);
  97  
  98          $auth_options = array();
  99          while ($row = $this->db->sql_fetchrow($result))
 100          {
 101              $auth_options[] = $row['auth_option'];
 102          }
 103          $this->db->sql_freeresult($result);
 104  
 105          // Remove specific auth options
 106          if (!empty($auth_options))
 107          {
 108              foreach ($auth_options as $option)
 109              {
 110                  // Select auth_option_ids... the largest id will be preserved
 111                  $sql = 'SELECT auth_option_id
 112                      FROM ' . ACL_OPTIONS_TABLE . "
 113                      WHERE auth_option = '" . $this->db->sql_escape($option) . "'
 114                      ORDER BY auth_option_id DESC";
 115                  // sql_query_limit not possible here, due to bug in postgresql layer
 116                  $result = $this->db->sql_query($sql);
 117  
 118                  // Skip first row, this is our original auth option we want to preserve
 119                  $row = $this->db->sql_fetchrow($result);
 120  
 121                  while ($row = $this->db->sql_fetchrow($result))
 122                  {
 123                      // Ok, remove this auth option...
 124                      $this->sql_query('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']);
 125                      $this->sql_query('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']);
 126                      $this->sql_query('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']);
 127                      $this->sql_query('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id']);
 128                  }
 129                  $this->db->sql_freeresult($result);
 130              }
 131          }
 132      }
 133  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1