1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 05:50:42 +02:00

Merge remote-tracking branch 'github-marc1706/ticket/12352' into develop-ascraeus

* github-marc1706/ticket/12352: (33 commits)
  [ticket/12352] Do not check hashes that don't have the necessary length
  [ticket/12352] Update file headers to fit new format
  [ticket/12352] Use custom provider collection for auth providers
  [ticket/12352] Add checks for existing user_pass_convert to migrations
  [ticket/12352] Remove usages of user_pass_convert column
  [ticket/12352] Update schema json file
  [ticket/12352] Remove user_pass_convert column from database
  [ticket/12352] Check each newly added passwords driver in manager_test
  [ticket/12352] Add get_settings_only method to passwords driver base
  [ticket/12352] Add passwords driver for xenforo 1.0, 1.1 passwords
  [ticket/12352] Add tests for wcf1 and wcf2 drivers
  [ticket/12352] Add driver for woltlab community framework 1 passwords
  [ticket/12352] Add driver for woltlab community framework 2 passwords
  [ticket/12352] Add missing $ to md5_mybb and md5_vb driver
  [ticket/12352] Fix spacing in passwords tests
  [ticket/12352] Add passwords driver for vB passwords
  [ticket/12352] Use correct hashing method in md5_mybb driver
  [ticket/12352] Add driver for myBB md5 passwords
  [ticket/12352] Rename phpbb2_md5 driver to fit filenames of other drivers
  [ticket/12352] Add passwords driver for sha1 password hashes
  ...
This commit is contained in:
Nils Adermann
2014-06-11 14:27:57 +02:00
35 changed files with 1335 additions and 113 deletions

View File

@@ -0,0 +1,85 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\db\migration\data\v310;
class passwords_convert_p1 extends \phpbb\db\migration\migration
{
static public function depends_on()
{
return array('\phpbb\db\migration\data\v310\passwords_p2');
}
public function update_data()
{
return array(
array('custom', array(array($this, 'update_passwords'))),
);
}
public function update_passwords($start)
{
// Nothing to do if user_pass_convert column doesn't exist
if (!$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_pass_convert'))
{
return;
}
$start = (int) $start;
$limit = 1000;
$converted_users = 0;
$sql = 'SELECT user_password, user_id
FROM ' . $this->table_prefix . 'users
WHERE user_pass_convert = 1
GROUP BY user_id
ORDER BY user_id';
$result = $this->db->sql_query_limit($sql, $limit, $start);
$update_users = array();
while ($row = $this->db->sql_fetchrow($result))
{
$converted_users++;
$user_id = (int) $row['user_id'];
// Only prefix passwords without proper prefix
if (!isset($update_users[$user_id]) && !preg_match('#^\$([a-zA-Z0-9\\\]*?)\$#', $row['user_password']))
{
// Use $CP$ prefix for passwords that need to
// be converted and set pass convert to false.
$update_users[$user_id] = array(
'user_password' => '$CP$' . $row['user_password'],
'user_pass_convert' => 0,
);
}
}
$this->db->sql_freeresult($result);
foreach ($update_users as $user_id => $user_data)
{
$sql = 'UPDATE ' . $this->table_prefix . 'users
SET ' . $this->db->sql_build_array('UPDATE', $user_data) . '
WHERE user_id = ' . $user_id;
$this->sql_query($sql);
}
if ($converted_users < $limit)
{
// There are no more users to be converted
return;
}
// There are still more users to query, return the next start value
return $start + $limit;
}
}

View File

@@ -0,0 +1,49 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\db\migration\data\v310;
class passwords_convert_p2 extends \phpbb\db\migration\migration
{
public function effectively_installed()
{
return !$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_pass_convert');
}
static public function depends_on()
{
return array('\phpbb\db\migration\data\v310\passwords_convert_p1');
}
public function update_schema()
{
return array(
'drop_columns' => array(
$this->table_prefix . 'users' => array(
'user_pass_convert',
),
),
);
}
public function revert_schema()
{
return array(
'add_columns' => array(
$this->table_prefix . 'users' => array(
'user_pass_convert' => array('BOOL', 0, 'after' => 'user_passchg'),
),
),
);
}
}