-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate1_0.php
1207 lines (1105 loc) · 65 KB
/
update1_0.php
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
<?php
// Ultimate PHP Board Updater to V2.0
// Author: Jerroyd Moore aka Rebles, R_Rebles, or RxRebles
// Website: http://www.myupb.com
// Version: 2.0
// Using textdb Version: 4.3.4
set_time_limit(300);
$mt = explode(' ', microtime());
$script_start_time = $mt[0] + $mt[1];
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// always modified
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache");
if(isset($_GET['step'])) $step = (int) $_GET['step'];
else $step = 0;
$finish = '';
error_reporting(E_ALL ^ E_NOTICE);
ignore_user_abort();
if($_GET['step'] != 0) {
if(TRUE !== is_writable('config.php')) die('Unable to continue with the installation process. "config.php" in the root upb directory MUST BE writable.');
if(filesize('config.php') > 0) {
require_once('config.php');
if(INSTALLATION_MODE === FALSE && (int)$_GET['step'] < 7) {
$msg = '';
if(isset($_COOKIE['user_env'])) $msg .= $_COOKIE['user_env'];
else $msg .= 'Someone';
if(isset($_COOKIE['id_env'])) $msg .= '(User ID:'.$_COOKIE['id_env'].')';
if(isset($_SERVER['REMOTE_ADDR'])) $msg .= 'with the IP Address "'.$_SERVER['REMOTE_ADDR'].'"';
$msg .= 'tried to initiate an installation or upgrade file. Since the installation and upgrade files pose a risk, this could be an attempted hack. The administrator, you, were notified. It is advised you delete installation and upgrade files, which are no long use, and ban the IP Address and username, if given.';
@mail(ADMIN_EMAIL, 'SECURITY ALERT on your forum', $msg);
die('<b>Security Risk</b>: Unable to initiate installation. An Administrater must put the forum in Installation Mode. You\'re IP Address has been sent to the administrater aswell as login information.');
}
} else {
$f = fopen('config.php', 'w');
fwrite($f, "<?php
define('INSTALLATION_MODE', true, true);
define('UPB_VERSION', '2.0.0', true);
define('DB_DIR', './db', true);
?>");
fclose($f);
}
}
//Begin error.class.php
class errorhandler {
var $howmany = 0;
var $error = array();
var $errortype = array (
E_ERROR => "Fatal error",
E_WARNING => "Warning",
E_PARSE => "Parsing Error",
E_NOTICE => "Notice",
E_CORE_ERROR => "Core Error",
E_CORE_WARNING => "Core Warning",
E_COMPILE_ERROR => "Compile Error",
E_COMPILE_WARNING => "Compile Warning",
E_USER_ERROR => "Fatal error",
E_USER_WARNING => "Warning",
E_USER_NOTICE => "Notice",
);
function add_error($errno, $errstr, $errfile='', $errline='') {
error_log("<b>".$this->errortype[$error[0]]."</b>: ".$errstr." in file ".$errfile." on <b>line ".$errline."</b><br />", 3, 'error_log');
if($errno == E_NOTICE) return;
if(!isset($this->errortype[$errno])) return;
/*
[0]$errno = integer;
[1]$errstr = string;
[2]$errfile = string;
[3]$errline = integer;
[4]$errcontext = array;
*/
$this->howmany++;
$this->error[] = array($errno, $errstr, $errfile, $errline);
if($errno == E_ERROR || $errno == E_USER_ERROR) {
$this->print_errors();
exit;
}
}
function add_cError($errno, $errstr, $errfile='', $errline='') {
$this->error[] = array($errno, $errstr, $errfile, $errline);
if($errno == E_ERROR || $errno == E_USER_ERROR) {
$this->print_errors();
exit;
}
}
function print_errors() {
$die = false;
reset($this->error);
if($this->error_exists()) {
echo '<table border="0" width="100%" cellspacing="0" cellpadding="7" bordercolor="#000000" style="border-style: solid; border-width: 1">
<tr><td width="100%"><font face="Verdana" size="2"><b>Advisory:</b> The following errors occured when converting this section of your forum. Please note that IF you can proceed to the next step, then no major errors occured that would prevent your forum from functioning.</font><br><br>';
echo '<div class="error">';
foreach($this->error as $error) {
echo "<b>".$this->errortype[$error[0]]."</b>: ";
echo $error[1];
if($error[3] != '') echo " on line <b>".$error[3]."</b>";
if($error[2] != '') echo " in file <b>".$error[2]."</b>";
echo '.<br>';
if($error[0] == E_ERROR || $error[0] == E_USER_ERROR) $die = true;
}
echo '<br><font face="Verdana" size="2">For additional support, Contact UPB Team at <a href="http://www.myupb.com" target="_blank">myupb.com</a> or visit their <a href="http://forum.myupb.com" target="_blank">forums</a></font>';
echo '</td></tr></table><br>';
if($die) {
echo'<script language="Javascript">var flag = 0;</script></body></html>';
exit;
}
}
}
function error_exists() {
if(!empty($this->error[0])) return true;
return false;
}
function return_howmany() {
return $this->howmany;
}
}
//end error.class.php
$errorHandler = &new errorhandler();
set_error_handler(array(&$errorHandler, 'add_error'));
?>
<html>
<head>
<title>UPB Updater: Step <?php echo $step; ?> of 8 Completed...</title>
<script language="Javascript">
var flag = 1;
function ConfirmUnload()
{
if(flag == 1) event.returnValue = "The Updater is not finish and will corrupt your forum data.";
}
function submitonce(theform)
{
if (document.all||document.getElementById)
{
for (i=0;i<theform.length;i++)
{
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="next >>") tempobj.disabled=true
}
}
}
<!--
var counter=0;
function check_submit()
{
counter++;
if (counter>1)
{
alert("You cannot submit the form again! Please Wait.");
return false;
}
}
-->
</script>
<body onbeforeunload="ConfirmUnload();">
<?php
//old textdb functions
function def($rec, $db) {
$r = "";
if(!file_exists("$db.def")) return false;
$f = fopen("$db.def", "r");
$def = fread($f, filesize("$db.def"));
fclose($f);
$def = trim($def);
$def = explode("<~>", $def);
$rec = explode("<~>", $rec);
for($i=0;$i<count($rec);$i++) {
$r[$def[$i]] = $rec[$i];
}
return $r;
}
function listall($db) {
/*
String: $db
*/
$r = "";
$rc = 0;
if(!file_exists("$db.dat")) return false;
if(filesize($db.".dat") == 0) return "";
$f = fopen("$db.dat", "r");
$a = fread($f, filesize("$db.dat"));
fclose($f);
$a = trim($a);
$a = explode("\n", $a);
for($i=0;$i<count($a);$i++) {
if($a[$i] != "") {
$r[$rc] = $a[$i];
$rc++;
}
}
return $r;
}
function get($id, $db, $upb='') {
/*
Integer: $id
String: $db
*/
if(!file_exists("$db.dat")) return false;
$d = listall($db);
$a = count($d);
$howmany = explode("<~>", $d[0]);
$field = count($howmany)-1;
$q = "$id";
for($i=0;$i<=$a;$i++) {
if(empty($d[$i])) continue;
@$stuff = explode("<~>", $d[$i]);
if(@$stuff[$field] == $q) {
$a = $d[$i];
if(file_exists("$db.def")) $rec = def($a, $db);
else $rec = def($a, $upb["def"]);
break;
}
}
if(!isset($rec)) $rec = false;
return $rec;
}
function getID($db) {
if(file_exists($db.".id")) {
$idfile = file($db.".id");
$id = trim($idfile[0]);
} else {
return false;
}
return $id;
}
function undo_format($field) {
$r = $field;
$r = str_replace("\n", "", $r);
$r = str_replace("[NL][NL]", "\n", $r);
$r = str_replace("[NL]", "\n", $r);
return $r;
}
//end of old tdb functions
function numberEnding($num) {
if(substr($num, -1) == 1 && $num != 11) $ending = "st";
if(substr($num, -1) == 2 && $num != 12) $ending = "nd";
if(substr($num, -1) == 3 && $num != 13) $ending = "rd";
if(substr($num, -1) > 3 || substr($num, -1) == 0) $ending = "th";
if($num == 11 || $num == 12 || $num == 13) $ending = "th";
return $ending;
}
// Jan 14, 2008 #2:44:10 pm
$ratio = array("corrupt" => 0, "correct" => 0);
if(function_exists('date_default_timezone_set')) date_default_timezone_set(date('e')); //PHP 5.1.0
function convertTimeString($timeString, $format="", &$ratio) {
$months = array("Jan" => 1, "Feb" => 2, "Mar" => 3, "Apr" => 4, "May" => 5, "Jun" => 6, "Jul" => 7, "Aug" => 8, "Sep" => 9, "Oct" => 10, "Nov" => 11, "Dec" => 12);
$timeString = trim($timeString);
if($format == "user" || $format == "users") {
if(FALSE === strpos($timeString, '-')) {
$ratio['correct']++;
return time();
}
$arr = explode("-", $timeString);
$year = $arr[0];
$month = $arr[1];
$day = $arr[2];
$hour = 0;
$minute = 0;
$second = 0;
} else {
$month = $months[substr($timeString, 0, 3)];
$day = substr($timeString, 4, 2);
$year = substr($timeString, 8, 4);
$hour = trim(substr($timeString, -11, 2));
if(substr($timeString, -2, 2) == "pm") $hour += 12;
$minute = substr($timeString, -8, 2);
$second = substr($timeString, -5, 2);
}
$date = @mktime($hour, $minute, $second, $month, $day, $year);
if($timeString == @date("M d, Y g:i:s a", $date)) $ratio["correct"]++;
elseif(!($format == "user" || $format == "users")) $ratio["corrupt"]++;
return $date;
}
//debugging purposes..
if(isset($_GET['debugging'])) {
define('DEBUGGING_MODE', TRUE, true);
$debug_to_file_resource = fopen('debugging_log', 'w');
} else define('DEBUGGING_MODE', FALSE, true);
require_once('./includes/debug_print_backtrace.php');
if($step == 0) {
//Intro, don't execute anything important here!!
//Future: Maybe add a verification here, to make sure there are no unauthorized entries ?>
<p>Thank you for choosing to upgrade your Ultimate PHP Board to Version
2.0! Version 2.0 offers greater security than before. UPB 2, powered by
the new Text Database class loads your pages in a fraction of a second.</p>
<p>Before continueing, be sure to note the following so that the upgrade
transition is smooth and effortless:</P>
<ul>
<li>Be sure that you have backed up your db folder</li>
<li>CHMOD the config.php in the root UPB directory to 666</li>
<li>CHMOD the db folder (and all files and folders inside, including
files inside folders) in the root UPB directory to 777</li>
<li>CHMOD each skin's folder, located in the skins folder (ex:
/upb/skins/default/), to 777</li>
</ul>
<?php
} elseif($step == 1) {
//Create Necessary Directories
if(@(!is_dir("./db/"))) die("<script language=\"JavaScript\">var flag = 0;</script>Unable to proceed with the update. Cause: <b>\"./db/\" does NOT exist.</b>");
if(@(!is_dir("./db/backup/"))) {
if(@(!mkdir("./db/backup", 0777))) die("<script language=\"JavaScript\">var flag = 0;</script>Unable to create and chmod directory <b>./db/backup/</b>, please do this manually.");
}
if(!is_writable("./db/")) die("<script language=\"JavaScript\">var flag = 0;</script>Make sure the folder <b>./db/</b> is chmoded to 0777, the upgrade cannot continue until it can write in these folders.");
if(!is_readable("./db/")) die("<script language=\"JavaScript\">var flag = 0;</script>Make sure the folder <b>./db/</b> is chmoded to 0777, the upgrade cannot continue until it can read in these folders.");
//if(!is_writable("./backup/")) die("<script language=\"JavaScript\">var flag = 0;</script>Make sure the folder <b>./backup/</b> is chmoded to 0777, the upgrade cannot continue until it can write in these folders.");
//if(!is_readable("./backup/")) die("<script language=\"JavaScript\">var flag = 0;</script>Make sure the folder <b>./backup/</b> is chmoded to 0777, the upgrade cannot continue until it can read in these folders.");
echo "Checking if Directories are created and accessable...Done!";
} elseif($step == 2) {
//Create TextDBs & necessary Tables
require_once('./includes/class/tdb.class.php');
$tdb = new tdb("", "");
$tdb->createDatabase("./db/", "main.tdb");
$tdb->tdb("./db/", "main.tdb");
$_PrivMsg["tdb"] = new tdb("", "");
$_PrivMsg["tdb"]->createDatabase("./db/", "privmsg.tdb");
$_PrivMsg["tdb"]->tdb("./db/", "privmsg.tdb");
$tdb->createDatabase("./db/", "posts.tdb");
$tdb->createTable("members", array(
array("user_name", "string", 20),
array("password", "string", 49),
array("uniquekey", "string", 32),
array("level", "number", 1),
array("email", "memo"),
array("view_email", "number", 1),
array("mail_list", "number", 1),
array("status", "memo"),
array("location", "memo"),
array("url", "memo"),
array("avatar", "memo"),
array("avatar_height", "number", 3),
array("avatar_width", "number", 3),
array("avatar_hash", "string", 32),
array("icq", "number", 20),
array("aim", "string", 24),
array("yahoo", "memo"),
array("msn", "memo"),
array("sig", "memo"),
array("posts", "number", 7),
array("date_added", "number", 14),
array("timezone", "string", 3),
array("id", "id")
), 20);
$tdb->createTable("forums", array(
array("forum", "memo"),
array("cat", "number", 7),
array("view", "number", 1),
array("post", "number", 1),
array("reply", "number", 1),
array("des", "memo"),
array("topics", "number", 7),
array("posts", "number", 7),
array("id", "id")
), 20);
$tdb->createTable("categories", array(
array("name", "memo"),
array("sort", "memo"),
array("view", "number", 1),
array("id", "id")
), 20);
if(!($user_id = getID("./db/users"))) die("Unable to retrieve User IDs");
$user_id = (int)$user_id;
$num_of_pm_tb = ceil($user_id/120) + 1;
for($pm_tb=1;$pm_tb<$num_of_pm_tb;$pm_tb++) {
$_PrivMsg["tdb"]->createTable($pm_tb, array(
array("box", "string", 6),
array("from", "number", 7),
array("to", "number", 7),
array("icon", "string", 10),
array("subject", "memo"),
array("date", "number", 14),
array("message", "memo"),
array("id", "id")
));
}
$f = fopen("./db/blockedlist.dat", "w");
fwrite($f, "");
fclose($f);
$tdb->createTable("getpass", array(
array("passcode_HASH", "string", 49),
array("time", "number", 14),
array("user_id", "number", 7),
array("id", "id")
), 30);
$tdb->createTable("config", array(
array("name", "memo"),
array("value", "memo"),
array("type", "string", 6),
array("id", "id"),
), 20);
$tdb->createTable("ext_config", array(
array("name", "memo"),
array("value", "memo"),
array("type", "string", 6),
array("title", "memo"),
array("description", "memo"),
array("form_object", "string", 8),
array("data_type", "string", 7),
array("minicat", "number", 2),
array("sort", "number", 2),
array("id", "id")
), 20);
$tdb->setFp("config", "config");
$tdb->setFp("ext_config", "ext_config");
require_once("./db/config.dat");
require_once("./db/config2.dat");
@include "./db/config_pm.dat";
$config_file = rtrim(file_get_contents('config.php'), '?>');
$config_file .= "\ndefine('ADMIN_EMAIL', '".$admin_email."', true);\n?>";
$f = fopen('config.php', 'w');
fwrite($f, $config_file);
fclose($f);
unset($config_file);
$f = fopen('./db/constants.php', 'w');
fwrite($f, 'define("TABLE_WIDTH_MAIN", $_CONFIG["table_width_main"], true);
define("SKIN_DIR", $_CONFIG["skin_dir"], true);');
$f = fopen("./db/config_org.dat", 'w');
fwrite($f,
"config".chr(30)."General Settings".chr(31).
"status".chr(30)."Members' Statuses".chr(31).
"regist".chr(30)."Newly Registered Users".chr(31).
//.type.chr(30).type name.chr(31)
chr(29).
"config".chr(30)."1".chr(30)."Main Forum Config".chr(31).
"status".chr(30)."2".chr(30)."Member status".chr(31).
"status".chr(30)."3".chr(30)."Moderator status".chr(31).
"status".chr(30)."4".chr(30)."Admin Status".chr(31).
"status".chr(30)."5".chr(30)."Member status Colors".chr(31).
"status".chr(30)."6".chr(30)."Who's Online User Colors".chr(31).
"regist".chr(30)."7".chr(30)."New Users' Confirmation E-mail".chr(31).
"regist".chr(30)."8".chr(30)."Users' Avatars".chr(31));
//.type.chr(30).minicat.chr(30).cat name.chr(31)
fclose($f);
//$_CONFIG
$tdb->add("ext_config", array("name" => "ver", "value" => '2.0B1.4', "type" => "config", "form_object" => "hidden", "data_type" => "string"));
$tdb->add("config", array("name" => "ver", "value" => '2.0B1.4', "type" => "config"));
$tdb->add("ext_config", array("name" => "title", "value" => $title, "type" => "config", "title" => "Title", "description" => "Title of the forum", "form_object" => "text", "data_type" => "string", "minicat" => "1", "sort" => "1"));
$tdb->add("config", array("name" => "title", "value" => $title, "type" => "config"));
$tdb->add("ext_config", array("name" => "table_width_main", "value" => $table_width_main, "type" => "config", "title" => "Table Width", "description" => "This will change the table width of the main section of the forums", "form_object" => "text", "data_type" => "string", "minicat" => "1", "sort" => "10"));
$tdb->add("config", array("name" => "table_width_main", "value" => $table_width_main, "type" => "config"));
$tdb->add("ext_config", array("name" => "posts_per_page", "value" => $posts_per_page, "type" => "config", "title" => "Posts Per Page", "description" => "this is how many posts will be displays on each page for topics", "form_object" => "text", "data_type" => "number", "minicat" => "1", "sort" => "4"));
$tdb->add("config", array("name" => "posts_per_page", "value" => $posts_per_page, "type" => "config"));
$tdb->add("ext_config", array("name" => "topics_per_page", "value" => $topics_per_page, "type" => "config", "title" => "Topics per Page", "description" => "this is how many topics will be displays on each page for forums", "form_object" => "text", "data_type" => "number", "minicat" => "1", "sort" => "5"));
$tdb->add("config", array("name" => "topics_per_page", "value" => $topics_per_page, "type" => "config"));
$tdb->add("ext_config", array("name" => "logo", "value" => $logo, "type" => "config", "title" => "Logo Location", "description" => "can be relative or a url", "form_object" => "text", "data_type" => "string", "minicat" => "1", "sort" => "2"));
$tdb->add("config", array("name" => "logo", "value" => $logo, "type" => "config"));
$tdb->add("ext_config", array("name" => "homepage", "value" => $homepage, "type" => "config", "title" => "Homepage URL", "description" => "can be relative or a url", "form_object" => "text", "data_type" => "string", "minicat" => "1", "sort" => "3"));
$tdb->add("config", array("name" => "homepage", "value" => $homepage, "type" => "config"));
$tdb->add("ext_config", array("name" => "admin_catagory_sorting", "value" => $admin_catagory_sorting, "type" => "config", "title" => "Catagory Sorting", "description" => "Put the id numbers of the catagories that you want sorted; Seperate with commas. (I.E. 1,2,3,4)", "form_object" => "text", "data_type" => "string", "minicat" => "1", "sort" => "16"));
$tdb->add("config", array("name" => "admin_catagory_sorting", "value" => $admin_catagory_sorting, "type" => "config"));
$tdb->add("ext_config", array("name" => "servicemessage", "value" => $servicemessage, "type" => "config", "title" => "Service Messages", "description" => "Service Messages appear above the forum, if nothing input, Announcements will not be displayed. Html is allowed.", "form_object" => "textarea", "data_type" => "string", "minicat" => "1", "sort" => "17"));
$tdb->add("config", array("name" => "servicemessage", "value" => $servicemessage, "type" => "config"));
$tdb->add("ext_config", array("name" => "skin_dir", "value" => substr($skin_images_dir, 0, -7), "type" => "config", "title" => "Skin Directory", "description" => "leave it unless you upload another skin", "form_object" => "text", "data_type" => "string", "minicat" => "1", "sort" => "12"));
$tdb->add("config", array("name" => "skin_dir", "value" => substr($skin_images_dir, 0, -7), "type" => "config"));
$tdb->add("ext_config", array("name" => "fileupload_location", "value" => $fileupload_location, "type" => "config", "title" => "Location for file attachments", "description" => "Put the path to the directory for file attachments.<br>e.g. If your forums are located at http://forum.myupb.com, and your uploads directory is at http://forum.myupb.com/uploads, you would simply put 'uploads' (without quotes) in the box.", "form_object" => "text", "data_type" => "number", "minicat" => "1", "sort" => "6"));
$tdb->add("config", array("name" => "fileupload_location", "value" => $fileupload_location, "type" => "config"));
$tdb->add("ext_config", array("name" => "fileupload_size", "value" => $fileupload_size, "type" => "config", "title" => "Size limits for file upload", "description" => "In kilobytes, type in the maximum size allowed for file uploads", "form_object" => "text", "data_type" => "number", "minicat" => "1", "sort" => "7"));
$tdb->add("config", array("name" => "fileupload_size", "value" => $fileupload_size, "type" => "config"));
$tdb->add("ext_config", array("name" => "censor", "value" => $censor, "type" => "config", "title" => "Word to replace bad words", "description" => "Words that will replace bad words in a post", "form_object" => "text", "data_type" => "string", "minicat" => "1", "sort" => "13"));
$tdb->add("config", array("name" => "censor", "value" => $censor, "type" => "config"));
$tdb->add("ext_config", array("name" => "sticky_note", "value" => "[Stick Note]", "type" => "config", "title" => "Sticky Note Text", "description" => "Text that appends the title indicating it is a \"Stickied Topic\" (HTML Tags Allowed)", "form_object" => "text", "data_type" => "string", "minicat" => "1", "sort" => "14"));
$tdb->add("config", array("name" => "sticky_note", "value" => "[Stick Note]", "type" => "config"));
$tdb->add("ext_config", array("name" => "sticky_after", "value" => "1", "type" => "config", "title" => "Sticky Note Before or After Title", "description" => "If this is checked, the \"sticky note\" text will appear after the title. Unchecking this will display it before the title.", "form_object" => "checkbox", "minicat" => "1", "sort" => "15"));
$tdb->add("config", array("name" => "sticky_after", "value" => "1", "type" => "config"));
$tdb->add("ext_config", array("name" => "pm_max_outbox_msg", "value" => $pm_max_outbox_msg, "type" => "config", "title" => "Max Number of Private Msgs in a Users OutBox", "description" => "Can be set to 0 to infinity", "form_object" => "text", "data_object" => "number", "minicat" => "1", "sort" => "18"));
$tdb->add("config", array("name" => "pm_max_outbox_msg", "value" => $pm_max_outbox_msg, "type" => "config"));
$tdb->add("ext_config", array("name" => "pm_version", "value" => $pm_version, "type" => "config", "form_object" => "hidden", "data_type" => "string"));
$tdb->add("config", array("name" => "pm_version", "value" => $pm_version, "type" => "config"));
$tdb->add("ext_config", array("name" => "avatar_width", "value" => $avatar_width, "type" => "config", "title" => "Avatars' Width", "description" => "The width (with respect to the height) of user avatars you want to be displayed at in pixels (Cannot be higher than 999)", "form_object" => "text", "data_object" => "number", "minicat" => "1", "sort" => "8"));
$tdb->add("config", array("name" => "avatar_width", "value" => $avatar_width, "type" => "config"));
$tdb->add("ext_config", array("name" => "avatar_height", "value" => $avatar_height, "type" => "config", "title" => "Avatars' Height", "description" => "The height (with respect to the width) of user avatars you want to be displayed at in pixels (Cannot be higher than 999)", "form_object" => "text", "data_object" => "number", "minicat" => "1", "sort" => "9"));
$tdb->add("config", array("name" => "avatar_height", "value" => $avatar_height, "type" => "config"));
$tdb->add("ext_config", array("name" => "Create List", "value" => "more_smilies_create_list.php", "type" => "config", "title" => "Adding More Smilies", "description" => "Click on the link if you have recently added more smilies to your <b>moresmilies</b> directory", "form_object" => "link", "minicat" => "1", "sort" => "11"));
$tdb->add("config", array("name" => "Create List", "value" => "more_smilies_create_list.php", "type" => "config"));
//$_REGISTER
$tdb->add("ext_config", array("name" => "register_sbj", "value" => $register_sbj, "type" => "regist", "title" => "Register Email Subject", "description" => "this is the subject for confirmation of registration", "form_object" => "text", "data_type" => "string", "minicat" => "7", "sort" => "2"));
$tdb->add("config", array("name" => "register_sbj", "value" => $register_sbj, "type" => "regist"));
$tdb->add("ext_config", array("name" => "register_msg", "value" => $register_msg, "type" => "regist", "title" => "Register Email Message", "description" => "this is the message for confirmation of registration (options: <login> <password>)", "form_object" => "textarea", "data_type" => "string", "minicat" => "7", "sort" => "3"));
$tdb->add("config", array("name" => "register_msg", "value" => $register_msg, "type" => "regist"));
$tdb->add("ext_config", array("name" => "admin_email", "value" => $admin_email, "type" => "regist", "title" => "Admin E-mail", "description" => "this is the return address for confirmation of registration", "form_object" => "text", "data_type" => "string", "minicat" => "7", "sort" => "1"));
$tdb->add("config", array("name" => "admin_email", "value" => $admin_email, "type" => "regist"));
$tdb->add("ext_config", array("name" => "avatar1", "value" => $avatar1, "type" => "regist", "title" => "Avatar 1", "description" => "The first avatar on the selection menu for new users", "form_object" => "text", "data_type" => "string", "minicat" => "8", "sort" => "2"));
$tdb->add("config", array("name" => "avatar1", "value" => $avatar1, "type" => "regist"));
$tdb->add("ext_config", array("name" => "avatar2", "value" => $avatar2, "type" => "regist", "title" => "Avatar 2", "description" => "The second avatar on the selection menu for new users", "form_object" => "text", "data_type" => "string", "minicat" => "8", "sort" => "3"));
$tdb->add("config", array("name" => "avatar2", "value" => $avatar2, "type" => "regist"));
$tdb->add("ext_config", array("name" => "avatar3", "value" => $avatar3, "type" => "regist", "title" => "Avatar 3", "description" => "The third avatar on the selection menu for new users", "form_object" => "text", "data_type" => "string", "minicat" => "8", "sort" => "4"));
$tdb->add("config", array("name" => "avatar3", "value" => $avatar3, "type" => "regist"));
$tdb->add("ext_config", array("name" => "avatar4", "value" => $avatar4, "type" => "regist", "title" => "Avatar 4", "description" => "The fourth avatar on the selection menu for new users", "form_object" => "text", "data_type" => "string", "minicat" => "8", "sort" => "5"));
$tdb->add("config", array("name" => "avatar4", "value" => $avatar4, "type" => "regist"));
$tdb->add("ext_config", array("name" => "avatar5", "value" => $avatar5, "type" => "regist", "title" => "Avatar 5", "description" => "The fifth avatar on the selection menu for new users", "form_object" => "text", "data_type" => "string", "minicat" => "8", "sort" => "6"));
$tdb->add("config", array("name" => "avatar5", "value" => $avatar5, "type" => "regist"));
$tdb->add("ext_config", array("name" => "avatar6", "value" => $avatar6, "type" => "regist", "title" => "Avatar 6", "description" => "The sixth avatar on the selection menu for new users", "form_object" => "text", "data_type" => "string", "minicat" => "8", "sort" => "7"));
$tdb->add("config", array("name" => "avatar6", "value" => $avatar6, "type" => "regist"));
$tdb->add("ext_config", array("name" => "avatar7", "value" => $avatar7, "type" => "regist", "title" => "Avatar 7", "description" => "The seventh avatar on the selection menu for new users", "form_object" => "text", "data_type" => "string", "minicat" => "8", "sort" => "8"));
$tdb->add("config", array("name" => "avatar7", "value" => $avatar7, "type" => "regist"));
$tdb->add("ext_config", array("name" => "avatar8", "value" => $avatar8, "type" => "regist", "title" => "Avatar 8", "description" => "The eighth avatar on the selection menu for new users", "form_object" => "text", "data_type" => "string", "minicat" => "8", "sort" => "9"));
$tdb->add("config", array("name" => "avatar8", "value" => $avatar8, "type" => "regist"));
$tdb->add("ext_config", array("name" => "avatar9", "value" => $avatar9, "type" => "regist", "title" => "Avatar 9", "description" => "The nineth avatar on the selection menu for new users", "form_object" => "text", "data_type" => "string", "minicat" => "8", "sort" => "10"));
$tdb->add("config", array("name" => "avatar9", "value" => $avatar9, "type" => "regist"));
$tdb->add("ext_config", array("name" => "newuseravatars", "value" => $newuseravatars, "type" => "regist", "title" => "Avatars for new users", "description" => "Would you like to define the avatars that members under 50 posts can use? (After 50 posts they may use whatever they like)", "form_object" => "checkbox", "minicat" => "8", "sort" => "1"));
$tdb->add("config", array("name" => "newuseravatars", "value" => $newuseravatars, "type" => "regist"));
//$_STATUS
$tdb->add("ext_config", array("name" => "member_status1", "value" => $member_status1, "type" => "status", "title" => "Member post status 1", "description" => "According to post count", "form_object" => "text", "data_type" => "string", "minicat" => "2", "sort" => "1"));
$tdb->add("config", array("name" => "member_status1", "value" => $member_status1, "type" => "status"));
$tdb->add("ext_config", array("name" => "member_status2", "value" => $member_status2, "type" => "status", "title" => "Member post status 2", "description" => "According to post count", "form_object" => "text", "data_type" => "string", "minicat" => "2", "sort" => "3"));
$tdb->add("config", array("name" => "member_status2", "value" => $member_status2, "type" => "status"));
$tdb->add("ext_config", array("name" => "member_status3", "value" => $member_status3, "type" => "status", "title" => "Member post status 3", "description" => "According to post count", "form_object" => "text", "data_type" => "string", "minicat" => "2", "sort" => "5"));
$tdb->add("config", array("name" => "member_status3", "value" => $member_status3, "type" => "status"));
$tdb->add("ext_config", array("name" => "member_status4", "value" => $member_status4, "type" => "status", "title" => "Member post status 4", "description" => "According to post count", "form_object" => "text", "data_type" => "string", "minicat" => "2", "sort" => "7"));
$tdb->add("config", array("name" => "member_status4", "value" => $member_status4, "type" => "status"));
$tdb->add("ext_config", array("name" => "member_status5", "value" => $member_status5, "type" => "status", "title" => "Member post status 5", "description" => "According to post count", "form_object" => "text", "data_type" => "string", "minicat" => "2", "sort" => "9"));
$tdb->add("config", array("name" => "member_status5", "value" => $member_status5, "type" => "status"));
$tdb->add("ext_config", array("name" => "mod_status1", "value" => $mod_status1, "type" => "status", "title" => "Moderator post status 1", "description" => "According to post count", "form_object" => "text", "data_type" => "string", "minicat" => "3", "sort" => "1"));
$tdb->add("config", array("name" => "mod_status1", "value" => $mod_status1, "type" => "status"));
$tdb->add("ext_config", array("name" => "mod_status2", "value" => $mod_status2, "type" => "status", "title" => "Moderator post status 2", "description" => "According to post count", "form_object" => "text", "data_type" => "string", "minicat" => "3", "sort" => "3"));
$tdb->add("config", array("name" => "mod_status2", "value" => $mod_status2, "type" => "status"));
$tdb->add("ext_config", array("name" => "mod_status3", "value" => $mod_status3, "type" => "status", "title" => "Moderator post status 3", "description" => "According to post count", "form_object" => "text", "data_type" => "string", "minicat" => "3", "sort" => "5"));
$tdb->add("config", array("name" => "mod_status3", "value" => $mod_status3, "type" => "status"));
$tdb->add("ext_config", array("name" => "mod_status4", "value" => $mod_status4, "type" => "status", "title" => "Moderator post status 4", "description" => "According to post count", "form_object" => "text", "data_type" => "string", "minicat" => "3", "sort" => "7"));
$tdb->add("config", array("name" => "mod_status4", "value" => $mod_status4, "type" => "status"));
$tdb->add("ext_config", array("name" => "mod_status5", "value" => $mod_status5, "type" => "status", "title" => "Moderator post status 5", "description" => "According to post count", "form_object" => "text", "data_type" => "string", "minicat" => "3", "sort" => "9"));
$tdb->add("config", array("name" => "mod_status5", "value" => $mod_status5, "type" => "status"));
$tdb->add("ext_config", array("name" => "admin_status1", "value" => $admin_status1, "type" => "status", "title" => "Admin post status 1", "description" => "According to post count", "form_object" => "text", "data_type" => "string", "minicat" => "4", "sort" => "1"));
$tdb->add("config", array("name" => "admin_status1", "value" => $admin_status1, "type" => "status"));
$tdb->add("ext_config", array("name" => "admin_status2", "value" => $admin_status2, "type" => "status", "title" => "Admin post status 2", "description" => "According to post count", "form_object" => "text", "data_type" => "string", "minicat" => "4", "sort" => "3"));
$tdb->add("config", array("name" => "admin_status1", "value" => $admin_status1, "type" => "status"));
$tdb->add("ext_config", array("name" => "admin_status3", "value" => $admin_status3, "type" => "status", "title" => "Admin post status 3", "description" => "According to post count", "form_object" => "text", "data_type" => "string", "minicat" => "4", "sort" => "5"));
$tdb->add("config", array("name" => "admin_status3", "value" => $admin_status3, "type" => "status"));
$tdb->add("ext_config", array("name" => "admin_status4", "value" => $admin_status4, "type" => "status", "title" => "Admin post status 4", "description" => "According to post count", "form_object" => "text", "data_type" => "string", "minicat" => "4", "sort" => "7"));
$tdb->add("config", array("name" => "admin_status4", "value" => $admin_status4, "type" => "status"));
$tdb->add("ext_config", array("name" => "admin_status5", "value" => $admin_status5, "type" => "status", "title" => "Admin post status 5", "description" => "According to post count", "form_object" => "text", "data_type" => "string", "minicat" => "4", "sort" => "9"));
$tdb->add("config", array("name" => "admin_status5", "value" => $admin_status5, "type" => "status"));
$tdb->add("ext_config", array("name" => "member_post1", "value" => $member_post1, "type" => "status", "title" => "Post count 1", "form_object" => "text", "data_type" => "number", "minicat" => "2", "sort" => "2"));
$tdb->add("config", array("name" => "member_post1", "value" => $member_post1, "type" => "status"));
$tdb->add("ext_config", array("name" => "member_post2", "value" => $member_post2, "type" => "status", "title" => "Post count 2", "form_object" => "text", "data_type" => "number", "minicat" => "2", "sort" => "4"));
$tdb->add("config", array("name" => "member_post2", "value" => $member_post2, "type" => "status"));
$tdb->add("ext_config", array("name" => "member_post3", "value" => $member_post3, "type" => "status", "title" => "Post count 3", "form_object" => "text", "data_type" => "number", "minicat" => "2", "sort" => "6"));
$tdb->add("config", array("name" => "member_post3", "value" => $member_post3, "type" => "status"));
$tdb->add("ext_config", array("name" => "member_post4", "value" => $member_post4, "type" => "status", "title" => "Post count 4", "form_object" => "text", "data_type" => "number", "minicat" => "2", "sort" => "8"));
$tdb->add("config", array("name" => "member_post4", "value" => $member_post4, "type" => "status"));
$tdb->add("ext_config", array("name" => "member_post5", "value" => $member_post5, "type" => "status", "title" => "Post count 5", "form_object" => "text", "data_type" => "number", "minicat" => "2", "sort" => "10"));
$tdb->add("config", array("name" => "member_post5", "value" => $member_post5, "type" => "status"));
$tdb->add("ext_config", array("name" => "mod_post1", "value" => $mod_post1, "type" => "status", "title" => "Post count 1", "form_object" => "text", "data_type" => "number", "minicat" => "3", "sort" => "2"));
$tdb->add("config", array("name" => "mod_post1", "value" => $mod_post1, "type" => "status"));
$tdb->add("ext_config", array("name" => "mod_post2", "value" => $mod_post2, "type" => "status", "title" => "Post count 2", "form_object" => "text", "data_type" => "number", "minicat" => "3", "sort" => "4"));
$tdb->add("config", array("name" => "mod_post2", "value" => $mod_post2, "type" => "status"));
$tdb->add("ext_config", array("name" => "mod_post3", "value" => $mod_post3, "type" => "status", "title" => "Post count 3", "form_object" => "text", "data_type" => "number", "minicat" => "3", "sort" => "6"));
$tdb->add("config", array("name" => "mod_post3", "value" => $mod_post3, "type" => "status"));
$tdb->add("ext_config", array("name" => "mod_post4", "value" => $mod_post4, "type" => "status", "title" => "Post count 4", "form_object" => "text", "data_type" => "number", "minicat" => "3", "sort" => "8"));
$tdb->add("config", array("name" => "mod_post4", "value" => $mod_post4, "type" => "status"));
$tdb->add("ext_config", array("name" => "mod_post5", "value" => $mod_post5, "type" => "status", "title" => "Post count 5", "form_object" => "text", "data_type" => "number", "minicat" => "3", "sort" => "10"));
$tdb->add("config", array("name" => "mod_post5", "value" => $mod_post5, "type" => "status"));
$tdb->add("ext_config", array("name" => "admin_post1", "value" => $admin_post1, "type" => "status", "title" => "Post count 1", "form_object" => "text", "data_type" => "number", "minicat" => "4", "sort" => "2"));
$tdb->add("config", array("name" => "admin_post1", "value" => $admin_post1, "type" => "status"));
$tdb->add("ext_config", array("name" => "admin_post2", "value" => $admin_post2, "type" => "status", "title" => "Post count 2", "form_object" => "text", "data_type" => "number", "minicat" => "4", "sort" => "4"));
$tdb->add("config", array("name" => "admin_post2", "value" => $admin_post2, "type" => "status"));
$tdb->add("ext_config", array("name" => "admin_post3", "value" => $admin_post3, "type" => "status", "title" => "Post count 3", "form_object" => "text", "data_type" => "number", "minicat" => "4", "sort" => "6"));
$tdb->add("config", array("name" => "admin_post3", "value" => $admin_post3, "type" => "status"));
$tdb->add("ext_config", array("name" => "admin_post4", "value" => $admin_post4, "type" => "status", "title" => "Post count 4", "form_object" => "text", "data_type" => "number", "minicat" => "4", "sort" => "8"));
$tdb->add("config", array("name" => "admin_post4", "value" => $admin_post4, "type" => "status"));
$tdb->add("ext_config", array("name" => "admin_post5", "value" => $admin_post5, "type" => "status", "title" => "Post count 5", "form_object" => "text", "data_type" => "number", "minicat" => "4", "sort" => "10"));
$tdb->add("config", array("name" => "admin_post5", "value" => $admin_post5, "type" => "status"));
$tdb->add("ext_config", array("name" => "membercolor", "value" => $membercolor, "type" => "status", "title" => "Member status color", "description" => "The color that the status of a regular user will have", "form_object" => "text", "data_type" => "string", "minicat" => "5", "sort" => "1"));
$tdb->add("config", array("name" => "membercolor", "value" => $membercolor, "type" => "status"));
$tdb->add("ext_config", array("name" => "moderatorcolor", "value" => $moderatorcolor, "type" => "status", "title" => "Moderator status color", "description" => "The color that the status of a moderator will have", "form_object" => "text", "data_type" => "string", "minicat" => "5", "sort" => "2"));
$tdb->add("config", array("name" => "moderatorcolor", "value" => $moderatorcolor, "type" => "status"));
$tdb->add("ext_config", array("name" => "admcolor", "value" => $admcolor, "type" => "status", "title" => "Admin status color", "description" => "The color that the status of an administrator will have", "form_object" => "text", "data_type" => "string", "minicat" => "5", "sort" => "3"));
$tdb->add("config", array("name" => "admcolor", "value" => $admcolor, "type" => "status"));
//Who's online hex
$tdb->add("ext_config", array("name" => "userColor", "value" => $userColor, "type" => "status", "title" => "User Color", "description" => "The color of usernames of regular users in the who's online box", "form_object" => "text", "data_type" => "string", "minicat" => "6", "sort" => "1"));
$tdb->add("config", array("name" => "userColor", "value" => $userColor, "type" => "status"));
$tdb->add("ext_config", array("name" => "modColor", "value" => $modColor, "type" => "status", "title" => "Moderator Color", "description" => "The color of usernames of moderators in the who's online box", "form_object" => "text", "data_type" => "string", "minicat" => "6", "sort" => "2"));
$tdb->add("config", array("name" => "modColor", "value" => $modColor, "type" => "status"));
$tdb->add("ext_config", array("name" => "adminColor", "value" => $adminColor, "type" => "status", "title" => "Admin Color", "description" => "The color of usernames of administrators in the who's online box", "form_object" => "text", "data_type" => "string", "minicat" => "6", "sort" => "3"));
$tdb->add("config", array("name" => "adminColor", "value" => $adminColor, "type" => "status"));
//$tdb->add("ext_config", array("name" => "###", "value" => $###, "type" => "###", "title" => "###", "description" => "###", "form_object" => "###", "data_type" => "###", "minicat" => "!!", "sort" => "%%"));
//$tdb->add("config", array("name" => "###", "value" => $###, "type" => "###"));
//$tdb->sortAndBuild("ext_config", "sort", "ASC");
$tdb->tdb('./db/', 'posts.tdb');
$tdb->createTable('trackforums', array(array('fId', 'number', 7), array('uId', 'number', 7), array('lastvisit', 'number', 14), array('id', 'id')));
$tdb->createTable('tracktopics', array(array('fId', 'number', 7), array('tId', 'number', 7), array('uId', 'number', 7), array('old', 'number', 1), array('id', 'id')));
if($errorHandler->return_howmany() != 0) $error_finish = "Unable to create and Modify Databases and Tables.";
$finish = "Creating and Modifying Text Databases and Tables...Done!";
} elseif($step == 3) {
//Transfer User Records from the old tdb to the new tdb
//Including PM Files
require_once('./includes/class/tdb.class.php');
$_PrivMsg = array();
$_FAILED = array();
include "./db/config_pm.dat";
$tdb = new tdb("./db/", "main.tdb");
$_PrivMsg["tdb"] = new tdb("./db/", "privmsg.tdb");
$tdb->setFp("users", "members");
$bList = fopen("./db/blockedlist.dat", 'a');
$lvList = fopen("./db/lastvisit.dat", 'a');
$newpmList = fopen("./db/new_pm.dat", 'a');
$recs = array_reverse(listall('./db/users'));
for($i=0, $id=1, $r_c=count($recs);$i<$r_c;$i++, $id++) {
$rec = def($recs[$i], './db/users');
while($id < $rec["id"]) {
$_FAILED[] = $id;
fwrite($lvList, str_repeat(' ', 14));
$tdb->add("users", array());
$id++;
}
if($id > $rec["id"]) $errorHandler->add_Error(E_USER_ERROR, "Current ID surpassed ID in current record");
if(file_exists("./db/pms/".$id."_block.dat")) {
if(filesize("./db/pms/".$id."_block.dat") != 0) fwrite($bList, $id.":".trim(file_get_contents("./db/pms/".$id."_block.dat")).chr(31));
}
fwrite($newpmList, " 0");
$_PrivMsg["tdb"]->setFp("CuPrivMsgTb", ceil($id/120));
for($k = array("inbox", "outbox", "end");current($k) != "end";next($k)) {
if(file_exists("./db/pms/".$id."_".current($k).".dat")) {
$_PrivMsg[current($k)] = listall("./db/pms/".$id."_".current($k));
$_PrivMsg["c_".current($k)] = count($_PrivMsg[current($k)]);
if(!empty($_PrivMsg[current($k)])) { //if($_PrivMsg[current($k)][0] != "") {
for($j=0;$j<$_PrivMsg["c_".current($k)];$j++) {
$_PrivMsg["CuRec"] = def($_PrivMsg[current($k)][$j], "./db/pms/".current($k));
$_PrivMsg["CuRec"]["box"] = current($k);
$_PrivMsg["CuRec"]["message"] = undo_format($_PrivMsg["CuRec"]["message"]);
$_PrivMsg["CuRec"]["date"] = convertTimeString($_PrivMsg["CuRec"]["date"], '', $ratio);
if(isset($_PrivMsg["CuRec"]["from"])) {
$_PrivMsg["CuRec"]["to"] = $id;
$_PrivMsg["CuRec"]["from"] = $_PrivMsg["CuRec"]["from_id"];
} else {
$_PrivMsg["CuRec"]["from"] = $id;
$_PrivMsg["CuRec"]["to"] = $_PrivMsg["CuRec"]["to_id"];
}
$_PrivMsg["tdb"]->add("CuPrivMsgTb", $_PrivMsg["CuRec"]);
unset($_PrivMsg["CuRec"]);
if($j > ($pm_max_outbox_msg - 1) && current($k) == "outbox") $_PrivMsg["c_".current($k)] = -1;
}
}
} else {
$errorHandler->add_cError(E_USER_WARNING, "(ID ".$rec["id"].")'s ".current($k)." does not exist");
}
}
$lastvisit = time();
if(file_exists("./db/lastvisit/".$id.".dat"))
if(@is_readable("./db/lastvisit/".$id.".dat"))
if(@filesize("./db/lastvisit/".$id.".dat") != 0) $lastvisit = convertTimeString(trim(file_get_contents("./db/lastvisit/".$id.".dat")), '', $ratio);
fwrite($lvList, $lastvisit.str_repeat(' ', (14 - strlen($lastvisit))));
$rec["password"] = chr(21).$rec["password"];
$rec["date_added"] = convertTimeString($rec["date_added"], "user", $ratio);
if($rec["view_email"] == 'on') $rec["view_email"] = '1';
else $rec["view_email"] = '0';
if($rec["mail_list"] == 'on') $rec["mail_list"] = '1';
else $rec["mail_list"] = '0';
$rec["sig"] = undo_format($rec["sig"]);
$rec["timezone"] = '0';
$tdb->add("users", $rec);
unset($lastvisit, $rec);
}
fclose($lvList);
fclose($bList);
fclose($newpmList);
foreach($_FAILED as $failed_user_id) {
$tdb->delete("users", $failed_user_id, false);
}
//$tdb->reBuild("users");
if($errorHandler->return_howmany() != 0) $error_finish = "<b>Unable to transfer User records and PM files to new database.</b>";
$finish = "Transfering User records and PM files to new database...Done!";
} elseif($step == 4) {
//Transfering categories, & forums, and prepares to for the next step
require_once('./includes/class/tdb.class.php');
$tdb = new tdb("./db/", "main.tdb");
$_TPosts = array("tdb"=>new tdb("./db/", "posts.tdb"), "fId"=>array(), "p_ids" => array());
$_TRANSFER = array("cats" => array("sort" => array("old" => array(), "new" => array())), "forums" => array());
$tdb->setFp("cats", "categories");
$tdb->setFp("forums", "forums");
if(DEBUGGING_MODE) fwrite($debug_to_file_resource, "Set ini. arr.(s) and opened tdb class\n");
if(!($cat_id = (getID("./db/cat")+1))) die("Unable to retrieve Category IDs");
if(DEBUGGING_MODE) fwrite($debug_to_file_resource, "Retrieved last CAT ID:".$cat_id."\n");
$permcats = explode("\n", file_get_contents("./db/permcats.dat"));
if(empty($permcats)) { //if($permcats[0] != "") {
$pCats = array();
for($i=0;$i<count($permcats);$i++) {
list($c_id, $user_id) = explode(",", $permcats[$i]);
$pCats[$c_id] = $user_id;
}
}
for($id=1;$id<$cat_id;$id++) {
if(FALSE !== ($rec = get($id, "./db/cat"))) {
$cId = $rec["id"];
$_TRANSFER["cats"]["sort"]["old"][$cId] = explode(",", $rec["sort"]);
unset($rec["id"], $rec["sort"]);
if(!empty($pCats[$cId])) $rec["view"] = $pCats[$cId];
else $rec["view"] = 0;
$_TRANSFER["cats"][$cId] = $tdb->add("cats", $rec);
$_TRANSFER["cats"]["sort"]["new"][$cId] = array();
unset($cId);
}
unset($rec);
}
if(DEBUGGING_MODE) fwrite($debug_to_file_resource, "retrieved category list and sort:".var_dump($_TRANSFER['cats']['sort']['old'])."\n");
$tdb->setFp("config", "config");
$admin_catagory_sorting = $tdb->get("config", 8);
$cSorting = explode(",", $admin_catagory_sorting[0]["value"]);
$nSort = array();
for($i=0;$i<count($cSorting);$i++) {
if($_TRANSFER["cats"][$cSorting[$i]] != "") $nSort[$i] = $_TRANSFER["cats"][$cSorting[$i]];
}
$newSorting = implode(",", $nSort);
$tdb->setFp("config", "config");
$tdb->setFp('ext_config', 'ext_config');
//the version stored in here is for the footer, not for update
$tdb->edit("config", 1, array("value" => "2.0 BETA 1"), false);
$tdb->edit("ext_config", 1, array("value" => "2.0 BETA 1"), false);
$tdb->edit("config", 8, array("value" => $newSorting));
$tdb->edit("ext_config", 8, array("value" => $newSorting));
$permforum = file("./db/permforums.dat");
$pForum = array();
if(empty($permforum)) { //if($permforum[0] != "") {
for($i=0; $i<count($permforum); $i++) {
$temp = explode(",", $permforum[$i]);
$pForum[$temp[0]] = $temp[1];
}
}
if(DEBUGGING_MODE) fwrite($debug_to_file_resource, "Received Permissions for forums file:".var_dump($pForum)."\n");
$fAll = listall("./db/forum");
$ending = array();
$count = array();
for($i=0, $fMax=count($fAll);$i<$fMax;$i++) {
$fRec = def($fAll[$i], "./db/forum");
if($fRec["id"] != "") {
$fId = $fRec["id"];
unset($fRec["id"]);
$count[$fId]["topics"] = 0;
$count[$fId]["posts"] = 0;
unset($fRec["topics"], $fRec["posts"]);
if($_TRANSFER["cats"][$fRec["cat"]] != "") {
$trans = $fRec["cat"];
if(!empty($pForum[$fId])) {
$fRec["view"] = $pForum[$fId];
$fRec["post"] = $pForum[$fId];
$fRec["reply"] = $pForum[$fId];
} else {
$fRec["view"] = "0";
$fRec["post"] = "1";
$fRec["reply"] = "1";
}
$fRec["cat"] = $_TRANSFER["cats"][$fRec["cat"]];
if(!is_array($fRec)) die("<b>Error</b>: \$fRec[".$fId."] needs to be an array in function: \$this->add(\"forums\", \$fRec[".$fId."]) on line <b>245</b>");
$_TRANSFER["forums"][$fId] = $tdb->add("forums", $fRec);
$_TPosts["tdb"]->createTable($_TRANSFER["forums"][$fId], array(
array("icon", "string", 10),
array("user_name", "string", 20),
array("date", "number", 14),
array("message", "memo"),
array("user_id", "number", 7),
array("t_id", "number", 7),
array('edited_by', 'string', 20),
array('edited_by_id', 'number', 7),
array('edited_date', 'number', 14),
array("id", "id")
));
$_TPosts["tdb"]->createTable($_TRANSFER["forums"][$fId]."_topics", array(
array("icon", "string", 10),
array("subject", "memo"),
array("topic_starter", "string", 20),
array("sticky", "number", 1),
array("replies", "number", 9),
array("locked", "number", 1),
array("views", "number", 7),
array("last_post", "number", 14),
array("user_name", "string", 20),
array("user_id", "number", 7),
array("monitor", "memo"),
array("p_ids", "memo"),
array("id", "id")
), 30);
$_TPosts["fId"][] = $fId;
$_TPosts["p_ids"][$fId] = array();
$boolean = false;
reset($_TRANSFER["cats"]["sort"]["old"][$trans]);
while(list($key, $val) = each($_TRANSFER["cats"]["sort"]["old"][$trans])) {
// $val = Forum Id; $key = Forums' Order;
if($val == $fId) {
$_TRANSFER["cats"]["sort"]["new"][$trans][$key] = $_TRANSFER["forums"][$fId];
$boolean = true;
break 1;
}
}
if(!($boolean)) {
$errorHandler->add_cError(E_USER_NOTICE, "<i>Mismatching Variables</i>: The forum ".$fRec["forum"]."(ID ".$fId.") Belongs in Category ID ".$fRec["cat"].", but wasn't found in FORUM_SORT. This forum will be added to the end of FORUM_SORT");
if($ending[$fRec["cat"]]["old"] != "") $ending[$fRec["cat"]]["forums"][] = $fId;
else $ending = array($fRec["cat"] => array("old" => $trans, "forums" => array($fId)));
}
unset($trans, $boolean, $fId);
} else {
$errorHandler->add_cError(E_USER_WARNING, "<b>Unexpected Error</b>(step $step): Unavailable CAT TRANSFER ID available for: CAT #".$fRec["cat"]);
}
} else {
$errorHandler->add_error(E_PARSE,"(step $step) The $i forum record couldn't be parsed<br>");
$errorHandler->print_errors();
exit;
}
}
if(DEBUGGING_MODE) fwrite($debug_to_file_resource, "Converted Forums over... \$_TRANSFER['cats'] = ".var_dump($_TRANSFER['cats'])." and \$_TRANSFER['forums'] = ".var_dump($_TRANSFER['forums'])."\n");
foreach($ending as $missing) {
for($i=0;$i<count($missing["forums"]);$i++) {
$_TRANSFER["cats"]["sort"]["new"][$missing["old"]][] = $missing["forums"][$i];
}
}
for($i=0;$i<$cat_id;$i++) {
$trans = "";
if(!empty($_TRANSFER["cats"]["sort"]["new"][$i])) {
ksort($_TRANSFER["cats"]["sort"]["new"][$i]);
$trans = implode(",", $_TRANSFER["cats"]["sort"]["new"][$i]);
$tdb->edit("cats", $_TRANSFER["cats"][$i], array("sort" => $trans));
} elseif(!empty($_TRANSFER["cats"][$i])) {
$errorHandler->add_cError(E_USER_NOTICE, "Could not find FORUM_SORT for category ".$_TRANSFER["cats"][$i].". Forums in this Category will be sorted by ALPHA_NUMERIC");
}
unset($trans);
}
unset($_TRANSFER["cats"], $id);
if(DEBUGGING_MODE) fwrite($debug_to_file_resource, "Updated FORUM_SORT for category. Now commencing Topic and Posts conversion.\n");
$fcount = count($_TPosts["fId"]);
foreach($_TPosts["fId"] as $fId) {
if(!(file_exists("./db/".$fId."_sorted.dat") || is_dir("./db/".$fId))) {
$errorHandler->add_cError(E_USER_WARNING, "<b><font color=red>*</font></b> Unable to update forum:$fId. Topics and/or Posts are missing");
} else {
$_TPosts["tdb"]->setFp("CuTopic", $_TRANSFER["forums"][$fId]."_topics");
$_TPosts["tdb"]->setFp("CuPost", $_TRANSFER["forums"][$fId]);
//$rebuild = false;
$tAll = array_reverse(listall("./db/".$fId."_sorted"));
$tCount = count($tAll);
$count[$fId]["topics"] = $tCount;
for($i=0;$i<$tCount;$i++) {
if(empty($tAll[$i])) continue;
$tRec = def($tAll[$i], "./db/p_forum");
if(empty($tRec)) continue;
$tId = $tRec["id"];
unset($tRec["id"]);
if(substr($tRec["subject"], 0, 7) != "MOVED: " && file_exists('./db/'.$fId.'/'.$tId.'.dat')) {
$tRec["last_post"] = convertTimeString($tRec["last_post"], '', $ratio);
if(strpos($tRec["subject"], "[Sticky Note]")) {
$tRec["sticky"] = 1;
$tRec["subject"] = str_replace("[Sticky Note]", "", $tRec["subject"]);
} else $tRec["sticky"] = 0;
if(!is_writable("./db/".$fId."/".$tId.".dat")) $tRec["locked"] = 1;
else $tRec["locked"] = 0;
$tRec["topic_starter"] = $tRec["user"];
$tRec["views"] = 0;
if($tRec["icon"] == "no_icon.gif") $tRec["icon"] = "noicon.gif";
$newId = $_TPosts["tdb"]->add("CuTopic", $tRec);
$pAll = listall("./db/$fId/".$tId);
$pCount = count($pAll);
if(!(empty($pAll[0]) && $pCount == 1)) {
$count[$fId]["posts"] = $count[$fId]["posts"] + count($pAll);
for($k=0;$k<$pCount;$k++) {
if(!empty($pAll[$k])) {
$pRec = def($pAll[$k], "./db/p_topic");
if(!empty($pRec["id"])) {
unset($pRec["id"]);
$pRec["message"] = undo_format($pRec["message"]);
$pRec["date"] = convertTimeString($pRec["date"], '', $ratio);
if($pRec["icon"] = "no_icon.gif") $pRec["icon"] = "noicon.gif";
$pRec["t_id"] = $newId;
$_TPosts["p_ids"][$fId][$newId][] = $_TPosts["tdb"]->add("CuPost", $pRec);
unset($pRec);
} else {
$count[$fId]["posts"] = $count[$fId]["posts"] - 1;
$errorHandler->add_cError(E_PARSE, "Parsing Errors for the ".$k.numberEnding($k+1)." post of topic ".$tId." of forum $fId.");
}
} else $count[$fId]["posts"] = $count[$fId]["posts"] - 1;
}
} else {
$count[$fId]["topics"] = $count[$fId]["topics"] - 1;
sleep(1);
$_TPosts["tdb"]->delete("CuTopic", $tId, false);
//$rebuild = true;
$errorHandler->add_cError(E_USER_WARNING, "No Posts found in <b>".$tRec["subject"]."(ID ".$tId.")</b> of forum ".$fId.".This could be because there are corrupted files. <b>The Topic was deleted.</b>");
}
} else {
$count[$fId]["topics"] = $count[$fId]["topics"] - 1;
}
unset($newId, $pAll, $pRec, $tRec);
}
//if($rebuild) $_TPosts["tdb"]->reBuild("CuTopic"); //Rebuld obsolete in tdb4.4
unset($tAll);
}
unset($fId);
}
if(DEBUGGING_MODE) fwrite($debug_to_file_resource, "Finished Topic and Posts Conversion\n");
while(list($fId, $edit) = each($count)) {
$tdb->edit("forums", $_TRANSFER["forums"][$fId], $edit);
}
foreach($_TPosts["p_ids"] as $fId => $arr1) {
$_TPosts["tdb"]->setFp("CuTopic", $_TRANSFER["forums"][$fId]."_topics");
reset($arr1);
while(list($tId, $arr2) = each($arr1)) {
$_TPosts["tdb"]->edit("CuTopic", $tId, array("p_ids" => implode(",", $arr2)));
}
}
if(DEBUGGING_MODE) fwrite($debug_to_file_resource, "Updated topic/post count in forums and saved p_ids to topics. Step 4 is complete\n");
if($errorHandler->return_howmany() != 0) $error_finish = "<b>Unable to transfer topics and posts to new database.</b>";
$finish = "Transfering categories, forums, topics, and posts to new database...Done!";
} elseif($step == 5) {
//Preparing Topics & pm for use by Sorting them
//Calculating the dimensions of users' avatars
echo '<p><IFRAME SRC="./includes/class/mod_avatar.class.php?self_execute=all" WIDTH="100%" HEIGHT="300">Please visit <a href="./includes/class/mod_avatar.class.php?self_execute=all" target="_blank">this page</a> to calculate avatars\' dimensions.</IFRAME></p>';
require_once('./includes/class/tdb.class.php');
$posts = new tdb("./db/", "posts.tdb");
$tables1 = $posts->getTableList();
foreach($tables1 as $table) {
if(substr($table, -7) == "_topics") {
$posts->setFp("topic", $table);
$posts->sortAndBuild("topic", "last_post", "DESC");
}
}
$privmsg = new tdb("./db/", "privmsg.tdb");
$tables2 = $privmsg->getTableList();
foreach($tables2 as $table) {
$privmsg->setFp("pm", $table);
$privmsg->sortAndBuild("pm", "date", "DESC");