| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined('ABSPATH') ) |
| 4 |
die(); |
| 5 |
|
| 6 |
if( !function_exists ( 'iwp_mmb_define_constant' )) { |
| 7 |
function iwp_mmb_define_constant(){ |
| 8 |
if (!defined('IWP_DEFAULT_OTHERS_EXCLUDE')) define('IWP_DEFAULT_OTHERS_EXCLUDE','upgrade,cache,updraft,backup*,*backups,mysql.sql,debug.log,managewp,infinity-cache,backupwordpress,old-cache,nfwlog,wflogs,wishlist-backup,w3tc,logs,widget_cache,updraftplus,wpmerge-temp'); |
| 9 |
|
| 10 |
if (!defined('IWP_DEFAULT_INCLUDES')) define('IWP_DEFAULT_INCLUDES','google,wp-config.php,.htaccess'); |
| 11 |
|
| 12 |
if (!defined('IWP_DEFAULT_UPLOADS_EXCLUDE')) define('IWP_DEFAULT_UPLOADS_EXCLUDE','backup*,*backups,backwpup*,wp-clone,snapshots,db-backup,backupbuddy_backups,vcf,pb_backupbuddy,sucuri,aiowps_backups,mainwp,wp_system,wpcf7_captcha,wc-logs,siteorigin-widgets,wp-hummingbird-cache,wp-security-audit-log,backwpup-12b462-backups,backwpup-12b462-logs,backwpup-12b462-temp,Dropbox_Backup,cache'); |
| 13 |
|
| 14 |
if (!defined('IWP_DATA_OPTIONAL_TABLES')) define('IWP_DATA_OPTIONAL_TABLES', 'bwps_log,statpress,slim_stats,redirection_logs,Counterize,Counterize_Referers,Counterize_UserAgents,wbz404_logs,wbz404_redirects,tts_trafficstats,tts_referrer_stats,wponlinebackup_generations,svisitor_stat,simple_feed_stats,itsec_log,relevanssi_log,blc_instances,wysija_email_user_stat,woocommerce_sessions,et_bloom_stats,redirection_404,iwp_backup_status,iwp_file_list'); |
| 15 |
|
| 16 |
if (!defined('IWP_ZIP_EXECUTABLE')) define('IWP_ZIP_EXECUTABLE', "/usr/bin/zip,/bin/zip,/usr/local/bin/zip,/usr/sfw/bin/zip,/usr/xdg4/bin/zip,/opt/bin/zip"); |
| 17 |
|
| 18 |
if (!defined('IWP_MYSQLDUMP_EXECUTABLE')) define('IWP_MYSQLDUMP_EXECUTABLE', iwp_mmb_build_mysqldump_list()); |
| 19 |
|
| 20 |
if (!defined('IWP_WARN_FILE_SIZE')) define('IWP_WARN_FILE_SIZE', 1024*1024*250); |
| 21 |
|
| 22 |
if (!defined('IWP_WARN_DB_ROWS')) define('IWP_WARN_DB_ROWS', 150000); |
| 23 |
|
| 24 |
if (!defined('IWP_SPLIT_MIN')) define('IWP_SPLIT_MIN', 200); |
| 25 |
|
| 26 |
if (!defined('IWP_MAXBATCHFILES')) define('IWP_MAXBATCHFILES', 500); |
| 27 |
|
| 28 |
if (!defined('IWP_WARN_EMAIL_SIZE')) define('IWP_WARN_EMAIL_SIZE', 20*1048576); |
| 29 |
|
| 30 |
if (!defined('IWP_ZIP_NOCOMPRESS')) define('IWP_ZIP_NOCOMPRESS', '.jpg,.jpeg,.png,.gif,.zip,.gz,.bz2,.xz,.rar,.mp3,.mp4,.mpeg,.avi,.mov'); |
| 31 |
|
| 32 |
if (!defined('IWP_SET_TIME_LIMIT')) define('IWP_SET_TIME_LIMIT', 900); |
| 33 |
if (!defined('IWP_INITIAL_RESUME_INTERVAL')) define('IWP_INITIAL_RESUME_INTERVAL', 300); |
| 34 |
|
| 35 |
if (!defined('IWP_BINZIP_OPTS')) { |
| 36 |
$zip_nocompress = array_map('trim', explode(',', IWP_ZIP_NOCOMPRESS)); |
| 37 |
$zip_binzip_opts = ''; |
| 38 |
foreach ($zip_nocompress as $ext) { |
| 39 |
if (empty($zip_binzip_opts)) { |
| 40 |
$zip_binzip_opts = "-n $ext:".strtoupper($ext); |
| 41 |
} else { |
| 42 |
$zip_binzip_opts .= ':'.$ext.':'.strtoupper($ext); |
| 43 |
} |
| 44 |
} |
| 45 |
define('IWP_BINZIP_OPTS', $zip_binzip_opts); |
| 46 |
} |
| 47 |
|
| 48 |
if(!defined('IWP_BACKUP_DIR')){ |
| 49 |
define('IWP_BACKUP_DIR', WP_CONTENT_DIR . '/infinitewp/backups'); |
| 50 |
} |
| 51 |
|
| 52 |
if(!defined('IWP_DB_DIR')){ |
| 53 |
define('IWP_DB_DIR', IWP_BACKUP_DIR . '/iwp_db'); |
| 54 |
} |
| 55 |
|
| 56 |
if(!defined('IWP_PCLZIP_TEMPORARY_DIR')){ |
| 57 |
define('IWP_PCLZIP_TEMPORARY_DIR', WP_CONTENT_DIR . '/infinitewp/temp/'); |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
if (!function_exists('iwp_mmb_modify_cron_schedules')){ |
| 65 |
function iwp_mmb_modify_cron_schedules($schedules) { |
| 66 |
$schedules['weekly'] = array('interval' => 604800, 'display' => 'Once Weekly'); |
| 67 |
$schedules['fortnightly'] = array('interval' => 1209600, 'display' => 'Once Each Fortnight'); |
| 68 |
$schedules['monthly'] = array('interval' => 2592000, 'display' => 'Once Monthly'); |
| 69 |
$schedules['every4hours'] = array('interval' => 14400, 'display' => sprintf(__('Every %s hours', 'InfiniteWP'), 4)); |
| 70 |
$schedules['every8hours'] = array('interval' => 28800, 'display' => sprintf(__('Every %s hours', 'InfiniteWP'), 8)); |
| 71 |
return $schedules; |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
if (!function_exists('iwp_mmb_build_mysqldump_list')) { |
| 76 |
function iwp_mmb_build_mysqldump_list() { |
| 77 |
if ('win' == strtolower(substr(PHP_OS, 0, 3)) && function_exists('glob')) { |
| 78 |
$drives = array('C','D','E'); |
| 79 |
|
| 80 |
if (!empty($_SERVER['DOCUMENT_ROOT'])) { |
| 81 |
//Get the drive that this is running on |
| 82 |
$current_drive = strtoupper(substr($_SERVER['DOCUMENT_ROOT'], 0, 1)); |
| 83 |
if(!in_array($current_drive, $drives)) array_unshift($drives, $current_drive); |
| 84 |
} |
| 85 |
|
| 86 |
$directories = array(); |
| 87 |
|
| 88 |
foreach ($drives as $drive_letter) { |
| 89 |
$dir = glob("$drive_letter:\\{Program Files\\MySQL\\{,MySQL*,etc}{,\\bin,\\?},mysqldump}\\mysqldump*", GLOB_BRACE); |
| 90 |
if (is_array($dir)) $directories = array_merge($directories, $dir); |
| 91 |
} |
| 92 |
|
| 93 |
$drive_string = implode(',', $directories); |
| 94 |
return $drive_string; |
| 95 |
|
| 96 |
} else return "mysqldump,/usr/bin/mysqldump,/bin/mysqldump,/usr/local/bin/mysqldump,/usr/sfw/bin/mysqldump,/usr/xdg4/bin/mysqldump,/opt/bin/mysqldump,/usr/local/opt/mysql@5.7/bin/mysqldump"; |
| 97 |
} |
| 98 |
} |
| 99 |
|
| 100 |
if (!function_exists('gzopen') && function_exists('gzopen64')) { |
| 101 |
function gzopen($filename, $mode, $use_include_path = 0) { |
| 102 |
return gzopen64($filename, $mode, $use_include_path); |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
if (!function_exists('remove_http')) { |
| 107 |
function remove_http($url = '') |
| 108 |
{ |
| 109 |
if ($url == 'http://' OR $url == 'https://') { |
| 110 |
return $url; |
| 111 |
} |
| 112 |
return preg_replace('/^(http|https)\:\/\/(www.)?/i', '', $url); |
| 113 |
|
| 114 |
} |
| 115 |
} |
| 116 |
|
| 117 |
if (!function_exists('iwp_getSiteName')) { |
| 118 |
function iwp_getSiteName(){ |
| 119 |
$site_name = str_replace(array( |
| 120 |
"_", |
| 121 |
"/", |
| 122 |
"~" |
| 123 |
), array( |
| 124 |
"", |
| 125 |
"-", |
| 126 |
"-" |
| 127 |
), rtrim(remove_http(get_bloginfo('url')), "/")); |
| 128 |
|
| 129 |
return $site_name; |
| 130 |
} |
| 131 |
} |
| 132 |
|
| 133 |
if (!function_exists('iwp_mmb_get_backup_ID_by_taskname')) { |
| 134 |
function iwp_mmb_get_backup_ID_by_taskname($method, $taskName){ |
| 135 |
global $iwp_mmb_core, $iwp_backup_core; |
| 136 |
$backup_keys = array(); |
| 137 |
if ($method == 'advanced') { |
| 138 |
$backup_keys = $iwp_backup_core->get_timestamp_by_label($taskName); |
| 139 |
}else{ |
| 140 |
require_once($GLOBALS['iwp_mmb_plugin_dir']."/backup.class.multicall.php"); |
| 141 |
$backup_instance = new IWP_MMB_Backup_Multicall(); |
| 142 |
$backup_keys = $backup_instance->get_timestamp_by_label($taskName); |
| 143 |
} |
| 144 |
|
| 145 |
return $backup_keys; |
| 146 |
} |
| 147 |
} |