PluginProbe ʕ •ᴥ•ʔ
Backup Migration / 1.3.2
Backup Migration v1.3.2
2.1.6 2.1.5.2 trunk 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.6.1 1.4.7 1.4.8 1.4.9 1.4.9.1 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.5.1
backup-backup / includes / cli-handler.php
backup-backup / includes Last commit date
banner 2 years ago check 2 years ago cli 2 years ago cron 2 years ago dashboard 2 years ago database 2 years ago extracter 2 years ago htaccess 2 years ago progress 2 years ago scanner 2 years ago staging 2 years ago uploader 2 years ago zipper 2 years ago .htaccess 2 years ago activation.php 2 years ago ajax.php 2 years ago analyst.php 2 years ago backup-cli.php 2 years ago backup-heart.php 2 years ago bypasser.php 2 years ago cli-handler.php 2 years ago compatibility.php 2 years ago config.php 2 years ago constants.php 2 years ago initializer.php 2 years ago logger.php 2 years ago restore-batching.php 2 years ago
cli-handler.php
99 lines
1 <?php
2
3 // Namespace
4 namespace BMI\Plugin;
5
6 // Use classes
7 use BMI\Plugin\BMI_Logger as Logger;
8 use BMI\Plugin\Backup_Migration_Plugin as BMP;
9 use BMI\Plugin\Extracter\BMI_Extracter as Extracter;
10 use BMI\Plugin\Progress\BMI_MigrationProgress as MigrationProgress;
11
12 // Allow only PHP CLI to use this script
13 if (php_sapi_name() !== 'cli') {
14 echo 'This script it dedicated for PHP CLI';
15 exit;
16 }
17
18 function isFunctionEnabled($func) {
19 $disabled = explode(',', ini_get('disable_functions'));
20 $isDisabled = in_array($func, $disabled);
21 if (!$isDisabled && function_exists($func)) return true;
22 else return false;
23 }
24
25 // Find WordPress Path
26 function bmi_find_wordpress_base_path() {
27
28 $dir = dirname(__FILE__);
29 $previous = null;
30
31 do {
32
33 if (file_exists($dir . '/wp-load.php') && file_exists($dir . '/wp-config.php')) return $dir;
34 if ($previous == $dir) break;
35 $previous = $dir;
36
37 } while ($dir = dirname($dir));
38
39 return null;
40
41 }
42
43 // Tell WP to not use Themes and set Base Path
44 define('BASE_PATH', bmi_find_wordpress_base_path() . '/');
45 define('WP_USE_THEMES', false);
46 define('BMI_USING_CLI_FUNCTIONALITY', true);
47 if (isset($argv[1])) define('BMI_CLI_FUNCTION', $argv[1]);
48 else {
49
50 echo 'Please specify CLI function: bmi_restore [<backup_name>.zip], bmi_backup or bmi_quick_migration <backup URL>';
51 exit();
52
53 }
54
55 if (isset($argv[2])) define('BMI_CLI_ARGUMENT', $argv[2]);
56 if (isset($argv[3])) define('BMI_CLI_ARGUMENT_2', $argv[3]);
57
58 // Pseudo Server variables
59 $_SERVER['REQUEST_METHOD'] = 'CLI';
60
61 // Increase max execution time
62 if (isFunctionEnabled('headers_sent')) {
63 if (!headers_sent()) {
64 if (isFunctionEnabled('set_time_limit')) @set_time_limit(259200);
65 if (isFunctionEnabled('ini_set')) {
66 @ini_set('max_input_time', '259200');
67 @ini_set('max_execution_time', '259200');
68 @ini_set('session.gc_maxlifetime', '1200');
69 }
70 }
71 }
72
73 // Response
74 ob_start();
75 echo '100101011101' . "\n";
76
77 @header('Connection: close');
78 @header('Content-Length: ' . ob_get_length());
79
80 ob_end_clean();
81 flush();
82
83 if (isFunctionEnabled('fastcgi_finish_request') && isFunctionEnabled('is_callable') && is_callable('fastcgi_finish_request')) {
84 fastcgi_finish_request();
85 }
86
87 // Let the server know it's server-side script
88 if (isFunctionEnabled('ignore_user_abort')) {
89 @ignore_user_abort(true);
90 }
91
92 if (isFunctionEnabled('session_write_close')) {
93 @session_write_close();
94 }
95
96 // Use WP Globals and load WordPress
97 global $wp, $wp_query, $wp_the_query, $wp_rewrite, $wp_did_header;
98 require_once BASE_PATH . 'wp-load.php';
99