[r1451]: branches / 2.6 / cgi-bin / yabb2 / Convert2x.pl Maximize Restore History

Download this file

Convert2x.pl    1355 lines (1211 with data), 51.8 kB

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
#!/usr/bin/perl --
# $Id: YaBB 2x Conversion Utility $
# $HeadURL: YaBB $
# $Source: /Convert2x.pl $
###############################################################################
# Convert2x.pl #
# $Date: 02.20.14 $ #
###############################################################################
# YaBB: Yet another Bulletin Board #
# Open-Source Community Software for Webmasters #
# Version: YaBB 2.6.0 #
# Packaged: February 20, 2014 #
# Distributed by: http://www.yabbforum.com #
# =========================================================================== #
# Copyright (c) 2000-2014 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.6.0';
$convert2xplver = 'YaBB 2.6.0 $Revision: 1451 $';
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/\/Convert2x\.(pl|cgi)//igxsm;
if ( -e './Paths.pm' ) { require Paths; }
elsif ( -e './Variables/Paths.pm' ) { require './Variables/Paths.pm'; }
$boardsdir = './Boards';
$sourcedir = './Sources';
$memberdir = './Members';
$vardir = './Variables';
$thisscript = "$ENV{'SCRIPT_NAME'}";
if ( -e ('YaBB.cgi') ) { $yyext = 'cgi'; }
else { $yyext = 'pl'; }
if ($boardurl) { $set_cgi = "$boardurl/Convert2x.$yyext"; }
else { $set_cgi = "Convert2x.$yyext"; }
$scripturl = "$boardurl/YaBB.$yyext";
# Make sure the module path is present
push @INC, './Modules';
require Sources::Subs;
require Sources::System;
require Sources::Load;
require Sources::DateTime;
require Admin::Admin;
#############################################
# Conversion starts here #
#############################################
$px = 'px';
if ( -e "$vardir/Setup.lock" ) {
if ( -e "$vardir/Convert2x.lock" ) { FoundConvert2xLock(); }
tempstarter();
tabmenushow();
if ( !$action ) {
$yytabmenu =
$NavLink1 . $NavLink2 . $NavLink3 . $NavLink5 . $NavLink6;
$yymain = qq~
<div class="bordercolor borderbox">
<form action="$set_cgi?action=prepare" method="post">
<table class="cs_thin pad_4px">
<col style="width:5%" />
<tr>
<td class="tabtitle" colspan="2">YaBB 2.6.0 Converter</td>
</tr><tr>
<td class="windowbg center">
<img src="$imagesdir/thread.gif" alt="" />
</td>
<td class="windowbg2 fontbigger">
Make sure your YaBB 2.6.0 installation is running and that it has all the correct folder paths and URLs.<br />
Proceed through the following steps to convert your YaBB 2x forum to YaBB 2.6.0.<br /><br />
<b>If</b> your YaBB 2x forum is located on the same server as your YaBB 2.6.0 installation:
<ol>
<li>Insert the path to your YaBB 2x forum in the input field below</li>
<li>Click on the 'Continue' button</li>
</ol>
<b>Else</b> if your YaBB 2x forum is located on a different server than your YaBB 2.6.0 installation or if you do not know the path to your YaBB 2x forum:
<ol>
<li>Copy all files in the /Boards, /Members, /Messages, and /Variables folders from your YaBB 2x installation, to the corresponding Convert/Boards, Convert/Members, Convert/Messages, and Convert/Variables folders of your YaBB 2.6.0 installation, and chmod them 755.</li>
<li>Click on the 'Continue' button</li>
</ol>
<div style="width: 100%; text-align: center;">
<b>Path to your YaBB 2x files: </b> <input type="text" name="convertdir" value="$convertdir" size="50" />
</div>
<br />
</td>
</tr><tr>
<td class="catbg center" colspan="2">
<input type="submit" value="Continue" />
</td>
</tr>
</table>
</form>
</div>
~;
}
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 ( !-d "$convertdir/Variables" ) {
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
. $NavLink5
. $NavLink6;
$yymain = qq~
<div class="bordercolor borderbox">
<table class="cs_thin pad_4px">
<col style="width:5%" />
<tr>
<td class="tabtitle" colspan="2">YaBB 2.6.0. Converter</td>
</tr><tr>
<td class="windowbg center">
<img src="$imagesdir/thread.gif" alt="" />
</td>
<td class="windowbg2 fontbigger">
<ul>
<li>Members info found in: <b>$convmemberdir</b></li>
<li>Board and Category info found in: <b>$convboardsdir</b></li>
<li>Messages info found in: <b>$convdatadir</b></li>
</ul>
</td>
</tr><tr>
<td class="windowbg center">
<img src="$imagesdir/info.png" alt="" />
</td>
<td class="windowbg2 fontbigger">
- Conversion can take a long time depending on the size of your forum (30 seconds to a couple hours).<br />
- Your browser will be refreshed automatically every $max_process_time seconds and you will see the ongoing process in the status bar.<br />
- Some internet connections refresh their IP-Address automatically every 24 hours.<br />
&nbsp; Make sure that your IP-Address will not change during conversion, or you must restart the conversion after that! <br />
- Your forum will be set to maintenance while converting.
<p id="memcontinued">Click on 'Members' in the menu to start.<br />&nbsp;</p>
</td>
</tr>
</table>
</div>
<script type="text/javascript">
function PleaseWait() {
document.getElementById("memcontinued").innerHTML = '<span style="color:red"><b>Converting - please wait!<br />If you want to stop \\'Members\\' conversion, click here on STOP before this red message appears again on next page.</b></span>';
}
</script>
~;
}
elsif ( $action eq 'members' ) {
require qq~$vardir/ConvSettings.txt~;
PrepareConv();
MyUpdateUser($convmemberdir, $memberdir);
$yytabmenu =
$NavLink1
. $NavLink2a
. $NavLink3
. $NavLink5
. $NavLink6;
$yymain = qq~
<div class="bordercolor borderbox">
<table class="cs_thin pad_4px">
<col style="width:5%" />
<tr>
<td class="tabtitle" colspan="2">YaBB 2.6.0 Converter</td>
</tr><tr>
<td class="windowbg center">
<img src="$imagesdir/thread.gif" alt="" />
</td>
<td class="windowbg2">
<div class="convdone">Member Import.</div>
$ConvDone
<div class="convnotdone">Board and Category Import.</div>
$ConvNotDone
<div class="convnotdone">Message Import.</div>
$ConvNotDone
<div class="convnotdone">Clean Up</div>
$ConvNotDone
</td>
</tr><tr>
<td class="windowbg center">
<img src="$imagesdir/info.png" alt="" />
</td>
<td class="windowbg2 fontbigger">
User data files have been imported.<br />
<br />
You are importing <i>~
. int( ( $INFO{'st'} + 60 ) / 60 ) . qq~ minutes</i>.
<br />
<br />
<p id="memcontinued">Click on 'Boards &amp; Categories' in the menu to continue.<br />
If you do not do that the script will continue itself in 5 minutes.</p>
</td>
</tr>
</table>
</div>
<script type="text/javascript">
function PleaseWait() {
document.getElementById("memcontinued").innerHTML = '<span style="color:red"><b>Converting - please wait!<br />If you want to stop \\'Boards & Categories\\' conversion, click here on STOP before this red message appears again on next page.</b></span>';
}
function membtick() {
PleaseWait();
location.href="$set_cgi?action=cats;st=$INFO{'st'}";
}
setTimeout("membtick()",300000);
</script>
~;
}
elsif ( $action eq 'cats' ) {
require qq~$vardir/ConvSettings.txt~;
MoveBoards($convboardsdir);
$yytabmenu =
$NavLink1
. $NavLink2
. $NavLink3a
. $NavLink5
. $NavLink6;
$yymain = qq~
<div class="bordercolor borderbox">
<table class="cs_thin pad_4px">
<col style="width:5%" />
<tr>
<td class="tabtitle" colspan="2">YaBB 2.6.0 Converter</td>
</tr><tr>
<td class="windowbg center">
<img src="$imagesdir/thread.gif" alt="" />
</td>
<td class="windowbg2">
<div class="convdone">Member Import.</div>
$ConvDone
<div class="convdone">Board &amp; Category Import.</div>
$ConvDone
<div class="convnotdone">Message Import.</div>
$ConvNotDone
<div class="convnotdone">Clean Up.</div>
$ConvNotDone
</td>
</tr><tr>
<td class="windowbg center">
<img src="$imagesdir/info.png" alt="" />
</td>
<td class="windowbg2 fontbigger">
All Boards threads imported.<br />
<br />
You are converting <i>~
. int( ( $INFO{'st'} + 60 ) / 60 ) . qq~ minutes</i>.<br />
<br />
<p id="memcontinued">Click on 'Messages' in the menu to continue.<br />
If you do not do that the script will continue by itself in 5 minutes.</p>
</td>
</tr>
</table>
</div>
<script type="text/javascript">
function PleaseWait() {
document.getElementById("memcontinued").innerHTML = '<span style="color:red"><b>Converting - please wait!<br />If you want to stop \\'Messages\\' conversion, click here on STOP before this red message appears again on next page.</b></span>';
}
function membtick() {
PleaseWait();
location.href="$set_cgi?action=messages;st=$INFO{'st'}";
}
setTimeout("membtick()",300000);
</script>
~;
}
elsif ( $action eq 'messages' ) {
require qq~$vardir/ConvSettings.txt~;
MoveMessages($convdatadir);
$yytabmenu =
$NavLink1
. $NavLink2
. $NavLink3
. $NavLink5a
. $NavLink6;
$yymain = qq~
<div class="bordercolor borderbox">
<table class="cs_thin pad_4px">
<col style="width:5%" />
<tr>
<td class="titlebg" colspan="2">YaBB 2.6.0 Converter</td>
</tr><tr>
<td class="windowbg center">
<img src="$imagesdir/thread.gif" alt="" />
</td>
<td class="windowbg2">
<div class="convdone">Member Import.</div>
$ConvDone
<div class="convdone">Board and Category Import.</div>
$ConvDone
<div class="convdone">Message Import.</div>
$ConvDone
<div class="convnotdone">Clean Up.</div>
$ConvNotDone
</td>
</tr><tr>
<td class="windowbg center">
<img src="$imagesdir/info.png" alt="" />
</td>
<td class="windowbg2 fontbigger">
<i>$INFO{'total_threads'}</i> Threads have been converted.<br />
<i>$INFO{'total_mess'}</i> Messages have been converted.<br />
<br />
You are converting <i>~
. int( ( $INFO{'st'} + 60 ) / 60 ) . qq~ minutes</i>.<br />
<br />
<p id="memcontinued">Click on 'Clean Up' in the menu to continue.<br />
If you do not do that the script will continue by itself in 5 minutes.</p>
</td>
</tr>
</table>
</div>
<script type="text/javascript">
function PleaseWait() {
document.getElementById("memcontinued").innerHTML = '<span style="color:red"><b>Converting - please wait!<br />If you want to stop \\'Clean Up\\', click here on STOP before this red message appears again on next page.</b></span>';
}
function membtick() {
PleaseWait();
location.href="$set_cgi?action=cleanup;st=$INFO{'st'}";
}
setTimeout("membtick()",300000);
</script>
~;
}
elsif ( $action eq 'cleanup' ) {
require qq~$vardir/ConvSettings.txt~;
MoveVariables($convvardir);
FixControl();
FixNopost();
$yytabmenu =
$NavLink1
. $NavLink2
. $NavLink3
. $NavLink5
. $NavLink6a;
$formsession = cloak("$mbname$username");
$convtext .=
q~<br /><br />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.~;
$yymain = qq~
<div class="bordercolor borderbox">
<table class="cs_thin pad_4px">
<tr>
<td class="tabtitle" colspan="2">YaBB 2.6.0 Converter</td>
</tr><tr>
<td class="windowbg center">
<img src="$imagesdir/thread.gif" alt="" />
</td>
<td class="windowbg2">
<div class="convdone">Member Import.</div>
$ConvDone
<div class="convdone">Board and Category Import.</div>
$ConvDone
<div class="convdone">Message Import.</div>
$ConvDone
<div class="convdone">Clean Up.</div>
$ConvDone
</td>
</tr><tr>
<td class="windowbg center">
<img src="$imagesdir/info.png" alt="" />
</td>
<td class="windowbg2 fontbigger">
$forumstarttext
$convtext<br />
<br />
The conversion took <i>~
. int( ( $INFO{'st'} + 60 ) / 60 ) . qq~ minutes</i>.<br />
<br />
<br />
<span style="color:red">We recommend you delete the file "$ENV{'SCRIPT_NAME'}". This is to prevent someone else running the converter and damaging your files.<br />
<br />
Further more, we strongly recommend to run the following "Maintenance Controls" in the "Admin Center" before you start doing other things:<br />
- Rebuild Message Index<br />
- Recount Board Totals<br />
- Rebuild Members List<br />
- Recount Membership<br />
- Rebuild Members History<br />
- Rebuild Notifications Files<br />
- Clean Users Online Log<br />
- Attachment Functions => Rebuild Attachments<br /></span>
<br />
<br />
You may now login to your forum. Enjoy using YaBB 2.6.0!
</td>
</tr><tr>
<td class="catbg center" colspan="2">
<form action="YaBB.$yyext" method="post" style="display: inline;">
<input type="submit" value="Start" />
<input type="hidden" name="formsession" value="$formsession" />
</form>
</td>
</tr>
</table>
</div>~;
CreateFixLock();
}
$yyim = 'You are running the YaBB 2.6.0 Converter.';
$yytitle = 'YaBB 2.6.0 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 MyUpdateUser {
my ( $convmemberdir, $memberdir ) = @_;
fopen( MEMDIR, "$convmemberdir/memberlist.txt" )
|| setup_fatal_error( "$maintext_23 $convmemberdir/memberlist.txt:", 1 );
my @memlist = <MEMDIR>;
fclose(MEMDIR);
fopen( MEMDIRLST, "> $memberdir/memberlist.txt" )
|| setup_fatal_error( "$maintext_23 $memberdir/memberlist.txt:", 1 );
print {MEMDIRLST} @memlist or croak 'cannot print MEMDIR';
fclose(MEMDIRLST);
for my $i ( @memlist ) {
( $user, undef ) = split /\t/xsm, $i;
my $newuser = $user;
my @xtn = qw(vars msg ims imstore log outbox rlog imdraft);
for my $cnt ( @xtn ) {
if ( -e "$convmemberdir/$user.$cnt" ) {
fopen( FILEUSER, "$convmemberdir/$user.$cnt" )
|| setup_fatal_error(
"$maintext_23 $convmemberdir/$user.$cnt: ", 1 );
my @divfiles = <FILEUSER>;
fclose(FILEUSER);
fopen( FILEUSER, ">$memberdir/$newuser.$cnt" )
|| setup_fatal_error(
"$maintext_23 $memberdir/$newuser.$cnt: ", 1 );
print {FILEUSER} @divfiles or croak 'cannot print FILEUSER';
fclose(FILEUSER);
}
}
}
fopen( MEMINFO, "$convmemberdir/memberinfo.txt" )
|| setup_fatal_error( "$maintext_23 $convmemberdir/memberinfo.txt: ", 1 );
my @meminfo = <MEMINFO>;
fclose(MEMINFO);
fopen( NMEMINFO, ">$memberdir/memberinfo.txt" )
|| setup_fatal_error( "$maintext_23 $memberdir/memberinfo.txt: ", 1 );
print {NMEMINFO} @meminfo or croak 'cannot print NBMEMINFO';
fclose(NMEMINFO);
if ( -e "$convmemberdir/broadcast.messages" ) {
fopen( BMEMDIR, "$convmemberdir/broadcast.messages" )
|| setup_fatal_error( "$maintext_23 $convmemberdir/broadcast.messages: ", 1 );
my @bmessages = <BMEMDIR>;
fclose(BMEMDIR);
fopen( NBMEMDIR, ">$memberdir/broadcast.messages" )
|| setup_fatal_error( "$maintext_23 $convmemberdir/broadcast.messages: ", 1 );
print {NBMEMDIR} @bmessages or croak 'cannot print NBMEMDIR';
fclose(NBMEMDIR);
}
return;
}
sub FixControl {
if ( -e qq~$convvardir/boardconv.txt~ ) {
require qq~$convvardir/boardconv.txt~;
fopen( OLDFORUMCONTROL, "$convboardsdir/forum.control" )
|| setup_fatal_error( "$maintext_23 $convboardsdir/forum.control: ", 1 );
@oldboardcontrols = <OLDFORUMCONTROL>;
fclose(OLDFORUMCONTROL);
chomp @oldboardcontrols;
foreach (@oldboardcontrols) {
my ( $old, $oldboard ) = split /[|]/xsm, $_;
push @oldboard, $oldboard;
}
my $j = 0;
my @newboard = ();
foreach my $x (@oldboard) {
#$cat|$board|$pic|$description|$mods|$modgroups|$topicperms|$replyperms|$pollperms|$zero|$membergroups|$ann|$rbin|$attperms|$minageperms|$maxageperms|$genderperms|$canpost|$parent|$rules|$rulestitle|$rulesdesc|$rulescollapse|$brdpasswr|$brdpassw|$bdrss
$newboard[$j] = qq~${$x}{'cat'}|$x|${$x}{'pic'}|${$x}{'description'}|${$x}{'mods'}|${$x}{'modgroups'}|${$x}{'topicperms'}|${$x}{'replyperms'}|${$x}{'pollperms'}|${$x}{'zero'}|${$x}{'membergroups'}|${$x}{'ann'}|${$x}{'rbin'}|${$x}{'attperms'}|${$x}{'minageperms'}|${$x}{'maxageperms'}|${$x}{'genderperms'}|${$x}{'canpost'}|${$x}{'parent'}|${$x}{'rules'}|${$x}{'rulestitle'}|${$x}{'rulesdesc'}|${$x}{'rulescollapse'}|${$x}{'brdpasswr'}|${$x}{'brdpassw'}|${$x}{'brdrss'}\n~;
$j++;
}
fopen( FORUMCONTROL, ">$boardsdir/forum.control" )
|| setup_fatal_error( "$maintext_23 $boardsdir/forum.control: ", 1 );
print {FORUMCONTROL} @newboard
or croak 'cannot print FORUMCONTROL';
fclose(FORUMCONTROL);
}
else {
fopen( OLDFORUMCONTROL, "$convboardsdir/forum.control" )
|| setup_fatal_error( "$maintext_23 $convboardsdir/forum.control: ", 1 );
@oldboardcontrols = <OLDFORUMCONTROL>;
fclose(OLDFORUMCONTROL);
fopen( FORUMCONTROL, ">$boardsdir/forum.control" )
|| setup_fatal_error( "$maintext_23 $boardsdir/forum.control: ", 1 );
print {FORUMCONTROL} @oldboardcontrols
or croak 'cannot print FORUMCONTROL';
fclose(FORUMCONTROL);
}
}
sub FixNopost {
if ( $NoPost{'1'} ) {
fopen( FORUMCONTROL, "$boardsdir/forum.control" )
|| setup_fatal_error( "$maintext_23 $boardsdir/forum.control: ", 1 );
@boardcontrols = <FORUMCONTROL>;
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, $cntbrdrss
) = 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|$brdrss\n~;
}
}
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;
}
sub tempstarter {
return if !-e "$vardir/Settings.pm";
$YaBBversion = 'YaBB 2.6.0';
# 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 CreateFixLock {
fopen( 'LOCKFILE', ">$vardir/Convert2x.lock" )
|| setup_fatal_error( "$maintext_23 $vardir/Convert2x.lock: ", 1 );
print {LOCKFILE} qq~This is a lockfile for the Convert2x Utility.\n~
or croak 'cannot print to Convert2x.lock';
print {LOCKFILE}
qq~It prevents it being run again after it has been run once.\n~
or croak 'cannot print to Convert2x.lock';
print {LOCKFILE}
q~Delete this file if you want to run the Convert2x Utility again.~
or croak 'cannot print to Convert2x.lock';
fclose('LOCKFILE');
return;
}
sub FoundConvert2xLock {
tempstarter();
require Sources::TabMenu;
# $formsession = cloak("$mbname$username");
if ( -e "$vardir/Convert2x.lock" ) {
$fixa = q{};
$fixa2 =
qq~The 2x Conversion Utility has already been run.<br />To run Utility again, remove the file "$vardir/Convert2x.lock," then re-visit this page.~;
}
else {
$fixa =
q~&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<form action="Convert2x.pl" method="post" style="display: inline;">
<input type="submit" value="Fix 2.0-2.4 files" />
</form>~;
}
$yymain = qq~
<div class="bordercolor" style="padding: 0px; width: 100%; margin-left: 0px; margin-right: 0px;">
<table class="cs_thin pad_4px">
<col style="width:5%" />
<tr>
<td class="titlebg" colspan="2">
YaBB 2.6.0 Setup
</td>
</tr><tr>
<td class="windowbg center">
<img src="$imagesdir/info.png" alt="" />
</td>
<td class="windowbg2 center">
$fixa2
</td>
</tr><tr>
<td class="catbg center" colspan="2">
<form action="$boardurl/YaBB.$yyext" method="post" style="display: inline;">
<input type="submit" value="Go to your Forum" />
<input type="hidden" name="formsession" value="$formsession" />
</form>
$fixa
</td>
</tr>
</table>
</div>
~;
$yyim = 'YaBB 2.6.0 Convert2x Utility has already been run.';
$yytitle = 'YaBB 2.6.0 Convert2x Utility';
template();
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 =
q{ &nbsp; };
$tabfill = q{ &nbsp; };
$NavLink1 = qq~<span>$tabfill Members $tabfill</span>~;
$NavLink2 = qq~$tabsep<span>$tabfill Boards & Categories $tabfill</span>~;
$NavLink3 = qq~$tabsep<span>$tabfill Messages $tabfill</span>~;
$NavLink5 = qq~$tabsep<span>$tabfill Clean Up $tabfill</span>~;
$NavLink6 = qq~$tabsep<span>$tabfill Login $tabfill</span>$tabsep&nbsp;~;
$NavLink1a =
qq~<span class="selected"><a href="$set_cgi?action=members;st=$INFO{'st'}" style="color: #FF3333; padding:0" class="selected" onClick="PleaseWait();">$tabfill Members $tabfill</a></span>~;
$NavLink2a =
qq~$tabsep<span class="selected"><a href="$set_cgi?action=cats;st=$INFO{'st'}" style="color: #FF3333; padding:0" class="selected" onClick="PleaseWait();">$tabfill Boards & Categories $tabfill</a></span>~;
$NavLink3a =
qq~$tabsep<span class="selected"><a href="$set_cgi?action=messages;st=$INFO{'st'}" style="color: #FF3333; padding:0" class="selected" onClick="PleaseWait();">$tabfill Messages $tabfill</a></span>~;
$NavLink5a =
qq~$tabsep<span class="selected"><a href="$set_cgi?action=cleanup;st=$INFO{'st'}" style="color: #FF3333; padding:0" class="selected" onClick="PleaseWait();">$tabfill Clean Up $tabfill</a></span>~;
$NavLink6a =
qq~$tabsep<span class="selected"><a href="$boardurl/YaBB.$yyext?action=login" style="color: #FF3333; padding:0" class="selected">$tabfill Login $tabfill</a></span>$tabsep&nbsp;~;
$ConvDone = q~
<div class="divvary_m">&nbsp;</div>
<div class="divvary2">100 %</div><br />
~;
$ConvNotDone = q~
<div class="divouter">&nbsp;</div>
<div class="divvary3">0 %</div><br />
~;
return;
}
sub setup_fatal_error {
my ( $e, $v ) = @_;
$e .= "\n";
if ($v) { $e .= $! . "\n"; }
$yymenu = q~Boards &amp; Categories | ~;
$yymenu .= q~Members | ~;
$yymenu .= q~Messages | ~;
$yymenu .= q~Date &amp; Time | ~;
$yymenu .= q~Clean Up | ~;
$yymenu .= q~Login~;
$yymain .= qq~
<table class="bordercolor cs_thin pad_4px" style="width:80%">
<tr>
<td class="titlebg text1"><b>An Error Has Occurred!</b></td>
</tr><tr>
<td class="windowbg text1"><br />$e<br /><br /></td>
</tr>
</table>
<p class="center"><a href="javascript:history.go(-1)">Back</a></p>
~;
$yyim = 'YaBB 2.6.0 Convertor Error.';
$yytitle = 'YaBB 2.6.0 Convertor Error.';
if ( !-e "$vardir/Settings.pm" ) { SimpleOutput(); }
tempstarter();
SetupTemplate();
return;
}
sub SimpleOutput {
$gzcomp = 0;
print_output_header();
print qq~
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>YaBB 2.6.0 Setup</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<!-- Main Content -->
<div style="height: 40px;">&nbsp;</div>
<div style="text-align:center">$yymain</div>
</body>
</html>
~ 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~<link rel="stylesheet" href="$yyhtml_root/Templates/Forum/$usestyle.css" type="text/css" />\n<link rel="stylesheet" href="$yyhtml_root/Templates/Forum/setup.css" type="text/css" />\n ~;
$yystyle =~ s/$usestyle\///gxsm;
$yytemplate = "$templatesdir/$usehead/$usehead.html";
fopen( TEMPLATE, "$yytemplate" )
|| setup_fatal_error( "$maintext_23 $yytemplate: ", 1 );
@yytemplate = <TEMPLATE>;
fclose(TEMPLATE);
my $output = q{};
$yyboardname = $mbname;
$yytime = timeformat( $date, 1 );
$yyuname =
$iamguest ? q{} : qq~$maintxt{'247'} ${$uid.$username}{'realname'}, ~;
if ($enable_news) {
fopen( NEWS, "$vardir/news.txt" );
@newsmessages = <NEWS>;
fclose(NEWS);
}
for my $i ( 0 .. ( @yytemplate - 1 ) ) {
$curline = $yytemplate[$i];
if (
!$yycopyin
&& ( $curline =~ m{<yabb\ copyright>}xsm
|| $curline =~ /{yabb\ copyright}/xsm )
)
{
$yycopyin = 1;
}
if ( $curline =~ m{<yabb\ newstitle>}xsm && $enable_news ) {
$yynewstitle = qq~<b>$maintxt{'102'}:</b> ~;
}
if ( $curline =~ m{<yabb\ news>}xsm && $enable_news ) {
srand;
if ( $shownewsfader == 1 ) {
$fadedelay = ( $maxsteps * $stepdelay );
$yynews .= qq~
<script type="text/javascript">
var maxsteps = "$maxsteps";
var stepdelay = "$stepdelay";
var fadelinks = $fadelinks;
var delay = "$fadedelay";
var bcolor = "$color{'faderbg'}";
var tcolor = "$color{'fadertext'}";
var fcontent = new Array();
var begintag = "";
~;
fopen( NEWS, "$vardir/news.txt" );
@newsmessages = <NEWS>;
fclose(NEWS);
for my $j ( 0 .. ( @newsmessages - 1 ) ) {
$newsmessages[$j] =~ s/\n|\r//gxsm;
if ( $newsmessages[$j] eq q{} ) { next; }
if ( $i != 0 ) { $yymain .= qq~\n~; }
$message = $newsmessages[$j];
if ($enable_ubbc) {
enable_yabbc();
DoUBBC();
}
$message =~ s/"/\\"/gxsm;
$yynews .= qq~
fcontent[$j] = "$message";\n
~;
}
$yynews .= q~
var closetag = '';
</script>
~;
}
else {
$message = $newsmessages[ int rand @newsmessages ];
if ($enable_ubbc) {
enable_yabbc();
DoUBBC();
}
$yynews = $message;
}
}
$yyurl = $scripturl;
$curline =~ s/{yabb\s+(\w+)}/${"yy$1"}/gxsm;
$curline =~ s/<yabb\s+(\w+)>/${"yy$1"}/gxsm;
$curline =~ s/img src\=\"$imagesdir\/(.+?)\"/SetupImgLoc($1)/eisgm; #";
$output .= $curline;
}
if ( $yycopyin == 0 ) {
$output =
q~<h1 style="text-align:center"><b>Sorry, the copyright tag <yabb copyright> must be in the template.<br />Please notify this forum&#39;s administrator that this site is using an ILLEGAL copy of YaBB!</b></h1>~;
}
if ( fileno $GZIP ) {
$OUTPUT_AUTOFLUSH = 1;
print {$GZIP} $output or croak 'cannot print compressed page';
close $GZIP or croak 'cannot close GZIP';
}
else {
print $output or croak 'cannot print page';
}
exit;
}
sub nicely_aligned_file {
$filler = q{ } x 50;
# Make files look nicely aligned. The comment starts after 50 Col
my $setfile = shift;
$setfile =~ s/=\s+;/= 0;/gsm;
$setfile =~
s/(.+;)[ \t]+(#.+$)/ $1 . substr($filler,(length $1 < 50 ? length $1 : 49)) . $2 /gem;
$setfile =~ s/\t+(#.+$)/$filler$1/gsm;
*cut_comment = sub { # line break of too long comments
my @x = @_;
my ( $comment, $length ) =
( q{}, 120 ); # 120 Col is the max width of page
my $var_length = length $x[0];
while ( $length < $var_length ) { $length += 120; }
foreach ( split / +/sm, $x[1] ) {
if ( ( $var_length + length($comment) + length $_ ) > $length ) {
$comment =~ s/ $//sm;
$comment .= "\n$filler# $_ ";
$length += 120;
}
else { $comment .= "$_ "; }
}
$comment =~ s/ $//sm;
return $comment;
};
$setfile =~ s/(.+)(#.+$)/ $1 . cut_comment($1,$2) /gem;
return $setfile;
}
sub MoveBoards {
my ($convboardsdir) = @_;
opendir( BDIR, $convboardsdir ) or croak "cannot read $convboardsdir gg";
@boardlist = readdir BDIR;
closedir BDIR;
for my $newbrd ( @boardlist ) {
if ( $newbrd ne q{.} && $newbrd ne q{..} ) {
fopen( OLDBRD, "$convboardsdir/$newbrd" );
my @brdinfo = <OLDBRD>;
fclose(OLDBRD);
fopen( NEWBRD, ">$boardsdir/$newbrd" );
print {NEWBRD} @brdinfo or croak 'cannot print NEWBRD hh';
fclose(NEWBRD);
}
}
return;
}
sub MoveMessages {
my ($convdatadir) = @_;
require "$boardsdir/forum.master";
my $ctbtime = timeformat( $date, 1, 'rfc' );
my @boards = sort keys %board;
my $totalbdr = @boards;
for my $boardname ( @boards ) {
fopen( BRDFILE, "$boardsdir/$boardname.txt" )
|| setup_fatal_error( "$maintext_23 $boardsdir/$boardname.txt: ", 1 );
my @brdmessageline = <BRDFILE>;
fclose(BRDFILE);
for my $tops ( @brdmessageline ) {
( $thread, undef, undef, undef, undef, $replies, undef ) =
split /\|/xsm, $tops, 7;
fopen( MSGFILE, "$convdatadir/$thread.txt" )
|| setup_fatal_error( "$maintext_23 $convdatadir/$thread.txt: ",
1 );
@messagelines = <MSGFILE>;
fclose(MSGFILE);
foreach my $msgline (@messagelines) {
my (
$subject, $name, $email, $mdate,
$musername, $icon, $dummy, $user_ip,
$message, $ns, $editdate, $editby,
undef, $attachment
) = split /\|/xsm, $msgline;
}
fopen( MSGFILE, ">$datadir/$thread.txt" )
|| setup_fatal_error( "$maintext_23 $datadir/$thread.txt: ", 1 );
print {MSGFILE} @messagelines
or croak "cannot print $datadir/$thread.txt";
fclose(MSGFILE);
# do the .ctb
fopen( OLDCTB, "$convdatadir/$thread.ctb" )
|| setup_fatal_error( "$maintext_23 $convdatadir/$thread.ctb: ",
1 );
@ctblines = <OLDCTB>;
fclose(OLDCTB);
fopen( NEWCTB, ">$datadir/$thread.ctb" );
print {NEWCTB} @ctblines
or croak "cannot print $datadir/$thread.ctb";
fclose(NEWCTB);
if ( -e "$convdatadir/$thread.mail") {
fopen( OLDMAIL, "$convdatadir/$thread.mail" )
|| setup_fatal_error( "$maintext_23 $convdatadir/$thread.mail: ",
1 );
@oldmail = <OLDMAIL>;
fclose(OLDMAIL);
fopen( NEWMAIL, ">$datadir/$thread.mail" );
print {NEWMAIL} @oldmail
or croak "cannot print $datadir/$thread.mail";
fclose(NEWMAIL);
}
if ( -e "$convdatadir/$thread.poll") {
fopen( OLDPOLL, "$convdatadir/$thread.poll" )
|| setup_fatal_error( "$maintext_23 $convdatadir/$thread.poll: ",
1 );
@oldpoll = <OLDPOLL>;
fclose(OLDPOLL);
fopen( NEWPOLL, ">$datadir/$thread.poll" );
print {NEWPOLL} @oldpoll
or croak "cannot print $datadir/$thread.poll";
fclose(NEWPOLL);
}
if ( -e "$convdatadir/$thread.polled") {
fopen( OLDPOLLED, "$convdatadir/$thread.polled" )
|| setup_fatal_error( "$maintext_23 $convdatadir/$thread.polled: ",
1 );
@oldpolled = <OLDPOLLED>;
fclose(OLDPOLLED);
fopen( NEWPOLLED, ">$datadir/$thread.polled" );
print {NEWPOLLED} @oldpolled
or croak "cannot print $datadir/$thread.polled";
fclose(NEWPOLLED);
}
}
if (-e "$convdatadir/movedthreads.cgi" ) {
fopen( OLDMVFILE, "$convdatadir/movedthreads.cgi" )
|| setup_fatal_error( "$maintext_23 $convdatadir/movedthreads.cgi: ", 1 );
my @movedmessageline = <OLDMVFILE>;
fclose(OLDMVFILE);
fopen( MVFILE, ">$vardir/Movedthreads.pm" );
print {MVFILE} @movedmessageline
or croak "cannot print $vardir/Movedthreads.pm";
fclose(MVFILE);
}
}
return;
}
sub MoveVariables {
my ($convdatadir) = @_;
my @mvvar = ( 'allowed.txt','attachments.txt','ban_log.txt','bots.hosts','email_domain_filter.txt','eventcal.db','eventcalbday.db','flood.txt','gmodsettings.txt','modlist.txt','mostlog.txt','Movedthreads.pm','oldestmes.txt','pm.attachments','registration.log','reserve.txt','reservecfg.txt','spamrules.txt',);
for my $varfl (@mvvar) {
if ( -e "$convdatadir/$varfl" ) {
if ( $varfl eq 'eventcal.db') {
fopen( OLDVAR, "$convdatadir/$varfl" );
my @oldvar = <OLDVAR>;
fclose (OLDVAR);
chomp @oldvar;
my @newvar;
foreach my $eventline ( @oldvar ) {
my @eventline = split /\|/xsm, $eventline;
if ( scalar(@eventline) < 9 ) {
# ( $cal_date,$cal_type,$cal_name,$cal_time,$cal_event,$cal_icon,$cal_noname,$cal_type2)
my $g = q{};
if (lc $eventline[2] eq 'guest' ) {
$g = 'g';
}
push @newvar,
qq~$eventline[0]|$eventline[1]|$eventline[2]|$eventline[3]||$eventline[4]|$eventline[5]|$eventline[6]|$eventline[7]||$g\n~;
}
else { push @newvar, qq~$eventline\n~; }
}
fopen( NEWVAR, ">$vardir/$varfl" );
print {NEWVAR} @newvar
or croak "cannot print $vardir/$varfl";
fclose(NEWVAR);
}
else {
fopen( OLDVAR, "$convdatadir/$varfl" );
my @oldvar = <OLDVAR>;
fclose (OLDVAR);
fopen( NEWVAR, ">$vardir/$varfl" );
print {NEWVAR} @oldvar
or croak "cannot print $vardir/$varfl";
fclose(NEWVAR);
}
}
}
Convert_Settings();
return;
}
sub Convert_Settings {
$ret = 0;
if ( -e "$convvardir/Settings.pl" ) {
use Time::gmtime;
$time = time;
require "$convvardir/Settings.pl";
if ($ip_banlist) {
@i_ban = ( split /,/xsm, $ip_banlist );
chomp @i_ban;
for my $j (@i_ban) {
fopen( BAN, ">>$vardir/banlist.txt" );
print {BAN} qq~I|$j|$time|import|p\n~
or croak 'cannot write to BAN';
fclose(BAN);
}
}
if ($email_banlist) {
@e_ban = ( split /,/xsm, $email_banlist );
chomp @e_ban;
for my $j (@e_ban) {
fopen( BAN, ">>$vardir/banlist.txt" );
print {BAN} qq~E|$j|$time|import|p\n~
or croak 'cannot write to BAN';
fclose(BAN);
}
}
if ($user_banlist) {
@u_ban = ( split /,/xsm, $user_banlist );
chomp @u_ban;
for my $j (@u_ban) {
fopen( BAN, ">>$vardir/banlist.txt" );
print {BAN} qq~U|$j|$time|import|p\n~
or croak 'cannot write to BAN';
fclose(BAN);
}
}
}
if ( -e "$convvardir/eventcalset.txt" ) {
require "$convvardir/eventcalset.txt";
}
$settings_file_version = "YaBB 2.6.0";
if ($enable_notifications eq q{}) { $enable_notifications = $enable_notification ? 3 : 0; }
if ( !$cookietsort ) { ( undef,$rancook ) = split /\-/xsm, $cookieusername;
$cookietsort = qq~Y2tsort-$rancook~;
}
if ( !$cookieview ) { ( undef,$rancook ) = split /\-/xsm, $cookieusername;
$cookieview = qq~Y2view-$rancook~;
}
if ( !$cookieviewtime ) { $cookieviewtime = 525_600; }
if ( !$MaxIMMessLen ) { $MaxIMMessLen = 2000; }
if ( !$AdMaxIMMessLen ) { $AdMaxIMMessLen = 3000; }
if ( !$MaxCalMessLen ){ $MaxCalMessLen = 200; }
if ( !$AdMaxCalMessLen ){ $AdMaxCalMessLen = 300; }
if ( !$Show_EventCal ){ $Show_EventCal = 0; }
if ( !$Event_TodayColor ){ $Event_TodayColor = '#ff0000'; }
if ( !$fix_avatar_img_size) { $fix_avatar_img_size = 0; }
if ( !$max_avatar_width) { $$max_avatar_width = 65; }
if ( !$max_avatar_height) { $max_avatar_height = 65; }
if ( !$fix_avatarml_img_size) { $fix_avatarml_img_size = 0; }
if ( !$max_avatarml_width) { $max_avatarml_width = 65; }
if ( !$max_avatarml_height) { $max_avatarml_height = 65; }
$gzcomp = fileno $GZIP ? 1 : 0;
$ip_banlist = q{};
$email_banlist = q{};
$user_banlist = q{};
$showsearchbox = 1;
$fmodview = $gmodview;
$mdfmod = $mdglobal;
$show_online_ip_admin = 1;
$show_online_ip_gmod = 1;
$show_online_ip_fmod = 1;
$ipLookup = 1;
$bm_subcut = 50;
require Admin::NewSettings;
SaveSettingsTo('Settings.pm');
$ret = 1;
return;
}
1;