1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-23 11:28:33 +01:00
php-phpbb/phpBB/develop/update_email_hash.php
Igor Wiedler af5b9a9640 [ticket/9556] Drop php closing tags, add trailing newline
Closing tags converted using Oleg's script.
remove-php-end-tags.py -a .

Trailing newlines added using the following where $ext is file extension.
find . -type f -name "*.$ext" -print | xargs printf "e %s\nw\n" | ed -s;

Extensions: php, css, html, js, xml.

PHPBB3-9556
2010-11-11 19:10:55 +01:00

57 lines
1.2 KiB
PHP

<?php
/**
* Corrects user_email_hash values if DB moved from 32-bit system to 64-bit system or vice versa.
* The CRC32 function in PHP generates different results for both systems.
* @PHP dev team: no, a hexdec() applied to it does not solve the issue. And please document it.
*
*/
die("Please read the first lines of this script for instructions on how to enable it");
set_time_limit(0);
define('IN_PHPBB', true);
$phpbb_root_path = './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
$start = request_var('start', 0);
$num_items = 1000;
echo '<br />Updating user email hashes' . "\n";
$sql = 'SELECT user_id, user_email
FROM ' . USERS_TABLE . '
ORDER BY user_id ASC';
$result = $db->sql_query($sql);
$echos = 0;
while ($row = $db->sql_fetchrow($result))
{
$echos++;
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_email_hash = '" . $db->sql_escape(phpbb_email_hash($row['user_email'])) . "'
WHERE user_id = " . (int) $row['user_id'];
$db->sql_query($sql);
if ($echos == 200)
{
echo '<br />';
$echos = 0;
}
echo '.';
flush();
}
$db->sql_freeresult($result);
echo 'FINISHED';
// Done
$db->sql_close();