Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

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

Download this file

Convert2x.pl    1734 lines (1570 with data), 70.1 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
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
#!/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: 1502 $';
if ( $ENV{'SERVER_SOFTWARE'} =~ /IIS/sm ) {
$yyIIS = 1;
if ( $PROGRAM_NAME =~ m{(.*)(\\|/)}xsm ) {
$yypath = $1;
}
$yypath =~ s/\\/\//gxsm;
chdir $yypath;
push @INC, $yypath;
}
$max_process_time = 20;
$time_to_jump = time() + $max_process_time;
### 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;
$date = time();
#############################################
# 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. <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:#f33"><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~;
if ( !exists $INFO{'mstart1'} ) { PrepareConv(); }
ConvertMembers();
$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 Conversion.</div>
$ConvDone
<div class="convnotdone">Board and Category Conversion.</div>
$ConvNotDone
<div class="convnotdone">Message Conversion.</div>
$ConvNotDone
<div class="convnotdone">Variables &amp; Clean Up</div>
$ConvNotDone
</td>
</tr><tr>
<td class="windowbg center">
<img src="$imagesdir/info.png" alt="" />
</td>
<td class="windowbg2 fontbigger">
To prevent server time-out due to the amount of members to be converted, the conversion is split into more steps.<br />
<br />
The time-step (\$max_process_time) is set to <i>$max_process_time seconds</i>.<br />
Conversion took <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:#f33"><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 'members2' ) {
if ( $INFO{'mstart1'} < 0 ) {
setup_fatal_error(
"Member conversion (members2) 'mstart1' ($INFO{'mstart1'})) error!"
);
}
$yytabmenu = $NavLink1 . $NavLink2 . $NavLink3 . $NavLink5 . $NavLink6;
my $mwidth =
int( ( ( $INFO{'mstart1'} ) / 2 ) / $INFO{'mtotal'} * 100 );
$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 Conversion.</div>
<div class="divouter">
<div class="divvary" style="width: $mwidth$px;">&nbsp;</div>
</div>
<div class="divvary2">$mwidth %</div>
<br />
<div class="convnotdone">Board and Category Conversion.</div>
$ConvNotDone
<div class="convnotdone">Message Conversion.</div>
$ConvNotDone
<div class="convnotdone">Final Cleanup.</div>
$ConvNotDone
</td>
</tr><tr>
<td class="windowbg center">
<img src="$imagesdir/info.png" alt="" />
</td>
<td class="windowbg2 fontbigger">
To prevent server time-out due to the amount of members to be converted, the conversion is split into more steps.<br />
<br />
The time-step (\$max_process_time) is set to <i>$max_process_time seconds</i>.<br />
The last step took <i>~
. ( $time_to_jump - $INFO{'starttime'} ) . q~ seconds</i>.
<br />
Conversion has taken <i>~
. int( ( $INFO{'st'} + 60 ) / 60 ) . q~ minutes</i>.
<br />
<br />
There are <b>~
. int( $INFO{'mtotal'} - ( $INFO{'mstart1'} / 2 ) )
. qq~/$INFO{'mtotal'}</b> Members left to be converted.
<br />
<p id="memcontinued">If nothing happens in 5 seconds <a href="$set_cgi?action=members;st=$INFO{'st'};mstart1=$INFO{'mstart1'}" onclick="PleaseWait();">click here to continue</a>...<br />If you want to <a href="javascript:stoptick();">STOP 'Members' conversion click here</a>. Then copy the actual browser address and type it in when you want to continue the conversion.</p>
</td>
</tr>
</table>
</div>
<script type="text/javascript">
function PleaseWait() {
document.getElementById("memcontinued").innerHTML = '<span style="color:#f33"><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>';
}
function stoptick() { stop = 1; }
stop = 0;
function membtick() {
if (stop != 1) {
PleaseWait();
location.href="$set_cgi?action=members;st=$INFO{'st'};mstart1=$INFO{'mstart1'}";
}
}
setTimeout("membtick()",2000);
</script>
~;
}
elsif ( $action eq 'cats' ) {
require qq~$vardir/ConvSettings.txt~;
if ( !exists $INFO{'bstart'} ) {
MoveBoards();
}
$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 Conversion.</div>
$ConvDone
<div class="convdone">Board &amp; Category Conversion.</div>
$ConvDone
<div class="convnotdone">Message Conversion.</div>
$ConvNotDone
<div class="convnotdone">Variables &amp; Clean Up.</div>
$ConvNotDone
</td>
</tr><tr>
<td class="windowbg center">
<img src="$imagesdir/info.png" alt="" />
</td>
<td class="windowbg2 fontbigger">
All Boards and Subboards moved.<br />
<br />
Conversion has taken <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:#f00"><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 '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 . $NavLink3a . $NavLink5 . $NavLink6;
my $bwidth = int( $INFO{'bstart'} / $INFO{'btotal'} * 100 );
$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 Conversion.</div>
$ConvDone
<div class="convdone">Board and Category Conversion.</div>
<div class="divouter">
<div class="divvary" style="width: $bwidth$px;">&nbsp;</div>
</div>
<div class="divvary2">$bwidth %</div>
<br />
<div class="convnotdone">Message Conversion.</div>
$ConvNotDone
<div class="convnotdone">Variables &amp; Clean Up.</div>
$ConvNotDone
</td>
</tr><tr>
<td class="windowbg center">
<img src="$imagesdir/info.png" alt="" />
</td>
<td class="windowbg2 fontbigger">
To prevent server time-out due to the amount of boards to be converted, the conversion is split into more steps.<br />
<br />
The time-step (\$max_process_time) is set to <i>$max_process_time seconds</i>.<br />
The last step took <i>~
. ( $time_to_jump - $INFO{'starttime'} ) . q~ seconds</i>.<br />
Conversion has taken <i>~
. int( ( $INFO{'st'} + 60 ) / 60 ) . q~ minutes</i>.<br />
<br />
There are <b>~
. ( $INFO{'btotal'} - $INFO{'bstart'} )
. qq~/$INFO{'btotal'}</b> Boards left to be converted.<br />
<p id="memcontinued">If nothing happens in 5 seconds <a href="$set_cgi?action=cats;st=$INFO{'st'};bstart=$INFO{'bstart'};bfstart=$INFO{'bfstart'}" onclick="PleaseWait();">click here to continue</a>...<br />If you want to <a href="javascript:stoptick();">STOP 'Boards & Categories' conversion click here</a>. Then copy the actual browser address and type it in when you are going to continue the conversion.</p>
</td>
</tr>
</table>
</div>
<script type="text/javascript">
function PleaseWait() {
document.getElementById("memcontinued").innerHTML = '<span style="color:#f00"><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 stoptick() { stop = 1; }
stop = 0;
function membtick() {
if (stop != 1) {
PleaseWait();
location.href="$set_cgi?action=cats;st=$INFO{'st'};bstart=$INFO{'bstart'};bfstart=$INFO{'bfstart'}";
}
}
setTimeout("membtick()",2000);
</script>
~;
}
elsif ( $action eq 'messages' ) {
require qq~$vardir/ConvSettings.txt~;
MoveMessages();
$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 Conversion.</div>
$ConvDone
<div class="convdone">Board and Category Conversion.</div>
$ConvDone
<div class="convdone">Message Conversion.</div>
$ConvDone
<div class="convnotdone">Variables &amp; 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 />
Conversion has taken <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:#f00"><b>Converting - please wait!<br />If you want to stop \\'Clean Up\\' conversion, 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 '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 . $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 Conversion.</div>
$ConvDone
<div class="convdone">Board and Category Conversion.</div>
$ConvDone
<div class="convdone">Message Conversion.</div>
<div class="divouter">
<div class="divvary" style="width: $bwidth$px;">&nbsp;</div>
</div>
<div class="divvary2">$bwidth %</div><br />
<div class="convnotdone">Variables &amp; Clean Up.</div>
$ConvNotDone
</td>
</tr><tr>
<td class="windowbg center">
<img src="$imagesdir/info.png" alt="" />
</td>
<td class="windowbg2 fontbigger">
To prevent server time-out due to the amount of messages to be converted, the conversion is split into more steps.<br />
<br />
The time-step (\$max_process_time) is set to <i>$max_process_time seconds</i>.<br />
The last step took <i>~
. ( $time_to_jump - $INFO{'starttime'} ) . q~ seconds</i>.<br />
Conversion has taken <i>~
. int( ( $INFO{'st'} + 60 ) / 60 ) . qq~ minutes</i>.<br />
<br />
<i>$INFO{'total_threads'}</i> Threads have been converted.<br />
<i>$INFO{'total_mess'}</i> Messages have been converted.<br />
There are <b>~
. ( $INFO{'totboard'} - $INFO{'count'} )
. qq~/$INFO{'totboard'}</b> Boards left with Messages to be converted.<br />
<div style="float: left;">There are <b>~
. ( $INFO{'totmess'} - $INFO{'tcount'} )
. qq~/$INFO{'totmess'}</b> Threads left to be converted. &nbsp; </div>
<div class="divouter">
<div class="divvary" style="width: $mwidth$px;">&nbsp;</div>
</div>
<div class="divvary2">$mwidth %</div>
<br />
<p id="memcontinued">If nothing happens in 5 seconds <a href="$set_cgi?action=messages;st=$INFO{'st'};totboard=$INFO{'totboard'};count=$INFO{'count'};tcount=$INFO{'tcount'};total_mess=$INFO{'total_mess'};total_threads=$INFO{'total_threads'}" onclick="PleaseWait();">click here to continue</a>...<br />If you want to <a href="javascript:stoptick();">STOP 'Messages' conversion click here</a>. Then copy the actual browser address and type it in when you are going to continue the conversion.</p>
</td>
</tr>
</table>
</div>
<script type="text/javascript">
function PleaseWait() {
document.getElementById("memcontinued").innerHTML = '<span style="color:#f00"><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 stoptick() { stop = 1; }
stop = 0;
function membtick() {
if (stop != 1) {
PleaseWait();
location.href="$set_cgi?action=messages;st=$INFO{'st'};count=$INFO{'count'};tcount=$INFO{'tcount'};total_mess=$INFO{'total_mess'};total_threads=$INFO{'total_threads'}";
}
}
setTimeout("membtick()",2000);
</script>
~;
}
elsif ( $action eq 'cleanup' ) {
require qq~$vardir/ConvSettings.txt~;
MoveVariables();
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~ minute(s)</i>.<br />
<br />
<br />
<span style="color:#f33">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>~;
CreateConvLock();
}
$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');
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 ConvertMembers {
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);
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);
}
if ( -e "$convmemberdir/memberlist.approve" ) {
fopen( BMEMDIRA, "$convmemberdir/memberlist.approve" )
|| setup_fatal_error(
"$maintext_23 $convmemberdir/memberlist.approve: ", 1 );
my @approve = <BMEMDIRA>;
fclose(BMEMDIRA);
fopen( NBMEMDIRA, ">$memberdir/memberlist.approve" )
|| setup_fatal_error(
"$maintext_23 $convmemberdir/memberlist.approve: ", 1 );
print {NBMEMDIRA} @approve or croak 'cannot print NBMEMDIR';
fclose(NBMEMDIRA);
}
if ( -e "$convmemberdir/memberlist.inactive" ) {
fopen( BMEMDIRIN, "$convmemberdir/memberlist.inactive" )
|| setup_fatal_error(
"$maintext_23 $convmemberdir/memberlist.inactive: ", 1 );
my @inactive = <BMEMDIRIN>;
fclose(BMEMDIRIN);
fopen( NBMEMDIRIN, ">$memberdir/memberlist.inactive" )
|| setup_fatal_error(
"$maintext_23 $convmemberdir/memberlist.inactive: ", 1 );
print {NBMEMDIRIN} @inactive or croak 'cannot print NBMEMDIRIN';
fclose(NBMEMDIRIN);
}
if ( -e "$convmemberdir/members.ttl" ) {
fopen( BMEMDIRTTL, "$convmemberdir/members.ttl" )
|| setup_fatal_error( "$maintext_23 $convmemberdir/members.ttl: ",
1 );
my @memtotl = <BMEMDIRTTL>;
fclose(BMEMDIRTTL);
fopen( NBMEMDIRTTL, ">$memberdir/members.ttl" )
|| setup_fatal_error( "$maintext_23 $memberdir/members.ttl: ", 1 );
print {NBMEMDIRTTL} @memtotl or croak 'cannot print NBMEMDIRTTL';
fclose(NBMEMDIRTTL);
}
if ( -e "$convmemberdir/forgotten.passes" ) {
fopen( BMEMDIRP, "$convmemberdir/forgotten.passes" )
|| setup_fatal_error(
"$maintext_23 $convmemberdir/forgotten.passes: ", 1 );
my @passes = <BMEMDIRP>;
fclose(BMEMDIRP);
fopen( NBMEMDIRP, ">$memberdir/forgotten.passes" )
|| setup_fatal_error( "$maintext_23 $memberdir/forgotten.passes: ",
1 );
print {NBMEMDIRP} @passes or croak 'cannot print NBMEMDIRP';
fclose(NBMEMDIRP);
}
for (@approve) {
( undef, undef, $regmember, undef, undef ) =
split /\|/xsm, $_;
push @memlist, $regmember;
}
for (@inactive) {
( undef, undef, $regmember, undef, undef ) =
split /\|/xsm, $_;
push @memlist, $regmember;
}
my @xtn = qw(vars msg ims imstore log outbox rlog imdraft pre wait);
for my $i ( ( $INFO{'mstart1'} || 0 ) .. ( @memlist - 1 ) ) {
( $user, undef ) = split /\t/xsm, $memlist[$i];
if ( !-e "$convmemberdir/$user.vars"
&& !-e "$convmemberdir/$user.pre"
&& !-e "$convmemberdir/$user.wait" )
{
next;
}
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( FILEUSERB, ">$memberdir/$user.$cnt" )
|| setup_fatal_error(
"$maintext_23 $memberdir/$user.$cnt: ", 1 );
print {FILEUSERB} @divfiles or croak 'cannot print FILEUSER';
fclose(FILEUSERB);
}
}
if ( -e "$convmemberdir/$user.wlog" && !-e "$convmemberdir/$user.rlog") {
undef %recent;
require "$convmemberdir/$user.wlog";
fopen( RLOG, ">$memberdir/$user.rlog" );
print {RLOG} map { "$_\t$recent{$_}\n" } keys %recent or croak "$croak{'print'} RLOG";
fclose(RLOG);
}
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=$i~;
redirectexit();
}
}
return;
}
# / Member Conversion ##
# Board + Category Conversion ##
sub MoveBoards {
my @brdlst = ( 'forum.master', 'forum.totals', 'forum.control', );
for my $newbrd (@brdlst) {
fopen( OLDBRD, "$convboardsdir/$newbrd" );
my @brdinfo = <OLDBRD>;
fclose(OLDBRD);
fopen( NEWBRD, ">$boardsdir/$newbrd" );
print {NEWBRD} @brdinfo or croak 'cannot print NEWBRD';
fclose(NEWBRD);
}
require "$boardsdir/forum.master";
@boards = sort keys %board;
@subboards = sort keys %subboard;
my @brdtype = qw(txt mail exhits);
push( @boards, @subboards );
for my $i ( ( $INFO{'bstart'} || 0 ) .. ( @boards - 1 ) ) {
for my $ext (@brdtype) {
if ( -e "$convboardsdir/$boards[$i].$ext" ) {
fopen( BOARDFILE, "$convboardsdir/$boards[$i].$ext" )
|| setup_fatal_error(
"$maintext_23 $convboardsdir/$boards[$i].ext: ", 1 );
@brdinfo = <BOARDFILE>;
fclose(BOARDFILE);
fopen( NEWBRD, ">$boardsdir/$boards[$i].$ext" );
print {NEWBRD} @brdinfo or croak 'cannot print NEWBRD';
fclose(NEWBRD);
}
}
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;bstart=$i;btotal=~
. @boards;
redirectexit();
}
}
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;
}
# / Board + Category Conversion ##
# Messages Conversion ##
sub MoveMessages {
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);
}
require "$boardsdir/forum.master";
my @boards = sort keys %board;
my @subboards = sort keys %subboard;
push @boards, @subboards;
my $totalbdr = @boards;
my @threadext = qw(mail poll polled);
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 = <BRDFILE>;
fclose(BRDFILE);
chomp @brdmessageline;
$totalmess = @brdmessageline;
for my $tops ( ( $INFO{'tcount'} || 0 ) .. ( $totalmess - 1 ) ) {
my @thread = split /\|/xsm, $brdmessageline[$tops];
my $thread = $thread[0];
if ( -e "$convdatadir/$thread.txt" && -e "$convdatadir/$thread.ctb" ) {
fopen( MSGFILE, "$convdatadir/$thread.txt" )
|| setup_fatal_error(
"$maintext_23 $convdatadir/$thread.txt: ", 1 );
@messagelines = <MSGFILE>;
fclose(MSGFILE);
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);
$INFO{'total_mess'} += @messagelines;
$INFO{'total_threads'}++;
fopen( MSGFILE, "$convdatadir/$thread.ctb" )
|| setup_fatal_error(
"$maintext_23 $convdatadir/$thread.ctb: ", 1 );
@messagelines = <MSGFILE>;
fclose(MSGFILE);
fopen( MSGFILE, ">$datadir/$thread.ctb" )
|| setup_fatal_error(
"$maintext_23 $datadir/$thread.ctb: ", 1 );
print {MSGFILE} @messagelines
or croak "cannot print $datadir/$thread.ctb";
fclose(MSGFILE);
for my $ext (@threadext) {
if ( -e "$convdatadir/$thread.$ext" ) {
fopen( MSGFILE, "$convdatadir/$thread.$ext" )
|| setup_fatal_error(
"$maintext_23 $convdatadir/$thread.$ext: ", 1 );
@messagelines = <MSGFILE>;
fclose(MSGFILE);
fopen( MSGFILE, ">$datadir/$thread.$ext" )
|| setup_fatal_error(
"$maintext_23 $datadir/$thread.$ext: ", 1 );
print {MSGFILE} @messagelines
or croak "cannot print $datadir/$thread.$ext";
fclose(MSGFILE);
}
}
}
if ( time() > $time_to_jump && ( $tops + 1 ) < $totalmess ) {
$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();
}
}
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;
}
# / Messages Conversion ##
# Variables Conversion ##
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);
}
}
$mypl = 1;
}
elsif ( -e "$convvardir/Settings.pm" ) {
require "$convvardir/Settings.pm";
}
if ( -e "$convvardir/eventcalset.txt" ) {
require "$convvardir/eventcalset.txt";
}
if ( $mypl == 1 ) {
$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; }
if ( !$enabletz ) { $enabletz = 0; }
if ( !$default_tz ) { $default_tz = 'UTC'; }
$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;
}
# / Variables Conversion ##
#End Conversion#
sub FoundConvert2xLock {
tempstarter();
require Sources::TabMenu;
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.5 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';
SetupTemplate();
return;
}
sub CreateConvLock {
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 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 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 &amp; 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: #f33; 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: #f33; padding:0" class="selected" onClick="PleaseWait();">$tabfill Boards &amp; Categories $tabfill</a></span>~;
$NavLink3a =
qq~$tabsep<span class="selected"><a href="$set_cgi?action=messages;st=$INFO{'st'}" style="color: #f33; 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: #f33; 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: #f33; 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~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=utf-8" />
</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;
@months = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
my (
$newsecond, $newminute, $newhour, $newday, $newmonth,
$newyear, $newweekday, $newyearday, $newoff
) = localtime($date);
$newyear += 1900;
$newminute = sprintf '%02d', $newminute;
$newsecond = sprintf '%02d', $newsecond;
$yytime =
qq~$months[$newmonth] $newday, $newyear $maintxt{'107'} $newhour:$newminute~;
# $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 ) {
$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 &#123;yabb copyright&#125; 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 {
$mycopy = qq~2000-$newyear~;
$output =~ s/2000-1900/$mycopy/xsm;
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;
}
1;