Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
passwords_convert_p1.php
01 <?php
02 /**
03 *
04 * This file is part of the phpBB Forum Software package.
05 *
06 * @copyright (c) phpBB Limited <https://www.phpbb.com>
07 * @license GNU General Public License, version 2 (GPL-2.0)
08 *
09 * For full copyright and license information, please see
10 * the docs/CREDITS.txt file.
11 *
12 */
13
14 namespace phpbb\db\migration\data\v310;
15
16 class passwords_convert_p1 extends \phpbb\db\migration\migration
17 {
18 static public function depends_on()
19 {
20 return array('\phpbb\db\migration\data\v310\passwords_p2');
21 }
22
23 public function update_data()
24 {
25 return array(
26 array('custom', array(array($this, 'update_passwords'))),
27 );
28 }
29
30 public function update_passwords($start)
31 {
32 // Nothing to do if user_pass_convert column doesn't exist
33 if (!$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_pass_convert'))
34 {
35 return;
36 }
37
38 $start = (int) $start;
39 $limit = 1000;
40 $converted_users = 0;
41
42 $sql = 'SELECT user_password, user_id
43 FROM ' . $this->table_prefix . 'users
44 WHERE user_pass_convert = 1
45 ORDER BY user_id';
46 $result = $this->db->sql_query_limit($sql, $limit, $start);
47
48 $update_users = array();
49 while ($row = $this->db->sql_fetchrow($result))
50 {
51 $converted_users++;
52
53 $user_id = (int) $row['user_id'];
54 // Only prefix passwords without proper prefix
55 if (!isset($update_users[$user_id]) && !preg_match('#^\$([a-zA-Z0-9\\\]*?)\$#', $row['user_password']))
56 {
57 // Use $CP$ prefix for passwords that need to
58 // be converted and set pass convert to false.
59 $update_users[$user_id] = array(
60 'user_password' => '$CP$' . $row['user_password'],
61 'user_pass_convert' => 0,
62 );
63 }
64 }
65 $this->db->sql_freeresult($result);
66
67 foreach ($update_users as $user_id => $user_data)
68 {
69 $sql = 'UPDATE ' . $this->table_prefix . 'users
70 SET ' . $this->db->sql_build_array('UPDATE', $user_data) . '
71 WHERE user_id = ' . $user_id;
72 $this->sql_query($sql);
73 }
74
75 if ($converted_users < $limit)
76 {
77 // There are no more users to be converted
78 return;
79 }
80
81 // There are still more users to query, return the next start value
82 return $start + $limit;
83 }
84 }
85