mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
script to convert 2.0.x usernames to 2.0.5. Existing 2.0.5 usernames will be not affected by this.
git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@4177 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
5a13b0710d
commit
7af3199e0c
1 changed files with 67 additions and 0 deletions
67
phpBB/develop/convert_usernames.php
Normal file
67
phpBB/develop/convert_usernames.php
Normal file
|
@ -0,0 +1,67 @@
|
|||
<html>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
//
|
||||
// Security message:
|
||||
//
|
||||
// This script is potentially dangerous.
|
||||
// Remove or comment the next line (die(".... ) to enable this script.
|
||||
// Do NOT FORGET to either remove this script or disable it after you have used it.
|
||||
//
|
||||
die("Please read the first lines of this script for instructions on how to enable it");
|
||||
|
||||
//
|
||||
// Do not change anything below this line.
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// Convert 2.0.x Usernames to the new 2.0.5 Username format.
|
||||
//
|
||||
|
||||
chdir("../");
|
||||
|
||||
define('IN_PHPBB', true);
|
||||
include('extension.inc');
|
||||
include('config.'.$phpEx);
|
||||
include('includes/constants.'.$phpEx);
|
||||
include('includes/db.'.$phpEx);
|
||||
|
||||
$sql = "SELECT user_id, username
|
||||
FROM " . USERS_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if(!$result)
|
||||
{
|
||||
die("Unable to get users");
|
||||
}
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
if (!preg_match('#(>)|(<)|(")|(&)#', $row['username']))
|
||||
{
|
||||
if ($row['username'] != htmlspecialchars($row['username']))
|
||||
{
|
||||
flush();
|
||||
$sql = "UPDATE " . USERS_TABLE . "
|
||||
SET username = '" . str_replace("'", "''", htmlspecialchars($row['username'])) . "'
|
||||
WHERE user_id = " . $row['user_id'];
|
||||
if (!$db->sql_query($sql))
|
||||
{
|
||||
echo "ERROR: Unable to rename user " . htmlspecialchars($row['username']) . " with ID " . $row['user_id'] . "<br>";
|
||||
echo "<pre>" . print_r($db->sql_error()) . "</pre><br />$sql";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Renamed User " . htmlspecialchars($row['username']) . " with ID " . $row['user_id'] . "<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "<br>That's All Folks!";
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Reference in a new issue