Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

June 05, 2020, 10:20:16 PM

Login with username, password and session length
Members
Stats
  • Total Posts: 190084
  • Total Topics: 20841
  • Online Today: 126
  • Online Ever: 917
  • (January 21, 2020, 09:02:26 AM)
Users Online
Users: 1
Guests: 46
Total: 47

Author Topic: How to: Import shouts from SP/EhPortal  (Read 1371 times)

0 Members and 1 Guest are viewing this topic.

Online Oldiesmann

  • Jr. Member
  • **
  • Posts: 30
    • Cincy Space
How to: Import shouts from SP/EhPortal
« on: January 20, 2020, 11:32:34 AM »
Just moved a site I'm hosting from EhPortal to TP and the members wanted shoutbox history imported as well, so I wrote a script to do that. Figured I'd share it here in case anyone else wants to do that. Note that this was run on 2.1. If you're on 2.0, you should be able to remove the "$smcFunc['db_select_db']" line and also change "inet_ntop($results['member_ip'])" to just "$results['member_ip']" (this is needed due to differences in how the data is stored in 2.1 vs 2.0)


Code: [Select]
<?php
include_once('SSI.php');
$smcFunc['db_select_db']('your_database');


$query $smcFunc['db_query']('''SELECT shout.id_shout, shout.id_member, shout.member_name, shout.log_time, shout.body, mem.member_ip FROM {db_prefix}sp_shouts AS shout
INNER JOIN {db_prefix}members AS mem ON (mem.id_member = shout.id_member)'
, array());


$shouts = array();


while(
$results $smcFunc['db_fetch_assoc']($query))
{


$shouts[] = array(
$results['id_shout'],
$results['body'],
$results['log_time'],
'shoutbox',
'<a href="' $scripturl '?action=profile;u='$results['id_member'] . '">'$results['member_name'] . '</a>',
inet_ntop($results['member_ip']),
$results['id_member']
);

}


 
$smcFunc['db_insert']('insert''{db_prefix}tp_shoutbox', array('id' => 'int','value1' => 'string','value2' => 'string''type' => 'string''value3' => 'string''value4' => 'string''value5' => 'string'), $shouts, array('id'));


?>

Offline lurkalot

  • Administrator
  • *
  • Posts: 6634
    • Camera Craniums
Re: How to: Import shouts from SP/EhPortal
« Reply #1 on: January 20, 2020, 03:25:00 PM »
Neat  ;) Thank you Oldiesmann, I'm sure someone will find this very useful should they find themselves in the same position. 

And thanks for switching to TP as well.  8)