mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-04-30 03:09:22 +02:00
Fix #205 special/database2znoteaac.php
Conversion of old accounts works with TFS_10. Should work with TFS_02 and TFS_03 too but untested.
This commit is contained in:
parent
ab2f40df72
commit
fff61ef79d
@ -17,7 +17,12 @@ require '../engine/function/users.php';
|
|||||||
|
|
||||||
// install functions
|
// install functions
|
||||||
function fetch_all_accounts() {
|
function fetch_all_accounts() {
|
||||||
return mysql_select_multi("SELECT `id` FROM `accounts`");
|
$results = mysql_select_multi("SELECT `id` FROM `accounts`");
|
||||||
|
$accounts = array();
|
||||||
|
foreach ($results as $row) {
|
||||||
|
$accounts[] = $row['id'];
|
||||||
|
}
|
||||||
|
return (count($accounts) > 0) ? $accounts : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_count_znote_accounts() {
|
function user_count_znote_accounts() {
|
||||||
@ -31,7 +36,12 @@ require '../engine/function/users.php';
|
|||||||
}
|
}
|
||||||
|
|
||||||
function fetch_znote_accounts() {
|
function fetch_znote_accounts() {
|
||||||
return mysql_select_multi("SELECT `account_id` FROM `znote_accounts`");
|
$results = mysql_select_multi("SELECT `account_id` FROM `znote_accounts`");
|
||||||
|
$accounts = array();
|
||||||
|
foreach ($results as $row) {
|
||||||
|
$accounts[] = $row['account_id'];
|
||||||
|
}
|
||||||
|
return (count($accounts) > 0) ? $accounts : false;
|
||||||
}
|
}
|
||||||
// end install functions
|
// end install functions
|
||||||
|
|
||||||
@ -39,7 +49,7 @@ require '../engine/function/users.php';
|
|||||||
$all_account = fetch_all_accounts();
|
$all_account = fetch_all_accounts();
|
||||||
$znote_account = fetch_znote_accounts();
|
$znote_account = fetch_znote_accounts();
|
||||||
if ($all_account !== false) {
|
if ($all_account !== false) {
|
||||||
if ($znote_account != false) { // If existing znote compatible account exists:
|
if ($znote_account !== false) { // If existing znote compatible account exists:
|
||||||
foreach ($all_account as $all) { // Loop through every element in znote_account array
|
foreach ($all_account as $all) { // Loop through every element in znote_account array
|
||||||
if (!in_array($all, $znote_account)) {
|
if (!in_array($all, $znote_account)) {
|
||||||
$old_accounts[] = $all;
|
$old_accounts[] = $all;
|
||||||
@ -58,7 +68,7 @@ require '../engine/function/users.php';
|
|||||||
echo '<br>';
|
echo '<br>';
|
||||||
echo 'Total accounts detected: '. count($all_account) .'.';
|
echo 'Total accounts detected: '. count($all_account) .'.';
|
||||||
|
|
||||||
if (isset($znote_account)) {
|
if (isset($znote_account) && $znote_account !== false) {
|
||||||
echo '<br>';
|
echo '<br>';
|
||||||
echo 'Znote compatible accounts detected: '. count($znote_account) .'.';
|
echo 'Znote compatible accounts detected: '. count($znote_account) .'.';
|
||||||
|
|
||||||
@ -82,25 +92,23 @@ require '../engine/function/users.php';
|
|||||||
if (isset($old_accounts) && $old_accounts !== false) {
|
if (isset($old_accounts) && $old_accounts !== false) {
|
||||||
$time = time();
|
$time = time();
|
||||||
foreach ($old_accounts as $old) {
|
foreach ($old_accounts as $old) {
|
||||||
// Get acc id
|
|
||||||
$old_id = $old['id'];
|
|
||||||
|
|
||||||
// Make acc data compatible:
|
// Make acc data compatible:
|
||||||
mysql_insert("INSERT INTO `znote_accounts` (`account_id`, `ip`, `created`) VALUES ('$old_id', '0', '$time')");
|
mysql_insert("INSERT INTO `znote_accounts` (`account_id`, `ip`, `created`) VALUES ('$old', '0', '$time')");
|
||||||
$updated_acc += 1;
|
$updated_acc += 1;
|
||||||
|
|
||||||
// Fetch unsalted password
|
// Fetch unsalted password
|
||||||
if ($config['TFSVersion'] == 'TFS_03' && $config['salt'] === true) {
|
if ($config['TFSVersion'] == 'TFS_03' && $config['salt'] === true) {
|
||||||
$password = user_data($old_id, 'password', 'salt');
|
$password = user_data($old, 'password', 'salt');
|
||||||
$p_pass = str_replace($password['salt'],"",$password['password']);
|
$p_pass = str_replace($password['salt'],"",$password['password']);
|
||||||
}
|
}
|
||||||
if ($config['TFSVersion'] == 'TFS_02' || $config['salt'] === false) {
|
if ($config['TFSVersion'] == 'TFS_02' || $config['salt'] === false) {
|
||||||
$password = user_data($old_id, 'password');
|
$password = user_data($old, 'password');
|
||||||
$p_pass = $password['password'];
|
$p_pass = $password['password'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify lenght of password is less than 28 characters (most likely a plain password)
|
// Verify lenght of password is less than 28 characters (most likely a plain password)
|
||||||
if (strlen($p_pass) < 28 && $old_id > 1) {
|
if (strlen($p_pass) < 28 && $old > 1) {
|
||||||
// encrypt it with sha1
|
// encrypt it with sha1
|
||||||
if ($config['TFSVersion'] == 'TFS_02' || $config['salt'] === false) $p_pass = sha1($p_pass);
|
if ($config['TFSVersion'] == 'TFS_02' || $config['salt'] === false) $p_pass = sha1($p_pass);
|
||||||
if ($config['TFSVersion'] == 'TFS_03' && $config['salt'] === true) $p_pass = sha1($password['salt'].$p_pass);
|
if ($config['TFSVersion'] == 'TFS_03' && $config['salt'] === true) $p_pass = sha1($password['salt'].$p_pass);
|
||||||
@ -125,10 +133,10 @@ require '../engine/function/users.php';
|
|||||||
// Lets loop through the character list
|
// Lets loop through the character list
|
||||||
foreach ($chars as $c) {
|
foreach ($chars as $c) {
|
||||||
// Is character not compatible yet?
|
// Is character not compatible yet?
|
||||||
if (user_character_is_compatible($c) == 0) {
|
if (user_character_is_compatible($c['id']) == 0) {
|
||||||
// Then lets make it compatible:
|
// Then lets make it compatible:
|
||||||
|
$cid = $c['id'];
|
||||||
mysql_insert("INSERT INTO `znote_players` (`player_id`, `created`, `hide_char`, `comment`) VALUES ('$c', '$time', '0', '')");
|
mysql_insert("INSERT INTO `znote_players` (`player_id`, `created`, `hide_char`, `comment`) VALUES ('$cid', '$time', '0', '')");
|
||||||
$updated_char += 1;
|
$updated_char += 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user