#!/usr/bin/perl # soif changed this line for unix #*----------------------------------------*# # iB2 Version 2.1.x => IBF 1.0 # Members Convertor # # Written & Maintained by Stewart Campbell # s.campbell@ibforums.com # # This script is not to be distributed # without written permission of the author. # #*----------------------------------------*# ## SOIF modifications ############################### # This version has been edited and modified by soif to easely install it on unix hosts. # no warranty or support is provided by soif! # soif modifications are ALL commented and can be found by searching 'soif' in the code # # soif modifications include: # - correct path to perl for unix hosts # - fixed $user/$pass typos ;-) # - added .gif to all inported avatars (vatoloco suggestion) # - clean member's websites = "http://" to "" # - start first id at 10 (instead of 2) # - clean signature code # - NULL value corrected to '' # - disable post for 'banned' members and affect them to the $banned_group # remember to chmod this script to 755 ##################################################### $banned_group=3; ## banned members will be moved to this group. leave 3 if you dont want to change them # Basic Setup - NOT UserEditable use CGI; use CGI::Carp qw(fatalsToBrowser); use DBI; use Digest::MD5 qw(md5 md5_hex); my $q = new CGI; # End Basic Setup # USER DEFINABLE ELEMENTS # iB2 Elements # soif notes: keep the trailing '/' in this path /// $ib2dir = "/home/path/to/ikonboard/"; # Where your ikon.lib file resides $ib2version = "219"; # Version of iB2. Enter without .'s. Eg: # 2.1.7 = 217, 2.1.8 = 218 etc $limit = "200"; # Number of members to convert at a time, default is 200 # ADVANCED ONLY $fileformat = "default"; # Unless you have been given Specific instructions on how to use these, # DO NOT ALTER ANYTHING IN THE ADVANCED SECTION ABOVE! # IBF DataBase Elements $db = "database"; # Name of the Database IBF Is Using $host = "localhost"; # Host, normally localhost $username = "user"; # Username for the DB $password = "pass"; # Password for the DB $port = ""; # Port, if different from default $ibfprefix = "ibf_"; # IBF Prefix $adminsname = "admin"; # Admins Name on your IBF, so it doesnt get overwritten # END USER DEFINABLE ELEMENTS my $details = "DBI:mysql:dbname=$db"; $details .= ":$host" if $host; $details .= ":$port" if $port; # soif ## change $user --> $username and $pass --> $password ///////////////////////////////////// my $ibf = DBI->connect($details, $username, $password) or die "$DBI::errstr"; $members = $ibfprefix.members; if ($q->param('a') eq "dynamic") { &do_dynamic; } elsif ($q->param('a') eq "static") { &do_static; } elsif ($q->param('a') eq "members") { &do_members; } # elsif ($q->param('a') eq "categories") { # &do_categories; # } elsif ($q->param('a') eq "finished") { &convert_done; } else { &do_frames; } #------------------------------------------------------------------------- # soif - fn copied from ikonboardlib ######### sub ikoncode { my $post = shift; $post =~ s/\

/

/isg; $post =~ s|\[\[|\{\{|g; $post =~ s|\]\]|\}\}|g; $post =~ s|\n\[|\[|g; $post =~ s|\]\n|\]|g; $post =~ s|
|
|g; $post =~ s|\[hr\]\n|\


|g; $post =~ s|\[hr\]|\
|g; $post =~ s/\[quote\](.*)\[quote\](.*)\[\/quote](.*)\[\/quote\]/

$1<\/font>

$2<\/font>
<\/blockquote>$3<\/font>
<\/blockquote>/isg; $post =~ s/\[quote\]\s*(.*?)\s*\[\/quote\]/

$1
<\/blockquote><\/font>/isg; $post =~ s/\[url\](\S+?)\[\/url\]/$1<\/a>/isg; $post =~ s/\[url=http:\/\/(\S+?)\]//isg; $post =~ s/\[url=(\S+?)\]//isg; $post =~ s/\[\/url\]/<\/a>/isg; $post =~ s/\ http:\/\/(\S+?)\ / http\:\/\/$1<\/a> /isg; $post =~ s/
http:\/\/(\S+?)\ /
http\:\/\/$1<\/a> /isg; $post =~ s/^http:\/\/(\S+?)\ /http\:\/\/$1<\/a> /isg; $post =~ s/\ www.(\S+?)\ / http\:\/\/www.$1<\/a> /isg; $post =~ s/
www.(\S+?)\ /
http\:\/\/www.$1<\/a> /isg; $post =~ s/^www.(\S+?)\ /http\:\/\/www.$1<\/a> /isg; $post =~ s/\[b\]//isg; $post =~ s/\[\/b\]/<\/b>/isg; $post =~ s/\[i\]//isg; $post =~ s/\[\/i\]/<\/i>/isg; $post =~ s/\[size=\s*(.*?)\s*\]\s*(.*?)\s*\[\/size\]/$2<\/font>/isg; $post =~ s/\[font=\s*(.*?)\s*\]\s*(.*?)\s*\[\/font\]/$2<\/font>/isg; $post =~ s/\[u\]//isg; $post =~ s/\[br\]/
/isg; $post =~ s/\[\/u\]/<\/u>/isg; $post =~ s/\[img\](.+?)\[\/img\]//isg; $post =~ s/\[color=(\S+?)\]//isg; $post =~ s/\[\/color\]/<\/font>/isg; $post =~ s/\\http:\/\/(\S+)/
http:\/\/$1<\/a>/isg; $post =~ s/\[list\]/
    /isg; $post =~ s/\[\*\]/
  • /isg; $post =~ s/\[\/list\]/<\/ul>/isg; $post =~ s/\[code\](.+?)\[\/code\]/
    code:<\/font>
    $1<\/pre><\/font>
    <\/blockquote>/isg; $post =~ s/\\(\S+?)\@(\S+)/
    $1\@$2<\/a>/ig; $post =~ s/\[email=(\S+?)\]//isg; $post =~ s/\[\/email\]/<\/a>/isg; $post =~ s|\{\{|\[|g; $post =~ s|\}\}|\]|g; return $post; } # end routine sub convert_done { print $q->header(); info_screen("Conversion Complete!", "All Members Have Been Converted! There is no need for your members to convert their account, this has been done automatically. A Full Convertor will be available shortly, watch InvisionBoard.com for News!"); } sub do_frames { { print $q->header(); print " Ikonboard 2 to Invision Board Convertor "; exit(); } sub do_dynamic { print $q->header(); # Check we have entered a valid Admin name $std = $ibf->prepare("SELECT id FROM $members WHERE name=?"); $std->execute($adminsname); unless ($std->rows) { print "ERROR!
    An account by the name of $adminsname cannot be found, please edit the script and check the case of the name entered."; exit(); } &info_screen("We're ready to go!", "Connected to mySQL Server: $host - Using Database: $db

    To continue, simply click the link below

    Proceed >>" ); } sub do_static { print $q->header(); &print_top; print " • Welcome!
    Welcome to the Ikonboard 2 to Invision Board Convertor

    Before you continue, have you configured this script? If you have not, open it up in your favourite text editor, and edit the values at the top of the script.
    (The instructions are contained at the top of the script also).

    Remember, that running this convertor will remove all your current Invision Board Forums, Posts and Topics.
    "; &print_bottom("",""); } sub print_bottom { ($copy, $no_exit) = @_; if ($copy eq "") { print "

    © 2002 Invision Board (www.invisionboard.com)
    "; } if ($exit eq "") { exit(); } } sub print_top { $no_header = @_; print " Invision Board Convertor :: mySQL "; if ($no_header=="") { print "
      Invision Board Convertor [ Ikonboard 2 ]
    "; } print "
    "; } sub info_screen { ($title, $msg, $meta) = @_; &print_top("no"); if ($meta ne "") { $meta_tag = ""; $meta_link = "

    ( Click here to continue if the auto-redirect fails )"; } print "
    $meta_tag $title

    $msg $meta_link
    "; &print_bottom('no'); } sub do_members { print $q->header(); $start = $q->param('start'); $stop = $start + $limit - 1; $id = $q->param('id'); $done = $q->param('done'); $dirtoopen = "$ib2dir" . "members"; opendir (DIR, "$dirtoopen"); @dirdata = readdir(DIR); closedir (DIR); # For some unknown reason, im getting DOS dirs, ie . and .. here, so dump them. foreach (@dirdata) { unless ($_ eq "." || $_ eq "..") { push (@temp, $_); } } # Note to Self - This CANT Happen, but Im leaving it in for now, it works fine. @members = grep(/cgi/,@temp); $membercount = scalar(@members); unless ($start > $membercount) { if ($membercount < $stop) { $stop = $membercount -1; } foreach $member (@members[$start .. $stop]) { $filetoopen = "$ib2dir" . "members/$member"; # soif # change beginid from 2 to 10 /////////////////////////////// $beginid = 10; unless ($id) { $id = $beginid; } open (MEMBER, "$filetoopen"); $data = ; close MEMBER; ($membername, $password, $membertitle, $membercode, $numberofposts, $emailaddress, $showemail, $ipaddress, $homepage, $aolname, $icqnumber ,$location ,$interests, $joineddate, $lastpostdate, $signature, $timedifference, $privateforums, $useravatar, $misc1, $misc2, $misc3) = split(/\|/,$data); $members = $ibfprefix."members"; $std = $ibf->prepare("insert into $members(id,mgroup,name,password,email,joined,ip_address,avatar,avatar_size,posts,photo,aim_name,icq_number,location,signature,website,yahoo,title,time_offset,interests,email_pm,email_full,msnname,last_post,allow_post,view_sigs,view_img,view_avs,misc,bday_day,bday_month,bday_year) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); #Check the iB2 Data and amend as neccesary $password = md5_hex($password); #MD5 The pass for convenience. if ($membercode eq "ad") { $mgroup = "4" } else { $mgroup = "3" } # soif # adding .GIF to useravatars // clean empty website // nopost and banned group for banned /////////////////////////////////// $useravatar=$useravatar.".gif"; if ($membercode eq "banned") { $mgroup = $banned_group; $mm_allow_post=0;} else { $mgroup = "3"; $mm_allow_post=1;} if ($homepage eq "http://") { $homepage = "" ;} $signature=&ikoncode($signature); $null=''; $std->execute($id,$mgroup,$membername,$password,$emailaddress,$joineddate,$ipaddress,$useravatar,$null,$numberofposts,$null,$aolname,$icqnumber,$location,$signature,$homepage,$null,$membertitle,$timedifference,$interests,$null,$null,$null,$lastpostdate,$mm_allow_post,1,1,1,$null,$null,$null,$null); # end soif modif ############ # original from stewart # $std->execute($id,$mgroup,$membername,$password,$emailaddress,$joineddate,$ipaddress,$useravatar,NULL,$numberofposts,NULL,$aolname,$icqnumber,$location,$signature,$homepage,NULL,$membertitle,$timedifference,$interests,NULL,NULL,NULL,$lastpostdate,$mm_allow_post,1,1,1,NULL,NULL,NULL,NULL); $id++; } $done = $done + $limit; $start = $start + $limit; &info_screen("Converting Members - $limit at a Time - $done Converted.","Please wait - this may take some time....","ib2_convert.cgi?a=members&start=$start&done=$done&id=$id"); } else { &info_screen("Members Completed - $finish rows converted.","Please wait - Transfering ....", "ib2_convert.cgi?a=finished"); exit(); } } } sub do_categories { print $q->header(); $filetoopen = "$ib2dir" . "data/allforums.cgi"; open (FORUMS, "$filetoopen"); @allforums = ; close(FORUMS); # First of all, lets get the categories sorted. Damn iB2 for having this all in one line! foreach $forum (@allforums) { ($junk,$catname,$catid,$junk)=split(/\|/,$forum); # Get the Bits I need. push (@temp,$catid); # Add all Catids to an array. } foreach (@temp) { if ($_ > $highestid) { $highestid = $_; } } # Acquired Highest ID, now do something with it. $cats = $ibfprefix."categories"; $std = $ibf->prepare("insert into $cats(id,position,state,name,description,image,url) values (?,?,?,?,?,?,?)"); foreach $forum (@allforums) { ($junk,$catname,$catid,$junk)=split(/\|/,$forum); # Get the Bits I need. unless ($tempo[$catid]) { $tempo[$catid] = $forum; } } $id= 0; foreach $uniqueline (@tempo) { if ($id > 0) { ($junk,$catname,$catid,$junk)=split(/\|/,$uniqueline) or die "This shouldnt happen."; } $std->execute($catid,$catid,1,$catname,NULL,NULL,NULL); $id++; } &info_screen("Categories Completed - $highestid rows converted.","Please wait - Transfering to Forum Conversion....", "ib2_convert.cgi?a=forums"); }