Tweaking the converter for Membermap (Gold) data?

Started by ms_ukyankee, March 23, 2004, 05:35:04 AM

Previous topic - Next topic

ms_ukyankee

This seems relatively simple, though I can't possibly manage this on my own, and would possibly be useful to others converting from Gold, who have the Member Map mod installed.

It would be a much tidier conversion for me if the data that is in the Location field could be tweaked, it is currently inserting this into the member location:

x1|Rugby, Warwickshire|United_Kingdom|united_kingdom|308|296|

Could someone please help so that the code of one of the conversion scripts only inserts the second section of this location data instead?
SMF since 2004 <3

ms_ukyankee

No takers?  :P

Okay, this looks like it might work, given that the location data is in $userData[15]? This is a stab in the dark, so please don't laugh.

beginStep(5);

// Getting members information
echo '
Importing Member Data:
<blockquote>';

$dh = opendir($_REQUEST['membersdir']);
$insertData = array();
while ($file = readdir($dh))
{
$extension = substr(strrchr($file, '.'), 1);
if ($extension != 'dat')
continue;

if (isset($user))
echo ', ';

$user = substr($file, 0, strrpos($file, '.'));

$userData = file($_REQUEST['membersdir'] . '/' . $file);
for ($i = 0; $i < sizeof($userData); $i++)
$userData[$i] = mysql_escape_string(trim(htmlspecialchars($userData[$i])));

$userData = array_pad($userData, 20, '');

// Just use md5, it'll get upgraded.
$password = md5(stripcslashes($userData[0]));

$userData[14] = get_yabb_time(stripcslashes($userData[14]));

$birthdate = $userData[16] == '' ? 0 : strtotime(stripcslashes($userData[16]));

if ($birthdate <= 0 && $userData[16] != '')
{
if (preg_match("/(\d\d)\/(\d\d)\/(\d\d)(.*)(\d\d)\:(\d\d)\:(\d\d)/i", stripcslashes($userData[16]), $matches))
$birthdate = strtotime("$matches[5]:$matches[6]:$matches[7] $matches[1]/$matches[2]/$matches[3]");
}

if ($birthdate > 0)
{
$tmp = getdate($birthdate);
$userData[16] = "$tmp[year]-$tmp[mon]-$tmp[mday]";
}
else
$userData[16] = '0000-00-00';

$userData[19] = $userData[19] == 'checked' ? '1' : '0';

$userData[5] = str_replace(array('&&', '&amp;&amp;'), "\n", $userData[5]);
//*  Yabb Gold Membermap tweak
$pos = strpos("|", $userData[15]);
if ($pos !== FALSE){
$userLocation = explode("|",$userData[15]);
$userData[15] = $userLocation[2];
}
//*  Yabb Gold Membermap tweak end
if ($userData[4] == 'Guest')
$userData[4] = $userData[1];

$insertData[$user] = "('$user', '$password', '$userData[1]', '$userData[2]', '$userData[3]', '$userData[4]', '$userData[5]', '$userData[6]', '$userData[7]', '$userData[8]', '$userData[9]', '$userData[10]', '$userData[11]', '$userData[12]', '$userData[13]', '$userData[14]', '$userData[15]', '$userData[16]', '$userData[18]', '$userData[19]')";

echo $user;
}
closedir($dh);

echo '
</blockquote>';

// Inserting Members
SMF since 2004 <3

[Unknown]

I know just enough about YaBB to tweak the converter... sorry, I can't really tell you if that's right or not.

-[Unknown]

ms_ukyankee

Okay, thanks. Maybe instead, run a script that would change all the piped locations in the tables to the correct data, that would be fairly simple too wouldn't it? Not simple for me, I don't know a lick of mysql scripting yet.

If I wanted to do a test SEinstall/convert on my main forum to make sure it works, is there any reason why I would have to put the Gold board into maintainance mode to do that if it's not busy? I won't be keeping it after all, just testing the conversion one more time.
SMF since 2004 <3

[Unknown]

Well, it'd be best to in case someone started a topic in the middle of conversion...

-[Unknown]

ms_ukyankee

#5
I got an error from my bit of code, strpos() empty delimiter (forgot to copy the exact error), what have I done wrong there?

Nevermind, I see I've got my needle and handstack swapped. doh.
SMF since 2004 <3

ms_ukyankee

Ok, finally finished this off, and it works.

In yabb2yabbse.php

Find this:
$userData[5] = str_replace(array('&&', '&amp;&amp;'), "\n", $userData[5]);


Replace with:
$userData[5] = str_replace(array('&&', '&amp;&amp;'), "\n", $userData[5]);
//*  Membermap tweak
$findme='|';
$pos = strpos($userData[15], $findme,1);
if ($pos !== FALSE){
$userLocation = explode("|",$userData[15]);
$userData[15] = $userLocation[1];
}
//*  Membermap tweak end


This strips out the old map co-ordinates and inserts only the text location of the user into their profile. :)
SMF since 2004 <3

Advertisement: