[ Index ]

PHP Cross Reference of phpBB-3.3.0-deutsch

title

Body

[close]

/install/convertors/ -> functions_phpbb20.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  if (!defined('IN_PHPBB'))
  15  {
  16      exit;
  17  }
  18  
  19  /**
  20  * Helper functions for phpBB 2.0.x to phpBB 3.1.x conversion
  21  */
  22  
  23  /**
  24  * Set forum flags - only prune old polls by default
  25  */
  26  function phpbb_forum_flags()
  27  {
  28      // Set forum flags
  29      $forum_flags = 0;
  30  
  31      // FORUM_FLAG_LINK_TRACK
  32      $forum_flags += 0;
  33  
  34      // FORUM_FLAG_PRUNE_POLL
  35      $forum_flags += FORUM_FLAG_PRUNE_POLL;
  36  
  37      // FORUM_FLAG_PRUNE_ANNOUNCE
  38      $forum_flags += 0;
  39  
  40      // FORUM_FLAG_PRUNE_STICKY
  41      $forum_flags += 0;
  42  
  43      // FORUM_FLAG_ACTIVE_TOPICS
  44      $forum_flags += 0;
  45  
  46      // FORUM_FLAG_POST_REVIEW
  47      $forum_flags += FORUM_FLAG_POST_REVIEW;
  48  
  49      return $forum_flags;
  50  }
  51  
  52  /**
  53  * Insert/Convert forums
  54  */
  55  function phpbb_insert_forums()
  56  {
  57      global $db, $src_db, $same_db, $convert, $user;
  58  
  59      $db->sql_query($convert->truncate_statement . FORUMS_TABLE);
  60  
  61      // Determine the highest id used within the old forums table (we add the categories after the forum ids)
  62      $sql = 'SELECT MAX(forum_id) AS max_forum_id
  63          FROM ' . $convert->src_table_prefix . 'forums';
  64      $result = $src_db->sql_query($sql);
  65      $max_forum_id = (int) $src_db->sql_fetchfield('max_forum_id');
  66      $src_db->sql_freeresult($result);
  67  
  68      $max_forum_id++;
  69  
  70      // pruning disabled globally?
  71      $sql = "SELECT config_value
  72          FROM {$convert->src_table_prefix}config
  73          WHERE config_name = 'prune_enable'";
  74      $result = $src_db->sql_query($sql);
  75      $prune_enabled = (int) $src_db->sql_fetchfield('config_value');
  76      $src_db->sql_freeresult($result);
  77  
  78      // Insert categories
  79      $sql = 'SELECT cat_id, cat_title
  80          FROM ' . $convert->src_table_prefix . 'categories
  81          ORDER BY cat_order';
  82  
  83      if ($convert->mysql_convert && $same_db)
  84      {
  85          $src_db->sql_query("SET NAMES 'binary'");
  86      }
  87  
  88      $result = $src_db->sql_query($sql);
  89  
  90      if ($convert->mysql_convert && $same_db)
  91      {
  92          $src_db->sql_query("SET NAMES 'utf8'");
  93      }
  94  
  95      switch ($db->get_sql_layer())
  96      {
  97          case 'mssql_odbc':
  98          case 'mssqlnative':
  99              $db->sql_query('SET IDENTITY_INSERT ' . FORUMS_TABLE . ' ON');
 100          break;
 101      }
 102  
 103      $cats_added = array();
 104      while ($row = $src_db->sql_fetchrow($result))
 105      {
 106          $sql_ary = array(
 107              'forum_id'        => (int) $max_forum_id,
 108              'forum_name'    => ($row['cat_title']) ? htmlspecialchars(phpbb_set_default_encoding($row['cat_title']), ENT_COMPAT, 'UTF-8') : $user->lang['CATEGORY'],
 109              'parent_id'        => 0,
 110              'forum_parents'    => '',
 111              'forum_desc'    => '',
 112              'forum_type'    => FORUM_CAT,
 113              'forum_status'    => ITEM_UNLOCKED,
 114              'forum_rules'    => '',
 115          );
 116  
 117          $sql = 'SELECT MAX(right_id) AS right_id
 118              FROM ' . FORUMS_TABLE;
 119          $_result = $db->sql_query($sql);
 120          $cat_row = $db->sql_fetchrow($_result);
 121          $db->sql_freeresult($_result);
 122  
 123          $sql_ary['left_id'] = (int) ($cat_row['right_id'] + 1);
 124          $sql_ary['right_id'] = (int) ($cat_row['right_id'] + 2);
 125  
 126          $sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
 127          $db->sql_query($sql);
 128  
 129          $cats_added[$row['cat_id']] = $max_forum_id;
 130          $max_forum_id++;
 131      }
 132      $src_db->sql_freeresult($result);
 133  
 134      // There may be installations having forums with non-existant category ids.
 135      // We try to catch them and add them to an "unknown" category instead of leaving them out.
 136      $sql = 'SELECT cat_id
 137          FROM ' . $convert->src_table_prefix . 'forums
 138          GROUP BY cat_id';
 139      $result = $src_db->sql_query($sql);
 140  
 141      $unknown_cat_id = false;
 142      while ($row = $src_db->sql_fetchrow($result))
 143      {
 144          // Catch those categories not been added before
 145          if (!isset($cats_added[$row['cat_id']]))
 146          {
 147              $unknown_cat_id = true;
 148          }
 149      }
 150      $src_db->sql_freeresult($result);
 151  
 152      // Is there at least one category not known?
 153      if ($unknown_cat_id === true)
 154      {
 155          $unknown_cat_id = 'ghost';
 156  
 157          $sql_ary = array(
 158              'forum_id'        => (int) $max_forum_id,
 159              'forum_name'    => (string) $user->lang['CATEGORY'],
 160              'parent_id'        => 0,
 161              'forum_parents'    => '',
 162              'forum_desc'    => '',
 163              'forum_type'    => FORUM_CAT,
 164              'forum_status'    => ITEM_UNLOCKED,
 165              'forum_rules'    => '',
 166          );
 167  
 168          $sql = 'SELECT MAX(right_id) AS right_id
 169              FROM ' . FORUMS_TABLE;
 170          $_result = $db->sql_query($sql);
 171          $cat_row = $db->sql_fetchrow($_result);
 172          $db->sql_freeresult($_result);
 173  
 174          $sql_ary['left_id'] = (int) ($cat_row['right_id'] + 1);
 175          $sql_ary['right_id'] = (int) ($cat_row['right_id'] + 2);
 176  
 177          $sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
 178          $db->sql_query($sql);
 179  
 180          $cats_added[$unknown_cat_id] = $max_forum_id;
 181      }
 182  
 183      // Now insert the forums
 184      $sql = 'SELECT f.forum_id, f.forum_name, f.cat_id, f.forum_desc, f.forum_status, f.prune_enable, f.prune_next, fp.prune_days, fp.prune_freq FROM ' . $convert->src_table_prefix . 'forums f
 185          LEFT JOIN ' . $convert->src_table_prefix . 'forum_prune fp ON f.forum_id = fp.forum_id
 186          GROUP BY f.forum_id, f.forum_name, f.cat_id, f.forum_desc, f.forum_status, f.prune_enable, f.prune_next, f.forum_order, fp.prune_days, fp.prune_freq
 187          ORDER BY f.cat_id, f.forum_order';
 188  
 189      if ($convert->mysql_convert && $same_db)
 190      {
 191          $src_db->sql_query("SET NAMES 'binary'");
 192      }
 193  
 194      $result = $src_db->sql_query($sql);
 195  
 196      if ($convert->mysql_convert && $same_db)
 197      {
 198          $src_db->sql_query("SET NAMES 'utf8'");
 199      }
 200  
 201      while ($row = $src_db->sql_fetchrow($result))
 202      {
 203          // Some might have forums here with an id not being "possible"...
 204          // To be somewhat friendly we "change" the category id for those to a previously created ghost category
 205          if (!isset($cats_added[$row['cat_id']]) && $unknown_cat_id !== false)
 206          {
 207              $row['cat_id'] = $unknown_cat_id;
 208          }
 209  
 210          if (!isset($cats_added[$row['cat_id']]))
 211          {
 212              continue;
 213          }
 214  
 215          // Define the new forums sql ary
 216          $sql_ary = array(
 217              'forum_id'            => (int) $row['forum_id'],
 218              'forum_name'        => htmlspecialchars(phpbb_set_default_encoding($row['forum_name']), ENT_COMPAT, 'UTF-8'),
 219              'parent_id'            => (int) $cats_added[$row['cat_id']],
 220              'forum_parents'        => '',
 221              'forum_desc'        => htmlspecialchars(phpbb_set_default_encoding($row['forum_desc']), ENT_COMPAT, 'UTF-8'),
 222              'forum_type'        => FORUM_POST,
 223              'forum_status'        => is_item_locked($row['forum_status']),
 224              'enable_prune'        => ($prune_enabled) ? (int) $row['prune_enable'] : 0,
 225              'prune_next'        => (int) null_to_zero($row['prune_next']),
 226              'prune_days'        => (int) null_to_zero($row['prune_days']),
 227              'prune_viewed'        => 0,
 228              'prune_freq'        => (int) null_to_zero($row['prune_freq']),
 229  
 230              'forum_flags'        => phpbb_forum_flags(),
 231              'forum_options'        => 0,
 232  
 233              // Default values
 234              'forum_desc_bitfield'        => '',
 235              'forum_desc_options'        => 7,
 236              'forum_desc_uid'            => '',
 237              'forum_link'                => '',
 238              'forum_password'            => '',
 239              'forum_style'                => 0,
 240              'forum_image'                => '',
 241              'forum_rules'                => '',
 242              'forum_rules_link'            => '',
 243              'forum_rules_bitfield'        => '',
 244              'forum_rules_options'        => 7,
 245              'forum_rules_uid'            => '',
 246              'forum_topics_per_page'        => 0,
 247              'forum_posts_approved'        => 0,
 248              'forum_posts_unapproved'    => 0,
 249              'forum_posts_softdeleted'    => 0,
 250              'forum_topics_approved'        => 0,
 251              'forum_topics_unapproved'    => 0,
 252              'forum_topics_softdeleted'    => 0,
 253              'forum_last_post_id'        => 0,
 254              'forum_last_poster_id'        => 0,
 255              'forum_last_post_subject'    => '',
 256              'forum_last_post_time'        => 0,
 257              'forum_last_poster_name'    => '',
 258              'forum_last_poster_colour'    => '',
 259              'display_on_index'            => 1,
 260              'enable_indexing'            => 1,
 261              'enable_icons'                => 0,
 262          );
 263  
 264          // Now add the forums with proper left/right ids
 265          $sql = 'SELECT left_id, right_id
 266              FROM ' . FORUMS_TABLE . '
 267              WHERE forum_id = ' . $cats_added[$row['cat_id']];
 268          $_result = $db->sql_query($sql);
 269          $cat_row = $db->sql_fetchrow($_result);
 270          $db->sql_freeresult($_result);
 271  
 272          $sql = 'UPDATE ' . FORUMS_TABLE . '
 273              SET left_id = left_id + 2, right_id = right_id + 2
 274              WHERE left_id > ' . $cat_row['right_id'];
 275          $db->sql_query($sql);
 276  
 277          $sql = 'UPDATE ' . FORUMS_TABLE . '
 278              SET right_id = right_id + 2
 279              WHERE ' . $cat_row['left_id'] . ' BETWEEN left_id AND right_id';
 280          $db->sql_query($sql);
 281  
 282          $sql_ary['left_id'] = (int) $cat_row['right_id'];
 283          $sql_ary['right_id'] = (int) ($cat_row['right_id'] + 1);
 284  
 285          $sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
 286          $db->sql_query($sql);
 287      }
 288      $src_db->sql_freeresult($result);
 289  
 290      switch ($db->get_sql_layer())
 291      {
 292          case 'postgres':
 293              $db->sql_query("SELECT SETVAL('" . FORUMS_TABLE . "_seq',(select case when max(forum_id)>0 then max(forum_id)+1 else 1 end from " . FORUMS_TABLE . '));');
 294          break;
 295  
 296          case 'mssql_odbc':
 297          case 'mssqlnative':
 298              $db->sql_query('SET IDENTITY_INSERT ' . FORUMS_TABLE . ' OFF');
 299          break;
 300  
 301          case 'oracle':
 302              $result = $db->sql_query('SELECT MAX(forum_id) as max_id FROM ' . FORUMS_TABLE);
 303              $row = $db->sql_fetchrow($result);
 304              $db->sql_freeresult($result);
 305  
 306              $largest_id = (int) $row['max_id'];
 307  
 308              if ($largest_id)
 309              {
 310                  $db->sql_query('DROP SEQUENCE ' . FORUMS_TABLE . '_seq');
 311                  $db->sql_query('CREATE SEQUENCE ' . FORUMS_TABLE . '_seq START WITH ' . ($largest_id + 1));
 312              }
 313          break;
 314      }
 315  }
 316  
 317  /**
 318  * Function for recoding text with the default language
 319  *
 320  * @param string $text text to recode to utf8
 321  * @param bool $grab_user_lang if set to true the function tries to use $convert_row['user_lang'] (and falls back to $convert_row['poster_id']) instead of the boards default language
 322  */
 323  function phpbb_set_encoding($text, $grab_user_lang = true)
 324  {
 325      global $lang_enc_array, $convert_row;
 326      global $convert, $phpEx;
 327  
 328      /*static $lang_enc_array = array(
 329          'korean'                        => 'euc-kr',
 330          'serbian'                        => 'windows-1250',
 331          'polish'                        => 'iso-8859-2',
 332          'kurdish'                        => 'windows-1254',
 333          'slovak'                        => 'Windows-1250',
 334          'russian'                        => 'windows-1251',
 335          'estonian'                        => 'iso-8859-4',
 336          'chinese_simplified'            => 'gb2312',
 337          'macedonian'                    => 'windows-1251',
 338          'azerbaijani'                    => 'UTF-8',
 339          'romanian'                        => 'iso-8859-2',
 340          'romanian_diacritice'            => 'iso-8859-2',
 341          'lithuanian'                    => 'windows-1257',
 342          'turkish'                        => 'iso-8859-9',
 343          'ukrainian'                        => 'windows-1251',
 344          'japanese'                        => 'shift_jis',
 345          'hungarian'                        => 'ISO-8859-2',
 346          'romanian_no_diacritics'        => 'iso-8859-2',
 347          'mongolian'                        => 'UTF-8',
 348          'slovenian'                        => 'windows-1250',
 349          'bosnian'                        => 'windows-1250',
 350          'czech'                            => 'Windows-1250',
 351          'farsi'                            => 'Windows-1256',
 352          'croatian'                        => 'windows-1250',
 353          'greek'                            => 'iso-8859-7',
 354          'russian_tu'                    => 'windows-1251',
 355          'sakha'                            => 'UTF-8',
 356          'serbian_cyrillic'                => 'windows-1251',
 357          'bulgarian'                        => 'windows-1251',
 358          'chinese_traditional_taiwan'    => 'big5',
 359          'chinese_traditional'            => 'big5',
 360          'arabic'                        => 'windows-1256',
 361          'hebrew'                        => 'WINDOWS-1255',
 362          'thai'                            => 'windows-874',
 363          //'chinese_traditional_taiwan'    => 'utf-8' // custom modified, we may have to do an include :-(
 364      );*/
 365  
 366      if (empty($lang_enc_array))
 367      {
 368          $lang_enc_array = array();
 369      }
 370  
 371      $get_lang = trim(get_config_value('default_lang'));
 372  
 373      // Do we need the users language encoding?
 374      if ($grab_user_lang && !empty($convert_row))
 375      {
 376          if (!empty($convert_row['user_lang']))
 377          {
 378              $get_lang = trim($convert_row['user_lang']);
 379          }
 380          else if (!empty($convert_row['poster_id']))
 381          {
 382              global $src_db, $same_db;
 383  
 384              if ($convert->mysql_convert && $same_db)
 385              {
 386                  $src_db->sql_query("SET NAMES 'binary'");
 387              }
 388  
 389              $sql = 'SELECT user_lang
 390                  FROM ' . $convert->src_table_prefix . 'users
 391                  WHERE user_id = ' . (int) $convert_row['poster_id'];
 392              $result = $src_db->sql_query($sql);
 393              $get_lang = (string) $src_db->sql_fetchfield('user_lang');
 394              $src_db->sql_freeresult($result);
 395  
 396              if ($convert->mysql_convert && $same_db)
 397              {
 398                  $src_db->sql_query("SET NAMES 'utf8'");
 399              }
 400  
 401              $get_lang = (!trim($get_lang)) ? trim(get_config_value('default_lang')) : trim($get_lang);
 402          }
 403      }
 404  
 405      if (!isset($lang_enc_array[$get_lang]))
 406      {
 407          $filename = $convert->options['forum_path'] . '/language/lang_' . $get_lang . '/lang_main.' . $phpEx;
 408  
 409          if (!file_exists($filename))
 410          {
 411              $get_lang = trim(get_config_value('default_lang'));
 412          }
 413  
 414          if (!isset($lang_enc_array[$get_lang]))
 415          {
 416              include($convert->options['forum_path'] . '/language/lang_' . $get_lang . '/lang_main.' . $phpEx);
 417              $lang_enc_array[$get_lang] = $lang['ENCODING'];
 418              unset($lang);
 419          }
 420      }
 421  
 422      return utf8_recode($text, $lang_enc_array[$get_lang]);
 423  }
 424  
 425  /**
 426  * Same as phpbb_set_encoding, but forcing boards default language
 427  */
 428  function phpbb_set_default_encoding($text)
 429  {
 430      return phpbb_set_encoding($text, false);
 431  }
 432  
 433  /**
 434  * Convert Birthday from Birthday MOD to phpBB Format
 435  */
 436  function phpbb_get_birthday($birthday = '')
 437  {
 438      if (defined('MOD_BIRTHDAY_TERRA'))
 439      {
 440          $birthday = (string) $birthday;
 441  
 442          // stored as month, day, year
 443          if (!$birthday)
 444          {
 445              return ' 0- 0-   0';
 446          }
 447  
 448          // We use the original mod code to retrieve the birthday (not ideal)
 449          preg_match('/(..)(..)(....)/', sprintf('%08d', $birthday), $birthday_parts);
 450  
 451          $month = $birthday_parts[1];
 452          $day = $birthday_parts[2];
 453          $year =  $birthday_parts[3];
 454  
 455          return sprintf('%2d-%2d-%4d', $day, $month, $year);
 456      }
 457      else
 458      {
 459          $birthday = (int) $birthday;
 460  
 461          if (!$birthday || $birthday == 999999)
 462          {
 463              return ' 0- 0-   0';
 464          }
 465  
 466          // The birthday mod from niels is using this code to transform to day/month/year
 467          return sprintf('%2d-%2d-%4d', gmdate('j', $birthday * 86400 + 1), gmdate('n', $birthday * 86400 + 1), gmdate('Y', $birthday * 86400 + 1));
 468      }
 469  }
 470  
 471  /**
 472  * Return correct user id value
 473  * Everyone's id will be one higher to allow the guest/anonymous user to have a positive id as well
 474  */
 475  function phpbb_user_id($user_id)
 476  {
 477      global $config;
 478  
 479      // Increment user id if the old forum is having a user with the id 1
 480      if (!isset($config['increment_user_id']))
 481      {
 482          global $src_db, $same_db, $convert;
 483  
 484          if ($convert->mysql_convert && $same_db)
 485          {
 486              $src_db->sql_query("SET NAMES 'binary'");
 487          }
 488  
 489          // Now let us set a temporary config variable for user id incrementing
 490          $sql = "SELECT user_id
 491              FROM {$convert->src_table_prefix}users
 492              WHERE user_id = 1";
 493          $result = $src_db->sql_query($sql);
 494          $id = (int) $src_db->sql_fetchfield('user_id');
 495          $src_db->sql_freeresult($result);
 496  
 497          // Try to get the maximum user id possible...
 498          $sql = "SELECT MAX(user_id) AS max_user_id
 499              FROM {$convert->src_table_prefix}users";
 500          $result = $src_db->sql_query($sql);
 501          $max_id = (int) $src_db->sql_fetchfield('max_user_id');
 502          $src_db->sql_freeresult($result);
 503  
 504          if ($convert->mysql_convert && $same_db)
 505          {
 506              $src_db->sql_query("SET NAMES 'utf8'");
 507          }
 508  
 509          // If there is a user id 1, we need to increment user ids. :/
 510          if ($id === 1)
 511          {
 512              $config->set('increment_user_id', ($max_id + 1), false);
 513              $config['increment_user_id'] = $max_id + 1;
 514          }
 515          else
 516          {
 517              $config->set('increment_user_id', 0, false);
 518              $config['increment_user_id'] = 0;
 519          }
 520      }
 521  
 522      // If the old user id is -1 in 2.0.x it is the anonymous user...
 523      if ($user_id == -1)
 524      {
 525          return ANONYMOUS;
 526      }
 527  
 528      if (!empty($config['increment_user_id']) && $user_id == 1)
 529      {
 530          return $config['increment_user_id'];
 531      }
 532  
 533      // A user id of 0 can happen, for example within the ban table if no user is banned...
 534      // Within the posts and topics table this can be "dangerous" but is the fault of the user
 535      // having mods installed (a poster id of 0 is not possible in 2.0.x).
 536      // Therefore, we return the user id "as is".
 537  
 538      return (int) $user_id;
 539  }
 540  
 541  /**
 542  * Return correct user id value
 543  * Everyone's id will be one higher to allow the guest/anonymous user to have a positive id as well
 544  */
 545  function phpbb_topic_replies_to_posts($num_replies)
 546  {
 547      return (int) $num_replies + 1;
 548  }
 549  
 550  /* Copy additional table fields from old forum to new forum if user wants this (for Mod compatibility for example)
 551  function phpbb_copy_table_fields()
 552  {
 553  }
 554  */
 555  
 556  /**
 557  * Convert authentication
 558  * user, group and forum table has to be filled in order to work
 559  */
 560  function phpbb_convert_authentication($mode)
 561  {
 562      global $db, $src_db, $same_db, $convert, $config;
 563  
 564      if ($mode == 'start')
 565      {
 566          $db->sql_query($convert->truncate_statement . ACL_USERS_TABLE);
 567          $db->sql_query($convert->truncate_statement . ACL_GROUPS_TABLE);
 568  
 569          // What we will do is handling all 2.0.x admins as founder to replicate what is common in 2.0.x.
 570          // After conversion the main admin need to make sure he is removing permissions and the founder status if wanted.
 571  
 572          // Grab user ids of users with user_level of ADMIN
 573          $sql = "SELECT user_id
 574              FROM {$convert->src_table_prefix}users
 575              WHERE user_level = 1
 576              ORDER BY user_regdate ASC";
 577          $result = $src_db->sql_query($sql);
 578  
 579          while ($row = $src_db->sql_fetchrow($result))
 580          {
 581              $user_id = (int) phpbb_user_id($row['user_id']);
 582              // Set founder admin...
 583              $sql = 'UPDATE ' . USERS_TABLE . '
 584                  SET user_type = ' . USER_FOUNDER . "
 585                  WHERE user_id = $user_id";
 586              $db->sql_query($sql);
 587          }
 588          $src_db->sql_freeresult($result);
 589  
 590          $sql = 'SELECT group_id
 591              FROM ' . GROUPS_TABLE . "
 592              WHERE group_name = '" . $db->sql_escape('BOTS') . "'";
 593          $result = $db->sql_query($sql);
 594          $bot_group_id = (int) $db->sql_fetchfield('group_id');
 595          $db->sql_freeresult($result);
 596      }
 597  
 598      // Grab forum auth information
 599      $sql = "SELECT *
 600          FROM {$convert->src_table_prefix}forums";
 601      $result = $src_db->sql_query($sql);
 602  
 603      $forum_access = array();
 604      while ($row = $src_db->sql_fetchrow($result))
 605      {
 606          $forum_access[$row['forum_id']] = $row;
 607      }
 608      $src_db->sql_freeresult($result);
 609  
 610      if ($convert->mysql_convert && $same_db)
 611      {
 612          $src_db->sql_query("SET NAMES 'binary'");
 613      }
 614      // Grab user auth information from 2.0.x board
 615      $sql = "SELECT ug.user_id, aa.*
 616          FROM {$convert->src_table_prefix}auth_access aa, {$convert->src_table_prefix}user_group ug, {$convert->src_table_prefix}groups g, {$convert->src_table_prefix}forums f
 617          WHERE g.group_id = aa.group_id
 618              AND g.group_single_user = 1
 619              AND ug.group_id = g.group_id
 620              AND f.forum_id = aa.forum_id";
 621      $result = $src_db->sql_query($sql);
 622  
 623      $user_access = array();
 624      while ($row = $src_db->sql_fetchrow($result))
 625      {
 626          $user_access[$row['forum_id']][] = $row;
 627      }
 628      $src_db->sql_freeresult($result);
 629  
 630      // Grab group auth information
 631      $sql = "SELECT g.group_id, aa.*
 632          FROM {$convert->src_table_prefix}auth_access aa, {$convert->src_table_prefix}groups g
 633          WHERE g.group_id = aa.group_id
 634              AND g.group_single_user <> 1";
 635      $result = $src_db->sql_query($sql);
 636  
 637      $group_access = array();
 638      while ($row = $src_db->sql_fetchrow($result))
 639      {
 640          $group_access[$row['forum_id']][] = $row;
 641      }
 642      $src_db->sql_freeresult($result);
 643  
 644      if ($convert->mysql_convert && $same_db)
 645      {
 646          $src_db->sql_query("SET NAMES 'utf8'");
 647      }
 648  
 649      // Add Forum Access List
 650      $auth_map = array(
 651          'auth_view'            => array('f_', 'f_list'),
 652          'auth_read'            => array('f_read', 'f_search'),
 653          'auth_post'            => array('f_post', 'f_bbcode', 'f_smilies', 'f_img', 'f_sigs', 'f_postcount', 'f_report', 'f_subscribe', 'f_print', 'f_email'),
 654          'auth_reply'        => 'f_reply',
 655          'auth_edit'            => 'f_edit',
 656          'auth_delete'        => 'f_delete',
 657          'auth_pollcreate'    => 'f_poll',
 658          'auth_vote'            => 'f_vote',
 659          'auth_announce'        => array('f_announce', 'f_announce_global'),
 660          'auth_sticky'        => 'f_sticky',
 661          'auth_attachments'    => array('f_attach', 'f_download'),
 662          'auth_download'        => 'f_download',
 663      );
 664  
 665      // Define the ACL constants used in 2.0 to make the code slightly more readable
 666      define('AUTH_ALL', 0);
 667      define('AUTH_REG', 1);
 668      define('AUTH_ACL', 2);
 669      define('AUTH_MOD', 3);
 670      define('AUTH_ADMIN', 5);
 671  
 672      // A mapping of the simple permissions used by 2.0
 673      $simple_auth_ary = array(
 674          'public'            => array(
 675              'auth_view'            => AUTH_ALL,
 676              'auth_read'            => AUTH_ALL,
 677              'auth_post'            => AUTH_ALL,
 678              'auth_reply'        => AUTH_ALL,
 679              'auth_edit'            => AUTH_REG,
 680              'auth_delete'        => AUTH_REG,
 681              'auth_sticky'        => AUTH_MOD,
 682              'auth_announce'        => AUTH_MOD,
 683              'auth_vote'            => AUTH_REG,
 684              'auth_pollcreate'    => AUTH_REG,
 685          ),
 686          'registered'        => array(
 687              'auth_view'            => AUTH_ALL,
 688              'auth_read'            => AUTH_ALL,
 689              'auth_post'            => AUTH_REG,
 690              'auth_reply'        => AUTH_REG,
 691              'auth_edit'            => AUTH_REG,
 692              'auth_delete'        => AUTH_REG,
 693              'auth_sticky'        => AUTH_MOD,
 694              'auth_announce'        => AUTH_MOD,
 695              'auth_vote'            => AUTH_REG,
 696              'auth_pollcreate'    => AUTH_REG,
 697          ),
 698          'registered_hidden'    => array(
 699              'auth_view'            => AUTH_REG,
 700              'auth_read'            => AUTH_REG,
 701              'auth_post'            => AUTH_REG,
 702              'auth_reply'        => AUTH_REG,
 703              'auth_edit'            => AUTH_REG,
 704              'auth_delete'        => AUTH_REG,
 705              'auth_sticky'        => AUTH_MOD,
 706              'auth_announce'        => AUTH_MOD,
 707              'auth_vote'            => AUTH_REG,
 708              'auth_pollcreate'    => AUTH_REG,
 709          ),
 710          'private'            => array(
 711              'auth_view'            => AUTH_ALL,
 712              'auth_read'            => AUTH_ACL,
 713              'auth_post'            => AUTH_ACL,
 714              'auth_reply'        => AUTH_ACL,
 715              'auth_edit'            => AUTH_ACL,
 716              'auth_delete'        => AUTH_ACL,
 717              'auth_sticky'        => AUTH_ACL,
 718              'auth_announce'        => AUTH_MOD,
 719              'auth_vote'            => AUTH_ACL,
 720              'auth_pollcreate'    => AUTH_ACL,
 721          ),
 722          'private_hidden'    => array(
 723              'auth_view'            => AUTH_ACL,
 724              'auth_read'            => AUTH_ACL,
 725              'auth_post'            => AUTH_ACL,
 726              'auth_reply'        => AUTH_ACL,
 727              'auth_edit'            => AUTH_ACL,
 728              'auth_delete'        => AUTH_ACL,
 729              'auth_sticky'        => AUTH_ACL,
 730              'auth_announce'        => AUTH_MOD,
 731              'auth_vote'            => AUTH_ACL,
 732              'auth_pollcreate'    => AUTH_ACL,
 733          ),
 734          'moderator'            => array(
 735              'auth_view'            => AUTH_ALL,
 736              'auth_read'            => AUTH_MOD,
 737              'auth_post'            => AUTH_MOD,
 738              'auth_reply'        => AUTH_MOD,
 739              'auth_edit'            => AUTH_MOD,
 740              'auth_delete'        => AUTH_MOD,
 741              'auth_sticky'        => AUTH_MOD,
 742              'auth_announce'        => AUTH_MOD,
 743              'auth_vote'            => AUTH_MOD,
 744              'auth_pollcreate'    => AUTH_MOD,
 745          ),
 746          'moderator_hidden'    => array(
 747              'auth_view'            => AUTH_MOD,
 748              'auth_read'            => AUTH_MOD,
 749              'auth_post'            => AUTH_MOD,
 750              'auth_reply'        => AUTH_MOD,
 751              'auth_edit'            => AUTH_MOD,
 752              'auth_delete'        => AUTH_MOD,
 753              'auth_sticky'        => AUTH_MOD,
 754              'auth_announce'        => AUTH_MOD,
 755              'auth_vote'            => AUTH_MOD,
 756              'auth_pollcreate'    => AUTH_MOD,
 757          ),
 758      );
 759  
 760      if ($mode == 'start')
 761      {
 762          user_group_auth('guests', 'SELECT user_id, {GUESTS} FROM ' . USERS_TABLE . ' WHERE user_id = ' . ANONYMOUS, false);
 763          user_group_auth('registered', 'SELECT user_id, {REGISTERED} FROM ' . USERS_TABLE . ' WHERE user_id <> ' . ANONYMOUS . " AND group_id <> $bot_group_id", false);
 764  
 765          // Selecting from old table
 766          if (!empty($config['increment_user_id']))
 767          {
 768              $auth_sql = 'SELECT user_id, {ADMINISTRATORS} FROM ' . $convert->src_table_prefix . 'users WHERE user_level = 1 AND user_id <> 1';
 769              user_group_auth('administrators', $auth_sql, true);
 770  
 771              $auth_sql = 'SELECT ' . $config['increment_user_id'] . ' as user_id, {ADMINISTRATORS} FROM ' . $convert->src_table_prefix . 'users WHERE user_level = 1 AND user_id = 1';
 772              user_group_auth('administrators', $auth_sql, true);
 773          }
 774          else
 775          {
 776              $auth_sql = 'SELECT user_id, {ADMINISTRATORS} FROM ' . $convert->src_table_prefix . 'users WHERE user_level = 1';
 777              user_group_auth('administrators', $auth_sql, true);
 778          }
 779  
 780          if (!empty($config['increment_user_id']))
 781          {
 782              $auth_sql = 'SELECT user_id, {GLOBAL_MODERATORS} FROM ' . $convert->src_table_prefix . 'users WHERE user_level = 1 AND user_id <> 1';
 783              user_group_auth('global_moderators', $auth_sql, true);
 784  
 785              $auth_sql = 'SELECT ' . $config['increment_user_id'] . ' as user_id, {GLOBAL_MODERATORS} FROM ' . $convert->src_table_prefix . 'users WHERE user_level = 1 AND user_id = 1';
 786              user_group_auth('global_moderators', $auth_sql, true);
 787          }
 788          else
 789          {
 790              $auth_sql = 'SELECT user_id, {GLOBAL_MODERATORS} FROM ' . $convert->src_table_prefix . 'users WHERE user_level = 1';
 791              user_group_auth('global_moderators', $auth_sql, true);
 792          }
 793      }
 794      else if ($mode == 'first')
 795      {
 796          // Go through all 2.0.x forums
 797          foreach ($forum_access as $forum)
 798          {
 799              $new_forum_id = (int) $forum['forum_id'];
 800  
 801              // Administrators have full access to all forums whatever happens
 802              mass_auth('group_role', $new_forum_id, 'administrators', 'FORUM_FULL');
 803  
 804              $matched_type = '';
 805              foreach ($simple_auth_ary as $key => $auth_levels)
 806              {
 807                  $matched = 1;
 808                  foreach ($auth_levels as $k => $level)
 809                  {
 810                      if ($forum[$k] != $auth_levels[$k])
 811                      {
 812                          $matched = 0;
 813                      }
 814                  }
 815  
 816                  if ($matched)
 817                  {
 818                      $matched_type = $key;
 819                      break;
 820                  }
 821              }
 822  
 823              switch ($matched_type)
 824              {
 825                  case 'public':
 826                      mass_auth('group_role', $new_forum_id, 'guests', 'FORUM_LIMITED');
 827                      mass_auth('group_role', $new_forum_id, 'registered', 'FORUM_LIMITED_POLLS');
 828                      mass_auth('group_role', $new_forum_id, 'bots', 'FORUM_BOT');
 829                  break;
 830  
 831                  case 'registered':
 832                      mass_auth('group_role', $new_forum_id, 'guests', 'FORUM_READONLY');
 833                      mass_auth('group_role', $new_forum_id, 'bots', 'FORUM_BOT');
 834  
 835                  // no break;
 836  
 837                  case 'registered_hidden':
 838                      mass_auth('group_role', $new_forum_id, 'registered', 'FORUM_POLLS');
 839                  break;
 840  
 841                  case 'private':
 842                  case 'private_hidden':
 843                  case 'moderator':
 844                  case 'moderator_hidden':
 845                  default:
 846                      // The permissions don't match a simple set, so we're going to have to map them directly
 847  
 848                      // No post approval for all, in 2.0.x this feature does not exist
 849                      mass_auth('group', $new_forum_id, 'guests', 'f_noapprove', ACL_YES);
 850                      mass_auth('group', $new_forum_id, 'registered', 'f_noapprove', ACL_YES);
 851  
 852                      // Go through authentication map
 853                      foreach ($auth_map as $old_auth_key => $new_acl)
 854                      {
 855                          // If old authentication key does not exist we continue
 856                          // This is helpful for mods adding additional authentication fields, we need to add them to the auth_map array
 857                          if (!isset($forum[$old_auth_key]))
 858                          {
 859                              continue;
 860                          }
 861  
 862                          // Now set the new ACL correctly
 863                          switch ($forum[$old_auth_key])
 864                          {
 865                              // AUTH_ALL
 866                              case AUTH_ALL:
 867                                  mass_auth('group', $new_forum_id, 'guests', $new_acl, ACL_YES);
 868                                  mass_auth('group', $new_forum_id, 'bots', $new_acl, ACL_YES);
 869                                  mass_auth('group', $new_forum_id, 'registered', $new_acl, ACL_YES);
 870                              break;
 871  
 872                              // AUTH_REG
 873                              case AUTH_REG:
 874                                  mass_auth('group', $new_forum_id, 'registered', $new_acl, ACL_YES);
 875                              break;
 876  
 877                              // AUTH_ACL
 878                              case AUTH_ACL:
 879                                  // Go through the old group access list for this forum
 880                                  if (isset($group_access[$forum['forum_id']]))
 881                                  {
 882                                      foreach ($group_access[$forum['forum_id']] as $index => $access)
 883                                      {
 884                                          // We only check for ACL_YES equivalence entry
 885                                          if (isset($access[$old_auth_key]) && $access[$old_auth_key] == 1)
 886                                          {
 887                                              mass_auth('group', $new_forum_id, (int) $access['group_id'], $new_acl, ACL_YES);
 888                                          }
 889                                      }
 890                                  }
 891  
 892                                  if (isset($user_access[$forum['forum_id']]))
 893                                  {
 894                                      foreach ($user_access[$forum['forum_id']] as $index => $access)
 895                                      {
 896                                          // We only check for ACL_YES equivalence entry
 897                                          if (isset($access[$old_auth_key]) && $access[$old_auth_key] == 1)
 898                                          {
 899                                              mass_auth('user', $new_forum_id, (int) phpbb_user_id($access['user_id']), $new_acl, ACL_YES);
 900                                          }
 901                                      }
 902                                  }
 903                              break;
 904  
 905                              // AUTH_MOD
 906                              case AUTH_MOD:
 907                                  if (isset($group_access[$forum['forum_id']]))
 908                                  {
 909                                      foreach ($group_access[$forum['forum_id']] as $index => $access)
 910                                      {
 911                                          // We only check for ACL_YES equivalence entry
 912                                          if (isset($access[$old_auth_key]) && $access[$old_auth_key] == 1)
 913                                          {
 914                                              mass_auth('group', $new_forum_id, (int) $access['group_id'], $new_acl, ACL_YES);
 915                                          }
 916                                      }
 917                                  }
 918  
 919                                  if (isset($user_access[$forum['forum_id']]))
 920                                  {
 921                                      foreach ($user_access[$forum['forum_id']] as $index => $access)
 922                                      {
 923                                          // We only check for ACL_YES equivalence entry
 924                                          if (isset($access[$old_auth_key]) && $access[$old_auth_key] == 1)
 925                                          {
 926                                              mass_auth('user', $new_forum_id, (int) phpbb_user_id($access['user_id']), $new_acl, ACL_YES);
 927                                          }
 928                                      }
 929                                  }
 930                              break;
 931                          }
 932                      }
 933                  break;
 934              }
 935          }
 936      }
 937      else if ($mode == 'second')
 938      {
 939          // Assign permission roles and other default permissions
 940  
 941          // guests having u_download and u_search ability
 942          $db->sql_query('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) SELECT ' . get_group_id('guests') . ', 0, auth_option_id, 0, 1 FROM ' . ACL_OPTIONS_TABLE . " WHERE auth_option IN ('u_', 'u_download', 'u_search')");
 943  
 944          // administrators/global mods having full user features
 945          mass_auth('group_role', 0, 'administrators', 'USER_FULL');
 946          mass_auth('group_role', 0, 'global_moderators', 'USER_FULL');
 947  
 948          // By default all converted administrators are given full access
 949          mass_auth('group_role', 0, 'administrators', 'ADMIN_FULL');
 950  
 951          // All registered users are assigned the standard user role
 952          mass_auth('group_role', 0, 'registered', 'USER_STANDARD');
 953          mass_auth('group_role', 0, 'registered_coppa', 'USER_STANDARD');
 954  
 955          // Instead of administrators being global moderators we give the MOD_FULL role to global mods (admins already assigned to this group)
 956          mass_auth('group_role', 0, 'global_moderators', 'MOD_FULL');
 957  
 958          // And now those who have had their avatar rights removed get assigned a more restrictive role
 959          $sql = 'SELECT user_id FROM ' . $convert->src_table_prefix . 'users
 960              WHERE user_allowavatar = 0
 961                  AND user_id > 0';
 962          $result = $src_db->sql_query($sql);
 963  
 964          while ($row = $src_db->sql_fetchrow($result))
 965          {
 966              mass_auth('user_role', 0, (int) phpbb_user_id($row['user_id']), 'USER_NOAVATAR');
 967          }
 968          $src_db->sql_freeresult($result);
 969  
 970          // And the same for those who have had their PM rights removed
 971          $sql = 'SELECT user_id FROM ' . $convert->src_table_prefix . 'users
 972              WHERE user_allow_pm = 0
 973                  AND user_id > 0';
 974          $result = $src_db->sql_query($sql);
 975  
 976          while ($row = $src_db->sql_fetchrow($result))
 977          {
 978              mass_auth('user_role', 0, (int) phpbb_user_id($row['user_id']), 'USER_NOPM');
 979          }
 980          $src_db->sql_freeresult($result);
 981      }
 982      else if ($mode == 'third')
 983      {
 984          // And now the moderators
 985          // We make sure that they have at least standard access to the forums they moderate in addition to the moderating permissions
 986  
 987          $mod_post_map = array(
 988              'auth_announce'        => array('f_announce', 'f_announce_global'),
 989              'auth_sticky'        => 'f_sticky'
 990          );
 991  
 992          foreach ($user_access as $forum_id => $access_map)
 993          {
 994              $forum_id = (int) $forum_id;
 995  
 996              foreach ($access_map as $access)
 997              {
 998                  if (isset($access['auth_mod']) && $access['auth_mod'] == 1)
 999                  {
1000                      mass_auth('user_role', $forum_id, (int) phpbb_user_id($access['user_id']), 'MOD_STANDARD');
1001                      mass_auth('user_role', $forum_id, (int) phpbb_user_id($access['user_id']), 'FORUM_STANDARD');
1002                      foreach ($mod_post_map as $old => $new)
1003                      {
1004                          if (isset($forum_access[$forum_id]) && isset($forum_access[$forum_id][$old]) && $forum_access[$forum_id][$old] == AUTH_MOD)
1005                          {
1006                              mass_auth('user', $forum_id, (int) phpbb_user_id($access['user_id']), $new, ACL_YES);
1007                          }
1008                      }
1009                  }
1010              }
1011          }
1012  
1013          foreach ($group_access as $forum_id => $access_map)
1014          {
1015              $forum_id = (int) $forum_id;
1016  
1017              foreach ($access_map as $access)
1018              {
1019                  if (isset($access['auth_mod']) && $access['auth_mod'] == 1)
1020                  {
1021                      mass_auth('group_role', $forum_id, (int) $access['group_id'], 'MOD_STANDARD');
1022                      mass_auth('group_role', $forum_id, (int) $access['group_id'], 'FORUM_STANDARD');
1023                      foreach ($mod_post_map as $old => $new)
1024                      {
1025                          if (isset($forum_access[$forum_id]) && isset($forum_access[$forum_id][$old]) && $forum_access[$forum_id][$old] == AUTH_MOD)
1026                          {
1027                              mass_auth('group', $forum_id, (int) $access['group_id'], $new, ACL_YES);
1028                          }
1029                      }
1030                  }
1031              }
1032          }
1033  
1034          // We grant everyone readonly access to the categories to ensure that the forums are visible
1035          $sql = 'SELECT forum_id, forum_name, parent_id, left_id, right_id
1036              FROM ' . FORUMS_TABLE . '
1037              ORDER BY left_id ASC';
1038          $result = $db->sql_query($sql);
1039  
1040          $parent_forums = $forums = array();
1041          while ($row = $db->sql_fetchrow($result))
1042          {
1043              if ($row['parent_id'] == 0)
1044              {
1045                  mass_auth('group_role', $row['forum_id'], 'administrators', 'FORUM_FULL');
1046                  mass_auth('group_role', $row['forum_id'], 'global_moderators', 'FORUM_FULL');
1047                  $parent_forums[] = $row;
1048              }
1049              else
1050              {
1051                  $forums[] = $row;
1052              }
1053          }
1054          $db->sql_freeresult($result);
1055  
1056          global $auth;
1057  
1058          // Let us see which groups have access to these forums...
1059          foreach ($parent_forums as $row)
1060          {
1061              // Get the children
1062              $branch = $forum_ids = array();
1063  
1064              foreach ($forums as $key => $_row)
1065              {
1066                  if ($_row['left_id'] > $row['left_id'] && $_row['left_id'] < $row['right_id'])
1067                  {
1068                      $branch[] = $_row;
1069                      $forum_ids[] = $_row['forum_id'];
1070                      continue;
1071                  }
1072              }
1073  
1074              if (count($forum_ids))
1075              {
1076                  // Now make sure the user is able to read these forums
1077                  $hold_ary = $auth->acl_group_raw_data(false, 'f_list', $forum_ids);
1078  
1079                  if (empty($hold_ary))
1080                  {
1081                      continue;
1082                  }
1083  
1084                  foreach ($hold_ary as $g_id => $f_id_ary)
1085                  {
1086                      $set_group = false;
1087  
1088                      foreach ($f_id_ary as $f_id => $auth_ary)
1089                      {
1090                          foreach ($auth_ary as $auth_option => $setting)
1091                          {
1092                              if ($setting == ACL_YES)
1093                              {
1094                                  $set_group = true;
1095                                  break 2;
1096                              }
1097                          }
1098                      }
1099  
1100                      if ($set_group)
1101                      {
1102                          mass_auth('group', $row['forum_id'], $g_id, 'f_list', ACL_YES);
1103                      }
1104                  }
1105              }
1106          }
1107      }
1108  }
1109  
1110  /**
1111  * Set primary group.
1112  * Really simple and only based on user_level (remaining groups will be assigned later)
1113  */
1114  function phpbb_set_primary_group($user_level)
1115  {
1116      global $convert_row;
1117  
1118      if ($user_level == 1)
1119      {
1120          return get_group_id('administrators');
1121      }
1122  /*    else if ($user_level == 2)
1123      {
1124          return get_group_id('global_moderators');
1125      }
1126      else if ($user_level == 0 && $convert_row['user_active'])*/
1127      else if ($convert_row['user_active'])
1128      {
1129          return get_group_id('registered');
1130      }
1131  
1132      return 0;
1133  }
1134  
1135  /**
1136  * Convert the group name, making sure to avoid conflicts with 3.0 special groups
1137  */
1138  function phpbb_convert_group_name($group_name)
1139  {
1140      $default_groups = array(
1141          'GUESTS',
1142          'REGISTERED',
1143          'REGISTERED_COPPA',
1144          'GLOBAL_MODERATORS',
1145          'ADMINISTRATORS',
1146          'BOTS',
1147      );
1148  
1149      if (in_array(strtoupper($group_name), $default_groups))
1150      {
1151          return 'phpBB2 - ' . $group_name;
1152      }
1153  
1154      return phpbb_set_default_encoding($group_name);
1155  }
1156  
1157  /**
1158  * Convert the group type constants
1159  */
1160  function phpbb_convert_group_type($group_type)
1161  {
1162      switch ($group_type)
1163      {
1164          case 0:
1165              return GROUP_OPEN;
1166          break;
1167  
1168          case 1:
1169              return GROUP_CLOSED;
1170          break;
1171  
1172          case 2:
1173              return GROUP_HIDDEN;
1174          break;
1175      }
1176  
1177      // Never return GROUP_SPECIAL here, because only phpBB3's default groups are allowed to have this type set.
1178      return GROUP_HIDDEN;
1179  }
1180  
1181  /**
1182  * Convert the topic type constants
1183  */
1184  function phpbb_convert_topic_type($topic_type)
1185  {
1186      switch ($topic_type)
1187      {
1188          case 0:
1189              return POST_NORMAL;
1190          break;
1191  
1192          case 1:
1193              return POST_STICKY;
1194          break;
1195  
1196          case 2:
1197              return POST_ANNOUNCE;
1198          break;
1199  
1200          case 3:
1201              return POST_GLOBAL;
1202          break;
1203      }
1204  
1205      return POST_NORMAL;
1206  }
1207  
1208  function phpbb_replace_size($matches)
1209  {
1210      return '[size=' . min(200, ceil(100.0 * (((double) $matches[1])/12.0))) . ':' . $matches[2] . ']';
1211  }
1212  
1213  /**
1214  * Reparse the message stripping out the bbcode_uid values and adding new ones and setting the bitfield
1215  * @todo What do we want to do about HTML in messages - currently it gets converted to the entities, but there may be some objections to this
1216  */
1217  function phpbb_prepare_message($message)
1218  {
1219      global $convert, $user, $convert_row, $message_parser;
1220  
1221      if (!$message)
1222      {
1223          $convert->row['mp_bbcode_bitfield'] = $convert_row['mp_bbcode_bitfield'] = 0;
1224          return '';
1225      }
1226  
1227      // Decode phpBB 2.0.x Message
1228      if (isset($convert->row['old_bbcode_uid']) && $convert->row['old_bbcode_uid'] != '')
1229      {
1230          // Adjust size...
1231          if (strpos($message, '[size=') !== false)
1232          {
1233              $message = preg_replace_callback('/\[size=(\d*):(' . $convert->row['old_bbcode_uid'] . ')\]/', 'phpbb_replace_size', $message);
1234          }
1235  
1236          $message = preg_replace('/\:(([a-z0-9]:)?)' . $convert->row['old_bbcode_uid'] . '/s', '', $message);
1237      }
1238  
1239      if (strpos($message, '[quote=') !== false)
1240      {
1241          $message = preg_replace('/\[quote="(.*?)"\]/s', '[quote=&quot;\1&quot;]', $message);
1242          $message = preg_replace('/\[quote=\\\"(.*?)\\\"\]/s', '[quote=&quot;\1&quot;]', $message);
1243  
1244          // let's hope that this solves more problems than it causes. Deal with escaped quotes.
1245          $message = str_replace('\"', '&quot;', $message);
1246          $message = str_replace('\&quot;', '&quot;', $message);
1247      }
1248  
1249      $message = str_replace('<br />', "\n", $message);
1250      $message = str_replace('<', '&lt;', $message);
1251      $message = str_replace('>', '&gt;', $message);
1252  
1253      // make the post UTF-8
1254      $message = phpbb_set_encoding($message);
1255  
1256      $message_parser->warn_msg = array(); // Reset the errors from the previous message
1257      $message_parser->bbcode_uid = make_uid($convert->row['post_time']);
1258      $message_parser->message = $message;
1259      unset($message);
1260  
1261      // Make sure options are set.
1262  //    $enable_html = (!isset($row['enable_html'])) ? false : $row['enable_html'];
1263      $enable_bbcode = (!isset($convert->row['enable_bbcode'])) ? true : $convert->row['enable_bbcode'];
1264      $enable_smilies = (!isset($convert->row['enable_smilies'])) ? true : $convert->row['enable_smilies'];
1265      $enable_magic_url = (!isset($convert->row['enable_magic_url'])) ? true : $convert->row['enable_magic_url'];
1266  
1267      // parse($allow_bbcode, $allow_magic_url, $allow_smilies, $allow_img_bbcode = true, $allow_flash_bbcode = true, $allow_quote_bbcode = true, $allow_url_bbcode = true, $update_this_message = true, $mode = 'post')
1268      $message_parser->parse($enable_bbcode, $enable_magic_url, $enable_smilies);
1269  
1270      if (count($message_parser->warn_msg))
1271      {
1272          $msg_id = isset($convert->row['post_id']) ? $convert->row['post_id'] : $convert->row['privmsgs_id'];
1273          $convert->p_master->error('<span style="color:red">' . $user->lang['POST_ID'] . ': ' . $msg_id . ' ' . $user->lang['CONV_ERROR_MESSAGE_PARSER'] . ': <br /><br />' . implode('<br />', $message_parser->warn_msg), __LINE__, __FILE__, true);
1274      }
1275  
1276      $convert->row['mp_bbcode_bitfield'] = $convert_row['mp_bbcode_bitfield'] = $message_parser->bbcode_bitfield;
1277  
1278      $message = $message_parser->message;
1279      unset($message_parser->message);
1280  
1281      return $message;
1282  }
1283  
1284  /**
1285  * Return the bitfield calculated by the previous function
1286  */
1287  function get_bbcode_bitfield()
1288  {
1289      global $convert_row;
1290  
1291      return $convert_row['mp_bbcode_bitfield'];
1292  }
1293  
1294  /**
1295  * Determine the last user to edit a post
1296  * In practice we only tracked edits by the original poster in 2.0.x so this will only be set if they had edited their own post
1297  */
1298  function phpbb_post_edit_user()
1299  {
1300      global $convert_row;
1301  
1302      if (isset($convert_row['post_edit_count']))
1303      {
1304          return phpbb_user_id($convert_row['poster_id']);
1305      }
1306  
1307      return 0;
1308  }
1309  
1310  /**
1311  * Obtain the path to uploaded files on the 2.0.x forum
1312  * This is only used if the Attachment MOD was installed
1313  */
1314  function phpbb_get_files_dir()
1315  {
1316      if (!defined('MOD_ATTACHMENT'))
1317      {
1318          return;
1319      }
1320  
1321      global $src_db, $same_db, $convert, $user;
1322  
1323      if ($convert->mysql_convert && $same_db)
1324      {
1325          $src_db->sql_query("SET NAMES 'binary'");
1326      }
1327      $sql = 'SELECT config_value AS upload_dir
1328          FROM ' . $convert->src_table_prefix . "attachments_config
1329          WHERE config_name = 'upload_dir'";
1330      $result = $src_db->sql_query($sql);
1331      $upload_path = $src_db->sql_fetchfield('upload_dir');
1332      $src_db->sql_freeresult($result);
1333  
1334      $sql = 'SELECT config_value AS ftp_upload
1335          FROM ' . $convert->src_table_prefix . "attachments_config
1336          WHERE config_name = 'allow_ftp_upload'";
1337      $result = $src_db->sql_query($sql);
1338      $ftp_upload = (int) $src_db->sql_fetchfield('ftp_upload');
1339      $src_db->sql_freeresult($result);
1340  
1341      if ($convert->mysql_convert && $same_db)
1342      {
1343          $src_db->sql_query("SET NAMES 'utf8'");
1344      }
1345  
1346      if ($ftp_upload)
1347      {
1348          $convert->p_master->error($user->lang['CONV_ERROR_ATTACH_FTP_DIR'], __LINE__, __FILE__);
1349      }
1350  
1351      return $upload_path;
1352  }
1353  
1354  /**
1355  * Copy thumbnails of uploaded images from the 2.0.x forum
1356  * This is only used if the Attachment MOD was installed
1357  */
1358  function phpbb_copy_thumbnails()
1359  {
1360      global $convert, $config, $phpbb_root_path;
1361  
1362      $src_path = $convert->options['forum_path'] . '/' . phpbb_get_files_dir() . '/thumbs/';
1363  
1364      if ($handle = @opendir($src_path))
1365      {
1366          while ($entry = readdir($handle))
1367          {
1368              if ($entry[0] == '.')
1369              {
1370                  continue;
1371              }
1372  
1373              if (is_dir($src_path . $entry))
1374              {
1375                  continue;
1376              }
1377              else
1378              {
1379                  copy_file($src_path . $entry, $config['upload_path'] . '/' . preg_replace('/^t_/', 'thumb_', $entry));
1380                  @unlink($phpbb_root_path . $config['upload_path'] . '/thumbs/' . $entry);
1381              }
1382          }
1383          closedir($handle);
1384      }
1385  }
1386  
1387  /**
1388  * Convert the attachment category constants
1389  * This is only used if the Attachment MOD was installed
1390  */
1391  function phpbb_attachment_category($cat_id)
1392  {
1393      switch ($cat_id)
1394      {
1395          case 1:
1396              return ATTACHMENT_CATEGORY_IMAGE;
1397          break;
1398  
1399          case 2:
1400              return ATTACHMENT_CATEGORY_WM;
1401          break;
1402      }
1403  
1404      return ATTACHMENT_CATEGORY_NONE;
1405  }
1406  
1407  /**
1408  * Convert the attachment extension names
1409  * This is only used if the Attachment MOD was installed
1410  */
1411  function phpbb_attachment_extension_group_name()
1412  {
1413      global $db, $phpbb_root_path, $phpEx;
1414  
1415      // Update file extension group names to use language strings.
1416      $sql = 'SELECT lang_dir
1417          FROM ' . LANG_TABLE;
1418      $result = $db->sql_query($sql);
1419  
1420      $extension_groups_updated = array();
1421      while ($lang_dir = $db->sql_fetchfield('lang_dir'))
1422      {
1423          $lang_dir = basename($lang_dir);
1424          $lang_file = $phpbb_root_path . 'language/' . $lang_dir . '/acp/attachments.' . $phpEx;
1425  
1426          if (!file_exists($lang_file))
1427          {
1428              continue;
1429          }
1430  
1431          $lang = array();
1432          include($lang_file);
1433  
1434          foreach ($lang as $lang_key => $lang_val)
1435          {
1436              if (isset($extension_groups_updated[$lang_key]) || strpos($lang_key, 'EXT_GROUP_') !== 0)
1437              {
1438                  continue;
1439              }
1440  
1441              $sql_ary = array(
1442                  'group_name'    => substr($lang_key, 10), // Strip off 'EXT_GROUP_'
1443              );
1444  
1445              $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . '
1446                  SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
1447                      WHERE group_name = '" . $db->sql_escape($lang_val) . "'";
1448              $db->sql_query($sql);
1449  
1450              $extension_groups_updated[$lang_key] = true;
1451          }
1452      }
1453      $db->sql_freeresult($result);
1454  }
1455  
1456  /**
1457  * Obtain list of forums in which different attachment categories can be used
1458  */
1459  function phpbb_attachment_forum_perms($forum_permissions)
1460  {
1461      if (empty($forum_permissions))
1462      {
1463          return '';
1464      }
1465  
1466      // Decode forum permissions
1467      $forum_ids = array();
1468  
1469      $one_char_encoding = '#';
1470      $two_char_encoding = '.';
1471  
1472      $auth_len = 1;
1473      for ($pos = 0; $pos < strlen($forum_permissions); $pos += $auth_len)
1474      {
1475          $forum_auth = substr($forum_permissions, $pos, 1);
1476          if ($forum_auth == $one_char_encoding)
1477          {
1478              $auth_len = 1;
1479              continue;
1480          }
1481          else if ($forum_auth == $two_char_encoding)
1482          {
1483              $auth_len = 2;
1484              $pos--;
1485              continue;
1486          }
1487  
1488          $forum_auth = substr($forum_permissions, $pos, $auth_len);
1489          $forum_id = base64_unpack($forum_auth);
1490  
1491          $forum_ids[] = (int) $forum_id;
1492      }
1493  
1494      if (count($forum_ids))
1495      {
1496          return attachment_forum_perms($forum_ids);
1497      }
1498  
1499      return '';
1500  }
1501  
1502  /**
1503  * Convert the avatar type constants
1504  */
1505  function phpbb_avatar_type($type)
1506  {
1507      switch ($type)
1508      {
1509          case 1:
1510              return AVATAR_UPLOAD;
1511          break;
1512  
1513          case 2:
1514              return AVATAR_REMOTE;
1515          break;
1516  
1517          case 3:
1518              return AVATAR_GALLERY;
1519          break;
1520      }
1521  
1522      return 0;
1523  }
1524  
1525  
1526  /**
1527  * Just undos the replacing of '<' and '>'
1528  */
1529  function  phpbb_smilie_html_decode($code)
1530  {
1531      $code = str_replace('&lt;', '<', $code);
1532      return str_replace('&gt;', '>', $code);
1533  }
1534  
1535  /**
1536  * Transfer avatars, copying the image if it was uploaded
1537  */
1538  function phpbb_import_avatar($user_avatar)
1539  {
1540      global $convert_row;
1541  
1542      if (!$convert_row['user_avatar_type'])
1543      {
1544          return '';
1545      }
1546      else if ($convert_row['user_avatar_type'] == 1)
1547      {
1548          // Uploaded avatar
1549          return import_avatar($user_avatar, false, $convert_row['user_id']);
1550      }
1551      else if ($convert_row['user_avatar_type'] == 2)
1552      {
1553          // Remote avatar
1554          return $user_avatar;
1555      }
1556      else if ($convert_row['user_avatar_type'] == 3)
1557      {
1558          // Gallery avatar
1559          return $user_avatar;
1560      }
1561  
1562      return '';
1563  }
1564  
1565  
1566  /**
1567  * Find out about the avatar's dimensions
1568  */
1569  function phpbb_get_avatar_height($user_avatar)
1570  {
1571      global $convert_row;
1572  
1573      if (empty($convert_row['user_avatar_type']))
1574      {
1575          return 0;
1576      }
1577      return get_avatar_height($user_avatar, 'phpbb_avatar_type', $convert_row['user_avatar_type']);
1578  }
1579  
1580  
1581  /**
1582  * Find out about the avatar's dimensions
1583  */
1584  function phpbb_get_avatar_width($user_avatar)
1585  {
1586      global $convert_row;
1587  
1588      if (empty($convert_row['user_avatar_type']))
1589      {
1590          return 0;
1591      }
1592  
1593      return get_avatar_width($user_avatar, 'phpbb_avatar_type', $convert_row['user_avatar_type']);
1594  }
1595  
1596  
1597  /**
1598  * Calculate the correct to_address field for private messages
1599  */
1600  function phpbb_privmsgs_to_userid($to_userid)
1601  {
1602      return 'u_' . phpbb_user_id($to_userid);
1603  }
1604  
1605  /**
1606  * Calculate whether a private message was unread using the bitfield
1607  */
1608  function phpbb_unread_pm($pm_type)
1609  {
1610      return ($pm_type == 5) ? 1 : 0;
1611  }
1612  
1613  /**
1614  * Calculate whether a private message was new using the bitfield
1615  */
1616  function phpbb_new_pm($pm_type)
1617  {
1618      return ($pm_type == 1) ? 1 : 0;
1619  }
1620  
1621  /**
1622  * Obtain the folder_id for the custom folder created to replace the savebox from 2.0.x (used to store saved private messages)
1623  */
1624  function phpbb_get_savebox_id($user_id)
1625  {
1626      global $db;
1627  
1628      $user_id = phpbb_user_id($user_id);
1629  
1630      // Only one custom folder, check only one
1631      $sql = 'SELECT folder_id
1632          FROM ' . PRIVMSGS_FOLDER_TABLE . '
1633          WHERE user_id = ' . $user_id;
1634      $result = $db->sql_query_limit($sql, 1);
1635      $folder_id = (int) $db->sql_fetchfield('folder_id');
1636      $db->sql_freeresult($result);
1637  
1638      return $folder_id;
1639  }
1640  
1641  /**
1642  * Transfer attachment specific configuration options
1643  * These were not stored in the main config table on 2.0.x
1644  * This is only used if the Attachment MOD was installed
1645  */
1646  function phpbb_import_attach_config()
1647  {
1648      global $src_db, $same_db, $convert, $config;
1649  
1650      if ($convert->mysql_convert && $same_db)
1651      {
1652          $src_db->sql_query("SET NAMES 'binary'");
1653      }
1654  
1655      $sql = 'SELECT *
1656          FROM ' . $convert->src_table_prefix . 'attachments_config';
1657      $result = $src_db->sql_query($sql);
1658  
1659      if ($convert->mysql_convert && $same_db)
1660      {
1661          $src_db->sql_query("SET NAMES 'utf8'");
1662      }
1663  
1664      $attach_config = array();
1665      while ($row = $src_db->sql_fetchrow($result))
1666      {
1667          $attach_config[$row['config_name']] = $row['config_value'];
1668      }
1669      $src_db->sql_freeresult($result);
1670  
1671      $config->set('allow_attachments', 1);
1672  
1673      // old attachment mod? Must be very old if this entry do not exist...
1674      if (!empty($attach_config['display_order']))
1675      {
1676          $config->set('display_order', $attach_config['display_order']);
1677      }
1678      $config->set('max_filesize', $attach_config['max_filesize']);
1679      $config->set('max_filesize_pm', $attach_config['max_filesize_pm']);
1680      $config->set('attachment_quota', $attach_config['attachment_quota']);
1681      $config->set('max_attachments', $attach_config['max_attachments']);
1682      $config->set('max_attachments_pm', $attach_config['max_attachments_pm']);
1683      $config->set('allow_pm_attach', $attach_config['allow_pm_attach']);
1684  
1685      $config->set('img_display_inlined', $attach_config['img_display_inlined']);
1686      $config->set('img_max_width', $attach_config['img_max_width']);
1687      $config->set('img_max_height', $attach_config['img_max_height']);
1688      $config->set('img_link_width', $attach_config['img_link_width']);
1689      $config->set('img_link_height', $attach_config['img_link_height']);
1690      $config->set('img_create_thumbnail', $attach_config['img_create_thumbnail']);
1691      $config->set('img_max_thumb_width', 400);
1692      $config->set('img_min_thumb_filesize', $attach_config['img_min_thumb_filesize']);
1693  }
1694  
1695  /**
1696  * Calculate the date a user became inactive
1697  */
1698  function phpbb_inactive_time()
1699  {
1700      global $convert_row;
1701  
1702      if ($convert_row['user_active'])
1703      {
1704          return 0;
1705      }
1706  
1707      if ($convert_row['user_lastvisit'])
1708      {
1709          return $convert_row['user_lastvisit'];
1710      }
1711  
1712      return $convert_row['user_regdate'];
1713  }
1714  
1715  /**
1716  * Calculate the reason a user became inactive
1717  * We can't actually tell the difference between a manual deactivation and one for profile changes
1718  * from the data available to assume the latter
1719  */
1720  function phpbb_inactive_reason()
1721  {
1722      global $convert_row;
1723  
1724      if ($convert_row['user_active'])
1725      {
1726          return 0;
1727      }
1728  
1729      if ($convert_row['user_lastvisit'])
1730      {
1731          return INACTIVE_PROFILE;
1732      }
1733  
1734      return INACTIVE_REGISTER;
1735  }
1736  
1737  /**
1738  * Adjust 2.0.x disallowed names to 3.0.x format
1739  */
1740  function phpbb_disallowed_username($username)
1741  {
1742      // Replace * with %
1743      $username = phpbb_set_default_encoding(str_replace('*', '%', $username));
1744      return utf8_htmlspecialchars($username);
1745  }
1746  
1747  /**
1748  * Checks whether there are any usernames on the old board that would map to the same
1749  * username_clean on phpBB3. Prints out a list if any exist and exits.
1750  */
1751  function phpbb_create_userconv_table()
1752  {
1753      global $db;
1754  
1755      switch ($db->get_sql_layer())
1756      {
1757          case 'mysqli':
1758              $map_dbms = 'mysql_41';
1759          break;
1760  
1761          case 'mssql_odbc':
1762          case 'mssqlnative':
1763              $map_dbms = 'mssql';
1764          break;
1765  
1766          default:
1767              $map_dbms = $db->get_sql_layer();
1768          break;
1769      }
1770  
1771      // create a temporary table in which we store the clean usernames
1772      $drop_sql = 'DROP TABLE ' . USERCONV_TABLE;
1773      switch ($map_dbms)
1774      {
1775          case 'mssql':
1776              $create_sql = 'CREATE TABLE [' . USERCONV_TABLE . '] (
1777                  [user_id] [int] NOT NULL ,
1778                  [username_clean] [varchar] (255) DEFAULT (\'\') NOT NULL
1779              )';
1780          break;
1781  
1782          case 'mysql_41':
1783              $create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' (
1784                  user_id mediumint(8) NOT NULL,
1785                  username_clean varchar(255) DEFAULT \'\' NOT NULL
1786              ) CHARACTER SET `utf8` COLLATE `utf8_bin`';
1787          break;
1788  
1789          case 'oracle':
1790              $create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' (
1791                  user_id number(8) NOT NULL,
1792                  username_clean varchar2(255) DEFAULT \'\'
1793              )';
1794          break;
1795  
1796          case 'postgres':
1797              $create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' (
1798                  user_id INT4 DEFAULT \'0\',
1799                  username_clean varchar_ci DEFAULT \'\' NOT NULL
1800              )';
1801          break;
1802  
1803          case 'sqlite3':
1804              $create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' (
1805                  user_id INTEGER NOT NULL DEFAULT \'0\',
1806                  username_clean varchar(255) NOT NULL DEFAULT \'\'
1807              )';
1808          break;
1809      }
1810  
1811      $db->sql_return_on_error(true);
1812      $db->sql_query($drop_sql);
1813      $db->sql_return_on_error(false);
1814      $db->sql_query($create_sql);
1815  }
1816  
1817  function phpbb_check_username_collisions()
1818  {
1819      global $db, $src_db, $convert, $user, $lang;
1820  
1821      // now find the clean version of the usernames that collide
1822      $sql = 'SELECT username_clean
1823          FROM ' . USERCONV_TABLE .'
1824          GROUP BY username_clean
1825          HAVING COUNT(user_id) > 1';
1826      $result = $db->sql_query($sql);
1827  
1828      $colliding_names = array();
1829      while ($row = $db->sql_fetchrow($result))
1830      {
1831          $colliding_names[] = $row['username_clean'];
1832      }
1833      $db->sql_freeresult($result);
1834  
1835      // there was at least one collision, the admin will have to solve it before conversion can continue
1836      if (count($colliding_names))
1837      {
1838          $sql = 'SELECT user_id, username_clean
1839              FROM ' . USERCONV_TABLE . '
1840              WHERE ' . $db->sql_in_set('username_clean', $colliding_names);
1841          $result = $db->sql_query($sql);
1842          unset($colliding_names);
1843  
1844          $colliding_user_ids = array();
1845          while ($row = $db->sql_fetchrow($result))
1846          {
1847              $colliding_user_ids[(int) $row['user_id']] = $row['username_clean'];
1848          }
1849          $db->sql_freeresult($result);
1850  
1851          $sql = 'SELECT username, user_id, user_posts
1852              FROM ' . $convert->src_table_prefix . 'users
1853              WHERE ' . $src_db->sql_in_set('user_id', array_keys($colliding_user_ids));
1854          $result = $src_db->sql_query($sql);
1855  
1856          $colliding_users = array();
1857          while ($row = $src_db->sql_fetchrow($result))
1858          {
1859              $row['user_id'] = (int) $row['user_id'];
1860              if (isset($colliding_user_ids[$row['user_id']]))
1861              {
1862                  $colliding_users[$colliding_user_ids[$row['user_id']]][] = $row;
1863              }
1864          }
1865          $src_db->sql_freeresult($result);
1866          unset($colliding_user_ids);
1867  
1868          $list = '';
1869          foreach ($colliding_users as $username_clean => $users)
1870          {
1871              $list .= sprintf($user->lang['COLLIDING_CLEAN_USERNAME'], $username_clean) . "<br />\n";
1872              foreach ($users as $i => $row)
1873              {
1874                  $list .= sprintf($user->lang['COLLIDING_USER'], $row['user_id'], phpbb_set_default_encoding($row['username']), $row['user_posts']) . "<br />\n";
1875              }
1876          }
1877  
1878          $lang['INST_ERR_FATAL'] = $user->lang['CONV_ERR_FATAL'];
1879          $convert->p_master->error('<span style="color:red">' . $user->lang['COLLIDING_USERNAMES_FOUND'] . '</span></b><br /><br />' . $list . '<b>', __LINE__, __FILE__);
1880      }
1881  
1882      $drop_sql = 'DROP TABLE ' . USERCONV_TABLE;
1883      $db->sql_query($drop_sql);
1884  }
1885  
1886  function phpbb_convert_timezone($timezone)
1887  {
1888      global $config, $db, $phpbb_root_path, $phpEx, $table_prefix;
1889  
1890      $factory = new \phpbb\db\tools\factory();
1891      $timezone_migration = new \phpbb\db\migration\data\v310\timezone($config, $db, $factory->get($db), $phpbb_root_path, $phpEx, $table_prefix);
1892      return $timezone_migration->convert_phpbb30_timezone($timezone, 0);
1893  }
1894  
1895  function phpbb_add_notification_options($user_notify_pm)
1896  {
1897      global $convert_row, $db;
1898  
1899      $user_id = phpbb_user_id($convert_row['user_id']);
1900      if ($user_id == ANONYMOUS)
1901      {
1902          return;
1903      }
1904  
1905      $rows = array();
1906  
1907      $rows[] = array(
1908          'item_type'        => 'post',
1909          'item_id'        => 0,
1910          'user_id'        => (int) $user_id,
1911          'notify'        => 1,
1912          'method'        => 'email',
1913      );
1914      $rows[] = array(
1915          'item_type'        => 'topic',
1916          'item_id'        => 0,
1917          'user_id'        => (int) $user_id,
1918          'notify'        => 1,
1919          'method'        => 'email',
1920      );
1921      if ($user_notify_pm)
1922      {
1923          $rows[] = array(
1924              'item_type'        => 'pm',
1925              'item_id'        => 0,
1926              'user_id'        => (int) $user_id,
1927              'notify'        => 1,
1928              'method'        => 'email',
1929          );
1930      }
1931  
1932      $db->sql_multi_insert(USER_NOTIFICATIONS_TABLE, $rows);
1933  }
1934  
1935  function phpbb_convert_password_hash($hash)
1936  {
1937      global $phpbb_container;
1938  
1939      /* @var $manager \phpbb\passwords\manager */
1940      $manager = $phpbb_container->get('passwords.manager');
1941      $hash = $manager->hash($hash, '$H$');
1942  
1943      return '$CP$' . $hash;
1944  }


Generated: Tue Apr 7 19:44:41 2020 Cross-referenced by PHPXref 0.7.1