| 1 |
<?php |
| 2 |
/* |
| 3 |
* BACKUPLY |
| 4 |
* https://backuply.com |
| 5 |
* (c) Backuply Team |
| 6 |
*/ |
| 7 |
|
| 8 |
if(!function_exists('add_action')){ |
| 9 |
echo 'You are not allowed to access this page directly.'; |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
define('BACKUPLY_VERSION', '1.4.7'); |
| 14 |
define('BACKUPLY_DIR', dirname(BACKUPLY_FILE)); |
| 15 |
define('BACKUPLY_URL', plugins_url('', BACKUPLY_FILE)); |
| 16 |
define('BACKUPLY_BACKUP_DIR', str_replace('\\' , '/', WP_CONTENT_DIR).'/backuply/'); |
| 17 |
define('BACKUPLY_TIMEOUT_TIME', 300); |
| 18 |
define('BACKUPLY_DEV', file_exists(dirname(__FILE__).'/DEV.php') ? 1 : 0); |
| 19 |
|
| 20 |
if(BACKUPLY_DEV){ |
| 21 |
include_once BACKUPLY_DIR.'/DEV.php'; |
| 22 |
} |
| 23 |
|
| 24 |
// Some other constants |
| 25 |
if(!defined('BACKUPLY_API')){ |
| 26 |
define('BACKUPLY_API', 'https://api.backuply.com'); |
| 27 |
} |
| 28 |
|
| 29 |
define('BACKUPLY_DOCS', 'https://backuply.com/docs/'); |
| 30 |
define('BACKUPLY_WWW_URL', 'https://backuply.com/'); |
| 31 |
define('BACKUPLY_PRO_URL', 'https://backuply.com/pricing?from=plugin'); |
| 32 |
|
| 33 |
include_once(BACKUPLY_DIR.'/functions.php'); |
| 34 |
|
| 35 |
function backuply_died() { |
| 36 |
//backuply_log(serialize(error_get_last())); |
| 37 |
|
| 38 |
$last_error = error_get_last(); |
| 39 |
|
| 40 |
if(!$last_error){ |
| 41 |
return false; |
| 42 |
} |
| 43 |
|
| 44 |
// To show the memory limit error. |
| 45 |
if(!empty($last_error['message']) && strpos($last_error['message'], 'Allowed memory size') !== FALSE){ |
| 46 |
backuply_status_log($last_error['message'] . ' you can solve this issue by increasing PHP memory limit', 'error'); |
| 47 |
} |
| 48 |
|
| 49 |
// To show maximum time out error. |
| 50 |
if(!empty($last_error['message']) && strpos($last_error['message'], 'Maximum execution time') !== FALSE){ |
| 51 |
backuply_status_log($last_error['message'] . ' you can solve this issue by increasing PHP max_execution_time', 'error'); |
| 52 |
backuply_kill_process(); |
| 53 |
} |
| 54 |
|
| 55 |
if(!empty($last_error['message']) && !empty($last_error['types']) && $last_error['types'] == 1){ |
| 56 |
backuply_status_log($last_error['message'] . ' ' . $last_error['line'] . ' ' .$last_error['file'] . '', 'warning'); |
| 57 |
} |
| 58 |
|
| 59 |
} |
| 60 |
register_shutdown_function('backuply_died'); |
| 61 |
|
| 62 |
// Ok so we are now ready to go |
| 63 |
register_activation_hook(BACKUPLY_FILE, 'backuply_activation'); |
| 64 |
|
| 65 |
// Is called when the ADMIN enables the plugin |
| 66 |
function backuply_activation(){ |
| 67 |
global $wpdb, $error; |
| 68 |
|
| 69 |
update_option('backuply_version', BACKUPLY_VERSION); |
| 70 |
|
| 71 |
backuply_create_backup_folders(); |
| 72 |
backuply_add_htaccess(); |
| 73 |
backuply_add_web_config(); |
| 74 |
backuply_add_index_files(); |
| 75 |
backuply_set_config(); |
| 76 |
backuply_set_status_key(); |
| 77 |
backuply_add_litespeed_noabort(); |
| 78 |
} |
| 79 |
|
| 80 |
// The function that will be called when the plugin is loaded |
| 81 |
add_action('plugins_loaded', 'backuply_load_plugin'); |
| 82 |
|
| 83 |
function backuply_load_plugin(){ |
| 84 |
global $backuply; |
| 85 |
|
| 86 |
// Set the array |
| 87 |
if(empty($backuply)){ |
| 88 |
$backuply = array(); |
| 89 |
} |
| 90 |
|
| 91 |
$backuply['settings'] = get_option('backuply_settings', []); |
| 92 |
$backuply['cron'] = get_option('backuply_cron_settings', []); |
| 93 |
$backuply['auto_backup'] = false; |
| 94 |
|
| 95 |
if(!defined('BACKUPLY_PRO')){ |
| 96 |
$backuply['license'] = get_option('backuply_license', []); |
| 97 |
} |
| 98 |
|
| 99 |
$backuply['status'] = get_option('backuply_status'); |
| 100 |
$backuply['excludes'] = get_option('backuply_excludes'); |
| 101 |
$backuply['htaccess_error'] = true; |
| 102 |
$backuply['index_html_error'] = true; |
| 103 |
$backuply['debug_mode'] = !empty(get_option('backuply_debug')) ? true : false; |
| 104 |
$backuply['bcloud_key'] = get_option('bcloud_key', ''); |
| 105 |
|
| 106 |
backuply_update_check(); |
| 107 |
|
| 108 |
if(!defined('BACKUPLY_PRO') && !empty($backuply['bcloud_key'])){ |
| 109 |
include_once BACKUPLY_DIR . '/main/bcloud-cron.php'; |
| 110 |
} |
| 111 |
|
| 112 |
add_action('init', 'backuply_handle_self_call'); // To make sure all plugins are loaded. |
| 113 |
add_action('backuply_clean_tmp', 'backuply_delete_tmp'); // This is for daily cleaning of backups folder. |
| 114 |
add_action('backuply_update_quota', 'backuply_schedule_quota_updation'); // This is for scheduled quota updation |
| 115 |
|
| 116 |
if(file_exists(BACKUPLY_BACKUP_DIR . '.htaccess')) { |
| 117 |
$backuply['htaccess_error'] = false; |
| 118 |
} |
| 119 |
|
| 120 |
if(file_exists(BACKUPLY_BACKUP_DIR . 'index.html')) { |
| 121 |
$backuply['index_html_error'] = false; |
| 122 |
} |
| 123 |
|
| 124 |
add_action('admin_menu', 'backuply_admin_menu'); |
| 125 |
add_filter('cron_schedules', 'backuply_add_cron_interval'); |
| 126 |
|
| 127 |
$showing_promo = false; // flag for single nag |
| 128 |
|
| 129 |
if(is_admin() && current_user_can('install_plugins')){ |
| 130 |
add_filter('upload_mimes', 'backuply_add_mime_types'); // In case tar or gz are not supported |
| 131 |
add_action('admin_post_backuply_download_backup', 'backuply_direct_download_file'); |
| 132 |
|
| 133 |
if(isset($_REQUEST['backuply_trial_promo']) && (int)$_REQUEST['backuply_trial_promo'] == 0 ){ |
| 134 |
if(!wp_verify_nonce(backuply_optreq('security'), 'backuply_trial_nonce')) { |
| 135 |
die('Security Check Failed'); |
| 136 |
} |
| 137 |
|
| 138 |
update_option('backuply_hide_trial', (0 - time()), false); |
| 139 |
die('DONE'); |
| 140 |
} |
| 141 |
|
| 142 |
$trial_time = get_option('backuply_hide_trial', 0); |
| 143 |
|
| 144 |
// It will show one day after install |
| 145 |
if(empty($trial_time)){ |
| 146 |
$trial_time = time(); |
| 147 |
update_option('backuply_hide_trial', $trial_time, false); |
| 148 |
} |
| 149 |
|
| 150 |
if($trial_time >= 0 && empty($backuply['bcloud_key']) && $trial_time < (time() - (86400)) && isset($_GET['page']) && $_GET['page'] === 'backuply'){ |
| 151 |
$showing_promo = true; |
| 152 |
add_action('admin_notices', 'backuply_free_trial_promo'); |
| 153 |
} |
| 154 |
|
| 155 |
// Schedule for backup folder tmp cleanup. |
| 156 |
if(!wp_next_scheduled('backuply_clean_tmp')){ |
| 157 |
wp_schedule_event(time(), 'backuply_daily', 'backuply_clean_tmp'); |
| 158 |
} |
| 159 |
} |
| 160 |
|
| 161 |
// Are we pro ? |
| 162 |
if(is_admin() && !defined('BACKUPLY_PRO') && current_user_can('install_plugins')){ |
| 163 |
|
| 164 |
// The holiday promo time |
| 165 |
$holiday_time = get_option('backuply_hide_holiday'); |
| 166 |
if(empty($holiday_time) || (time() - abs($holiday_time)) > 172800){ |
| 167 |
$holiday_time = time(); |
| 168 |
update_option('backuply_hide_holiday', $holiday_time, false); |
| 169 |
} |
| 170 |
|
| 171 |
$time = date('nj'); |
| 172 |
$days = array(1225, 1224, 11); |
| 173 |
if(!empty($holiday_time) && $holiday_time > 0 && isset($_GET['page']) && $_GET['page'] === 'backuply' && in_array($time, $days) && empty($showing_promo)){ |
| 174 |
$showing_promo = true; |
| 175 |
add_action('admin_notices', 'backuply_holiday_promo'); |
| 176 |
} |
| 177 |
|
| 178 |
// Are we to disable the holiday promo for 48 hours |
| 179 |
if(isset($_REQUEST['backuply_holiday_promo']) && (int)$_REQUEST['backuply_holiday_promo'] == 0 ){ |
| 180 |
if(!wp_verify_nonce(backuply_optreq('security'), 'backuply_promo_nonce')) { |
| 181 |
die('Security Check Failed'); |
| 182 |
} |
| 183 |
|
| 184 |
update_option('backuply_hide_holiday', (0 - time()), false); |
| 185 |
die('DONE'); |
| 186 |
} |
| 187 |
|
| 188 |
// The promo time |
| 189 |
$promo_time = get_option('backuply_promo_time'); |
| 190 |
if(empty($promo_time)){ |
| 191 |
$promo_time = time(); |
| 192 |
update_option('backuply_promo_time', $promo_time, false); |
| 193 |
} |
| 194 |
|
| 195 |
// Are we to show the backuply promo, and it will show up after 7 days of install. |
| 196 |
if(empty($showing_promo) && !empty($promo_time) && $promo_time > 0 && $promo_time < (time() - (7 * 86400))){ |
| 197 |
$showing_promo = true; |
| 198 |
add_action('admin_notices', 'backuply_promo'); |
| 199 |
} |
| 200 |
|
| 201 |
// Are we to disable the promo |
| 202 |
if(isset($_REQUEST['backuply_promo']) && (int)$_REQUEST['backuply_promo'] == 0 ){ |
| 203 |
if(!wp_verify_nonce(backuply_optreq('security'), 'backuply_promo_nonce')) { |
| 204 |
die('Security Check Failed'); |
| 205 |
} |
| 206 |
|
| 207 |
update_option('backuply_promo_time', (0 - time()), false); |
| 208 |
die('DONE'); |
| 209 |
} |
| 210 |
|
| 211 |
// The offer time |
| 212 |
$offer_time = get_option('backuply_offer_time', ''); |
| 213 |
if(empty($offer_time)){ |
| 214 |
$offer_time = time(); |
| 215 |
update_option('backuply_offer_time', $offer_time, false); |
| 216 |
} |
| 217 |
|
| 218 |
// Are we to show the backuply offer, and it will show up after 7 days of install. |
| 219 |
if(empty($showing_promo) && !empty($offer_time) && ($offer_time > 0 || abs($offer_time + time()) > 15780000) && $offer_time < time() - (7 * 86400) && !empty($_GET['page']) && strpos(backuply_optget('page'), 'backuply') !== FALSE){ |
| 220 |
add_action('admin_notices', 'backuply_offer_handler'); |
| 221 |
} |
| 222 |
|
| 223 |
// Are we to disable the offer |
| 224 |
if(isset($_REQUEST['backuply_offer']) && (int)$_REQUEST['backuply_offer'] == 0 ){ |
| 225 |
if(!wp_verify_nonce(backuply_optreq('security'), 'backuply_promo_nonce')) { |
| 226 |
die('Security Check Failed'); |
| 227 |
} |
| 228 |
|
| 229 |
update_option('backuply_offer_time', (0 - time()), false); |
| 230 |
die('DONE'); |
| 231 |
} |
| 232 |
} |
| 233 |
|
| 234 |
|
| 235 |
if(is_admin() && current_user_can('activate_plugins')){ |
| 236 |
// Backup notice for user to backup the if its been a week user took a backup |
| 237 |
$last_backup = get_option('backuply_last_backup'); |
| 238 |
$backup_nag = get_option('backuply_backup_nag'); |
| 239 |
|
| 240 |
// We want to show it one day after install. |
| 241 |
if(empty($backup_nag)){ |
| 242 |
update_option('backuply_backup_nag', time() - 518400, false); |
| 243 |
} |
| 244 |
|
| 245 |
if((time() - $last_backup) >= 604800 && (time() - $backup_nag) >= 604800){ |
| 246 |
add_action('admin_notices', 'backuply_backup_nag'); |
| 247 |
} |
| 248 |
|
| 249 |
// Are we to disable the license notice for 2 months. |
| 250 |
if(isset($_REQUEST['backuply_license_notice']) && (int)$_REQUEST['backuply_license_notice'] == 0 ){ |
| 251 |
if(!wp_verify_nonce(backuply_optreq('security'), 'backuply_promo_nonce')) { |
| 252 |
die('Security Check Failed'); |
| 253 |
} |
| 254 |
|
| 255 |
update_option('backuply_license_notice', (0 - time()), false); |
| 256 |
die('DONE'); |
| 257 |
} |
| 258 |
|
| 259 |
$backuply_license_notice = get_option('backuply_license_notice', 0); |
| 260 |
|
| 261 |
if(empty($backuply_license_notice)){ |
| 262 |
$backuply_license_notice = time(); |
| 263 |
update_option('backuply_license_notice', $backuply_license_notice); |
| 264 |
} |
| 265 |
|
| 266 |
// Here we are making sure that we have license and Cloud trial has ended and if dismissed it does not shows for next 2 months. |
| 267 |
if(!empty($backuply['license']) && !empty($backuply['license']['expires']) && isset($_GET['page']) && strpos($_GET['page'], 'backuply') !== FALSE && get_option('bcloud_trial_time', 0) <= 0 && ($backuply_license_notice > 0 || (abs($backuply_license_notice) + MONTH_IN_SECONDS * 2) < time())){ |
| 268 |
$current_timestamp = time(); |
| 269 |
$expiration_timestamp = strtotime($backuply['license']['expires']); |
| 270 |
$timediff = $expiration_timestamp - $current_timestamp; |
| 271 |
|
| 272 |
if($timediff <= WEEK_IN_SECONDS){ |
| 273 |
add_action('admin_notices', 'backuply_license_renew'); |
| 274 |
} |
| 275 |
} |
| 276 |
|
| 277 |
add_action('admin_init', 'backuply_admin_init'); |
| 278 |
} |
| 279 |
|
| 280 |
// Cron for Backing Up Files/Database |
| 281 |
add_action('backuply_backup_cron', 'backuply_backup_execute'); |
| 282 |
|
| 283 |
// Cron to check for timeout |
| 284 |
add_action('backuply_timeout_check', 'backuply_timeout_check'); |
| 285 |
} |
| 286 |
|
| 287 |
// If we are doing ajax and its a backuply ajax |
| 288 |
if(wp_doing_ajax()){ |
| 289 |
include_once(BACKUPLY_DIR.'/main/ajax.php'); |
| 290 |
} |
| 291 |
|
| 292 |
/** |
| 293 |
* Looks if Backuply just got updated. |
| 294 |
*/ |
| 295 |
function backuply_update_check(){ |
| 296 |
|
| 297 |
$sql = array(); |
| 298 |
$current_version = get_option('backuply_version'); |
| 299 |
$version = (int) str_replace('.', '', $current_version); |
| 300 |
|
| 301 |
// No update required |
| 302 |
if($current_version == BACKUPLY_VERSION){ |
| 303 |
return true; |
| 304 |
} |
| 305 |
|
| 306 |
// Is it first run ? |
| 307 |
if(empty($current_version)){ |
| 308 |
backuply_activation(); |
| 309 |
return; |
| 310 |
} |
| 311 |
|
| 312 |
if($version < 108){ |
| 313 |
backuply_create_backup_folders(); |
| 314 |
backuply_add_web_config(); |
| 315 |
backuply_add_index_files(); |
| 316 |
} |
| 317 |
|
| 318 |
if($version < 109){ |
| 319 |
backuply_update_restore_key(); |
| 320 |
} |
| 321 |
|
| 322 |
if($version < 120){ |
| 323 |
backuply_keys_to_db(); |
| 324 |
|
| 325 |
$cron_settings = get_option('backuply_cron_settings'); |
| 326 |
|
| 327 |
// Updates both Backuply key and Restore key if custom cron is not enabled. |
| 328 |
if(!empty($cron_settings) && !empty($cron_settings['backuply_cron_schedule']) && $cron_settings['backuply_cron_schedule'] !== 'custom'){ |
| 329 |
backuply_set_config(); |
| 330 |
} |
| 331 |
} |
| 332 |
|
| 333 |
// Save the new Version |
| 334 |
update_option('backuply_version', BACKUPLY_VERSION); |
| 335 |
backuply_set_status_key(); // We will update the status key on every update to decrease chances of it being stolen. |
| 336 |
|
| 337 |
} |
| 338 |
|
| 339 |
// List of core files to backup |
| 340 |
function backuply_core_fileindex(){ |
| 341 |
$default_fileindex = array('index.php', 'license.txt', 'readme.html', 'wp-activate.php', 'wp-admin', 'wp-blog-header.php', 'wp-comments-post.php', 'wp-config-sample.php', 'wp-content', 'wp-cron.php', 'wp-includes', 'wp-links-opml.php', 'wp-load.php', 'wp-login.php', 'wp-mail.php', 'wp-settings.php', 'wp-signup.php', 'wp-trackback.php', 'xmlrpc.php', '.htaccess', 'wp-config.php'); |
| 342 |
|
| 343 |
return $default_fileindex; |
| 344 |
} |
| 345 |
|
| 346 |
// Shows the admin menu of Backuply |
| 347 |
function backuply_admin_menu(){ |
| 348 |
global $backuply; |
| 349 |
|
| 350 |
$capability = 'activate_plugins'; |
| 351 |
|
| 352 |
// Add the menu page |
| 353 |
add_menu_page(__('Backuply Dashboard', 'backuply'), __('Backuply', 'backuply'), $capability, 'backuply', 'backuply_settings_page_handle', BACKUPLY_URL .'/assets/images/icon.svg'); |
| 354 |
|
| 355 |
// Dashboard |
| 356 |
add_submenu_page('backuply', __('Backuply Dashboard', 'backuply'), __('Dashboard', 'backuply'), $capability, 'backuply', 'backuply_settings_page_handle'); |
| 357 |
|
| 358 |
if(defined('BACKUPLY_PRO')){ |
| 359 |
add_submenu_page('backuply', __('License', 'backuply'), __('License', 'backuply'), $capability, 'backuply-license', 'backuply_license_page_handle'); |
| 360 |
} else { |
| 361 |
add_submenu_page('backuply', __('Backuply Cloud', 'backuply'), __('Backuply Cloud', 'backuply'), $capability, 'backuply-license', 'backuply_license_page_handle'); |
| 362 |
} |
| 363 |
|
| 364 |
// Its Free |
| 365 |
if(!defined('BACKUPLY_PRO')){ |
| 366 |
|
| 367 |
// Go Pro link |
| 368 |
add_submenu_page('backuply', __('Backuply Go Pro'), __('Go Pro'), $capability, BACKUPLY_PRO_URL); |
| 369 |
|
| 370 |
} |
| 371 |
} |
| 372 |
|
| 373 |
// Backuply - Backup Page |
| 374 |
function backuply_settings_page_handle(){ |
| 375 |
include_once BACKUPLY_DIR . '/main/settings.php'; |
| 376 |
|
| 377 |
backuply_page_backup(); |
| 378 |
backuply_page_theme(); |
| 379 |
} |
| 380 |
|
| 381 |
// Backuply - License Page |
| 382 |
function backuply_license_page_handle(){ |
| 383 |
include_once BACKUPLY_DIR . '/main/license.php'; |
| 384 |
backuply_license_page(); |
| 385 |
} |
| 386 |
|
| 387 |
// Shows a nag to the user, 1 week after last backup |
| 388 |
function backuply_backup_nag(){ |
| 389 |
|
| 390 |
$last_backup = get_option('backuply_last_backup'); |
| 391 |
|
| 392 |
echo |
| 393 |
'<div class="notice notice-error is-dismissible backuply-backup-nag">'; |
| 394 |
|
| 395 |
if(!empty($last_backup)){ |
| 396 |
$time_diff = time() - $last_backup; |
| 397 |
$days = floor(abs($time_diff / 86400)); |
| 398 |
|
| 399 |
echo '<p>'. sprintf(esc_html__( 'It\'s been %1$s days you took a backup, would you like to take a backup with Backuply and secure your website!', 'backuply' ), $days).' <a href="'.menu_page_url('backuply', false).'" class="button button-primary">Backup Now</a>'.(!defined('BACKUPLY_PRO') ? ' <span style="float:right;">For automatic backup schedules please <a href="https://backuply.com/pricing" target="_blank" class="button" style="background-color:#64b450; border-color:#64b450; color:white;">Upgrade to Pro</a></span>' : '').'</p>'; |
| 400 |
} else{ |
| 401 |
echo '<p>'. esc_html__( 'You haven\'t taken a backup since you activated Backuply, Take a backup and secure your website!', 'backuply' ).' <a href="'.menu_page_url('backuply', false).'" class="button button-primary">Backup Now</a></p>'; |
| 402 |
} |
| 403 |
|
| 404 |
echo '</div>'; |
| 405 |
|
| 406 |
wp_register_script('backuply_time_nag', '', array('jquery'), '', true); |
| 407 |
wp_enqueue_script('backuply_time_nag'); |
| 408 |
|
| 409 |
wp_add_inline_script('backuply_time_nag' ,' |
| 410 |
|
| 411 |
jQuery(document).ready(function(){ |
| 412 |
jQuery(".backuply-backup-nag .notice-dismiss").on("click", function(){ |
| 413 |
|
| 414 |
jQuery.ajax({ |
| 415 |
method : "GET", |
| 416 |
url : "' . admin_url('admin-ajax.php') .'?action=backuply_hide_backup_nag&security=' . wp_create_nonce('backuply_nonce'). '", |
| 417 |
success : function(res){ |
| 418 |
console.log(res); |
| 419 |
} |
| 420 |
}); |
| 421 |
}); |
| 422 |
});' |
| 423 |
); |
| 424 |
|
| 425 |
} |
| 426 |
|
| 427 |
// Cron Schedules for WordPress cron |
| 428 |
function backuply_add_cron_interval($schedules){ |
| 429 |
// 30 Min |
| 430 |
$schedules['backuply_thirty_min'] = array( |
| 431 |
'interval' => 1800, |
| 432 |
'display' => esc_html__( 'Every 30 Minutes' ) |
| 433 |
); |
| 434 |
|
| 435 |
$schedules['backuply_one_hour'] = array( |
| 436 |
'interval' => 3600, |
| 437 |
'display' => esc_html__( 'Every One Hour' ) |
| 438 |
); |
| 439 |
|
| 440 |
$schedules['backuply_two_hours'] = array( |
| 441 |
'interval' => 7200, |
| 442 |
'display' => esc_html__( 'Every Two Hours' ) |
| 443 |
); |
| 444 |
|
| 445 |
$schedules['backuply_daily'] = array( |
| 446 |
'interval' => 86400, |
| 447 |
'display' => esc_html__( 'Once a day' ) |
| 448 |
); |
| 449 |
|
| 450 |
$schedules['backuply_weekly'] = array( |
| 451 |
'interval' => 604800, |
| 452 |
'display' => esc_html__('Once a Week') |
| 453 |
); |
| 454 |
|
| 455 |
$schedules['backuply_monthly'] = array( |
| 456 |
'interval' => 2635200, |
| 457 |
'display' => esc_html__('Once a month') |
| 458 |
); |
| 459 |
|
| 460 |
return $schedules; |
| 461 |
} |
| 462 |
|
| 463 |
// Initiates the backup |
| 464 |
function backuply_backup_execute(){ |
| 465 |
global $wpdb, $backuply, $data; |
| 466 |
|
| 467 |
// Updates the $backuply['status'] var |
| 468 |
$is_active = backuply_active(); |
| 469 |
|
| 470 |
if(empty($backuply['status'])){ |
| 471 |
return; |
| 472 |
} |
| 473 |
|
| 474 |
// Update the last active time |
| 475 |
$backuply['status']['last_update'] = time(); |
| 476 |
update_option('backuply_status', $backuply['status']); |
| 477 |
|
| 478 |
// Informaton regarding remote location |
| 479 |
$remote_location = ''; |
| 480 |
|
| 481 |
if(!empty($backuply['status']['backup_location'])){ |
| 482 |
$backuply_remote_backup_locs = get_option('backuply_remote_backup_locs'); |
| 483 |
$backup_location_id = $backuply['status']['backup_location']; |
| 484 |
$remote_location = $backuply_remote_backup_locs[$backup_location_id]; |
| 485 |
} |
| 486 |
|
| 487 |
include(BACKUPLY_DIR.'/backup_ins.php'); |
| 488 |
|
| 489 |
} |
| 490 |
|
| 491 |
function backuply_handle_self_call(){ |
| 492 |
// CURL call for bacukup when its incomplete |
| 493 |
if(isset($_GET['action']) && ($_GET['action'] === 'backuply_curl_backup' || $_GET['action'] === 'backuply_curl_upload')) { |
| 494 |
|
| 495 |
if(!wp_verify_nonce(backuply_optreq('security'), 'backuply_nonce')){ |
| 496 |
backuply_status_log('Security Check Failed', 'error'); |
| 497 |
die(); |
| 498 |
} |
| 499 |
|
| 500 |
backuply_backup_execute(); |
| 501 |
wp_send_json(array('success' => true)); |
| 502 |
} |
| 503 |
} |
| 504 |
|
| 505 |
// Show the promo |
| 506 |
function backuply_promo(){ |
| 507 |
include_once(BACKUPLY_DIR.'/main/promo.php'); |
| 508 |
|
| 509 |
backuply_base_promo(); |
| 510 |
} |
| 511 |
|
| 512 |
function backuply_holiday_promo(){ |
| 513 |
include_once(BACKUPLY_DIR.'/main/promo.php'); |
| 514 |
|
| 515 |
backuply_holiday_offers(); |
| 516 |
} |
| 517 |
|
| 518 |
function backuply_license_renew(){ |
| 519 |
if(!function_exists('backuply_check_expires')){ |
| 520 |
include_once BACKUPLY_DIR.'/main/promo.php'; |
| 521 |
} |
| 522 |
|
| 523 |
backuply_check_expires(); |
| 524 |
} |
| 525 |
|
| 526 |
function backuply_free_trial_promo(){ |
| 527 |
if(!function_exists('backuply_free_trial')){ |
| 528 |
include_once(BACKUPLY_DIR.'/main/promo.php'); |
| 529 |
} |
| 530 |
|
| 531 |
backuply_promo_scripts(); |
| 532 |
backuply_free_trial(); |
| 533 |
} |
| 534 |
|
| 535 |
function backuply_offer_handler(){ |
| 536 |
if(!function_exists('backuply_regular_offer')){ |
| 537 |
include_once(BACKUPLY_DIR.'/main/promo.php'); |
| 538 |
} |
| 539 |
|
| 540 |
backuply_regular_offer(); |
| 541 |
} |
| 542 |
|
| 543 |
function backuply_admin_init(){ |
| 544 |
|
| 545 |
if(!isset($_GET['page']) || $_GET['page'] !== 'backuply'){ |
| 546 |
return; |
| 547 |
} |
| 548 |
|
| 549 |
$litespeed_time = get_option('backuply_litespeed_notice', time()); |
| 550 |
if(extension_loaded('litespeed') && $litespeed_time <= time()){ |
| 551 |
if(!file_exists(ABSPATH .'.htaccess') || !preg_match('/noabort/i', file_get_contents(ABSPATH .'.htaccess'))){ |
| 552 |
add_action('admin_notices', 'backuply_litespeed_handler'); |
| 553 |
} |
| 554 |
} |
| 555 |
} |
| 556 |
|
| 557 |
function backuply_litespeed_handler(){ |
| 558 |
if(!function_exists('backuply_litespeed_notice')){ |
| 559 |
include_once(BACKUPLY_DIR.'/main/promo.php'); |
| 560 |
} |
| 561 |
|
| 562 |
backuply_litespeed_notice(); |
| 563 |
} |
| 564 |
|
| 565 |
|
| 566 |
// Sorry to see you going |
| 567 |
register_uninstall_hook(BACKUPLY_FILE, 'backuply_deactivation'); |
| 568 |
|
| 569 |
function backuply_deactivation(){ |
| 570 |
delete_option('backuply_version'); |
| 571 |
delete_option('backuply_cron_schedules'); |
| 572 |
delete_option('backuply_cron_settings'); |
| 573 |
delete_option('backuply_remote_backup_locs'); |
| 574 |
delete_option('backuply_notify_email_address'); |
| 575 |
delete_option('backuply_settings'); |
| 576 |
delete_option('backuply_license'); |
| 577 |
delete_option('backuply_hide_trial'); |
| 578 |
delete_option('backuply_promo_time'); |
| 579 |
delete_option('backuply_backup_stopped'); |
| 580 |
delete_option('backuply_last_restore'); |
| 581 |
delete_option('backuply_last_backup'); |
| 582 |
delete_option('backuply_hide_holiday'); |
| 583 |
delete_option('backuply_excludes'); |
| 584 |
delete_option('backuply_black_friday'); |
| 585 |
delete_option('backuply_debug'); |
| 586 |
delete_option('external_updates-backuply-pro'); |
| 587 |
delete_option('backuply_offer_time'); |
| 588 |
delete_option('backuply_backup_nag'); |
| 589 |
delete_option('backuply_config_keys'); |
| 590 |
|
| 591 |
// Cleaning all the cron events |
| 592 |
wp_clear_scheduled_hook('backuply_clean_tmp'); |
| 593 |
wp_clear_scheduled_hook('backuply_timeout_check'); |
| 594 |
} |
| 595 |
|