Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
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 /**
31 * Update passwords with convert flag to have $CP$ prefix
32 *
33 * @param int $start Limit start value
34 * @return int|void Null if conversion is finished, next start value if not
35 */
36 public function update_passwords($start)
37 {
38 // Nothing to do if user_pass_convert column doesn't exist
39 if (!$this->db_tools->sql_column_exists($this->table_prefix . 'users', 'user_pass_convert'))
40 {
41 return;
42 }
43
44 $start = (int) $start;
45 $limit = 1000;
46 $converted_users = 0;
47
48 $sql = 'SELECT user_password, user_id
49 FROM ' . $this->table_prefix . 'users
50 WHERE user_pass_convert = 1
51 ORDER BY user_id';
52 $result = $this->db->sql_query_limit($sql, $limit, $start);
53
54 $update_users = array();
55 while ($row = $this->db->sql_fetchrow($result))
56 {
57 $converted_users++;
58
59 $user_id = (int) $row['user_id'];
60 // Prefix all passwords that need to be converted
61 if (!isset($update_users[$user_id]))
62 {
63 // Use $CP$ prefix for passwords that need to
64 // be converted and set pass convert to false.
65 $update_users[$user_id] = '$CP$' . $row['user_password'];
66 }
67 }
68 $this->db->sql_freeresult($result);
69
70 foreach ($update_users as $user_id => $user_password)
71 {
72 $sql = 'UPDATE ' . $this->table_prefix . "users
73 SET user_password = '" . $this->db->sql_escape($user_password) . "'
74 WHERE user_id = $user_id";
75 $this->sql_query($sql);
76 }
77
78 if ($converted_users < $limit)
79 {
80 // There are no more users to be converted
81 return;
82 }
83
84 // There are still more users to query, return the next start value
85 return $start + $limit;
86 }
87 }
88