#!/usr/bin/perl -- # $Id: YaBB Converter $ # $HeadURL: YaBB $ # $Source: /Convert.pl $ ############################################################################### # Convert.pl # # $Date: 1.15.13 $ # ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Community Software for Webmasters # # Version: YaBB 2.5.4 # # Packaged: January 1, 2013 # # Distributed by: http://www.yabbforum.com # # =========================================================================== # # Copyright (c) 2000-2013 YaBB (www.yabbforum.com) - All Rights Reserved. # # Software by: The YaBB Development Team # # with assistance from the YaBB community. # ############################################################################### # use strict; # use warnings; no warnings qw(uninitialized once redefine); use CGI::Carp qw(fatalsToBrowser); use English qw(-no_match_vars); our $VERSION = '2.5.4'; $convertplver = 'YaBB 2.5.4 $Revision$'; # conversion will stop after $max_process_time # in seconds, than the browser will call the script # again until all is done. Don't put it too high # or you will run into server or browser timeout $max_process_time = 20; $time_to_jump = time() + $max_process_time; if ( $ENV{'SERVER_SOFTWARE'} =~ /IIS/sm ) { $yyIIS = 1; if ( $PROGRAM_NAME =~ m{(.*)(\\|/)}xsm ) { $yypath = $1; } $yypath =~ s/\\/\//gxsm; chdir $yypath; push @INC, $yypath; } ### Requirements and Errors ### $script_root = $ENV{'SCRIPT_FILENAME'}; if ( !$script_root ) { $script_root = $ENV{'PATH_TRANSLATED'}; $script_root =~ s/\\/\//gxsm; } $script_root =~ s/\/Convert\.(pl|cgi)//igxsm; if ( -e './Paths.pm' ) { require Paths; } elsif ( -e "$script_root/Paths.pm" ) { require "$script_root/Paths.pm"; } elsif ( -e "$script_root/Variables/Paths.pm" ) { require "$script_root/Variables/Paths.pm"; } if ( -e 'YaBB.cgi' ) { $yyext = 'cgi'; } else { $yyext = 'pl'; } if ($boardurl) { $set_cgi = "$boardurl/Convert.$yyext"; } else { $set_cgi = "Convert.$yyext"; } # Make sure the module path is present push @INC, './Modules'; require Sources::Subs; require Sources::System; require Sources::Load; require Sources::DateTime; ############################################# # Conversion starts here # ############################################# $px = 'px'; # Conversion was rewritten and fixed for xx-large # forums by Detlef Pilzecker (deti) in June 2008 # The 'our' function is available sincee Perl v5.6.0 # If your Perl version is lower, then comment the 'our'-lines out and use this: # use vars qw(@categoryorder,@catboards,@catdata,@boarddata,@allboards,%catinfo,%cat,%board,%boarddata,$catfile,$boardfile,$key,$value,$cnt); our ( @categoryorder, @catboards, @catdata, @boarddata, @allboards ); our ( %catinfo, %cat, %board, %boarddata ); our ( $catfile, $boardfile, $key, $value, $cnt ); our (%fixed_users); if ( -e "$vardir/Setup.lock" ) { if ( -e "$vardir/Converter.lock" ) { FoundConvLock(); } if ( -e "$vardir/fixusers.txt" ) { fopen( FIXUSER, "$vardir/fixusers.txt" ) || setup_fatal_error( "$maintext_23 $vardir/fixusers.txt: ", 1 ); my @fixed = ; fclose(FIXUSER); foreach (@fixed) { my ( $user, $fixedname, undef, $displayedname, undef ) = split /\|/xsm, $_; @{ $fixed_users{$user} } = ( $fixedname, $displayedname ); } } tempstarter(); tabmenushow(); if ( $action && !$INFO{'convert'} ) { # needed for: sub conv_stringtotime require Time::Local; import Time::Local 'timelocal'; } elsif ( !$action || $INFO{'convert'} ) { $yytabmenu = $NavLink1 . $NavLink2 . $NavLink3 . $NavLink4 . $NavLink5 . $NavLink6; $yymain = qq~
YaBB 2.5.4 Converter
Make sure your YaBB 2.5.4 installation is running and that it has all the correct folder paths and URLs.
Proceed through the following steps to convert your YaBB 1 Gold - SP 1.x forum to YaBB 2.5.4!

If your YaBB 1 Gold - SP 1.x forum is located on the same server as your YaBB 2.5.4 installation:
  1. Insert the path to your YaBB 1 Gold - SP 1.x forum in the input field below
  2. Click on the 'Continue' button
Else if your YaBB 1 Gold - SP 1.x forum is located on a different server than your YaBB 2.5.4 installation or if you do not know the path to your SP 1.x forum:
  1. Copy all files in the /Boards, /Members, and /Messages folders from your YaBB 1 Gold - SP 1.x installation, to the corresponding Convert/Boards, Convert/Members, and Convert/Messages folders of your YaBB 2.5.4 installation, and chmod them 777.
  2. Copy cat.txt from the /Variables folder of your YaBB 1 Gold - SP 1.x installation to the Convert/Variables folder of your YaBB 2.5.4 installation, and chmod it 666.
  3. If you have 'Add More Membergroups' installed on your YaBB 1 Gold - SP 1.x, copy MemberStats.txt from the /Variables folder of your YaBB 1 Gold - SP 1.x installation to the Convert/Variables folder of your YaBB 2.5.4 installation, and chmod it 666.
  4. Click on the 'Continue' button
Path to your YaBB 1 Gold - SP 1.x files:

~; } if ( $action eq 'prepare' ) { UpdateCookie('delete'); $username = 'Guest'; $iamguest = '1'; $iamadmin = q{}; $iamgmod = q{}; $password = q{}; $yyim = q{}; local $ENV{'HTTP_COOKIE'} = q{}; $yyuname = q{}; $convertdir = $FORM{'convertdir'}; if ( !-d "$convertdir/Boards" ) { setup_fatal_error( "Directory: $convertdir/Boards", 1 ); } else { $convboardsdir = "$convertdir/Boards"; } if ( !-e "$convertdir/Members/memberlist.txt" ) { setup_fatal_error( "Directory: $convertdir/Members", 1 ); } else { $convmemberdir = "$convertdir/Members"; } if ( !-d "$convertdir/Messages" ) { setup_fatal_error( "Directory: $convertdir/Messages", 1 ); } else { $convdatadir = "$convertdir/Messages"; } if ( !-e "$convertdir/Variables/cat.txt" ) { setup_fatal_error( "Directory: $convertdir/Variables", 1 ); } else { $convvardir = "$convertdir/Variables"; } my $setfile = << "EOF"; \$convertdir = qq~$convertdir~; \$convboardsdir = qq~$convertdir/Boards~; \$convmemberdir = qq~$convertdir/Members~; \$convdatadir = qq~$convertdir/Messages~; \$convvardir = qq~$convertdir/Variables~; 1; EOF fopen( SETTING, ">$vardir/ConvSettings.txt" ) || setup_fatal_error( "$maintext_23 $vardir/ConvSettings.txt: ", 1 ); print {SETTING} nicely_aligned_file($setfile) or croak 'cannot print SETTING'; fclose(SETTING); $yytabmenu = $NavLink1a . $NavLink2 . $NavLink3 . $NavLink4 . $NavLink5 . $NavLink6; $yymain = qq~
YaBB 2.5.4 Converter
  • Members info found in: $convmemberdir
  • Board and Category info found in: $convboardsdir
  • Messages info found in: $convdatadir
  • cat.txt found in: $convvardir
- Conversion can take a long time depending on the size of your forum (30 seconds to a couple hours).
- Your browser will be refreshed automatically every $max_process_time seconds and you will see the ongoing process in the status bar.
- Some internet connections refresh their IP-Address automatically every 24 hours.
  Make sure that your IP-Address will not change during conversion, or you must restart the conversion after that!
- Your forum will be set to maintenance while converting.

Click on 'Members' in the menu to start.
 

~; } elsif ( $action eq 'members' ) { if ( !exists $INFO{'mstart1'} ) { PrepareConv(); } $INFO{'mstart2'} ? ConvertMembers2() : ConvertMembers1(); $yytabmenu = $NavLink1 . $NavLink2a . $NavLink3 . $NavLink4 . $NavLink5 . $NavLink6; $yymain = qq~
YaBB 2.5.4 Converter
Member Conversion.
$ConvDone
Board and Category Conversion.
$ConvNotDone
Message Conversion.
$ConvNotDone
Date & Time Conversion.
$ConvNotDone
Final Cleanup.
$ConvNotDone
New User data files have been created.
Password encryption is done for each user the first time he/she logs in.

You are converting ~ . int( ( $INFO{'st'} + 60 ) / 60 ) . qq~ minutes.

Click on 'Boards & Categories' in the menu to continue.
If you do not do that the script will continue itself in 5 Minutes.

~; if ( -e "$vardir/fixusers.txt" ) { fopen( FIXUSER, "$vardir/fixusers.txt" ) || setup_fatal_error( "$maintext_23 $vardir/fixusers.txt: ", 1 ); my @fixed = ; fclose(FIXUSER); chomp @fixed; $yymain .= qq~
~; foreach my $userfixed (@fixed) { ( $inname, $fxname, $rgdate, $dspname, $tmail ) = split /\|/xsm, $userfixed; $yymain .= qq~~; } $yymain .= q~
Member(s) with illegal username(s) were found and converted to legal name(s).
You can find this information in the $vardir/fixusers.txt file. If you do not need it, you can delete it later.
Invalid name Fixed name Reg. date Displayed name E-mail
$inname $fxname $rgdate $dspname $tmail
~; } } elsif ( $action eq 'members2' ) { if ( $INFO{'mstart1'} <= 0 || $INFO{'mstart2'} < 0 ) { setup_fatal_error( "Member conversion (members2) 'mstart1' ($INFO{'mstart1'}), 'mstart2' ($INFO{'mstart2'}) error!" ); } $yytabmenu = $NavLink1 . $NavLink2 . $NavLink3 . $NavLink4 . $NavLink5 . $NavLink6; my $mwidth = int( ( ( $INFO{'mstart2'} + $INFO{'mstart1'} ) / 2 ) / $INFO{'mtotal'} * 100 ); $yymain = qq~
YaBB 2.5.4 Converter
Member Conversion.
 
$mwidth %

Board and Category Conversion.
$ConvNotDone
Message Conversion.
$ConvNotDone
Date & Time Conversion.
$ConvNotDone
Final Cleanup.
$ConvNotDone
To prevent server time-out due to the amount of members to be converted, the conversion is split into more steps.

The time-step (\$max_process_time) is set to $max_process_time seconds.
The last step took ~ . ( $time_to_jump - $INFO{'starttime'} ) . q~ seconds.
You are converting ~ . int( ( $INFO{'st'} + 60 ) / 60 ) . q~ minutes.

There are ~ . int( $INFO{'mtotal'} - ( ( $INFO{'mstart2'} + $INFO{'mstart1'} ) / 2 ) ) . qq~/$INFO{'mtotal'} Members left to be converted.

If nothing happens in 5 seconds click here to continue...
If you want to STOP 'Members' conversion click here. Then copy the actual browser adress and type it in when you are going to continue the conversion.

~; } elsif ( $action eq 'cats' ) { if ( !exists $INFO{'bstart'} || !exists $INFO{'bfstart'} ) { GetCats(); CreateControl(); } ConvertBoards(); $yytabmenu = $NavLink1 . $NavLink2 . $NavLink3a . $NavLink4 . $NavLink5 . $NavLink6; $yymain = qq~
YaBB 2.5.4 Converter
Member Conversion.
$ConvDone
Board & Category Conversion.
$ConvDone
Message Conversion.
$ConvNotDone
Date & Time Conversion.
$ConvNotDone
Final Cleanup.
$ConvNotDone
New forum.master file has been created.
New forum.control file has been created.
All dates in files have been converted to timestamps.
All threads have been converted.

You are converting ~ . int( ( $INFO{'st'} + 60 ) / 60 ) . qq~ minutes.

Click on 'Messages' in the menu to continue.
If you do not do that the script will continue by itself in 5 minutes.

~; } elsif ( $action eq 'cats2' ) { if ( ( !$INFO{'bstart'} && !$INFO{'bfstart'} ) || $INFO{'bstart'} < 0 || $INFO{'bfstart'} < 0 ) { setup_fatal_error( "Boards conversion (cats2) 'bstart' ($INFO{'bstart'}) or 'bfstart' ($INFO{'bfstart'}) error!" ); } $yytabmenu = $NavLink1 . $NavLink2 . $NavLink3 . $NavLink4 . $NavLink5 . $NavLink6; my $bwidth = int( $INFO{'bstart'} / $INFO{'btotal'} * 100 ); $yymain = qq~
YaBB 2.5.4 Converter
Member Conversion.
$ConvDone
Board and Category Conversion.
 
$bwidth %

Message Conversion.
$ConvNotDone
Date & Time Conversion.
$ConvNotDone
Final Cleanup.
$ConvNotDone
To prevent server time-out due to the amount of boards to be converted, the conversion is split into more steps.

The time-step (\$max_process_time) is set to $max_process_time seconds.
The last step took ~ . ( $time_to_jump - $INFO{'starttime'} ) . q~ seconds.
You are converting ~ . int( ( $INFO{'st'} + 60 ) / 60 ) . q~ minutes.

There are ~ . ( $INFO{'btotal'} - $INFO{'bstart'} ) . qq~/$INFO{'btotal'} Boards left to be converted.

If nothing happens in 5 seconds click here to continue...
If you want to STOP 'Boards & Categories' conversion click here. Then copy the actual browser address and type it in when you are going to continue the conversion.

~; } elsif ( $action eq 'messages' ) { ConvertMessages(); $yytabmenu = $NavLink1 . $NavLink2 . $NavLink3 . $NavLink4a . $NavLink5 . $NavLink6; $yymain = qq~
YaBB 2.5.4 Converter
Member Conversion.
$ConvDone
Board and Category Conversion.
$ConvDone
Message Conversion.
$ConvDone
Date & Time Conversion.
$ConvNotDone
Final Cleanup.
$ConvNotDone
New style message files have been created.

$INFO{'total_threads'} Threads have been converted.
$INFO{'total_mess'} Messages have been converted.

You are converting ~ . int( ( $INFO{'st'} + 60 ) / 60 ) . qq~ minutes.

Click on 'Date & Time' in the menu to continue.
If you do not do that the script will continue by itself in 5 minutes.

~; } elsif ( $action eq 'messages2' ) { if ( ( !$INFO{'count'} && !$INFO{'tcount'} ) || $INFO{'count'} < 0 || $INFO{'tcount'} < 0 ) { setup_fatal_error( "Message conversion (messages2) 'count' ($INFO{'count'}) or 'tcount' ($INFO{'tcount'}) error!", 1 ); } my $bwidth = int( $INFO{'count'} / $INFO{'totboard'} * 100 ); my $mwidth = $INFO{'totmess'} ? int( $INFO{'tcount'} / $INFO{'totmess'} * 100 ) : 0; $yytabmenu = $NavLink1 . $NavLink2 . $NavLink3 . $NavLink4 . $NavLink5 . $NavLink6; $yymain = qq~
YaBB 2.5.4 Converter
Member Conversion.
$ConvDone
Board and Category Conversion.
$ConvDone
Message Conversion.
 
$bwidth %

Date & Time Conversion.
$ConvNotDone
Final Cleanup.
$ConvNotDone
To prevent server time-out due to the amount of messages to be converted, the conversion is split into more steps.

The time-step (\$max_process_time) is set to $max_process_time seconds.
The last step took ~ . ( $time_to_jump - $INFO{'starttime'} ) . q~ seconds.
You are converting ~ . int( ( $INFO{'st'} + 60 ) / 60 ) . qq~ minutes.

$INFO{'total_threads'} Threads where converted until now.
$INFO{'total_mess'} Messages where converted until now.

There are ~ . ( $INFO{'totboard'} - $INFO{'count'} ) . qq~/$INFO{'totboard'} Boards left, to convert the Messages in.
There are ~ . ( $INFO{'totmess'} - $INFO{'tcount'} ) . qq~/$INFO{'totmess'} Threads left in the actual Board to be converted.  
 
$mwidth %

If nothing happens in 5 seconds click here to continue...
If you want to STOP 'Messages' conversion click here. Then copy the actual browser address and type it in when you are going to continue the conversion.

~; } elsif ( $action eq 'dates' ) { ConvertTimeToString(); $yytabmenu = $NavLink1 . $NavLink2 . $NavLink3 . $NavLink4 . $NavLink5a . $NavLink6; $yymain = qq~
YaBB 2.5.4 Converter
Member Conversion.
$ConvDone
Board & Category Conversion.
$ConvDone
Message Conversion.
$ConvDone
Date & Time Conversion.
$ConvDone
Final Cleanup.
$ConvNotDone
New style timestamps have been created throughout the board. All old style dates have been converted.

You are converting ~ . int( ( $INFO{'st'} + 60 ) / 60 ) . qq~ minutes.

Click on 'Clean Up' in the menu to continue.
If you do not do that the script will continue by itself in 5 minutes.

~; } elsif ( $action eq 'dates2' ) { if ( $INFO{'pollfile'} <= 0 && $INFO{'polledfile'} <= 0 ) { setup_fatal_error( "Date & Time conversion (dates2) error! pollfile($INFO{'pollfile'}), polledfile($INFO{'polledfile'})", 1 ); } my $pollwidth = ( $INFO{'totalpolls'} && $INFO{'pollfile'} ) ? int( $INFO{'pollfile'} / $INFO{'totalpolls'} * 100 ) : 100; $INFO{'pollfile'} = $INFO{'pollfile'} ? $INFO{'pollfile'} : $INFO{'totalpolls'}; my $polledwidth = ( $INFO{'totalpolled'} && $INFO{'polledfile'} ) ? int( $INFO{'polledfile'} / $INFO{'totalpolled'} * 100 ) : 0; $INFO{'polledfile'} = $INFO{'polledfile'} ? $INFO{'polledfile'} : $INFO{'totalpolled'}; $yytabmenu = $NavLink1 . $NavLink2 . $NavLink3 . $NavLink4 . $NavLink5 . $NavLink6; $yymain = qq~
YaBB 2.5.4 Converter
Member Conversion.
$ConvDone
Board & Category Conversion.
$ConvDone
Message Conversion.
$ConvDone
Date & Time Conversion.
See info below!
--- %

Final Cleanup.
$ConvNotDone
To prevent server time-out due to the amount of Date & Time conversion, the conversion is split into more steps.

The time-step (\$max_process_time) is set to $max_process_time seconds.
The last step took ~ . ( $time_to_jump - $INFO{'starttime'} ) . q~ seconds.
You are converting ~ . int( ( $INFO{'st'} + 60 ) / 60 ) . q~ minutes.

There are ~ . ( $INFO{'totalpolls'} - $INFO{'pollfile'} ) . qq~/$INFO{'totalpolls'} Polls left to be converted.  
 
$pollwidth %


There are ~ . ( $INFO{'totalpolled'} - $INFO{'polledfile'} ) . qq~/$INFO{'totalpolled'} Polled-Files left to be converted.  
 
$polledwidth %


If nothing happens in 5 seconds click here to continue...
If you want to STOP 'Date & Time' conversion click here. Then copy the actual browser address and type it in when you are going to continue the conversion.

~; } elsif ( $action eq 'cleanup' ) { require "$boardsdir/forum.master"; if ( !$INFO{'clean'} ) { fopen( FORUMTOTALS, ">>$boardsdir/forum.totals" ) || setup_fatal_error( "Can not open $boardsdir/forum.totals", 1 ); foreach my $testboard (@allboards) { chomp $testboard; if ( -e "$convboardsdir/$testboard.ttl" ) { fopen( BOARDTTL, "$convboardsdir/$testboard.ttl" ) || setup_fatal_error( "Can not open $convboardsdir/$testboard.ttl", 1 ); my $line = ; fclose(BOARDTTL); chomp $line; print {FORUMTOTALS} "$testboard|$line|\n" or croak 'cannot print FORUMTOTALS'; #unlink "$convboardsdir/$testboard.ttl"; } } print {FORUMTOTALS} "recycle|0|0|N/A|N/A||||\n" or croak 'cannot print FORUMTOTALS'; print {FORUMTOTALS} "announcements|0|0|N/A|N/A||||\n" or croak 'cannot print FORUMTOTALS'; print {FORUMTOTALS} "general|1|1|1278201900|admin|1278201900|0|Welcome to your new YaBB 2\.5\.4 forum!|xx|0|\n" or croak 'cannot print FORUMTOTALS'; fclose(FORUMTOTALS); $yySetLocation = qq~$set_cgi?action=cleanup2;st=~ . int( $INFO{'st'} + time() - $time_to_jump + $max_process_time ) . qq~;starttime=$time_to_jump;clean=1;pass_error=1;total_boards=~ . @allboards; redirectexit(); } if ( $INFO{'clean'} == 1 ) { MyReCountTotals(); } if ( $INFO{'clean'} == 2 ) { MyMemberIndex(); } if ( $INFO{'clean'} == 3 ) { MyMailNotify(); } if ( $INFO{'clean'} == 4 ) { FixNopost(); } if ( $INFO{'tmp_firstforum'} > $INFO{'firstforum'} ) { $setforumstart = timeformat( $INFO{'tmp_firstforum'} ); $firstmember = timeformat( $INFO{'firstforum'} ); $forumstarttext = qq~The Forum Start date was set to $setforumstart but the first member was registered $firstmember. So we changed the Forum Start Date to $firstmember.~; } $yytabmenu = $NavLink1 . $NavLink2 . $NavLink3 . $NavLink4 . $NavLink5 . $NavLink7a . $NavLink6a; $formsession = cloak("$mbname$username"); if ( -e 'Convert/Members/admin.dat' ) { $convtext .= q~

After you have tested your forum and made sure everything was converted correctly you can go to your Admin Center and delete /Convert/Boards, /Convert/Members, /Convert/Messages and /Convert/Variables folders and their contents.~; } if ( -e "$vardir/fixusers.txt" ) { $convtext .= qq~

There were some illegal usernames. Their names were changed. Please inform them. You can find the list in the $vardir/fixusers.txt~; } $yymain = qq~
YaBB 2.5.4 Converter
Member Conversion.
$ConvDone
Board and Category Conversion.
$ConvDone
Message Conversion.
$ConvDone
Date & Time Conversion.
$ConvDone
Final Cleanup.
$ConvDone
$forumstarttext $convtext

The conversion took ~ . int( ( $INFO{'st'} + 60 ) / 60 ) . qq~ minutes.


We recommend you delete the file "$ENV{'SCRIPT_NAME'}". This is to prevent someone else running the converter and damaging your files.

Further more, we strongly recomend to run the following "Maintenance Controls" in the "Admin Center" before you start doing other things:
- Rebuild Message Index
- Recount Board Totals
- Rebuild Members List
- Recount Membership
- Rebuild Members History
- Rebuild Notifications Files
- Clean Users Online Log
- Attachment Functions => Rebuild Attachments


You may now log in to your forum or you can run the Extended Profiles converter by clicking on the button above. Enjoy using YaBB 2.5.4!
~; # CreateConvLock(); } elsif ( $action eq 'extended' ) { ext_admin_convert(); $yytabmenu = $NavLink1 . $NavLink2 . $NavLink3 . $NavLink4 . $NavLink5 . $NavLink7a . $NavLink6a; $yymain = qq~
YaBB 2.5.4 Converter
Member Conversion.
$ConvDone
Board and Category Conversion.
$ConvDone
Message Conversion.
$ConvDone
Date & Time Conversion.
$ConvDone
Final Cleanup.
$ConvDone
The Extended Profiles conversion took ~ . int( ( $INFO{'st'} + 60 ) / 60 ) . qq~ minutes.


You may now login to your forum . Enjoy using YaBB 2.5.4!
~; CreateConvLock(); } elsif ( $action eq 'cleanup2' ) { if ( ( !$INFO{'pass_error'} && $INFO{'my_re_tot'} <= 0 ) && $INFO{'memb_index'} <= 0 && $INFO{'my_mail_n'} <= 0 && $INFO{'fix_nopost'} <= 1 ) { setup_fatal_error( "Clean Up (cleanup2) error! pass_error($INFO{'pass_error'}), my_re_tot($INFO{'my_re_tot'}), memb_index($INFO{'memb_index'}), my_mail_n($INFO{'my_mail_n'})", 1 ); } my $re_tot_width = ( $INFO{'total_re_tot'} && $INFO{'my_re_tot'} ) ? int( $INFO{'my_re_tot'} / $INFO{'total_re_tot'} * 100 ) : ( $INFO{'total_re_tot'} ? 100 : 0 ); $INFO{'my_re_tot'} = $INFO{'my_re_tot'} ? $INFO{'my_re_tot'} : $INFO{'total_re_tot'}; my $memb_index_width = ( $INFO{'total_memb'} && $INFO{'memb_index'} ) ? int( $INFO{'memb_index'} / $INFO{'total_memb'} * 100 ) : ( $INFO{'total_memb'} ? 100 : 0 ); $INFO{'memb_index'} = $INFO{'memb_index'} ? $INFO{'memb_index'} : $INFO{'total_memb'}; my $mail_not_width = ( $INFO{'total_mail_n'} && $INFO{'my_mail_n'} ) ? int( $INFO{'my_mail_n'} / $INFO{'total_mail_n'} * 100 ) : ( $INFO{'total_mail_n'} ? 100 : 0 ); $INFO{'my_mail_n'} = $INFO{'my_mail_n'} ? $INFO{'my_mail_n'} : $INFO{'total_mail_n'}; my $nopost_width = $INFO{'total_nopost'} ? int( $INFO{'fix_nopost'} / $INFO{'total_nopost'} * 100 ) : 0; $yytabmenu = $NavLink1 . $NavLink2 . $NavLink3 . $NavLink4 . $NavLink5 . $NavLink6; $yymain = qq~
YaBB 2.5.4 Converter
Member Conversion.
$ConvDone
Board & Category Conversion.
$ConvDone
Message Conversion.
$ConvDone
Date & Time Conversion.
$ConvDone
Final Cleanup.
See info below!
--- %
To prevent server time-out due to the amount to Clean Up, the Cleanup is split into more steps.

The time-step (\$max_process_time) is set to $max_process_time seconds.
The last step took ~ . ( $time_to_jump - $INFO{'starttime'} ) . q~ seconds.
You are converting ~ . int( ( $INFO{'st'} + 60 ) / 60 ) . qq~ minutes.

There are 0/$INFO{'total_boards'} Boards (1) left to be recounted.  
 
100 %


There are ~ . ( $INFO{'total_re_tot'} - $INFO{'my_re_tot'} ) . qq~/$INFO{'total_re_tot'} Boards (2) left to be recounted.  
 
$re_tot_width %


There are ~ . ( $INFO{'total_memb'} - $INFO{'memb_index'} ) . qq~/$INFO{'total_memb'} Members left to be recounted.  
 
$memb_index_width %


There are ~ . ( $INFO{'total_mail_n'} - $INFO{'my_mail_n'} ) . qq~/$INFO{'total_mail_n'} Notifications left to be written new.  
 
$mail_not_width %


There are ~ . ( $INFO{'total_nopost'} - $INFO{'fix_nopost'} ) . qq~/$INFO{'total_nopost'} NoPost-Membergroups left to be updated.  
 
$nopost_width %


If nothing happens in 5 seconds click here to continue...
If you want to STOP 'Clean Up' conversion click here. Then copy the actual browser address and type it in when you are going to continue the conversion.

~; } $yyim = 'You are running the YaBB 2.5.4 Converter.'; $yytitle = 'YaBB 2.5.4 Converter'; SetupTemplate(); } # Prepare Conversion ## sub PrepareConv { fopen( FILE, ">$boardsdir/dummy.testfile" ) || setup_fatal_error( "The CHMOD of the $boardsdir is not set correctly! Cannot write this directory!", 1 ); print {FILE} "dummy testfile\n" or croak 'cannot print FILE'; fclose(FILE); opendir( BDIR, $boardsdir ) || setup_fatal_error( "The CHMOD of the $boardsdir is not set correctly! Cannot read this directory! ", 1 ); @boardlist = readdir BDIR; closedir BDIR; fopen( FILE, ">$memberdir/dummy.testfile" ) || setup_fatal_error( "The CHMOD of the $memberdir is not set correctly! Cannot write this directory!", 1 ); print {FILE} "dummy testfile\n" or croak 'cannot print FILE'; fclose(FILE); opendir( MBDIR, $memberdir ) || setup_fatal_error( "The CHMOD of the $memberdir is not set correctly! Cannot read this directory! ", 1 ); @memblist = readdir MBDIR; closedir MBDIR; fopen( FILE, ">$datadir/dummy.testfile" ) || setup_fatal_error( "The CHMOD of the $datadir is not set correctly! Cannot write this directory!", 1 ); print {FILE} "dummy testfile\n" or croak 'cannot print FILE'; fclose(FILE); opendir( MSDIR, $datadir ) || setup_fatal_error( "The CHMOD of the $datadir is not set correctly! Cannot read this directory! ", 1 ); @msglist = readdir MSDIR; closedir MSDIR; automaintenance('on'); unlink "$vardir/fixusers.txt"; foreach my $file (@boardlist) { if ( $file ne '.htaccess' && $file ne 'index.html' && $file ne 'forum.control' && $file ne q{.} && $file ne q{..} ) { unlink "$boardsdir/$file"; } } foreach my $file (@memblist) { if ( $file ne '.htaccess' && $file ne 'index.html' && $file ne 'admin.vars' && $file ne q{.} && $file ne q{..} ) { unlink "$memberdir/$file"; } } foreach my $file (@msglist) { if ( $file ne '.htaccess' && $file ne 'index.html' && $file ne q{.} && $file ne q{..} ) { unlink "$datadir/$file"; } } return; } # / Prepare Conversion ## # Member Conversion ## sub ConvertMembers1 { fopen( MEMDIR, "$convmemberdir/memberlist.txt" ) || setup_fatal_error( "$maintext_23 $convmemberdir/memberlist.txt: ", 1 ); my @memlist = ; fclose(MEMDIR); for my $i ( ( $INFO{'mstart1'} || 0 ) .. ( @memlist - 1 ) ) { $uname = $memlist[$i]; chomp $uname; next if !-e "$convmemberdir/$uname.dat"; if ( $uname =~ /[^\w\+\-\.\@]|guest/ixsm ) { IllegalUser($uname); } else { MyUpdateUser($uname); } if ( time() > $time_to_jump && ( $i + 1 ) < @memlist ) { $yySetLocation = qq~$set_cgi?action=members2;st=~ . int( $INFO{'st'} + time() - $time_to_jump + $max_process_time ) . qq~;starttime=$time_to_jump;mtotal=~ . @memlist . q~;mstart1=~ . ( $i + 1 ); redirectexit(); } } $INFO{'mstart1'} = @memlist; if ( -e "$convvardir/MemberStats.txt" ) { groupconvert(); } if ( -e "$vardir/fixusers.txt" ) { fopen( FIXUSER, "$vardir/fixusers.txt" ) || setup_fatal_error( "$maintext_23 $vardir/fixusers.txt: ", 1 ); my @fixed = ; fclose(FIXUSER); foreach (@fixed) { my ( $user, $fixedname, undef, $displayedname, undef ) = split /\|/xsm, $_; @{ $fixed_users{$user} } = ( $fixedname, $displayedname ); } } ConvertMembers2(); return; } sub IllegalUser { my ($user) = @_; my $fixeduser = $user; $fixeduser =~ s/[^\w\+\-\.\@]|guest//gixsm; if ( !$fixeduser ) { $fixeduser = 'fixeduser'; } $fixeduser = check_existence( $memberdir, "$fixeduser.vars" ); $fixeduser =~ s/(\S+?)(\.\S+$)/$1/xsm; fopen( LOADOLDUSER, "$convmemberdir/$user.dat" ) || setup_fatal_error( "$maintext_23 $convmemberdir/$user.dat: ", 1 ); my @settings = ; fclose(LOADOLDUSER); chomp @settings; my ( $pmignorelist, $pmnotify, $pmpopup, $pmspop ); if ( -e "$convmemberdir/$user.imconfig" ) { fopen( PMUSER, "$convmemberdir/$user.imconfig" ) || setup_fatal_error( "$maintext_23 $convmemberdir/$user.imconfig: ", 1 ); @pmconfics = ; fclose(PMUSER); chomp $pmconfics[0]; chomp $pmconfics[1]; chomp $pmconfics[3]; chomp $pmconfics[5]; $pmignorelist = $pmconfics[0]; $pmnotify = $pmconfics[1] ? 3 : 0; $pmpopup = $pmconfics[3]; $pmspop = $pmconfics[5]; } my ( $lastonline, $lastpost, $lastim ); if ( -e "$convmemberdir/$user.ll" ) { fopen( LLFILE, "$convmemberdir/$user.ll" ) || setup_fatal_error( "$maintext_23 $convmemberdir/$user.ll: ", 1 ); ( $lastonline, $lastpost, $lastim ) = ; fclose(LLFILE); chomp $lastonline; chomp $lastpost; chomp $lastim; $lastonline =~ s/(\d{1,2}\/\d{1,2}\/\d{2,4}).*?(\d{1,2}\:\d{1,2}\:\d{1,2})/&conv_stringtotime("$1 at $2")/eism; $lastpost =~ s/(\d{1,2}\/\d{1,2}\/\d{2,4}).*?(\d{1,2}\:\d{1,2}\:\d{1,2})/&conv_stringtotime("$1 at $2")/eism; $lastim =~ s/(\d{1,2}\/\d{1,2}\/\d{2,4}).*?(\d{1,2}\:\d{1,2}\:\d{1,2})/&conv_stringtotime("$1 at $2")/eism; } if ( -e "$convmemberdir/$user.yam" ) { fopen( YAMFILE, "$convmemberdir/$user.yam" ) || setup_fatal_error( "$maintext_23 $convmemberdir/$user.yam: ", 1 ); my @ipsettings = ; fclose(YAMFILE); chomp $ipsettings[1]; ( $c_ip_one, $c_ip_two, $c_ip_three ) = split /\|/xsm, $ipsettings[1]; if ( $c_ip_one eq '0' ) { $c_ip_one = q{}; } if ( $c_ip_two eq '0' ) { $c_ip_two = q{}; } if ( $c_ip_three eq '0' ) { $c_ip_three = q{}; } } $settings[14] = format_timestring( $settings[14] ); $regitime = "$settings[14]"; $regitime =~ s/(\d{2}\/\d{2}\/\d{2,4}).*?(\d{2}\:\d{2}\:\d{2})/&conv_stringtotime("$1 at $2")/eism; if ($default_template) { $new_template = $default_template; } else { $new_template = q~Forum default~; } if ( $settings[1] eq q{} ) { $settings[1] = $user; } if ( $settings[5] ) { $settings[5] =~ s/&&/&&/gxsm; $settings[5] =~ s/\"/"/gxsm; #"; $settings[5] =~ s/\[size=([+-]?\d)\](.*?)\[\/size\]/ '\[size=' . conv_size($1) . "\]$2\[\/size\]" /igesm; $settings[5] =~ s/
/
/igsm; } my @location = split /,|\|/xsm, $settings[15]; shift @location; %{ $uid . $fixeduser } = ( 'password' => "$settings[0]", 'realname' => "$settings[1]", 'email' => "$settings[2]", 'webtitle' => "$settings[3]", 'weburl' => ( ( $settings[4] && $settings[4] !~ m{\Ahttps?://}sm ) ? 'http://' : q{} ) . $settings[4], 'signature' => "$settings[5]", 'postcount' => "$settings[6]", 'position' => "$settings[7]", 'icq' => "$settings[8]", 'aim' => "$settings[9]", 'yim' => "$settings[10]", 'gender' => "$settings[11]", 'usertext' => "$settings[12]", 'userpic' => "$settings[13]", 'regdate' => "$settings[14]", 'regtime' => "$regitime", 'location' => join( ', ', grep { $_ } @location ), 'bday' => "$settings[16]", 'timeselect' => "$settings[17]", 'timeoffset' => "$timeoffset", 'hidemail' => ( $settings[19] ? 1 : 0 ), 'gtalk' => "$settings[32]", 'template' => "$new_template", 'language' => "$language", 'lastonline' => "$lastonline", 'lastpost' => "$lastpost", 'lastim' => "$lastim", 'im_ignorelist' => "$pmignorelist", 'notify_me' => "$pmnotify", 'im_popup' => ( $pmpopup ? 1 : 0 ), 'im_imspop' => ( $pmspop ? 1 : 0 ), 'cathide' => "$settings[30]", 'postlayout' => ( $settings[31] ? "$settings[31]|0" : q{} ), 'dsttimeoffset' => "$dstoffset", 'pageindex' => '1|1|1', 'lastips' => "$c_ip_one|$c_ip_two|$c_ip_three", ); UserAccount( $fixeduser, 'update' ); fopen( FIXUSER, ">>$vardir/fixusers.txt" ) || setup_fatal_error( "$maintext_23 $vardir/fixusers.txt: ", 1 ); print {FIXUSER} "$user|$fixeduser|$settings[14]|$settings[1]|$settings[2]\n" or croak 'cannot print FIXUSER'; fclose(FIXUSER); if ( $fixeduser ne $username ) { undef %{ $uid . $fixeduser }; } return; } sub MyUpdateUser { my ($user) = @_; fopen( LOADOLDUSER, "$convmemberdir/$user.dat" ) || setup_fatal_error( "$maintext_23 $convmemberdir/$user.dat: ", 1 ); my @settings = ; fclose(LOADOLDUSER); chomp @settings; my ( $pmignorelist, $pmnotify, $pmpopup, $pmspop ); if ( -e "$convmemberdir/$user.imconfig" ) { fopen( PMUSER, "$convmemberdir/$user.imconfig" ) || setup_fatal_error( "$maintext_23 $convmemberdir/$user.imconfig: ", 1 ); @pmconfics = ; fclose(PMUSER); chomp $pmconfics[0]; chomp $pmconfics[1]; chomp $pmconfics[3]; chomp $pmconfics[5]; $pmignorelist = $pmconfics[0]; $pmnotify = $pmconfics[1] ? 3 : 0; $pmpopup = $pmconfics[3]; $pmspop = $pmconfics[5]; } my ( $lastonline, $lastpost, $lastim ); if ( -e "$convmemberdir/$user.ll" ) { fopen( LLFILE, "$convmemberdir/$user.ll" ) || setup_fatal_error( "$maintext_23 $convmemberdir/$user.ll: ", 1 ); ( $lastonline, $lastpost, $lastim ) = ; fclose(LLFILE); chomp $lastonline; chomp $lastpost; chomp $lastim; $lastonline =~ s/(\d{1,2}\/\d{1,2}\/\d{2,4}).*?(\d{1,2}\:\d{1,2}\:\d{1,2})/&conv_stringtotime("$1 at $2")/eism; $lastpost =~ s/(\d{1,2}\/\d{1,2}\/\d{2,4}).*?(\d{1,2}\:\d{1,2}\:\d{1,2})/&conv_stringtotime("$1 at $2")/eism; $lastim =~ s/(\d{1,2}\/\d{1,2}\/\d{2,4}).*?(\d{1,2}\:\d{1,2}\:\d{1,2})/&conv_stringtotime("$1 at $2")/eism; } if ( -e "$convmemberdir/$user.yam" ) { fopen( YAMFILE, "$convmemberdir/$user.yam" ) || setup_fatal_error( "$maintext_23 $convmemberdir/$user.yam: ", 1 ); my @ipsettings = ; fclose(YAMFILE); chomp $ipsettings[1]; ( $c_ip_one, $c_ip_two, $c_ip_three ) = split /\|/xsm, $ipsettings[1]; if ( $c_ip_one eq '0' ) { $c_ip_one = q{}; } if ( $c_ip_two eq '0' ) { $c_ip_two = q{}; } if ( $c_ip_three eq '0' ) { $c_ip_three = q{}; } } $settings[14] = format_timestring( $settings[14] ); $regitime = "$settings[14]"; $regitime =~ s/(\d{2}\/\d{2}\/\d{2,4}).*?(\d{2}\:\d{2}\:\d{2})/&conv_stringtotime("$1 at $2")/eism; if ($default_template) { $new_template = $default_template; } else { $new_template = q~Forum default~; } if ( $settings[1] eq q{} ) { $settings[1] = $user; } if ( $settings[5] ) { $settings[5] =~ s/&&/&&/gxsm; $settings[5] =~ s/\"/"/gxsm; #"; $settings[5] =~ s/\[size=([+-]?\d)\](.*?)\[\/size\]/ '\[size=' . conv_size($1) . "\]$2\[\/size\]" /igesm; $settings[5] =~ s/
/
/igxsm; } my @location = split /,|\|/xsm, $settings[15]; shift @location; %{ $uid . $user } = ( 'password' => "$settings[0]", 'realname' => "$settings[1]", 'email' => "$settings[2]", 'webtitle' => "$settings[3]", 'weburl' => ( ( $settings[4] && $settings[4] !~ m{\Ahttps?://}sm ) ? 'http://' : q{} ) . $settings[4], 'signature' => "$settings[5]", 'postcount' => "$settings[6]", 'position' => "$settings[7]", 'icq' => "$settings[8]", 'aim' => "$settings[9]", 'yim' => "$settings[10]", 'gender' => "$settings[11]", 'usertext' => "$settings[12]", 'userpic' => "$settings[13]", 'regdate' => "$settings[14]", 'regtime' => "$regitime", 'location' => join( ', ', grep { $_ } @location ), 'bday' => "$settings[16]", 'timeselect' => "$settings[17]", 'timeoffset' => "$timeoffset", 'hidemail' => ( $settings[19] ? 1 : 0 ), 'gtalk' => "$settings[32]", 'template' => "$new_template", 'language' => "$language", 'lastonline' => "$lastonline", 'lastpost' => "$lastpost", 'lastim' => "$lastim", 'im_ignorelist' => "$pmignorelist", 'notify_me' => "$pmnotify", 'im_popup' => ( $pmpopup ? 1 : 0 ), 'im_imspop' => ( $pmspop ? 1 : 0 ), 'cathide' => "$settings[30]", 'postlayout' => "$settings[31]|0", 'dsttimeoffset' => "$dstoffset", 'pageindex' => '1|1|1', 'lastips' => "$c_ip_one|$c_ip_two|$c_ip_three", ); UserAccount( $user, 'update' ); if ( $user ne $username ) { undef %{ $uid . $user }; } return; } sub groupconvert { require "$convvardir/MemberStats.txt"; my $i = 0; my $z = 1; undef %Post; $Post{'-1'} = qq~$MemStatNewbie|$MemStarNumNewbie|$MemStarPicNewbie|$MemTypeColNewbie|0|0|0|0|0|0~; while ( $MemStat[$i] ) { if ( $MemPostNum[$i] eq 'x' ) { $NoPost{$z} = qq~$MemStat[$i]|$MemStarNum[$i]|$MemStarPic[$i]|$MemTypeCol[$i]|0|0|0|0|0|0~; $z++; } else { $Post{ $MemPostNum[$i] } = qq~$MemStat[$i]|$MemStarNum[$i]|$MemStarPic[$i]|$MemTypeCol[$i]|0|0|0|0|0|0~; } $i++; } foreach my $key ( keys %Group ) { $value = $Group{$key}; $value =~ s/'/'/gxsm; #'; $Group{$key} = $value; } foreach my $key ( keys %NoPost ) { $value = $NoPost{$key}; $value =~ s/'/'/gxsm; #'; $NoPost{$key} = $value; } foreach my $key ( keys %Post ) { $value = $Post{$key}; $value =~ s/'/'/gxsm; #'; $Post{$key} = $value; } require Admin::NewSettings; SaveSettingsTo('Settings.pm'); # save %Group, %NoPost and %Post return; } sub ConvertMembers2 { fopen( MEMDIR, "$convmemberdir/memberlist.txt" ) || setup_fatal_error( "$maintext_23 $convmemberdir/memberlist.txt: ", 1 ); my @memlist = ; fclose(MEMDIR); for my $i ( ( $INFO{'mstart2'} || 0 ) .. ( @memlist - 1 ) ) { my $user = $memlist[$i]; chomp $user; next if !-e "$convmemberdir/$user.dat"; my $newuser = exists $fixed_users{$user} ? ${ $fixed_users{$user} }[0] : $user; my @xtn = qw(msg ims imstore log outbox); for my $cnt ( 0 .. ( @xtn - 1 ) ) { if ( -e "$convmemberdir/$user.$xtn[$cnt]" ) { fopen( FILEUSER, "$convmemberdir/$user.$xtn[$cnt]" ) || setup_fatal_error( "$maintext_23 $convmemberdir/$user.$xtn[$cnt]: ", 1 ); my @divfiles = ; fclose(FILEUSER); if ( $cnt == 0 || $cnt == 2 || $cnt == 4 ) { # msg || imstore || outbox chomp @divfiles; for my $i ( 0 .. ( @divfiles - 1 ) ) { if ( $cnt == 2 ) { # imstore my ( $name, $subject, $date, $message, $id, $ip, $read_flag, $folder ) = split /\|/xsm, $divfiles[$i]; $name = exists $fixed_users{$name} ? ${ $fixed_users{$name} }[0] : $name; $date =~ s/(\d{1,2}\/\d{1,2}\/\d{2,4}).*?(\d{1,2}\:\d{1,2}\:\d{1,2})/&conv_stringtotime("$1 at $2")/eism; $message =~ s/
/
/igsm; if ( $folder eq 'outbox' ) { $folder = 'out'; if ( !$read_flag ) { $read_flag = 'u'; } elsif ( $read_flag == 1 ) { $read_flag = 'r'; } $divfiles[$i] = "$id|$newuser|$name|||$subject|$date|$message|$id|0|$ip|s|$read_flag|$folder|\n"; } elsif ( $folder eq 'inbox' ) { $folder = 'in'; if ( $read_flag == 1 ) { $read_flag = 'u'; } elsif ( $read_flag == 2 ) { $read_flag = 'r'; } $divfiles[$i] = "$id|$name|$newuser|||$subject|$date|$message|$id|0|$ip|s|$read_flag|$folder|\n"; } } else { # msg || outbox my ( $name, $subject, $date, $message, $id, $ip, $read_flag ) = split /\|/xsm, $divfiles[$i]; $name = exists $fixed_users{$name} ? ${ $fixed_users{$name} }[0] : $name; $date =~ s/(\d{1,2}\/\d{1,2}\/\d{2,4}).*?(\d{1,2}\:\d{1,2}\:\d{1,2})/&conv_stringtotime("$1 at $2")/eism; $message =~ s/
/
/igsm; if ( $id < 101 || $id eq q{} ) { $id = $date; } if ( $cnt == 0 ) { # msg if ( $read_flag == 1 ) { $read_flag = 'u'; } # u(nread) elsif ( $read_flag == 2 ) { $read_flag = 'r'; } # r(eplied) $divfiles[$i] = "$id|$name|$newuser|||$subject|$date|$message|$id|0|$ip|s|$read_flag||\n"; } else { # outbox if ( !$read_flag ) { $read_flag = 'u'; } # u(rgent) elsif ( $read_flag == 1 ) { $read_flag = 's'; } # s(tandard) $divfiles[$i] = "$id|$newuser|$name|||$subject|$date|$message|$id|0|$ip|s|$read_flag||\n"; } } } } fopen( FILEUSER, ">$memberdir/$newuser.$xtn[$cnt]" ) || setup_fatal_error( "$maintext_23 $memberdir/$newuser.$xtn[$cnt]: ", 1 ); print {FILEUSER} @divfiles or croak 'cannot print FILEUSER'; fclose(FILEUSER); } } if ( time() > $time_to_jump && ( $i + 1 ) < @memlist ) { $yySetLocation = qq~$set_cgi?action=members2;st=~ . int( $INFO{'st'} + time() - $time_to_jump + $max_process_time ) . qq~;starttime=$time_to_jump;mtotal=~ . @memlist . qq~;mstart1=$INFO{'mstart1'};mstart2=~ . ( $i + 1 ); redirectexit(); } } return; } # / Member Conversion ## # Board + Category Conversion ## sub GetCats { fopen( VDIR, "$convvardir/cat.txt" ) || setup_fatal_error( "$maintext_23 $convvardir/cat.txt: ", 1 ); @categoryorder = ; fclose(VDIR); chomp @categoryorder; my @allboards; foreach my $fcat (@categoryorder) { fopen( VCAT, "$convboardsdir/$fcat.cat" ) || setup_fatal_error( "$maintext_23 $convboardsdir/$fcat.cat: ", 1 ); @catdata = ; fclose(VCAT); chomp @catdata; $catinfo{$fcat} = qq~$catdata[0]|$catdata[1]|1~; @catboards = (); for my $cnt ( 2 .. ( @catdata - 1 ) ) { if ( $catdata[$cnt] ) { push @catboards, $catdata[$cnt]; } } push @allboards, @catboards; $cat{$fcat} = join q{,}, @catboards; } foreach my $fboard (@allboards) { fopen( VBRD, "$convboardsdir/$fboard.dat" ) || setup_fatal_error( "$maintext_23 $convboardsdir/$fboard.dat: ", 1 ); @bdata = ; fclose(VBRD); chomp $bdata[0]; # get board access data if ( -e "$convboardsdir/$fboard.mbo" ) { require "$convboardsdir/$fboard.mbo"; } $board{$fboard} = qq~$bdata[0]|$view_groups{$fboard}|$showprivboards{$fboard}~; } # add trash if not exists if ( !exists $cat{'staff'} ) { push @categoryorder, 'staff'; $cat{'staff'} = 'announcements,recycle'; $catinfo{'staff'} = 'Forum Staff|Administrator, Global Moderator|0'; } else { my @temp; foreach ( split /,/xsm, $cat{'staff'} ) { if ( $_ ne 'recycle' && $_ ne 'announcements' ) { push @temp, $_; } } push @temp, 'recycle'; push @temp, 'announcements'; $cat{'staff'} = join q{,}, @temp; } if ( !exists $cat{'general'} ) { push @categoryorder, 'general'; $cat{'general'} = 'general'; $catinfo{'general'} = 'General Category||0|'; } else { my @temp; foreach ( split /,/xsm, $cat{'general'} ) { if ( $_ ne 'general' ) { push @temp, $_; } } push @temp, 'general'; $cat{'general'} = join q{,}, @temp; } if ( !exists $board{'recycle'} ) { $board{'recycle'} = 'Recycle Bin||'; } if ( !exists $board{'announcements'} ) { $board{'announcements'} = 'Global Announcements||'; } if ( !exists $board{'general'} ) { $board{'general'} = 'General Board||1'; } @temparray = (); while ( ( $key, $value ) = each %cat ) { # Strip membergroups with a ~ from them $value =~ s/~//gsm; push @temparray, qq~\$cat{$key} = qq\~$value\~;\n~; } while ( ( $key, $value ) = each %catinfo ) { # Strip membergroups with a ~ from them $value =~ s/~//gxsm; $value =~ s/,/, /gsm; push @temparray, qq~\$catinfo{$key} = qq\~$value\~;\n~; } while ( ( $key, $value ) = each %board ) { # Strip membergroups with a ~ from them $value =~ s/~//gxsm; $value =~ s/,/, /gsm; push @temparray, qq~\$board{'$key'} = qq\~$value\~;\n~; } fopen( FILE, ">$boardsdir/forum.master" ) || setup_fatal_error( "$maintext_23 $boardsdir/forum.master: ", 1 ); print {FILE} qq~\$mloaded = 1;\n~, qq~\@categoryorder = qw(@categoryorder);\n~, @temparray, "\n1;" or croak 'cannot print FILE'; fclose(FILE); return; } sub CreateControl { require "$boardsdir/forum.master"; foreach my $foundboard ( keys %board ) { # get category fopen( CINFO, "$convboardsdir/$foundboard.ctb" ); @category = ; fclose(CINFO); chomp $category[0]; $cntcat = $category[0]; # get boardinfo fopen( BINFO, "$convboardsdir/$foundboard.dat" ); @boardinfo = ; fclose(BINFO); chomp @boardinfo; $boardinfo[2] =~ s/^\||\|$//gxsm; $boardinfo[2] =~ s/\|(\S?)/,$1/gxsm; $cntmods = join q{,}, grep { exists $fixed_users{$_} ? ${ $fixed_users{$_} }[0] : $_; } split /,/xsm, $boardinfo[2]; $cntpic = q{}; $cntdescription = $boardinfo[1]; # get board access data if ( -e "$convboardsdir/$foundboard.mbo" ) { require "$convboardsdir/$foundboard.mbo"; } $cntstartperms = "$start_groups{$foundboard}"; $cntreplyperms = "$reply_groups{$foundboard}"; $cntpollperms = q{}; $cntstartperms =~ s/,/, /gsm; $cntreplyperms =~ s/,/, /gsm; $cntpollperms =~ s/,/, /gsm; $cntpic = "$boardpic{$foundboard}"; $cntzero = q{}; $cntpassword = q{}; $cnttotals = q{}; $cntattperms = q{}; $spare = q{}; if ( $cntcat && $foundboard ) { push @boardcontrol, "$cntcat|$foundboard|$cntpic|$cntdescription|$cntmods|$cntmodgroups|$cntstartperms|$cntreplyperms|$cntpollperms|$cntzero|$cntpassword|$cnttotals|$cntattperms|$spare|||\n"; } elsif ( !$cntcat && $foundboard eq 'general' ) { # add general board if not exist push @boardcontrol, qq{general|general||This is the board for General Discussions.
The board description can now hold multiple lines and can use HTML!|admin|||||0||||1|||\n}; if ( !-e "$convboardsdir/general.txt" ) { fopen( BOARDFILE, ">$convboardsdir/general.txt" ) || setup_fatal_error( "$maintext_23 $convboardsdir/general.txt: ", 1 ); print {BOARDFILE} qq{1278201900|Welcome to your new YaBB 2.5.4 forum!|Administrator|webmaster\@yoursite.com|1278201900|0|admin|xx|0\n} or croak 'cannot print BOARDFILE'; fclose(BOARDFILE); } } elsif ( !$cntcat && $foundboard eq 'recycle' ) { # add trash if not exists push @boardcontrol, qq{staff|recycle||If the Recycle Bin is turned on, removed topics will be moved to this board. This will allow you to recover them if it is necessary. You should purge messages in this board frequently to keep it clean.|admin|||||1|||1||||\n}; if ( !-e "$convboardsdir/recycle.txt" ) { fopen( BOARDFILE, ">$convboardsdir/recycle.txt" ) || setup_fatal_error( "$maintext_23 $convboardsdir/recycle.txt: ", 1 ); print {BOARDFILE} q{} or croak 'cannot print BOARDFILE'; fclose(BOARDFILE); } } elsif ( !$cntcat && $foundboard eq 'announcements' ) { push @boardcontrol, qq{staff|announcements||Topics you place in this board will display as a "Global Announcement" on the top of all other boards. Use this for things such as forum rules, top news articles, or important statements.|admin||Administrator|||0||1|||||\n}; if ( !-e "$convboardsdir/announcements.txt" ) { fopen( BOARDFILE, ">$convboardsdir/announcements.txt" ) || setup_fatal_error( "$maintext_23 $convboardsdir/announcements.txt: ", 1 ); print {BOARDFILE} q{} or croak 'cannot print BOARDFILE'; fclose(BOARDFILE); } } } fopen( CONTROL, ">$boardsdir/forum.control" ) || setup_fatal_error( "$maintext_23 $boardsdir/forum.control: ", 1 ); @boardcontrol = sort @boardcontrol; print {CONTROL} @boardcontrol or croak 'cannot print CONTROL'; fclose(CONTROL); return; } sub ConvertBoards { require "$boardsdir/forum.master"; my %stickies; if ( open $DATADIR, '<', "$convboardsdir/sticky.stk" ) { my @stickies = <$DATADIR>; close $DATADIR or croak 'cannot close stickies file'; chomp @stickies; foreach (@stickies) { $stickies{$_} = 1; } } @boards = sort keys %board; for my $i ( ( $INFO{'bstart'} || 0 ) .. ( @boards - 1 ) ) { fopen( BOARDFILE, "$convboardsdir/$boards[$i].txt" ) || setup_fatal_error( "$maintext_23 $convboardsdir/$boards[$i].txt: ", 1 ); @boardfile = ; fclose(BOARDFILE); @temparray = (); for my $j ( ( $INFO{'bfstart'} || 0 ) .. ( @boardfile - 1 ) ) { my $line = $boardfile[$j]; chomp $line; my ( $mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate ) = split /\|/xsm, $line; next if (!-e "$convdatadir/$mnum.txt" || -s "$convdatadir/$mnum.txt" < 35 ); $mname = exists $fixed_users{$mname} ? ${ $fixed_users{$mname} }[1] : $mname; $musername = exists $fixed_users{$musername} ? ${ $fixed_users{$musername} }[0] : $musername; $mdate =~ s/(\d{1,2}\/\d{1,2}\/\d{2,4}).*?(\d{1,2}\:\d{1,2}\:\d{1,2})/&conv_stringtotime("$1 at $2")/eism; $mstate =~ s/1/l/xsm; if ( exists $stickies{$mnum} ) { $mstate .= 's'; } push @temparray, "$mnum|$msub|$mname|$memail|$mdate|$mreplies|$musername|$micon|$mstate\n"; if ( time() > $time_to_jump && ( $j + 1 ) < @boardfile ) { fopen( BOARDFILE, ">>$boardsdir/$boards[$i].txt" ) || setup_fatal_error( "$maintext_23 $boardsdir/$boards[$i].txt: ", 1 ); print {BOARDFILE} @temparray or croak 'cannot print BOARDFILE'; fclose(BOARDFILE); $yySetLocation = qq~$set_cgi?action=cats2;st=~ . int( $INFO{'st'} + time() - ( $time_to_jump - $max_process_time ) ) . qq~;starttime=$time_to_jump;bfstart=~ . ( $j + 1 ) . qq~;bstart=$i;btotal=~ . @boards; redirectexit(); } } fopen( BOARDFILE, ">>$boardsdir/$boards[$i].txt" ) || setup_fatal_error( "$maintext_23 $boardsdir/$boards[$i].txt: ", 1 ); print {BOARDFILE} @temparray or croak 'cannot print BOARDFILE'; fclose(BOARDFILE); if ( time() > $time_to_jump && ( $i + 1 ) < @boards ) { $yySetLocation = qq~$set_cgi?action=cats2;st=~ . int( $INFO{'st'} + time() - $time_to_jump + $max_process_time ) . qq~;starttime=$time_to_jump;mtotal=~ . @memlist . q~;bfstart=0;bstart=~ . ( $i + 1 ); redirectexit(); } $INFO{'bfstart'} = 0; } return; } # / Board + Category Conversion ## # Message Conversion ## sub ConvertMessages { require "$boardsdir/forum.master"; ${ $uid . $username }{'timeformat'} = 'SDT, DD MM YYYY HH:mm:ss zzz'; # the .ctb time format ${ $uid . $username }{'timeselect'} = 7; my $ctbtime = timeformat( $date, 1, 'rfc' ); my %stickies; if ( open $DATADIR, '<', "$convboardsdir/sticky.stk" ) { my @stickies = <$DATADIR>; close $DATADIR or croak 'cannot close sticky.stk'; chomp @stickies; foreach (@stickies) { $stickies{$_} = 1; } } my @boards = sort keys %board; my $totalbdr = @boards; for my $next_board ( ( $INFO{'count'} || 0 ) .. ( $totalbdr - 1 ) ) { my $boardname = $boards[$next_board]; fopen( BRDFILE, "$boardsdir/$boardname.txt" ) || setup_fatal_error( "$maintext_23 $boardsdir/$boardname.txt: ", 1 ); my @brdmessageline = ; fclose(BRDFILE); my %newreply = (); my $totalmess = @brdmessageline; for my $tops ( ( $INFO{'tcount'} || 0 ) .. ( $totalmess - 1 ) ) { ( $thread, undef, undef, undef, undef, $replies, undef ) = split /\|/xsm, $brdmessageline[$tops], 7; fopen( MSGFILE, "$convdatadir/$thread.txt" ) || setup_fatal_error( "$maintext_23 $convdatadir/$thread.txt: ", 1 ); @messagelines = ; fclose(MSGFILE); chomp @messagelines; $INFO{'total_mess'} += @messagelines; $INFO{'total_threads'}++; @temparray = (); foreach my $msgline (@messagelines) { my ( $subject, $name, $email, $mdate, $musername, $icon, $dummy, $user_ip, $message, $ns, $editdate, $editby, undef, $attachment ) = split /\|/xsm, $msgline; $name = exists $fixed_users{$name} ? ${ $fixed_users{$name} }[1] : $name; $musername = exists $fixed_users{$musername} ? ${ $fixed_users{$musername} }[0] : $musername; $editby = exists $fixed_users{$editby} ? ${ $fixed_users{$editby} }[0] : $editby; if ( $message =~ /\[[qgs]/ixsm ) { # too many RegExpr take too much time!!! $message =~ s/\[quote(\s+author=(.*?)\s+link=(.*?)\s+date=(.*?)\s*)?\](.*?)\[\/quote\]/QuoteFix($2,$3,$4,$5)/eigsm; $message =~ s/\[(glow|shadow)=.*?\](.*?)\[\/(glow|shadow)\]/\[glb\]$2\[\/glb\]/igsm; $message =~ s/\[size=([+-]?\d)\](.*?)\[\/size\]/ '\[size=' . conv_size($1) . "\]$2\[\/size\]" /igesm; } $message =~ s/
/
/igsm; $mdate =~ s/(\d{1,2}\/\d{1,2}\/\d{2,4}).*?(\d{1,2}\:\d{1,2}\:\d{1,2}).*/&conv_stringtotime("$1 at $2")/eism; $editdate =~ s/(\d{1,2}\/\d{1,2}\/\d{2,4}).*?(\d{1,2}\:\d{1,2}\:\d{1,2}).*/&conv_stringtotime("$1 at $2")/eism; push @temparray, "$subject|$name|$email|$mdate|$musername|$icon|$dummy|$user_ip|$message|$ns|$editdate|$editby|$attachment\n"; if ( $musername ne 'Guest' ) { ${ $uid . $thread }{$musername}++; ${ $uid . $thread . 'time' }{$musername} = $mdate; } } fopen( MSGFILE, ">$datadir/$thread.txt" ) || setup_fatal_error( "$maintext_23 $datadir/$thread.txt: ", 1 ); print {MSGFILE} @temparray or croak "cannot print $datadir/$thread.txt"; fclose(MSGFILE); # do the .ctb my $views = 1; if ( -e "$convdatadir/$thread.data" ) { fopen( DATA, "$convdatadir/$thread.data" ) || setup_fatal_error( "$maintext_23 $convdatadir/$thread.data: ", 1 ); $data = ; fclose(DATA); chomp $data; ( $views, undef ) = split /\|/xsm, $data, 2; } my $trstate = exists $stickies{$thread} ? 's' : q{}; $lastposter = $musername eq 'Guest' ? "Guest-$name" : $musername; fopen( CTB, ">$datadir/$thread.ctb" ) || setup_fatal_error( "$maintext_23 $datadir/$thread.ctb: ", 1 ); print {CTB} qq~### ThreadID: $thread, LastModified: $ctbtime ###\n\n'board',"$boardname"\n'replies',"$#messagelines"\n'views',"$views"\n'lastposter',"$lastposter"\n'lastpostdate',"$mdate"\n'threadstatus',"$trstate"\n'repliers',""\n~ or croak "cannot print $datadir/$thread.ctb"; fclose(CTB); if ( $replies != $#messagelines ) { $newreply{$tops} = $#messagelines; } if ( time() > $time_to_jump && ( $tops + 1 ) < $totalmess ) { writerecentlog( ( $INFO{'tcount'} || 0 ), $totalmess, \@brdmessageline ); if (%newreply) { # fix reply display foreach ( keys %newreply ) { my @temp = split /\|/xsm, $brdmessageline[$_]; $temp[5] = $newreply{$_}; $brdmessageline[$_] = join q{|}, @temp; } fopen( BOARDFILE, ">$boardsdir/$boardname.txt" ) || setup_fatal_error( "$maintext_23 $boardsdir/$boardname.txt: ", 1 ); print {BOARDFILE} @brdmessageline or croak "cannot print $boardsdir/$boardname.txt"; fclose(BOARDFILE); } $yySetLocation = qq~$set_cgi?action=messages2;st=~ . int( $INFO{'st'} + time() - ( $time_to_jump - $max_process_time ) ) . qq~;starttime=$time_to_jump;count=$next_board;tcount=~ . ( $tops + 1 ) . qq~;total_mess=$INFO{'total_mess'};total_threads=$INFO{'total_threads'};totboard=$totalbdr;totmess=$totalmess~; redirectexit(); } } writerecentlog( ( $INFO{'tcount'} || 0 ), $totalmess, \@brdmessageline ); if (%newreply) { # fix reply display foreach ( keys %newreply ) { my @temp = split /\|/xsm, $brdmessageline[$_]; $temp[5] = $newreply{$_}; $brdmessageline[$_] = join q{|}, @temp; } fopen( BOARDFILE, ">$boardsdir/$boardname.txt" ) || setup_fatal_error( "$maintext_23 $boardsdir/$boardname.txt: ", 1 ); print {BOARDFILE} @brdmessageline or croak "cannot print $boardsdir/$boardname.txt"; fclose(BOARDFILE); } if ( time() > $time_to_jump && ( $next_board + 1 ) < $totalbdr ) { $yySetLocation = qq~$set_cgi?action=messages2;st=~ . int( $INFO{'st'} + time() - ( $time_to_jump - $max_process_time ) ) . qq~;starttime=$time_to_jump;count=~ . ( $next_board + 1 ) . qq~;tcount=0;total_mess=$INFO{'total_mess'};total_threads=$INFO{'total_threads'};totboard=$totalbdr;totmess=0~; redirectexit(); } $INFO{'tcount'} = 0; } return; } sub QuoteFix { my ( $qauthor, $qlink, $qdate, $qmessage ) = @_; if ( $qauthor eq q{} || $qlink eq q{} || $qdate eq q{} ) { $quote = "\[quote\]$qmessage\[/quote\]"; } else { $qdate = conv_stringtotime($qdate); ( undef, $threadlink, $start ) = split /;/xsm, $qlink; ( undef, $num ) = split /=/xsm, $threadlink; ( undef, $start ) = split /=/xsm, $start; $quote = "\[quote author=$qauthor link=$num/$start date=$qdate\]$qmessage\[/quote\]"; } return $quote; } sub conv_size { my $size = shift; if ( $size eq '1' || $size eq '-2' ) { $size = 10; } elsif ( $size eq '2' || $size eq '-1' ) { $size = 13; } elsif ( $size eq '3' ) { $size = 16; } elsif ( $size eq '4' || $size eq '+1' ) { $size = 18; } elsif ( $size eq '5' || $size eq '+2' ) { $size = 24; } elsif ( $size eq '6' || $size eq '+3' ) { $size = 32; } elsif ( $size eq '7' || $size eq '+4' ) { $size = 48; } return $size; } sub writerecentlog { my ( $start, $total, $messageref ) = @_; for my $t ( $start .. ( $total - 1 ) ) { ( $thread, undef ) = split /\|/xsm, ${$messageref}[$t], 2; foreach my $user ( keys %{ $uid . $thread } ) { fopen( RLOG, ">>$memberdir/$user.rlog" ) || setup_fatal_error( "$maintext_23 $memberdir/$user.rlog: ", 1 ); print {RLOG} "$thread\t${$uid.$thread}{$user},${$uid.$thread.'time'}{$user}\n" or croak "cannot print $memberdir/$user.rlog"; fclose(RLOG); } undef %{ $uid . $thread }; undef %{ $uid . $thread . 'time' }; } return; } # / Message Conversion ## # Date Conversion ## sub ConvertTimeToString { if ( $INFO{'timeconv'} < 1 ) { opendir( DATADIR, $convdatadir ) || setup_fatal_error( "Directory: $convdatadir: ", 1 ); my @polls = sort grep { /\.poll$/xsm } readdir DATADIR; closedir DATADIR; my $totalpolls = @polls; for my $i ( ( $INFO{'pollfile'} || 0 ) .. ( $totalpolls - 1 ) ) { $file = $polls[$i]; fopen( POLLFILE, "$convdatadir/$file" ) || setup_fatal_error( "$maintext_23 $convdatadir/$file: ", 1 ); @pollsfile = ; fclose(POLLFILE); chomp $pollsfile[0]; my ( $dummy1, $dummy2, $polluname, $dummy4, $dummy5, $pdate, $dummy6, $dummy7, $dummy8, $epdate, $dummy10, $dummy11 ) = split /\|/xsm, shift @pollsfile; $polluname = exists $fixed_users{$polluname} ? ${ $fixed_users{$polluname} }[0] : $polluname; $pdate =~ s/(\d{1,2}\/\d{1,2}\/\d{2,4}).*?(\d{1,2}\:\d{1,2}\:\d{1,2})/&conv_stringtotime("$1 at $2")/eism; $epdate =~ s/(\d{1,2}\/\d{1,2}\/\d{2,4}).*?(\d{1,2}\:\d{1,2}\:\d{1,2}).*/&conv_stringtotime("$1 at $2")/eism; fopen( POLLFILE, ">$datadir/$file" ) || setup_fatal_error( "$maintext_23 $datadir/$file: ", 1 ); print {POLLFILE} "$dummy1|$dummy2|$polluname|$dummy4|$dummy5|$pdate|$dummy6|$dummy7|$dummy8|$epdate|$dummy10|$dummy11\n", @pollsfile or croak "cannot print $datadir/$file"; fclose(POLLFILE); if ( time() > $time_to_jump && ( $i + 1 ) < $totalpolls ) { $yySetLocation = qq~$set_cgi?action=dates2;st=~ . int( $INFO{'st'} + time() - $time_to_jump + $max_process_time ) . qq~;starttime=$time_to_jump;timeconv=0;totalpolls=$totalpolls;pollfile=~ . ( $i + 1 ); redirectexit(); } } $INFO{'totalpolls'} = $totalpolls; } if ( $INFO{'timeconv'} < 2 ) { opendir( DATADIR, $convdatadir ) || setup_fatal_error( "Directory: $convdatadir: ", 1 ); my @polled = sort grep { /\.polled$/xsm } readdir DATADIR; closedir DATADIR; my $totalpolled = @polled; for my $i ( ( $INFO{'polledfile'} || 0 ) .. ( $totalpolled - 1 ) ) { $file = $polled[$i]; fopen( POLLEDFILE, "$convdatadir/$file" ) || setup_fatal_error( "$maintext_23 $convdatadir/$file: ", 1 ); @polledfile = ; fclose(POLLEDFILE); chomp @polledfile; @temparray = (); foreach my $line (@polledfile) { my ( $dummy1, $pollername, $dummy3, $pdate ) = split /\|/xsm, $line; $pollername = exists $fixed_users{$pollername} ? ${ $fixed_users{$pollername} }[0] : $pollername; $pdate =~ s/(\d{1,2}\/\d{1,2}\/\d{2,4}).*?(\d{1,2}\:\d{1,2}\:\d{1,2})/&conv_stringtotime("$1 at $2")/eism; push @temparray, "$dummy1|$pollername|$dummy3|$pdate\n"; } fopen( POLLEDFILE, ">$datadir/$file" ) || setup_fatal_error( "$maintext_23 $datadir/$file: ", 1 ); print {POLLEDFILE} @temparray or croak "cannot print $datadir/$file"; fclose(POLLEDFILE); if ( time() > $time_to_jump && ( $i + 1 ) < $totalpolled ) { $yySetLocation = qq~$set_cgi?action=dates2;st=~ . int( $INFO{'st'} + time() - $time_to_jump + $max_process_time ) . qq~;starttime=$time_to_jump;timeconv=1;totalpolls=$INFO{'totalpolls'};totalpolled=$totalpolled;polledfile=~ . ( $i + 1 ); redirectexit(); } } } return; } # / Date Conversion ## # Cleanup ## sub MyReCountTotals { @boards = sort keys %board; my $totalboards = @boards; for my $j ( ( $INFO{'my_re_tot'} || 0 ) .. ( $totalboards - 1 ) ) { my $cntboard = $boards[$j]; next if !$cntboard; fopen( BOARD, "$boardsdir/$cntboard.txt" ) || setup_fatal_error( "$maintext_23 $boardsdir/$cntboard.txt: ", 1 ); my @threads = ; fclose(BOARD); my $threadcount = @threads; my $messagecount = $threadcount; if ($threadcount) { for my $i ( 0 .. ( @threads - 1 ) ) { $messagecount += ( split /\|/xsm, $threads[$i] )[5]; } } BoardTotals( 'load', $cntboard ); ${ $uid . $cntboard }{'threadcount'} = $threadcount; ${ $uid . $cntboard }{'messagecount'} = $messagecount; # &BoardTotals("update", ...) is done in &BoardSetLastInfo BoardSetLastInfo( $cntboard, \@threads ); if ( time() > $time_to_jump && ( $j + 1 ) < $totalboards ) { $yySetLocation = qq~$set_cgi?action=cleanup2;st=~ . int( $INFO{'st'} + time() - $time_to_jump + $max_process_time ) . qq~;starttime=$time_to_jump;clean=1;total_boards=$INFO{'total_boards'};total_re_tot=$totalboards;my_re_tot=~ . ( $j + 1 ); redirectexit(); } } $INFO{'total_re_tot'} = $totalboards; $INFO{'clean'} = 2; return; } sub MyMemberIndex { if ( $INFO{'memb_index'} > 0 ) { ManageMemberlist('load'); ManageMemberinfo('load'); $siglength = $INFO{'siglength'}; } else { $INFO{'tmp_firstforum'} = $INFO{'firstforum'} = conv_stringtotime($forumstart); $siglength = 200; } opendir( MEMBERS, $memberdir ) || setup_fatal_error( "Directory: $memberdir: ", 1 ); @members = sort grep { /.\.vars$/xsm } readdir MEMBERS; closedir MEMBERS; $totalmemb = @members; for my $j ( ( $INFO{'memb_index'} || 0 ) .. ( $totalmemb - 1 ) ) { $member = $members[$j]; $member =~ s/\.vars$//gxsm; LoadUser($member); Recent_Load($member); ${ $uid . $member }{'postcount'} = 0; foreach ( keys %recent ) { ${ $uid . $member }{'postcount'} += ${ $recent{$_} }[0]; } if ( $INFO{'firstforum'} > ${ $uid . $member }{'regtime'} ) { $INFO{'firstforum'} = ${ $uid . $member }{'regtime'}; } if ( length( ${ $uid . $member }{'signature'} ) > $siglength ) { $siglength = length( ${ $uid . $member }{'signature'} ); } if ( ${ $uid . $member }{'position'} ) { foreach my $key ( keys %NoPost ) { ( $NoPostname, undef ) = split /\|/xsm, $NoPost{$key}, 2; if ( ${ $uid . $member }{'position'} eq $NoPostname ) { ${ $uid . $member }{'position'} = $key; last; } } } if ( !${ $uid . $member }{'position'} ) { ${ $uid . $member }{'position'} = MyMemberPostGroup( ${ $uid . $member }{'postcount'} ); } if ( ${ $uid . $member }{'addgroups'} ) { my $newaddigrp = q{}; foreach my $addigrp ( split /, ?/sm, ${ $uid . $member }{'addgroups'} ) { foreach my $key ( keys %NoPost ) { ( $NoPostname, undef ) = split /\|/xsm, $NoPost{$key}, 2; if ( $addigrp eq $NoPostname ) { $addigrp = $key; last; } } $newaddigrp .= qq~$addigrp,~; } $newaddigrp =~ s/,$//xsm; ${ $uid . $member }{'addgroups'} = $newaddigrp; } UserAccount( $member, 'update' ); $memberlist{$member} = sprintf '%010d', ${ $uid . $member }{'regtime'}; $memberinf{$member} = qq~${$uid.$member}{'realname'}|${$uid.$member}{'email'}|${$uid.$member}{'position'}|${$uid.$member}{'postcount'}~; if ( time() > $time_to_jump && ( $j + 1 ) < $totalmemb ) { ManageMemberlist('save'); ManageMemberinfo('save'); $yySetLocation = qq~$set_cgi?action=cleanup2;st=~ . int( $INFO{'st'} + time() - $time_to_jump + $max_process_time ) . qq~;starttime=$time_to_jump;clean=2;total_boards=$INFO{'total_boards'};total_re_tot=$INFO{'total_re_tot'};tmp_firstforum=$INFO{'tmp_firstforum'};firstforum=$INFO{'firstforum'};siglength=$siglength;total_memb=$totalmemb;memb_index=~ . ( $j + 1 ); redirectexit(); } } ManageMemberlist('save'); ManageMemberinfo('save'); $INFO{'total_memb'} = $totalmemb; $INFO{'clean'} = 3; fopen( MEMBERLISTREAD, "$memberdir/memberlist.txt" ) || setup_fatal_error( "$maintext_23 $memberdir/memberlist.txt: ", 1 ); my @num = ; fclose(MEMBERLISTREAD); my $membertotal = @num; ( $latestmember, undef ) = split /\t/xsm, $num[-1], 2; fopen( MEMTTL, ">$memberdir/members.ttl" ) || setup_fatal_error( "$maintext_23 $memberdir/members.ttl: ", 1 ); print {MEMTTL} qq~$membertotal|$latestmember~ or croak "cannot print $memberdir/members.ttl"; fclose(MEMTTL); if ( $INFO{'tmp_firstforum'} > $INFO{'firstforum'} || $siglength > 200 ) { SetInstall2(); } return; } sub MyMemberPostGroup { my ($userpostcnt) = @_; $grtitle = q{}; foreach my $postamount ( reverse sort { $a <=> $b } keys %Post ) { if ( $userpostcnt >= $postamount ) { ( $grtitle, undef ) = split /\|/xsm, $Post{$postamount}, 2; last; } } return $grtitle; } sub MyMailNotify { require Sources::Notify; ManageMemberinfo('load'); opendir( DIRECTORY, $convdatadir ) || setup_fatal_error( "Directory: $convdatadir: ", 1 ); my @files = sort grep { /\.mail$/xsm } readdir DIRECTORY; closedir DIRECTORY; my $totalfiles = @files; for my $j ( ( $INFO{'my_mail_n'} || 0 ) .. ( $totalfiles - 1 ) ) { my $filename = ( split /\./xsm, $files[$j], 2 )[0]; fopen( MAILFILE, "$convdatadir/$filename.mail" ) || setup_fatal_error( "$maintext_23 $convdatadir/$filename.mail: ", 1 ); my @mailaddresses = ; fclose(MAILFILE); chomp @mailaddresses; foreach my $mailaddress (@mailaddresses) { while ( ( $curuser, $value ) = each %memberinf ) { if ( $mailaddress eq ( split /\|/xsm, $value, 3 )[1] ) { ManageThreadNotify( 'add', $filename, $curuser, $language, 1, 1 ); if ( $curuser ne $username ) { undef %{ $uid . $curuser }; } last; } } } if ( time() > $time_to_jump && ( $j + 1 ) < $totalfiles ) { $yySetLocation = qq~$set_cgi?action=cleanup2;st=~ . int( $INFO{'st'} + time() - $time_to_jump + $max_process_time ) . qq~;starttime=$time_to_jump;clean=3;total_boards=$INFO{'total_boards'};total_re_tot=$INFO{'total_re_tot'};total_memb=$INFO{'total_memb'};tmp_firstforum=$INFO{'tmp_firstforum'};firstforum=$INFO{'firstforum'};total_mail_n=$totalfiles;my_mail_n=~ . ( $j + 1 ); redirectexit(); } } $INFO{'total_mail_n'} = $totalfiles; $INFO{'clean'} = 4; return; } sub FixNopost { if ( $NoPost{'1'} ) { fopen( FORUMCONTROL, "$boardsdir/forum.control" ) || setup_fatal_error( "$maintext_23 $boardsdir/forum.control: ", 1 ); @boardcontrols = ; fclose(FORUMCONTROL); chomp @boardcontrols; my $totalnoposts = keys %NoPost; for my $i ( ( $INFO{'fix_nopost'} || 1 ) .. ( $totalnoposts - 1 ) ) { ( $grptitle, undef ) = split /\|/xsm, $NoPost{$i}, 2; foreach my $key ( keys %catinfo ) { ( $catname, $catperms, $catcol ) = split /\|/xsm, $catinfo{$key}, 3; $newperm = q{}; foreach my $theperm ( split /, /sm, $catperms ) { if ( $theperm eq $grptitle ) { $theperm = $i; } $newperm .= qq~$theperm, ~; } $newperm =~ s/, $//sm; $catinfo{$key} = qq~$catname|$newperm|$catcol~; } foreach my $key ( keys %board ) { ( $boardname, $boardperms, $boardshow ) = split /\|/xsm, $board{$key}, 3; $newperm = q{}; foreach my $theperm ( split /, /sm, $boardperms ) { if ( $theperm eq $grptitle ) { $theperm = $i; } $newperm .= qq~$theperm, ~; } $newperm =~ s/, $//sm; $board{$key} = qq~$boardname|$newperm|$boardshow~; } for my $j ( 0 .. ( @boardcontrols - 1 ) ) { ( $cntcat, $cntboard, $cntpic, $cntdescription, $cntmods, $cntmodgroups, $cnttopicperms, $cntreplyperms, $cntpollperms, $cntzero, $cntmembergroups, $cntann, $cntrbin, $cntattperms, $cntminageperms, $cntmaxageperms, $cntgenderperms ) = split /\|/xsm, $boardcontrols[$j]; $newmodgroups = q{}; foreach my $theperm ( split /, /sm, $cntmodgroups ) { if ( $theperm eq $grptitle ) { $theperm = $i; } $newmodgroups .= qq~$theperm, ~; } $newmodgroups =~ s/, $//sm; $newtopicperms = q{}; foreach my $theperm ( split /, /sm, $cnttopicperms ) { if ( $theperm eq $grptitle ) { $theperm = $i; } $newtopicperms .= qq~$theperm, ~; } $newtopicperms =~ s/, $//sm; $newreplyperms = q{}; foreach my $theperm ( split /, /sm, $cntreplyperms ) { if ( $theperm eq $grptitle ) { $theperm = $i; } $newreplyperms .= qq~$theperm, ~; } $newreplyperms =~ s/, $//sm; $newpollperms = q{}; foreach my $theperm ( split /, /sm, $cntpollperms ) { if ( $theperm eq $grptitle ) { $theperm = $i; } $newpollperms .= qq~$theperm, ~; } $newpollperms =~ s/, $//sm; $boardcontrols[$j] = qq~$cntcat|$cntboard|$cntpic|$cntdescription|$cntmods|$newmodgroups|$newtopicperms|$newreplyperms|$newpollperms|$cntzero|$cntmembergroups|$cntann|$cntrbin|$cntattperms|$cntminageperms|$cntmaxageperms|$cntgenderperms\n~; } if ( time() > $time_to_jump && ( $i + 1 ) < $totalnoposts ) { Write_ForumMaster(); fopen( FORUMCONTROL, ">$boardsdir/forum.control" ) || setup_fatal_error( "$maintext_23 $boardsdir/forum.control: ", 1 ); print {FORUMCONTROL} @boardcontrols or croak 'cannot print FORUMCONTROL'; fclose(FORUMCONTROL); $yySetLocation = qq~$set_cgi?action=cleanup2;st=~ . int( $INFO{'st'} + time() - $time_to_jump + $max_process_time ) . qq~;starttime=$time_to_jump;clean=4;total_boards=$INFO{'total_boards'};total_re_tot=$INFO{'total_re_tot'};total_memb=$INFO{'total_memb'};tmp_firstforum=$INFO{'tmp_firstforum'};firstforum=$INFO{'firstforum'};total_mail_n=$INFO{'total_mail_n'};total_nopost=$totalnoposts;fix_nopost=~ . ( $i + 1 ); redirectexit(); } } Write_ForumMaster(); fopen( FORUMCONTROL, ">$boardsdir/forum.control" ) || setup_fatal_error( "$maintext_23 $boardsdir/forum.control: ", 1 ); print {FORUMCONTROL} @boardcontrols or croak 'cannot print FORUMCONTROL'; fclose(FORUMCONTROL); } return; } # / Cleanup ## sub format_timestring { my ($time_string) = @_; if ( $time_string !~ m/(\d{1,2})\/(\d{1,2})\/(\d{2,4}).*?(\d{1,2})\:(\d{1,2})\:(\d{1,2})/ism ) { $time_string = "$forumstart"; } if ( $time_string =~ m/(\d{1,2})\/(\d{1,2})\/(\d{2,4}).*?(\d{1,2})\:(\d{1,2})\:(\d{1,2})/ism ) { $dr_month = $1; $dr_day = $2; $dr_year = $3; $dr_hour = $4; $dr_minute = $5; $dr_secund = $6; } if ( $dr_month > 12 ) { $dr_month = 12; } if ( $dr_month < 1 ) { $dr_month = 1; } if ( $dr_day > 31 ) { $dr_day = 31; } if ( $dr_day < 1 ) { $dr_day = 1; } if ( length($dr_year) > 2 ) { $dr_year = substr $dr_year, length($dr_year) - 2, 2; } if ( $dr_year < 90 && $dr_year > 20 ) { $dr_year = 90; } if ( $dr_year > 20 && $dr_year < 90 ) { $dr_year = 20; } if ( $dr_hour > 23 ) { $dr_hour = 23; } if ( $dr_minute > 59 ) { $dr_minute = 59; } if ( $dr_secund > 59 ) { $dr_secund = 59; } if ( $dr_month == 4 || $dr_month == 6 || $dr_month == 9 || $dr_month == 11 ) { $max_days = 30; } elsif ( $dr_month == 2 && $dr_year % 4 == 0 ) { $max_days = 29; } elsif ( $dr_month == 2 && $dr_year % 4 != 0 ) { $max_days = 28; } else { $max_days = 31; } if ( $dr_day > $max_days ) { $dr_day = $max_days; } $dr_month = sprintf '%02d', $dr_month; $dr_day = sprintf '%02d', $dr_day; $dr_year = sprintf '%02d', $dr_year; $dr_hour = sprintf '%02d', $dr_hour; $dr_minute = sprintf '%02d', $dr_minute; $dr_secund = sprintf '%02d', $dr_secund; return qq~$dr_month/$dr_day/$dr_year $maintxt{'107'} $dr_hour:$dr_minute:$dr_secund~; } sub conv_stringtotime { my ($splitvar) = @_; if ( !$splitvar ) { return 0; } if ( $splitvar =~ m/(\d{1,2})\/(\d{1,2})\/(\d{2,4}).*?(\d{1,2})\:(\d{1,2})\:(\d{1,2})/ism ) { $amonth = int($1) || 1; $aday = int($2) || 1; $ayear = int($3) || 0; $ahour = int($4) || 0; $amin = int($5) || 0; $asec = int($6) || 0; } if ( $ayear >= 36 && $ayear <= 99 ) { $ayear += 1900; } elsif ( $ayear >= 00 && $ayear <= 35 ) { $ayear += 2000; } if ( $ayear < 1904 ) { $ayear = 1904; } elsif ( $ayear > 2036 ) { $ayear = 2036; } if ( $amonth < 1 ) { $amonth = 0; } elsif ( $amonth > 12 ) { $amonth = 11; } else { --$amonth; } if ( $amonth == 3 || $amonth == 5 || $amonth == 8 || $amonth == 10 ) { $max_days = 30; } elsif ( $amonth == 1 && $ayear % 4 == 0 ) { $max_days = 29; } elsif ( $amonth == 1 && $ayear % 4 != 0 ) { $max_days = 28; } else { $max_days = 31; } if ( $aday > $max_days ) { $aday = $max_days; } if ( $ahour < 1 ) { $ahour = 0; } elsif ( $ahour > 23 ) { $ahour = 23; } if ( $amin < 1 ) { $amin = 0; } elsif ( $amin > 59 ) { $amin = 59; } if ( $asec < 1 ) { $asec = 0; } elsif ( $asec > 59 ) { $asec = 59; } return timelocal( $asec, $amin, $ahour, $aday, $amonth, $ayear ); } #End Conversion# sub tempstarter { return if !-e "$vardir/Settings.pm"; $YaBBversion = 'YaBB 2.5.4'; # Make sure the module path is present push @INC, './Modules'; if ( $ENV{'SERVER_SOFTWARE'} =~ /IIS/sm ) { $yyIIS = 1; if ( $PROGRAM_NAME =~ m{(.*)(\\|/)}xsm ) { $yypath = $1; } $yypath =~ s/\\/\//gxsm; chdir $yypath; push @INC, $yypath; } # Requirements and Errors require Variables::Settings; if ( -e "$vardir/convSettings.txt" ) { require "$vardir/convSettings.txt"; } else { $convertdir = './Convert'; } LoadCookie(); # Load the user's cookie (or set to guest) LoadUserSettings(); WhatTemplate(); WhatLanguage(); require Sources::Security; WriteLog(); return; } sub CreateConvLock { fopen( LOCKFILE, ">$vardir/Converter.lock" ) || setup_fatal_error( "$maintext_23 $vardir/Converter.lock: ", 1 ); print {LOCKFILE} qq~This is a lockfile for the Converter.\n~ or croak 'cannot print to LOCKFILE'; print {LOCKFILE} qq~It prevents it being run again after it has been run once.\n~ or croak 'cannot print to LOCKFILE'; print {LOCKFILE} q~Delete this file if you want to run the Converter again.~ or croak 'cannot print to LOCKFILE'; fclose(LOCKFILE); unlink "$vardir/convSettings.txt"; return; } sub SetupImgLoc { if ( !-e "$htmldir/Templates/Forum/$useimages/$_[0]" ) { $thisimgloc = qq~img src="$yyhtml_root/Templates/Forum/default/$_[0]"~; } else { $thisimgloc = qq~img src="$imagesdir/$_[0]"~; } return $thisimgloc; } sub tabmenushow { # used by the converter $tabsep = qq~~; $tabfill = qq~~; $NavLink1 = qq~$tabfill Members $tabfill~; $NavLink2 = qq~$tabsep$tabfill Boards & Categories $tabfill~; $NavLink3 = qq~$tabsep$tabfill Messages $tabfill~; $NavLink4 = qq~$tabsep$tabfill Date & Time $tabfill~; $NavLink5 = qq~$tabsep$tabfill Clean Up $tabfill~; $NavLink5 = qq~$tabsep$tabfill Extended Profiles $tabfill~; $NavLink6 = qq~$tabsep$tabfill Login $tabfill$tabsep ~; $NavLink1a = qq~$tabfill Members $tabfill~; $NavLink2a = qq~$tabsep$tabfill Boards & Categories $tabfill~; $NavLink3a = qq~$tabsep$tabfill Messages $tabfill~; $NavLink4a = qq~$tabsep$tabfill Date & Time $tabfill~; $NavLink5a = qq~$tabsep$tabfill Clean Up $tabfill~; $NavLink6a = qq~$tabsep$tabfill Login $tabfill$tabsep ~; $NavLink7a = qq~$tabsep$tabfill Extended Profiles $tabfill~; $ConvDone = q~
 
100 %

~; $ConvNotDone = q~
 
0 %

~; return; } sub FoundConvLock { tempstarter(); tabmenushow(); $yytabmenu = $NavLink1 . $NavLink2 . $NavLink3 . $NavLink4 . $NavLink5 . $NavLink6; $formsession = cloak("$mbname$username"); $yymain = qq~
YaBB 2.5.4 Converter
Converter has already been run, attempting to run them again will cause damage to your files.

To run Converter again, remove the file "$vardir/Converter.lock," then re-visit this page.
~; $yyim = 'YaBB 2.5.4 Converter has already been run.'; $yytitle = 'YaBB 2.5.4 Converter'; SetupTemplate(); return; } sub setup_fatal_error { my ( $e, $v ) = @_; $e .= "\n"; if ($v) { $e .= $! . "\n"; } $yymenu = q~Boards & Categories | ~; $yymenu .= q~Members | ~; $yymenu .= q~Messages | ~; $yymenu .= q~Date & Time | ~; $yymenu .= q~Clean Up | ~; $yymenu .= q~Login~; $yymain .= qq~
An Error Has Occurred!

$e

Back

~; $yyim = 'YaBB 2.5.4 Convertor Error.'; $yytitle = 'YaBB 2.5.4 Convertor Error.'; if ( !-e "$vardir/Settings.pm" ) { SimpleOutput(); } tempstarter(); SetupTemplate(); return; } sub SimpleOutput { $gzcomp = 0; print_output_header(); print qq~ YaBB 2.5.4 Setup
 
$yymain
~ or croak 'cannot print output screen'; exit; } sub SetupTemplate { $gzcomp = fileno $GZIP ? 1 : 0; print_output_header(); $yyposition = $yytitle; $yytitle = "$mbname - $yytitle"; $yyimages = $imagesdir; $yydefaultimages = $defaultimagesdir; $yystyle = qq~\n\n ~; $yystyle =~ s/$usestyle\///gxsm; $yytemplate = "$templatesdir/$usehead/$usehead.html"; fopen( TEMPLATE, "$yytemplate" ) || setup_fatal_error( "$maintext_23 $yytemplate: ", 1 ); @yytemplate =