@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @param string $plugin_name The name of the plugin. |
| 48 | 48 | * @param string $version The version of this plugin. |
| 49 | 49 | */ |
| 50 | - public function __construct( $plugin_name, $version ) { |
|
| 50 | + public function __construct($plugin_name, $version) { |
|
| 51 | 51 | |
| 52 | 52 | $this->plugin_name = $plugin_name; |
| 53 | 53 | $this->version = $version; |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * class. |
| 74 | 74 | */ |
| 75 | 75 | |
| 76 | - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/xcloner-public.css', array(), $this->version, 'all' ); |
|
| 76 | + wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__).'css/xcloner-public.css', array(), $this->version, 'all'); |
|
| 77 | 77 | |
| 78 | 78 | } |
| 79 | 79 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * class. |
| 97 | 97 | */ |
| 98 | 98 | |
| 99 | - wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/xcloner-public.js', array( 'jquery' ), $this->version, false ); |
|
| 99 | + wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__).'js/xcloner-public.js', array('jquery'), $this->version, false); |
|
| 100 | 100 | |
| 101 | 101 | } |
| 102 | 102 | |
@@ -22,14 +22,14 @@ |
||
| 22 | 22 | { |
| 23 | 23 | $path = filter_var($option, FILTER_SANITIZE_URL); |
| 24 | 24 | |
| 25 | - try{ |
|
| 25 | + try { |
|
| 26 | 26 | $option = Util::normalizePath($path); |
| 27 | - }catch(Exception $e){ |
|
| 27 | + }catch (Exception $e) { |
|
| 28 | 28 | add_settings_error('xcloner_error_message', '', __($e->getMessage()), 'error'); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if($path and !is_dir($path)){ |
|
| 32 | - add_settings_error('xcloner_error_message', '', __(sprintf('Invalid Server Path %s',$option)), 'error'); |
|
| 31 | + if ($path and !is_dir($path)) { |
|
| 32 | + add_settings_error('xcloner_error_message', '', __(sprintf('Invalid Server Path %s', $option)), 'error'); |
|
| 33 | 33 | return false; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | |
| 25 | 25 | try{ |
| 26 | 26 | $option = Util::normalizePath($path); |
| 27 | - }catch(Exception $e){ |
|
| 27 | + } catch(Exception $e){ |
|
| 28 | 28 | add_settings_error('xcloner_error_message', '', __($e->getMessage()), 'error'); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -35,22 +35,22 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | global $wpdb; |
| 37 | 37 | |
| 38 | - if(version_compare(phpversion(), Xcloner_Activator::xcloner_minimum_version, '<')) |
|
| 38 | + if (version_compare(phpversion(), Xcloner_Activator::xcloner_minimum_version, '<')) |
|
| 39 | 39 | { |
| 40 | - wp_die('<p>'.sprintf(__("XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s"),Xcloner_Activator::xcloner_minimum_version, phpversion()).'</p>', __("XCloner Activation Error"), array( 'response'=>500, 'back_link'=>TRUE ) ); |
|
| 40 | + wp_die('<p>'.sprintf(__("XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s"), Xcloner_Activator::xcloner_minimum_version, phpversion()).'</p>', __("XCloner Activation Error"), array('response'=>500, 'back_link'=>TRUE)); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | $charset_collate = $wpdb->get_charset_collate(); |
| 44 | 44 | |
| 45 | - $installed_ver = get_option( "xcloner_db_version" ); |
|
| 45 | + $installed_ver = get_option("xcloner_db_version"); |
|
| 46 | 46 | |
| 47 | 47 | $xcloner_db_version = Xcloner_Activator::xcloner_db_version; |
| 48 | 48 | |
| 49 | - if($installed_ver != $xcloner_db_version) |
|
| 49 | + if ($installed_ver != $xcloner_db_version) |
|
| 50 | 50 | { |
| 51 | - $table_name = $wpdb->prefix . "xcloner_scheduler"; |
|
| 51 | + $table_name = $wpdb->prefix."xcloner_scheduler"; |
|
| 52 | 52 | |
| 53 | - $xcloner_schedule_sql="CREATE TABLE IF NOT EXISTS `".$table_name."` ( |
|
| 53 | + $xcloner_schedule_sql = "CREATE TABLE IF NOT EXISTS `".$table_name."` ( |
|
| 54 | 54 | `id` int(11) NOT NULL AUTO_INCREMENT, |
| 55 | 55 | `name` varchar(255) NOT NULL, |
| 56 | 56 | `recurrence` varchar(10) NOT NULL, |
@@ -63,49 +63,49 @@ discard block |
||
| 63 | 63 | PRIMARY KEY (`id`) |
| 64 | 64 | ) ".$charset_collate."; |
| 65 | 65 | "; |
| 66 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 67 | - dbDelta( $xcloner_schedule_sql ); |
|
| 66 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 67 | + dbDelta($xcloner_schedule_sql); |
|
| 68 | 68 | |
| 69 | - update_option( "xcloner_db_version", $xcloner_db_version ); |
|
| 69 | + update_option("xcloner_db_version", $xcloner_db_version); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if(!get_option('xcloner_backup_compression_level')) |
|
| 72 | + if (!get_option('xcloner_backup_compression_level')) |
|
| 73 | 73 | update_option('xcloner_backup_compression_level', 0); |
| 74 | 74 | |
| 75 | - if(!get_option('xcloner_enable_log')) |
|
| 75 | + if (!get_option('xcloner_enable_log')) |
|
| 76 | 76 | update_option('xcloner_enable_log', 1); |
| 77 | 77 | |
| 78 | - if(!get_option('xcloner_enable_mysql_backup')) |
|
| 78 | + if (!get_option('xcloner_enable_mysql_backup')) |
|
| 79 | 79 | update_option('xcloner_enable_mysql_backup', 1); |
| 80 | 80 | |
| 81 | - if(!get_option('xcloner_system_settings_page')) |
|
| 81 | + if (!get_option('xcloner_system_settings_page')) |
|
| 82 | 82 | update_option('xcloner_system_settings_page', 100); |
| 83 | 83 | |
| 84 | - if(!get_option('xcloner_files_to_process_per_request')) |
|
| 84 | + if (!get_option('xcloner_files_to_process_per_request')) |
|
| 85 | 85 | update_option('xcloner_files_to_process_per_request', 250); |
| 86 | 86 | |
| 87 | - if(!get_option('xcloner_database_records_per_request')) |
|
| 87 | + if (!get_option('xcloner_database_records_per_request')) |
|
| 88 | 88 | update_option('xcloner_database_records_per_request', 10000); |
| 89 | 89 | |
| 90 | - if(!get_option('xcloner_exclude_files_larger_than_mb')) |
|
| 90 | + if (!get_option('xcloner_exclude_files_larger_than_mb')) |
|
| 91 | 91 | update_option('xcloner_exclude_files_larger_than_mb', 0); |
| 92 | 92 | |
| 93 | - if(!get_option('xcloner_split_backup_limit')) |
|
| 93 | + if (!get_option('xcloner_split_backup_limit')) |
|
| 94 | 94 | update_option('xcloner_split_backup_limit', 2048); |
| 95 | 95 | |
| 96 | - if(!get_option('xcloner_size_limit_per_request')) |
|
| 96 | + if (!get_option('xcloner_size_limit_per_request')) |
|
| 97 | 97 | update_option('xcloner_size_limit_per_request', 50); |
| 98 | 98 | |
| 99 | - if(!get_option('xcloner_cleanup_retention_limit_days')) |
|
| 99 | + if (!get_option('xcloner_cleanup_retention_limit_days')) |
|
| 100 | 100 | update_option('xcloner_cleanup_retention_limit_days', 60); |
| 101 | 101 | |
| 102 | - if(!get_option('xcloner_cleanup_retention_limit_archives')) |
|
| 102 | + if (!get_option('xcloner_cleanup_retention_limit_archives')) |
|
| 103 | 103 | update_option('xcloner_cleanup_retention_limit_archives', 100); |
| 104 | 104 | |
| 105 | - if(!get_option('xcloner_directories_to_scan_per_request')) |
|
| 105 | + if (!get_option('xcloner_directories_to_scan_per_request')) |
|
| 106 | 106 | update_option('xcloner_directories_to_scan_per_request', 25); |
| 107 | 107 | |
| 108 | - if(!get_option('xcloner_regex_exclude')) |
|
| 108 | + if (!get_option('xcloner_regex_exclude')) |
|
| 109 | 109 | update_option('xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$".PHP_EOL."(.*)\.(svn|git)(.*)$".PHP_EOL."wp-content\/cache(.*)$"); |
| 110 | 110 | |
| 111 | 111 | } |
@@ -69,44 +69,57 @@ |
||
| 69 | 69 | update_option( "xcloner_db_version", $xcloner_db_version ); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if(!get_option('xcloner_backup_compression_level')) |
|
| 73 | - update_option('xcloner_backup_compression_level', 0); |
|
| 72 | + if(!get_option('xcloner_backup_compression_level')) { |
|
| 73 | + update_option('xcloner_backup_compression_level', 0); |
|
| 74 | + } |
|
| 74 | 75 | |
| 75 | - if(!get_option('xcloner_enable_log')) |
|
| 76 | - update_option('xcloner_enable_log', 1); |
|
| 76 | + if(!get_option('xcloner_enable_log')) { |
|
| 77 | + update_option('xcloner_enable_log', 1); |
|
| 78 | + } |
|
| 77 | 79 | |
| 78 | - if(!get_option('xcloner_enable_mysql_backup')) |
|
| 79 | - update_option('xcloner_enable_mysql_backup', 1); |
|
| 80 | + if(!get_option('xcloner_enable_mysql_backup')) { |
|
| 81 | + update_option('xcloner_enable_mysql_backup', 1); |
|
| 82 | + } |
|
| 80 | 83 | |
| 81 | - if(!get_option('xcloner_system_settings_page')) |
|
| 82 | - update_option('xcloner_system_settings_page', 100); |
|
| 84 | + if(!get_option('xcloner_system_settings_page')) { |
|
| 85 | + update_option('xcloner_system_settings_page', 100); |
|
| 86 | + } |
|
| 83 | 87 | |
| 84 | - if(!get_option('xcloner_files_to_process_per_request')) |
|
| 85 | - update_option('xcloner_files_to_process_per_request', 250); |
|
| 88 | + if(!get_option('xcloner_files_to_process_per_request')) { |
|
| 89 | + update_option('xcloner_files_to_process_per_request', 250); |
|
| 90 | + } |
|
| 86 | 91 | |
| 87 | - if(!get_option('xcloner_database_records_per_request')) |
|
| 88 | - update_option('xcloner_database_records_per_request', 10000); |
|
| 92 | + if(!get_option('xcloner_database_records_per_request')) { |
|
| 93 | + update_option('xcloner_database_records_per_request', 10000); |
|
| 94 | + } |
|
| 89 | 95 | |
| 90 | - if(!get_option('xcloner_exclude_files_larger_than_mb')) |
|
| 91 | - update_option('xcloner_exclude_files_larger_than_mb', 0); |
|
| 96 | + if(!get_option('xcloner_exclude_files_larger_than_mb')) { |
|
| 97 | + update_option('xcloner_exclude_files_larger_than_mb', 0); |
|
| 98 | + } |
|
| 92 | 99 | |
| 93 | - if(!get_option('xcloner_split_backup_limit')) |
|
| 94 | - update_option('xcloner_split_backup_limit', 2048); |
|
| 100 | + if(!get_option('xcloner_split_backup_limit')) { |
|
| 101 | + update_option('xcloner_split_backup_limit', 2048); |
|
| 102 | + } |
|
| 95 | 103 | |
| 96 | - if(!get_option('xcloner_size_limit_per_request')) |
|
| 97 | - update_option('xcloner_size_limit_per_request', 50); |
|
| 104 | + if(!get_option('xcloner_size_limit_per_request')) { |
|
| 105 | + update_option('xcloner_size_limit_per_request', 50); |
|
| 106 | + } |
|
| 98 | 107 | |
| 99 | - if(!get_option('xcloner_cleanup_retention_limit_days')) |
|
| 100 | - update_option('xcloner_cleanup_retention_limit_days', 60); |
|
| 108 | + if(!get_option('xcloner_cleanup_retention_limit_days')) { |
|
| 109 | + update_option('xcloner_cleanup_retention_limit_days', 60); |
|
| 110 | + } |
|
| 101 | 111 | |
| 102 | - if(!get_option('xcloner_cleanup_retention_limit_archives')) |
|
| 103 | - update_option('xcloner_cleanup_retention_limit_archives', 100); |
|
| 112 | + if(!get_option('xcloner_cleanup_retention_limit_archives')) { |
|
| 113 | + update_option('xcloner_cleanup_retention_limit_archives', 100); |
|
| 114 | + } |
|
| 104 | 115 | |
| 105 | - if(!get_option('xcloner_directories_to_scan_per_request')) |
|
| 106 | - update_option('xcloner_directories_to_scan_per_request', 25); |
|
| 116 | + if(!get_option('xcloner_directories_to_scan_per_request')) { |
|
| 117 | + update_option('xcloner_directories_to_scan_per_request', 25); |
|
| 118 | + } |
|
| 107 | 119 | |
| 108 | - if(!get_option('xcloner_regex_exclude')) |
|
| 109 | - update_option('xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$".PHP_EOL."(.*)\.(svn|git)(.*)$".PHP_EOL."wp-content\/cache(.*)$"); |
|
| 120 | + if(!get_option('xcloner_regex_exclude')) { |
|
| 121 | + update_option('xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$".PHP_EOL."(.*)\.(svn|git)(.*)$".PHP_EOL."wp-content\/cache(.*)$"); |
|
| 122 | + } |
|
| 110 | 123 | |
| 111 | 124 | } |
| 112 | 125 | |
@@ -147,14 +147,14 @@ |
||
| 147 | 147 | $unit_list = array('B', 'KB', 'MB', 'GB', 'PB'); |
| 148 | 148 | |
| 149 | 149 | if ($bytes == 0) { |
| 150 | - return $bytes . ' ' . $unit_list[0]; |
|
| 150 | + return $bytes . ' ' . $unit_list[0]; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | $unit_count = count($unit_list); |
| 154 | 154 | for ($i = $unit_count - 1; $i >= 0; $i--) { |
| 155 | - $power = $i * 10; |
|
| 156 | - if (($bytes >> $power) >= 1) |
|
| 157 | - return round($bytes / (1 << $power), $decimals) . ' ' . $unit_list[$i]; |
|
| 155 | + $power = $i * 10; |
|
| 156 | + if (($bytes >> $power) >= 1) |
|
| 157 | + return round($bytes / (1 << $power), $decimals) . ' ' . $unit_list[$i]; |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -3,29 +3,29 @@ discard block |
||
| 3 | 3 | class XCloner_Requirements |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | - var $min_php_version = "5.4.0"; |
|
| 7 | - var $safe_mode = "Off"; |
|
| 6 | + var $min_php_version = "5.4.0"; |
|
| 7 | + var $safe_mode = "Off"; |
|
| 8 | 8 | |
| 9 | 9 | public function __construct() |
| 10 | 10 | { |
| 11 | - $this->xcloner_settings = new Xcloner_Settings(); |
|
| 11 | + $this->xcloner_settings = new Xcloner_Settings(); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | public function check_backup_ready_status() |
| 15 | 15 | { |
| 16 | - if(!$this->check_min_php_version(1)) |
|
| 16 | + if (!$this->check_min_php_version(1)) |
|
| 17 | 17 | return false; |
| 18 | 18 | |
| 19 | - if(!$this->check_safe_mode(1)) |
|
| 19 | + if (!$this->check_safe_mode(1)) |
|
| 20 | 20 | return false; |
| 21 | 21 | |
| 22 | - if(!$this->check_xcloner_start_path(1)) |
|
| 22 | + if (!$this->check_xcloner_start_path(1)) |
|
| 23 | 23 | return false; |
| 24 | 24 | |
| 25 | - if(!$this->check_xcloner_store_path(1)) |
|
| 25 | + if (!$this->check_xcloner_store_path(1)) |
|
| 26 | 26 | return false; |
| 27 | 27 | |
| 28 | - if(!$this->check_xcloner_tmp_path(1)) |
|
| 28 | + if (!$this->check_xcloner_tmp_path(1)) |
|
| 29 | 29 | return false; |
| 30 | 30 | |
| 31 | 31 | return true; |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | public function check_min_php_version($return_bool = 0) |
| 40 | 40 | { |
| 41 | 41 | |
| 42 | - if($return_bool == 1) |
|
| 42 | + if ($return_bool == 1) |
|
| 43 | 43 | { |
| 44 | - if(version_compare(phpversion(), $this->min_php_version, '<')) |
|
| 44 | + if (version_compare(phpversion(), $this->min_php_version, '<')) |
|
| 45 | 45 | return false; |
| 46 | 46 | else |
| 47 | 47 | return true; |
@@ -50,31 +50,31 @@ discard block |
||
| 50 | 50 | return phpversion(); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - public function check_safe_mode($return_bool=0) |
|
| 53 | + public function check_safe_mode($return_bool = 0) |
|
| 54 | 54 | { |
| 55 | 55 | $safe_mode = "Off"; |
| 56 | 56 | |
| 57 | - if($return_bool) |
|
| 57 | + if ($return_bool) |
|
| 58 | 58 | { |
| 59 | - if( ini_get('safe_mode') ) |
|
| 59 | + if (ini_get('safe_mode')) |
|
| 60 | 60 | return false; |
| 61 | 61 | else |
| 62 | 62 | return true; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if( ini_get('safe_mode') ) |
|
| 65 | + if (ini_get('safe_mode')) |
|
| 66 | 66 | $safe_mode = "On"; |
| 67 | 67 | |
| 68 | 68 | return $safe_mode; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - public function check_xcloner_start_path($return_bool=0) |
|
| 71 | + public function check_xcloner_start_path($return_bool = 0) |
|
| 72 | 72 | { |
| 73 | 73 | $path = $this->xcloner_settings->get_xcloner_start_path(); |
| 74 | 74 | |
| 75 | - if($return_bool) |
|
| 75 | + if ($return_bool) |
|
| 76 | 76 | { |
| 77 | - if(!file_exists($path)) |
|
| 77 | + if (!file_exists($path)) |
|
| 78 | 78 | return false; |
| 79 | 79 | |
| 80 | 80 | return is_readable($path); |
@@ -83,16 +83,16 @@ discard block |
||
| 83 | 83 | return $path; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - public function check_xcloner_tmp_path($return_bool=0) |
|
| 86 | + public function check_xcloner_tmp_path($return_bool = 0) |
|
| 87 | 87 | { |
| 88 | 88 | $path = $this->xcloner_settings->get_xcloner_tmp_path(); |
| 89 | 89 | |
| 90 | - if($return_bool) |
|
| 90 | + if ($return_bool) |
|
| 91 | 91 | { |
| 92 | - if(!file_exists($path)) |
|
| 92 | + if (!file_exists($path)) |
|
| 93 | 93 | return false; |
| 94 | 94 | |
| 95 | - if(!is_writeable($path)) |
|
| 95 | + if (!is_writeable($path)) |
|
| 96 | 96 | @chmod($path, 0777); |
| 97 | 97 | |
| 98 | 98 | return is_writeable($path); |
@@ -101,16 +101,16 @@ discard block |
||
| 101 | 101 | return $path; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - public function check_xcloner_store_path($return_bool=0) |
|
| 104 | + public function check_xcloner_store_path($return_bool = 0) |
|
| 105 | 105 | { |
| 106 | 106 | $path = $this->xcloner_settings->get_xcloner_store_path(); |
| 107 | 107 | |
| 108 | - if($return_bool) |
|
| 108 | + if ($return_bool) |
|
| 109 | 109 | { |
| 110 | - if(!file_exists($path)) |
|
| 110 | + if (!file_exists($path)) |
|
| 111 | 111 | return false; |
| 112 | 112 | |
| 113 | - if(!is_writeable($path)) |
|
| 113 | + if (!is_writeable($path)) |
|
| 114 | 114 | @chmod($path, 0777); |
| 115 | 115 | |
| 116 | 116 | return is_writeable($path); |
@@ -131,9 +131,9 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | public function get_open_basedir() |
| 133 | 133 | { |
| 134 | - $open_basedir = ini_get('open_basedir'); |
|
| 134 | + $open_basedir = ini_get('open_basedir'); |
|
| 135 | 135 | |
| 136 | - if(!$open_basedir) |
|
| 136 | + if (!$open_basedir) |
|
| 137 | 137 | $open_basedir = "none"; |
| 138 | 138 | return $open_basedir; |
| 139 | 139 | } |
@@ -147,14 +147,14 @@ discard block |
||
| 147 | 147 | $unit_list = array('B', 'KB', 'MB', 'GB', 'PB'); |
| 148 | 148 | |
| 149 | 149 | if ($bytes == 0) { |
| 150 | - return $bytes . ' ' . $unit_list[0]; |
|
| 150 | + return $bytes.' '.$unit_list[0]; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | $unit_count = count($unit_list); |
| 154 | 154 | for ($i = $unit_count - 1; $i >= 0; $i--) { |
| 155 | 155 | $power = $i * 10; |
| 156 | 156 | if (($bytes >> $power) >= 1) |
| 157 | - return round($bytes / (1 << $power), $decimals) . ' ' . $unit_list[$i]; |
|
| 157 | + return round($bytes / (1 << $power), $decimals).' '.$unit_list[$i]; |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -13,20 +13,25 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | public function check_backup_ready_status() |
| 15 | 15 | { |
| 16 | - if(!$this->check_min_php_version(1)) |
|
| 17 | - return false; |
|
| 16 | + if(!$this->check_min_php_version(1)) { |
|
| 17 | + return false; |
|
| 18 | + } |
|
| 18 | 19 | |
| 19 | - if(!$this->check_safe_mode(1)) |
|
| 20 | - return false; |
|
| 20 | + if(!$this->check_safe_mode(1)) { |
|
| 21 | + return false; |
|
| 22 | + } |
|
| 21 | 23 | |
| 22 | - if(!$this->check_xcloner_start_path(1)) |
|
| 23 | - return false; |
|
| 24 | + if(!$this->check_xcloner_start_path(1)) { |
|
| 25 | + return false; |
|
| 26 | + } |
|
| 24 | 27 | |
| 25 | - if(!$this->check_xcloner_store_path(1)) |
|
| 26 | - return false; |
|
| 28 | + if(!$this->check_xcloner_store_path(1)) { |
|
| 29 | + return false; |
|
| 30 | + } |
|
| 27 | 31 | |
| 28 | - if(!$this->check_xcloner_tmp_path(1)) |
|
| 29 | - return false; |
|
| 32 | + if(!$this->check_xcloner_tmp_path(1)) { |
|
| 33 | + return false; |
|
| 34 | + } |
|
| 30 | 35 | |
| 31 | 36 | return true; |
| 32 | 37 | } |
@@ -41,10 +46,11 @@ discard block |
||
| 41 | 46 | |
| 42 | 47 | if($return_bool == 1) |
| 43 | 48 | { |
| 44 | - if(version_compare(phpversion(), $this->min_php_version, '<')) |
|
| 45 | - return false; |
|
| 46 | - else |
|
| 47 | - return true; |
|
| 49 | + if(version_compare(phpversion(), $this->min_php_version, '<')) { |
|
| 50 | + return false; |
|
| 51 | + } else { |
|
| 52 | + return true; |
|
| 53 | + } |
|
| 48 | 54 | } |
| 49 | 55 | |
| 50 | 56 | return phpversion(); |
@@ -56,14 +62,16 @@ discard block |
||
| 56 | 62 | |
| 57 | 63 | if($return_bool) |
| 58 | 64 | { |
| 59 | - if( ini_get('safe_mode') ) |
|
| 60 | - return false; |
|
| 61 | - else |
|
| 62 | - return true; |
|
| 65 | + if( ini_get('safe_mode') ) { |
|
| 66 | + return false; |
|
| 67 | + } else { |
|
| 68 | + return true; |
|
| 69 | + } |
|
| 63 | 70 | } |
| 64 | 71 | |
| 65 | - if( ini_get('safe_mode') ) |
|
| 66 | - $safe_mode = "On"; |
|
| 72 | + if( ini_get('safe_mode') ) { |
|
| 73 | + $safe_mode = "On"; |
|
| 74 | + } |
|
| 67 | 75 | |
| 68 | 76 | return $safe_mode; |
| 69 | 77 | } |
@@ -74,8 +82,9 @@ discard block |
||
| 74 | 82 | |
| 75 | 83 | if($return_bool) |
| 76 | 84 | { |
| 77 | - if(!file_exists($path)) |
|
| 78 | - return false; |
|
| 85 | + if(!file_exists($path)) { |
|
| 86 | + return false; |
|
| 87 | + } |
|
| 79 | 88 | |
| 80 | 89 | return is_readable($path); |
| 81 | 90 | } |
@@ -89,11 +98,13 @@ discard block |
||
| 89 | 98 | |
| 90 | 99 | if($return_bool) |
| 91 | 100 | { |
| 92 | - if(!file_exists($path)) |
|
| 93 | - return false; |
|
| 101 | + if(!file_exists($path)) { |
|
| 102 | + return false; |
|
| 103 | + } |
|
| 94 | 104 | |
| 95 | - if(!is_writeable($path)) |
|
| 96 | - @chmod($path, 0777); |
|
| 105 | + if(!is_writeable($path)) { |
|
| 106 | + @chmod($path, 0777); |
|
| 107 | + } |
|
| 97 | 108 | |
| 98 | 109 | return is_writeable($path); |
| 99 | 110 | } |
@@ -107,11 +118,13 @@ discard block |
||
| 107 | 118 | |
| 108 | 119 | if($return_bool) |
| 109 | 120 | { |
| 110 | - if(!file_exists($path)) |
|
| 111 | - return false; |
|
| 121 | + if(!file_exists($path)) { |
|
| 122 | + return false; |
|
| 123 | + } |
|
| 112 | 124 | |
| 113 | - if(!is_writeable($path)) |
|
| 114 | - @chmod($path, 0777); |
|
| 125 | + if(!is_writeable($path)) { |
|
| 126 | + @chmod($path, 0777); |
|
| 127 | + } |
|
| 115 | 128 | |
| 116 | 129 | return is_writeable($path); |
| 117 | 130 | } |
@@ -133,8 +146,9 @@ discard block |
||
| 133 | 146 | { |
| 134 | 147 | $open_basedir = ini_get('open_basedir'); |
| 135 | 148 | |
| 136 | - if(!$open_basedir) |
|
| 137 | - $open_basedir = "none"; |
|
| 149 | + if(!$open_basedir) { |
|
| 150 | + $open_basedir = "none"; |
|
| 151 | + } |
|
| 138 | 152 | return $open_basedir; |
| 139 | 153 | } |
| 140 | 154 | |
@@ -153,8 +167,9 @@ discard block |
||
| 153 | 167 | $unit_count = count($unit_list); |
| 154 | 168 | for ($i = $unit_count - 1; $i >= 0; $i--) { |
| 155 | 169 | $power = $i * 10; |
| 156 | - if (($bytes >> $power) >= 1) |
|
| 157 | - return round($bytes / (1 << $power), $decimals) . ' ' . $unit_list[$i]; |
|
| 170 | + if (($bytes >> $power) >= 1) { |
|
| 171 | + return round($bytes / (1 << $power), $decimals) . ' ' . $unit_list[$i]; |
|
| 172 | + } |
|
| 158 | 173 | } |
| 159 | 174 | } |
| 160 | 175 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | * @since 1.0.0 |
| 31 | 31 | */ |
| 32 | 32 | public static function deactivate() { |
| 33 | - if(class_exists('Xcloner_Scheduler')) |
|
| 33 | + if (class_exists('Xcloner_Scheduler')) |
|
| 34 | 34 | { |
| 35 | 35 | $xcloner_scheduler = new Xcloner_Scheduler(); |
| 36 | 36 | $xcloner_scheduler->deactivate_wp_cron_hooks(); |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | load_plugin_textdomain( |
| 38 | 38 | 'xcloner-backup-and-restore', |
| 39 | 39 | false, |
| 40 | - dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' |
|
| 40 | + dirname(dirname(plugin_basename(__FILE__))).'/languages/' |
|
| 41 | 41 | ); |
| 42 | 42 | |
| 43 | 43 | } |
@@ -4,31 +4,31 @@ discard block |
||
| 4 | 4 | use Monolog\Handler\StreamHandler; |
| 5 | 5 | use Monolog\Handler\RotatingFileHandler; |
| 6 | 6 | |
| 7 | -class Xcloner_Logger extends Logger{ |
|
| 7 | +class Xcloner_Logger extends Logger { |
|
| 8 | 8 | |
| 9 | - private $logger_path ; |
|
| 9 | + private $logger_path; |
|
| 10 | 10 | private $max_logger_files = 15; |
| 11 | 11 | private $main_logger_url; |
| 12 | 12 | |
| 13 | - public function __construct($logger_name = "xcloner_logger", $hash="") |
|
| 13 | + public function __construct($logger_name = "xcloner_logger", $hash = "") |
|
| 14 | 14 | { |
| 15 | - $xcloner_settings = new Xcloner_Settings($hash); |
|
| 15 | + $xcloner_settings = new Xcloner_Settings($hash); |
|
| 16 | 16 | $logger_path = $xcloner_settings->get_xcloner_store_path().DS.$xcloner_settings->get_logger_filename(); |
| 17 | 17 | |
| 18 | - if($hash) |
|
| 18 | + if ($hash) |
|
| 19 | 19 | $logger_path_tmp = $xcloner_settings->get_xcloner_tmp_path().DS.$xcloner_settings->get_logger_filename(1); |
| 20 | 20 | |
| 21 | 21 | |
| 22 | 22 | $this->logger_path = $logger_path; |
| 23 | 23 | //$this->logger_path_tmp = $logger_path_tmp; |
| 24 | 24 | |
| 25 | - if(!is_dir($xcloner_settings->get_xcloner_store_path()) or !is_writable($xcloner_settings->get_xcloner_store_path())) |
|
| 25 | + if (!is_dir($xcloner_settings->get_xcloner_store_path()) or !is_writable($xcloner_settings->get_xcloner_store_path())) |
|
| 26 | 26 | { |
| 27 | 27 | $logger_path = "php://stderr"; |
| 28 | 28 | $logger_path_tmp = ""; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - if(!$xcloner_settings->get_xcloner_option('xcloner_enable_log')) |
|
| 31 | + if (!$xcloner_settings->get_xcloner_option('xcloner_enable_log')) |
|
| 32 | 32 | { |
| 33 | 33 | $logger_path = "php://stderr"; |
| 34 | 34 | $logger_path_tmp = ""; |
@@ -39,17 +39,17 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $debug_level = Logger::INFO; |
| 41 | 41 | |
| 42 | - if(WP_DEBUG) |
|
| 42 | + if (WP_DEBUG) |
|
| 43 | 43 | $debug_level = Logger::DEBUG; |
| 44 | 44 | |
| 45 | 45 | |
| 46 | - if($logger_path) |
|
| 46 | + if ($logger_path) |
|
| 47 | 47 | $this->pushHandler($stream = new RotatingFileHandler($logger_path, $this->max_logger_files, $debug_level)); |
| 48 | 48 | |
| 49 | 49 | |
| 50 | - $this->main_logger_url = $stream->getUrl(); |
|
| 50 | + $this->main_logger_url = $stream->getUrl(); |
|
| 51 | 51 | |
| 52 | - if($hash and $logger_path_tmp) |
|
| 52 | + if ($hash and $logger_path_tmp) |
|
| 53 | 53 | $this->pushHandler(new StreamHandler($logger_path_tmp, $debug_level)); |
| 54 | 54 | |
| 55 | 55 | return $this; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $lines = array(); |
| 66 | 66 | |
| 67 | 67 | //if(!file_exists($this->logger_path) or !is_readable($this->logger_path)) |
| 68 | - if(!file_exists($this->main_logger_url) or !is_readable($this->main_logger_url)) |
|
| 68 | + if (!file_exists($this->main_logger_url) or !is_readable($this->main_logger_url)) |
|
| 69 | 69 | return false; |
| 70 | 70 | |
| 71 | 71 | //$fp = fopen($this->logger_path, 'r'); |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | $lastLine = ""; |
| 76 | 76 | |
| 77 | 77 | // Loop backword until we have our lines or we reach the start |
| 78 | - while($pos > 0 && count($lines) < $totalLines) { |
|
| 78 | + while ($pos > 0 && count($lines) < $totalLines) { |
|
| 79 | 79 | |
| 80 | 80 | $C = fgetc($fp); |
| 81 | - if($C == "\n") { |
|
| 81 | + if ($C == "\n") { |
|
| 82 | 82 | // skip empty lines |
| 83 | - if(trim($lastLine) != "") { |
|
| 83 | + if (trim($lastLine) != "") { |
|
| 84 | 84 | $lines[] = $lastLine; |
| 85 | 85 | } |
| 86 | 86 | $lastLine = ''; |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | $xcloner_settings = new Xcloner_Settings($hash); |
| 16 | 16 | $logger_path = $xcloner_settings->get_xcloner_store_path().DS.$xcloner_settings->get_logger_filename(); |
| 17 | 17 | |
| 18 | - if($hash) |
|
| 19 | - $logger_path_tmp = $xcloner_settings->get_xcloner_tmp_path().DS.$xcloner_settings->get_logger_filename(1); |
|
| 18 | + if($hash) { |
|
| 19 | + $logger_path_tmp = $xcloner_settings->get_xcloner_tmp_path().DS.$xcloner_settings->get_logger_filename(1); |
|
| 20 | + } |
|
| 20 | 21 | |
| 21 | 22 | |
| 22 | 23 | $this->logger_path = $logger_path; |
@@ -39,18 +40,21 @@ discard block |
||
| 39 | 40 | |
| 40 | 41 | $debug_level = Logger::INFO; |
| 41 | 42 | |
| 42 | - if(WP_DEBUG) |
|
| 43 | - $debug_level = Logger::DEBUG; |
|
| 43 | + if(WP_DEBUG) { |
|
| 44 | + $debug_level = Logger::DEBUG; |
|
| 45 | + } |
|
| 44 | 46 | |
| 45 | 47 | |
| 46 | - if($logger_path) |
|
| 47 | - $this->pushHandler($stream = new RotatingFileHandler($logger_path, $this->max_logger_files, $debug_level)); |
|
| 48 | + if($logger_path) { |
|
| 49 | + $this->pushHandler($stream = new RotatingFileHandler($logger_path, $this->max_logger_files, $debug_level)); |
|
| 50 | + } |
|
| 48 | 51 | |
| 49 | 52 | |
| 50 | 53 | $this->main_logger_url = $stream->getUrl(); |
| 51 | 54 | |
| 52 | - if($hash and $logger_path_tmp) |
|
| 53 | - $this->pushHandler(new StreamHandler($logger_path_tmp, $debug_level)); |
|
| 55 | + if($hash and $logger_path_tmp) { |
|
| 56 | + $this->pushHandler(new StreamHandler($logger_path_tmp, $debug_level)); |
|
| 57 | + } |
|
| 54 | 58 | |
| 55 | 59 | return $this; |
| 56 | 60 | } |
@@ -65,8 +69,9 @@ discard block |
||
| 65 | 69 | $lines = array(); |
| 66 | 70 | |
| 67 | 71 | //if(!file_exists($this->logger_path) or !is_readable($this->logger_path)) |
| 68 | - if(!file_exists($this->main_logger_url) or !is_readable($this->main_logger_url)) |
|
| 69 | - return false; |
|
| 72 | + if(!file_exists($this->main_logger_url) or !is_readable($this->main_logger_url)) { |
|
| 73 | + return false; |
|
| 74 | + } |
|
| 70 | 75 | |
| 71 | 76 | //$fp = fopen($this->logger_path, 'r'); |
| 72 | 77 | $fp = fopen($this->main_logger_url, 'r'); |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class Xcloner_Scheduler{ |
|
| 3 | +class Xcloner_Scheduler { |
|
| 4 | 4 | |
| 5 | 5 | private $db; |
| 6 | 6 | private $scheduler_table = "xcloner_scheduler"; |
@@ -15,23 +15,23 @@ discard block |
||
| 15 | 15 | global $wpdb; |
| 16 | 16 | $this->db = $wpdb; |
| 17 | 17 | |
| 18 | - $wpdb->show_errors = false; |
|
| 18 | + $wpdb->show_errors = false; |
|
| 19 | 19 | |
| 20 | 20 | $this->xcloner_settings = new Xcloner_Settings(); |
| 21 | 21 | |
| 22 | 22 | $this->scheduler_table = $this->db->prefix.$this->scheduler_table; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function get_scheduler_list($return_only_enabled = 0 ) |
|
| 25 | + public function get_scheduler_list($return_only_enabled = 0) |
|
| 26 | 26 | { |
| 27 | 27 | $list = $this->db->get_results("SELECT * FROM ".$this->scheduler_table); |
| 28 | 28 | |
| 29 | - if($return_only_enabled) |
|
| 29 | + if ($return_only_enabled) |
|
| 30 | 30 | { |
| 31 | - $new_list= array(); |
|
| 31 | + $new_list = array(); |
|
| 32 | 32 | |
| 33 | - foreach($list as $res) |
|
| 34 | - if($res->status) |
|
| 33 | + foreach ($list as $res) |
|
| 34 | + if ($res->status) |
|
| 35 | 35 | { |
| 36 | 36 | $res->next_run_time = wp_next_scheduled('xcloner_scheduler_'.$res->id, array($res->id)); |
| 37 | 37 | $new_list[] = $res; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | { |
| 60 | 60 | $data = $this->db->get_row("SELECT * FROM ".$this->scheduler_table." WHERE id=".$id, ARRAY_A); |
| 61 | 61 | |
| 62 | - if(!$data) |
|
| 62 | + if (!$data) |
|
| 63 | 63 | return false; |
| 64 | 64 | |
| 65 | 65 | $params = json_decode($data['params']); |
@@ -76,10 +76,10 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | public function delete_schedule_by_id($id) |
| 78 | 78 | { |
| 79 | - $hook = 'xcloner_scheduler_'.$id; |
|
| 80 | - wp_clear_scheduled_hook( $hook, array($id) ); |
|
| 79 | + $hook = 'xcloner_scheduler_'.$id; |
|
| 80 | + wp_clear_scheduled_hook($hook, array($id)); |
|
| 81 | 81 | |
| 82 | - $data = $this->db->delete( $this->scheduler_table , array( 'id' => $id ) ); |
|
| 82 | + $data = $this->db->delete($this->scheduler_table, array('id' => $id)); |
|
| 83 | 83 | |
| 84 | 84 | return $data; |
| 85 | 85 | } |
@@ -88,12 +88,12 @@ discard block |
||
| 88 | 88 | { |
| 89 | 89 | $list = $this->get_scheduler_list(); |
| 90 | 90 | |
| 91 | - foreach($list as $schedule) |
|
| 91 | + foreach ($list as $schedule) |
|
| 92 | 92 | { |
| 93 | - $hook = 'xcloner_scheduler_'.$schedule->id; |
|
| 93 | + $hook = 'xcloner_scheduler_'.$schedule->id; |
|
| 94 | 94 | |
| 95 | - $timestamp = wp_next_scheduled( $hook , array($schedule->id) ); |
|
| 96 | - wp_unschedule_event( $timestamp, $hook, array($schedule->id) ); |
|
| 95 | + $timestamp = wp_next_scheduled($hook, array($schedule->id)); |
|
| 96 | + wp_unschedule_event($timestamp, $hook, array($schedule->id)); |
|
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
@@ -101,24 +101,24 @@ discard block |
||
| 101 | 101 | { |
| 102 | 102 | $list = $this->get_scheduler_list(); |
| 103 | 103 | |
| 104 | - foreach($list as $schedule) |
|
| 104 | + foreach ($list as $schedule) |
|
| 105 | 105 | { |
| 106 | - $hook = 'xcloner_scheduler_'.$schedule->id; |
|
| 106 | + $hook = 'xcloner_scheduler_'.$schedule->id; |
|
| 107 | 107 | |
| 108 | 108 | //adding the xcloner_scheduler hook with xcloner_scheduler_callback callback |
| 109 | - add_action( $hook, array($this, 'xcloner_scheduler_callback'), 10, 1 ); |
|
| 109 | + add_action($hook, array($this, 'xcloner_scheduler_callback'), 10, 1); |
|
| 110 | 110 | |
| 111 | - if ( ! wp_next_scheduled( $hook, array($schedule->id) ) and $schedule->status) { |
|
| 111 | + if (!wp_next_scheduled($hook, array($schedule->id)) and $schedule->status) { |
|
| 112 | 112 | |
| 113 | - if($schedule->recurrence == "single") |
|
| 114 | - wp_schedule_single_event( strtotime($schedule->start_at), $hook, array($schedule->id)); |
|
| 113 | + if ($schedule->recurrence == "single") |
|
| 114 | + wp_schedule_single_event(strtotime($schedule->start_at), $hook, array($schedule->id)); |
|
| 115 | 115 | else |
| 116 | - wp_schedule_event( strtotime($schedule->start_at), $schedule->recurrence, $hook, array($schedule->id) ); |
|
| 116 | + wp_schedule_event(strtotime($schedule->start_at), $schedule->recurrence, $hook, array($schedule->id)); |
|
| 117 | 117 | |
| 118 | - }elseif(!$schedule->status) |
|
| 118 | + }elseif (!$schedule->status) |
|
| 119 | 119 | { |
| 120 | - $timestamp = wp_next_scheduled( $hook , array($schedule->id) ); |
|
| 121 | - wp_unschedule_event( $timestamp, $hook, array($schedule->id) ); |
|
| 120 | + $timestamp = wp_next_scheduled($hook, array($schedule->id)); |
|
| 121 | + wp_unschedule_event($timestamp, $hook, array($schedule->id)); |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
@@ -127,17 +127,17 @@ discard block |
||
| 127 | 127 | public function update_cron_hook($id) |
| 128 | 128 | { |
| 129 | 129 | $schedule = $this->get_schedule_by_id_object($id); |
| 130 | - $hook = 'xcloner_scheduler_'.$schedule->id; |
|
| 130 | + $hook = 'xcloner_scheduler_'.$schedule->id; |
|
| 131 | 131 | |
| 132 | - $timestamp = wp_next_scheduled( $hook , array($schedule->id) ); |
|
| 133 | - wp_unschedule_event( $timestamp, $hook, array($schedule->id) ); |
|
| 132 | + $timestamp = wp_next_scheduled($hook, array($schedule->id)); |
|
| 133 | + wp_unschedule_event($timestamp, $hook, array($schedule->id)); |
|
| 134 | 134 | |
| 135 | 135 | if ($schedule->status) { |
| 136 | 136 | |
| 137 | - if($schedule->recurrence == "single") |
|
| 138 | - wp_schedule_single_event( strtotime($schedule->start_at), $hook, array($schedule->id)); |
|
| 139 | - else{ |
|
| 140 | - wp_schedule_event( strtotime($schedule->start_at), $schedule->recurrence, $hook, array($schedule->id) ); |
|
| 137 | + if ($schedule->recurrence == "single") |
|
| 138 | + wp_schedule_single_event(strtotime($schedule->start_at), $hook, array($schedule->id)); |
|
| 139 | + else { |
|
| 140 | + wp_schedule_event(strtotime($schedule->start_at), $schedule->recurrence, $hook, array($schedule->id)); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | } |
@@ -145,16 +145,16 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | public function disable_single_cron($schedule_id) |
| 147 | 147 | { |
| 148 | - $hook = 'xcloner_scheduler_'.$schedule_id; |
|
| 149 | - $timestamp = wp_next_scheduled( $hook , array($schedule_id) ); |
|
| 150 | - wp_unschedule_event( $timestamp, $hook, array($schedule_id) ); |
|
| 148 | + $hook = 'xcloner_scheduler_'.$schedule_id; |
|
| 149 | + $timestamp = wp_next_scheduled($hook, array($schedule_id)); |
|
| 150 | + wp_unschedule_event($timestamp, $hook, array($schedule_id)); |
|
| 151 | 151 | |
| 152 | 152 | $schedule['status'] = 0; |
| 153 | 153 | |
| 154 | 154 | $update = $this->db->update( |
| 155 | 155 | $this->scheduler_table, |
| 156 | 156 | $schedule, |
| 157 | - array( 'id' => $schedule_id ), |
|
| 157 | + array('id' => $schedule_id), |
|
| 158 | 158 | array( |
| 159 | 159 | '%s', |
| 160 | 160 | '%s' |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $update = $this->db->update( |
| 171 | 171 | $this->scheduler_table, |
| 172 | 172 | $schedule, |
| 173 | - array( 'id' => $schedule_id ), |
|
| 173 | + array('id' => $schedule_id), |
|
| 174 | 174 | array( |
| 175 | 175 | '%s', |
| 176 | 176 | '%s' |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | $update = $this->db->update( |
| 187 | 187 | $this->scheduler_table, |
| 188 | 188 | $schedule, |
| 189 | - array( 'id' => $schedule_id ), |
|
| 189 | + array('id' => $schedule_id), |
|
| 190 | 190 | array( |
| 191 | 191 | '%s', |
| 192 | 192 | '%s' |
@@ -201,20 +201,20 @@ discard block |
||
| 201 | 201 | |
| 202 | 202 | $this->xcloner_settings->generate_new_hash(); |
| 203 | 203 | |
| 204 | - $this->xcloner_file_system = new Xcloner_File_System($this->xcloner_settings->get_hash()); |
|
| 205 | - $this->xcloner_database = new XCloner_Database($this->xcloner_settings->get_hash()); |
|
| 206 | - $this->archive_system = new Xcloner_Archive($this->xcloner_settings->get_hash()); |
|
| 207 | - $this->logger = new XCloner_Logger('xcloner_scheduler', $this->xcloner_settings->get_hash()); |
|
| 208 | - $this->xcloner_remote_storage = new Xcloner_Remote_Storage($this->xcloner_settings->get_hash()); |
|
| 204 | + $this->xcloner_file_system = new Xcloner_File_System($this->xcloner_settings->get_hash()); |
|
| 205 | + $this->xcloner_database = new XCloner_Database($this->xcloner_settings->get_hash()); |
|
| 206 | + $this->archive_system = new Xcloner_Archive($this->xcloner_settings->get_hash()); |
|
| 207 | + $this->logger = new XCloner_Logger('xcloner_scheduler', $this->xcloner_settings->get_hash()); |
|
| 208 | + $this->xcloner_remote_storage = new Xcloner_Remote_Storage($this->xcloner_settings->get_hash()); |
|
| 209 | 209 | |
| 210 | 210 | //$schedule = $this->get_schedule_by_id($id); |
| 211 | 211 | |
| 212 | - if($schedule['recurrence'] == "single") |
|
| 212 | + if ($schedule['recurrence'] == "single") |
|
| 213 | 213 | { |
| 214 | 214 | $this->disable_single_cron($schedule['id']); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - if(!$schedule) |
|
| 217 | + if (!$schedule) |
|
| 218 | 218 | { |
| 219 | 219 | $this->logger->info(sprintf("Could not load schedule with id'%s'", $id), array("CRON")); |
| 220 | 220 | return; |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | $init = 1; |
| 230 | 230 | $continue = 1; |
| 231 | 231 | |
| 232 | - while($continue) |
|
| 232 | + while ($continue) |
|
| 233 | 233 | { |
| 234 | 234 | $continue = $this->xcloner_file_system->start_file_recursion($init); |
| 235 | 235 | |
@@ -244,9 +244,9 @@ discard block |
||
| 244 | 244 | $extra = array(); |
| 245 | 245 | $return['finished'] = 0; |
| 246 | 246 | |
| 247 | - while(!$return['finished']) |
|
| 247 | + while (!$return['finished']) |
|
| 248 | 248 | { |
| 249 | - $return = $this->xcloner_database->start_database_recursion((array)json_decode($schedule['table_params']), $return, $init); |
|
| 249 | + $return = $this->xcloner_database->start_database_recursion((array)json_decode($schedule['table_params']), $return, $init); |
|
| 250 | 250 | $init = 0; |
| 251 | 251 | } |
| 252 | 252 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | $return['finished'] = 0; |
| 260 | 260 | $return['extra'] = array(); |
| 261 | 261 | |
| 262 | - while(!$return['finished']) |
|
| 262 | + while (!$return['finished']) |
|
| 263 | 263 | { |
| 264 | 264 | $return = $this->archive_system->start_incremental_backup((array)$schedule['backup_params'], $return['extra'], $init); |
| 265 | 265 | $init = 0; |
@@ -268,28 +268,28 @@ discard block |
||
| 268 | 268 | |
| 269 | 269 | //getting the last backup archive file |
| 270 | 270 | $return['extra']['backup_parent'] = $this->archive_system->get_archive_name_with_extension(); |
| 271 | - if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) |
|
| 271 | + if ($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) |
|
| 272 | 272 | $return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart(); |
| 273 | 273 | |
| 274 | 274 | $this->update_last_backup($schedule['id'], $return['extra']['backup_parent']); |
| 275 | 275 | |
| 276 | - if($schedule['remote_storage'] and array_key_exists($schedule['remote_storage'], $this->xcloner_remote_storage->get_available_storages())) |
|
| 276 | + if ($schedule['remote_storage'] and array_key_exists($schedule['remote_storage'], $this->xcloner_remote_storage->get_available_storages())) |
|
| 277 | 277 | { |
| 278 | 278 | $backup_file = $return['extra']['backup_parent']; |
| 279 | 279 | |
| 280 | 280 | $this->logger->info(sprintf("Transferring backup to remote storage %s", strtoupper($schedule['remote_storage'])), array("CRON")); |
| 281 | 281 | |
| 282 | - if(method_exists($this->xcloner_remote_storage, "upload_backup_to_storage")) |
|
| 282 | + if (method_exists($this->xcloner_remote_storage, "upload_backup_to_storage")) |
|
| 283 | 283 | $return_storage = call_user_func_array(array($this->xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $schedule['remote_storage'])); |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | |
| 287 | - if(isset($schedule['backup_params']->email_notification) and $to=$schedule['backup_params']->email_notification) |
|
| 287 | + if (isset($schedule['backup_params']->email_notification) and $to = $schedule['backup_params']->email_notification) |
|
| 288 | 288 | { |
| 289 | - try{ |
|
| 289 | + try { |
|
| 290 | 290 | $from = "XCloner Schedule - ".$schedule['name']; |
| 291 | 291 | $this->archive_system->send_notification($to, $from, "", $return['extra']['backup_parent'], $schedule); |
| 292 | - }catch(Exception $e) |
|
| 292 | + }catch (Exception $e) |
|
| 293 | 293 | { |
| 294 | 294 | $this->logger->error($e->getMessage()); |
| 295 | 295 | } |
@@ -304,16 +304,16 @@ discard block |
||
| 304 | 304 | { |
| 305 | 305 | $schedule = $this->get_schedule_by_id($id); |
| 306 | 306 | |
| 307 | - try{ |
|
| 307 | + try { |
|
| 308 | 308 | |
| 309 | 309 | $this->__xcloner_scheduler_callback($id, $schedule); |
| 310 | 310 | |
| 311 | - }catch(Exception $e){ |
|
| 311 | + }catch (Exception $e) { |
|
| 312 | 312 | |
| 313 | - if(isset($schedule['backup_params']->email_notification) and $to=$schedule['backup_params']->email_notification) |
|
| 313 | + if (isset($schedule['backup_params']->email_notification) and $to = $schedule['backup_params']->email_notification) |
|
| 314 | 314 | { |
| 315 | 315 | $from = "XCloner Schedule - ".$schedule['name']; |
| 316 | - $this->archive_system->send_notification($to, $from, "Scheduled backup error","", "", $e->getMessage()); |
|
| 316 | + $this->archive_system->send_notification($to, $from, "Scheduled backup error", "", "", $e->getMessage()); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | } |
@@ -30,10 +30,11 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $new_list= array(); |
| 32 | 32 | |
| 33 | - foreach($list as $res) |
|
| 34 | - if($res->status) |
|
| 33 | + foreach($list as $res) { |
|
| 34 | + if($res->status) |
|
| 35 | 35 | { |
| 36 | 36 | $res->next_run_time = wp_next_scheduled('xcloner_scheduler_'.$res->id, array($res->id)); |
| 37 | + } |
|
| 37 | 38 | $new_list[] = $res; |
| 38 | 39 | } |
| 39 | 40 | $list = $new_list; |
@@ -59,8 +60,9 @@ discard block |
||
| 59 | 60 | { |
| 60 | 61 | $data = $this->db->get_row("SELECT * FROM ".$this->scheduler_table." WHERE id=".$id, ARRAY_A); |
| 61 | 62 | |
| 62 | - if(!$data) |
|
| 63 | - return false; |
|
| 63 | + if(!$data) { |
|
| 64 | + return false; |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | $params = json_decode($data['params']); |
| 66 | 68 | |
@@ -110,12 +112,13 @@ discard block |
||
| 110 | 112 | |
| 111 | 113 | if ( ! wp_next_scheduled( $hook, array($schedule->id) ) and $schedule->status) { |
| 112 | 114 | |
| 113 | - if($schedule->recurrence == "single") |
|
| 114 | - wp_schedule_single_event( strtotime($schedule->start_at), $hook, array($schedule->id)); |
|
| 115 | - else |
|
| 116 | - wp_schedule_event( strtotime($schedule->start_at), $schedule->recurrence, $hook, array($schedule->id) ); |
|
| 115 | + if($schedule->recurrence == "single") { |
|
| 116 | + wp_schedule_single_event( strtotime($schedule->start_at), $hook, array($schedule->id)); |
|
| 117 | + } else { |
|
| 118 | + wp_schedule_event( strtotime($schedule->start_at), $schedule->recurrence, $hook, array($schedule->id) ); |
|
| 119 | + } |
|
| 117 | 120 | |
| 118 | - }elseif(!$schedule->status) |
|
| 121 | + } elseif(!$schedule->status) |
|
| 119 | 122 | { |
| 120 | 123 | $timestamp = wp_next_scheduled( $hook , array($schedule->id) ); |
| 121 | 124 | wp_unschedule_event( $timestamp, $hook, array($schedule->id) ); |
@@ -134,9 +137,9 @@ discard block |
||
| 134 | 137 | |
| 135 | 138 | if ($schedule->status) { |
| 136 | 139 | |
| 137 | - if($schedule->recurrence == "single") |
|
| 138 | - wp_schedule_single_event( strtotime($schedule->start_at), $hook, array($schedule->id)); |
|
| 139 | - else{ |
|
| 140 | + if($schedule->recurrence == "single") { |
|
| 141 | + wp_schedule_single_event( strtotime($schedule->start_at), $hook, array($schedule->id)); |
|
| 142 | + } else{ |
|
| 140 | 143 | wp_schedule_event( strtotime($schedule->start_at), $schedule->recurrence, $hook, array($schedule->id) ); |
| 141 | 144 | } |
| 142 | 145 | |
@@ -268,8 +271,9 @@ discard block |
||
| 268 | 271 | |
| 269 | 272 | //getting the last backup archive file |
| 270 | 273 | $return['extra']['backup_parent'] = $this->archive_system->get_archive_name_with_extension(); |
| 271 | - if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) |
|
| 272 | - $return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart(); |
|
| 274 | + if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) { |
|
| 275 | + $return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart(); |
|
| 276 | + } |
|
| 273 | 277 | |
| 274 | 278 | $this->update_last_backup($schedule['id'], $return['extra']['backup_parent']); |
| 275 | 279 | |
@@ -279,8 +283,9 @@ discard block |
||
| 279 | 283 | |
| 280 | 284 | $this->logger->info(sprintf("Transferring backup to remote storage %s", strtoupper($schedule['remote_storage'])), array("CRON")); |
| 281 | 285 | |
| 282 | - if(method_exists($this->xcloner_remote_storage, "upload_backup_to_storage")) |
|
| 283 | - $return_storage = call_user_func_array(array($this->xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $schedule['remote_storage'])); |
|
| 286 | + if(method_exists($this->xcloner_remote_storage, "upload_backup_to_storage")) { |
|
| 287 | + $return_storage = call_user_func_array(array($this->xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $schedule['remote_storage'])); |
|
| 288 | + } |
|
| 284 | 289 | } |
| 285 | 290 | |
| 286 | 291 | |
@@ -289,7 +294,7 @@ discard block |
||
| 289 | 294 | try{ |
| 290 | 295 | $from = "XCloner Schedule - ".$schedule['name']; |
| 291 | 296 | $this->archive_system->send_notification($to, $from, "", $return['extra']['backup_parent'], $schedule); |
| 292 | - }catch(Exception $e) |
|
| 297 | + } catch(Exception $e) |
|
| 293 | 298 | { |
| 294 | 299 | $this->logger->error($e->getMessage()); |
| 295 | 300 | } |
@@ -308,7 +313,7 @@ discard block |
||
| 308 | 313 | |
| 309 | 314 | $this->__xcloner_scheduler_callback($id, $schedule); |
| 310 | 315 | |
| 311 | - }catch(Exception $e){ |
|
| 316 | + } catch(Exception $e){ |
|
| 312 | 317 | |
| 313 | 318 | if(isset($schedule['backup_params']->email_notification) and $to=$schedule['backup_params']->email_notification) |
| 314 | 319 | { |
@@ -55,19 +55,19 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | public function xcloner_backup_add_admin_menu() |
| 57 | 57 | { |
| 58 | - if ( function_exists('add_menu_page') ) |
|
| 59 | - $hook_suffix = add_menu_page( __('Site Backup','xcloner-backup-and-restore'), __('Site Backup','xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page', 'xcloner_display', 'dashicons-backup'); |
|
| 58 | + if (function_exists('add_menu_page')) |
|
| 59 | + $hook_suffix = add_menu_page(__('Site Backup', 'xcloner-backup-and-restore'), __('Site Backup', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page', 'xcloner_display', 'dashicons-backup'); |
|
| 60 | 60 | |
| 61 | - if ( function_exists('add_submenu_page') ) |
|
| 61 | + if (function_exists('add_submenu_page')) |
|
| 62 | 62 | { |
| 63 | 63 | |
| 64 | - add_submenu_page( 'xcloner_init_page', __('XCloner Dashboard','xcloner-backup-and-restore'), __('Dashboard','xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page', 'xcloner_display'); |
|
| 65 | - add_submenu_page( 'xcloner_init_page', __('XCloner Backup Settings','xcloner-backup-and-restore'), __('Settings','xcloner-backup-and-restore'), 'manage_options', 'xcloner_settings_page', 'xcloner_display'); |
|
| 66 | - add_submenu_page( 'xcloner_init_page', __('Remote Storage Settings','xcloner-backup-and-restore'), __('Remote Storage','xcloner-backup-and-restore'), 'manage_options', 'xcloner_remote_storage_page', 'xcloner_display'); |
|
| 67 | - add_submenu_page( 'xcloner_init_page', __('Manage Backups','xcloner-backup-and-restore'), __('Manage Backups','xcloner-backup-and-restore'), 'manage_options', 'xcloner_manage_backups_page', 'xcloner_display'); |
|
| 68 | - add_submenu_page( 'xcloner_init_page', __('Scheduled Backups','xcloner-backup-and-restore'), __('Scheduled Backups','xcloner-backup-and-restore'), 'manage_options', 'xcloner_scheduled_backups_page', 'xcloner_display'); |
|
| 69 | - add_submenu_page( 'xcloner_init_page', __('Generate Backups','xcloner-backup-and-restore'), __('Generate Backups','xcloner-backup-and-restore'), 'manage_options', 'xcloner_generate_backups_page', 'xcloner_display'); |
|
| 70 | - add_submenu_page( 'xcloner_init_page', __('Restore Backups','xcloner-backup-and-restore'), __('Restore Backups','xcloner-backup-and-restore'), 'manage_options', 'xcloner_restore_page', 'xcloner_display'); |
|
| 64 | + add_submenu_page('xcloner_init_page', __('XCloner Dashboard', 'xcloner-backup-and-restore'), __('Dashboard', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page', 'xcloner_display'); |
|
| 65 | + add_submenu_page('xcloner_init_page', __('XCloner Backup Settings', 'xcloner-backup-and-restore'), __('Settings', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_settings_page', 'xcloner_display'); |
|
| 66 | + add_submenu_page('xcloner_init_page', __('Remote Storage Settings', 'xcloner-backup-and-restore'), __('Remote Storage', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_remote_storage_page', 'xcloner_display'); |
|
| 67 | + add_submenu_page('xcloner_init_page', __('Manage Backups', 'xcloner-backup-and-restore'), __('Manage Backups', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_manage_backups_page', 'xcloner_display'); |
|
| 68 | + add_submenu_page('xcloner_init_page', __('Scheduled Backups', 'xcloner-backup-and-restore'), __('Scheduled Backups', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_scheduled_backups_page', 'xcloner_display'); |
|
| 69 | + add_submenu_page('xcloner_init_page', __('Generate Backups', 'xcloner-backup-and-restore'), __('Generate Backups', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_generate_backups_page', 'xcloner_display'); |
|
| 70 | + add_submenu_page('xcloner_init_page', __('Restore Backups', 'xcloner-backup-and-restore'), __('Restore Backups', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_restore_page', 'xcloner_display'); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | } |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | * @param int $priority Optional. he priority at which the function should be fired. Default is 10. |
| 83 | 83 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. |
| 84 | 84 | */ |
| 85 | - public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
| 86 | - $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); |
|
| 85 | + public function add_action($hook, $component, $callback, $priority = 10, $accepted_args = 1) { |
|
| 86 | + $this->actions = $this->add($this->actions, $hook, $component, $callback, $priority, $accepted_args); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | * @param int $priority Optional. he priority at which the function should be fired. Default is 10. |
| 97 | 97 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 |
| 98 | 98 | */ |
| 99 | - public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
| 100 | - $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); |
|
| 99 | + public function add_filter($hook, $component, $callback, $priority = 10, $accepted_args = 1) { |
|
| 100 | + $this->filters = $this->add($this->filters, $hook, $component, $callback, $priority, $accepted_args); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * @param int $accepted_args The number of arguments that should be passed to the $callback. |
| 115 | 115 | * @return array The collection of actions and filters registered with WordPress. |
| 116 | 116 | */ |
| 117 | - private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { |
|
| 117 | + private function add($hooks, $hook, $component, $callback, $priority, $accepted_args) { |
|
| 118 | 118 | |
| 119 | 119 | $hooks[] = array( |
| 120 | 120 | 'hook' => $hook, |
@@ -135,12 +135,12 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | public function run() { |
| 137 | 137 | |
| 138 | - foreach ( $this->filters as $hook ) { |
|
| 139 | - add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
| 138 | + foreach ($this->filters as $hook) { |
|
| 139 | + add_filter($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - foreach ( $this->actions as $hook ) { |
|
| 143 | - add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
| 142 | + foreach ($this->actions as $hook) { |
|
| 143 | + add_action($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | } |
@@ -55,8 +55,9 @@ |
||
| 55 | 55 | |
| 56 | 56 | public function xcloner_backup_add_admin_menu() |
| 57 | 57 | { |
| 58 | - if ( function_exists('add_menu_page') ) |
|
| 59 | - $hook_suffix = add_menu_page( __('Site Backup','xcloner-backup-and-restore'), __('Site Backup','xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page', 'xcloner_display', 'dashicons-backup'); |
|
| 58 | + if ( function_exists('add_menu_page') ) { |
|
| 59 | + $hook_suffix = add_menu_page( __('Site Backup','xcloner-backup-and-restore'), __('Site Backup','xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page', 'xcloner_display', 'dashicons-backup'); |
|
| 60 | + } |
|
| 60 | 61 | |
| 61 | 62 | if ( function_exists('add_submenu_page') ) |
| 62 | 63 | { |