Cprl.Rst Posted August 30, 2012 Share Posted August 30, 2012 HI there, i have a website http://www.league.vivahosting.co.uk which uses Joomla for main cms and Dragonflycms as the league component module. now what i want to achieve is a script to copy username and email from the jos_users table and insert it into the cmsdf_users table now the rows in each table are as follows jos_users - username, email cmsdf_users - username, user-email now i'dlike to do the same with the passwords but joomal's encryption is hash:salted i believe and Dragonflycms is md5 so i'm thinking a workaround using a custom field provided by joomla to have a plain txt password that is encrypted during the transfer process from db to db. Now the custom field is not kept in the jos_users table its located in letnp_user which i believe are linked by user_id. Below is what i have so far but doesn't seem to work it gives the following error ERROR: there was a problem inserting data. and [29-Aug-2012 15:31:13] PHP Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/leaguevi/public_html/convert.php on line 25 in toe error_log from the server. <?php // Set the connection information $con = mysql_connect("localhost", "DbName", "Password"); // Select the original database containing old records mysql_select_db("leaguevi_jooml62", $con); // Check the connection if (!$con) { die('Could not connect: ' . mysql_error()); } // Select the records from the database $query = "SELECT * FROM jos_users"; // Run the query $result = mysql_query($query); // Now select the new database mysql_select_db("cmsdf_users", $con); // Loop through each row from the old database while ($row = mysql_fetch_assoc($result)) { // Set each column to a variable $username = $row['username']; $email = $row['email']; // You could also reset defaults or check for NULL columns // Here's an example for permissions: if ($row['permissions'] == 0) { $permissions = 1; } else if ($row['permissions'] > 3) { $permissions = $row['permissions'] + 1; } else { $permissions = $row['permissions']; } $date = $row['date']; // Set up the INSERT query $insert = "INSERT INTO cmsdf_users (username, user_email, permissions, date) VALUES ('$username', '$email', '$permissions', '$date')"; // Run the INSERT query mysql_query($insert); // Check to make sure this particular INSERT worked if (!mysql_insert_id()) { echo "ERROR: there was a problem inserting data."; } } // Close the connection mysql_close($con); ?> Any help on this i would be very greatful Quote Link to comment https://forums.phpfreaks.com/topic/267804-sql-table-copy-script/ Share on other sites More sharing options...
Christian F. Posted August 30, 2012 Share Posted August 30, 2012 Don't do this, you'll only create a huge headache for yourself. Not to mention, there is no way for you to unhash the passwords. (They're hashed, not encrypted. Former is one-way only, meaning it's impossible to reverse.) What I'd do instead, is to modify DragonflyCMS to use Joomla's login code instead. Especially seeing as Joomla's is a lot more secure than DragonflyCMS'. Then users only have to log in once and be done with it, and without you having to send new passwords to everyone. PS: Why use two CM systems, for one site? This does strike me as a over-complicating things a bit too much, especially if they are meant to share users. My recommendation would be to move everything over into Joomla, and then just one it. Keep things as simple as possible, and you'll have a lot less problems on your hands. Quote Link to comment https://forums.phpfreaks.com/topic/267804-sql-table-copy-script/#findComment-1373967 Share on other sites More sharing options...
Cprl.Rst Posted August 30, 2012 Author Share Posted August 30, 2012 Don't do this, you'll only create a huge headache for yourself. Not to mention, there is no way for you to unhash the passwords. (They're hashed, not encrypted. Former is one-way only, meaning it's impossible to reverse.) What I'd do instead, is to modify DragonflyCMS to use Joomla's login code instead. Especially seeing as Joomla's is a lot more secure than DragonflyCMS'. Then users only have to log in once and be done with it, and without you having to send new passwords to everyone. PS: Why use two CM systems, for one site? This does strike me as a over-complicating things a bit too much, especially if they are meant to share users. My recommendation would be to move everything over into Joomla, and then just one it. Keep things as simple as possible, and you'll have a lot less problems on your hands. i'm not technically minded enough to modify dragonfly to use joomlas login code so this is the simplist way i could think of. the reason for the 2 cm's is this DF cms is less than pretty and devlopment is minimal at best however the league/competition module for DFCMS is one of the best i have seen so thats the sole reason for the 2 CM's i'm not wanting the pass from the joomla db as i know it cannot be decrypted how ever if i take a txt field from joomla i thought this could be md5'd into password field for DFCMS hope this makes a little more sense. Quote Link to comment https://forums.phpfreaks.com/topic/267804-sql-table-copy-script/#findComment-1373984 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.