/var/www/(Del)hsihk.com/wp-content/plugins/backupbuddy/_importbuddy/_importbuddy.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
<?php
/* ImportBuddy Restore & Migration Tool - iThemes.com
 * @author Dustin Bolton
 *
 * ATTENTION: IF YOU ARE READING THIS WHILE TRYING TO LOAD IMPORTBUDDY TO RESTORE YOUR SITE:
 * Your server is not properly handling PHP files. Contact your hosting provider to fix this.
 * Notify them that PHP files are not executing and instead are outputting their code contents.
 *
 */

$php_minimum '5.1'// User's PHP must be equal or newer to this version.
//error_reporting( E_ALL );

if ( version_comparePHP_VERSION$php_minimum ) < ) {
    die( 
'ERROR #9013. See <a href="http://ithemes.com/codex/page/BackupBuddy:_Error_Codes#9013">this codex page for details</a>. Sorry! PHP version ' $php_minimum ' or newer is required for BackupBuddy to properly run. You are running PHP version ' PHP_VERSION '.' );
}

global 
$importbuddy_file;
$importbuddy_file basename__FILE__ ); // filename of importbuddy.php (or whatever it is named).

$abspath rtrimdirname__FILE__ ), '\\/' ) . '/';
define'ABSPATH'$abspath );
define'PB_BB_VERSION''#VERSION#' );
define'PB_PASSWORD''#PASSWORD#' );

// Used by wpdb class.
define('DB_CHARSET''utf8');
define('DB_COLLATE''');

@
date_default_timezone_set( @date_default_timezone_get() ); // Prevents date() from throwing a warning if the default timezone has not been set. Run prior to any file_exists()!


// Try to put an index.htm file in place during import to help prevent against file browsing. Only do if not a defined step OR a non-numeric defined step OR a defined numeric step < 5.
if (
    ( ! isset( 
$_GET['step'] ) )
    ||
    ( isset( 
$_GET['step'] ) && !is_numeric$_GET['step'] ) )
    ||
    ( isset( 
$_GET['step'] ) && is_numeric$_GET['step'] ) && ( $_GET['step'] < ) )
    )
{
    if ( ( ! 
file_existsABSPATH 'index.htm' ) ) && ( ! file_existsABSPATH 'index.php' ) ) ) {
        @
file_put_contentsABSPATH 'index.htm''<html></html>' );
    }
}


// Unpack importbuddy files into importbuddy directory.
if ( !file_existsABSPATH 'importbuddy' ) || ( ( count$_GET ) == ) && ( count$_POST ) == ) ) ) {
    
$unpack_importbuddy true;
    if ( 
file_existsABSPATH 'importbuddy' ) ) { // ImportBuddy directory already exists. We may need to re-unpack it if this file has been updated since.
        
$signature = @file_get_contentsABSPATH 'importbuddy/_signature.php' );
        
$signature trimstr_replace'<?php die(); ?>'''$signature ) );
        if ( 
md5PB_BB_VERSION PB_PASSWORD ) != $signature ) { // Signature mismatch. We will need to delete and unpack again to update.
            
echo '<!-- unlinking existing importbuddy directory. -->';
            
recursive_unlinkABSPATH 'importbuddy' );
        } else {
            
$unpack_importbuddy false;
        }
    }
    if ( 
true === $unpack_importbuddy ) {
        
unpack_importbuddy();
        @
file_put_contentsABSPATH 'importbuddy/_signature.php''<?php die(); ?>' md5PB_BB_VERSION PB_PASSWORD ) ); // Create a hash of this ImportBuddy version & password. On accessing importbuddy.php's authentication page all importbuddy files will be freshly unpacked if the importbuddy.php version and/or password mismatches to allow users to just replace importbuddy.php to upgrade ImportBuddy or password.
    
}
}



// Database wrapper.
require_once( ABSPATH 'importbuddy/classes/wp-db.php' );
global 
$wpdb;
//$wpdb = new wpdb();



if ( isset( $_GET['api'] ) && ( $_GET['api'] != '' ) ) { // API ACCESS
    
if ( $_GET['api'] == 'ping' ) {
        die( 
'pong' );
    } else {
        die( 
'Unknown API access action.' );
    }
} else { 
// NORMAL ACCESS.
    
if ( !file_existsABSPATH 'importbuddy/init.php' ) ) {
        die( 
'Error: Unable to find file `' ABSPATH 'importbuddy/init.php`. Make sure that you downloaded this script from within BackupBuddy. Copying importbuddy files from inside the plugin directory is not sufficient as many file additions are made on demand.' );
    } else {
        require_once( 
ABSPATH 'importbuddy/init.php' );
    }
}



function 
recursive_unlink$path ) {
  return 
is_file($path)?
    @
unlink($path):
array_map('recursive_unlink',glob($path.'/*'))==@rmdir($path);
}


/**
*    unpack_importbuddy()
*
*    Unpacks required files encoded in importbuddy.php into stand-alone files.
*
*    @return        null
*/
function unpack_importbuddy() {
    if ( !
is_writableABSPATH ) ) {
        echo 
'Error #224834. This directory, `' ABSPATH '`, is not write enabled according to the server. Please verify proper write permissions to continue. If this persists, contact your web hosting provider and tell them that is_writable("' ABSPATH '") returns FALSE in PHP.';
        die();
    } else {
        
$unpack_file '';
        
        
// Make sure the file is complete and contains all the packed data to the end.
        
if ( false === strposfile_get_contents__FILE__ ), '###PACKDATA' ',END' ) ) { // Concat here so we don't false positive on this line when searching.
            
die( 'ERROR: It appears your `' __FILE__ '` file is incomplete.  It may have not finished downloading or uploading completely.  Please try re-downloading the script from within BackupBuddy in WordPress (do not just copy the file from the plugin directory) and re-uploading it.' );
        }
        
        
$handle = @fopen__FILE__'r' );
        if ( 
$handle ) {
            while ( ( 
$buffer fgets$handle ) ) !== false ) {
                if ( 
substr$buffer011 ) == '###PACKDATA' ) {
                    
$packdata_commands explode','trim$buffer ) );
                    
array_shift$packdata_commands );
                    
                    if ( 
$packdata_commands[0] == 'BEGIN' ) {
                        
// Start packed data.
                    
} elseif ( $packdata_commands[0] == 'FILE_START' ) {
                        
$unpack_file $packdata_commands[2];
                    } elseif ( 
$packdata_commands[0] == 'FILE_END' ) {
                        
$unpack_file '';
                    } elseif ( 
$packdata_commands[0] == 'END' ) {
                        return;
                    }
                } else {
                    if ( 
$unpack_file != '' ) {
                        if ( !
is_dirdirnameABSPATH $unpack_file ) ) ) {
                            
$mkdir_result mkdirdirnameABSPATH $unpack_file ), 0777true ); // second param makes recursive.
                            
if ( $mkdir_result === false ) {
                                echo 
'Error #54455. Unable to mkdir `' dirnameABSPATH $unpack_file ) . '`<br>';
                            }
                        }
                        
$fileput_result file_put_contentsABSPATH $unpack_filebase64_decode$buffer ) );
                        if ( 
$fileput_result === false ) {
                            echo 
'Error #65656. Unable to put file contents to `' ABSPATH $unpack_file '`.<br>';
                        }
                    }
                }
            }
            if ( !
feof$handle ) ) {
                echo 
"Error: unexpected fgets() fail.<br>";
            }
            
fclose$handle );
        } else {
            echo 
'ERROR #54455: Unable to open `' __FILE__ '` file for reading in packaged data.<br>';
        }
    }
}
die();
?>