PluginProbe ʕ •ᴥ•ʔ
Backup Migration / 1.4.6
Backup Migration v1.4.6
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 / constants.php
backup-backup / includes Last commit date
banner 1 year ago check 1 year ago cli 1 year ago cron 1 year ago dashboard 1 year ago database 1 year ago extracter 1 year ago htaccess 1 year ago progress 1 year ago scanner 1 year ago staging 1 year ago uploader 1 year ago zipper 1 year ago .htaccess 1 year ago activation.php 1 year ago ajax.php 1 year ago analyst.php 1 year ago backup-process.php 1 year ago cli-handler.php 1 year ago compatibility.php 1 year ago config.php 1 year ago constants.php 1 year ago initializer.php 1 year ago logger.php 1 year ago
constants.php
231 lines
1 <?php
2
3 // Namespace
4 namespace BMI\Plugin;
5
6 // Exit on direct access
7 if (!defined('ABSPATH')) {
8 exit;
9 }
10
11 // Plugin includes
12 if (!defined('BMI_AUTHOR_URI')) {
13 define('BMI_AUTHOR_URI', 'https://backupbliss.com/');
14 }
15 if (!defined('BMI_API_BACKUPBLISS_PUSH')) {
16 define('BMI_API_BACKUPBLISS_PUSH', 'api.backupbliss.com');
17 }
18 if (!defined('BMI_BACKUPS_DEFAULT')) {
19 define('BMI_BACKUPS_DEFAULT', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'backup-migration');
20 }
21 if (!defined('BMI_CONFIG_DEFAULT')) {
22 define('BMI_CONFIG_DEFAULT', BMI_INCLUDES . DIRECTORY_SEPARATOR . 'htaccess' . DIRECTORY_SEPARATOR . 'default.json');
23 }
24 if (!defined('BMI_STATIC_PHP_CONFIG')) {
25 define('BMI_STATIC_PHP_CONFIG', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'backup-migration-config.php');
26 }
27 if (!defined('BMI_REV')) {
28 define('BMI_REV', 2);
29 }
30
31 // Load configuration
32 require_once BMI_INCLUDES . DIRECTORY_SEPARATOR . 'config.php';
33
34 // Database queries amount
35 if (!defined('BMI_DB_MAX_ROWS_PER_QUERY')) {
36 $db_queries = Dashboard\bmi_get_config('OTHER:DB:QUERIES');
37 if (is_numeric($db_queries)) {
38 $db_queries = intval($db_queries);
39
40 if ($db_queries > 15000 || $db_queries < 15) {
41 $db_queries = 2000;
42 }
43 }
44
45 if (!isset($db_queries) || is_null($db_queries) || !is_numeric($db_queries)) {
46 $db_queries = 2000;
47 }
48
49 define('BMI_DB_MAX_ROWS_PER_QUERY', $db_queries);
50 }
51
52 // Default constants
53 if (!defined('BMI_MAX_SEARCH_REPLACE_PAGE')) {
54 $db_sr_max_page = Dashboard\bmi_get_config('OTHER:DB:SEARCHREPLACE:MAX');
55 if (is_numeric($db_sr_max_page)) {
56 $db_sr_max_page = intval($db_sr_max_page);
57
58 if ($db_sr_max_page > 30000 || $db_sr_max_page < 10) {
59 $db_sr_max_page = 300;
60 }
61 }
62
63 if (!isset($db_sr_max_page) || is_null($db_sr_max_page) || !is_numeric($db_sr_max_page)) {
64 $db_sr_max_page = 300;
65 }
66
67 define('BMI_MAX_SEARCH_REPLACE_PAGE', $db_sr_max_page);
68 }
69 if (!defined('BMI_MAX_FILE_EXTRACTION_LIMIT')) {
70 $file_ex_max_limit = Dashboard\bmi_get_config('OTHER:FILE:EXTRACT:MAX');
71 if (is_numeric($file_ex_max_limit)) {
72 $file_ex_max_limit = intval($file_ex_max_limit);
73
74 if ($file_ex_max_limit > 20000 || $file_ex_max_limit < 50) {
75 $file_ex_max_limit = 'auto';
76 }
77 } else if (trim(strtolower($file_ex_max_limit)) == 'auto') {
78 $file_ex_max_limit = 'auto';
79 }
80
81 if ((!isset($file_ex_max_limit) || is_null($file_ex_max_limit) || !is_numeric($file_ex_max_limit)) && $file_ex_max_limit != 'auto') {
82 $file_ex_max_limit = 'auto';
83 }
84
85 define('BMI_MAX_FILE_EXTRACTION_LIMIT', $file_ex_max_limit);
86 }
87 if (!defined('BMI_CLI_EXECUTABLE')) {
88 $php_cli_path = Dashboard\bmi_get_config('OTHER:CLI:PATH');
89 if (strlen(trim($php_cli_path)) > 0) {
90 define('BMI_CLI_EXECUTABLE', $php_cli_path);
91 }
92 }
93 if (!defined('BMI_CLI_ENABLED')) {
94 $cli_enabled = Dashboard\bmi_get_config('OTHER:CLI:DISABLE') === true ? false : true;
95 if ($cli_enabled === false) {
96 define('BMI_CLI_ENABLED', $cli_enabled);
97 }
98 }
99
100 if (Dashboard\bmi_get_config('OTHER:EXPERIMENT:TIMEOUT') === true) {
101 $disabled = explode(',', ini_get('disable_functions'));
102
103 if (!function_exists('curl_version') || !function_exists('curl_exec') || !function_exists('curl_init') || in_array('curl_exec', $disabled) || in_array('curl_init', $disabled) || in_array('curl_version', $disabled)) {
104 Dashboard\bmi_set_config('OTHER:EXPERIMENT:TIMEOUT', false);
105 Dashboard\bmi_set_config('OTHER:USE:TIMEOUT:NORMAL', true);
106 }
107 }
108
109 if (!defined('BMI_LEGACY_VERSION')) {
110 $legacy = (Dashboard\bmi_get_config('OTHER:EXPERIMENT:TIMEOUT') == 'true' || Dashboard\bmi_get_config('OTHER:EXPERIMENT:TIMEOUT') === true) ? false : true;
111 define('BMI_LEGACY_VERSION', $legacy);
112 }
113 if (!defined('BMI_LEGACY_HARD_VERSION')) {
114 $legacy_hard = (Dashboard\bmi_get_config('OTHER:EXPERIMENT:TIMEOUT:HARD') == 'true' || Dashboard\bmi_get_config('OTHER:EXPERIMENT:TIMEOUT:HARD') === true) ? false : true;
115 define('BMI_LEGACY_HARD_VERSION', $legacy_hard);
116 }
117 if (!defined('BMI_FUNCTION_NORMAL')) {
118 if (BMI_LEGACY_VERSION && BMI_LEGACY_HARD_VERSION) {
119 define('BMI_FUNCTION_NORMAL', true);
120 } else {
121 define('BMI_FUNCTION_NORMAL', false);
122 }
123 }
124 if (!defined('BMI_ASSETS')) {
125 define('BMI_ASSETS', plugin_dir_url(BMI_ROOT_FILE) . 'admin');
126 }
127 if (!defined('BMI_BACKUPS_ROOT')) {
128 define('BMI_BACKUPS_ROOT', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'backup-migration');
129 }
130 if (!defined('BMI_TMP')) {
131 define('BMI_TMP', BMI_BACKUPS_ROOT . DIRECTORY_SEPARATOR . 'tmp');
132 }
133 if (!defined('BMI_BACKUPS')) {
134 define('BMI_BACKUPS', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'backup-migration' . DIRECTORY_SEPARATOR . 'backups');
135 }
136 if (!defined('BMI_STAGING')) {
137 define('BMI_STAGING', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'backup-migration' . DIRECTORY_SEPARATOR . 'staging');
138 }
139
140 // Fill folders if not removed (security)
141 if (!file_exists(BMI_BACKUPS)) {
142 mkdir(BMI_BACKUPS, 0755, true);
143 }
144 if (!file_exists(BMI_STAGING)) {
145 mkdir(BMI_STAGING, 0755, true);
146 }
147 if (!file_exists(BMI_CONFIG_DIR)) {
148 mkdir(BMI_CONFIG_DIR, 0755, true);
149 }
150 if (!file_exists(BMI_TMP)) {
151 mkdir(BMI_TMP, 0755, true);
152 }
153
154 // Secure config and logs
155 if (!file_exists(BMI_CONFIG_DIR . DIRECTORY_SEPARATOR . 'index.php')) {
156 touch(BMI_CONFIG_DIR . DIRECTORY_SEPARATOR . 'index.php');
157 }
158 if (!file_exists(BMI_CONFIG_DIR . DIRECTORY_SEPARATOR . 'index.html')) {
159 touch(BMI_CONFIG_DIR . DIRECTORY_SEPARATOR . 'index.html');
160 }
161 if (!file_exists(BMI_CONFIG_DIR . DIRECTORY_SEPARATOR . '.htaccess')) {
162 copy(BMI_INCLUDES . DIRECTORY_SEPARATOR . 'htaccess' . DIRECTORY_SEPARATOR . '.htaccess', BMI_CONFIG_DIR . DIRECTORY_SEPARATOR . '.htaccess');
163 }
164 if (!file_exists(BMI_STAGING . DIRECTORY_SEPARATOR . 'index.php')) {
165 touch(BMI_STAGING . DIRECTORY_SEPARATOR . 'index.php');
166 }
167 if (!file_exists(BMI_STAGING . DIRECTORY_SEPARATOR . 'index.html')) {
168 touch(BMI_STAGING . DIRECTORY_SEPARATOR . 'index.html');
169 }
170 if (!file_exists(BMI_STAGING . DIRECTORY_SEPARATOR . '.htaccess')) {
171 copy(BMI_INCLUDES . DIRECTORY_SEPARATOR . 'htaccess' . DIRECTORY_SEPARATOR . '.htaccess', BMI_STAGING . DIRECTORY_SEPARATOR . '.htaccess');
172 }
173 if (!file_exists(BMI_TMP . DIRECTORY_SEPARATOR . 'index.php')) {
174 touch(BMI_TMP . DIRECTORY_SEPARATOR . 'index.php');
175 }
176 if (!file_exists(BMI_TMP . DIRECTORY_SEPARATOR . 'index.html')) {
177 touch(BMI_TMP . DIRECTORY_SEPARATOR . 'index.html');
178 }
179 if (!file_exists(BMI_TMP . DIRECTORY_SEPARATOR . '.htaccess')) {
180 copy(BMI_INCLUDES . DIRECTORY_SEPARATOR . 'htaccess' . DIRECTORY_SEPARATOR . '.htaccess', BMI_TMP . DIRECTORY_SEPARATOR . '.htaccess');
181 }
182
183 // Secure backups (if in backup dir)
184 if (!file_exists(BMI_BACKUPS . DIRECTORY_SEPARATOR . 'index.php')) {
185 touch(BMI_BACKUPS . DIRECTORY_SEPARATOR . 'index.php');
186 }
187 if (!file_exists(BMI_BACKUPS . DIRECTORY_SEPARATOR . 'index.html')) {
188 touch(BMI_BACKUPS . DIRECTORY_SEPARATOR . 'index.html');
189 }
190 if (!file_exists(BMI_BACKUPS . DIRECTORY_SEPARATOR . '.htaccess')) {
191 copy(BMI_INCLUDES . DIRECTORY_SEPARATOR . 'htaccess' . DIRECTORY_SEPARATOR . '.htaccess', BMI_BACKUPS . DIRECTORY_SEPARATOR . '.htaccess');
192 }
193
194 // Tooltips
195 if (!defined('BMI_PREMIUM_TOOLTIP')) {
196 $tooltip = sanitize_text_field(__("This feature isn’t ready yet in the premium plugin, that’s why you can buy it at a <b>big discount</b>", 'backup-backup'));
197 $tooltip .= '&nbsp;– <a href="' . BMI_AUTHOR_URI . '" target="_blank">' . sanitize_text_field(__('learn more', 'backup-backup')) . '</a>.';
198 define('BMI_PREMIUM_TOOLTIP', $tooltip);
199 }
200 if (!defined('BMI_PREMIUM_TOOLTIP_R')) {
201 $tooltip_r = '– <a href="' . BMI_AUTHOR_URI . '" target="_blank">' . sanitize_text_field(__('check it out', 'backup-backup')) . '</a>.';
202 define('BMI_PREMIUM_TOOLTIP_R', $tooltip_r);
203 }
204 if (!defined('BMI_COMMING_SOON_TUNED')) {
205 $cmsx = '<b><a href="' . BMI_AUTHOR_URI . '" target="_blank" class="link-white">' . sanitize_text_field(__('Order it now at a big discount!', 'backup-backup')) . '</a></b>';
206 define('BMI_COMMING_SOON_TUNED', $cmsx);
207 }
208 if (!defined('BMI_COMMING_SOON_PRO')) {
209 $cmsv = '<p class="f16">';
210 $cmsv .= sanitize_text_field(__("Coming soon in the Premium Plugin", 'backup-backup'));
211 $cmsv .= '&nbsp;–&nbsp;' . BMI_COMMING_SOON_TUNED;
212 $cmsv .= '</p>';
213 define('BMI_COMMING_SOON_PRO', $cmsv);
214 }
215 if (!defined('BMI_ALREADY_IN_PRO')) {
216 $aisv = '<p class="f16">';
217 $aisv .= sanitize_text_field(__("Already included in the Premium Plugin", 'backup-backup'));
218 $aisv .= '&nbsp;–&nbsp;' . BMI_COMMING_SOON_TUNED;
219 $aisv .= '</p>';
220 define('BMI_ALREADY_IN_PRO', $aisv);
221 }
222 if (!defined('BMI_COMMING_SOON_FREE')) {
223 $cmsne = '<p class="f16">';
224 $cmsne .= __("Coming soon also in the free plugin", 'backup-backup') . ' – <b>' . __("stay tuned!", 'backup-backup') . '</b>';
225 $cmsne .= '</p>';
226 define('BMI_COMMING_SOON_FREE', $cmsne);
227 }
228 if (!defined('BMI_CHAT_SUPPORT_URL')) {
229 define('BMI_CHAT_SUPPORT_URL', '//code.jivosite.com/widget/qli4YP0snZ');
230 }
231