#!/usr/bin/perl # Last change: PFB 15 Dec 99 0:53 am ############################################################################# # impwww.cgi # Imports Matt Wright's wwwboard messages into FutureForum Web Forum # by Peter F. Brown - peterbrown@futurerealm.com # FutureRealm Productions - futurerealm.com # FutureForum Home Page: 'http://futurerealm.com/forum/futureforum.htm' ############################################################################# # Copyright 1999 Peter F. Brown (FutureRealm Productions) # Complies with the GNU GENERAL PUBLIC LICENSE # and is released as "Open Source Software". # You can therefore use it, modify it, and install it anywhere. # You simply can't SELL IT directly, and you have to include the copyright. # NO WARRANTY IS OFFERED FOR THE USE OF THIS SOFTWARE ############################################################################# # NOTE! PLEASE... read the documentation below. This is a specialized script # that worked perfectly for me, but may not work for your implementation # of the wwwboard script. If you're not a Perl programmer, you may wish # to hire one to work through some of these issues. # -- This script is probably only worth messing with if you have a LOT # of wwwboard messages that you really, really want to keep. # step 1: take the 'index.html' file (from wwwboard) and # remove all text above and below the outer and # tags. THIS IS MANDATORY. The script will assume that # all extraneous text is gone. # ==>>>> THIS OF COURSE ASSUMES THAT YOU HAVE BACKED UP YOUR WWWBOARD FILES! # step 2: set up your empty MySQL table prior to running this script # see the futureforum.cgi file for info about this # step 3: edit all the variables below # step 4: run the script # FIELDS IN THE TABLE THAT IT WILL BE IMPORTED INTO: # fields with no notes will be imported, also #............................................................................ # message_no # we'll use the message id numbers in the index.html file # parent_no # branch_no # level # topic # set this to the default of your choice # since wwwboard won't have this field # subject # author # email # we have to pull this from the message html file # date # time # seconds # we'll set this based on the above date and time # body # we have to pull this from the message html file # responses # send_email # we'll set this based on the default you choose #................................................................................ # ===>>>> NOTE!! I've kept my own data in this file, that I used, when # I imported my wwwboard files for the "HeartThread Forum", # (at 'http://futurerealm.com/forum/heart_thread/'), # because I figured a real example would be the best way # to explain how to do it. So... just change things as you wish. #................................................................................ # ====>>>> NOTE 2: This script is sparsely documented; however, it's all I # could do at this point. Frankly, it was a real headache # putting this script together... I'm glad I only had to # use it once! :-) I never would have bothered, but I had # over 500 messages that I didn't want to lose. #................................................................................ # ====>>>> REALLY, REALLY IMPORTANT NOTE!!!! # The logic of this script made a number of assumptions; one of the biggest # was that the wwwboard index file and individual message files followed # a specific format. One issue that WILL NEED ADJUSTING is the selection # of the DELIMITERS around your body text in each individual message. # In my copy of wwwboard, which I had heavily customized, the body text # was surrounded by the
characters, like this: #
# multi line body text here .... # ... #
# This was NON-STANDARD, so you'll probably have to change it, and FIGURE # OUT how to SELECT AND DELIMIT your body text. The code is toward the # bottom of this script. # IN ADDITION, there may be other issues; so... try it, and if it works, great! # (It worked perfectly for my copy, but my copy was, after all, a customized # version. Oy... why is life so complicated... :-) #................................................................................ $indexfile = "./index_long.html"; $ext = ".htm"; $msg_path = "./heart_thread/messages"; $send_email = 'y'; $time = '12:00:00'; $topic = 'Any Topic'; $db_main = 'forum'; # name of database (not table) $db_host = 'localhost'; $db_table = 'heart_thread'; # each forum should have its own table $cnf_file = "../../.my.cnf"; # has user name and password $user_group = 'heart_thread'; # part of .my.cnf $branch_length = 8; # keep this at 8 # DON'T CHANGE WITHOUT CONSULTING DOCS!!! use DBI; &connect_to_db; %months = ( 'January', '01', 'February', '02', 'March', '03', 'April', '04', 'May', '05', 'June', '06', 'July', '07', 'August', '08', 'September', '09', 'October', '10', 'November', '11', 'December', '12' ); # end of variable set up ############################################################################## $cls = `clear`; print $cls; print '-' x 75; print "\n\n"; #............................................................ open (FILE, $indexfile) or die "can't open $indexfile"; @file = ; close(FILE); # => sample of data from a wwwboard index file: #
  • 10th anniverisary depression - Dian 7/11/99 # (0) #
      #
    $message_no = 0; $parent = 0; $level = 1; $branch_no = 0; $response_count = 0; undef(@parent); $parent[0] = 0; $minus_branch_length = $branch_length - ($branch_length * 2); $chop_branch = ($branch_length + 1); $minus_chop = $chop_branch - ($chop_branch * 2); # e.g: substr($parent_branch_no, -8, 8 ) = ''; # substr($parent_branch_no, $minus_chop, $chop_branch ) = ''; foreach $line (@file) { if ($line =~ /[\d]+/) { $responses = $&; $responses = substr($responses, index($responses, '-->')+3 ); $parent_no = $parent[$level-1]; print '-' x 75; print "\n"; print "P: $parent_no - L: $level - M: $message_no - R: $responses - B: $branch_no\n"; print "............. [$subject] ......\n"; # insert into db &insert_msg; } elsif ($line =~ /