Simple Machines Community Forum

SMF Support => Converting to SMF => Topic started by: vbgamer45 on April 01, 2019, 10:11:59 PM

Title: Elarkte Password support for SMF 2.0
Post by: vbgamer45 on April 01, 2019, 10:11:59 PM
Here is a script to use Elkarte 1.1x passwords in SMF 2.0.x

Open Sources/LogInOut.php

Find

elseif (strlen($user_settings['passwd']) == 40)
{
// Maybe they are using a hash from before the password fix.
$other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd']));

// BurningBoard3 style of hashing.
$other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd'])));

// Perhaps we converted to UTF-8 and have a valid password being hashed differently.
if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8')
{
// Try iconv first, for no particular reason.
if (function_exists('iconv'))
$other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd'])));

// Say it aint so, iconv failed!
if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding'))
$other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet'])));
}
}

Add after

elseif (strlen($user_settings['passwd']) == 60)
{
$other_passwords[] = validateLoginPasswordElkarte($_POST['passwrd'], $user_settings['passwd'],$user_settings['member_name']);

}


Find at the end of the and add before ?>

function validateLoginPasswordElkarte(&$password, $hash, $user = '', $returnhash = false)
{
    global $smcFunc, $sourcedir;

// Our hashing controller
require_once($sourcedir . '/PasswordHash.php');

// Base-2 logarithm of the iteration count used for password stretching, the
// higher the number the more secure and CPU time consuming
$hash_cost_log2 = 10;

// Do we require the hashes to be portable to older systems (less secure)?
$hash_portable = false;

// Get an instance of the hasher
$hasher = new PasswordHash($hash_cost_log2, $hash_portable);

// If the password is not 64 characters, lets make it a (SHA-256)
if (strlen($password) !== 64)
$password = hash('sha256', $smcFunc['strtolower']($user) . un_htmlspecialchars($password));

// They need a password hash, something to save in the db?
if ($returnhash)
{
$passhash = $hasher->HashPassword($password);

// Something is not right, we can not generate a valid hash that's <20 characters
if (strlen($passhash) < 20)
$passhash = false;
}
// Or doing a password check?
else
$passhash = (bool) $hasher->CheckPassword($password, $hash);

unset($hasher);

return $passhash;
}




Then Copy attached PasswordHash.php to the Sources folder
Title: Re: Elarkte Password support for SMF 2.0
Post by: gevv on December 16, 2020, 12:36:45 PM
Hello,

Is there a converter from elkarte 1.1.6 to smf?
Title: Re: Elarkte Password support for SMF 2.0
Post by: vbgamer45 on December 16, 2020, 01:08:47 PM
I did one for openimporter https://github.com/OpenImporter/openimporter/pull/105/commits

Attached you can use it to convert.
Title: Re: Elarkte Password support for SMF 2.0
Post by: gevv on December 17, 2020, 10:19:19 AM
Thanks  @vbgamer45

I tried it gave an error in the member groups.

Importing settings... ✔
Importing members... ✔
Importing categories... ✔
Importing boards... ✔
Importing topics... ✔
Importing messages... ✔
Importing polls... ✔
Importing poll choices... ✔
Importing poll votes... ✔
Importing personal messages... ✔
Importing pm recipients... ✔
Importing pm rules... ✔
Importing board moderators... ✔
Importing mark read data (boards)... ✔
Importing mark read data (topics)... ✔
Importing mark read data... ✔
Importing notifications... ✔
Importing membergroups...
Unsuccessful!
This query:

    REPLACE INTO `smf`.smf_membergroups
    (id_group, group_name, description, online_color, min_posts, max_messages, stars, group_type, hidden, id_parent)
    VALUES ('1', 'Yönetici', '', '#E1332D', '-1', '0', '5#iconadmin.png', '0', '0', '-2'),
    ('2', 'Genel Moderatör', '', '#0000FF', '-1', '0', '5#icongmod.png', '0', '0', '-2'),
    ('3', 'Moderatör', '', '', '-1', '0', '5#iconmod.png', '0', '0', '-2'),
    ('4', 'Yeni Üye', '', '', '0', '0', '1#icon.png', '0', '0', '-2'),
    ('5', 'Üye', '', '', '6', '0', '2#icon.png', '0', '0', '-2'),
    ('6', 'Tam Üye', '', '', '100', '0', '3#icon.png', '0', '0', '-2'),
    ('7', 'Kıdemli Üye', '', '', '250', '0', '4#icon.png', '0', '0', '-2'),
    ('8', 'Kahraman Üye', '', '', '500', '0', '5#icon.png', '0', '0', '-2');

Caused the error:

    Unknown column 'stars' in 'field list'

Line: 117
File: C:\wamp64\www\op\OpenImporter\Database.php

Unsuccessful!
This query:

    REPLACE INTO `smf`.smf_membergroups
    (id_group, group_name, description, online_color, min_posts, max_messages, stars, group_type, hidden, id_parent)
    VALUES ('1', 'Yönetici', '', '#E1332D', '-1', '0', '5#iconadmin.png', '0', '0', '-2'),
    ('2', 'Genel Moderatör', '', '#0000FF', '-1', '0', '5#icongmod.png', '0', '0', '-2'),
    ('3', 'Moderatör', '', '', '-1', '0', '5#iconmod.png', '0', '0', '-2'),
    ('4', 'Yeni Üye', '', '', '0', '0', '1#icon.png', '0', '0', '-2'),
    ('5', 'Üye', '', '', '6', '0', '2#icon.png', '0', '0', '-2'),
    ('6', 'Tam Üye', '', '', '100', '0', '3#icon.png', '0', '0', '-2'),
    ('7', 'Kıdemli Üye', '', '', '250', '0', '4#icon.png', '0', '0', '-2'),
    ('8', 'Kahraman Üye', '', '', '500', '0', '5#icon.png', '0', '0', '-2');

Caused the error:

    Unknown column 'stars' in 'field list'
Title: Re: Elarkte Password support for SMF 2.0
Post by: vbgamer45 on December 17, 2020, 10:46:34 AM
Your smf membergroups table is missing the stars column for some reason... Add it to the table
Title: Re: Elarkte Password support for SMF 2.0
Post by: gevv on December 17, 2020, 10:56:40 AM
my fault i installed smf 2.1 but there was smf 2.0 support

I'm trying to install smf 2.0

thanks
Title: Re: Elarkte Password support for SMF 2.0
Post by: gevv on December 17, 2020, 01:23:18 PM
error occurred during the conversion of attachments  (in the last moments)


Message: Trying to get property of non-object
Trace: Trying to get property of non-object
Line: 499
File: /op/OpenImporter/Importer.php
Message: Invalid argument supplied for foreach()
Trace: Invalid argument supplied for foreach()
Line: 499
File: //op/OpenImporter/Importer.php

Fatal error: Class '_step1' not found in /op/OpenImporter/Importer.php on line 533



+ Completed files return error 404 - Attachment Not Found


smf 2.0 admin Attachment Settings   "Attachments directory"   recorded as below. How should I arrange?

Path;

a:51:{i:1;s:54:"/SITE/public_html/smf/attachments/attachments";i:2;s:50:"/SITE/public_html/smf/attachments/2016/11";i:3;s:50:"/SITE/public_html/smf/attachments/2016/12";i:4;s:50:"/SITE/public_html/smf/attachments/2017/01";i:5;s:50:"/SITE/public_html/smf/attachments/2017/02";i:6;s:50:"/SITE/public_html/smf/attachments/2017/03";i:7;s:50:"/SITE/public_html/smf/attachments/2017/04";i:8;s:50:"/SITE/public_html/smf/attachments/2017/05";i:9;s:50:"/SITE/public_html/smf/attachments/2017/06";i:10;s:50:"/SITE/public_html/smf/attachments/2017/07";i:11;s:50:"/SITE/public_html/smf/attachments/2017/08";i:12;s:50:"/SITE/public_html/smf/attachments/2017/09";i:13;s:50:"/SITE/public_html/smf/attachments/2017/10";i:14;s:50:"/SITE/public_html/smf/attachments/2017/11";i:15;s:50:"/SITE/public_html/smf/attachments/2017/12";i:16;s:50:"/SITE/public_html/smf/attachments/2018/01";i:17;s:50:"/SITE/public_html/smf/attachments/2018/02";i:18;s:50:"/SITE/public_html/smf/attachments/2018/03";i:19;s:50:"/SITE/public_html/smf/attachments/2018/04";i:20;s:50:"/SITE/public_html/smf/attachments/2018/05";i:21;s:50:"/SITE/public_html/smf/attachments/2018/06";i:22;s:50:"/SITE/public_html/smf/attachments/2018/07";i:23;s:50:"/SITE/public_html/smf/attachments/2018/08";i:24;s:50:"/SITE/public_html/smf/attachments/2018/09";i:25;s:50:"/SITE/public_html/smf/attachments/2018/10";i:26;s:50:"/SITE/public_html/smf/attachments/2018/11";i:27;s:50:"/SITE/public_html/smf/attachments/2018/12";i:28;s:50:"/SITE/public_html/smf/attachments/2019/01";i:29;s:50:"/SITE/public_html/smf/attachments/2019/02";i:30;s:50:"/SITE/public_html/smf/attachments/2019/03";i:31;s:50:"/SITE/public_html/smf/attachments/2019/04";i:32;s:50:"/SITE/public_html/smf/attachments/2019/05";i:33;s:50:"/SITE/public_html/smf/attachments/2019/06";i:34;s:50:"/SITE/public_html/smf/attachments/2019/07";i:35;s:50:"/SITE/public_html/smf/attachments/2019/08";i:36;s:50:"/SITE/public_html/smf/attachments/2019/09";i:37;s:50:"/SITE/public_html/smf/attachments/2019/10";i:38;s:50:"/SITE/public_html/smf/attachments/2019/11";i:39;s:50:"/SITE/public_html/smf/attachments/2019/12";i:40;s:50:"/SITE/public_html/smf/attachments/2020/01";i:41;s:50:"/SITE/public_html/smf/attachments/2020/02";i:42;s:50:"/SITE/public_html/smf/attachments/2020/03";i:43;s:50:"/SITE/public_html/smf/attachments/2020/04";i:44;s:50:"/SITE/public_html/smf/attachments/2020/05";i:45;s:50:"/SITE/public_html/smf/attachments/2020/06";i:46;s:50:"/SITE/public_html/smf/attachments/2020/07";i:47;s:50:"/SITE/public_html/smf/attachments/2020/08";i:48;s:50:"/SITE/public_html/smf/attachments/2020/09";i:49;s:50:"/SITE/public_html/smf/attachments/2020/10";i:50;s:50:"/SITE/public_html/smf/attachments/2020/11";i:51;s:50:"/SITE/public_html/smf/attachments/2020/12";}


My elkarte Attachment Settings; Choose the mode of management of the add-on folders   "(automatic) separate by year and month"
Title: Re: Elarkte Password support for SMF 2.0
Post by: vbgamer45 on December 17, 2020, 07:08:28 PM
Hmm give this a shot

Copy to
openimporter\importer\Importers\smf2.0
Title: Re: Elarkte Password support for SMF 2.0
Post by: gevv on December 18, 2020, 06:20:15 AM
I tried again with the new file gave an error


Fatal error: Cannot redeclare moveAttachment() (previously declared in //op/Importers/smf2.0/elkarte1-1_importer.php:106) in //op/Importers/smf2.0/smf2.0_importer.php on line 201
Title: Re: Elarkte Password support for SMF 2.0
Post by: vbgamer45 on December 18, 2020, 03:47:45 PM
Skip the file post. Your attachments directory serialzations are corrupt... Which is why it failed.
For instance this part
s:50:"/SITE/public_html/smf/attachments/2016/11";
Is supposed to 50 characters in quotes it is 41 instead.
Title: Re: Elarkte Password support for SMF 2.0
Post by: gevv on February 10, 2021, 02:38:25 PM
Hello,

I started again. I moved the attachments  from the elk. admin panel to the attachment folder, I run the import 

failed in attachments transfer


https://site.com/import.php?step=1&substep=33&start=1500


Importing...

Message: Trying to get property of non-object
Trace: Trying to get property of non-object
Line: 499
File: //OpenImporter/Importer.php
Message: Invalid argument supplied for foreach()
Trace: Invalid argument supplied for foreach()
Line: 499
File: //OpenImporter/Importer.php

Fatal error: Class '_step1' not found in //OpenImporter/Importer.php on line 533
Title: Re: Elarkte Password support for SMF 2.0
Post by: vbgamer45 on February 10, 2021, 02:44:49 PM
What PHP version?
Title: Re: Elarkte Password support for SMF 2.0
Post by: gevv on February 10, 2021, 02:48:52 PM
PHP version 5.6
Title: Re: Elarkte Password support for SMF 2.0
Post by: gevv on February 11, 2021, 11:15:35 AM
I can change the php version
php version should I use?   7, 7.4
Title: Re: Elarkte Password support for SMF 2.0
Post by: vbgamer45 on February 11, 2021, 11:27:28 AM
I would have to do some testing. Can you provide a sample db/attachments.
Title: Re: Elarkte Password support for SMF 2.0
Post by: gevv on February 15, 2021, 09:21:36 AM
Hello @vbgamer45 ,

I wonder if there is any improvement

Thanks
Title: Re: Elarkte Password support for SMF 2.0
Post by: gevv on February 18, 2021, 04:00:22 PM
Hello @vbgamer45 ,

I tried localhost, it was successful.

All attachments data loaded did not fail, but does not convert attacments.

I manually deleted the file extensions name attachments (bat file; rename *.elk *.)   and re upload server

Convert  completed Thanks.
Title: Re: Elarkte Password support for SMF 2.0
Post by: vbgamer45 on February 18, 2021, 04:12:54 PM
Glad you got it working! Strange worked on localhost.
Title: Re: Elarkte Password support for SMF 2.0
Post by: gevv on February 19, 2021, 09:27:26 AM
@vbgamer45


Valid for elarkte password support for SMF 2.1 RC3?

I'm getting a token error
Title: Re: Elarkte Password support for SMF 2.0
Post by: vbgamer45 on February 19, 2021, 10:08:28 AM
Do changes above work for 2.1?
Title: Re: Elarkte Password support for SMF 2.0
Post by: gevv on February 19, 2021, 10:15:20 AM
Yes

I made the changes and uploaded the PasswordHash.php file

login error;

QuoteLogin
An error has occurred
Token verification failed. Please go back and try again.

elkarte to smf 2.0 and update smf 2.1 rc3
[/s]

I deleted the browser cookies problem solved

Thanks
Title: Re: Elarkte Password support for SMF 2.0
Post by: txcas on October 14, 2021, 10:31:58 AM
I am testing the migration of an ElkArte forum to SMF. I used your OpenImporter script and you ElkArte password support script. The forum migrated just fine and I can login to SMF 2.0 with the ElkArte forum passwords. My intention is to upgrade SMF 2.0 to SMF 2.1 RC4 right after the migration, but I ran into a problem. The ElkArte passwords work on SMF 2.1 RC4 as long as the user logs in first to SMF 2.0. If the forum is upgraded to SMF 2.1 RC4 before users log on to SMS 2.0, their ElkArte passwords do not work. Would it be possible to update the password support script so it works on SMF 2.1?
Title: Re: Elarkte Password support for SMF 2.0
Post by: vbgamer45 on October 14, 2021, 10:35:47 AM
Did you add the password support to 2.1?
Title: Re: Elarkte Password support for SMF 2.0
Post by: txcas on October 14, 2021, 11:15:23 AM
Quote from: vbgamer45 on October 14, 2021, 10:35:47 AMDid you add the password support to 2.1?
Yes I did. I edited the LogInOut.php file and added the hash script to the Sources directory.
Title: Re: Elarkte Password support for SMF 2.0
Post by: vbgamer45 on October 14, 2021, 11:41:43 AM
Can you attach that file want to see if something changed in 2.1
Title: Re: Elarkte Password support for SMF 2.0
Post by: txcas on October 14, 2021, 11:49:32 AM
Here it is with my edits.
Title: Re: Elarkte Password support for SMF 2.0
Post by: txcas on October 23, 2021, 07:49:52 AM
Hi. Do you need anything else?