/var/www/(Del)hsihk.com/wp-content/plugins/backupbuddy/classes/_migrate_database.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
<?php
/**
 *    _migrate_database.php
 *
 *    Handles all SQL data migration for both importbuddy and multisite importing.
 *    Handles updating paths, URLs, etc.
 *    
 *    Version: 1.0.1
 *    Author: Dustin Bolton
 *    Author URI: http://dustinbolton.com/
 *
 *    REQUIREMENTS:
 *
 *    1) Set up the variable $this->destinationType to the destination type if non-standalone (default) or Multisite Network (auto-detected). Valid values: standalone, multisite_import, multisite_network
 *    2) Mysql should already be connected.
 *    3) $this->restoreData['dat'] should be initialized with the DAT file array.
 *    4) If migrating a network -> network then set up the variable $this->networkPrefix to be the database prefix of the network. Needed to access users tables.
 *    5) If multisite_import is DESTINATION then $wp_upload_dir (upload_path option), $this->restoreData['upload_url'] (fileupload_url option) must be set.
 *
 *    USED BY:
 *
 *    1) ImportBuddy
 *    2) Multisite Import / Restore
 *
 */

// NOTES:
//        * Example instantiation: $migrate = new backupbuddy_migrateDB( 'standalone', $this->_state );
//        * dbreplace class intelligently ignores replacing values with identical values for performance.


global $wpdb;

if ( isset( 
$destination_type ) && ( $destination_type == 'multisite_import' ) ) { // MULTISITE IMPORT
    
    
$state = array(
        
'dat' => pb_backupbuddy::$options['dat_file'],
        
'maxExecutionTime' => 30,
        
'siteurl' => $destination_siteurl,
        
'homeurl' => $destination_home,
        
'upload_url' => $this->restoreData['upload_url'], // MS related stuff.
        
'databaseSettings' => array(
                                    
'prefix' => $multisite_network_db_prefix,
                                    
'migrateDatabaseBruteForce' => true,
                                )
    );
    
    
$migrate = new backupbuddy_migrateDB$destination_type$state$multisite_network_db_prefix );
    
}



class 
backupbuddy_migrateDB {

    const 
TIME_WIGGLE_ROOM 1// Number of seconds to fudge up the time elapsed to give a little wiggle room so we don't accidently hit the edge and time out.
    
    
var $startTime// Microtime migration started.
    
    
var $restoreData;
    var 
$sourceType;
    var 
$destinationType;
    var 
$networkPrefix;
    var 
$overridePrefix// Prefix to use. Defaults to $this->restoreData['databaseSettings']['prefix']. Allows overriding.

    
var $oldURLs;
    var 
$newURLs;
    
    var 
$oldFullReplace;
    var 
$newFullReplace;
    
    var 
$networkUploadURLReal;
    var 
$bruteforceExcludedTables;

    
    
// DESTINATION TYPE. Valid values: standalone, multisite_import, multisite_network
    // RETURNS: true on success fully completing, array( resumeFunction, resumePoint ) on needing chunking. false on failure.
    
function __construct$destinationType$restoreData$networkPrefix ''$overridePrefix '' ) {

        
$this->startTime microtimetrue ); // Start tracking for elapsed time.
        
        
$this->destinationType $destinationType;
        
$this->restoreData = &$restoreData;
        
        if ( 
'' == $overridePrefix ) { // Not overriding prefix.
            
$this->overridePrefix $this->restoreData['databaseSettings']['prefix'];
            
pb_backupbuddy::status'details''Using normal mode database prefix based on settings: `' $this->overridePrefix '`.' );
        } else { 
// Overriding prefix.
            
$this->overridePrefix $overridePrefix;
            
pb_backupbuddy::status'details''Using override database prefix: `' $this->overridePrefix '`.' );
        }
        
        
$this->networkPrefix $networkPrefix
        if ( 
'' == $networkPrefix ) {
            
$this->networkPrefix $this->overridePrefix;
        }

        
pb_backupbuddy::status'message''Migrating database content...' );
        
pb_backupbuddy::status'details''Destination site table prefix: ' $this->overridePrefix );

        if ( 
'' == $this->restoreData['homeurl'] ) { // If no home then we set it equal to site URL.
            
$settings['homeurl'] = $this->restoreData['siteurl'];
        }
        
        
// Source type. Valid values: network, multisite_export (single site exported from multisite network), standalone
        
if ( isset( $this->restoreData['dat'][ 'is_multisite' ] ) && ( ( $this->restoreData['dat'][ 'is_multisite' ] === true ) || ( $this->restoreData['dat'][ 'is_multisite' ] === 'true' ) ) ) {
            
$this->sourceType 'multisite_network';
            
$this->destinationType 'multisite_network';
        } elseif ( isset( 
$this->restoreData['dat'][ 'is_multisite_export' ] ) && ( ( $this->restoreData['dat'][ 'is_multisite_export' ] === true ) || ( $this->restoreData['dat'][ 'is_multisite_export' ] === 'true' ) ) ) {
            
$this->sourceType 'multisite_export';
        } else {
            
$this->sourceType 'standalone';
        }
        
        
pb_backupbuddy::status'details''Migration type: `' $this->sourceType '` to `' $this->destinationType '`.' );
        
pb_backupbuddy::status'details''Destination Site URL: ' $this->restoreData['siteurl'] );
        
pb_backupbuddy::status'details''Destination Home URL: ' $this->restoreData['homeurl'] );
        
    } 
// End __construct().
    
    
    
    
function migrate() {
        if ( 
is_array$this->restoreData['databaseSettings']['migrateResumeSteps'] ) ) { // Resuming so use existing steps list.
            
$steps = &$this->restoreData['databaseSettings']['migrateResumeSteps'];
        } else { 
// Not resuming so build steps list.
            // Migrate anything common to all types.
            
$steps = array( 'migrateCommon' );
            
// Migrate Network -> Network.
            
if ( ( $this->sourceType == 'multisite_network' ) && ( $this->destinationType == 'multisite_network' ) ) {
                
$steps[] = 'migrateNetworkToNetwork';
            }
            
// Standalone -> Multisite Import.
            
if ( ( $this->sourceType == 'standalone' ) && ( $this->destinationType == 'multisite_import' ) ) {
                
$steps[] = 'migrateStandaloneToMultisiteImport';
            }
            
// Multisite Export -> Multisite Import.
            
if ( ( $this->sourceType == 'multisite_export' ) && ( $this->destinationType == 'multisite_import' ) ) {
                
$steps[] = 'migrateMultisiteImportToMultisiteExport';
            }
            
// Multisite Export -> Standalone.
            
if ( ( $this->sourceType == 'multisite_export' ) && ( $this->destinationType == 'standalone' ) ) {
                
$steps[] = 'migrateMultisiteExportToStandalone';
            }
            
$steps[] = '_calculateNewOldURLs';
            
$steps[] = 'bruteForceTables';
            
$steps[] = 'finalize';
            
$steps[] = 'verifyDatabase';
        }
        
pb_backupbuddy::status'details''Steps to run: `' implode','$steps ) . '`.' );
        
        
        foreach( 
$steps as $step ) {
            
$this->restoreData['databaseSettings']['migrateResumePoint'] = ''// Clear out needing to resume for now.
            
            // Run the function.
            
pb_backupbuddy::status'details''Starting step `' $step '`.' );
            
$results call_user_func( array( $this$step ), $this->restoreData['databaseSettings']['migrateResumePoint'] );
            
pb_backupbuddy::status'details''Finished step `' $step '`.' );
            
            if ( 
TRUE === $results ) { // Success so move to next loop.
                
array_shift$steps ); // Shifts step off the front of the array.
                
                
pb_backupbuddy::status'details''Database migration step `' $step '` finished successfully.' );

                if ( 
$this->nearTimeLimit() ) {
                    return array( 
$steps'''' ); // array of remaining steps, no resume point since not within a function.
                
}

                
// Do nothing... will just continue to next step.
            
} elseif( is_array$results ) ) { // NEEDS CHUNKING.
                
$steps array_unshift$steps$step ); // This step did not finish so put it back at the beginning for resuming.
                
pb_backupbuddy::status'details''Migrating the database did not complete in the first passs. Chunking into multiple parts. Resuming step `' $step '` shortly at point `' $results[0] . '`.' );
                return array( 
$steps$results[0] ); // Array of steps to run, resume point.
            
} else { // FALSE or something weird...
                
pb_backupbuddy::status'error''Database migration step `' $step '` failed. See log for details. Result: `' $results '`.' );
                return 
FALSE;
            }
        } 
// end foreach.
        
        
        
        
        
        
pb_backupbuddy::status'message''Took ' roundmicrotimetrue ) - pb_backupbuddy::$start_time) . ' seconds. Done.' );
        
pb_backupbuddy::status'message''Database content migrated.' );
        
        return 
true;
    } 
// End function __construct().
    
    
function nearTimeLimit() {
        
// If we are within 1 second of reaching maximum PHP runtime then stop here so that it can be picked up in another PHP process...
        
if ( ( ( microtimetrue ) - $this->startTime ) + self::TIME_WIGGLE_ROOM ) >= $this->restoreData['maxExecutionTime'] ) {
            
pb_backupbuddy::status'message''Approaching limit of available PHP chunking time of `' $this->restoreData['maxExecutionTime'] . '` sec. Ran for ' roundmicrotimetrue ) - $this->startTime) . ' sec.' );
            return 
true;
        } else {
            return 
false;
        }
    }
    
    function 
_calculateNewOldURLs() {
        
// ********** BEGIN MAKING OLD URLS UNIQUE AND TRIMMING CORRESPONDING NEW URLS **********

        // This entire section is in place to prevent duplicate replacements.
        
$unique_urls $this->_array_pairs_unique_first$this->oldURLs$this->newURLs );
        
$this->oldURLs $unique_urls[0];
        
$this->newURLs $unique_urls[1];

        
$unique_urls $this->_array_pairs_unique_first$this->oldFullReplace$this->newFullReplace );
        
$this->oldFullReplace $unique_urls[0];
        
$this->newFullReplace $unique_urls[1];

        
pb_backupbuddy::status'details''Old URLs: ' implode', '$this->oldURLs ) );
        
pb_backupbuddy::status'details''New URLs: ' implode', '$this->newURLs ) );
        
pb_backupbuddy::status'details''Old full replace: ' implode', '$this->oldFullReplace ) );
        
pb_backupbuddy::status'details''New full replace: ' implode', '$this->newFullReplace ) );

        return 
true;

        
// ********** END MAKING OLD URLS UNIQUE AND TRIMMING CORRESPONDING NEW URLS **********
    
}
    
    function 
migrateCommon() {
        
pb_backupbuddy::status'details''Starting migration steps for `all` sites.' );

        
// ABSPATH
        
$old_abspath $this->restoreData['dat']['abspath'];
        
//$old_abspath = preg_replace( '|/+$|', '', $old_abspath ); // Remove escaping of windows paths. This is wrong. strips trailing slashes. Why? It shouldnt! Removed Nov 4
        
$new_abspath ABSPATH;
        
pb_backupbuddy::status'details''ABSPATH change for database. Old Path: ' $old_abspath ', New Path: ' $new_abspath '.' );



        
$old_url $this->restoreData['dat']['siteurl'];  // the value you want to search for    

        // SITEURL
        
if ( stristr$old_url'http://www.' ) || stristr$old_url'https://www.' ) ) { // If http://www.blah.... then also we will replace http://blah... and vice versa.
            
$old_url_alt str_ireplace'http://www.''http://'$old_url );
            
$old_url_alt str_ireplace'https://www.''https://'$old_url_alt );
        } else {
            
$old_url_alt str_ireplace'http://''http://www.'$old_url );
            
$old_url_alt str_ireplace'https://''https://www.'$old_url_alt );
        }
        
        
pb_backupbuddy::status'details''Calculated site URL update. Previous URL: `' $old_url '`, New URL: `' $this->restoreData['siteurl'] . '`.' );
        
$this->oldFullReplace = array( $old_url$old_url_alt );
        if ( 
'/' != $old_abspath ) { // Only do replace on abspath if it was not previously at the root as this easily breaks things.
            
$this->oldFullReplace[] = $old_abspath;
        } else {
            
pb_backupbuddy::status'warning''WARNING: Skipping ABSPATH database migrations as the previous ABSPATH was in the root directory. Cannot safely update paths at this location do it only being a single slash.' );
        }
        
$this->newFullReplace = array( $this->restoreData['siteurl'], $this->restoreData['siteurl'] );
        if ( 
'/' != $old_abspath ) { // Only do replace on abspath if it was not previously at the root as this easily breaks things.
            
$this->newFullReplace[] = $new_abspath;
        }

        
// HOMEURL.
        
if ( $this->restoreData['homeurl'] != $this->restoreData['dat']['siteurl'] ) { // Old and new homeurl differ so needs updating.

            
if ( empty( $this->restoreData['dat']['homeurl'] ) ) { // old BackupBuddy versions did not store the previous homeurl. Hang onto this for backwards compatibility for a while.
                
pb_backupbuddy::status'error''Your current backup does not include a home URL. Home URLs will NOT be updated; site URL will be updated though.  Make a new backup with the latest BackupBuddy before migrating if you wish to fully update home URL configuration.' );
            } else {
                
$this->oldURLs = array( $old_url$old_url_alt$this->restoreData['dat']['homeurl'] );
                
$this->newURLs = array( $this->restoreData['siteurl'], $this->restoreData['siteurl'], $this->restoreData['homeurl'] );

                
$this->oldFullReplace[] = $this->restoreData['dat']['homeurl'];
                
$this->newFullReplace[] = $this->restoreData['dat']['homeurl'];

                
pb_backupbuddy::status'details''Calculated home URL update. Previous URL: `' $this->restoreData['dat']['homeurl'] . '`, New URL: `' $this->restoreData['homeurl'] . '`' );
            }
        } else { 
// Site URL updates only.
            
$this->oldURLs = array( $old_url$old_url_alt );
            
$this->newURLs = array( $this->restoreData['siteurl'], $this->restoreData['siteurl'] );
        }

        if ( isset( 
$wp_upload_dir ) ) {
            
$this->networkUploadURLReal $this->restoreData['siteurl'] . '/' str_replaceABSPATH''$wp_upload_dir );
            
pb_backupbuddy::status'details''$this->networkUploadURLReal = `' $this->networkUploadURLReal '`.' );
        }
        
        
        
$this->bruteforceExcludedTables = array(
            
$this->overridePrefix 'posts',
            
$this->overridePrefix 'users'// Imported users table will temporarily be here so this is fine for MS imports.
            
$this->overridePrefix 'usermeta'// Imported users table will temporarily be here so this is fine for MS imports.
            
$this->overridePrefix 'terms',
            
$this->overridePrefix 'term_taxonomy',
            
$this->overridePrefix 'term_relationships',
            
$this->overridePrefix 'postmeta',
            
$this->overridePrefix 'options',
            
$this->overridePrefix 'comments',
            
$this->overridePrefix 'commentmeta',
            
$this->overridePrefix 'links',
        );

        
pb_backupbuddy::status'details''Finished migration steps for `all` sites.' );
        
        return 
true;
    } 
// End migrateCommon().
    
    
    
    
function migrateNetworkToNetwork() {

        
pb_backupbuddy::status'details''Starting migration steps for `Network -> Network` sites.' );

        
// Multisite Network domain & path from site url:
        
$url_parts parse_url$this->restoreData['siteurl'] );
        
$multisite_destination_domain =  $url_parts['host'];
        if ( isset( 
$url_parts['path'] ) ) {
            
$destination_path rtrim$url_parts['path'], '/\\' ) . '/';
        } else {
            
$destination_path '/';
        }
        
        
//pb_update_domain_path( $this->restoreData['dat']['domain'], $multisite_destination_domain, $this->restoreData['dat']['path'], $destination_path ); // $old_domain, $multisite_destination_domain, $old_path, $destination_path
        
$old_domain $this->restoreData['dat']['domain'];
        
$old_path $this->restoreData['dat']['path'];

        
pb_backupbuddy::status'details''Multisite Network URLs: Old domain: `' $old_domain '`; new domain: `' $multisite_destination_domain '`; old path: `' $old_path '`; new path: `' $destination_path '`.' );


        
// BLOGS TABLE-----

        // Update blog path for all sites that had the old domain and started with the old path in BLOGS table.
        
if ( $old_path != '/' ) { // Used to be a subdomain so we can more safely replace.
            
mysql_query"UPDATE `" $this->overridePrefix "blogs` SET path=REPLACE( path, '" backupbuddy_core::dbEscape$old_path ) . "', '" backupbuddy_core::dbEscape$destination_path ) . "') WHERE domain='" backupbuddy_core::dbEscape$old_domain ) . "' AND path LIKE '" backupbuddy_core::dbEscape$old_path ) . "%'" );
            
pb_backupbuddy::status'details''Modified ' mysql_affected_rows() . ' row(s) while updating paths in blogs table to `' backupbuddy_core::dbEscape$destination_path ) . '` (old path was a subdirectory).' );
        } else { 
// Used to be in root so much prepend new path.
            
mysql_query"UPDATE `" $this->overridePrefix "blogs` SET path=concat( '" backupbuddy_core::dbEscapertrim$destination_path'/\\' ) ) . "', path ) WHERE domain='" backupbuddy_core::dbEscape$old_domain ) . "'" );
            
pb_backupbuddy::status'details''Modified ' mysql_affected_rows() . ' row(s) while updating paths in blogs table to `' backupbuddy_core::dbEscape$destination_path ) . '` (old path was root).' );
        }
        if ( 
mysql_error() != '' ) { pb_backupbuddy::status'error''mysql error: ' mysql_error() ); }

        
// Update blog domain for all matching sites.
        
mysql_query"UPDATE `" $this->overridePrefix "blogs` SET domain='" backupbuddy_core::dbEscape$multisite_destination_domain ) . "' WHERE domain='" backupbuddy_core::dbEscape$old_domain ) . "'" );
        
pb_backupbuddy::status'details''Modified ' mysql_affected_rows() . ' row(s) while updating domain in blogs table to `' backupbuddy_core::dbEscape$multisite_destination_domain ) . '`.' );
        if ( 
mysql_error() != '' ) { pb_backupbuddy::status'error''mysql error: ' mysql_error() ); }

        
// SITE TABLE-----

        // Update blog path for all matching sites in SITE table.
        
if ( $old_path != '/' ) { // Used to be a subdomain so we can more safely replace.
            
mysql_query"UPDATE `" $this->overridePrefix "site` SET path=REPLACE( path, '" backupbuddy_core::dbEscape$old_path ) . "', '" backupbuddy_core::dbEscape$destination_path ) . "') WHERE domain='" backupbuddy_core::dbEscape$old_domain ) . "' AND path LIKE '" backupbuddy_core::dbEscape$old_path ) . "%'" );
            
pb_backupbuddy::status'details''Modified ' mysql_affected_rows() . ' row(s) while updating paths in site table to `' backupbuddy_core::dbEscape$destination_path ) . '` (old path was a subdirectory).' );
        } else { 
// Used to be in root so much prepend new path.
            
mysql_query"UPDATE `" $this->overridePrefix "site` SET path=concat( '" backupbuddy_core::dbEscapertrim$destination_path'/\\' ) ) . "', path ) WHERE domain='" backupbuddy_core::dbEscape$old_domain ) . "'" );
            
pb_backupbuddy::status'details''Modified ' mysql_affected_rows() . ' row(s) while updating paths in site table to `' backupbuddy_core::dbEscape$destination_path ) . '` (old path was root).' );
        }
        if ( 
mysql_error() != '' ) { pb_backupbuddy::status'error''mysql error: ' mysql_error() ); }

        
// Update blog domain for all matching sites.
        
mysql_query"UPDATE `" $this->overridePrefix "site` SET domain='" backupbuddy_core::dbEscape$multisite_destination_domain ) . "' WHERE domain='" backupbuddy_core::dbEscape$old_domain ) . "'" );
        
pb_backupbuddy::status'details''Modified ' mysql_affected_rows() . ' row(s) while updating domain in site table to `' backupbuddy_core::dbEscape$multisite_destination_domain ) . '`.' );
        if ( 
mysql_error() != '' ) { pb_backupbuddy::status'error''mysql error: ' mysql_error() ); }

        
pb_backupbuddy::status'details''Finished migration steps for `Network -> Network` sites.' );
        return 
true;
    } 
// End migrateNetworkToNetwork().
    
    
    
    
function migrateStandaloneToMultisiteImport() {
    
        global 
$wpdb;
        global 
$wp_version;
        
pb_backupbuddy::status'details''Starting migration steps for `Standalone -> Multisite Import` sites.' );
        
        
// Note for any destination of multisite_import: Users tables exist temporarily in their normal location so we replace them like a normal standalone site. The next import step will merge them into the multisite tables.
        
        // TODO: add code from ms_importbuddy.php into here for any updates if needed.
        
        // The old uploads URL. Standalone source like: http://getbackupbuddy.com/wp-content/uploads/. BB doesnt currently support moved uploads. Unshifted to place these replacements FIRST in the array of URLs to replace.
        
pb_backupbuddy::status'details''Old uploads URL: ' $this->restoreData['dat']['siteurl'] . '/wp-content/uploads' );
        
array_unshift$this->oldURLs$this->restoreData['dat']['siteurl'] . '/wp-content/uploads' );
        
array_unshift$this->oldFullReplace$this->restoreData['dat']['siteurl'] . '/wp-content/uploads' );
        
        
// The new standalone upload URL. Ex: http://pluginbuddy.com/wp-content/uploads/. Unshifted to place these replacements FIRST in the array of URLs to replace.
        
pb_backupbuddy::status'details''New virtual upload URL to replace standalone upload URL: ' $this->restoreData['upload_url'] );
        
array_unshift$this->newURLs$this->restoreData['upload_url'] );
        
array_unshift$this->newFullReplace$this->restoreData['upload_url'] );
        
        
// Update upload_path in options table.
        
if ( version_compare$wp_version'3.5''>=') ) { // As of WP v3.5 substies should have upload_path option removed.
            
mysql_query"DELETE FROM `" $this->overridePrefix "options` WHERE option_name='upload_path' LIMIT 1"$wpdb->dbh );
            
pb_backupbuddy::status'details''Deleted ' mysql_affected_rows$wpdb->dbh ) . ' row(s) as upload_path is no longer needed by Multisite.' );
        } else {
            
mysql_query"UPDATE `" $this->overridePrefix "options` SET option_value='" backupbuddy_core::dbEscapestr_replace$this->restoreData['siteurl'] . '/'''$this->networkUploadURLReal ) ) . "' WHERE option_name='upload_path' LIMIT 1"$wpdb->dbh );
            
pb_backupbuddy::status'details''Modified ' mysql_affected_rows$wpdb->dbh ) . ' row(s) while updating uploads URL in options table. New value: ' str_replace$this->restoreData['siteurl'] . '/'''$this->networkUploadURLReal ) );
        }
        if ( 
mysql_error$wpdb->dbh ) != '' ) { pb_backupbuddy::status'error''mysql error: ' mysql_error$wpdb->dbh ) ); }
        
        
// Update user roles option_name row.
        
mysql_query"UPDATE `" $this->overridePrefix "options` SET option_name='" $this->overridePrefix "user_roles' WHERE option_name LIKE '%\_user\_roles' LIMIT 1"$wpdb->dbh );
        
pb_backupbuddy::status'details''Modified ' mysql_affected_rows$wpdb->dbh ) . ' row(s) while updating user roles option_name to `' $this->overridePrefix 'user_roles`.' );
        if ( 
mysql_error$wpdb->dbh ) != '' ) { pb_backupbuddy::status'error''mysql error: ' mysql_error$wpdb->dbh ) ); }
        
        
// Update fileupload_url in options table.
        
mysql_query"UPDATE `" $this->overridePrefix "options` SET option_value='" backupbuddy_core::dbEscape$this->restoreData['upload_url'] ) . "' WHERE option_name='fileupload_url' LIMIT 1"$wpdb->dbh );
        
pb_backupbuddy::status'details''Modified ' mysql_affected_rows$wpdb->dbh ) . ' row(s) while updating fileupload_url in options table. New value: `' $this->restoreData['upload_url'] . '`.' );
        if ( 
mysql_error$wpdb->dbh ) != '' ) { pb_backupbuddy::status'error''mysql error: ' mysql_error$wpdb->dbh ) ); }
        
        
        
// Update user level meta_key in user_meta table.
        // TODO: moved to bottom of this file.
        //mysql_query( "UPDATE `" . $this->overridePrefix . "options` SET option_name='" . $this->overridePrefix . "user_roles' WHERE option_name LIKE '%_user_roles' LIMIT 1" );
        //pb_backupbuddy::status( 'details', 'Modified ' . mysql_affected_rows() . ' row(s) while updating user roles option_name to `' . $this->overridePrefix . 'user_roles`.' );
        
        
pb_backupbuddy::status'details''Finished migration steps for `Standalone -> Multisite Import` sites.' );

        return 
true;
    } 
// End migrateStandaloneToMultisiteImport().
    
    
    
    
function migrateMultisiteExportToMultisiteImport() {
        
        global 
$wpdb$wp_version;
        
pb_backupbuddy::status'details''Starting migration steps for `Multisite Export -> Multisite Import` sites.' );
        
        
// Note for any destination of multisite_import: Users tables exist temporarily in their normal location so we replace them like a normal standalone site. The next import step will merge them into the multisite tables.
        
        // The old virtual uploads URL. Standalone source like: http://getbackupbuddy.com/wp-content/uploads/. BB doesnt currently support moved uploads. Unshifted to place these replacements FIRST in the array of URLs to replace.
        
pb_backupbuddy::status'details''Old virtual uploads URL: ' $this->restoreData['dat']['upload_url'] );
        
array_unshift$this->oldURLs$this->restoreData['dat']['upload_url'] );
        
array_unshift$this->oldFullReplace$this->restoreData['dat']['upload_url'] );
        
        
// The new virtual upload URL. Ex: http://pluginbuddy.com/wp-content/uploads/. Unshifted to place these replacements FIRST in the array of URLs to replace.
        
pb_backupbuddy::status'details''New virtual upload URL to replace old virtual uploads URL: ' $this->restoreData['upload_url'] );
        
array_unshift$this->newURLs$this->restoreData['upload_url'] );
        
array_unshift$this->newFullReplace$this->restoreData['upload_url'] );
        
        
// The old real direct uploads URL. Standalone source like: http://getbackupbuddy.com/wp-content/uploads/. BB doesnt currently support moved uploads. Unshifted to place these replacements FIRST in the array of URLs to replace.
        
pb_backupbuddy::status'details''Old real direct uploads URL: ' $this->restoreData['dat']['upload_url_rewrite'] );
        
array_unshift$this->oldURLs$this->restoreData['dat']['upload_url_rewrite'] );
        
array_unshift$this->oldFullReplace$this->restoreData['dat']['upload_url_rewrite'] );
        
        
// The new real direct upload URL. Ex: http://pluginbuddy.com/wp-content/uploads/. Unshifted to place these replacements FIRST in the array of URLs to replace.
        
pb_backupbuddy::status'details''New real direct upload URL to replace old virtual uploads URL: ' $this->networkUploadURLReal );
        
array_unshift$this->newURLs$this->networkUploadURLReal );
        
array_unshift$this->newFullReplace$this->networkUploadURLReal );
        
        
// Update upload_path in options table.
        // Update upload_path in options table.
        
if ( version_compare$wp_version'3.5''>=') ) { // As of WP v3.5 substies should have upload_path option removed.
            
mysql_query"DELETE FROM `" $this->overridePrefix "options` WHERE option_name='upload_path' LIMIT 1"$wpdb->dbh );
            
pb_backupbuddy::status'details''Deleted ' mysql_affected_rows$wpdb->dbh ) . ' row(s) as upload_path is no longer needed by Multisite.' );
            if ( 
mysql_error$wpdb->dbh ) != '' ) { pb_backupbuddy::status'error''mysql error: ' mysql_error$wpdb->dbh ) ); }
        } else {
            
mysql_query"UPDATE `" $this->overridePrefix "options` SET option_value='" backupbuddy_core::dbEscapestr_replace$this->restoreData['siteurl'] . '/'''$this->networkUploadURLReal ) ) . "' WHERE option_name='upload_path' LIMIT 1"$wpdb->dbh );
            
pb_backupbuddy::status'details''Modified ' mysql_affected_rows$wpdb->dbh ) . ' row(s) while updating upload_path in options table. New value: ' str_replace$this->restoreData['siteurl'] . '/'''$this->networkUploadURLReal ) );
            if ( 
mysql_error$wpdb->dbh ) != '' ) { pb_backupbuddy::status'error''mysql error: ' mysql_error$wpdb->dbh ) ); }
        }
        
        
// Update fileupload_url in options table.
        
mysql_query"UPDATE `" $this->overridePrefix "options` SET option_value='" backupbuddy_core::dbEscape$this->restoreData['upload_url'] ) . "' WHERE option_name='fileupload_url' LIMIT 1"$wpdb->dbh );
        
pb_backupbuddy::status'details''Modified ' mysql_affected_rows$wpdb->dbh ) . ' row(s) while updating fileupload_url in options table. New value: `' $this->restoreData['upload_url'] . '`.' );
        if ( 
mysql_error$wpdb->dbh ) != '' ) { pb_backupbuddy::status'error''mysql error: ' mysql_error$wpdb->dbh ) ); }
        
        
// Update user roles option_name row.
        // TODO: moved to bottom of this file.
        //mysql_query( "UPDATE `" . $this->overridePrefix . "options` SET option_name='" . $this->overridePrefix . "user_roles' WHERE option_name LIKE '%_user_roles' LIMIT 1" );
        //pb_backupbuddy::status( 'details', 'Modified ' . mysql_affected_rows() . ' row(s) while updating user roles option_name to `' . $this->overridePrefix . 'user_roles`.' );
        
        
pb_backupbuddy::status'details''Finished migration steps for `Multisite Export -> Multisite Import` sites.' );
        return 
true;
    } 
// End migrateMultisiteExportToMultisiteImport().
    
    
    
    // ********** BEGIN MULTISITE EXPORT -> STANDALONE  **********
    
function migrateMultisiteExportToStandalone() {
        
        
pb_backupbuddy::status'details''Starting migration steps for `Multisite Export -> Standalone` sites.' );
        
        
// IMPORTANT: Upload URLs _MUST_ be updated before doing a full URL replacement or else the first portion of the URL will be migrated so these will no longer match. array_unshift() is used to bump these to the top of the list to update.
        // These will handle both the REAL url http://.../wp-content/blogs.dir/##/files/ that the virtual path (http://..../wp-content/uploads/).
        
        // The old virtual upload URL. Ex: http://getbackupbuddy.com/files/. Unshifted to place these replacements FIRST in the array of URLs to replace.
        
pb_backupbuddy::status'details''Old virtual upload URL: ' $this->restoreData['dat'][ 'upload_url' ] );
        
array_unshift$this->oldURLs$this->restoreData['dat'][ 'upload_url' ] );
        
array_unshift$this->oldFullReplace$this->restoreData['dat'][ 'upload_url' ] );
        
        
// The new standalone upload URL. Ex: http://pluginbuddy.com/wp-content/uploads/. Unshifted to place these replacements FIRST in the array of URLs to replace.
        
pb_backupbuddy::status'details''New upload URL to replace virtual upload URL: ' $this->restoreData['siteurl'] . '/wp-content/uploads/' );
        
array_unshift$this->newURLs$this->restoreData['siteurl'] . '/wp-content/uploads/' );
        
array_unshift$this->newFullReplace$this->restoreData['siteurl'] . '/wp-content/uploads/' );
        
        
// Only update another URL if it differs -- usually will. They will be the same if the virtual url doesn't exist for some reason (no htaccess availability so the virtual url would match the real url)
        
if ( $this->restoreData['dat'][ 'upload_url' ] != $this->restoreData['dat'][ 'upload_url_rewrite' ] ) {
            
// The old virtual upload URL. Ex: http://getbackupbuddy.com/files/. Unshifted to place these replacements FIRST in the array of URLs to replace.
            
pb_backupbuddy::status'details''Old real upload URL: ' $this->restoreData['dat'][ 'upload_url_rewrite' ] );
            
array_unshift$this->oldURLs$this->restoreData['dat'][ 'upload_url_rewrite' ] ); // The old real upload URL.
            
array_unshift$this->oldFullReplace$this->restoreData['dat'][ 'upload_url_rewrite' ] );
            
            
// The new standalone upload URL. Ex: http://pluginbuddy.com/wp-content/uploads/. Unshifted to place these replacements FIRST in the array of URLs to replace.
            
pb_backupbuddy::status'details''New upload URL to replace real upload URL: ' $this->restoreData['siteurl'] . '/wp-content/uploads/' );
            
array_unshift$this->newURLs$this->restoreData['siteurl'] . '/wp-content/uploads/' ); // The new standalone upload URL.
            
array_unshift$this->newFullReplace$this->restoreData['siteurl'] . '/wp-content/uploads/' ); // The new standalone upload URL.
        
}
        
        
// Update upload_path in options table to be default blank value.
        
mysql_query"UPDATE `" $this->overridePrefix "options` SET option_value='' WHERE option_name='upload_path' LIMIT 1" );
        
pb_backupbuddy::status'details''Modified ' mysql_affected_rows() . ' row(s) while updating uploads path in options table. New value: `` (blank default).' );
        if ( 
mysql_error() != '' ) { pb_backupbuddy::status'error''mysql error: ' mysql_error() ); }
        
        
pb_backupbuddy::status'details''Finished migration steps for `Multisite Export -> Standalone` sites.' );
        return 
true;
    } 
// End migrateMultisiteExportToStandalone().
    // ********** END MULTISITE EXPORT -> STANDALONE **********
    
    
    
    
    
    
    
    
function bruteforceTables() {
        
        global 
$wpdb;
        
// Loop through the tables matching this prefix. Does NOT change data in other tables.
        // This changes actual data on a column by column basis for very row in every table.
        
$tables = array();
        
$rows $wpdb->get_results"SELECT table_name FROM information_schema.tables WHERE table_name LIKE '" str_replace'_''\_'$this->overridePrefix ) . "%' AND table_schema = DATABASE()"ARRAY_A );
        foreach( 
$rows as $row ) {
            
$tables[] = $row['table_name'];
        }
        
pb_backupbuddy::status'message''Found ' count$rows ) . ' WordPress tables. ' );
        unset( 
$rows );
        
$bruteforce_tables pb_backupbuddy::array_remove$tables$this->bruteforceExcludedTables ); // Removes all tables listed in $excluded_tables from $tables.
        
unset( $tables );
        
        
        if ( 
$this->destinationType == 'multisite_import' ) {
            require_once( 
pb_backupbuddy::plugin_path() . '/lib/dbreplace/dbreplace.php' );
        } else {
            require_once( 
'importbuddy/lib/dbreplace/dbreplace.php' );
        }
        
        
// Instantiate db replace class.
        
$dbreplace = new pluginbuddy_dbreplace$this->startTimeself::TIME_WIGGLE_ROOM$this->restoreData['maxExecutionTime'] );


        if ( 
is_array$this->restoreData['databaseSettings']['migrateResumePoint'] ) ) {
            
$steps $this->restoreData['databaseSettings']['migrateResumePoint'][0];
            
$stepResumePoint $this->restoreData['databaseSettings']['migrateResumePoint'][1];
        } else {
            
$stepResumePoint '';
            
            
$steps = array(
                array(
                    
'Posts table site URLs.',
                    
'text',
                    
$this->overridePrefix 'posts',
                    
$this->oldURLs,
                    
$this->newURLs,
                    array( 
'post_content''post_excerpt''post_content_filtered' ),
                ),
                array(
                    
'WordPress core database text data.',
                    
'text',
                    
$this->overridePrefix 'users',
                    
$this->oldURLs,
                    
$this->newURLs,
                    array( 
'user_url' )
                ),
                array(
                    
'WordPress core database text data.',
                    
'text',
                    
$this->overridePrefix 'comments',
                    
$this->oldURLs,
                    
$this->newURLs,
                    array( 
'comment_content''comment_author_url' )
                ),
                array(
                    
'WordPress core database text data.',
                    
'text',
                    
$this->overridePrefix 'links',
                    
$this->oldURLs,
                    
$this->newURLs,
                    array( 
'link_url''link_image''link_target''link_description''link_notes''link_rss' ),
                ),
                array(
                    
'WordPress core database serialized data.',
                    
'serialized',
                    
$this->overridePrefix 'options',
                    
$this->oldFullReplace,
                    
$this->newFullReplace,
                    array( 
'option_value' )
                ),
                array(
                    
'WordPress core database serialized data.',
                    
'serialized',
                    
$this->networkPrefix 'usermeta',
                    
$this->oldFullReplace,
                    
$this->newFullReplace,
                    array( 
'meta_value' ),
                ),
                array(
                    
'WordPress core database serialized data.',
                    
'serialized',
                    
$this->overridePrefix 'postmeta',
                    
$this->oldFullReplace,
                    
$this->newFullReplace,
                    array( 
'meta_value' ),
                ),
                array(
                    
'WordPress core database serialized data.',
                    
'serialized',
                    
$this->overridePrefix 'commentmeta',
                    
$this->oldFullReplace,
                    
$this->newFullReplace,
                    array( 
'meta_value' ),
                ),
                
            );
            
            if ( ! isset( 
$this->restoreData['databaseSettings']['migrateDatabaseBruteForce'] ) || ( true !== $this->restoreData['databaseSettings']['migrateDatabaseBruteForce'] ) ) { // skip bruteforce.
                
pb_backupbuddy::status'details''Brute force database migration skipped based on advanced settings' );
            } else { 
// dont skip bruteforce.
                
                
foreach ( $bruteforce_tables as $bruteforce_table ) {
                    
$steps[] = array(
                        
'Bruteforcing entire tables: `' implode','$bruteforce_tables ) .'`.',
                        
'bruteforce_table',
                        
$bruteforce_table,
                        
$this->oldFullReplace,
                        
$this->newFullReplace
                    
);
                }
            }
        }
        
        
        foreach( 
$steps as $step ) {
            
$this->restoreData['databaseSettings']['migrateResumePoint'][1] = ''// Clear out needing to resume this substep for now.

            // Run the function.
            
pb_backupbuddy::status'details''Starting substep `' $step[0] . '`.' );
            if ( 
'bruteforce_table' == $step[1] ) { // Table bruteforce has different param count.
                
$results call_user_func( array( $dbreplace$step[1] ), $step[2], $step[3], $step[4], $stepResumePoint );
            } else {
                
$results call_user_func( array( $dbreplace$step[1] ), $step[2], $step[3], $step[4], $step[5], $stepResumePoint );
            }
            
pb_backupbuddy::status'details''Finished substep `' $step[0] . '`.' );

            if ( 
TRUE === $results ) { // Success so move to next loop.
                
array_shift$steps ); // Shifts step off the front of the array.
                // Do nothing... will just continue to next step.
                
pb_backupbuddy::status'details''Database migration substep `' $step[0] . '` finished successfully.' );

                if ( 
$this->nearTimeLimit() ) {
                    return array( 
$steps'' ); // array of remaining steps, no resume point since not within a function.
                
}
            } elseif( 
is_array$results ) ) { // NEEDS CHUNKING.
                
$steps array_unshift$steps$step ); // This step did not finish so put it back at the beginning for resuming.
                
pb_backupbuddy::status'details''Substep migrating the database did not complete in the first pass. Chunking into multiple parts. Resuming substep `' $step '` shortly at point `' $results[0] . '`.' );
                return array( 
$steps$results[0] ); // Array of steps to run, resume point.
            
} else { // FALSE or something weird...
                
pb_backupbuddy::status'error''Database migration substep `' $step[0] . '` failed. See log for details. This may only be a non-fatal warning.' );
                return 
FALSE;
            }
        } 
// end foreach.
        
        
        // Update table prefixes in some WordPress meta data. $this->networkPrefix is set to the normal prefix in non-ms environment.
        
$old_prefix $this->restoreData['dat']['db_prefix'];
        
$new_prefix backupbuddy_core::dbEscape$this->overridePrefix );
        
pb_backupbuddy::status'details''Old DB prefix: `' $old_prefix '`; New DB prefix: `' $new_prefix '`. Network prefix: `' $this->networkPrefix '`' );
        if (
$old_prefix != $new_prefix ) {
            
mysql_query("UPDATE `".$new_prefix."usermeta` SET meta_key = REPLACE(meta_key, '".$old_prefix."', '".$new_prefix."' );"); // usermeta table temporarily is in the new subsite's prefix until next step.
            
pb_backupbuddy::status'details''Modified ' mysql_affected_rows() . ' row(s) while updating meta_key\'s for DB prefix in subsite\'s [temporary if multisite] usermeta table from `' backupbuddy_core::dbEscape$old_prefix ) . '` to `' backupbuddy_core::dbEscape$new_prefix ) . '`.' );
            if ( 
mysql_error() != '' ) { pb_backupbuddy::status'error''mysql error: ' mysql_error() ); }

            
mysql_query("UPDATE `".$new_prefix."options` SET option_name = '".$new_prefix."user_roles' WHERE option_name ='".$old_prefix."user_roles' LIMIT 1");
            
pb_backupbuddy::status'details''Modified ' mysql_affected_rows() . ' row(s) while updating option_name user_roles DB prefix in [subsite if multisite] options table to `' backupbuddy_core::dbEscape$new_prefix ) . '`.' );
            if ( 
mysql_error() != '' ) { pb_backupbuddy::status'error''mysql error: ' mysql_error() ); }

            
pb_backupbuddy::status'message''Updated prefix META data.' );
        }

        
pb_backupbuddy::status'message''Migrated ' count$bruteforce_tables ) . ' tables via brute force.' );
        return 
true;

    } 
// End bruteforceTables().



    
function finalize() {
        
// LASTLY UPDATE SITE/HOME URLS to prevent double replacement; just in case!

        // Update SITEURL in options table. Usually mass replacement will cover this but set these here just in case.
        
mysql_query"UPDATE `" $this->overridePrefix "options` SET option_value='" backupbuddy_core::dbEscape$this->restoreData['siteurl'] ) . "' WHERE option_name='siteurl' LIMIT 1" );
        
pb_backupbuddy::status'details''Modified ' mysql_affected_rows() . ' row(s) while updating Site URL in options table `' $this->overridePrefix 'options` to `' $this->restoreData['siteurl'] . '`.' );
        if ( 
mysql_error() != '' ) { pb_backupbuddy::status'error''mysql error: ' mysql_error() ); }

        
// Update HOME URL in options table. Usually mass replacement will cover this but set these here just in case.
        
if ( $this->restoreData['homeurl'] != '' ) {
            
mysql_query"UPDATE `" $this->overridePrefix "options` SET option_value='" backupbuddy_core::dbEscape$this->restoreData['homeurl'] ) . "' WHERE option_name='home' LIMIT 1" );
            
pb_backupbuddy::status'details''Modified ' mysql_affected_rows() . ' row(s) while updating Home URL in options table to `' $this->restoreData['homeurl'] . '`.' );
            if ( 
mysql_error() != '' ) { pb_backupbuddy::status'error''mysql error: ' mysql_error() ); }
        }
        
        return 
true;
    }




    
/*    verify_database()
 *    
 *    Verify various contents of the database after all migration is complete.
 *    
 *    @param        
 *    @return        
 */
    
function verifyDatabase() {

        
//pb_backupbuddy::$classes['import']->connect_database();
        
$db_prefix $this->overridePrefix;

        
// Check site URL.
        
$result mysql_query"SELECT option_value FROM `{$db_prefix}options` WHERE option_name='siteurl' LIMIT 1" );
        if ( 
$result === false ) {
            
pb_backupbuddy::status'error''Unable to retrieve siteurl from database. A portion of the database may not have imported (or with the wrong prefix).' );
        } else {
            while( 
$row mysql_fetch_row$result ) ) {
                
pb_backupbuddy::status'details''Final site URL: `' $row[0] . '`.' );
            }
            
mysql_free_result$result ); // Free memory.
        
}

        
// Check home URL.
        
$result mysql_query"SELECT option_value FROM `{$db_prefix}options` WHERE option_name='home' LIMIT 1" );
        if ( 
$result === false ) {
            
pb_backupbuddy::status'error''Unable to retrieve home [url] from database. A portion of the database may not have imported (or with the wrong prefix).' );
        } else {
            while( 
$row mysql_fetch_row$result ) ) {
                
pb_backupbuddy::status'details''Final home URL: `' $row[0] . '`.' );
            }
        }
        @
mysql_free_result$result ); // Free memory.

        // Verify media upload path.
        
$result mysql_query"SELECT option_value FROM `{$db_prefix}options` WHERE option_name='upload_path' LIMIT 1" );
        if ( 
$result === false ) {
            
pb_backupbuddy::status'error''Unable to retrieve upload_path from database table ' "`{$db_prefix}options`" '. A portion of the database may not have imported (or with the wrong prefix).' );
            
$media_upload_path '{ERR_34834984-UNKNOWN}';
        } else {
            while( 
$row mysql_fetch_row$result ) ) {
                
$media_upload_path $row[0];
            }
        }
        @
mysql_free_result$result ); // Free memory.

        
pb_backupbuddy::status'details''Media upload path in database options table: `' $media_upload_path '`.' );
        if ( 
substr$media_upload_path0) == '/' ) { // Absolute path.
            
if ( !file_exists$media_upload_path ) ) { // Media path does not exist.
                
$media_upload_message 'Your media upload path is assigned a directory which does not appear to exist on this server. Please verify it is correct in your WordPress settings. Current path: `' $media_upload_path '`.';
                
pb_backupbuddy::alert$media_upload_message );
                
pb_backupbuddy::status'warning'$media_upload_message );
            } else { 
// Media path does exist.
                
pb_backupbuddy::status'details''Your media upload path is assigned an absolute path which appears to be correct.' );
            }
        } else { 
// Relative path.
            
pb_backupbuddy::status'details''Your media upload path is assigned a relative path; validity not tested.' );
        }
        
        return 
true;

    } 
// End verifyDatabase().
    
    
    
    



    /*    _array_pairs_unique_first()
     *    
     *    Takes two arrays. Looks for any duplicate values in the first array. That item is removed. The corresponding item in the second array is removed also.
     *    Resets indexes as a courtesy while maintaining order.
     *    
     *    @param        array        $a        First array to make unique.
     *    @param        array        $b        Second array that has items removed that were in the same position as the removed duplicates found in $a.
     *    @return        
     */
    
function _array_pairs_unique_first$a$b ) {
        
$a_uniques array_unique$a ); // Get unique values in $a. Keys are maintained.
    
        
$result = array();
        
$result[0] = $a_uniques;
        
$result[1] = array_intersect_key$b$a_uniques ); // Get the part of the $b array that is missing from $a.
    
        
$result[0] = array_merge$result[0] );
        
$result[1] = array_merge$result[1] );
        return 
$result;
    } 
// End _array_pairs_unique_first().
// end class backupbuddy_migrateDB.