forked from fisharebest/webtrees
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_pgv_to_wt.php
1059 lines (992 loc) · 47.9 KB
/
admin_pgv_to_wt.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
// PGV to webtrees transfer wizard
//
// webtrees: Web based Family History software
// Copyright (C) 2013 webtrees development team.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
define('WT_SCRIPT_NAME', 'admin_pgv_to_wt.php');
require './includes/session.php';
//require WT_ROOT.'includes/functions/functions_edit.php';
// We can only import into an empty system, so deny access if we have already created a gedcom or added users.
if (WT_GED_ID || get_user_count()>1) {
header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH);
exit;
}
$controller=new WT_Controller_Page();
$controller
->requireAdminLogin()
->setPageTitle(WT_I18N::translate('PhpGedView to webtrees transfer wizard'));
$error = '';
$warning = '';
$PGV_PATH = WT_Filter::post('PGV_PATH');
if ($PGV_PATH) {
if (!is_dir($PGV_PATH) || !is_readable($PGV_PATH.'/config.php')) {
$error=WT_I18N::translate('The specified directory does not contain an installation of PhpGedView');
} else {
// Load the configuration settings
$config_php=file_get_contents($PGV_PATH.'/config.php');
// The easiest way to do this is to exec() the file - but not lines containing require or PHP tags
$config_php=preg_replace(
array(
'/^\s*(include|require).*/m',
'/.*<\?php.*/',
'/.*\?>.*/'
), '', $config_php
);
eval($config_php);
// $INDEX_DIRECTORY can be either absolute or relative to the PhpGedView root.
if (preg_match('/^(\/|\\|[A-Z]:)/', $INDEX_DIRECTORY)) {
$INDEX_DIRECTORY=realpath($INDEX_DIRECTORY);
} else {
$INDEX_DIRECTORY=realpath($PGV_PATH.'/'.$INDEX_DIRECTORY);
}
$wt_config=parse_ini_file(WT_ROOT.'data/config.ini.php');
if ($DBHOST!=$wt_config['dbhost']) {
$error=WT_I18N::translate('PhpGedView must use the same database as <b>webtrees</b>');
unset($wt_config);
} else {
unset($wt_config);
try {
$PGV_SCHEMA_VERSION=WT_DB::prepare(
"SELECT site_setting_value FROM `{$DBNAME}`.`{$TBLPREFIX}site_setting` WHERE site_setting_name='PGV_SCHEMA_VERSION'"
)->fetchOne();
if ($PGV_SCHEMA_VERSION<10) {
$error=WT_I18N::translate('The version of %s is too old', 'PhpGedView');
} elseif ($PGV_SCHEMA_VERSION>14) {
$error=WT_I18N::translate('The version of %s is too new', 'PhpGedView');
}
} catch (PDOException $ex) {
$error=
/* I18N: %s is a database name/identifier */
WT_I18N::translate('<b>webtrees</b> cannot connect to the PhpGedView database: %s.', $DBNAME.'@'.$DBHOST).
'<br>'.
/* I18N: %s is an error message */
WT_I18N::translate('MySQL gave the error: %s', $ex->getMessage());
}
}
}
}
if ($PGV_PATH && !$error) {
// The account we are using is about to be deleted.
$WT_SESSION->wt_user = null;
}
$controller->pageHeader();
echo
'<style type="text/css">
#container {width: 70%; margin:15px auto; border: 1px solid gray; padding: 10px;}
#container dl {margin:0 0 40px 25px;}
#container dt {display:inline; width: 320px; font-weight:normal; margin: 0 0 15px 0;}
#container dd {color: #81A9CB; margin-bottom:20px;font-weight:bold;}
#container p {color: #81A9CB; font-size: 14px; font-style: italic; font-weight:bold; padding: 0 5px 5px; align: top;}
h2 {color: #81A9CB;}
.good {color: green;}
.bad {color: red !important;}
.indifferent {color: blue;}
#container p.pgv {color: black; font-size: 12px; font-style: normal; font-weight:normal; padding:0; margin:10px 0 0 320px}
</style>';
if ($error || !$PGV_PATH) {
// Prompt for location of PhpGedView installation
echo '<div id="container">';
echo
'<h2>',
WT_I18N::translate('PhpGedView to <b>webtrees</b> transfer wizard'),
help_link('PGV_WIZARD'),
'</h2>';
if ($error) {
echo '<p class="bad">', $error, '</p>';
}
// Look for PGV in some nearby directories
$pgv_dirs=array();
$dir=opendir(realpath('..'));
while (($subdir=readdir($dir))!==false) {
if (is_dir('../'.$subdir) && file_exists('../'.$subdir.'/config.php')) {
$pgv_dirs[]='../'.$subdir;
}
}
closedir($dir);
echo
'<form action="', WT_SCRIPT_NAME, '" method="post">',
'<p>', WT_I18N::translate('Where is your PhpGedView installation?'), '</p>',
'<dl>',
'<dt>',WT_I18N::translate('Installation directory'), '</dt>';
switch (count($pgv_dirs)) {
case '0':
echo '<dd><input type="text" name="PGV_PATH" size="40" value="" autofocus></dd>';
break;
case '1':
echo '<dd><input type="text" name="PGV_PATH" size="40" value="'.WT_Filter::escapeHtml($pgv_dirs[0]).'" autofocus></dd>';
break;
default:
echo '<dd><input type="text" name="PGV_PATH" size="40" value="" autofocus></dd>';
echo '<dt>', /* find better english before translating */ 'PhpGedView might be found in these locations', '</dt>';
echo '<dd>';
foreach ($pgv_dirs as $pgvpath) {
echo '<p class="pgv">', $pgvpath, '</p>';
}
echo '</dd>';
break;
}
echo
'</dl>',
'<div class="center"><input type="submit" value="'.WT_I18N::translate('next').'"></div>',
'</form>',
'</div>';
exit;
}
// Run in a transaction
WT_DB::exec("START TRANSACTION");
// Delete the existing user accounts, and any information associated with it
WT_DB::exec("UPDATE `##log` SET user_id=NULL");
WT_DB::exec("DELETE FROM `##change`");
WT_DB::exec("DELETE `##block_setting` FROM `##block_setting` JOIN `##block` USING (block_id) WHERE user_id>0 OR gedcom_id>0");
WT_DB::exec("DELETE FROM `##block` WHERE user_id>0 OR gedcom_id>0");
WT_DB::exec("DELETE FROM `##message`");
WT_DB::exec("DELETE FROM `##user_gedcom_setting` WHERE user_id>0");
WT_DB::exec("DELETE FROM `##user_setting` WHERE user_id>0");
WT_DB::exec("DELETE FROM `##user` WHERE user_id>0");
////////////////////////////////////////////////////////////////////////////////
if (ob_get_level() == 0) ob_start();
echo '<p>', $INDEX_DIRECTORY, DIRECTORY_SEPARATOR, 'config.php => wt_site_setting ...</p>';
flush();
if (ini_get('output_buffering')) {
ob_flush();
}
// TODO May need to set 'DATA_DIRECTORY' to $INDEX_DIRECTORY when dealing with media??
@WT_Site::preference('USE_REGISTRATION_MODULE', $USE_REGISTRATION_MODULE);
@WT_Site::preference('REQUIRE_ADMIN_AUTH_REGISTRATION', $REQUIRE_ADMIN_AUTH_REGISTRATION);
@WT_Site::preference('ALLOW_USER_THEMES', $ALLOW_USER_THEMES);
@WT_Site::preference('ALLOW_CHANGE_GEDCOM', $ALLOW_CHANGE_GEDCOM);
@WT_Site::preference('SESSION_TIME', $PGV_SESSION_TIME);
@WT_Site::preference('SMTP_ACTIVE', $PGV_SMTP_ACTIVE ? 'external' : 'internal');
@WT_Site::preference('SMTP_HOST', $PGV_SMTP_HOST);
@WT_Site::preference('SMTP_HELO', $PGV_SMTP_HELO);
@WT_Site::preference('SMTP_PORT', $PGV_SMTP_PORT);
@WT_Site::preference('SMTP_AUTH', $PGV_SMTP_AUTH);
@WT_Site::preference('SMTP_AUTH_USER', $PGV_SMTP_AUTH_USER);
@WT_Site::preference('SMTP_AUTH_PASS', $PGV_SMTP_AUTH_PASS);
@WT_Site::preference('SMTP_SSL', $PGV_SMTP_SSL);
@WT_Site::preference('SMTP_FROM_NAME', $PGV_SMTP_FROM_NAME);
////////////////////////////////////////////////////////////////////////////////
echo '<p>pgv_site_setting => wt_site_setting ...</p>';
flush();
if (ini_get('output_buffering')) {
ob_flush();
}
WT_DB::prepare(
"REPLACE INTO `##site_setting` (setting_name, setting_value)".
" SELECT site_setting_name, site_setting_value FROM `{$DBNAME}`.`{$TBLPREFIX}site_setting`".
" WHERE site_setting_name IN ('DEFAULT_GEDCOM', 'LAST_CHANGE_EMAIL')"
)->execute();
////////////////////////////////////////////////////////////////////////////////
if ($PGV_SCHEMA_VERSION>=12) {
echo '<p>pgv_gedcom => wt_gedcom ...</p>';
flush();
if (ini_get('output_buffering')) {
ob_flush();
}
WT_DB::prepare(
"INSERT INTO `##gedcom` (gedcom_id, gedcom_name)".
" SELECT gedcom_id, gedcom_name FROM `{$DBNAME}`.`{$TBLPREFIX}gedcom`"
)->execute();
echo '<p>pgv_gedcom_setting => wt_gedcom_setting ...</p>';
flush();
if (ini_get('output_buffering')) {
ob_flush();
}
WT_DB::prepare(
"INSERT INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value)".
" SELECT gedcom_id, setting_name,".
" CASE setting_name".
" WHEN 'THEME_DIR' THEN".
" CASE setting_value".
" WHEN '' THEN ''".
" WHEN 'themes/cloudy/' THEN 'clouds'".
" WHEN 'themes/minimal/' THEN 'minimal'".
" WHEN 'themes/simplyblue/' THEN 'colors'".
" WHEN 'themes/simplygreen/' THEN 'colors'".
" WHEN 'themes/simplyred/' THEN 'colors'".
" WHEN 'themes/xenea/' THEN 'xenea'".
" ELSE 'themes/webtrees/'". // ocean, simplyred/blue/green, standard, wood
" END".
" WHEN 'LANGUAGE' THEN".
" CASE setting_value".
" WHEN 'catalan' THEN 'ca'".
" WHEN 'english' THEN 'en_US'".
" WHEN 'english-uk' THEN 'en_GB'". // PGV had the config for en_GB, but no language files
" WHEN 'polish' THEN 'pl'".
" WHEN 'italian' THEN 'it'".
" WHEN 'spanish' THEN 'es'".
" WHEN 'finnish' THEN 'fi'".
" WHEN 'french' THEN 'fr'".
" WHEN 'german' THEN 'de'".
" WHEN 'danish' THEN 'da'".
" WHEN 'portuguese' THEN 'pt'".
" WHEN 'hebrew' THEN 'he'".
" WHEN 'estonian' THEN 'et'".
" WHEN 'turkish' THEN 'tr'".
" WHEN 'dutch' THEN 'nl'".
" WHEN 'slovak' THEN 'sk'".
" WHEN 'norwegian' THEN 'nn'".
" WHEN 'slovenian' THEN 'sl'".
" WHEN 'hungarian' THEN 'hu'".
" WHEN 'swedish' THEN 'sv'".
" WHEN 'russian' THEN 'ru'".
" ELSE 'en_US'". // PGV supports other languages that webtrees does not (yet)
" END".
" ELSE setting_value".
" END".
" FROM `{$DBNAME}`.`{$TBLPREFIX}gedcom_setting`".
" WHERE setting_name NOT IN ('HOME_SITE_TEXT', 'HOME_SITE_URL')"
)->execute();
echo '<p>pgv_user => wt_user ...</p>';
flush();
if (ini_get('output_buffering')) {
ob_flush();
}
try {
// "INSERT IGNORE" is needed to allow for PGV users with duplicate emails. Only the first will be imported.
WT_DB::prepare(
"INSERT IGNORE INTO `##user` (user_id, user_name, real_name, email, password)".
" SELECT user_id, user_name, CONCAT_WS(' ', us1.setting_value, us2.setting_value), us3.setting_value, password FROM `{$DBNAME}`.`{$TBLPREFIX}user`".
" LEFT JOIN `{$DBNAME}`.`{$TBLPREFIX}user_setting` us1 USING (user_id)".
" LEFT JOIN `{$DBNAME}`.`{$TBLPREFIX}user_setting` us2 USING (user_id)".
" JOIN `{$DBNAME}`.`{$TBLPREFIX}user_setting` us3 USING (user_id)".
" WHERE us1.setting_name='firstname'".
" AND us2.setting_name='lastname'".
" AND us3.setting_name='email'"
)->execute();
} catch (PDOException $ex) {
// Ignore duplicates
}
echo '<p>pgv_user_setting => wt_user_setting ...</p>';
flush();
if (ini_get('output_buffering')) {
ob_flush();
}
WT_DB::prepare(
"INSERT INTO `##user_setting` (user_id, setting_name, setting_value)".
" SELECT user_id, setting_name,".
" CASE setting_name".
" WHEN 'language' THEN ".
" CASE setting_value".
" WHEN 'catalan' THEN 'ca'".
" WHEN 'english' THEN 'en_US'".
" WHEN 'english-uk' THEN 'en_GB'". // PGV had the config for en_GB, but no language files
" WHEN 'polish' THEN 'pl'".
" WHEN 'italian' THEN 'it'".
" WHEN 'spanish' THEN 'es'".
" WHEN 'finnish' THEN 'fi'".
" WHEN 'french' THEN 'fr'".
" WHEN 'german' THEN 'de'".
" WHEN 'danish' THEN 'da'".
" WHEN 'portuguese' THEN 'pt'".
" WHEN 'hebrew' THEN 'he'".
" WHEN 'estonian' THEN 'et'".
" WHEN 'turkish' THEN 'tr'".
" WHEN 'dutch' THEN 'nl'".
" WHEN 'slovak' THEN 'sk'".
" WHEN 'norwegian' THEN 'nn'".
" WHEN 'slovenian' THEN 'sl'".
" WHEN 'hungarian' THEN 'hu'".
" WHEN 'swedish' THEN 'sv'".
" WHEN 'russian' THEN 'ru'".
" ELSE 'en_US'". // PGV supports other languages that webtrees does not (yet)
" END".
" WHEN 'theme' THEN".
" CASE setting_value".
" WHEN '' THEN ''".
" WHEN 'themes/cloudy/' THEN 'clouds'".
" WHEN 'themes/minimal/' THEN 'minimal'".
" WHEN 'themes/simplyblue/' THEN 'colors'".
" WHEN 'themes/simplygreen/' THEN 'colors'".
" WHEN 'themes/simplyred/' THEN 'colors'".
" WHEN 'themes/xenea/' THEN 'xenea'".
" ELSE 'themes/webtrees/'". // ocean, simplyred/blue/green, standard, wood
" END".
" ELSE".
" CASE".
" WHEN setting_value IN ('Y', 'yes') THEN 1 WHEN setting_value IN ('N', 'no') THEN 0 ELSE setting_value END".
" END".
" FROM `{$DBNAME}`.`{$TBLPREFIX}user_setting`".
" JOIN `##user` USING (user_id)".
" WHERE setting_name NOT IN ('email', 'firstname', 'lastname', 'loggedin')"
)->execute();
echo '<p>pgv_user_gedcom_setting => wt_user_gedcom_setting ...</p>';
flush();
if (ini_get('output_buffering')) {
ob_flush();
}
WT_DB::prepare(
"INSERT INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value)".
" SELECT user_id, gedcom_id, setting_name, setting_value FROM `{$DBNAME}`.`{$TBLPREFIX}user_gedcom_setting`".
" JOIN `##user` USING (user_id)"
)->execute();
} else {
// Copied from PGV's db_schema_11_12
if (file_exists("{$INDEX_DIRECTORY}/gedcoms.php")) {
require_once "{$INDEX_DIRECTORY}/gedcoms.php";
$file=$INDEX_DIRECTORY.'/gedcoms.php';
echo '<p>', $file, ' => wt_gedcom ...</p>';
flush();
if (ini_get('output_buffering')) {
ob_flush();
}
if (isset($GEDCOMS) && is_array($GEDCOMS)) {
foreach ($GEDCOMS as $array) {
try {
WT_DB::prepare("INSERT INTO `##gedcom` (gedcom_id, gedcom_name) VALUES (?,?)")
->execute(array($array['id'], $array['gedcom']));
} catch (PDOException $ex) {
// Ignore duplicates
}
// insert gedcom
foreach ($array as $key=>$value) {
if ($key!='id' && $key!='gedcom' && $key!='commonsurnames') {
try {
WT_DB::prepare("INSERT INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value) VALUES (?,?, ?)")
->execute(array($array['id'], $key, $value));
} catch (PDOException $ex) {
// Ignore duplicates
}
}
}
}
}
}
// Migrate the data from pgv_users into pgv_user/pgv_user_setting/pgv_user_gedcom_setting
echo '<p>pgv_users => wt_user ...</p>';
flush();
if (ini_get('output_buffering')) {
ob_flush();
}
try {
// "INSERT IGNORE" is needed to allow for PGV users with duplicate emails. Only the first will be imported.
WT_DB::prepare(
"INSERT IGNORE INTO `##user` (user_name, real_name, email, password)".
" SELECT u_username, CONCAT_WS(' ', u_firstname, u_lastname), u_email, u_password FROM `{$DBNAME}`.`{$TBLPREFIX}users`"
)->execute();
} catch (PDOException $ex) {
// This could only fail if;
// a) we've already done it (upgrade)
// b) it doesn't exist (new install)
}
echo '<p>pgv_users => wt_user_setting ...</p>';
flush();
if (ini_get('output_buffering')) {
ob_flush();
}
try {
WT_DB::prepare(
"INSERT INTO `##user_setting` (user_id, setting_name, setting_value)".
" SELECT user_id, 'canadmin', ".
" CASE WHEN u_canadmin IN ('Y', 'yes') THEN 1 WHEN u_canadmin IN ('N', 'no') THEN 0 ELSE u_canadmin END".
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`".
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)".
" UNION ALL".
" SELECT user_id, 'verified', ".
" CASE WHEN u_verified IN ('Y', 'yes') THEN 1 WHEN u_verified IN ('N', 'no') THEN 0 ELSE u_verified END".
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`".
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)".
" UNION ALL".
" SELECT user_id, 'verified_by_admin', ".
" CASE WHEN u_verified_by_admin IN ('Y', 'yes') THEN 1 WHEN u_verified_by_admin IN ('N', 'no') THEN 0 ELSE u_verified_by_admin END".
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`".
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)".
" UNION ALL".
" SELECT user_id, 'language', ".
" CASE u_language".
" WHEN 'catalan' THEN 'ca'".
" WHEN 'english' THEN 'en_US'".
" WHEN 'english-uk' THEN 'en_GB'". // PGV had the config for en_GB, but no language files
" WHEN 'polish' THEN 'pl'".
" WHEN 'italian' THEN 'it'".
" WHEN 'spanish' THEN 'es'".
" WHEN 'finnish' THEN 'fi'".
" WHEN 'french' THEN 'fr'".
" WHEN 'german' THEN 'de'".
" WHEN 'danish' THEN 'da'".
" WHEN 'portuguese' THEN 'pt'".
" WHEN 'hebrew' THEN 'he'".
" WHEN 'estonian' THEN 'et'".
" WHEN 'turkish' THEN 'tr'".
" WHEN 'dutch' THEN 'nl'".
" WHEN 'slovak' THEN 'sk'".
" WHEN 'norwegian' THEN 'nn'".
" WHEN 'slovenian' THEN 'sl'".
" WHEN 'hungarian' THEN 'hu'".
" WHEN 'swedish' THEN 'sv'".
" WHEN 'russian' THEN 'ru'".
" ELSE 'en_US'". // PGV supports other languages that webtrees does not (yet)
" END".
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`".
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)".
" UNION ALL".
" SELECT user_id, 'pwrequested', ".
" CASE WHEN u_pwrequested IN ('Y', 'yes') THEN 1 WHEN u_pwrequested IN ('N', 'no') THEN 0 ELSE u_pwrequested END".
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`".
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)".
" UNION ALL".
" SELECT user_id, 'reg_timestamp', u_reg_timestamp".
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`".
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)".
" UNION ALL".
" SELECT user_id, 'reg_hashcode', u_reg_hashcode".
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`".
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)".
" UNION ALL".
" SELECT user_id, 'theme', ".
" CASE u_theme".
" WHEN '' THEN ''".
" WHEN 'themes/cloudy/' THEN 'clouds'".
" WHEN 'themes/minimal/' THEN 'minimal'".
" WHEN 'themes/simplyblue/' THEN 'colors'".
" WHEN 'themes/simplygreen/' THEN 'colors'".
" WHEN 'themes/simplyred/' THEN 'colors'".
" WHEN 'themes/xenea/' THEN 'xenea'".
" ELSE 'themes/webtrees/'". // ocean, simplyred/blue/green, standard, wood
" END".
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`".
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)".
" UNION ALL".
" SELECT user_id, 'sessiontime', u_sessiontime".
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`".
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)".
" UNION ALL".
" SELECT user_id, 'contactmethod', u_contactmethod".
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`".
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)".
" UNION ALL".
" SELECT user_id, 'visibleonline', ".
" CASE WHEN u_visibleonline IN ('Y', 'yes') THEN 1 WHEN u_visibleonline IN ('N', 'no') THEN 0 ELSE u_visibleonline END".
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`".
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)".
" UNION ALL".
" SELECT user_id, 'editaccount', ".
" CASE WHEN u_editaccount IN ('Y', 'yes') THEN 1 WHEN u_editaccount IN ('N', 'no') THEN 0 ELSE u_editaccount END".
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`".
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)".
" UNION ALL".
" SELECT user_id, 'comment', u_comment".
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`".
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)".
" UNION ALL".
" SELECT user_id, 'relationship_privacy', ".
" CASE WHEN u_relationship_privacy IN ('Y', 'yes') THEN 1 WHEN u_relationship_privacy IN ('N', 'no') THEN 0 ELSE u_relationship_privacy END".
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`".
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)".
" UNION ALL".
" SELECT user_id, 'max_relation_path', u_max_relation_path".
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`".
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)".
" UNION ALL".
" SELECT user_id, 'auto_accept', ".
" CASE WHEN u_auto_accept IN ('Y', 'yes') THEN 1 WHEN u_auto_accept IN ('N', 'no') THEN 0 ELSE u_auto_accept END".
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`".
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)"
)->execute();
} catch (PDOException $ex) {
// This could only fail if;
// a) we've already done it (upgrade)
// b) it doesn't exist (new install)
}
// Some PGV installations store the u_reg_timestamp in the format "2010-03-07 21:41:07"
WT_DB::prepare(
"UPDATE `##user_setting` SET setting_value=UNIX_TIMESTAMP(setting_value) WHERE setting_name='reg_timestamp' AND setting_value LIKE '____-__-__ __:__:__'"
)->execute();
// Some PGV installations have empty/invalid values for reg_timestamp
WT_DB::prepare(
"UPDATE `##user_setting` SET setting_value=CAST(setting_value AS UNSIGNED) WHERE setting_name='reg_timestamp'"
)->execute();
echo '<p>pgv_users => wt_user_gedcom_setting ...</p>';
flush();
if (ini_get('output_buffering')) {
ob_flush();
}
$user_gedcom_settings=
WT_DB::prepare(
"SELECT user_id, u_gedcomid, u_rootid, u_canedit".
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`".
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)"
)->fetchAll();
foreach ($user_gedcom_settings as $setting) {
@$array=unserialize($setting->u_gedcomid);
if (is_array($array)) {
foreach ($array as $gedcom=>$value) {
try {
WT_DB::prepare(
"INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, ?)"
)->execute(array($setting->user_id, get_id_from_gedcom($gedcom), 'gedcomid', $value));
} catch (PDOException $ex) {
// Invalid data? Reference to non-existing tree?
}
}
}
@$array=unserialize($setting->u_rootid);
if (is_array($array)) {
foreach ($array as $gedcom=>$value) {
try {
WT_DB::prepare(
"INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, ?)"
)->execute(array($setting->user_id, get_id_from_gedcom($gedcom), 'rootid', $value));
} catch (PDOException $ex) {
// Invalid data? Reference to non-existing tree?
}
}
}
@$array=unserialize($setting->u_canedit);
if (is_array($array)) {
foreach ($array as $gedcom=>$value) {
try {
WT_DB::prepare(
"INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, ?)"
)->execute(array($setting->user_id, get_id_from_gedcom($gedcom), 'canedit', $value));
} catch (PDOException $ex) {
// Invalid data? Reference to non-existing tree?
}
}
}
}
}
define('PGV_PHPGEDVIEW', true);
define('PGV_PRIV_PUBLIC', WT_PRIV_PUBLIC);
define('PGV_PRIV_USER', WT_PRIV_USER);
define('PGV_PRIV_NONE', WT_PRIV_NONE);
define('PGV_PRIV_HIDE', WT_PRIV_HIDE);
$PRIV_PUBLIC=WT_PRIV_PUBLIC;
$PRIV_USER=WT_PRIV_USER;
$PRIV_NONE=WT_PRIV_NONE;
$PRIV_HIDE=WT_PRIV_HIDE;
// Old versions of PGV used a $GEDCOMS[] array.
// New versions used a database.
$GEDCOMS=WT_DB::prepare(
"SELECT" .
" gedcom_id AS id," .
" gedcom_name AS gedcom," .
" gs1.setting_value AS config," .
" gs2.setting_value AS privacy" .
" FROM `##gedcom`" .
" JOIN `##gedcom_setting` AS gs1 USING (gedcom_id)" .
" JOIN `##gedcom_setting` AS gs2 USING (gedcom_id)" .
" WHERE gedcom_id>0" .
" AND gs1.setting_name='config'" .
" AND gs2.setting_name='privacy'"
)->fetchAll(PDO::FETCH_ASSOC);
foreach ($GEDCOMS as $GEDCOM=>$GED_DATA) {
$config=$GED_DATA['config'];
if ($PGV_SCHEMA_VERSION>=12) {
$config=str_replace('${INDEX_DIRECTORY}', $INDEX_DIRECTORY.DIRECTORY_SEPARATOR, $config);
} else {
$config=str_replace($INDEX_DIRECTORY, $INDEX_DIRECTORY.DIRECTORY_SEPARATOR, $config);
}
if (substr($config, 0, 1)=='.') {
$config=$PGV_PATH.'/'.$config;
}
if (is_readable($config)) {
echo '<p>Reading configuration file ', $config, '</p>';
require $config;
} else {
echo '<p>Error - could not read configuration file ', $config, '</p>';
}
$privacy=$GED_DATA['privacy'];
if ($PGV_SCHEMA_VERSION>=12) {
$privacy=str_replace('${INDEX_DIRECTORY}', $INDEX_DIRECTORY.DIRECTORY_SEPARATOR, $privacy);
} else {
$privacy=str_replace($INDEX_DIRECTORY, $INDEX_DIRECTORY.DIRECTORY_SEPARATOR, $privacy);
}
if (substr($config, 0, 1)=='.') {
$privacy=$PGV_PATH.'/'.$privacy;
}
if (is_readable($privacy)) {
echo '<p>Reading privacy file ', $privacy, '</p>';
require $privacy;
} else {
echo '<p>Could not read privacy file ', $privacy, '</p>';
}
$stmt_gedcom_setting=WT_DB::prepare("INSERT INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value) VALUES (?,?,?)");
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'ADVANCED_NAME_FACTS', $ADVANCED_NAME_FACTS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'ADVANCED_PLAC_FACTS', $ADVANCED_PLAC_FACTS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'ALLOW_THEME_DROPDOWN', $ALLOW_THEME_DROPDOWN));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'CALENDAR_FORMAT', $CALENDAR_FORMAT));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'CHART_BOX_TAGS', $CHART_BOX_TAGS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'COMMON_NAMES_ADD', $COMMON_NAMES_ADD));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'COMMON_NAMES_REMOVE', $COMMON_NAMES_REMOVE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'COMMON_NAMES_THRESHOLD', $COMMON_NAMES_THRESHOLD));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'CONTACT_USER_ID', get_user_id($CONTACT_EMAIL)));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'DEFAULT_PEDIGREE_GENERATIONS', $DEFAULT_PEDIGREE_GENERATIONS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'EXPAND_NOTES', $EXPAND_NOTES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'EXPAND_RELATIVES_EVENTS', $EXPAND_RELATIVES_EVENTS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'EXPAND_SOURCES', $EXPAND_SOURCES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'FAM_FACTS_ADD', $FAM_FACTS_ADD));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'FAM_FACTS_QUICK', $FAM_FACTS_QUICK));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'FAM_FACTS_UNIQUE', $FAM_FACTS_UNIQUE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'FAM_ID_PREFIX', $FAM_ID_PREFIX));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'FULL_SOURCES', $FULL_SOURCES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'GEDCOM_ID_PREFIX', $GEDCOM_ID_PREFIX));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'GENERATE_UIDS', $GENERATE_UIDS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'HIDE_GEDCOM_ERRORS', $HIDE_GEDCOM_ERRORS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'HIDE_LIVE_PEOPLE', $HIDE_LIVE_PEOPLE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'INDI_FACTS_ADD', $INDI_FACTS_ADD));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'INDI_FACTS_QUICK', $INDI_FACTS_QUICK));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'INDI_FACTS_UNIQUE', $INDI_FACTS_UNIQUE));
switch ($LANGUAGE) {
case 'catalan': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'ca')); break;
case 'english-uk': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'en_GB')); break;
case 'polish': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'pl')); break;
case 'italian': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'it')); break;
case 'spanish': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'es')); break;
case 'finnish': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'fi')); break;
case 'french': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'fr')); break;
case 'german': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'de')); break;
case 'danish': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'da')); break;
case 'portuguese': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'pt')); break;
case 'hebrew': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'he')); break;
case 'estonian': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'et')); break;
case 'turkish': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'tr')); break;
case 'dutch': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'nl')); break;
case 'slovak': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'sk')); break;
case 'norwegian': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'nn')); break;
case 'slovenian': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'sl')); break;
case 'hungarian': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'hu')); break;
case 'swedish': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'sv')); break;
case 'russian': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'ru')); break;
default: $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'en_US')); break;
}
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MAX_ALIVE_AGE', $MAX_ALIVE_AGE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MAX_DESCENDANCY_GENERATIONS', $MAX_DESCENDANCY_GENERATIONS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MAX_PEDIGREE_GENERATIONS', $MAX_PEDIGREE_GENERATIONS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MAX_RELATION_PATH_LENGTH', $MAX_RELATION_PATH_LENGTH));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MEDIA_DIRECTORY', 'media/'));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MEDIA_ID_PREFIX', $MEDIA_ID_PREFIX));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'META_DESCRIPTION', $META_DESCRIPTION));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'META_TITLE', $META_TITLE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MEDIA_UPLOAD', $MULTI_MEDIA)); // see schema v12-13
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'NOTE_FACTS_ADD', $NOTE_FACTS_ADD));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'NOTE_FACTS_QUICK', $NOTE_FACTS_QUICK));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'NOTE_FACTS_UNIQUE', $NOTE_FACTS_UNIQUE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'NOTE_ID_PREFIX', 'N'));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'NO_UPDATE_CHAN', $NO_UPDATE_CHAN));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'PEDIGREE_FULL_DETAILS', $PEDIGREE_FULL_DETAILS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'PEDIGREE_LAYOUT', $PEDIGREE_LAYOUT));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'PEDIGREE_ROOT_ID', $PEDIGREE_ROOT_ID));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'PEDIGREE_SHOW_GENDER', $PEDIGREE_SHOW_GENDER));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'PREFER_LEVEL2_SOURCES', $PREFER_LEVEL2_SOURCES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'QUICK_REQUIRED_FACTS', $QUICK_REQUIRED_FACTS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'QUICK_REQUIRED_FAMFACTS', $QUICK_REQUIRED_FAMFACTS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'REPO_FACTS_ADD', $REPO_FACTS_ADD));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'REPO_FACTS_QUICK', $REPO_FACTS_QUICK));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'REPO_FACTS_UNIQUE', $REPO_FACTS_UNIQUE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'REPO_ID_PREFIX', $REPO_ID_PREFIX));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'REQUIRE_AUTHENTICATION', $REQUIRE_AUTHENTICATION));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SAVE_WATERMARK_IMAGE', $SAVE_WATERMARK_IMAGE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SAVE_WATERMARK_THUMB', $SAVE_WATERMARK_THUMB));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_AGE_DIFF', $SHOW_AGE_DIFF));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_COUNTER', $SHOW_COUNTER));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_DEAD_PEOPLE', $SHOW_DEAD_PEOPLE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_EST_LIST_DATES', $SHOW_EST_LIST_DATES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_FACT_ICONS', $SHOW_FACT_ICONS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_GEDCOM_RECORD', $SHOW_GEDCOM_RECORD));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_HIGHLIGHT_IMAGES', $SHOW_HIGHLIGHT_IMAGES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_LDS_AT_GLANCE', $SHOW_LDS_AT_GLANCE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_LEVEL2_NOTES', $SHOW_LEVEL2_NOTES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_LIST_PLACES', $SHOW_LIST_PLACES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_LIVING_NAMES', $SHOW_LIVING_NAMES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_MEDIA_DOWNLOAD', $SHOW_MEDIA_DOWNLOAD));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_PARENTS_AGE', $SHOW_PARENTS_AGE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_PEDIGREE_PLACES', $SHOW_PEDIGREE_PLACES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_PRIVATE_RELATIONSHIPS', $SHOW_PRIVATE_RELATIONSHIPS));
// Update these - see db_schema_5_6.php
$SHOW_RELATIVES_EVENTS=preg_replace('/_(BIRT|MARR|DEAT)_(COUS|MSIB|FSIB|GGCH|NEPH|GGPA)/', '', $SHOW_RELATIVES_EVENTS);
$SHOW_RELATIVES_EVENTS=preg_replace('/_FAMC_(RESI_EMIG)/', '', $SHOW_RELATIVES_EVENTS);
$SHOW_RELATIVES_EVENTS=preg_replace('/_MARR_(MOTH|FATH|FAMC)/', '_MARR_PARE', $SHOW_RELATIVES_EVENTS);
$SHOW_RELATIVES_EVENTS=preg_replace('/_DEAT_(MOTH|FATH)/', '_DEAT_PARE', $SHOW_RELATIVES_EVENTS);
preg_match_all('/[_A-Z]+/', $SHOW_RELATIVES_EVENTS, $match);
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_RELATIVES_EVENTS', implode(',', array_unique($match[0]))));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_STATS', $SHOW_STATS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SOURCE_ID_PREFIX', $SOURCE_ID_PREFIX));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SOUR_FACTS_ADD', $SOUR_FACTS_ADD));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SOUR_FACTS_QUICK', $SOUR_FACTS_QUICK));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SOUR_FACTS_UNIQUE', $SOUR_FACTS_UNIQUE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SUBLIST_TRIGGER_I', $SUBLIST_TRIGGER_I));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SURNAME_LIST_STYLE', $SURNAME_LIST_STYLE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SURNAME_TRADITION', $SURNAME_TRADITION));
switch (@$THEME_DIR) {
case '':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', ''));
break;
case 'themes/cloudy/':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', 'clouds'));
break;
case 'themes/minimal/':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', 'minimal'));
break;
case 'themes/simplyblue/':
case 'themes/simplygreen/':
case 'themes/simplyred/':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', 'colors'));
break;
case 'themes/xenea/':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', 'xenea'));
break;
default:
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', 'webtrees'));
break;
}
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THUMBNAIL_WIDTH', $THUMBNAIL_WIDTH));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'USE_GEONAMES', $USE_GEONAMES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'USE_RELATIONSHIP_PRIVACY', $USE_RELATIONSHIP_PRIVACY));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'USE_RIN', $USE_RIN));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'WATERMARK_THUMB', $WATERMARK_THUMB));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'WEBMASTER_USER_ID', get_user_id($WEBMASTER_EMAIL)));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES));
}
WT_DB::prepare("DELETE FROM `##gedcom_setting` WHERE setting_name in ('config', 'privacy', 'path', 'pgv_ver', 'imported')")->execute();
// webtrees 1.0.5 combines user and gedcom settings for relationship privacy
// into a combined user-gedcom setting, for more granular control
WT_DB::exec(
"INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value)".
" SELECT u.user_id, g.gedcom_id, 'RELATIONSHIP_PATH_LENGTH', LEAST(us1.setting_value, gs1.setting_value)".
" FROM `##user` u".
" CROSS JOIN `##gedcom` g".
" LEFT JOIN `##user_setting` us1 ON (u.user_id =us1.user_id AND us1.setting_name='max_relation_path')".
" LEFT JOIN `##user_setting` us2 ON (u.user_id =us2.user_id AND us2.setting_name='relationship_privacy')".
" LEFT JOIN `##gedcom_setting` gs1 ON (g.gedcom_id=gs1.gedcom_id AND gs1.setting_name='MAX_RELATION_PATH_LENGTH')".
" LEFT JOIN `##gedcom_setting` gs2 ON (g.gedcom_id=gs2.gedcom_id AND gs2.setting_name='USE_RELATIONSHIP_PRIVACY')".
" WHERE us2.setting_value AND gs2.setting_value"
);
WT_DB::exec(
"DELETE FROM `##gedcom_setting` WHERE setting_name IN ('MAX_RELATION_PATH_LENGTH', 'USE_RELATIONSHIP_PRIVACY')"
);
WT_DB::exec(
"DELETE FROM `##user_setting` WHERE setting_name IN ('relationship_privacy', 'max_relation_path_length')"
);
////////////////////////////////////////////////////////////////////////////////
// The PGV blocks don't migrate easily.
// Just give everybody and every tree default blocks
////////////////////////////////////////////////////////////////////////////////
WT_DB::prepare(
"INSERT INTO `##block` (user_id, location, block_order, module_name)" .
" SELECT `##user`.user_id, location, block_order, module_name" .
" FROM `##block`" .
" JOIN `##user`" .
" WHERE `##block`.user_id = -1" .
" AND `##user`.user_id > 0"
)->execute();
WT_DB::prepare(
"INSERT INTO `##block` (gedcom_id, location, block_order, module_name)" .
" SELECT `##gedcom`.gedcom_id, location, block_order, module_name" .
" FROM `##block`" .
" JOIN `##gedcom`" .
" WHERE `##block`.gedcom_id = -1" .
" AND `##gedcom`.gedcom_id > 0"
)->execute();
////////////////////////////////////////////////////////////////////////////////
// Hit counter
////////////////////////////////////////////////////////////////////////////////
//
if ($PGV_SCHEMA_VERSION>=13) {
echo '<p>pgv_hit_counter => wt_hit_counter ...</p>';
flush();
if (ini_get('output_buffering')) {
ob_flush();
}
WT_DB::prepare(
"REPLACE INTO `##hit_counter` (gedcom_id, page_name, page_parameter, page_count)".
" SELECT gedcom_id, page_name, page_parameter, page_count FROM `{$DBNAME}`.`{$TBLPREFIX}hit_counter`"
)->execute();
} else {
// Copied from PGV's db_schema_12_13
$statement=WT_DB::prepare("INSERT IGNORE INTO `##hit_counter` (gedcom_id, page_name, page_parameter, page_count) VALUES (?, ?, ?, ?)");
foreach ($GEDCOMS as $GEDCOM=>$GED_DATA) {
// Caution these files might be quite large...
$file=$INDEX_DIRECTORY.'/'.$GEDCOM.'pgv_counters.txt';
echo '<p>', $file, ' => wt_hit_counter ...</p>';
flush();
if (ini_get('output_buffering')) {
ob_flush();
}
if (file_exists($file)) {
foreach (file($file) as $line) {
if (preg_match('/(@([A-Za-z0-9:_-]+)@ )?(\d+)/', $line, $match)) {
if ($match[2]) {
$page_name='individual.php';
$page_parameter=$match[2];
} else {
$page_name='index.php';
$page_parameter='gedcom:'.$GED_DATA['id'];
}
try {
$statement->execute(array($GED_DATA['id'], $page_name, $page_parameter, $match[3]));
} catch (PDOException $ex) {
// Primary key violation? Ignore?
}
}
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
if ($PGV_SCHEMA_VERSION>=14) {
echo '<p>pgv_ip_address => wt_ip_address ...</p>'; flush(); if (ini_get('output_buffering')) { ob_flush(); }
WT_DB::prepare(
"INSERT IGNORE INTO `##ip_address` (ip_address, category, comment)".
" SELECT ip_address, category, comment FROM `{$DBNAME}`.`{$TBLPREFIX}ip_address`"
)->execute();
} else {
// Copied from PGV's db_schema_13_14
$statement=WT_DB::prepare("REPLACE INTO `##ip_address` (ip_address, category, comment) VALUES (?, ?, ?)");
echo '<p>', $INDEX_DIRECTORY, DIRECTORY_SEPARATOR, 'banned.php => wt_ip_address ...</p>'; ob_flush(); flush(); usleep(50000);
if (is_readable($INDEX_DIRECTORY.'/banned.php')) {
@require $INDEX_DIRECTORY.'/banned.php';
if (!empty($banned) && is_array($banned)) {
foreach ($banned as $value) {
try {
if (is_array($value)) {
// New format: array(ip, comment)
$statement->execute(array($value[0], 'banned', $value[1]));
} else {
// Old format: string(ip)
$statement->execute(array($value, 'banned', ''));
}
} catch (PDOException $ex) {
echo $ex, '<br>';
}
}
}
}
echo '<p>', $INDEX_DIRECTORY, DIRECTORY_SEPARATOR, 'search_engines.php => wt_ip_address ...</p>'; ob_flush(); flush(); usleep(50000);
if (is_readable($INDEX_DIRECTORY.'/search_engines.php')) {
@require $INDEX_DIRECTORY.'/search_engines.php';
if (!empty($search_engines) && is_array($search_engines)) {
foreach ($search_engines as $value) {
try {
if (is_array($value)) {
// New format: array(ip, comment)
$statement->execute(array($value[0], 'search-engine', $value[1]));
} else {
// Old format: string(ip)
$statement->execute(array($value, 'search-engine', ''));
}
} catch (PDOException $ex) {
echo $ex, '<br>';
}
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
foreach ($GEDCOMS as $GED_DATA) {
WT_Module::setDefaultAccess($GED_DATA['id']);
}
echo '<p>pgv_site_setting => wt_module_setting ...</p>'; ob_flush(); flush(); usleep(50000);
WT_DB::prepare(
"REPLACE INTO `##module_setting` (module_name, setting_name, setting_value)".
" SELECT 'googlemap', site_setting_name, site_setting_value FROM `{$DBNAME}`.`{$TBLPREFIX}site_setting`".
" WHERE site_setting_name LIKE 'GM_%'"
)->execute();
WT_DB::prepare(
"REPLACE INTO `##module_setting` (module_name, setting_name, setting_value)".
" SELECT 'lightbox', site_setting_name, site_setting_value FROM `{$DBNAME}`.`{$TBLPREFIX}site_setting`".
" WHERE site_setting_name LIKE 'LB_%'"
)->execute();
////////////////////////////////////////////////////////////////////////////////
echo '<p>pgv_favorites => wt_favorite ...</p>'; ob_flush(); flush(); usleep(50000);
try {
WT_DB::prepare(
"REPLACE INTO `##favorite` (favorite_id, user_id, gedcom_id, xref, favorite_type, url, title, note)".
" SELECT fv_id, u.user_id, g.gedcom_id, fv_gid, fv_type, fv_url, fv_title, fv_note".
" FROM `{$DBNAME}`.`{$TBLPREFIX}favorites` f".
" LEFT JOIN `##gedcom` g ON (f.fv_username=g.gedcom_name)".
" LEFT JOIN `##user` u ON (f.fv_username=u.user_name)"
)->execute();
} catch (PDOException $ex) {
// This table will only exist if the favorites module is installed in WT
}
////////////////////////////////////////////////////////////////////////////////
echo '<p>pgv_news => wt_news ...</p>'; ob_flush(); flush(); usleep(50000);
try {
WT_DB::prepare(
"REPLACE INTO `##news` (news_id, user_id, gedcom_id, subject, body, updated)".
" SELECT n_id, u.user_id, g.gedcom_id, n_title, n_text, FROM_UNIXTIME(n_date)".
" FROM `{$DBNAME}`.`{$TBLPREFIX}news` n".
" LEFT JOIN `##gedcom` g ON (n.n_username=g.gedcom_name)".
" LEFT JOIN `##user` u ON (n.n_username=u.user_name)"
)->execute();
} catch (PDOException $ex) {
// This table will only exist if the news/blog module is installed in WT
}
////////////////////////////////////////////////////////////////////////////////
echo '<p>pgv_nextid => wt_next_id ...</p>'; ob_flush(); flush(); usleep(50000);
WT_DB::prepare(
"REPLACE INTO `##next_id` (gedcom_id, record_type, next_id)".
" SELECT ni_gedfile, ni_type, ni_id".
" FROM `{$DBNAME}`.`{$TBLPREFIX}nextid`".
" JOIN `##gedcom` ON (ni_gedfile = gedcom_id)".
" WHERE ni_type IN ('INDI', 'FAM', 'SOUR', 'REPO', 'OBJE', 'NOTE')"
)->execute();
////////////////////////////////////////////////////////////////////////////////
echo '<p>pgv_messages => wt_message ...</p>'; ob_flush(); flush(); usleep(50000);
WT_DB::prepare(
"REPLACE INTO `##message` (message_id, sender, ip_address, user_id, subject, body, created)".
" SELECT m_id, m_from, '127.0.0.1', user_id, m_subject, m_body, str_to_date(m_created,'%a, %d %M %Y %H:%i:%s')".
" FROM `{$DBNAME}`.`{$TBLPREFIX}messages`".
" JOIN `##user` ON (CONVERT(m_to USING utf8) COLLATE utf8_unicode_ci=user_name)"
)->execute();