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
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
constants.php
203 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_REV')) { |
| 25 | define('BMI_REV', 2); |
| 26 | } |
| 27 | |
| 28 | // Load configuration |
| 29 | require_once BMI_INCLUDES . DIRECTORY_SEPARATOR . 'config.php'; |
| 30 | |
| 31 | // Database queries amount |
| 32 | if (!defined('BMI_DB_MAX_ROWS_PER_QUERY')) { |
| 33 | $db_queries = Dashboard\bmi_get_config('OTHER:DB:QUERIES'); |
| 34 | if (is_numeric($db_queries)) { |
| 35 | $db_queries = intval($db_queries); |
| 36 | |
| 37 | if ($db_queries > 15000 || $db_queries < 15) { |
| 38 | $db_queries = 2000; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | if (!isset($db_queries) || is_null($db_queries) || !is_numeric($db_queries)) { |
| 43 | $db_queries = 2000; |
| 44 | } |
| 45 | |
| 46 | define('BMI_DB_MAX_ROWS_PER_QUERY', $db_queries); |
| 47 | } |
| 48 | |
| 49 | // Default constants |
| 50 | if (!defined('BMI_MAX_SEARCH_REPLACE_PAGE')) { |
| 51 | $db_sr_max_page = Dashboard\bmi_get_config('OTHER:DB:SEARCHREPLACE:MAX'); |
| 52 | if (is_numeric($db_sr_max_page)) { |
| 53 | $db_sr_max_page = intval($db_sr_max_page); |
| 54 | |
| 55 | if ($db_sr_max_page > 30000 || $db_sr_max_page < 10) { |
| 56 | $db_sr_max_page = 300; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | if (!isset($db_sr_max_page) || is_null($db_sr_max_page) || !is_numeric($db_sr_max_page)) { |
| 61 | $db_sr_max_page = 300; |
| 62 | } |
| 63 | |
| 64 | define('BMI_MAX_SEARCH_REPLACE_PAGE', $db_sr_max_page); |
| 65 | } |
| 66 | if (!defined('BMI_MAX_FILE_EXTRACTION_LIMIT')) { |
| 67 | $file_ex_max_limit = Dashboard\bmi_get_config('OTHER:FILE:EXTRACT:MAX'); |
| 68 | if (is_numeric($file_ex_max_limit)) { |
| 69 | $file_ex_max_limit = intval($file_ex_max_limit); |
| 70 | |
| 71 | if ($file_ex_max_limit > 20000 || $file_ex_max_limit < 50) { |
| 72 | $file_ex_max_limit = 'auto'; |
| 73 | } |
| 74 | } else if (trim(strtolower($file_ex_max_limit)) == 'auto') { |
| 75 | $file_ex_max_limit = 'auto'; |
| 76 | } |
| 77 | |
| 78 | if ((!isset($file_ex_max_limit) || is_null($file_ex_max_limit) || !is_numeric($file_ex_max_limit)) && $file_ex_max_limit != 'auto') { |
| 79 | $file_ex_max_limit = 'auto'; |
| 80 | } |
| 81 | |
| 82 | define('BMI_MAX_FILE_EXTRACTION_LIMIT', $file_ex_max_limit); |
| 83 | } |
| 84 | if (!defined('BMI_CLI_EXECUTABLE')) { |
| 85 | $php_cli_path = Dashboard\bmi_get_config('OTHER:CLI:PATH'); |
| 86 | if (strlen(trim($php_cli_path)) > 0) { |
| 87 | define('BMI_CLI_EXECUTABLE', $php_cli_path); |
| 88 | } |
| 89 | } |
| 90 | if (!defined('BMI_CLI_ENABLED')) { |
| 91 | $cli_enabled = Dashboard\bmi_get_config('OTHER:CLI:DISABLE') === true ? false : true; |
| 92 | if ($cli_enabled === false) { |
| 93 | define('BMI_CLI_ENABLED', $cli_enabled); |
| 94 | } |
| 95 | } |
| 96 | if (!defined('BMI_LEGACY_VERSION')) { |
| 97 | $legacy = (Dashboard\bmi_get_config('OTHER:EXPERIMENT:TIMEOUT') == 'true' || Dashboard\bmi_get_config('OTHER:EXPERIMENT:TIMEOUT') === true) ? false : true; |
| 98 | define('BMI_LEGACY_VERSION', $legacy); |
| 99 | } |
| 100 | if (!defined('BMI_LEGACY_HARD_VERSION')) { |
| 101 | $legacy_hard = (Dashboard\bmi_get_config('OTHER:EXPERIMENT:TIMEOUT:HARD') == 'true' || Dashboard\bmi_get_config('OTHER:EXPERIMENT:TIMEOUT:HARD') === true) ? false : true; |
| 102 | define('BMI_LEGACY_HARD_VERSION', $legacy_hard); |
| 103 | } |
| 104 | if (!defined('BMI_FUNCTION_NORMAL')) { |
| 105 | if (BMI_LEGACY_VERSION && BMI_LEGACY_HARD_VERSION) { |
| 106 | define('BMI_FUNCTION_NORMAL', true); |
| 107 | } else { |
| 108 | define('BMI_FUNCTION_NORMAL', false); |
| 109 | } |
| 110 | } |
| 111 | if (!defined('BMI_ASSETS')) { |
| 112 | define('BMI_ASSETS', plugin_dir_url(BMI_ROOT_FILE) . 'admin'); |
| 113 | } |
| 114 | if (!defined('BMI_BACKUPS_ROOT')) { |
| 115 | define('BMI_BACKUPS_ROOT', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'backup-migration'); |
| 116 | } |
| 117 | if (!defined('BMI_BACKUPS')) { |
| 118 | define('BMI_BACKUPS', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'backup-migration' . DIRECTORY_SEPARATOR . 'backups'); |
| 119 | } |
| 120 | if (!defined('BMI_STAGING')) { |
| 121 | define('BMI_STAGING', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'backup-migration' . DIRECTORY_SEPARATOR . 'staging'); |
| 122 | } |
| 123 | |
| 124 | // Fill folders if not removed (security) |
| 125 | if (!file_exists(BMI_BACKUPS)) { |
| 126 | mkdir(BMI_BACKUPS, 0755, true); |
| 127 | } |
| 128 | if (!file_exists(BMI_STAGING)) { |
| 129 | mkdir(BMI_STAGING, 0755, true); |
| 130 | } |
| 131 | if (!file_exists(BMI_CONFIG_DIR)) { |
| 132 | mkdir(BMI_CONFIG_DIR, 0755, true); |
| 133 | } |
| 134 | |
| 135 | // Secure config and logs |
| 136 | if (!file_exists(BMI_CONFIG_DIR . DIRECTORY_SEPARATOR . 'index.php')) { |
| 137 | touch(BMI_CONFIG_DIR . DIRECTORY_SEPARATOR . 'index.php'); |
| 138 | } |
| 139 | if (!file_exists(BMI_CONFIG_DIR . DIRECTORY_SEPARATOR . 'index.html')) { |
| 140 | touch(BMI_CONFIG_DIR . DIRECTORY_SEPARATOR . 'index.html'); |
| 141 | } |
| 142 | if (!file_exists(BMI_CONFIG_DIR . DIRECTORY_SEPARATOR . '.htaccess')) { |
| 143 | copy(BMI_INCLUDES . DIRECTORY_SEPARATOR . 'htaccess' . DIRECTORY_SEPARATOR . '.htaccess', BMI_CONFIG_DIR . DIRECTORY_SEPARATOR . '.htaccess'); |
| 144 | } |
| 145 | if (!file_exists(BMI_STAGING . DIRECTORY_SEPARATOR . 'index.php')) { |
| 146 | touch(BMI_STAGING . DIRECTORY_SEPARATOR . 'index.php'); |
| 147 | } |
| 148 | if (!file_exists(BMI_STAGING . DIRECTORY_SEPARATOR . 'index.html')) { |
| 149 | touch(BMI_STAGING . DIRECTORY_SEPARATOR . 'index.html'); |
| 150 | } |
| 151 | if (!file_exists(BMI_STAGING . DIRECTORY_SEPARATOR . '.htaccess')) { |
| 152 | copy(BMI_INCLUDES . DIRECTORY_SEPARATOR . 'htaccess' . DIRECTORY_SEPARATOR . '.htaccess', BMI_STAGING . DIRECTORY_SEPARATOR . '.htaccess'); |
| 153 | } |
| 154 | |
| 155 | // Secure backups (if in backup dir) |
| 156 | if (!file_exists(BMI_BACKUPS . DIRECTORY_SEPARATOR . 'index.php')) { |
| 157 | touch(BMI_BACKUPS . DIRECTORY_SEPARATOR . 'index.php'); |
| 158 | } |
| 159 | if (!file_exists(BMI_BACKUPS . DIRECTORY_SEPARATOR . 'index.html')) { |
| 160 | touch(BMI_BACKUPS . DIRECTORY_SEPARATOR . 'index.html'); |
| 161 | } |
| 162 | if (!file_exists(BMI_BACKUPS . DIRECTORY_SEPARATOR . '.htaccess')) { |
| 163 | copy(BMI_INCLUDES . DIRECTORY_SEPARATOR . 'htaccess' . DIRECTORY_SEPARATOR . '.htaccess', BMI_BACKUPS . DIRECTORY_SEPARATOR . '.htaccess'); |
| 164 | } |
| 165 | |
| 166 | // Tooltips |
| 167 | if (!defined('BMI_PREMIUM_TOOLTIP')) { |
| 168 | $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')); |
| 169 | $tooltip .= ' – <a href="' . BMI_AUTHOR_URI . '" target="_blank">' . sanitize_text_field(__('learn more', 'backup-backup')) . '</a>.'; |
| 170 | define('BMI_PREMIUM_TOOLTIP', $tooltip); |
| 171 | } |
| 172 | if (!defined('BMI_PREMIUM_TOOLTIP_R')) { |
| 173 | $tooltip_r = '– <a href="' . BMI_AUTHOR_URI . '" target="_blank">' . sanitize_text_field(__('check it out', 'backup-backup')) . '</a>.'; |
| 174 | define('BMI_PREMIUM_TOOLTIP_R', $tooltip_r); |
| 175 | } |
| 176 | if (!defined('BMI_COMMING_SOON_TUNED')) { |
| 177 | $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>'; |
| 178 | define('BMI_COMMING_SOON_TUNED', $cmsx); |
| 179 | } |
| 180 | if (!defined('BMI_COMMING_SOON_PRO')) { |
| 181 | $cmsv = '<p class="f16">'; |
| 182 | $cmsv .= sanitize_text_field(__("Coming soon in the Premium Plugin", 'backup-backup')); |
| 183 | $cmsv .= ' – ' . BMI_COMMING_SOON_TUNED; |
| 184 | $cmsv .= '</p>'; |
| 185 | define('BMI_COMMING_SOON_PRO', $cmsv); |
| 186 | } |
| 187 | if (!defined('BMI_ALREADY_IN_PRO')) { |
| 188 | $aisv = '<p class="f16">'; |
| 189 | $aisv .= sanitize_text_field(__("Already included in the Premium Plugin", 'backup-backup')); |
| 190 | $aisv .= ' – ' . BMI_COMMING_SOON_TUNED; |
| 191 | $aisv .= '</p>'; |
| 192 | define('BMI_ALREADY_IN_PRO', $aisv); |
| 193 | } |
| 194 | if (!defined('BMI_COMMING_SOON_FREE')) { |
| 195 | $cmsne = '<p class="f16">'; |
| 196 | $cmsne .= __("Coming soon also in the free plugin", 'backup-backup') . ' – <b>' . __("stay tuned!", 'backup-backup') . '</b>'; |
| 197 | $cmsne .= '</p>'; |
| 198 | define('BMI_COMMING_SOON_FREE', $cmsne); |
| 199 | } |
| 200 | if (!defined('BMI_CHAT_SUPPORT_URL')) { |
| 201 | define('BMI_CHAT_SUPPORT_URL', '//code.jivosite.com/widget/qli4YP0snZ'); |
| 202 | } |
| 203 |