UBB.Dev
Posted By: mdavoli webbbs 5.11 to latest ubbs.threads - 11/14/2002 7:27 PM
I would like to see if anyone is interested in giving me a quote for a script to port data from webbbs 5.11 found at

http://awsd.com/scripts/webbbs/

to ubb.threads.

I wanted to do it myself, but my knowledge of php is limited as is my time. Please drop me an email at [][email protected].[/]
Posted By: fishtails Re: webbbs 5.11 to latest ubbs.threads - 11/15/2002 8:49 AM
Hi

This is the script I was telling you about via PM. It's originally for converting webbbs to cyboards. In the next post I will have what I used to convert the cyboards over to threads (keep in mind that this is written with a postnuke membership in mind.. Be farwarned, it ain't pretty, but it served my purposes.

Take the two and compare them. Between them you should be able to come up with something.

On another note, the first script was taken from a webbs to phorum script. I thought I saw somewhere a phorum to UBBT script somewhere on the UBB site. You might check that out as well.

If you need further assistance, I'll do what I can. Here's the webbbs2cyboards.php script:

code:
<?php

/*

WebBBS to Cyboard 1.25 Converter
Original script was for converting WebBBS to Phorum
Modified for Cyboards by Mark Summerlin
Thanks to Jason Birch for writing the original for Phorum conversion
Version: 1.0
Applies to:
WebBBS Version 4.33 (and maybe others...)
Cyboard Version 1.25b

This little script pulls the contents of WebBBS
text files and writes them to a SQL file for easy
addition to previously created forum tables. It
resets the ID ordering (starting at 1) and creates
thread numbers.

mysql [parameters] < tablename.sql

Bugz:

- If the parent of a post has been deleted, its
thread will be set it its ID. Not sure how to
work around this one...

- No error checking for files exist (read or write)

*/

// *************** Config ******************

// Be sure to include the trailing slash on these
// directories. The script will crash if you do not.

// Where are the WebBBS files.
$strWebBBSLocation = "./bbs0/";

// Where do you want the output stored?
$strOutputDir = "./testbbs/";

// what is the main table name for the Cyboard?
$strCyboardTable = "board_data";

// ************** End Config ****************



// Set up char month to num month translation array

$aryMonths = array( "January" => "01",
"February" => "02",
"March" => "03",
"April" => "04",
"May" => "05",
"June" => "06",
"July" => "07",
"August" => "08",
"September" => "09",
"October" => "10",
"November" => "11",
"December" => "12"
);

// Initialize an array to hold the input file information
$aryInput[] = array ( 'ID' => 0,
'PREVIOUS' => 0,
'THREAD' => 0
) ;

// Build an array of numeric files in current directory
$dirCurrent = dir("$strWebBBSLocation");
$c = 0;
while ($strTemp = $dirCurrent->read() ) {
if ( (ereg_replace("[^0-9]","",$strTemp) == $strTemp) &&
( !empty ($strTemp) ) ) {
$aryFiles[$c] = (int) $strTemp;
$c++;
}
}
$dirCurrent->close();

// sort the array
sort ($aryFiles);

// set up output names
$strMainFile = $strOutputDir.$strCyboardTable.".sql";
$strCyboardBodies = $strCyboardTable."_bodies";
$strBodiesFile = $strOutputDir.$strCyboardBodies.".sql";

print "Processing WebBBS files into sql statements";

$fpCyboard = fopen($strMainFile, "w");

// Grab contents of files into an array
for ($b=0 ; $b < count($aryFiles); $b++) {
$strFile = $aryFiles[$b];
// Set ID to current record counter
$aryInput[$strFile]['ID'] = $b + 1;
$body = "";
$aryCurrFile = file ($strWebBBSLocation.$strFile);
for ($a = 0; $a < count($aryCurrFile); $a++ ) {
$strLine = $aryCurrFile[$a];
// pull lines into either specified tags or the body
if ( ereg ("^SUBJECT>",$strLine) ||
ereg ("^ADMIN>",$strLine) ||
ereg ("^POSTER>",$strLine) ||
ereg ("^EMAIL>",$strLine) ||
ereg ("^DATE>",$strLine) ||
ereg ("^EMAILNOTICES>",$strLine) ||
ereg ("^IP_ADDRESS>",$strLine) ||
ereg ("^PASSWORD>",$strLine) ||
ereg ("^NEXT>",$strLine) ||
ereg ("^IMAGE>",$strLine) ||
ereg ("^LINKNAME>",$strLine) ||
ereg ("^LINKURL>",$strLine) ) {
$tag = strtolower(trim(substr($strLine,0,strpos($strLine,">"))));
$value = trim(substr($strLine,strpos($strLine,">") + 1,strlen($strLine) - 1));
$$tag = $value;
} elseif ( ereg ("^PREVIOUS>",$strLine) ) {
$value = trim(substr($strLine,strpos($strLine,">") + 1,strlen($strLine) - 1));
$aryInput[$strFile]['PREVIOUS'] = $value;
} else {
$body .= trim($strLine);
}
}
// clean up body to format used by Cyboard
$body = trim(ereg_replace('<P>',"",ereg_replace('<BR>',"\n",$body)));
// attempt to assign threads
if (empty ($aryInput[$strFile]['PREVIOUS'])) {
$aryInput[$strFile]['THREAD'] = $aryInput[$strFile]['ID'];
} else {
$aryInput[$strFile]['THREAD'] = $aryInput[($aryInput[$strFile]['PREVIOUS'])]['THREAD'] ;
$aryInput[$strFile]['PREVIOUS'] = $aryInput[($aryInput[$strFile]['PREVIOUS'])]['ID'] ;
}
// trim IP_ADDRESS to actual IP_ADDRESS.
$ip_address = trim(substr($ip_address,strrpos($ip_address,":")+1,strlen($ip_address)));
// If you care about host names (and don't mind the slowdown) comment this line in:
// $ip_address = gethostbyaddress($ip_address);
// Fix up date format
// Wednesday, 10 February 1999, at 7:52 p.m. --> YYYY-MM-DD HH:MM:SS
$tmpDate = trim(ereg_replace(',','',$date));
list ($junk,$day,$cmon,$year,$junk2,$time,$tod) = explode (" ",$tmpDate);
list ($hour,$minute) = explode (":",$time);
$month = $aryMonths["$cmon"];
if ( substr($tod,0,1) == "p") { $hour += 12; }
// $datestamp = date("Y-m-d H:i:s",mktime($hour,$minute,0,$month,$day,$year));
$datestamp = date("Y-m-d H:i:s",mktime(0,0,$date -18000,1,1,1970));
// ouput values to screen (debug only)
print " .";
// set up and write insert commands to sql files
$id = $aryInput[$strFile]['ID'];
$thread = $aryInput[$strFile]['THREAD'];
if (empty ($thread)) { $thread = $id; }
$parent = $aryInput[$strFile]['PREVIOUS'];
$subject = addslashes($subject);
$body = addslashes(stripslashes($body));
$poster = addslashes($poster);
$linkname = addslashes($linkname);
$email_reply = 'N';
$good = fputs($fpCyboard, "Insert Into $strCyboardTable (id, board, thread, parent, author, email, subject, body, datestamp, ip, host, vipflag, link, linkname, image, locked, sticky, email_replies, hide_email) values ('$id', '1', '$thread', '$parent', '$poster', '$email', '$subject', '$body', '$datestamp', '$ip_address', '', '', '$linkurl', '$linkname', '$image', '0', '0', '0', '0');\n");
}

$null = fclose($fpCyboard);

print "Done!";

?>



Posted By: fishtails Re: webbbs 5.11 to latest ubbs.threads - 11/15/2002 8:57 AM
Here's the cyboards2threads.php script: (again, keep in mind this is set up for MY specific situation )

code:
<?
// author : Mark Summerlin aka fishtails
// cyboards2threads.php imports cyboard messages into UBBthreads
// WARNING!!!!! Backup your database before running this script!
// No warranties are expressed or implied. USE AT YOUR OWN RISK
// this script assumes that you have installed UBBThreads in the same database as your postnuke installation.
// Set variables
$host = "localhost"; // usually localhost
$dbuname = "root"; // db username
$dbpass = ""; // db password
$dbname = "ubbthread"; // name of the database
$board_name = "test"; // this is the name (keyword) of the forum you want entered into
// this assumes that you are putting ALL messages into ONE forum. If you have more than one forum and want
// them entered correctly, you will have to modify this script to do so. Otherwise use the move feature in Threads

// THAT'S ALL OF THE SETTINGS After running this script, DELETE IT FROM YOUR SERVER!

function port_cyboards_posts() {
GLOBAL $host,$dbuname,$dbpass,$dbname,$board_name;

$db_conn = mysql_connect("$host", "$dbuname", "$dbpass");
mysql_select_db("$dbname", $db_conn);

/*$query = "ALTER TABLE board_data CHANGE datestamp datestamp VARCHAR (14)";
mysql_query($query);
$query = "UPDATE board_data SET author = 'CaptDaveSipler' WHERE author = 'Capt Dave Sipler\'s Sport Fishing'";
mysql_query($query);
$query = "UPDATE board_data SET author = 'CaptDaveSipler' WHERE author = 'Capt. Dave Sipler\'s Sport Fishing'";
mysql_query($query);
$query = "UPDATE board_data SET author = 'CaptDaveSipler' WHERE author = 'Capt Dave Sipler Sport Fishing'";
mysql_query($query);
$query = "UPDATE board_data SET author = 'JiminGa' WHERE author = 'Jim fm GA'";
mysql_query($query);
$query = "UPDATE board_data SET author = 'PelicanPirate' WHERE author = 'Pelican Pirate'";
mysql_query($query);
$query = "UPDATE board_data SET author = 'Capt_Don' WHERE author = 'Capt Don'";
mysql_query($query);
$query = "UPDATE board_data SET author = 'Bill_Sax' WHERE author = 'Bill Sax'";
mysql_query($query);
*/
$result = mysql_query("SELECT id, board, thread, parent, author, email, subject, body, UNIX_TIMESTAMP(datestamp) as datestamp, ip, host, vipflag, link, linkname, image, locked, sticky, email_replies, hide_email, counter FROM board_data LIMIT 5000,500", $db_conn);

for ($x= 0; $x < mysql_num_rows($result); $x++)
{
$row = mysql_fetch_assoc($result);
//$poster = $row[author];
$poster = addslashes($row[author]);

//if ($poster = "Capt Dave Sipler's Sport Fishing") { $poster = "CaptDaveSipler"; }
//elseif ($poster = "Capt. Dave Sipler's Sport Fishing") { $poster = "CaptDaveSipler"; }
// Capt Dave Sipler Sport Fishing
//else {$poster = addslashes($row[author]);}

$dateposted = $row[datestamp];
$B_Parent = $row[parent];
$B_Board = $board_name;
$B_Number = $row[id];
$B_Main = $row[thread];
$B_Posted = $row[datestamp]; // need to convert the dates here
//$B_Last_Post = $row[datestamp]; // another timestamp. is it needed for the conversion?
$B_IP = addslashes($row[ip]);
$B_Subject = addslashes($row[subject]);
$body = stripslashes($row[body]);
if ($row[image] != "") {$image = "<img src="".$row[image].""";} else {$image = "";}
if ($row[link] != "") {$link = "<a href="".$row[link]."" target="_blank">".$row[linkname]."</a>";} else {$link = "";}
$B_Body = "".addslashes($row[body])."<br><br>".addslashes($link)."<br><br>".addslashes($image)."";
$B_Mail = "O";
$B_File = "";
$B_Kept = "";
$B_Status = "O";
$B_Approved = "yes";
$B_Picture = "";
$B_Icon = "book.gif";
$B_UTitle = "";
$B_Counter = 0;
$B_Sticky = "";
$B_Replies = ""; // not sure how to do this one
$B_Poll = "";
$B_Convert = "markup";
$B_Signature = "";
$B_LastEdit = "";
$B_LastEditBy = "";
$B_Rating = "";
$B_Rates = "";
$B_RealRating = "";
echo "<br>$dateposted";

// see if this is a member
$ismember = mysql_query("SELECT * from w3t_users WHERE U_Username = '$poster'");

if ($ismember && (mysql_num_rows($ismember)>0)) // if the author is a member...
{
$memberrow = mysql_fetch_assoc($ismember); // get the member info from the database
$oldtotalposts = $memberrow[U_Totalposts]; // not sure if this is needed, but.....
$totalposts = ($oldtotalposts+1);
$update_result = mysql_query("UPDATE w3t_users SET U_Totalposts=U_Totalposts+1, U_Laston = '$B_Posted' WHERE U_Username = '$poster'"); // update members total posts by adding 1
if ($update_result == TRUE)
{echo "$poster has posted $totalposts messages.<br>";}
else
{echo "<font color=red>The member total posts could not be updated</font><br>";}




$B_Username = $poster; //addslashes($row[author]); // assign the member name
$B_Reged = "y"; // indicate author is indeed a member
$B_PosterId = $memberrow[U_Number];

}
else
{ // since the author is not a registered member
echo "$poster is not a registered member!<br>";
$B_Username = $poster; //addslashes($row[author]); // assign the author name
$B_Reged = "n"; // indicate that the author is not a member
$B_PosterId = 1;
}
if ($B_Parent == 0)
{
$B_ParentUser = $poster;
$B_Topic = 1;
}
else
{
$B_ParentUser = $poster;
$B_Topic = 0;
}

$post_added = mysql_query("INSERT INTO w3t_posts (B_Board, B_Number, B_Parent, B_Main, B_Posted, B_Last_Post, B_Username, B_IP, B_Subject, B_Body, B_Mail, B_File, B_Kept, B_Status, B_Approved, B_Picture, B_Icon, B_Color, B_Reged, B_UTitle, B_Counter, B_Sticky, B_Replies, B_Poll, B_ParentUser, B_UStatus, B_Topic, B_Convert, B_Signature, B_LastEdit, B_LastEditBy, B_PosterId, B_Rating, B_Rates, B_RealRating)
VALUES ('$B_Board','$B_Number','$B_Parent','$B_Main','$B_Posted','$B_Posted','$B_Username','$B_IP','$B_Subject','$B_Body','$B_Mail','$B_File','$B_Kept','$B_Status','$B_Approved','$B_Picture','$B_Icon','$B_Color','$B_Reged','$B_UTitle','$B_Counter','$B_Sticky','$B_Replies','$B_Poll','$B_ParentUser','$B_UStatus','$B_Topic','$B_Convert','$B_Signature','$B_LastEdit','$B_LastEditBy','$B_PosterId','$B_Rating','$B_Rates','$B_RealRating')");

if ($B_Parent > 0)
{
$query = "UPDATE w3t_Posts
SET B_Last_Post = '$B_Posted',
B_Replies = B_Replies+1
WHERE B_Main = '$B_Main'
";
mysql_query($query);
}


if ($post_added == TRUE)
{echo "Message number $B_Number has been added.<br>";}
else
{echo "<font color=red>Message number $B_Number could not be added.</font><br>";}

}


mysql_close($db_conn);
echo "<br><br>DONE";

}

port_cyboards_posts();

?>

© UBB.Developers