Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-25-2004, 05:56 PM
rikman rikman is offline
 
Join Date: Jun 2003
Location: Berlin/Germany
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Transfer user data from one vB to another

We want to start a second board and want to give the users the option to transfer their user data (from vB's table 'user') to our new board.

I got the following idea:

- get username, password, salt and email from the user table
- encrypt these and transfer to the new server
- decrypt data and insert into the other user table (if username or email isn't used already)
- tell the user, that his account has cloned and that he should update his profile/options

Transfer works fine, inserting into database too, but if I want to log in, vB gives me a redirect page that says "Thanks for logging in ...". After that the forum is shown right to left?! (Look at the screeshot that is attached)

Has anybody an idea what went wrong? Are there important settings I've ignored?

Logging in with normal created (vB's registration procedure) user names works fine.

This ist the script that the user runs (source server):

PHP Code:
<?PHP
/////////////////////////////////////////////////////////////////////////
//
// register_rrnews.php
//
// transfer of user data from one user table to another
//
// Marcus T. Jaschen <m@rikman.net>
// 2004-01-22
//
// Version 0.0.1 (alpha)
//
/////////////////////////////////////////////////////////////////////////

// debug mode and error reporting
error_reporting (E_ALL);
define ("DEBUG"true);

// constants
//     key for XOR encryption
define ("XORKEY""dskjfwjeltkcjhsfkdhgsdjkhgwrkytiwreygiwyr95t435tgkhfs,"); // only an example
//    remote script
define ("REMOTESCRIPT""http://www2.sampleserver.com/user_xfer/userdata_xfer_vb.php");

// other scripts
chdir ("../forum/");
require (
"global.php");
chdir ("../user_xfer/");
require (
"../tool/mysql.class.php");
require (
"../tool/page.class.php");

//////////////////////////////////////////////////////////////////////////

// create new HTML page
$p = new Page ("Userdaten transferieren nach rennrad-news.de");
$p->addHeader ();
$p->addH1 ("Userdaten transferieren nach rennrad-news.de");

if (
DEBUG) {
    
$p->addP ("<font color=\"red\">Debug-Modus aktiviert!</font>");
    
$p->addNewline ();
}

// get UserID from vB login information
$intUserID $bbuserinfo['userid'];

// get required user data from user table
$dbUser = new mysql ();
$dbUser->query ("SELECT username, password, email,salt FROM user WHERE userid = ".$intUserID);
$r $dbUser->next ();

$strPlainUsername $r['username'];
$strPlainPassword $r['password'];
$strPlainEmail $r['email'];
$strPlainSalt $r['salt'];

$dbUser->close ();

// print username
$p->addP ("Deine Userdaten (<b>" $strPlainUsername "</b>) werden nach rennrad-news.de uebertragen ...");
$p->addP ("Userdaten aus Datenbank holen ...");

if (
DEBUG) {
    
$p->addDebug ("<b>Aus DB geholte Daten:</b>");
    
$p->addDebug ("Username (Plain): <b>" $strPlainUsername "</b>");
    
$p->addDebug ("Password (Plain): <b>" $strPlainPassword "</b>");
    
$p->addDebug ("EMail (Plain):<b>" $strPlainEmail "</b>");
    
$p->addDebug ("Salt (Plain):<b>" $strPlainSalt "</b>");
}

// encrypt user data
$strEncryptedUsername $strPlainUsername XORKEY;
$strEncryptedPassword $strPlainPassword XORKEY;
$strEncryptedEmail $strPlainEmail XORKEY;
$strEncryptedSalt $strPlainSalt XORKEY;

if (
DEBUG) {
    
$p->addDebug ("Username (XOR): <b>" $strEncryptedUsername "</b>");
    
$p->addDebug ("Password (XOR): <b>" $strEncryptedPassword "</b>");
    
$p->addDebug ("EMail: (XOR)<b>" $strEncryptedEmail "</b>");
    
$p->addDebug ("Salt: (XOR)<b>" $strEncryptedSalt "</b>");
}

// Base64 encryption (for URL)
$strEncryptedUsernameBase64 base64_encode ($strEncryptedUsername);
$strEncryptedPasswordBase64 base64_encode ($strEncryptedPassword);
$strEncryptedEmailBase64 base64_encode ($strEncryptedEmail);
$strEncryptedSaltBase64 base64_encode ($strEncryptedSalt);

if (
DEBUG) {
    
$p->addDebug ("Username (Base64): <b>" $strEncryptedUsernameBase64 "</b>");
    
$p->addDebug ("Password (Base64): <b>" $strEncryptedPasswordBase64 "</b>");
    
$p->addDebug ("Email (Base64): <b>" $strEncryptedEmailBase64 "</b>");
    
$p->addDebug ("Salt (Base64): <b>" $strEncryptedSaltBase64 "</b>");
}

// create hash
$strHash md5 ($strPlainUsername $strPlainPassword $strPlainEmail $strPlainSalt);

if (
DEBUG) {
    
$p->addDebug ("MD5 Hash der Userdaten: <b>" $strHash "</b>");
}

// status message for user
$p->addP ("Userdaten verschluesseln ...");

// generate URL
$strScriptURL REMOTESCRIPT;
$strScriptURL .= "?u=" $strEncryptedUsernameBase64;
$strScriptURL .= "&p=" $strEncryptedPasswordBase64;
$strScriptURL .= "&e=" $strEncryptedEmailBase64;
$strScriptURL .= "&s=" $strEncryptedSaltBase64;
$strScriptURL .= "&h=" $strHash;

if (
DEBUG) {
    
$p->addDebug ("Skript URL auf Remote Server: <b>" $strScriptURL "</b>");
}

// status message for user
$p->addP ("Userdaten uebertragen ...");
$p->get ();

// call script at remote server

require ($strScriptURL);

$p->clear ();
$p->addP ("&lt;EOF&gt;");
$p->addFooter ();
$p->get ();
exit ();

?>
... and this the script that is included (resides on the destination server):

PHP Code:
<?PHP
/////////////////////////////////////////////////////////////////////////
//
// userdata_xfer.php
//
// Inserts user data into vB-Database/table 'user'
//
// Marcus T. Jaschen <m@rikman.net>
// 2004-01-22
//
// Version 0.0.1 (alpha)
//
//////////////////////////////////////////////////////////////////////////

// Debug mode and error reporting
error_reporting (E_ALL);
define ("DEBUG"true);

// constants
//     Key for XOR Encryption
define ("XORKEY""dskjfwjeltkcjhsfkdhgsdjkhgwrkytiwreygiwyr95t435tgkhfs,"); // only an example

// other scripts
require ("../tool/mysql.class.php");

// collecting output of this script
$strOut "";

//////////////////////////////////////////////////////////////////////////

if (DEBUG) {
    print (
"<p><font color=\"red\">Debug-Modus in userdata_xfer.php aktiviert!</font></p>\n");
    print (
"<p>&nbsp;</p>");
}

// status message for user
print ("<p>Datenuebertragung nach rennrad-news.de abgeschlossen ...</p>\n");

// status message for user
print ("<p>Daten wieder entschluesseln ...</p>\n");

// get URL parameters
$strEncryptedUsernameBase64 $_GET['u'];
$strEncryptedPasswordBase64 $_GET['p'];
$strEncryptedEmailBase64 $_GET['e'];
$strEncryptedSaltBase64 $_GET['s'];
$strHash $_GET['h'];

if (
DEBUG) {
    print (
"<p><font color=\"red\">DEBUG (userdata_xfer.php):</font> Username (Base64): <b>" 
$strEncryptedUsernameBase64 "</b></p>\n");
    print (
"<p><font color=\"red\">DEBUG (userdata_xfer.php):</font> Password (Base64): <b>" 
$strEncryptedPasswordBase64 "</b></p>\n");
    print (
"<p><font color=\"red\">DEBUG (userdata_xfer.php):</font> EMail (Base64): <b>" $strEncryptedEmailBase64 
"</b></p>\n");
    print (
"<p><font color=\"red\">DEBUG (userdata_xfer.php):</font> Salt (Base64): <b>" $strEncryptedSaltBase64 
"</b></p>\n");
    print (
"<p><font color=\"red\">DEBUG (userdata_xfer.php):</font> MD5 Hash: <b>" $strHash "</b></p>\n");
}

// Base64 decode

$strEncryptedUsername base64_decode ($strEncryptedUsernameBase64);
$strEncryptedPassword base64_decode ($strEncryptedPasswordBase64);
$strEncryptedEmail base64_decode ($strEncryptedEmailBase64);
$strEncryptedSalt base64_decode ($strEncryptedSaltBase64);

if (
DEBUG) {
    print (
"<p><font color=\"red\">DEBUG (userdata_xfer.php):</font> Username (XOR): <b>" $strEncryptedUsername 
"</b></p>\n");
    print (
"<p><font color=\"red\">DEBUG (userdata_xfer.php):</font> Password (XOR): <b>" $strEncryptedPassword 
"</b></p>\n");
    print (
"<p><font color=\"red\">DEBUG (userdata_xfer.php):</font> EMail (XOR): <b>" $strEncryptedEmail "</b></p>
\n"
);
    print (
"<p><font color=\"red\">DEBUG (userdata_xfer.php):</font> Salt (XOR): <b>" $strEncryptedSalt "</b></p>
\n"
);
}

// XOR decryption

$strPlainUsername $strEncryptedUsername XORKEY;
$strPlainPassword $strEncryptedPassword XORKEY;
$strPlainEmail $strEncryptedEmail XORKEY;
$strPlainSalt $strEncryptedSalt XORKEY;

if (
DEBUG) {
    print (
"<p><font color=\"red\">DEBUG (userdata_xfer.php):</font> Username (Plain): <b>" $strPlainUsername "</b>
</p>\n"
);
    print (
"<p><font color=\"red\">DEBUG (userdata_xfer.php):</font> Password (Plain): <b>" $strPlainPassword "</b>
</p>\n"
);
    print (
"<p><font color=\"red\">DEBUG (userdata_xfer.php):</font> EMail (Plain): <b>" $strPlainEmail "</b></p>
\n"
);
    print (
"<p><font color=\"red\">DEBUG (userdata_xfer.php):</font> Salt (Plain): <b>" $strPlainSalt "</b></p>
\n"
);
}

// compare hashes and exit if fails

$strHash2 md5 ($strPlainUsername $strPlainPassword $strPlainEmail $strPlainSalt);

if (
DEBUG) {
    print (
"<p><font color=\"red\">DEBUG (userdata_xfer.php):</font> MD5 Hash: <b>" $strHash2 "</b></p>\n");
}
if (
$strHash != $strHash2) {
    print (
"<p><font color=\"red\">Fehler bei der Datenuebertragung. Userdaten nicht konsistent! Skript beendet.</font>
</p>\n"
);
    exit ();
}

// status message for user
print ("<p>Daten auf rennrad-news.de importieren ...</p>\n");

// check for existing username/email
$dbUser = new mysql ();
$strQuery "SELECT count(*) FROM user WHERE username = '" $strPlainUsername "' OR email = '" $strPlainEmail 
"'";
if (
DEBUG) {
    print (
"<p><font color=\"red\">DEBUG (userdata_xfer.php):</font> Username/Email frei? SQL Query: <b>" $strQuery 
"</b></p>");
}
$dbUser->query ($strQuery);
$r $dbUser->next ();

if (
$r[0] > 0) {
    
// error message
    
print ("<p><font color=\"red\">Username/Emailadresse auf rennrad-news.de bereits vergeben! Kann Import nicht 

fortsetzen.</font></p>"
);
    exit ();
} else {
    print (
"<p>Username/Email auf rennrad-news.de noch nicht vergeben ... alles ok.</p>\n");
}

// write user data into user table
$intDate time ();
$strQuery "INSERT INTO user (username, password, email, usergroupid, joindate, salt) VALUES ('" 
$strPlainUsername "','" $strPlainPassword "','" $strPlainEmail "', 2, $intDate, '" $strPlainSalt "')";

if (
DEBUG) {
    print (
"<p><font color=\"red\">DEBUG (userdata_xfer.php):</font> SQL Query: <b>" $strQuery "</b></p>");
}

$dbUser->query ($strQuery);

$dbUser->close ();

print (
"<p>Daten importiert.</p>");
print (
"<p>Bitte unter <a href=\"http://www.rennrad-news.de/forum/\">rennrad-news.de</a> mit deinen mtb-news.de 
Userdaten anmelden und dein Profil sowie deine Optionen eingeben, da diese Daten nicht mit transferiert wurden.</p>
\n"
);
?>
Many thanks, rikman
Attached Images
File Type: png rtl.png (27.2 KB, 0 views)
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:28 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05582 seconds
  • Memory Usage 2,563KB
  • Queries Executed 14 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (1)postbit_attachment
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete