GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Branch dev (aa2978)
by Liuta
01:55
created
includes/class-xcloner-database.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 					$this->log(sprintf(__("Excluding table %s.%s from backup"), $table, $database));
285 285
 				}
286 286
 			$inc++;
287
-        }
287
+		}
288 288
 
289 289
 		return $tablesList;
290 290
 
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 					$buffer = "";
508 508
 					$this->countRecords++;
509 509
 
510
-	                foreach ($arr as $key => $value) {
510
+					foreach ($arr as $key => $value) {
511 511
 						$value = $this->_real_escape($value);
512 512
 						
513 513
 						if(method_exists($this, 'remove_placeholder_escape')){
@@ -538,8 +538,8 @@  discard block
 block discarded – undo
538 538
 		$line = ("\n#\n# Table structure for table `$tableName`\n#\n\n");
539 539
 		$this->fs->get_tmp_filesystem_append()->write($dumpfile, $line);
540 540
 
541
-        if ($this->dbDropSyntax)
542
-        {
541
+		if ($this->dbDropSyntax)
542
+		{
543 543
 			$line = ("\nDROP table IF EXISTS `$tableName`;\n");
544 544
 			$this->fs->get_tmp_filesystem_append()->write($dumpfile, $line);
545 545
 		}
Please login to merge, or discard this patch.
includes/class-xcloner-remote-storage.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -170,60 +170,60 @@
 block discarded – undo
170 170
 
171 171
 		foreach($this->storage_fields as $main_key=>$array){
172 172
 
173
-		    if(is_array($array)) {
174
-                foreach ($array as $key => $type) {
173
+			if(is_array($array)) {
174
+				foreach ($array as $key => $type) {
175 175
 
176
-                    if( $type == "raw") {
177
-                        add_filter("pre_update_option_" . $this->storage_fields['option_prefix'] . $key,
178
-                            function ($value) {
176
+					if( $type == "raw") {
177
+						add_filter("pre_update_option_" . $this->storage_fields['option_prefix'] . $key,
178
+							function ($value) {
179 179
 
180
-                                return $this->simple_crypt($value, 'e');
180
+								return $this->simple_crypt($value, 'e');
181 181
 
182
-                            }, 10, 1);
182
+							}, 10, 1);
183 183
 
184
-                        add_filter("option_" . $this->storage_fields['option_prefix'] . $key, function ($value) {
184
+						add_filter("option_" . $this->storage_fields['option_prefix'] . $key, function ($value) {
185 185
 
186
-                            return $this->simple_crypt($value, 'd');
186
+							return $this->simple_crypt($value, 'd');
187 187
 
188
-                        }, 10, 1);
189
-                    }
188
+						}, 10, 1);
189
+					}
190 190
 
191
-                }
192
-            }
193
-        }
191
+				}
192
+			}
193
+		}
194 194
 
195 195
 	}
196 196
 
197
-    /**
198
-     * Encrypts and Decrypt a string based on openssl lib
199
-     *
200
-     * @param $string
201
-     * @param string $action
202
-     * @return string
203
-     */
204
-    private function simple_crypt( $string, $action = 'e' ) {
205
-        // you may change these values to your own
206
-        $secret_key = NONCE_KEY;
207
-        $secret_iv = NONCE_SALT;
208
-
209
-        $output = $string;
210
-        $encrypt_method = "AES-256-CBC";
211
-        $key = hash( 'sha256', $secret_key );
212
-        $iv = substr( hash( 'sha256', $secret_iv ), 0, 16 );
213
-
214
-        if( $action == 'e' && function_exists('openssl_encrypt')) {
215
-            $output = base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) );
216
-        }
217
-        else if( $action == 'd' && function_exists('openssl_decrypt') && base64_decode( $string )){
218
-            $decrypt = openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv );
219
-            if($decrypt) {
220
-                //we check if decrypt was succesful
221
-                $output = $decrypt;
222
-            }
223
-        }
224
-
225
-        return $output;
226
-    }
197
+	/**
198
+	 * Encrypts and Decrypt a string based on openssl lib
199
+	 *
200
+	 * @param $string
201
+	 * @param string $action
202
+	 * @return string
203
+	 */
204
+	private function simple_crypt( $string, $action = 'e' ) {
205
+		// you may change these values to your own
206
+		$secret_key = NONCE_KEY;
207
+		$secret_iv = NONCE_SALT;
208
+
209
+		$output = $string;
210
+		$encrypt_method = "AES-256-CBC";
211
+		$key = hash( 'sha256', $secret_key );
212
+		$iv = substr( hash( 'sha256', $secret_iv ), 0, 16 );
213
+
214
+		if( $action == 'e' && function_exists('openssl_encrypt')) {
215
+			$output = base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) );
216
+		}
217
+		else if( $action == 'd' && function_exists('openssl_decrypt') && base64_decode( $string )){
218
+			$decrypt = openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv );
219
+			if($decrypt) {
220
+				//we check if decrypt was succesful
221
+				$output = $decrypt;
222
+			}
223
+		}
224
+
225
+		return $output;
226
+	}
227 227
 
228 228
 	private function get_xcloner_container() {
229 229
 		return $this->xcloner_container;
Please login to merge, or discard this patch.
includes/class-xcloner-i18n.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -41,21 +41,21 @@
 block discarded – undo
41 41
 class Xcloner_i18n
42 42
 {
43 43
 
44
-    /**
45
-     * Load the plugin text domain for translation.
46
-     *
47
-     * @since    1.0.0
48
-     */
49
-    public function load_plugin_textdomain()
50
-    {
44
+	/**
45
+	 * Load the plugin text domain for translation.
46
+	 *
47
+	 * @since    1.0.0
48
+	 */
49
+	public function load_plugin_textdomain()
50
+	{
51 51
 
52
-        load_plugin_textdomain(
53
-            'xcloner-backup-and-restore',
54
-            false,
55
-            dirname(dirname(plugin_basename(__FILE__))) . '/languages/'
56
-        );
52
+		load_plugin_textdomain(
53
+			'xcloner-backup-and-restore',
54
+			false,
55
+			dirname(dirname(plugin_basename(__FILE__))) . '/languages/'
56
+		);
57 57
 
58
-    }
58
+	}
59 59
 
60 60
 
61 61
 }
Please login to merge, or discard this patch.
includes/class-xcloner-loader.php 1 patch
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -41,154 +41,154 @@
 block discarded – undo
41 41
 class Xcloner_Loader
42 42
 {
43 43
 
44
-    /**
45
-     * The array of actions registered with WordPress.
46
-     *
47
-     * @since    1.0.0
48
-     * @access   protected
49
-     * @var      array $actions The actions registered with WordPress to fire when the plugin loads.
50
-     */
51
-    protected $actions;
52
-
53
-    /**
54
-     * The array of filters registered with WordPress.
55
-     *
56
-     * @since    1.0.0
57
-     * @access   protected
58
-     * @var      array $filters The filters registered with WordPress to fire when the plugin loads.
59
-     */
60
-    protected $filters;
61
-
62
-    private $xcloner_plugin;
63
-
64
-    /**
65
-     * Initialize the collections used to maintain the actions and filters.
66
-     *
67
-     * @since    1.0.0
68
-     */
69
-    public function __construct(Xcloner $xcloner_container)
70
-    {
71
-
72
-        $this->actions = array();
73
-        $this->filters = array();
74
-
75
-        $this->xcloner_container = $xcloner_container;
76
-
77
-    }
78
-
79
-    public function xcloner_backup_add_admin_menu()
80
-    {
81
-        if (function_exists('add_menu_page')) {
82
-            add_menu_page(__('Site Backup', 'xcloner-backup-and-restore'),
83
-                __('Site Backup', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page',
84
-                array($this->xcloner_container, 'xcloner_display'), 'dashicons-backup');
85
-        }
86
-
87
-        if (function_exists('add_submenu_page')) {
88
-
89
-            add_submenu_page('xcloner_init_page', __('XCloner Dashboard', 'xcloner-backup-and-restore'),
90
-                __('Dashboard', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page',
91
-                array($this->xcloner_container, 'xcloner_display'));
92
-            add_submenu_page('xcloner_init_page', __('XCloner Backup Settings', 'xcloner-backup-and-restore'),
93
-                __('Settings', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_settings_page',
94
-                array($this->xcloner_container, 'xcloner_display'));
95
-            add_submenu_page('xcloner_init_page', __('Remote Storage Settings', 'xcloner-backup-and-restore'),
96
-                __('Remote Storage', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_remote_storage_page',
97
-                array($this->xcloner_container, 'xcloner_display'));
98
-            add_submenu_page('xcloner_init_page', __('Manage Backups', 'xcloner-backup-and-restore'),
99
-                __('Manage Backups', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_manage_backups_page',
100
-                array($this->xcloner_container, 'xcloner_display'));
101
-            add_submenu_page('xcloner_init_page', __('Scheduled Backups', 'xcloner-backup-and-restore'),
102
-                __('Scheduled Backups', 'xcloner-backup-and-restore'), 'manage_options',
103
-                'xcloner_scheduled_backups_page', array($this->xcloner_container, 'xcloner_display'));
104
-            add_submenu_page('xcloner_init_page', __('Generate Backups', 'xcloner-backup-and-restore'),
105
-                __('Generate Backups', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_generate_backups_page',
106
-                array($this->xcloner_container, 'xcloner_display'));
107
-            add_submenu_page('xcloner_init_page', __('Restore Backups', 'xcloner-backup-and-restore'),
108
-                __('Restore Backups', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_restore_page',
109
-                array($this->xcloner_container, 'xcloner_display'));
110
-        }
111
-
112
-    }
113
-
114
-
115
-    /**
116
-     * Add a new action to the collection to be registered with WordPress.
117
-     *
118
-     * @since    1.0.0
119
-     * @param    string $hook The name of the WordPress action that is being registered.
120
-     * @param    object $component A reference to the instance of the object on which the action is defined.
121
-     * @param    string $callback The name of the function definition on the $component.
122
-     * @param    int $priority Optional. he priority at which the function should be fired. Default is 10.
123
-     * @param    int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
124
-     */
125
-    public function add_action($hook, $component, $callback, $priority = 10, $accepted_args = 1)
126
-    {
127
-        $this->actions = $this->add($this->actions, $hook, $component, $callback, $priority, $accepted_args);
128
-    }
129
-
130
-    /**
131
-     * Add a new filter to the collection to be registered with WordPress.
132
-     *
133
-     * @since    1.0.0
134
-     * @param    string $hook The name of the WordPress filter that is being registered.
135
-     * @param    object $component A reference to the instance of the object on which the filter is defined.
136
-     * @param    string $callback The name of the function definition on the $component.
137
-     * @param    int $priority Optional. he priority at which the function should be fired. Default is 10.
138
-     * @param    int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1
139
-     */
140
-    public function add_filter($hook, $component, $callback, $priority = 10, $accepted_args = 1)
141
-    {
142
-        $this->filters = $this->add($this->filters, $hook, $component, $callback, $priority, $accepted_args);
143
-    }
144
-
145
-    /**
146
-     * A utility function that is used to register the actions and hooks into a single
147
-     * collection.
148
-     *
149
-     * @since    1.0.0
150
-     * @access   private
151
-     * @param    array $hooks The collection of hooks that is being registered (that is, actions or filters).
152
-     * @param    string $hook The name of the WordPress filter that is being registered.
153
-     * @param    object $component A reference to the instance of the object on which the filter is defined.
154
-     * @param    string $callback The name of the function definition on the $component.
155
-     * @param    int $priority The priority at which the function should be fired.
156
-     * @param    int $accepted_args The number of arguments that should be passed to the $callback.
157
-     * @return   array                                  The collection of actions and filters registered with WordPress.
158
-     */
159
-    private function add($hooks, $hook, $component, $callback, $priority, $accepted_args)
160
-    {
161
-
162
-        $hooks[] = array(
163
-            'hook' => $hook,
164
-            'component' => $component,
165
-            'callback' => $callback,
166
-            'priority' => $priority,
167
-            'accepted_args' => $accepted_args
168
-        );
169
-
170
-        return $hooks;
171
-
172
-    }
173
-
174
-    /**
175
-     * Register the filters and actions with WordPress.
176
-     *
177
-     * @since    1.0.0
178
-     */
179
-    public function run()
180
-    {
181
-
182
-        foreach ($this->filters as $hook) {
183
-            add_filter($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'],
184
-                $hook['accepted_args']);
185
-        }
186
-
187
-        foreach ($this->actions as $hook) {
188
-            add_action($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'],
189
-                $hook['accepted_args']);
190
-        }
191
-
192
-    }
44
+	/**
45
+	 * The array of actions registered with WordPress.
46
+	 *
47
+	 * @since    1.0.0
48
+	 * @access   protected
49
+	 * @var      array $actions The actions registered with WordPress to fire when the plugin loads.
50
+	 */
51
+	protected $actions;
52
+
53
+	/**
54
+	 * The array of filters registered with WordPress.
55
+	 *
56
+	 * @since    1.0.0
57
+	 * @access   protected
58
+	 * @var      array $filters The filters registered with WordPress to fire when the plugin loads.
59
+	 */
60
+	protected $filters;
61
+
62
+	private $xcloner_plugin;
63
+
64
+	/**
65
+	 * Initialize the collections used to maintain the actions and filters.
66
+	 *
67
+	 * @since    1.0.0
68
+	 */
69
+	public function __construct(Xcloner $xcloner_container)
70
+	{
71
+
72
+		$this->actions = array();
73
+		$this->filters = array();
74
+
75
+		$this->xcloner_container = $xcloner_container;
76
+
77
+	}
78
+
79
+	public function xcloner_backup_add_admin_menu()
80
+	{
81
+		if (function_exists('add_menu_page')) {
82
+			add_menu_page(__('Site Backup', 'xcloner-backup-and-restore'),
83
+				__('Site Backup', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page',
84
+				array($this->xcloner_container, 'xcloner_display'), 'dashicons-backup');
85
+		}
86
+
87
+		if (function_exists('add_submenu_page')) {
88
+
89
+			add_submenu_page('xcloner_init_page', __('XCloner Dashboard', 'xcloner-backup-and-restore'),
90
+				__('Dashboard', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page',
91
+				array($this->xcloner_container, 'xcloner_display'));
92
+			add_submenu_page('xcloner_init_page', __('XCloner Backup Settings', 'xcloner-backup-and-restore'),
93
+				__('Settings', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_settings_page',
94
+				array($this->xcloner_container, 'xcloner_display'));
95
+			add_submenu_page('xcloner_init_page', __('Remote Storage Settings', 'xcloner-backup-and-restore'),
96
+				__('Remote Storage', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_remote_storage_page',
97
+				array($this->xcloner_container, 'xcloner_display'));
98
+			add_submenu_page('xcloner_init_page', __('Manage Backups', 'xcloner-backup-and-restore'),
99
+				__('Manage Backups', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_manage_backups_page',
100
+				array($this->xcloner_container, 'xcloner_display'));
101
+			add_submenu_page('xcloner_init_page', __('Scheduled Backups', 'xcloner-backup-and-restore'),
102
+				__('Scheduled Backups', 'xcloner-backup-and-restore'), 'manage_options',
103
+				'xcloner_scheduled_backups_page', array($this->xcloner_container, 'xcloner_display'));
104
+			add_submenu_page('xcloner_init_page', __('Generate Backups', 'xcloner-backup-and-restore'),
105
+				__('Generate Backups', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_generate_backups_page',
106
+				array($this->xcloner_container, 'xcloner_display'));
107
+			add_submenu_page('xcloner_init_page', __('Restore Backups', 'xcloner-backup-and-restore'),
108
+				__('Restore Backups', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_restore_page',
109
+				array($this->xcloner_container, 'xcloner_display'));
110
+		}
111
+
112
+	}
113
+
114
+
115
+	/**
116
+	 * Add a new action to the collection to be registered with WordPress.
117
+	 *
118
+	 * @since    1.0.0
119
+	 * @param    string $hook The name of the WordPress action that is being registered.
120
+	 * @param    object $component A reference to the instance of the object on which the action is defined.
121
+	 * @param    string $callback The name of the function definition on the $component.
122
+	 * @param    int $priority Optional. he priority at which the function should be fired. Default is 10.
123
+	 * @param    int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
124
+	 */
125
+	public function add_action($hook, $component, $callback, $priority = 10, $accepted_args = 1)
126
+	{
127
+		$this->actions = $this->add($this->actions, $hook, $component, $callback, $priority, $accepted_args);
128
+	}
129
+
130
+	/**
131
+	 * Add a new filter to the collection to be registered with WordPress.
132
+	 *
133
+	 * @since    1.0.0
134
+	 * @param    string $hook The name of the WordPress filter that is being registered.
135
+	 * @param    object $component A reference to the instance of the object on which the filter is defined.
136
+	 * @param    string $callback The name of the function definition on the $component.
137
+	 * @param    int $priority Optional. he priority at which the function should be fired. Default is 10.
138
+	 * @param    int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1
139
+	 */
140
+	public function add_filter($hook, $component, $callback, $priority = 10, $accepted_args = 1)
141
+	{
142
+		$this->filters = $this->add($this->filters, $hook, $component, $callback, $priority, $accepted_args);
143
+	}
144
+
145
+	/**
146
+	 * A utility function that is used to register the actions and hooks into a single
147
+	 * collection.
148
+	 *
149
+	 * @since    1.0.0
150
+	 * @access   private
151
+	 * @param    array $hooks The collection of hooks that is being registered (that is, actions or filters).
152
+	 * @param    string $hook The name of the WordPress filter that is being registered.
153
+	 * @param    object $component A reference to the instance of the object on which the filter is defined.
154
+	 * @param    string $callback The name of the function definition on the $component.
155
+	 * @param    int $priority The priority at which the function should be fired.
156
+	 * @param    int $accepted_args The number of arguments that should be passed to the $callback.
157
+	 * @return   array                                  The collection of actions and filters registered with WordPress.
158
+	 */
159
+	private function add($hooks, $hook, $component, $callback, $priority, $accepted_args)
160
+	{
161
+
162
+		$hooks[] = array(
163
+			'hook' => $hook,
164
+			'component' => $component,
165
+			'callback' => $callback,
166
+			'priority' => $priority,
167
+			'accepted_args' => $accepted_args
168
+		);
169
+
170
+		return $hooks;
171
+
172
+	}
173
+
174
+	/**
175
+	 * Register the filters and actions with WordPress.
176
+	 *
177
+	 * @since    1.0.0
178
+	 */
179
+	public function run()
180
+	{
181
+
182
+		foreach ($this->filters as $hook) {
183
+			add_filter($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'],
184
+				$hook['accepted_args']);
185
+		}
186
+
187
+		foreach ($this->actions as $hook) {
188
+			add_action($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'],
189
+				$hook['accepted_args']);
190
+		}
191
+
192
+	}
193 193
 
194 194
 }
Please login to merge, or discard this patch.
restore/xcloner_restore.php 1 patch
Indentation   +243 added lines, -243 removed lines patch added patch discarded remove patch
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 	private $backup_storage_dir;
107 107
 	private $parent_api;
108 108
 
109
-    /**
110
-     * Xcloner_Restore constructor.
111
-     * @param string $parent_api
112
-     * @throws Exception
113
-     */
109
+	/**
110
+	 * Xcloner_Restore constructor.
111
+	 * @param string $parent_api
112
+	 * @throws Exception
113
+	 */
114 114
 	public function __construct($parent_api = "")
115 115
 	{
116 116
 		register_shutdown_function(array($this, 'exception_handler'));
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
 
151 151
 	}
152 152
 
153
-    /**
154
-     * Exception handler method
155
-     */
153
+	/**
154
+	 * Exception handler method
155
+	 */
156 156
 	public function exception_handler() {
157 157
 		
158 158
 		$error = error_get_last();
@@ -164,20 +164,20 @@  discard block
 block discarded – undo
164 164
 	
165 165
 	}
166 166
 
167
-    /**
168
-     * @param $type
169
-     * @return mixed|string
170
-     */
167
+	/**
168
+	 * @param $type
169
+	 * @return mixed|string
170
+	 */
171 171
 	private function friendly_error_type($type) {
172
-	    static $levels=null;
173
-	    if ($levels===null) {
174
-	        $levels=[];
175
-	        foreach (get_defined_constants() as $key=>$value) {
176
-	            if (strpos($key,'E_')!==0) {continue;}
172
+		static $levels=null;
173
+		if ($levels===null) {
174
+			$levels=[];
175
+			foreach (get_defined_constants() as $key=>$value) {
176
+				if (strpos($key,'E_')!==0) {continue;}
177 177
 					$levels[$value]= $key; //substr($key,2);
178
-	        }
179
-	    }
180
-	    return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}");
178
+			}
179
+		}
180
+		return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}");
181 181
 	}
182 182
 	
183 183
 	public function get_logger_filename()
@@ -187,12 +187,12 @@  discard block
 block discarded – undo
187 187
 		return $filename;
188 188
 	}
189 189
 
190
-    /**
191
-     * Init method
192
-     *
193
-     * @return mixed|void
194
-     * @throws Exception
195
-     */
190
+	/**
191
+	 * Init method
192
+	 *
193
+	 * @return mixed|void
194
+	 * @throws Exception
195
+	 */
196 196
 	public function init()
197 197
 	{
198 198
 		if(isset($_POST['xcloner_action']) and $_POST['xcloner_action'])
@@ -216,12 +216,12 @@  discard block
 block discarded – undo
216 216
 		return $this->check_system();
217 217
 	}
218 218
 
219
-    /**
220
-     * Write file method
221
-     *
222
-     * @return bool|int
223
-     * @throws Exception
224
-     */
219
+	/**
220
+	 * Write file method
221
+	 *
222
+	 * @return bool|int
223
+	 * @throws Exception
224
+	 */
225 225
 	public function write_file_action()
226 226
 	{
227 227
 		if(isset($_POST['file']))
@@ -266,16 +266,16 @@  discard block
 block discarded – undo
266 266
 		
267 267
 	}
268 268
 
269
-    /**
270
-     * Connect to mysql server method
271
-     *
272
-     * @param $remote_mysql_host
273
-     * @param $remote_mysql_user
274
-     * @param $remote_mysql_pass
275
-     * @param $remote_mysql_db
276
-     * @return mysqli
277
-     * @throws Exception
278
-     */
269
+	/**
270
+	 * Connect to mysql server method
271
+	 *
272
+	 * @param $remote_mysql_host
273
+	 * @param $remote_mysql_user
274
+	 * @param $remote_mysql_pass
275
+	 * @param $remote_mysql_db
276
+	 * @return mysqli
277
+	 * @throws Exception
278
+	 */
279 279
 	public function mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db )
280 280
 	{
281 281
 		$this->logger->info(sprintf('Connecting to mysql database %s with %s@%s', $remote_mysql_db, $remote_mysql_user, $remote_mysql_host));
@@ -297,11 +297,11 @@  discard block
 block discarded – undo
297 297
 		return $mysqli;	
298 298
 	}
299 299
 
300
-    /**
301
-     * Restore mysql backup file
302
-     *
303
-     * @throws Exception
304
-     */
300
+	/**
301
+	 * Restore mysql backup file
302
+	 *
303
+	 * @throws Exception
304
+	 */
305 305
 	public function restore_mysql_backup_action()
306 306
 	{
307 307
 		$mysqldump_file 	= filter_input(INPUT_POST, 'mysqldump_file', FILTER_SANITIZE_STRING);
@@ -432,14 +432,14 @@  discard block
 block discarded – undo
432 432
 		$this->send_response(200, $return);
433 433
 	}
434 434
 
435
-    /**
436
-     * Url replace method inside database backup file
437
-     *
438
-     * @param $search
439
-     * @param $replace
440
-     * @param $query
441
-     * @return mixed|string|string[]|null
442
-     */
435
+	/**
436
+	 * Url replace method inside database backup file
437
+	 *
438
+	 * @param $search
439
+	 * @param $replace
440
+	 * @param $query
441
+	 * @return mixed|string|string[]|null
442
+	 */
443 443
 	private function url_replace($search, $replace, $query)
444 444
 	{
445 445
 		$this->logger->info(sprintf("Doing url replace on query with length %s", strlen($query)), array("QUERY_REPLACE"));
@@ -462,11 +462,11 @@  discard block
 block discarded – undo
462 462
 		return $query;
463 463
 	}
464 464
 
465
-    /**
466
-     * List backup files method
467
-     *
468
-     * @throws \League\Flysystem\FileNotFoundException
469
-     */
465
+	/**
466
+	 * List backup files method
467
+	 *
468
+	 * @throws \League\Flysystem\FileNotFoundException
469
+	 */
470 470
 	public function list_backup_files_action()
471 471
 	{
472 472
 		$backup_parts = array();
@@ -532,11 +532,11 @@  discard block
 block discarded – undo
532 532
 		$this->send_response(200, $return);
533 533
 	}
534 534
 
535
-    /**
536
-     * Finish backup restore method
537
-     *
538
-     * @throws \League\Flysystem\FileNotFoundException
539
-     */
535
+	/**
536
+	 * Finish backup restore method
537
+	 *
538
+	 * @throws \League\Flysystem\FileNotFoundException
539
+	 */
540 540
 	public function restore_finish_action()
541 541
 	{
542 542
 		$remote_path 		= filter_input(INPUT_POST, 'remote_path', FILTER_SANITIZE_STRING);
@@ -577,12 +577,12 @@  discard block
 block discarded – undo
577 577
 		$this->send_response(200, $return);
578 578
 	}
579 579
 
580
-    /**
581
-     * Delete backup temporary folder
582
-     *
583
-     * @param $remote_path
584
-     * @return bool
585
-     */
580
+	/**
581
+	 * Delete backup temporary folder
582
+	 *
583
+	 * @param $remote_path
584
+	 * @return bool
585
+	 */
586 586
 	private function delete_backup_temporary_folder($remote_path)
587 587
 	{
588 588
 		$this->target_adapter = new Local($remote_path ,LOCK_EX, 'SKIP_LINKS');
@@ -610,11 +610,11 @@  discard block
 block discarded – undo
610 610
 	
611 611
 	}
612 612
 
613
-    /**
614
-     * Delete restore script method
615
-     *
616
-     * @throws \League\Flysystem\FileNotFoundException
617
-     */
613
+	/**
614
+	 * Delete restore script method
615
+	 *
616
+	 * @throws \League\Flysystem\FileNotFoundException
617
+	 */
618 618
 	private function delete_self()
619 619
 	{
620 620
 		if($this->filesystem->has("vendor.phar"))
@@ -647,14 +647,14 @@  discard block
 block discarded – undo
647 647
 		
648 648
 	}
649 649
 
650
-    /**
651
-     * Update Wordpress url in wp-config.php method
652
-     * @param $wp_path
653
-     * @param $url
654
-     * @param $mysqli
655
-     * @return bool
656
-     * @throws Exception
657
-     */
650
+	/**
651
+	 * Update Wordpress url in wp-config.php method
652
+	 * @param $wp_path
653
+	 * @param $url
654
+	 * @param $mysqli
655
+	 * @return bool
656
+	 * @throws Exception
657
+	 */
658 658
 	private function update_wp_url($wp_path, $url, $mysqli)
659 659
 	{
660 660
 		$wp_config = $wp_path.DS."wp-config.php";
@@ -682,17 +682,17 @@  discard block
 block discarded – undo
682 682
 		return true;
683 683
 	}
684 684
 
685
-    /**
686
-     * Update local wp-config.php file method
687
-     *
688
-     * @param $remote_path
689
-     * @param $remote_mysql_host
690
-     * @param $remote_mysql_user
691
-     * @param $remote_mysql_pass
692
-     * @param $remote_mysql_db
693
-     * @return string
694
-     * @throws Exception
695
-     */
685
+	/**
686
+	 * Update local wp-config.php file method
687
+	 *
688
+	 * @param $remote_path
689
+	 * @param $remote_mysql_host
690
+	 * @param $remote_mysql_user
691
+	 * @param $remote_mysql_pass
692
+	 * @param $remote_mysql_db
693
+	 * @return string
694
+	 * @throws Exception
695
+	 */
696 696
 	private function update_wp_config($remote_path, $remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db)
697 697
 	{
698 698
 		$wp_config = $remote_path.DS."wp-config.php";
@@ -724,10 +724,10 @@  discard block
 block discarded – undo
724 724
 		
725 725
 	}
726 726
 
727
-    /**
728
-     * List mysqldump database backup files
729
-     *
730
-     */
727
+	/**
728
+	 * List mysqldump database backup files
729
+	 *
730
+	 */
731 731
 	public function list_mysqldump_backups_action()
732 732
 	{
733 733
 		$source_backup_file = filter_input(INPUT_POST, 'backup_file', FILTER_SANITIZE_STRING);
@@ -777,12 +777,12 @@  discard block
 block discarded – undo
777 777
 		$this->send_response(200, $return);
778 778
 	}
779 779
 
780
-    /**
781
-     * Get backup hash method
782
-     *
783
-     * @param $backup_file
784
-     * @return bool
785
-     */
780
+	/**
781
+	 * Get backup hash method
782
+	 *
783
+	 * @param $backup_file
784
+	 * @return bool
785
+	 */
786 786
 	private function get_hash_from_backup($backup_file)
787 787
 	{
788 788
 		if(!$backup_file)
@@ -796,11 +796,11 @@  discard block
 block discarded – undo
796 796
 		return false;
797 797
 	}
798 798
 
799
-    /**
800
-     * List backup archives found on local system
801
-     *
802
-     * @throws \League\Flysystem\FileNotFoundException
803
-     */
799
+	/**
800
+	 * List backup archives found on local system
801
+	 *
802
+	 * @throws \League\Flysystem\FileNotFoundException
803
+	 */
804 804
 	public function list_backup_archives_action()
805 805
 	{
806 806
 		$local_backup_file = filter_input(INPUT_POST, 'local_backup_file', FILTER_SANITIZE_STRING);
@@ -859,12 +859,12 @@  discard block
 block discarded – undo
859 859
 		
860 860
 	}
861 861
 
862
-    /**
863
-     * Restore backup archive to local path
864
-     *
865
-     * @throws \League\Flysystem\FileNotFoundException
866
-     * @throws \splitbrain\PHPArchive\ArchiveIOException
867
-     */
862
+	/**
863
+	 * Restore backup archive to local path
864
+	 *
865
+	 * @throws \League\Flysystem\FileNotFoundException
866
+	 * @throws \splitbrain\PHPArchive\ArchiveIOException
867
+	 */
868 868
 	public function restore_backup_to_path_action()
869 869
 	{
870 870
 		$source_backup_file 	= filter_input(INPUT_POST, 'backup_file', FILTER_SANITIZE_STRING);
@@ -939,9 +939,9 @@  discard block
 block discarded – undo
939 939
 		$this->send_response(200, $return);
940 940
 	}
941 941
 
942
-    /**
943
-     * Get current directory method
944
-     */
942
+	/**
943
+	 * Get current directory method
944
+	 */
945 945
 	public function get_current_directory_action()
946 946
 	{	
947 947
 		global $wpdb;
@@ -975,11 +975,11 @@  discard block
 block discarded – undo
975 975
 		$this->send_response(200, $return);
976 976
 	}
977 977
 
978
-    /**
979
-     * Check current filesystem
980
-     *
981
-     * @throws Exception
982
-     */
978
+	/**
979
+	 * Check current filesystem
980
+	 *
981
+	 * @throws Exception
982
+	 */
983 983
 	public function check_system()
984 984
 	{
985 985
 		//check if i can write
@@ -1001,35 +1001,35 @@  discard block
 block discarded – undo
1001 1001
 		$this->send_response(200, $return);
1002 1002
 	}
1003 1003
 
1004
-    /**
1005
-     * Return bytes from human readable value
1006
-     *
1007
-     * @param $val
1008
-     * @return int
1009
-     *
1010
-     */
1011
-    private function return_bytes($val) {
1012
-        $numeric_val = (int)trim($val);
1013
-        $last = strtolower($val[strlen($val)-1]);
1014
-        switch($last) {
1015
-            // The 'G' modifier is available since PHP 5.1.0
1016
-            case 'g':
1017
-                $numeric_val *= 1024;
1018
-            case 'm':
1019
-                $numeric_val *= 1024;
1020
-            case 'k':
1021
-                $numeric_val *= 1024;
1022
-        }
1004
+	/**
1005
+	 * Return bytes from human readable value
1006
+	 *
1007
+	 * @param $val
1008
+	 * @return int
1009
+	 *
1010
+	 */
1011
+	private function return_bytes($val) {
1012
+		$numeric_val = (int)trim($val);
1013
+		$last = strtolower($val[strlen($val)-1]);
1014
+		switch($last) {
1015
+			// The 'G' modifier is available since PHP 5.1.0
1016
+			case 'g':
1017
+				$numeric_val *= 1024;
1018
+			case 'm':
1019
+				$numeric_val *= 1024;
1020
+			case 'k':
1021
+				$numeric_val *= 1024;
1022
+		}
1023 1023
 
1024
-        return $numeric_val;
1025
-    }
1024
+		return $numeric_val;
1025
+	}
1026 1026
 
1027
-    /**
1028
-     * Check if backup archive os multipart
1029
-     *
1030
-     * @param $backup_name
1031
-     * @return bool
1032
-     */
1027
+	/**
1028
+	 * Check if backup archive os multipart
1029
+	 *
1030
+	 * @param $backup_name
1031
+	 * @return bool
1032
+	 */
1033 1033
 	public function is_multipart($backup_name)
1034 1034
 	{
1035 1035
 		if(stristr($backup_name, "-multipart"))
@@ -1038,13 +1038,13 @@  discard block
 block discarded – undo
1038 1038
 		return false;	
1039 1039
 	}
1040 1040
 
1041
-    /**
1042
-     * Get backup archive size
1043
-     *
1044
-     * @param $backup_name
1045
-     * @return bool|false|int
1046
-     * @throws \League\Flysystem\FileNotFoundException
1047
-     */
1041
+	/**
1042
+	 * Get backup archive size
1043
+	 *
1044
+	 * @param $backup_name
1045
+	 * @return bool|false|int
1046
+	 * @throws \League\Flysystem\FileNotFoundException
1047
+	 */
1048 1048
 	public function get_backup_size($backup_name)
1049 1049
 	{
1050 1050
 		$backup_size = $this->filesystem->getSize($backup_name);
@@ -1058,12 +1058,12 @@  discard block
 block discarded – undo
1058 1058
 		return $backup_size;
1059 1059
 	}
1060 1060
 
1061
-    /**
1062
-     * Get multipart backup files list
1063
-     * @param $backup_name
1064
-     * @return array
1065
-     * @throws \League\Flysystem\FileNotFoundException
1066
-     */
1061
+	/**
1062
+	 * Get multipart backup files list
1063
+	 * @param $backup_name
1064
+	 * @return array
1065
+	 * @throws \League\Flysystem\FileNotFoundException
1066
+	 */
1067 1067
 	public function get_multipart_files($backup_name)
1068 1068
 	{
1069 1069
 		$files = array();
@@ -1084,58 +1084,58 @@  discard block
 block discarded – undo
1084 1084
 		return $files;
1085 1085
 	}
1086 1086
 
1087
-    /**
1088
-     * Sort_by method
1089
-     *
1090
-     * @param $array
1091
-     * @param $field
1092
-     * @param string $direction
1093
-     * @return bool
1094
-     */
1095
-    private function sort_by( &$array, $field, $direction = 'asc')
1096
-    {
1097
-        $direction = strtolower($direction);
1087
+	/**
1088
+	 * Sort_by method
1089
+	 *
1090
+	 * @param $array
1091
+	 * @param $field
1092
+	 * @param string $direction
1093
+	 * @return bool
1094
+	 */
1095
+	private function sort_by( &$array, $field, $direction = 'asc')
1096
+	{
1097
+		$direction = strtolower($direction);
1098 1098
 
1099
-        usort($array,
1100
-            function($a, $b) use($field, $direction){
1099
+		usort($array,
1100
+			function($a, $b) use($field, $direction){
1101 1101
 
1102
-                $a = $a[$field];
1103
-                $b = $b[$field];
1102
+				$a = $a[$field];
1103
+				$b = $b[$field];
1104 1104
 
1105
-                if ($a == $b)
1106
-                {
1107
-                    return 0;
1108
-                }
1105
+				if ($a == $b)
1106
+				{
1107
+					return 0;
1108
+				}
1109 1109
 
1110
-                if($direction == 'desc') {
1111
-                    if($a > $b) {
1112
-                        return -1;
1113
-                    }
1114
-                    else{
1115
-                        return 1;
1116
-                    }
1117
-                }else {
1118
-                    if($a < $b) {
1119
-                        return -1;
1120
-                    }
1121
-                    else{
1122
-                        return 1;
1123
-                    }
1124
-                }
1110
+				if($direction == 'desc') {
1111
+					if($a > $b) {
1112
+						return -1;
1113
+					}
1114
+					else{
1115
+						return 1;
1116
+					}
1117
+				}else {
1118
+					if($a < $b) {
1119
+						return -1;
1120
+					}
1121
+					else{
1122
+						return 1;
1123
+					}
1124
+				}
1125 1125
 
1126
-                //return ($a.($direction == 'desc' ? '>' : '<').$b) ? -1 : 1;
1127
-            }
1128
-        );
1126
+				//return ($a.($direction == 'desc' ? '>' : '<').$b) ? -1 : 1;
1127
+			}
1128
+		);
1129 1129
 
1130
-        return true;
1131
-    }
1130
+		return true;
1131
+	}
1132 1132
 
1133
-    /**
1134
-     * Send response method
1135
-     *
1136
-     * @param int $status
1137
-     * @param $response
1138
-     */
1133
+	/**
1134
+	 * Send response method
1135
+	 *
1136
+	 * @param int $status
1137
+	 * @param $response
1138
+	 */
1139 1139
 	public static function send_response($status = 200, $response)
1140 1140
 	{
1141 1141
 		header("Access-Control-Allow-Origin: *");
@@ -1158,12 +1158,12 @@  discard block
 block discarded – undo
1158 1158
 		exit;
1159 1159
 	}
1160 1160
 
1161
-    /**
1162
-     * Serialize fix methods below for mysql query lines
1163
-     *
1164
-     * @param $query
1165
-     * @return string|string[]|null
1166
-     */
1161
+	/**
1162
+	 * Serialize fix methods below for mysql query lines
1163
+	 *
1164
+	 * @param $query
1165
+	 * @return string|string[]|null
1166
+	 */
1167 1167
 	 
1168 1168
 	function do_serialized_fix($query)
1169 1169
 	{
@@ -1176,51 +1176,51 @@  discard block
 block discarded – undo
1176 1176
 					$m[3] = "";
1177 1177
 					
1178 1178
 					$data = 's:'.strlen(($m[3])).':\"'.($m[3]).'\";';
1179
-	              //return $this->unescape_quotes($data);
1179
+				  //return $this->unescape_quotes($data);
1180 1180
 	              
1181
-	              return $data;
1182
-	            }, $query);
1181
+				  return $data;
1182
+				}, $query);
1183 1183
 	}
1184 1184
 
1185
-    /**
1186
-     * Unescape quotes method
1187
-     *
1188
-     * @param $value
1189
-     * @return mixed
1190
-     */
1185
+	/**
1186
+	 * Unescape quotes method
1187
+	 *
1188
+	 * @param $value
1189
+	 * @return mixed
1190
+	 */
1191 1191
 	private function unescape_quotes($value) {
1192 1192
 		return str_replace('\"', '"', $value);
1193 1193
 	}
1194 1194
 
1195
-    /**
1196
-     * Unescape mysql method
1197
-     *
1198
-     * @param $value
1199
-     * @return mixed
1200
-     */
1195
+	/**
1196
+	 * Unescape mysql method
1197
+	 *
1198
+	 * @param $value
1199
+	 * @return mixed
1200
+	 */
1201 1201
 	private function unescape_mysql($value) {
1202 1202
 		return str_replace(array("\\\\", "\\0", "\\n", "\\r", "\Z",  "\'", '\"'),
1203 1203
 						   array("\\",   "\0",  "\n",  "\r",  "\x1a", "'", '"'), 
1204 1204
 						   $value);
1205 1205
 	}
1206 1206
 
1207
-    /**
1208
-     * Check if string is in serialized format
1209
-     *
1210
-     * @param $s
1211
-     * @return bool
1212
-     */
1207
+	/**
1208
+	 * Check if string is in serialized format
1209
+	 *
1210
+	 * @param $s
1211
+	 * @return bool
1212
+	 */
1213 1213
 	private function has_serialized($s)
1214 1214
 	{
1215 1215
 		if(
1216
-		    stristr($s, '{' ) != false &&
1217
-		    stristr($s, '}' ) != false &&
1218
-		    stristr($s, ';' ) != false &&
1219
-		    stristr($s, ':' ) != false
1220
-		    ){
1221
-		    return true;
1216
+			stristr($s, '{' ) != false &&
1217
+			stristr($s, '}' ) != false &&
1218
+			stristr($s, ';' ) != false &&
1219
+			stristr($s, ':' ) != false
1220
+			){
1221
+			return true;
1222 1222
 		}else{
1223
-		    return false;
1223
+			return false;
1224 1224
 		}
1225 1225
 
1226 1226
 	}
Please login to merge, or discard this patch.
admin/partials/xcloner_manage_backups_page.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 $storage_selection = "";
8 8
 
9 9
 if (isset($_GET['storage_selection']) and $_GET['storage_selection']) {
10
-    $storage_selection = $xcloner_sanitization->sanitize_input_as_string($_GET['storage_selection']);
10
+	$storage_selection = $xcloner_sanitization->sanitize_input_as_string($_GET['storage_selection']);
11 11
 }
12 12
 
13 13
 //$backup_list = $xcloner_file_system->get_backup_archives_list($storage_selection);
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
             <?php foreach ($available_storages as $storage => $text): ?>
40 40
                 <option value="<?php echo $storage ?>"<?php if ($storage == $storage_selection)
41
-                    echo "selected" ?>><?php echo $text ?></option>
41
+					echo "selected" ?>><?php echo $text ?></option>
42 42
             <?php endforeach ?>
43 43
         </select>
44 44
         <?php endif ?>
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
 
67 67
         <?php
68
-        /*$i = 0;
68
+		/*$i = 0;
69 69
         foreach ($backup_list as $file_info):?>
70 70
             <?php
71 71
             if ($storage_selection == "gdrive") {
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
                 <div class="row">
303 303
                     <div class="col s12 label">
304 304
                         <label><?php echo sprintf(__('Send %s to remote storage', 'xcloner-backup-and-restore'),
305
-                                "<span class='backup_name'></span>") ?></label>
305
+								"<span class='backup_name'></span>") ?></label>
306 306
                     </div>
307 307
                     <div class="input-field col s8 m10">
308 308
                         <select name="transfer_storage" id="transfer_storage" class="validate" required>
Please login to merge, or discard this patch.
includes/class-xcloner-settings.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -56,30 +56,30 @@  discard block
 block discarded – undo
56 56
 
57 57
 	public function get_xcloner_encryption_key() {
58 58
 
59
-	    if(!get_option('xcloner_encryption_key') )
60
-        {
61
-	        return $this->randomString(35);
62
-        }
63
-
64
-	    return get_option('xcloner_encryption_key');
65
-    }
66
-
67
-    /**
68
-     * Create a random string
69
-     * @author	XEWeb <>
70
-     * @param $length the length of the string to create
71
-     * @return $str the string
72
-     */
73
-    private function randomString($length = 6) {
74
-        $str = "";
75
-        $characters = array_merge(range('A','Z'), range('a','z'), range('0','9'));
76
-        $max = count($characters) - 1;
77
-        for ($i = 0; $i < $length; $i++) {
78
-            $rand = mt_rand(0, $max);
79
-            $str .= $characters[$rand];
80
-        }
81
-        return $str;
82
-    }
59
+		if(!get_option('xcloner_encryption_key') )
60
+		{
61
+			return $this->randomString(35);
62
+		}
63
+
64
+		return get_option('xcloner_encryption_key');
65
+	}
66
+
67
+	/**
68
+	 * Create a random string
69
+	 * @author	XEWeb <>
70
+	 * @param $length the length of the string to create
71
+	 * @return $str the string
72
+	 */
73
+	private function randomString($length = 6) {
74
+		$str = "";
75
+		$characters = array_merge(range('A','Z'), range('a','z'), range('0','9'));
76
+		$max = count($characters) - 1;
77
+		for ($i = 0; $i < $length; $i++) {
78
+			$rand = mt_rand(0, $max);
79
+			$str .= $characters[$rand];
80
+		}
81
+		return $str;
82
+	}
83 83
 
84 84
 	public function get_xcloner_tmp_path_suffix() {
85 85
 		return "xcloner" . $this->get_hash();
@@ -328,40 +328,40 @@  discard block
 block discarded – undo
328 328
 		);
329 329
 
330 330
 		register_setting( 'xcloner_general_settings_group', 'xcloner_store_path', array(
331
-            $this->xcloner_sanitization,
332
-            "sanitize_input_as_absolute_path"
333
-        ) );
334
-        add_settings_field(
335
-            'xcloner_store_path',
336
-            __( 'Backup Storage Location', 'xcloner-backup-and-restore' ),
337
-            array( $this, 'do_form_text_field' ),
338
-            'xcloner_settings_page',
339
-            'xcloner_general_settings_group',
340
-            array(
341
-                'xcloner_store_path',
342
-                __( 'Location where XCloner will store the Backup archives.', 'xcloner-backup-and-restore' ),
343
-                $this->get_xcloner_store_path(),
344
-                //'disabled'
345
-            )
346
-        );
347
-
348
-        register_setting( 'xcloner_general_settings_group', 'xcloner_encryption_key', array(
349
-            $this->xcloner_sanitization,
350
-            "sanitize_input_as_string"
351
-        ) );
352
-        add_settings_field(
353
-            'xcloner_encryption_key',
354
-            __( 'Backup Encryption Key', 'xcloner-backup-and-restore' ),
355
-            array( $this, 'do_form_text_field' ),
356
-            'xcloner_settings_page',
357
-            'xcloner_general_settings_group',
358
-            array(
359
-                'xcloner_encryption_key',
360
-                __( 'Backup Encryption Key used to Encrypt/Decrypt backups, you might want to save this somewhere else as well.', 'xcloner-backup-and-restore' ),
361
-                $this->get_xcloner_encryption_key(),
362
-                //'disabled'
363
-            )
364
-        );
331
+			$this->xcloner_sanitization,
332
+			"sanitize_input_as_absolute_path"
333
+		) );
334
+		add_settings_field(
335
+			'xcloner_store_path',
336
+			__( 'Backup Storage Location', 'xcloner-backup-and-restore' ),
337
+			array( $this, 'do_form_text_field' ),
338
+			'xcloner_settings_page',
339
+			'xcloner_general_settings_group',
340
+			array(
341
+				'xcloner_store_path',
342
+				__( 'Location where XCloner will store the Backup archives.', 'xcloner-backup-and-restore' ),
343
+				$this->get_xcloner_store_path(),
344
+				//'disabled'
345
+			)
346
+		);
347
+
348
+		register_setting( 'xcloner_general_settings_group', 'xcloner_encryption_key', array(
349
+			$this->xcloner_sanitization,
350
+			"sanitize_input_as_string"
351
+		) );
352
+		add_settings_field(
353
+			'xcloner_encryption_key',
354
+			__( 'Backup Encryption Key', 'xcloner-backup-and-restore' ),
355
+			array( $this, 'do_form_text_field' ),
356
+			'xcloner_settings_page',
357
+			'xcloner_general_settings_group',
358
+			array(
359
+				'xcloner_encryption_key',
360
+				__( 'Backup Encryption Key used to Encrypt/Decrypt backups, you might want to save this somewhere else as well.', 'xcloner-backup-and-restore' ),
361
+				$this->get_xcloner_encryption_key(),
362
+				//'disabled'
363
+			)
364
+		);
365 365
 
366 366
 		register_setting( 'xcloner_general_settings_group', 'xcloner_enable_log', array(
367 367
 			$this->xcloner_sanitization,
@@ -627,18 +627,18 @@  discard block
 block discarded – undo
627 627
 			)
628 628
 		);
629 629
 
630
-        register_setting( 'xcloner_system_settings_group', 'xcloner_disable_email_notification' );
631
-        add_settings_field(
632
-            'xcloner_disable_email_notification',
633
-            __( 'Disable Email Notifications', 'xcloner-backup-and-restore' ),
634
-            array( $this, 'do_form_switch_field' ),
635
-            'xcloner_system_settings_page',
636
-            'xcloner_system_settings_group',
637
-            array(
638
-                'xcloner_disable_email_notification',
639
-                sprintf( __( 'Enable this option if you want the XCloner to NOT send email notifications on successful backups', 'xcloner-backup-and-restore' ), $this->get_table_prefix() )
640
-            )
641
-        );
630
+		register_setting( 'xcloner_system_settings_group', 'xcloner_disable_email_notification' );
631
+		add_settings_field(
632
+			'xcloner_disable_email_notification',
633
+			__( 'Disable Email Notifications', 'xcloner-backup-and-restore' ),
634
+			array( $this, 'do_form_switch_field' ),
635
+			'xcloner_system_settings_page',
636
+			'xcloner_system_settings_group',
637
+			array(
638
+				'xcloner_disable_email_notification',
639
+				sprintf( __( 'Enable this option if you want the XCloner to NOT send email notifications on successful backups', 'xcloner-backup-and-restore' ), $this->get_table_prefix() )
640
+			)
641
+		);
642 642
 
643 643
 		//REGISTERING THE 'CLEANUP SECTION' FIELDS
644 644
 		register_setting( 'xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_days', array(
Please login to merge, or discard this patch.
includes/class-xcloner-activator.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 
64 64
 		if ( version_compare( phpversion(), Xcloner_Activator::xcloner_minimum_version, '<' ) ) {
65 65
 			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,
66
-			                                                                                                                                                                                                                                                       'back_link' => true
66
+																																																																   'back_link' => true
67 67
 			) );
68 68
 		}
69 69
 
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 			update_option( 'xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$" . PHP_EOL . "(.*)\.(svn|git)(.*)$" . PHP_EOL . "wp-content\/cache(.*)$" . PHP_EOL . "(.*)error_log$" );
153 153
 		}
154 154
 
155
-        if ( ! get_option( 'xcloner_regex_exclude' ) ) {
156
-            update_option( 'xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$" . PHP_EOL . "(.*)\.(svn|git)(.*)$" . PHP_EOL . "wp-content\/cache(.*)$" . PHP_EOL . "(.*)error_log$" );
157
-        }
155
+		if ( ! get_option( 'xcloner_regex_exclude' ) ) {
156
+			update_option( 'xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$" . PHP_EOL . "(.*)\.(svn|git)(.*)$" . PHP_EOL . "wp-content\/cache(.*)$" . PHP_EOL . "(.*)error_log$" );
157
+		}
158 158
 
159 159
 	}
160 160
 
Please login to merge, or discard this patch.
includes/class-xcloner-api.php 1 patch
Indentation   +1100 added lines, -1100 removed lines patch added patch discarded remove patch
@@ -43,903 +43,903 @@  discard block
 block discarded – undo
43 43
 class Xcloner_Api
44 44
 {
45 45
 
46
-    private $xcloner_database;
47
-    private $xcloner_settings;
48
-    private $xcloner_file_system;
49
-    private $xcloner_requirements;
50
-    private $xcloner_sanitization;
51
-    private $xcloner_encryption;
52
-    private $xcloner_remote_storage;
53
-    private $archive_system;
54
-    private $form_params;
55
-    private $logger;
56
-    private $xcloner_container;
57
-
58
-    /**
59
-     * XCloner_Api construct class
60
-     *
61
-     * @param Xcloner $xcloner_container [description]
62
-     */
63
-    public function __construct(Xcloner $xcloner_container)
64
-    {
65
-        global $wpdb;
66
-
67
-        if (WP_DEBUG) {
68
-            error_reporting(0);
69
-        }
70
-
71
-        if (ob_get_length()) {
72
-            ob_end_clean();
73
-        }
74
-        ob_start();
75
-
76
-        $wpdb->show_errors = false;
77
-
78
-        $this->xcloner_container = $xcloner_container;
79
-
80
-        $this->xcloner_settings         = $xcloner_container->get_xcloner_settings();
81
-        $this->logger                   = $xcloner_container->get_xcloner_logger()->withName("xcloner_api");
82
-        $this->xcloner_file_system      = $xcloner_container->get_xcloner_filesystem();
83
-        $this->xcloner_sanitization     = $xcloner_container->get_xcloner_sanitization();
84
-        $this->xcloner_requirements     = $xcloner_container->get_xcloner_requirements();
85
-        $this->archive_system           = $xcloner_container->get_archive_system();
86
-        $this->xcloner_database         = $xcloner_container->get_xcloner_database();
87
-        $this->xcloner_scheduler        = $xcloner_container->get_xcloner_scheduler();
88
-        $this->xcloner_encryption       = $xcloner_container->get_xcloner_encryption();
89
-        $this->xcloner_remote_storage   = $xcloner_container->get_xcloner_remote_storage();
90
-
91
-        if (isset($_POST['API_ID'])) {
92
-            $this->logger->info("Processing ajax request ID " . substr($this->xcloner_sanitization->sanitize_input_as_string($_POST['API_ID']),
93
-                    0, 15));
94
-        }
95
-
96
-    }
97
-
98
-    /**
99
-     * Get XCloner Container
100
-     * @return XCloner return the XCloner container
101
-     */
102
-    public function get_xcloner_container()
103
-    {
104
-        return $this->xcloner_container;
105
-    }
106
-
107
-    /**
108
-     * Check if user has access to this class
109
-     * @return die() returns die() if user is not allowed
110
-     * @link http://www.wordpress.org
111
-     */
112
-    private function check_access()
113
-    {
114
-        if (function_exists('current_user_can') && !current_user_can('manage_options')) {
115
-            die("Not allowed access here!");
116
-        }
117
-    }
118
-
119
-    /**
120
-     * Initialize the database connection
121
-     */
122
-    public function init_db()
123
-    {
124
-        return;
125
-
126
-
127
-        $data['dbHostname'] = $this->xcloner_settings->get_db_hostname();
128
-        $data['dbUsername'] = $this->xcloner_settings->get_db_username();
129
-        $data['dbPassword'] = $this->xcloner_settings->get_db_password();
130
-        $data['dbDatabase'] = $this->xcloner_settings->get_db_database();
131
-
132
-
133
-        $data['recordsPerSession'] = $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request');
134
-        $data['TEMP_DBPROCESS_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path() . DS . ".database";
135
-        $data['TEMP_DUMP_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path() . DS . "database-sql.sql";
136
-
137
-        try {
138
-            $this->xcloner_database->init($data);
139
-
140
-        } catch (Exception $e) {
141
-
142
-            $this->send_response($e->getMessage());
143
-            $this->logger->error($e->getMessage());
144
-
145
-        }
146
-
147
-        return $this->xcloner_database;
148
-
149
-
150
-    }
151
-
152
-    /*
46
+	private $xcloner_database;
47
+	private $xcloner_settings;
48
+	private $xcloner_file_system;
49
+	private $xcloner_requirements;
50
+	private $xcloner_sanitization;
51
+	private $xcloner_encryption;
52
+	private $xcloner_remote_storage;
53
+	private $archive_system;
54
+	private $form_params;
55
+	private $logger;
56
+	private $xcloner_container;
57
+
58
+	/**
59
+	 * XCloner_Api construct class
60
+	 *
61
+	 * @param Xcloner $xcloner_container [description]
62
+	 */
63
+	public function __construct(Xcloner $xcloner_container)
64
+	{
65
+		global $wpdb;
66
+
67
+		if (WP_DEBUG) {
68
+			error_reporting(0);
69
+		}
70
+
71
+		if (ob_get_length()) {
72
+			ob_end_clean();
73
+		}
74
+		ob_start();
75
+
76
+		$wpdb->show_errors = false;
77
+
78
+		$this->xcloner_container = $xcloner_container;
79
+
80
+		$this->xcloner_settings         = $xcloner_container->get_xcloner_settings();
81
+		$this->logger                   = $xcloner_container->get_xcloner_logger()->withName("xcloner_api");
82
+		$this->xcloner_file_system      = $xcloner_container->get_xcloner_filesystem();
83
+		$this->xcloner_sanitization     = $xcloner_container->get_xcloner_sanitization();
84
+		$this->xcloner_requirements     = $xcloner_container->get_xcloner_requirements();
85
+		$this->archive_system           = $xcloner_container->get_archive_system();
86
+		$this->xcloner_database         = $xcloner_container->get_xcloner_database();
87
+		$this->xcloner_scheduler        = $xcloner_container->get_xcloner_scheduler();
88
+		$this->xcloner_encryption       = $xcloner_container->get_xcloner_encryption();
89
+		$this->xcloner_remote_storage   = $xcloner_container->get_xcloner_remote_storage();
90
+
91
+		if (isset($_POST['API_ID'])) {
92
+			$this->logger->info("Processing ajax request ID " . substr($this->xcloner_sanitization->sanitize_input_as_string($_POST['API_ID']),
93
+					0, 15));
94
+		}
95
+
96
+	}
97
+
98
+	/**
99
+	 * Get XCloner Container
100
+	 * @return XCloner return the XCloner container
101
+	 */
102
+	public function get_xcloner_container()
103
+	{
104
+		return $this->xcloner_container;
105
+	}
106
+
107
+	/**
108
+	 * Check if user has access to this class
109
+	 * @return die() returns die() if user is not allowed
110
+	 * @link http://www.wordpress.org
111
+	 */
112
+	private function check_access()
113
+	{
114
+		if (function_exists('current_user_can') && !current_user_can('manage_options')) {
115
+			die("Not allowed access here!");
116
+		}
117
+	}
118
+
119
+	/**
120
+	 * Initialize the database connection
121
+	 */
122
+	public function init_db()
123
+	{
124
+		return;
125
+
126
+
127
+		$data['dbHostname'] = $this->xcloner_settings->get_db_hostname();
128
+		$data['dbUsername'] = $this->xcloner_settings->get_db_username();
129
+		$data['dbPassword'] = $this->xcloner_settings->get_db_password();
130
+		$data['dbDatabase'] = $this->xcloner_settings->get_db_database();
131
+
132
+
133
+		$data['recordsPerSession'] = $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request');
134
+		$data['TEMP_DBPROCESS_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path() . DS . ".database";
135
+		$data['TEMP_DUMP_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path() . DS . "database-sql.sql";
136
+
137
+		try {
138
+			$this->xcloner_database->init($data);
139
+
140
+		} catch (Exception $e) {
141
+
142
+			$this->send_response($e->getMessage());
143
+			$this->logger->error($e->getMessage());
144
+
145
+		}
146
+
147
+		return $this->xcloner_database;
148
+
149
+
150
+	}
151
+
152
+	/*
153 153
      * Save Schedule API
154 154
      */
155
-    public function save_schedule()
156
-    {
157
-        global $wpdb;
158
-
159
-        $this->check_access();
160
-
161
-        $scheduler = $this->xcloner_scheduler;
162
-        $params = array();
163
-        $schedule = array();
164
-        $response = array();
165
-
166
-        if (isset($_POST['data'])) {
167
-            $params = json_decode(stripslashes($_POST['data']));
168
-        }
169
-
170
-        $this->process_params($params);
171
-
172
-        if (isset($_POST['id'])) {
173
-
174
-            $this->form_params['backup_params']['backup_name'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['backup_name']);
175
-            $this->form_params['backup_params']['email_notification'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['email_notification']);
176
-            if ($_POST['diff_start_date']) {
177
-                $this->form_params['backup_params']['diff_start_date'] = strtotime($this->xcloner_sanitization->sanitize_input_as_string($_POST['diff_start_date']));
178
-            } else {
179
-                $this->form_params['backup_params']['diff_start_date'] = "";
180
-            }
181
-            $this->form_params['backup_params']['schedule_name'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['schedule_name']);
182
-            $this->form_params['backup_params']['backup_encrypt'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['backup_encrypt']);
183
-            $this->form_params['backup_params']['start_at'] = strtotime($_POST['schedule_start_date']);
184
-            $this->form_params['backup_params']['schedule_frequency'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['schedule_frequency']);
185
-            $this->form_params['backup_params']['schedule_storage'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['schedule_storage']);
186
-            $this->form_params['database'] = (stripslashes($this->xcloner_sanitization->sanitize_input_as_raw($_POST['table_params'])));
187
-            $this->form_params['excluded_files'] = (stripslashes($this->xcloner_sanitization->sanitize_input_as_raw($_POST['excluded_files'])));
188
-
189
-            //$this->form_params['backup_params']['backup_type'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['backup_type']);
190
-
191
-            $tables = explode(PHP_EOL, $this->form_params['database']);
192
-            $return = array();
193
-
194
-            foreach ($tables as $table) {
195
-                $table = str_replace("\r", "", $table);
196
-                $data = explode(".", $table);
197
-                if (isset($data[1])) {
198
-                    $return[$data[0]][] = $data[1];
199
-                }
200
-            }
201
-
202
-            $this->form_params['database'] = ($return);
203
-
204
-            $excluded_files = explode(PHP_EOL, $this->form_params['excluded_files']);
205
-            $return = array();
206
-
207
-            foreach ($excluded_files as $file) {
208
-                $file = str_replace("\r", "", $file);
209
-                if ($file) {
210
-                    $return[] = $file;
211
-                }
212
-            }
213
-
214
-            $this->form_params['excluded_files'] = ($return);
215
-
216
-            $schedule['start_at'] = $this->form_params['backup_params']['start_at'];
217
-
218
-            if (!isset($_POST['status'])) {
219
-                $schedule['status'] = 0;
220
-            } else {
221
-                $schedule['status'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['status']);
222
-            }
223
-        } else {
224
-
225
-            $schedule['status'] = 1;
226
-            $schedule['start_at'] = strtotime($this->form_params['backup_params']['schedule_start_date'] .
227
-                " " . $this->form_params['backup_params']['schedule_start_time']);
228
-
229
-            if ($schedule['start_at'] <= time()) {
230
-                $schedule['start_at'] = "";
231
-            }
232
-        }
233
-
234
-        if (!$schedule['start_at']) {
235
-            $schedule['start_at'] = date('Y-m-d H:i:s', time());
236
-        } else {
237
-            $schedule['start_at'] = date('Y-m-d H:i:s',
238
-                $schedule['start_at'] - (get_option('gmt_offset') * HOUR_IN_SECONDS));
239
-        }
240
-
241
-        $schedule['name'] = $this->form_params['backup_params']['schedule_name'];
242
-        $schedule['recurrence'] = $this->form_params['backup_params']['schedule_frequency'];
243
-        if (!isset($this->form_params['backup_params']['schedule_storage'])) {
244
-            $this->form_params['backup_params']['schedule_storage'] = "";
245
-        }
246
-        $schedule['remote_storage'] = $this->form_params['backup_params']['schedule_storage'];
247
-        //$schedule['backup_type'] = $this->form_params['backup_params']['backup_type'];
248
-        $schedule['params'] = json_encode($this->form_params);
249
-
250
-        if (!isset($_POST['id'])) {
251
-            $wpdb->insert(
252
-                $wpdb->prefix . 'xcloner_scheduler',
253
-                $schedule,
254
-                array(
255
-                    '%s',
256
-                    '%s'
257
-                )
258
-            );
259
-        } else {
260
-            $wpdb->update(
261
-                $wpdb->prefix . 'xcloner_scheduler',
262
-                $schedule,
263
-                array('id' => $_POST['id']),
264
-                array(
265
-                    '%s',
266
-                    '%s'
267
-                )
268
-            );
269
-        }
270
-        if (isset($_POST['id'])) {
271
-            $scheduler->update_cron_hook($_POST['id']);
272
-        }
273
-
274
-        if ($wpdb->last_error) {
275
-            $response['error'] = 1;
276
-            $response['error_message'] = $wpdb->last_error/*."--".$wpdb->last_query*/
277
-            ;
278
-
279
-        }
280
-
281
-        $scheduler->update_wp_cron_hooks();
282
-        $response['finished'] = 1;
283
-
284
-        $this->send_response($response);
285
-    }
286
-
287
-    /*
155
+	public function save_schedule()
156
+	{
157
+		global $wpdb;
158
+
159
+		$this->check_access();
160
+
161
+		$scheduler = $this->xcloner_scheduler;
162
+		$params = array();
163
+		$schedule = array();
164
+		$response = array();
165
+
166
+		if (isset($_POST['data'])) {
167
+			$params = json_decode(stripslashes($_POST['data']));
168
+		}
169
+
170
+		$this->process_params($params);
171
+
172
+		if (isset($_POST['id'])) {
173
+
174
+			$this->form_params['backup_params']['backup_name'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['backup_name']);
175
+			$this->form_params['backup_params']['email_notification'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['email_notification']);
176
+			if ($_POST['diff_start_date']) {
177
+				$this->form_params['backup_params']['diff_start_date'] = strtotime($this->xcloner_sanitization->sanitize_input_as_string($_POST['diff_start_date']));
178
+			} else {
179
+				$this->form_params['backup_params']['diff_start_date'] = "";
180
+			}
181
+			$this->form_params['backup_params']['schedule_name'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['schedule_name']);
182
+			$this->form_params['backup_params']['backup_encrypt'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['backup_encrypt']);
183
+			$this->form_params['backup_params']['start_at'] = strtotime($_POST['schedule_start_date']);
184
+			$this->form_params['backup_params']['schedule_frequency'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['schedule_frequency']);
185
+			$this->form_params['backup_params']['schedule_storage'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['schedule_storage']);
186
+			$this->form_params['database'] = (stripslashes($this->xcloner_sanitization->sanitize_input_as_raw($_POST['table_params'])));
187
+			$this->form_params['excluded_files'] = (stripslashes($this->xcloner_sanitization->sanitize_input_as_raw($_POST['excluded_files'])));
188
+
189
+			//$this->form_params['backup_params']['backup_type'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['backup_type']);
190
+
191
+			$tables = explode(PHP_EOL, $this->form_params['database']);
192
+			$return = array();
193
+
194
+			foreach ($tables as $table) {
195
+				$table = str_replace("\r", "", $table);
196
+				$data = explode(".", $table);
197
+				if (isset($data[1])) {
198
+					$return[$data[0]][] = $data[1];
199
+				}
200
+			}
201
+
202
+			$this->form_params['database'] = ($return);
203
+
204
+			$excluded_files = explode(PHP_EOL, $this->form_params['excluded_files']);
205
+			$return = array();
206
+
207
+			foreach ($excluded_files as $file) {
208
+				$file = str_replace("\r", "", $file);
209
+				if ($file) {
210
+					$return[] = $file;
211
+				}
212
+			}
213
+
214
+			$this->form_params['excluded_files'] = ($return);
215
+
216
+			$schedule['start_at'] = $this->form_params['backup_params']['start_at'];
217
+
218
+			if (!isset($_POST['status'])) {
219
+				$schedule['status'] = 0;
220
+			} else {
221
+				$schedule['status'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['status']);
222
+			}
223
+		} else {
224
+
225
+			$schedule['status'] = 1;
226
+			$schedule['start_at'] = strtotime($this->form_params['backup_params']['schedule_start_date'] .
227
+				" " . $this->form_params['backup_params']['schedule_start_time']);
228
+
229
+			if ($schedule['start_at'] <= time()) {
230
+				$schedule['start_at'] = "";
231
+			}
232
+		}
233
+
234
+		if (!$schedule['start_at']) {
235
+			$schedule['start_at'] = date('Y-m-d H:i:s', time());
236
+		} else {
237
+			$schedule['start_at'] = date('Y-m-d H:i:s',
238
+				$schedule['start_at'] - (get_option('gmt_offset') * HOUR_IN_SECONDS));
239
+		}
240
+
241
+		$schedule['name'] = $this->form_params['backup_params']['schedule_name'];
242
+		$schedule['recurrence'] = $this->form_params['backup_params']['schedule_frequency'];
243
+		if (!isset($this->form_params['backup_params']['schedule_storage'])) {
244
+			$this->form_params['backup_params']['schedule_storage'] = "";
245
+		}
246
+		$schedule['remote_storage'] = $this->form_params['backup_params']['schedule_storage'];
247
+		//$schedule['backup_type'] = $this->form_params['backup_params']['backup_type'];
248
+		$schedule['params'] = json_encode($this->form_params);
249
+
250
+		if (!isset($_POST['id'])) {
251
+			$wpdb->insert(
252
+				$wpdb->prefix . 'xcloner_scheduler',
253
+				$schedule,
254
+				array(
255
+					'%s',
256
+					'%s'
257
+				)
258
+			);
259
+		} else {
260
+			$wpdb->update(
261
+				$wpdb->prefix . 'xcloner_scheduler',
262
+				$schedule,
263
+				array('id' => $_POST['id']),
264
+				array(
265
+					'%s',
266
+					'%s'
267
+				)
268
+			);
269
+		}
270
+		if (isset($_POST['id'])) {
271
+			$scheduler->update_cron_hook($_POST['id']);
272
+		}
273
+
274
+		if ($wpdb->last_error) {
275
+			$response['error'] = 1;
276
+			$response['error_message'] = $wpdb->last_error/*."--".$wpdb->last_query*/
277
+			;
278
+
279
+		}
280
+
281
+		$scheduler->update_wp_cron_hooks();
282
+		$response['finished'] = 1;
283
+
284
+		$this->send_response($response);
285
+	}
286
+
287
+	/*
288 288
      *
289 289
      * Backup Files API
290 290
      *
291 291
      */
292
-    public function backup_files()
293
-    {
294
-        $this->check_access();
295
-
296
-        $params = json_decode(stripslashes($_POST['data']));
297
-
298
-        $init = (int)$_POST['init'];
299
-
300
-        if ($params === null) {
301
-            die('{"status":false,"msg":"The post_data parameter must be valid JSON"}');
302
-        }
303
-
304
-        $this->process_params($params);
305
-
306
-        $return['finished'] = 1;
307
-
308
-        //$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], $this->form_params['extra'], $init);
309
-        try {
310
-            $return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'],
311
-                $this->form_params['extra'], $init);
312
-        } catch (Exception $e) {
313
-            $return = array();
314
-            $return['error'] = true;
315
-            $return['status'] = 500;
316
-            $return['error_message'] = $e->getMessage();
317
-
318
-            return $this->send_response($return, $hash = 1);
319
-        }
320
-
321
-        if ($return['finished']) {
322
-            $return['extra']['backup_parent'] = $this->archive_system->get_archive_name_with_extension();
323
-            if ($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) {
324
-                $return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart();
325
-            }
326
-        }
327
-
328
-        $data = $return;
329
-
330
-        //check if backup is finished
331
-        if ($return['finished']) {
332
-            if (isset($this->form_params['backup_params']['email_notification']) and $to = $this->form_params['backup_params']['email_notification']) {
333
-                try {
334
-                    $from = "";
335
-                    $subject = "";
336
-                    $additional['lines_total'] = $return['extra']['lines_total'];
337
-                    $this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'],
338
-                        $this->form_params, "", $additional);
339
-                } catch (Exception $e) {
340
-                    $this->logger->error($e->getMessage());
341
-                }
342
-            }
343
-            $this->xcloner_file_system->remove_tmp_filesystem();
344
-        }
345
-
346
-        return $this->send_response($data, $hash = 1);
347
-    }
348
-
349
-    /*
292
+	public function backup_files()
293
+	{
294
+		$this->check_access();
295
+
296
+		$params = json_decode(stripslashes($_POST['data']));
297
+
298
+		$init = (int)$_POST['init'];
299
+
300
+		if ($params === null) {
301
+			die('{"status":false,"msg":"The post_data parameter must be valid JSON"}');
302
+		}
303
+
304
+		$this->process_params($params);
305
+
306
+		$return['finished'] = 1;
307
+
308
+		//$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], $this->form_params['extra'], $init);
309
+		try {
310
+			$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'],
311
+				$this->form_params['extra'], $init);
312
+		} catch (Exception $e) {
313
+			$return = array();
314
+			$return['error'] = true;
315
+			$return['status'] = 500;
316
+			$return['error_message'] = $e->getMessage();
317
+
318
+			return $this->send_response($return, $hash = 1);
319
+		}
320
+
321
+		if ($return['finished']) {
322
+			$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_with_extension();
323
+			if ($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) {
324
+				$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart();
325
+			}
326
+		}
327
+
328
+		$data = $return;
329
+
330
+		//check if backup is finished
331
+		if ($return['finished']) {
332
+			if (isset($this->form_params['backup_params']['email_notification']) and $to = $this->form_params['backup_params']['email_notification']) {
333
+				try {
334
+					$from = "";
335
+					$subject = "";
336
+					$additional['lines_total'] = $return['extra']['lines_total'];
337
+					$this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'],
338
+						$this->form_params, "", $additional);
339
+				} catch (Exception $e) {
340
+					$this->logger->error($e->getMessage());
341
+				}
342
+			}
343
+			$this->xcloner_file_system->remove_tmp_filesystem();
344
+		}
345
+
346
+		return $this->send_response($data, $hash = 1);
347
+	}
348
+
349
+	/*
350 350
      *
351 351
      * Backup Database API
352 352
      *
353 353
      */
354
-    public function backup_database()
355
-    {
356
-        $this->check_access();
354
+	public function backup_database()
355
+	{
356
+		$this->check_access();
357 357
 
358
-        $params = json_decode(stripslashes($_POST['data']));
358
+		$params = json_decode(stripslashes($_POST['data']));
359 359
 
360
-        $init = (int)$_POST['init'];
360
+		$init = (int)$_POST['init'];
361 361
 
362
-        if ($params === null) {
363
-            die('{"status":false,"msg":"The post_data parameter must be valid JSON"}');
364
-        }
362
+		if ($params === null) {
363
+			die('{"status":false,"msg":"The post_data parameter must be valid JSON"}');
364
+		}
365 365
 
366
-        $this->process_params($params);
366
+		$this->process_params($params);
367 367
 
368
-        //$xcloner_database = $this->init_db();
369
-        $return = $this->xcloner_database->start_database_recursion($this->form_params['database'],
370
-            $this->form_params['extra'], $init);
368
+		//$xcloner_database = $this->init_db();
369
+		$return = $this->xcloner_database->start_database_recursion($this->form_params['database'],
370
+			$this->form_params['extra'], $init);
371 371
 
372
-        if (isset($return['error']) and $return['error']) {
373
-            $data['finished'] = 1;
374
-        } else {
375
-            $data['finished'] = $return['finished'];
376
-        }
372
+		if (isset($return['error']) and $return['error']) {
373
+			$data['finished'] = 1;
374
+		} else {
375
+			$data['finished'] = $return['finished'];
376
+		}
377 377
 
378
-        $data['extra'] = $return;
378
+		$data['extra'] = $return;
379 379
 
380
-        return $this->send_response($data, $hash = 1);
381
-    }
380
+		return $this->send_response($data, $hash = 1);
381
+	}
382 382
 
383
-    /*
383
+	/*
384 384
      *
385 385
      * Scan Filesystem API
386 386
      *
387 387
      */
388
-    public function scan_filesystem()
389
-    {
390
-        $this->check_access();
388
+	public function scan_filesystem()
389
+	{
390
+		$this->check_access();
391 391
 
392
-        $params = json_decode(stripslashes($_POST['data']));
393
-        $init = (int)$_POST['init'];
392
+		$params = json_decode(stripslashes($_POST['data']));
393
+		$init = (int)$_POST['init'];
394 394
 
395
-        if ($params === null) {
396
-            die('{"status":false,"msg":"The post_data parameter must be valid JSON"}');
397
-        }
395
+		if ($params === null) {
396
+			die('{"status":false,"msg":"The post_data parameter must be valid JSON"}');
397
+		}
398 398
 
399
-        $hash = $this->process_params($params);
399
+		$hash = $this->process_params($params);
400 400
 
401
-        $this->xcloner_file_system->set_excluded_files($this->form_params['excluded_files']);
401
+		$this->xcloner_file_system->set_excluded_files($this->form_params['excluded_files']);
402 402
 
403
-        $return = $this->xcloner_file_system->start_file_recursion($init);
403
+		$return = $this->xcloner_file_system->start_file_recursion($init);
404 404
 
405
-        $data["finished"] = !$return;
406
-        $data["total_files_num"] = $this->xcloner_file_system->get_scanned_files_num();
407
-        $data["last_logged_file"] = $this->xcloner_file_system->last_logged_file();
408
-        $data["total_files_size"] = sprintf("%.2f",
409
-            $this->xcloner_file_system->get_scanned_files_total_size() / (1024 * 1024));
405
+		$data["finished"] = !$return;
406
+		$data["total_files_num"] = $this->xcloner_file_system->get_scanned_files_num();
407
+		$data["last_logged_file"] = $this->xcloner_file_system->last_logged_file();
408
+		$data["total_files_size"] = sprintf("%.2f",
409
+			$this->xcloner_file_system->get_scanned_files_total_size() / (1024 * 1024));
410 410
 
411
-        return $this->send_response($data, $hash = 1);
412
-    }
411
+		return $this->send_response($data, $hash = 1);
412
+	}
413 413
 
414
-    /*
414
+	/*
415 415
      *
416 416
      * Process params sent by the user
417 417
      *
418 418
      */
419
-    private function process_params($params)
420
-    {
421
-        if (isset($params->hash)) {
422
-            $this->xcloner_settings->set_hash($params->hash);
423
-        }
424
-
425
-        $this->form_params['extra'] = array();
426
-        $this->form_params['backup_params'] = array();
427
-
428
-        $this->form_params['database'] = array();
429
-
430
-        if (isset($params->backup_params)) {
431
-            foreach ($params->backup_params as $param) {
432
-                $this->form_params['backup_params'][$param->name] = $this->xcloner_sanitization->sanitize_input_as_string($param->value);
433
-                $this->logger->debug("Adding form parameter " . $param->name . "." . $param->value . "\n", array(
434
-                    'POST',
435
-                    'fields filter'
436
-                ));
437
-            }
438
-        }
439
-
440
-        $this->form_params['database'] = array();
441
-
442
-        if (isset($params->table_params)) {
443
-            foreach ($params->table_params as $param) {
444
-                $this->form_params['database'][$param->parent][] = $this->xcloner_sanitization->sanitize_input_as_raw($param->id);
445
-                $this->logger->debug("Adding database filter " . $param->parent . "." . $param->id . "\n", array(
446
-                    'POST',
447
-                    'database filter'
448
-                ));
449
-            }
450
-        }
451
-
452
-        $this->form_params['excluded_files'] = array();
453
-        if (isset($params->files_params)) {
454
-            foreach ($params->files_params as $param) {
455
-                $this->form_params['excluded_files'][] = $this->xcloner_sanitization->sanitize_input_as_relative_path($param->id);
456
-            }
457
-
458
-            $unique_exclude_files = array();
459
-
460
-            foreach ($params->files_params as $key => $param) {
461
-                if (!in_array($param->parent, $this->form_params['excluded_files'])) {
462
-                    //$this->form_params['excluded_files'][] = $this->xcloner_sanitization->sanitize_input_as_relative_path($param->id);
463
-                    $unique_exclude_files[] = $param->id;
464
-                    $this->logger->debug("Adding file filter " . $param->id . "\n", array(
465
-                        'POST',
466
-                        'exclude files filter'
467
-                    ));
468
-                }
469
-            }
470
-            $this->form_params['excluded_files'] = (array)$unique_exclude_files;
471
-
472
-        }
473
-
474
-        //$this->form_params['excluded_files'] =  array_merge($this->form_params['excluded_files'], $this->exclude_files_by_default);
475
-
476
-        if (isset($params->extra)) {
477
-            foreach ($params->extra as $key => $value) {
478
-                $this->form_params['extra'][$key] = $this->xcloner_sanitization->sanitize_input_as_raw($value);
479
-            }
480
-        }
481
-
482
-        if (isset($this->form_params['backup_params']['diff_start_date']) and $this->form_params['backup_params']['diff_start_date']) {
483
-            $this->form_params['backup_params']['diff_start_date'] = strtotime($this->form_params['backup_params']['diff_start_date']);
484
-            $this->xcloner_file_system->set_diff_timestamp_start($this->form_params['backup_params']['diff_start_date']);
485
-        }
486
-
487
-        return $this->xcloner_settings->get_hash();
488
-    }
489
-
490
-    /*
419
+	private function process_params($params)
420
+	{
421
+		if (isset($params->hash)) {
422
+			$this->xcloner_settings->set_hash($params->hash);
423
+		}
424
+
425
+		$this->form_params['extra'] = array();
426
+		$this->form_params['backup_params'] = array();
427
+
428
+		$this->form_params['database'] = array();
429
+
430
+		if (isset($params->backup_params)) {
431
+			foreach ($params->backup_params as $param) {
432
+				$this->form_params['backup_params'][$param->name] = $this->xcloner_sanitization->sanitize_input_as_string($param->value);
433
+				$this->logger->debug("Adding form parameter " . $param->name . "." . $param->value . "\n", array(
434
+					'POST',
435
+					'fields filter'
436
+				));
437
+			}
438
+		}
439
+
440
+		$this->form_params['database'] = array();
441
+
442
+		if (isset($params->table_params)) {
443
+			foreach ($params->table_params as $param) {
444
+				$this->form_params['database'][$param->parent][] = $this->xcloner_sanitization->sanitize_input_as_raw($param->id);
445
+				$this->logger->debug("Adding database filter " . $param->parent . "." . $param->id . "\n", array(
446
+					'POST',
447
+					'database filter'
448
+				));
449
+			}
450
+		}
451
+
452
+		$this->form_params['excluded_files'] = array();
453
+		if (isset($params->files_params)) {
454
+			foreach ($params->files_params as $param) {
455
+				$this->form_params['excluded_files'][] = $this->xcloner_sanitization->sanitize_input_as_relative_path($param->id);
456
+			}
457
+
458
+			$unique_exclude_files = array();
459
+
460
+			foreach ($params->files_params as $key => $param) {
461
+				if (!in_array($param->parent, $this->form_params['excluded_files'])) {
462
+					//$this->form_params['excluded_files'][] = $this->xcloner_sanitization->sanitize_input_as_relative_path($param->id);
463
+					$unique_exclude_files[] = $param->id;
464
+					$this->logger->debug("Adding file filter " . $param->id . "\n", array(
465
+						'POST',
466
+						'exclude files filter'
467
+					));
468
+				}
469
+			}
470
+			$this->form_params['excluded_files'] = (array)$unique_exclude_files;
471
+
472
+		}
473
+
474
+		//$this->form_params['excluded_files'] =  array_merge($this->form_params['excluded_files'], $this->exclude_files_by_default);
475
+
476
+		if (isset($params->extra)) {
477
+			foreach ($params->extra as $key => $value) {
478
+				$this->form_params['extra'][$key] = $this->xcloner_sanitization->sanitize_input_as_raw($value);
479
+			}
480
+		}
481
+
482
+		if (isset($this->form_params['backup_params']['diff_start_date']) and $this->form_params['backup_params']['diff_start_date']) {
483
+			$this->form_params['backup_params']['diff_start_date'] = strtotime($this->form_params['backup_params']['diff_start_date']);
484
+			$this->xcloner_file_system->set_diff_timestamp_start($this->form_params['backup_params']['diff_start_date']);
485
+		}
486
+
487
+		return $this->xcloner_settings->get_hash();
488
+	}
489
+
490
+	/*
491 491
      *
492 492
      * Get file list for tree view API
493 493
      *
494 494
      */
495
-    public function get_file_system_action()
496
-    {
497
-        $this->check_access();
498
-
499
-        $folder = $this->xcloner_sanitization->sanitize_input_as_relative_path($_POST['id']);
500
-
501
-        $data = array();
502
-
503
-        if ($folder == "#") {
504
-
505
-            $folder = "/";
506
-            $data[] = array(
507
-                'id' => $folder,
508
-                'parent' => '#',
509
-                'text' => $this->xcloner_settings->get_xcloner_start_path(),
510
-                //'children' => true,
511
-                'state' => array('selected' => false, 'opened' => true),
512
-                'icon' => plugin_dir_url(dirname(__FILE__)) . "/admin/assets/file-icon-root.png"
513
-            );
514
-        }
515
-
516
-        try {
517
-            $files = $this->xcloner_file_system->list_directory($folder);
518
-        } catch (Exception $e) {
519
-
520
-            print $e->getMessage();
521
-            $this->logger->error($e->getMessage());
522
-
523
-            return;
524
-        }
525
-
526
-        $type = array();
527
-        foreach ($files as $key => $row) {
528
-            $type[$key] = $row['type'];
529
-        }
530
-        array_multisort($type, SORT_ASC, $files);
531
-
532
-        foreach ($files as $file) {
533
-            $children = false;
534
-            $text = $file['basename'];
535
-
536
-            if ($file['type'] == "dir") {
537
-                $children = true;
538
-            } else {
539
-                $text .= " (" . $this->xcloner_requirements->file_format_size($file['size']) . ")";
540
-            }
541
-
542
-            if ($this->xcloner_file_system->is_excluded($file)) {
543
-                $selected = true;
544
-            } else {
545
-                $selected = false;
546
-            }
547
-
548
-            $data[] = array(
549
-                'id' => $file['path'],
550
-                'parent' => $folder,
551
-                'text' => $text,
552
-                //'title' => "test",
553
-                'children' => $children,
554
-                'state' => array('selected' => $selected, 'opened' => false, "checkbox_disabled" => $selected),
555
-                'icon' => plugin_dir_url(dirname(__FILE__)) . "/admin/assets/file-icon-" . strtolower(substr($file['type'],
556
-                        0, 1)) . ".png"
557
-            );
558
-        }
559
-
560
-
561
-        return $this->send_response($data, 0);
562
-    }
563
-
564
-    /*
495
+	public function get_file_system_action()
496
+	{
497
+		$this->check_access();
498
+
499
+		$folder = $this->xcloner_sanitization->sanitize_input_as_relative_path($_POST['id']);
500
+
501
+		$data = array();
502
+
503
+		if ($folder == "#") {
504
+
505
+			$folder = "/";
506
+			$data[] = array(
507
+				'id' => $folder,
508
+				'parent' => '#',
509
+				'text' => $this->xcloner_settings->get_xcloner_start_path(),
510
+				//'children' => true,
511
+				'state' => array('selected' => false, 'opened' => true),
512
+				'icon' => plugin_dir_url(dirname(__FILE__)) . "/admin/assets/file-icon-root.png"
513
+			);
514
+		}
515
+
516
+		try {
517
+			$files = $this->xcloner_file_system->list_directory($folder);
518
+		} catch (Exception $e) {
519
+
520
+			print $e->getMessage();
521
+			$this->logger->error($e->getMessage());
522
+
523
+			return;
524
+		}
525
+
526
+		$type = array();
527
+		foreach ($files as $key => $row) {
528
+			$type[$key] = $row['type'];
529
+		}
530
+		array_multisort($type, SORT_ASC, $files);
531
+
532
+		foreach ($files as $file) {
533
+			$children = false;
534
+			$text = $file['basename'];
535
+
536
+			if ($file['type'] == "dir") {
537
+				$children = true;
538
+			} else {
539
+				$text .= " (" . $this->xcloner_requirements->file_format_size($file['size']) . ")";
540
+			}
541
+
542
+			if ($this->xcloner_file_system->is_excluded($file)) {
543
+				$selected = true;
544
+			} else {
545
+				$selected = false;
546
+			}
547
+
548
+			$data[] = array(
549
+				'id' => $file['path'],
550
+				'parent' => $folder,
551
+				'text' => $text,
552
+				//'title' => "test",
553
+				'children' => $children,
554
+				'state' => array('selected' => $selected, 'opened' => false, "checkbox_disabled" => $selected),
555
+				'icon' => plugin_dir_url(dirname(__FILE__)) . "/admin/assets/file-icon-" . strtolower(substr($file['type'],
556
+						0, 1)) . ".png"
557
+			);
558
+		}
559
+
560
+
561
+		return $this->send_response($data, 0);
562
+	}
563
+
564
+	/*
565 565
      *
566 566
      * Get databases/tables list for frontend tree display API
567 567
      *
568 568
      */
569
-    public function get_database_tables_action()
570
-    {
571
-        $this->check_access();
572
-
573
-        $database = $this->xcloner_sanitization->sanitize_input_as_raw($_POST['id']);
574
-
575
-        $data = array();
576
-
577
-        $xcloner_backup_only_wp_tables = $this->xcloner_settings->get_xcloner_option('xcloner_backup_only_wp_tables');
578
-
579
-        if ($database == "#") {
580
-            try {
581
-                $return = $this->xcloner_database->get_all_databases();
582
-            } catch (Exception $e) {
583
-                $this->logger->error($e->getMessage());
584
-            }
585
-
586
-            foreach ($return as $database) {
587
-                if ($xcloner_backup_only_wp_tables and $database['name'] != $this->xcloner_settings->get_db_database()) {
588
-                    continue;
589
-                }
590
-
591
-                $state = array();
592
-
593
-                if ($database['name'] == $this->xcloner_settings->get_db_database()) {
594
-                    $state['selected'] = true;
595
-                    if ($database['num_tables'] < 25) {
596
-                        $state['opened'] = false;
597
-                    }
598
-                }
599
-
600
-                $data[] = array(
601
-                    'id' => $database['name'],
602
-                    'parent' => '#',
603
-                    'text' => $database['name'] . " (" . (int)$database['num_tables'] . ")",
604
-                    'children' => true,
605
-                    'state' => $state,
606
-                    'icon' => plugin_dir_url(dirname(__FILE__)) . "/admin/assets/database-icon.png"
607
-                );
608
-            }
609
-
610
-        } else {
611
-
612
-            try {
613
-                $return = $this->xcloner_database->list_tables($database, "", 1);
614
-            } catch (Exception $e) {
615
-                $this->logger->error($e->getMessage());
616
-            }
617
-
618
-            foreach ($return as $table) {
619
-                $state = array();
620
-
621
-                if ($xcloner_backup_only_wp_tables and !stristr($table['name'],
622
-                        $this->xcloner_settings->get_table_prefix())) {
623
-                    continue;
624
-                }
625
-
626
-                if (isset($database['name']) and $database['name'] == $this->xcloner_settings->get_db_database()) {
627
-                    $state = array('selected' => true);
628
-                }
629
-
630
-                $data[] = array(
631
-                    'id' => $database . "." . $table['name'],
632
-                    'parent' => $database,
633
-                    'text' => $table['name'] . " (" . (int)$table['records'] . ")",
634
-                    'children' => false,
635
-                    'state' => $state,
636
-                    'icon' => plugin_dir_url(dirname(__FILE__)) . "/admin/assets/table-icon.png"
637
-                );
638
-            }
639
-        }
640
-
641
-        return $this->send_response($data, 0);
642
-    }
643
-
644
-    /*
569
+	public function get_database_tables_action()
570
+	{
571
+		$this->check_access();
572
+
573
+		$database = $this->xcloner_sanitization->sanitize_input_as_raw($_POST['id']);
574
+
575
+		$data = array();
576
+
577
+		$xcloner_backup_only_wp_tables = $this->xcloner_settings->get_xcloner_option('xcloner_backup_only_wp_tables');
578
+
579
+		if ($database == "#") {
580
+			try {
581
+				$return = $this->xcloner_database->get_all_databases();
582
+			} catch (Exception $e) {
583
+				$this->logger->error($e->getMessage());
584
+			}
585
+
586
+			foreach ($return as $database) {
587
+				if ($xcloner_backup_only_wp_tables and $database['name'] != $this->xcloner_settings->get_db_database()) {
588
+					continue;
589
+				}
590
+
591
+				$state = array();
592
+
593
+				if ($database['name'] == $this->xcloner_settings->get_db_database()) {
594
+					$state['selected'] = true;
595
+					if ($database['num_tables'] < 25) {
596
+						$state['opened'] = false;
597
+					}
598
+				}
599
+
600
+				$data[] = array(
601
+					'id' => $database['name'],
602
+					'parent' => '#',
603
+					'text' => $database['name'] . " (" . (int)$database['num_tables'] . ")",
604
+					'children' => true,
605
+					'state' => $state,
606
+					'icon' => plugin_dir_url(dirname(__FILE__)) . "/admin/assets/database-icon.png"
607
+				);
608
+			}
609
+
610
+		} else {
611
+
612
+			try {
613
+				$return = $this->xcloner_database->list_tables($database, "", 1);
614
+			} catch (Exception $e) {
615
+				$this->logger->error($e->getMessage());
616
+			}
617
+
618
+			foreach ($return as $table) {
619
+				$state = array();
620
+
621
+				if ($xcloner_backup_only_wp_tables and !stristr($table['name'],
622
+						$this->xcloner_settings->get_table_prefix())) {
623
+					continue;
624
+				}
625
+
626
+				if (isset($database['name']) and $database['name'] == $this->xcloner_settings->get_db_database()) {
627
+					$state = array('selected' => true);
628
+				}
629
+
630
+				$data[] = array(
631
+					'id' => $database . "." . $table['name'],
632
+					'parent' => $database,
633
+					'text' => $table['name'] . " (" . (int)$table['records'] . ")",
634
+					'children' => false,
635
+					'state' => $state,
636
+					'icon' => plugin_dir_url(dirname(__FILE__)) . "/admin/assets/table-icon.png"
637
+				);
638
+			}
639
+		}
640
+
641
+		return $this->send_response($data, 0);
642
+	}
643
+
644
+	/*
645 645
      *
646 646
      * Get schedule by id API
647 647
      *
648 648
      */
649
-    public function get_schedule_by_id()
650
-    {
651
-        $this->check_access();
649
+	public function get_schedule_by_id()
650
+	{
651
+		$this->check_access();
652 652
 
653
-        $schedule_id = $this->xcloner_sanitization->sanitize_input_as_int($_GET['id']);
654
-        $scheduler = $this->xcloner_scheduler;
655
-        $data = $scheduler->get_schedule_by_id($schedule_id);
653
+		$schedule_id = $this->xcloner_sanitization->sanitize_input_as_int($_GET['id']);
654
+		$scheduler = $this->xcloner_scheduler;
655
+		$data = $scheduler->get_schedule_by_id($schedule_id);
656 656
 
657
-        $data['start_at'] = date("Y-m-d H:i",
658
-            strtotime($data['start_at']) + (get_option('gmt_offset') * HOUR_IN_SECONDS));
659
-        if (isset($data['backup_params']->diff_start_date) && $data['backup_params']->diff_start_date != "") {
660
-            $data['backup_params']->diff_start_date = date("Y-m-d", ($data['backup_params']->diff_start_date));
661
-        }
657
+		$data['start_at'] = date("Y-m-d H:i",
658
+			strtotime($data['start_at']) + (get_option('gmt_offset') * HOUR_IN_SECONDS));
659
+		if (isset($data['backup_params']->diff_start_date) && $data['backup_params']->diff_start_date != "") {
660
+			$data['backup_params']->diff_start_date = date("Y-m-d", ($data['backup_params']->diff_start_date));
661
+		}
662 662
 
663
-        return $this->send_response($data);
664
-    }
663
+		return $this->send_response($data);
664
+	}
665 665
 
666
-    /*
666
+	/*
667 667
      *
668 668
      * Get Schedule list API
669 669
      *
670 670
      */
671
-    public function get_scheduler_list()
672
-    {
673
-        $this->check_access();
671
+	public function get_scheduler_list()
672
+	{
673
+		$this->check_access();
674 674
 
675
-        $scheduler = $this->xcloner_scheduler;
676
-        $data = $scheduler->get_scheduler_list();
677
-        $return['data'] = array();
675
+		$scheduler = $this->xcloner_scheduler;
676
+		$data = $scheduler->get_scheduler_list();
677
+		$return['data'] = array();
678 678
 
679
-        foreach ($data as $res) {
680
-            $action = "<a href=\"#" . $res->id . "\" class=\"edit\" title='Edit'> <i class=\"material-icons \">edit</i></a>
679
+		foreach ($data as $res) {
680
+			$action = "<a href=\"#" . $res->id . "\" class=\"edit\" title='Edit'> <i class=\"material-icons \">edit</i></a>
681 681
 					<a href=\"#" . $res->id . "\" class=\"delete\" title='Delete'><i class=\"material-icons  \">delete</i></a>";
682
-            if ($res->status) {
683
-                $status = '<i class="material-icons active status">timer</i>';
684
-            } else {
685
-                $status = '<i class="material-icons status inactive">timer_off</i>';
686
-            }
687
-
688
-            $next_run_time = wp_next_scheduled('xcloner_scheduler_' . $res->id, array($res->id));
689
-
690
-            $next_run = date(get_option('date_format') . " " . get_option('time_format'), $next_run_time);
691
-
692
-            $remote_storage = $res->remote_storage;
693
-
694
-            if (!$next_run_time >= time()) {
695
-                $next_run = " ";
696
-            }
697
-
698
-            if (trim($next_run)) {
699
-                $date_text = date(get_option('date_format') . " " . get_option('time_format'),
700
-                    $next_run_time + (get_option('gmt_offset') * HOUR_IN_SECONDS));
701
-
702
-                if ($next_run_time >= time()) {
703
-                    $next_run = "in " . human_time_diff($next_run_time, time());
704
-                } else {
705
-                    $next_run = __("executed", 'xcloner-backup-and-restore');
706
-                }
707
-
708
-                $next_run = "<a href='#' title='" . $date_text . "'>" . $next_run . "</a>";
709
-                //$next_run .=" ($date_text)";
710
-            }
711
-
712
-            $backup_text = "";
713
-            $backup_size = "";
714
-            $backup_time = "";
715
-
716
-            if ($res->last_backup) {
717
-                if ($this->xcloner_file_system->get_storage_filesystem()->has($res->last_backup)) {
718
-                    $metadata = $this->xcloner_file_system->get_storage_filesystem()->getMetadata($res->last_backup);
719
-                    $backup_size = size_format($this->xcloner_file_system->get_backup_size($res->last_backup));
720
-                    $backup_time = date(get_option('date_format') . " " . get_option('time_format'),
721
-                        $metadata['timestamp'] + (get_option('gmt_offset') * HOUR_IN_SECONDS));
722
-                }
723
-
724
-                $backup_text = "<span title='" . $backup_time . "' class='shorten_string'>" . $res->last_backup . " (" . $backup_size . ")</span>";
725
-            }
726
-
727
-            $schedules = wp_get_schedules();
728
-
729
-            if (isset($schedules[$res->recurrence])) {
730
-                $res->recurrence = $schedules[$res->recurrence]['display'];
731
-            }
732
-
733
-            $return['data'][] = array(
734
-                $res->id,
735
-                $res->name,
736
-                $res->recurrence,/*$res->start_at,*/
737
-                $next_run,
738
-                $remote_storage,
739
-                $backup_text,
740
-                $status,
741
-                $action
742
-            );
743
-        }
744
-
745
-        return $this->send_response($return, 0);
746
-    }
747
-
748
-    /*
682
+			if ($res->status) {
683
+				$status = '<i class="material-icons active status">timer</i>';
684
+			} else {
685
+				$status = '<i class="material-icons status inactive">timer_off</i>';
686
+			}
687
+
688
+			$next_run_time = wp_next_scheduled('xcloner_scheduler_' . $res->id, array($res->id));
689
+
690
+			$next_run = date(get_option('date_format') . " " . get_option('time_format'), $next_run_time);
691
+
692
+			$remote_storage = $res->remote_storage;
693
+
694
+			if (!$next_run_time >= time()) {
695
+				$next_run = " ";
696
+			}
697
+
698
+			if (trim($next_run)) {
699
+				$date_text = date(get_option('date_format') . " " . get_option('time_format'),
700
+					$next_run_time + (get_option('gmt_offset') * HOUR_IN_SECONDS));
701
+
702
+				if ($next_run_time >= time()) {
703
+					$next_run = "in " . human_time_diff($next_run_time, time());
704
+				} else {
705
+					$next_run = __("executed", 'xcloner-backup-and-restore');
706
+				}
707
+
708
+				$next_run = "<a href='#' title='" . $date_text . "'>" . $next_run . "</a>";
709
+				//$next_run .=" ($date_text)";
710
+			}
711
+
712
+			$backup_text = "";
713
+			$backup_size = "";
714
+			$backup_time = "";
715
+
716
+			if ($res->last_backup) {
717
+				if ($this->xcloner_file_system->get_storage_filesystem()->has($res->last_backup)) {
718
+					$metadata = $this->xcloner_file_system->get_storage_filesystem()->getMetadata($res->last_backup);
719
+					$backup_size = size_format($this->xcloner_file_system->get_backup_size($res->last_backup));
720
+					$backup_time = date(get_option('date_format') . " " . get_option('time_format'),
721
+						$metadata['timestamp'] + (get_option('gmt_offset') * HOUR_IN_SECONDS));
722
+				}
723
+
724
+				$backup_text = "<span title='" . $backup_time . "' class='shorten_string'>" . $res->last_backup . " (" . $backup_size . ")</span>";
725
+			}
726
+
727
+			$schedules = wp_get_schedules();
728
+
729
+			if (isset($schedules[$res->recurrence])) {
730
+				$res->recurrence = $schedules[$res->recurrence]['display'];
731
+			}
732
+
733
+			$return['data'][] = array(
734
+				$res->id,
735
+				$res->name,
736
+				$res->recurrence,/*$res->start_at,*/
737
+				$next_run,
738
+				$remote_storage,
739
+				$backup_text,
740
+				$status,
741
+				$action
742
+			);
743
+		}
744
+
745
+		return $this->send_response($return, 0);
746
+	}
747
+
748
+	/*
749 749
      *
750 750
      * Delete Schedule by ID API
751 751
      *
752 752
      */
753
-    public function delete_schedule_by_id()
754
-    {
755
-        $this->check_access();
753
+	public function delete_schedule_by_id()
754
+	{
755
+		$this->check_access();
756 756
 
757
-        $schedule_id = $this->xcloner_sanitization->sanitize_input_as_int($_GET['id']);
758
-        $scheduler = $this->xcloner_scheduler;
759
-        $data['finished'] = $scheduler->delete_schedule_by_id($schedule_id);
757
+		$schedule_id = $this->xcloner_sanitization->sanitize_input_as_int($_GET['id']);
758
+		$scheduler = $this->xcloner_scheduler;
759
+		$data['finished'] = $scheduler->delete_schedule_by_id($schedule_id);
760 760
 
761
-        return $this->send_response($data);
762
-    }
761
+		return $this->send_response($data);
762
+	}
763 763
 
764
-    /*
764
+	/*
765 765
      *
766 766
      * Delete backup by name from the storage path
767 767
      *
768 768
      */
769
-    public function delete_backup_by_name()
770
-    {
771
-        $this->check_access();
769
+	public function delete_backup_by_name()
770
+	{
771
+		$this->check_access();
772
+
773
+		$backup_name = $this->xcloner_sanitization->sanitize_input_as_string($_POST['name']);
774
+		$storage_selection = $this->xcloner_sanitization->sanitize_input_as_string($_POST['storage_selection']);
775
+
776
+		$data['finished'] = $this->xcloner_file_system->delete_backup_by_name($backup_name, $storage_selection);
777
+
778
+		return $this->send_response($data);
779
+	}
780
+
781
+	/**
782
+	 *  API Incremental Backup Encryption Method
783
+	 */
784
+	public function backup_encryption()
785
+	{
786
+		$this->check_access();
787
+
788
+		$backup_parts = array();
789
+		$return = array();
772 790
 
773
-        $backup_name = $this->xcloner_sanitization->sanitize_input_as_string($_POST['name']);
774
-        $storage_selection = $this->xcloner_sanitization->sanitize_input_as_string($_POST['storage_selection']);
775 791
 
776
-        $data['finished'] = $this->xcloner_file_system->delete_backup_by_name($backup_name, $storage_selection);
792
+		if (isset($_POST['data'])) {
793
+			$params = json_decode(stripslashes($_POST['data']));
794
+
795
+			$this->process_params($params);
796
+			$source_backup_file = $this->xcloner_sanitization->sanitize_input_as_string($this->form_params['extra']['backup_parent']);
797
+
798
+			if(isset($this->form_params['extra']['start'])) {
799
+				$start = $this->xcloner_sanitization->sanitize_input_as_int($this->form_params['extra']['start']);
800
+			}else{
801
+				$start = 0;
802
+			}
803
+
804
+			if(isset($this->form_params['extra']['iv'])) {
805
+				$iv = $this->xcloner_sanitization->sanitize_input_as_raw($this->form_params['extra']['iv']);
806
+			}else{
807
+				$iv = "";
808
+			}
809
+
810
+			if(isset($this->form_params['extra']['part'])) {
811
+				$return['part'] = (int)$this->xcloner_sanitization->sanitize_input_as_int($this->form_params['extra']['part']);
812
+			}else{
813
+				$return['part'] = 0;
814
+			}
777 815
 
778
-        return $this->send_response($data);
779
-    }
816
+		}else{
817
+			$source_backup_file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
818
+			$start = $this->xcloner_sanitization->sanitize_input_as_int($_POST['start']);
819
+			$iv = $this->xcloner_sanitization->sanitize_input_as_raw($_POST['iv']);
820
+			$return['part'] = (int)$this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
821
+		}
780 822
 
781
-    /**
782
-     *  API Incremental Backup Encryption Method
783
-     */
784
-    public function backup_encryption()
785
-    {
786
-        $this->check_access();
787
-
788
-        $backup_parts = array();
789
-        $return = array();
790
-
791
-
792
-        if (isset($_POST['data'])) {
793
-            $params = json_decode(stripslashes($_POST['data']));
794
-
795
-            $this->process_params($params);
796
-            $source_backup_file = $this->xcloner_sanitization->sanitize_input_as_string($this->form_params['extra']['backup_parent']);
797
-
798
-            if(isset($this->form_params['extra']['start'])) {
799
-                $start = $this->xcloner_sanitization->sanitize_input_as_int($this->form_params['extra']['start']);
800
-            }else{
801
-                $start = 0;
802
-            }
803
-
804
-            if(isset($this->form_params['extra']['iv'])) {
805
-                $iv = $this->xcloner_sanitization->sanitize_input_as_raw($this->form_params['extra']['iv']);
806
-            }else{
807
-                $iv = "";
808
-            }
809
-
810
-            if(isset($this->form_params['extra']['part'])) {
811
-                $return['part'] = (int)$this->xcloner_sanitization->sanitize_input_as_int($this->form_params['extra']['part']);
812
-            }else{
813
-                $return['part'] = 0;
814
-            }
815
-
816
-        }else{
817
-            $source_backup_file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
818
-            $start = $this->xcloner_sanitization->sanitize_input_as_int($_POST['start']);
819
-            $iv = $this->xcloner_sanitization->sanitize_input_as_raw($_POST['iv']);
820
-            $return['part'] = (int)$this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
821
-        }
822
-
823
-        $backup_file = $source_backup_file;
824
-
825
-        if ($this->xcloner_file_system->is_multipart($backup_file)) {
826
-            $backup_parts = $this->xcloner_file_system->get_multipart_files($backup_file);
827
-            $backup_file = $backup_parts[$return['part']];
828
-        }
829
-
830
-        $return['processing_file'] = $backup_file;
831
-        $return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path() . DS . $backup_file);
832
-
833
-        try {
834
-            $this->logger->info(json_encode($_POST));
835
-            $this->logger->info($iv);
836
-            $return = array_merge($return,
837
-                $this->xcloner_encryption->encrypt_file($backup_file, "", "", $start, base64_decode($iv)));
838
-        }catch(\Exception $e){
839
-            $return['error'] = true;
840
-            $return['message'] = $e->getMessage();
841
-            $return['error_message'] = $e->getMessage();
842
-        }
843
-
844
-        //echo strlen($return['iv']);exit;
845
-
846
-        if($return['finished']) {
847
-            if ($this->xcloner_file_system->is_multipart($source_backup_file)) {
848
-                $return['start'] = 0;
849
-
850
-                ++$return['part'];
851
-
852
-                if ($return['part'] < sizeof($backup_parts)) {
853
-                    $return['finished'] = 0;
854
-                }
855
-
856
-            }
857
-        }
858
-
859
-        if (isset($_POST['data'])) {
860
-            $return['extra'] = array_merge($this->form_params['extra'],  $return);
861
-        }
862
-
863
-        $this->send_response($return, 0);
864
-    }
865
-
866
-    /**
867
-     *  API Incremental Backup Decryption Method
868
-     */
869
-    public function backup_decryption()
870
-    {
871
-        $this->check_access();
823
+		$backup_file = $source_backup_file;
824
+
825
+		if ($this->xcloner_file_system->is_multipart($backup_file)) {
826
+			$backup_parts = $this->xcloner_file_system->get_multipart_files($backup_file);
827
+			$backup_file = $backup_parts[$return['part']];
828
+		}
829
+
830
+		$return['processing_file'] = $backup_file;
831
+		$return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path() . DS . $backup_file);
832
+
833
+		try {
834
+			$this->logger->info(json_encode($_POST));
835
+			$this->logger->info($iv);
836
+			$return = array_merge($return,
837
+				$this->xcloner_encryption->encrypt_file($backup_file, "", "", $start, base64_decode($iv)));
838
+		}catch(\Exception $e){
839
+			$return['error'] = true;
840
+			$return['message'] = $e->getMessage();
841
+			$return['error_message'] = $e->getMessage();
842
+		}
872 843
 
873
-        $backup_parts = array();
874
-        $return = array();
844
+		//echo strlen($return['iv']);exit;
875 845
 
876
-        $source_backup_file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
877
-        $start = $this->xcloner_sanitization->sanitize_input_as_int($_POST['start']);
878
-        $iv = $this->xcloner_sanitization->sanitize_input_as_raw($_POST['iv']);
879
-        $decryption_key = $this->xcloner_sanitization->sanitize_input_as_raw($_POST['decryption_key']);;
880
-        $return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
846
+		if($return['finished']) {
847
+			if ($this->xcloner_file_system->is_multipart($source_backup_file)) {
848
+				$return['start'] = 0;
881 849
 
882
-        $backup_file = $source_backup_file;
850
+				++$return['part'];
883 851
 
884
-        if ($this->xcloner_file_system->is_multipart($backup_file)) {
885
-            $backup_parts = $this->xcloner_file_system->get_multipart_files($backup_file);
886
-            $backup_file = $backup_parts[$return['part']];
887
-        }
852
+				if ($return['part'] < sizeof($backup_parts)) {
853
+					$return['finished'] = 0;
854
+				}
888 855
 
889
-        $return['processing_file'] = $backup_file;
890
-        $return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path() . DS . $backup_file);
856
+			}
857
+		}
891 858
 
892
-        try {
893
-            $return = array_merge($return,
894
-                $this->xcloner_encryption->decrypt_file($backup_file, "", $decryption_key, $start, base64_decode($iv)));
895
-        }catch(\Exception $e){
896
-            $return['error'] = true;
897
-            $return['message'] = $e->getMessage();
898
-        }
859
+		if (isset($_POST['data'])) {
860
+			$return['extra'] = array_merge($this->form_params['extra'],  $return);
861
+		}
899 862
 
900
-        if($return['finished']) {
901
-            if ($this->xcloner_file_system->is_multipart($source_backup_file)) {
902
-                $return['start'] = 0;
863
+		$this->send_response($return, 0);
864
+	}
903 865
 
904
-                ++$return['part'];
866
+	/**
867
+	 *  API Incremental Backup Decryption Method
868
+	 */
869
+	public function backup_decryption()
870
+	{
871
+		$this->check_access();
905 872
 
906
-                if ($return['part'] < sizeof($backup_parts)) {
907
-                    $return['finished'] = 0;
908
-                }
873
+		$backup_parts = array();
874
+		$return = array();
909 875
 
910
-            }
911
-        }
876
+		$source_backup_file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
877
+		$start = $this->xcloner_sanitization->sanitize_input_as_int($_POST['start']);
878
+		$iv = $this->xcloner_sanitization->sanitize_input_as_raw($_POST['iv']);
879
+		$decryption_key = $this->xcloner_sanitization->sanitize_input_as_raw($_POST['decryption_key']);;
880
+		$return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
881
+
882
+		$backup_file = $source_backup_file;
912 883
 
913
-        $this->send_response($return, 0);
914
-    }
884
+		if ($this->xcloner_file_system->is_multipart($backup_file)) {
885
+			$backup_parts = $this->xcloner_file_system->get_multipart_files($backup_file);
886
+			$backup_file = $backup_parts[$return['part']];
887
+		}
915 888
 
916
-    public function get_manage_backups_list() {
889
+		$return['processing_file'] = $backup_file;
890
+		$return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path() . DS . $backup_file);
917 891
 
918
-        $storage_selection = "";
892
+		try {
893
+			$return = array_merge($return,
894
+				$this->xcloner_encryption->decrypt_file($backup_file, "", $decryption_key, $start, base64_decode($iv)));
895
+		}catch(\Exception $e){
896
+			$return['error'] = true;
897
+			$return['message'] = $e->getMessage();
898
+		}
899
+
900
+		if($return['finished']) {
901
+			if ($this->xcloner_file_system->is_multipart($source_backup_file)) {
902
+				$return['start'] = 0;
919 903
 
920
-        if (isset($_GET['storage_selection']) and $_GET['storage_selection']) {
921
-            $storage_selection = $this->xcloner_sanitization->sanitize_input_as_string($_GET['storage_selection']);
922
-        }
923
-        $available_storages = $this->xcloner_remote_storage->get_available_storages();
904
+				++$return['part'];
905
+
906
+				if ($return['part'] < sizeof($backup_parts)) {
907
+					$return['finished'] = 0;
908
+				}
924 909
 
925
-        $backup_list = $this->xcloner_file_system->get_backup_archives_list($storage_selection);
926
-        $return = array();
910
+			}
911
+		}
927 912
 
928
-        $i = -1;
929
-        foreach ($backup_list as $file_info):?>
913
+		$this->send_response($return, 0);
914
+	}
915
+
916
+	public function get_manage_backups_list() {
917
+
918
+		$storage_selection = "";
919
+
920
+		if (isset($_GET['storage_selection']) and $_GET['storage_selection']) {
921
+			$storage_selection = $this->xcloner_sanitization->sanitize_input_as_string($_GET['storage_selection']);
922
+		}
923
+		$available_storages = $this->xcloner_remote_storage->get_available_storages();
924
+
925
+		$backup_list = $this->xcloner_file_system->get_backup_archives_list($storage_selection);
926
+		$return = array();
927
+
928
+		$i = -1;
929
+		foreach ($backup_list as $file_info):?>
930 930
             <?php
931
-            if ($storage_selection == "gdrive") {
932
-                $file_info['path'] = $file_info['filename'] . "." . $file_info['extension'];
933
-            }
934
-            $file_exists_on_local_storage = true;
935
-
936
-            if ($storage_selection) {
937
-                if (!$this->xcloner_file_system->get_storage_filesystem()->has($file_info['path'])) {
938
-                    $file_exists_on_local_storage = false;
939
-                }
940
-            }
941
-
942
-            ?>
931
+			if ($storage_selection == "gdrive") {
932
+				$file_info['path'] = $file_info['filename'] . "." . $file_info['extension'];
933
+			}
934
+			$file_exists_on_local_storage = true;
935
+
936
+			if ($storage_selection) {
937
+				if (!$this->xcloner_file_system->get_storage_filesystem()->has($file_info['path'])) {
938
+					$file_exists_on_local_storage = false;
939
+				}
940
+			}
941
+
942
+			?>
943 943
             <?php if (!isset($file_info['parent'])): ?>
944 944
 
945 945
                 <?php ob_start(); ?>
@@ -949,21 +949,21 @@  discard block
 block discarded – undo
949 949
                             <label for="checkbox_<?php echo $i ?>">&nbsp;</label>
950 950
                         </p>
951 951
                 <?php
952
-                $return['data'][$i][] = ob_get_contents();
953
-                ob_end_clean();
954
-                ?>
952
+				$return['data'][$i][] = ob_get_contents();
953
+				ob_end_clean();
954
+				?>
955 955
 
956 956
                 <?php ob_start(); ?>
957 957
                         <span class=""><?php echo $file_info['path'] ?></span>
958 958
                         <?php if (!$file_exists_on_local_storage): ?>
959 959
                             <a href="#"
960 960
                                title="<?php echo __("File does not exists on local storage",
961
-                                   "xcloner-backup-and-restore") ?>"><i
961
+								   "xcloner-backup-and-restore") ?>"><i
962 962
                                         class="material-icons backup_warning">warning</i></a>
963 963
                         <?php endif ?>
964 964
                         <?php
965
-                        if (isset($file_info['childs']) and is_array($file_info['childs'])):
966
-                            ?>
965
+						if (isset($file_info['childs']) and is_array($file_info['childs'])):
966
+							?>
967 967
                             <a href="#" title="expand" class="expand-multipart add"><i
968 968
                                         class="material-icons">add</i></a>
969 969
                             <a href="#" title="collapse" class="expand-multipart remove"><i class="material-icons">remove</i></a>
@@ -972,17 +972,17 @@  discard block
 block discarded – undo
972 972
                                     <li>
973 973
                                         <?php echo $child[0] ?> (<?php echo size_format($child[2]) ?>)
974 974
                                         <?php
975
-                                        $child_exists_on_local_storage = true;
976
-                                        if ($storage_selection) {
977
-                                            if (!$this->xcloner_file_system->get_storage_filesystem()->has($child[0])) {
978
-                                                $child_exists_on_local_storage = false;
979
-                                            }
980
-                                        }
981
-                                        ?>
975
+										$child_exists_on_local_storage = true;
976
+										if ($storage_selection) {
977
+											if (!$this->xcloner_file_system->get_storage_filesystem()->has($child[0])) {
978
+												$child_exists_on_local_storage = false;
979
+											}
980
+										}
981
+										?>
982 982
                                         <?php if (!$child_exists_on_local_storage): ?>
983 983
                                             <a href="#"
984 984
                                                title="<?php echo __("File does not exists on local storage",
985
-                                                   "xcloner-backup-and-restore") ?>"><i
985
+												   "xcloner-backup-and-restore") ?>"><i
986 986
                                                         class="material-icons backup_warning">warning</i></a>
987 987
                                         <?php endif ?>
988 988
                                         <?php if (!$storage_selection) : ?>
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
                                             <?php else: ?>
998 998
                                                 <a href="#<?php echo $child[0] ?>" class="list-backup-content"
999 999
                                                    title="<?php echo __('List Backup Content',
1000
-                                                       'xcloner-backup-and-restore') ?>"><i
1000
+													   'xcloner-backup-and-restore') ?>"><i
1001 1001
                                                             class="material-icons">folder_open</i></a>
1002 1002
 
1003 1003
                                                 <a href="#<?php echo $child[0] ?>" class="backup-encryption"
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
                                         <?php elseif ($storage_selection != "gdrive" && !$this->xcloner_file_system->get_storage_filesystem()->has($child[0])): ?>
1010 1010
                                             <a href="#<?php echo $child[0] ?>" class="copy-remote-to-local"
1011 1011
                                                title="<?php echo __('Push Backup To Local Storage',
1012
-                                                   'xcloner-backup-and-restore') ?>"><i
1012
+												   'xcloner-backup-and-restore') ?>"><i
1013 1013
                                                         class="material-icons">file_upload</i></a>
1014 1014
                                         <?php endif ?>
1015 1015
                                     </li>
@@ -1017,24 +1017,24 @@  discard block
 block discarded – undo
1017 1017
                             </ul>
1018 1018
                         <?php endif; ?>
1019 1019
                 <?php
1020
-                $return['data'][$i][] = ob_get_contents();
1021
-                ob_end_clean();
1022
-                ?>
1020
+				$return['data'][$i][] = ob_get_contents();
1021
+				ob_end_clean();
1022
+				?>
1023 1023
                     <?php ob_start(); ?>
1024 1024
                         <?php if (isset($file_info['timestamp']))
1025
-                            echo date("Y-m-d H:i", $file_info['timestamp'])
1026
-                        ?>
1025
+							echo date("Y-m-d H:i", $file_info['timestamp'])
1026
+						?>
1027 1027
                     <?php
1028
-                        $return['data'][$i][] = ob_get_contents();
1029
-                        ob_end_clean();
1030
-                        ?>
1028
+						$return['data'][$i][] = ob_get_contents();
1029
+						ob_end_clean();
1030
+						?>
1031 1031
 
1032 1032
                     <?php ob_start(); ?>
1033 1033
                         <?php echo size_format($file_info['size']) ?>
1034 1034
                     <?php
1035
-                        $return['data'][$i][] = ob_get_contents();
1036
-                        ob_end_clean();
1037
-                    ?>
1035
+						$return['data'][$i][] = ob_get_contents();
1036
+						ob_end_clean();
1037
+					?>
1038 1038
 
1039 1039
                     <?php ob_start(); ?>
1040 1040
                         <?php if (!$storage_selection): ?>
@@ -1045,14 +1045,14 @@  discard block
 block discarded – undo
1045 1045
                             <?php if (sizeof($available_storages)): ?>
1046 1046
                                 <a href="#<?php echo $file_info['basename'] ?>" class="cloud-upload"
1047 1047
                                    title="<?php echo __('Send Backup To Remote Storage',
1048
-                                       'xcloner-backup-and-restore') ?>"><i
1048
+									   'xcloner-backup-and-restore') ?>"><i
1049 1049
                                             class="material-icons">cloud_upload</i></a>
1050 1050
                             <?php endif ?>
1051 1051
                             <?php
1052
-                            $basename = $file_info['basename'];
1053
-                            if(isset($file_info['childs']) and sizeof($file_info['childs']))
1054
-                                $basename = $file_info['childs'][0][0];
1055
-                            ?>
1052
+							$basename = $file_info['basename'];
1053
+							if(isset($file_info['childs']) and sizeof($file_info['childs']))
1054
+								$basename = $file_info['childs'][0][0];
1055
+							?>
1056 1056
                             <?php if($this->xcloner_encryption->is_encrypted_file($basename)) :?>
1057 1057
                                 <a href="#<?php echo $file_info['basename'] ?>" class="backup-decryption"
1058 1058
                                    title="<?php echo __('Backup Decryption', 'xcloner-backup-and-restore') ?>">
@@ -1081,193 +1081,193 @@  discard block
 block discarded – undo
1081 1081
                         <?php endif ?>
1082 1082
 
1083 1083
                     <?php
1084
-                        $return['data'][$i][] = ob_get_contents();
1085
-                        ob_end_clean(); ?>
1084
+						$return['data'][$i][] = ob_get_contents();
1085
+						ob_end_clean(); ?>
1086 1086
 
1087 1087
             <?php endif ?>
1088 1088
         <?php endforeach ?>
1089 1089
     <?php
1090
-        $this->send_response($return, 0);
1091
-    }
1092
-
1093
-    /**
1094
-     * API method to list internal backup files
1095
-     */
1096
-    public function list_backup_files()
1097
-    {
1098
-        $this->check_access();
1099
-
1100
-        $backup_parts = array();
1101
-
1102
-        $source_backup_file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
1103
-        $start = $this->xcloner_sanitization->sanitize_input_as_int($_POST['start']);
1104
-        $return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
1105
-
1106
-        $backup_file = $source_backup_file;
1107
-
1108
-        if ($this->xcloner_file_system->is_multipart($backup_file)) {
1109
-            $backup_parts = $this->xcloner_file_system->get_multipart_files($backup_file);
1110
-            $backup_file = $backup_parts[$return['part']];
1111
-        }
1112
-
1113
-        if($this->xcloner_encryption->is_encrypted_file($backup_file)) {
1114
-            $return['error'] = true;
1115
-            $return['message'] = __("Backup archive is encrypted, please decrypt it first before you can list it's content.", "xcloner-backup-and-restore");
1116
-            $this->send_response($return, 0);
1117
-        }
1118
-
1119
-        try {
1120
-            $tar = new Tar();
1121
-            $tar->open($this->xcloner_settings->get_xcloner_store_path() . DS . $backup_file, $start);
1122
-
1123
-            $data = $tar->contents(get_option('xcloner_files_to_process_per_request'));
1124
-        } catch (Exception $e) {
1125
-            $return['error'] = true;
1126
-            $return['message'] = $e->getMessage();
1127
-            $this->send_response($return, 0);
1128
-        }
1129
-
1130
-        $return['files'] = array();
1131
-        $return['finished'] = 1;
1132
-        $return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path() . DS . $backup_file);
1133
-        $i = 0;
1134
-
1135
-        if (isset($data['extracted_files']) and is_array($data['extracted_files'])) {
1136
-            foreach ($data['extracted_files'] as $file) {
1137
-                $return['files'][$i]['path'] = $file->getPath();
1138
-                $return['files'][$i]['size'] = $file->getSize();
1139
-                $return['files'][$i]['mtime'] = date(get_option('date_format') . " " . get_option('time_format'),
1140
-                    $file->getMtime());
1141
-
1142
-                $i++;
1143
-            }
1144
-        }
1145
-
1146
-        if (isset($data['start'])) {
1147
-            $return['start'] = $data['start'];
1148
-            $return['finished'] = 0;
1149
-        } else {
1150
-            if ($this->xcloner_file_system->is_multipart($source_backup_file)) {
1151
-                $return['start'] = 0;
1152
-
1153
-                ++$return['part'];
1154
-
1155
-                if ($return['part'] < sizeof($backup_parts)) {
1156
-                    $return['finished'] = 0;
1157
-                }
1158
-
1159
-            }
1160
-        }
1161
-
1162
-        $this->send_response($return, 0);
1163
-    }
1164
-
1165
-    /*
1090
+		$this->send_response($return, 0);
1091
+	}
1092
+
1093
+	/**
1094
+	 * API method to list internal backup files
1095
+	 */
1096
+	public function list_backup_files()
1097
+	{
1098
+		$this->check_access();
1099
+
1100
+		$backup_parts = array();
1101
+
1102
+		$source_backup_file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
1103
+		$start = $this->xcloner_sanitization->sanitize_input_as_int($_POST['start']);
1104
+		$return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
1105
+
1106
+		$backup_file = $source_backup_file;
1107
+
1108
+		if ($this->xcloner_file_system->is_multipart($backup_file)) {
1109
+			$backup_parts = $this->xcloner_file_system->get_multipart_files($backup_file);
1110
+			$backup_file = $backup_parts[$return['part']];
1111
+		}
1112
+
1113
+		if($this->xcloner_encryption->is_encrypted_file($backup_file)) {
1114
+			$return['error'] = true;
1115
+			$return['message'] = __("Backup archive is encrypted, please decrypt it first before you can list it's content.", "xcloner-backup-and-restore");
1116
+			$this->send_response($return, 0);
1117
+		}
1118
+
1119
+		try {
1120
+			$tar = new Tar();
1121
+			$tar->open($this->xcloner_settings->get_xcloner_store_path() . DS . $backup_file, $start);
1122
+
1123
+			$data = $tar->contents(get_option('xcloner_files_to_process_per_request'));
1124
+		} catch (Exception $e) {
1125
+			$return['error'] = true;
1126
+			$return['message'] = $e->getMessage();
1127
+			$this->send_response($return, 0);
1128
+		}
1129
+
1130
+		$return['files'] = array();
1131
+		$return['finished'] = 1;
1132
+		$return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path() . DS . $backup_file);
1133
+		$i = 0;
1134
+
1135
+		if (isset($data['extracted_files']) and is_array($data['extracted_files'])) {
1136
+			foreach ($data['extracted_files'] as $file) {
1137
+				$return['files'][$i]['path'] = $file->getPath();
1138
+				$return['files'][$i]['size'] = $file->getSize();
1139
+				$return['files'][$i]['mtime'] = date(get_option('date_format') . " " . get_option('time_format'),
1140
+					$file->getMtime());
1141
+
1142
+				$i++;
1143
+			}
1144
+		}
1145
+
1146
+		if (isset($data['start'])) {
1147
+			$return['start'] = $data['start'];
1148
+			$return['finished'] = 0;
1149
+		} else {
1150
+			if ($this->xcloner_file_system->is_multipart($source_backup_file)) {
1151
+				$return['start'] = 0;
1152
+
1153
+				++$return['part'];
1154
+
1155
+				if ($return['part'] < sizeof($backup_parts)) {
1156
+					$return['finished'] = 0;
1157
+				}
1158
+
1159
+			}
1160
+		}
1161
+
1162
+		$this->send_response($return, 0);
1163
+	}
1164
+
1165
+	/*
1166 1166
      * Copy remote backup to local storage
1167 1167
      */
1168
-    public function copy_backup_remote_to_local()
1169
-    {
1168
+	public function copy_backup_remote_to_local()
1169
+	{
1170 1170
 
1171
-        $this->check_access();
1171
+		$this->check_access();
1172 1172
 
1173
-        $backup_file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
1174
-        $storage_type = $this->xcloner_sanitization->sanitize_input_as_string($_POST['storage_type']);
1173
+		$backup_file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
1174
+		$storage_type = $this->xcloner_sanitization->sanitize_input_as_string($_POST['storage_type']);
1175 1175
 
1176
-        $xcloner_remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage();
1176
+		$xcloner_remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage();
1177 1177
 
1178
-        $return = array();
1178
+		$return = array();
1179 1179
 
1180
-        try {
1181
-            if (method_exists($xcloner_remote_storage, "copy_backup_remote_to_local")) {
1182
-                $return = call_user_func_array(array(
1183
-                    $xcloner_remote_storage,
1184
-                    "copy_backup_remote_to_local"
1185
-                ), array($backup_file, $storage_type));
1186
-            }
1187
-        } catch (Exception $e) {
1180
+		try {
1181
+			if (method_exists($xcloner_remote_storage, "copy_backup_remote_to_local")) {
1182
+				$return = call_user_func_array(array(
1183
+					$xcloner_remote_storage,
1184
+					"copy_backup_remote_to_local"
1185
+				), array($backup_file, $storage_type));
1186
+			}
1187
+		} catch (Exception $e) {
1188 1188
 
1189
-            $return['error'] = 1;
1190
-            $return['message'] = $e->getMessage();
1191
-        }
1189
+			$return['error'] = 1;
1190
+			$return['message'] = $e->getMessage();
1191
+		}
1192 1192
 
1193
-        if (!$return) {
1194
-            $return['error'] = 1;
1195
-            $return['message'] = "Upload failed, please check the error log for more information!";
1196
-        }
1193
+		if (!$return) {
1194
+			$return['error'] = 1;
1195
+			$return['message'] = "Upload failed, please check the error log for more information!";
1196
+		}
1197 1197
 
1198 1198
 
1199
-        $this->send_response($return, 0);
1199
+		$this->send_response($return, 0);
1200 1200
 
1201
-    }
1201
+	}
1202 1202
 
1203
-    /*
1203
+	/*
1204 1204
      *
1205 1205
      * Upload backup to remote API
1206 1206
      *
1207 1207
      */
1208
-    public function upload_backup_to_remote()
1209
-    {
1210
-        $this->check_access();
1208
+	public function upload_backup_to_remote()
1209
+	{
1210
+		$this->check_access();
1211 1211
 
1212
-        $backup_file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
1213
-        $storage_type = $this->xcloner_sanitization->sanitize_input_as_string($_POST['storage_type']);
1212
+		$backup_file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
1213
+		$storage_type = $this->xcloner_sanitization->sanitize_input_as_string($_POST['storage_type']);
1214 1214
 
1215
-        $xcloner_remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage();
1215
+		$xcloner_remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage();
1216 1216
 
1217
-        $return = array();
1217
+		$return = array();
1218 1218
 
1219
-        try {
1220
-            if (method_exists($xcloner_remote_storage, "upload_backup_to_storage")) {
1221
-                $return = call_user_func_array(array(
1222
-                    $xcloner_remote_storage,
1223
-                    "upload_backup_to_storage"
1224
-                ), array($backup_file, $storage_type));
1225
-            }
1226
-        } catch (Exception $e) {
1219
+		try {
1220
+			if (method_exists($xcloner_remote_storage, "upload_backup_to_storage")) {
1221
+				$return = call_user_func_array(array(
1222
+					$xcloner_remote_storage,
1223
+					"upload_backup_to_storage"
1224
+				), array($backup_file, $storage_type));
1225
+			}
1226
+		} catch (Exception $e) {
1227 1227
 
1228
-            $return['error'] = 1;
1229
-            $return['message'] = $e->getMessage();
1230
-        }
1228
+			$return['error'] = 1;
1229
+			$return['message'] = $e->getMessage();
1230
+		}
1231 1231
 
1232
-        if (!$return) {
1233
-            $return['error'] = 1;
1234
-            $return['message'] = "Upload failed, please check the error log for more information!";
1235
-        }
1232
+		if (!$return) {
1233
+			$return['error'] = 1;
1234
+			$return['message'] = "Upload failed, please check the error log for more information!";
1235
+		}
1236 1236
 
1237 1237
 
1238
-        $this->send_response($return, 0);
1238
+		$this->send_response($return, 0);
1239 1239
 
1240
-    }
1240
+	}
1241 1241
 
1242
-    /*
1242
+	/*
1243 1243
      *
1244 1244
      * Remote Storage Status Save
1245 1245
      *
1246 1246
      */
1247
-    public function remote_storage_save_status()
1248
-    {
1249
-        $this->check_access();
1247
+	public function remote_storage_save_status()
1248
+	{
1249
+		$this->check_access();
1250 1250
 
1251
-        $xcloner_remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage();
1251
+		$xcloner_remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage();
1252 1252
 
1253
-        $return['finished'] = $xcloner_remote_storage->change_storage_status($_POST['id'], $_POST['value']);
1253
+		$return['finished'] = $xcloner_remote_storage->change_storage_status($_POST['id'], $_POST['value']);
1254 1254
 
1255
-        $this->send_response($return, 0);
1256
-    }
1255
+		$this->send_response($return, 0);
1256
+	}
1257 1257
 
1258 1258
 
1259
-    public function download_restore_script()
1260
-    {
1261
-        $this->check_access();
1259
+	public function download_restore_script()
1260
+	{
1261
+		$this->check_access();
1262 1262
 
1263
-        @ob_end_clean();
1263
+		@ob_end_clean();
1264 1264
 
1265
-        $adapter = new Local(dirname(__DIR__), LOCK_EX, 'SKIP_LINKS');
1266
-        $xcloner_plugin_filesystem = new Filesystem($adapter, new Config([
1267
-            'disable_asserts' => true,
1268
-        ]));
1265
+		$adapter = new Local(dirname(__DIR__), LOCK_EX, 'SKIP_LINKS');
1266
+		$xcloner_plugin_filesystem = new Filesystem($adapter, new Config([
1267
+			'disable_asserts' => true,
1268
+		]));
1269 1269
 
1270
-        /* Generate PHAR FILE
1270
+		/* Generate PHAR FILE
1271 1271
         $file = 'restore/vendor.built';
1272 1272
 
1273 1273
         if(file_exists($file))
@@ -1283,178 +1283,178 @@  discard block
 block discarded – undo
1283 1283
         $phar2->setStub($phar2->createDefaultStub('vendor/autoload.php', 'vendor/autoload.php'));
1284 1284
          * */
1285 1285
 
1286
-        $tmp_file = $this->xcloner_settings->get_xcloner_tmp_path() . DS . "xcloner-restore.tgz";
1286
+		$tmp_file = $this->xcloner_settings->get_xcloner_tmp_path() . DS . "xcloner-restore.tgz";
1287 1287
 
1288
-        $tar = new Tar();
1289
-        $tar->create($tmp_file);
1288
+		$tar = new Tar();
1289
+		$tar->create($tmp_file);
1290 1290
 
1291
-        $tar->addFile(dirname(__DIR__) . "/restore/vendor.build.txt", "vendor.phar");
1292
-        //$tar->addFile(dirname(__DIR__)."/restore/vendor.tgz", "vendor.tgz");
1291
+		$tar->addFile(dirname(__DIR__) . "/restore/vendor.build.txt", "vendor.phar");
1292
+		//$tar->addFile(dirname(__DIR__)."/restore/vendor.tgz", "vendor.tgz");
1293 1293
 
1294
-        $files = $xcloner_plugin_filesystem->listContents("vendor/", true);
1295
-        foreach ($files as $file) {
1296
-            $tar->addFile(dirname(__DIR__) . DS . $file['path'], $file['path']);
1297
-        }
1294
+		$files = $xcloner_plugin_filesystem->listContents("vendor/", true);
1295
+		foreach ($files as $file) {
1296
+			$tar->addFile(dirname(__DIR__) . DS . $file['path'], $file['path']);
1297
+		}
1298 1298
 
1299
-        $content = file_get_contents(dirname(__DIR__) . "/restore/xcloner_restore.php");
1300
-        $content = str_replace("define('AUTH_KEY', '');", "define('AUTH_KEY', '" . md5(AUTH_KEY) . "');", $content);
1299
+		$content = file_get_contents(dirname(__DIR__) . "/restore/xcloner_restore.php");
1300
+		$content = str_replace("define('AUTH_KEY', '');", "define('AUTH_KEY', '" . md5(AUTH_KEY) . "');", $content);
1301 1301
 
1302
-        $tar->addData("xcloner_restore.php", $content);
1302
+		$tar->addData("xcloner_restore.php", $content);
1303 1303
 
1304
-        $tar->close();
1304
+		$tar->close();
1305 1305
 
1306
-        if (file_exists($tmp_file)) {
1307
-            header('Content-Description: File Transfer');
1308
-            header('Content-Type: application/octet-stream');
1309
-            header('Content-Disposition: attachment; filename="' . basename($tmp_file) . '"');
1310
-            header('Expires: 0');
1311
-            header('Cache-Control: must-revalidate');
1312
-            header('Pragma: public');
1313
-            header('Content-Length: ' . filesize($tmp_file));
1314
-            readfile($tmp_file);
1306
+		if (file_exists($tmp_file)) {
1307
+			header('Content-Description: File Transfer');
1308
+			header('Content-Type: application/octet-stream');
1309
+			header('Content-Disposition: attachment; filename="' . basename($tmp_file) . '"');
1310
+			header('Expires: 0');
1311
+			header('Cache-Control: must-revalidate');
1312
+			header('Pragma: public');
1313
+			header('Content-Length: ' . filesize($tmp_file));
1314
+			readfile($tmp_file);
1315 1315
 
1316
-        }
1316
+		}
1317 1317
 
1318
-        @unlink($tmp_file);
1319
-        exit;
1320
-    }
1318
+		@unlink($tmp_file);
1319
+		exit;
1320
+	}
1321 1321
 
1322
-    /*
1322
+	/*
1323 1323
      *
1324 1324
      * Download backup by Name from the Storage Path
1325 1325
      *
1326 1326
      */
1327
-    public function download_backup_by_name()
1328
-    {
1329
-        $this->check_access();
1327
+	public function download_backup_by_name()
1328
+	{
1329
+		$this->check_access();
1330 1330
 
1331
-        @ob_end_clean();
1331
+		@ob_end_clean();
1332 1332
 
1333
-        $backup_name = $this->xcloner_sanitization->sanitize_input_as_string($_GET['name']);
1333
+		$backup_name = $this->xcloner_sanitization->sanitize_input_as_string($_GET['name']);
1334 1334
 
1335 1335
 
1336
-        $metadata = $this->xcloner_file_system->get_storage_filesystem()->getMetadata($backup_name);
1337
-        $read_stream = $this->xcloner_file_system->get_storage_filesystem()->readStream($backup_name);
1336
+		$metadata = $this->xcloner_file_system->get_storage_filesystem()->getMetadata($backup_name);
1337
+		$read_stream = $this->xcloner_file_system->get_storage_filesystem()->readStream($backup_name);
1338 1338
 
1339 1339
 
1340
-        header('Pragma: public');
1341
-        header('Expires: 0');
1342
-        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
1343
-        header('Cache-Control: private', false);
1344
-        header('Content-Transfer-Encoding: binary');
1345
-        header('Content-Disposition: attachment; filename="' . $metadata['path'] . '";');
1346
-        header('Content-Type: application/octet-stream');
1347
-        header('Content-Length: ' . $metadata['size']);
1340
+		header('Pragma: public');
1341
+		header('Expires: 0');
1342
+		header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
1343
+		header('Cache-Control: private', false);
1344
+		header('Content-Transfer-Encoding: binary');
1345
+		header('Content-Disposition: attachment; filename="' . $metadata['path'] . '";');
1346
+		header('Content-Type: application/octet-stream');
1347
+		header('Content-Length: ' . $metadata['size']);
1348 1348
 
1349
-        @ob_end_clean();
1349
+		@ob_end_clean();
1350 1350
 
1351
-        $chunkSize = 1024 * 1024;
1352
-        while (!feof($read_stream)) {
1353
-            $buffer = fread($read_stream, $chunkSize);
1354
-            echo $buffer;
1355
-        }
1356
-        fclose($read_stream);
1357
-        exit;
1351
+		$chunkSize = 1024 * 1024;
1352
+		while (!feof($read_stream)) {
1353
+			$buffer = fread($read_stream, $chunkSize);
1354
+			echo $buffer;
1355
+		}
1356
+		fclose($read_stream);
1357
+		exit;
1358 1358
 
1359
-    }
1359
+	}
1360 1360
 
1361
-    /*
1361
+	/*
1362 1362
      * Restore upload backup
1363 1363
      */
1364
-    public function restore_upload_backup()
1365
-    {
1366
-        $this->check_access();
1364
+	public function restore_upload_backup()
1365
+	{
1366
+		$this->check_access();
1367 1367
 
1368
-        $return['part'] = 0;
1369
-        $return['total_parts'] = 0;
1370
-        $return['uploaded_size'] = 0;
1371
-        $is_multipart = 0;
1368
+		$return['part'] = 0;
1369
+		$return['total_parts'] = 0;
1370
+		$return['uploaded_size'] = 0;
1371
+		$is_multipart = 0;
1372 1372
 
1373
-        $file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
1374
-        $hash = $this->xcloner_sanitization->sanitize_input_as_string($_POST['hash']);
1373
+		$file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
1374
+		$hash = $this->xcloner_sanitization->sanitize_input_as_string($_POST['hash']);
1375 1375
 
1376
-        if (isset($_POST['part'])) {
1377
-            $return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
1378
-        }
1376
+		if (isset($_POST['part'])) {
1377
+			$return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
1378
+		}
1379 1379
 
1380
-        if (isset($_POST['uploaded_size'])) {
1381
-            $return['uploaded_size'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['uploaded_size']);
1382
-        }
1380
+		if (isset($_POST['uploaded_size'])) {
1381
+			$return['uploaded_size'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['uploaded_size']);
1382
+		}
1383 1383
 
1384
-        $start = $this->xcloner_sanitization->sanitize_input_as_string($_POST['start']);
1385
-        $target_url = $this->xcloner_sanitization->sanitize_input_as_string($_POST['target_url']);
1384
+		$start = $this->xcloner_sanitization->sanitize_input_as_string($_POST['start']);
1385
+		$target_url = $this->xcloner_sanitization->sanitize_input_as_string($_POST['target_url']);
1386 1386
 
1387
-        $return['total_size'] = $this->xcloner_file_system->get_backup_size($file);
1387
+		$return['total_size'] = $this->xcloner_file_system->get_backup_size($file);
1388 1388
 
1389
-        if ($this->xcloner_file_system->is_multipart($file)) {
1390
-            $backup_parts = $this->xcloner_file_system->get_multipart_files($file);
1389
+		if ($this->xcloner_file_system->is_multipart($file)) {
1390
+			$backup_parts = $this->xcloner_file_system->get_multipart_files($file);
1391 1391
 
1392
-            $return['total_parts'] = sizeof($backup_parts) + 1;
1392
+			$return['total_parts'] = sizeof($backup_parts) + 1;
1393 1393
 
1394
-            if ($return['part'] and isset($backup_parts[$return['part'] - 1])) {
1395
-                $file = $backup_parts[$return['part'] - 1];
1396
-            }
1394
+			if ($return['part'] and isset($backup_parts[$return['part'] - 1])) {
1395
+				$file = $backup_parts[$return['part'] - 1];
1396
+			}
1397 1397
 
1398
-            $is_multipart = 1;
1399
-        }
1398
+			$is_multipart = 1;
1399
+		}
1400 1400
 
1401
-        try {
1401
+		try {
1402 1402
 
1403
-            $xcloner_file_transfer = $this->get_xcloner_container()->get_xcloner_file_transfer();
1404
-            $xcloner_file_transfer->set_target($target_url);
1405
-            $return['start'] = $xcloner_file_transfer->transfer_file($file, $start, $hash);
1403
+			$xcloner_file_transfer = $this->get_xcloner_container()->get_xcloner_file_transfer();
1404
+			$xcloner_file_transfer->set_target($target_url);
1405
+			$return['start'] = $xcloner_file_transfer->transfer_file($file, $start, $hash);
1406 1406
 
1407
-        } catch (Exception $e) {
1407
+		} catch (Exception $e) {
1408 1408
 
1409
-            $return = array();
1410
-            $return['error'] = true;
1411
-            $return['status'] = 500;
1412
-            $return['message'] = "CURL communication error with the restore host. " . $e->getMessage();
1413
-            $this->send_response($return, 0);
1409
+			$return = array();
1410
+			$return['error'] = true;
1411
+			$return['status'] = 500;
1412
+			$return['message'] = "CURL communication error with the restore host. " . $e->getMessage();
1413
+			$this->send_response($return, 0);
1414 1414
 
1415
-        }
1415
+		}
1416 1416
 
1417
-        $return['status'] = 200;
1417
+		$return['status'] = 200;
1418 1418
 
1419
-        //we have finished the upload
1420
-        if (!$return['start'] and $is_multipart) {
1421
-            $return['part']++;
1422
-            $return['uploaded_size'] += $this->xcloner_file_system->get_storage_filesystem()->getSize($file);
1423
-        }
1419
+		//we have finished the upload
1420
+		if (!$return['start'] and $is_multipart) {
1421
+			$return['part']++;
1422
+			$return['uploaded_size'] += $this->xcloner_file_system->get_storage_filesystem()->getSize($file);
1423
+		}
1424 1424
 
1425
-        $this->send_response($return, 0);
1426
-    }
1425
+		$this->send_response($return, 0);
1426
+	}
1427 1427
 
1428
-    /*
1428
+	/*
1429 1429
      * Restore backup
1430 1430
      */
1431
-    public function restore_backup()
1432
-    {
1433
-        $this->check_access();
1431
+	public function restore_backup()
1432
+	{
1433
+		$this->check_access();
1434 1434
 
1435
-        define("XCLONER_PLUGIN_ACCESS", 1);
1436
-        include_once(dirname(__DIR__) . DS . "restore" . DS . "xcloner_restore.php");
1435
+		define("XCLONER_PLUGIN_ACCESS", 1);
1436
+		include_once(dirname(__DIR__) . DS . "restore" . DS . "xcloner_restore.php");
1437 1437
 
1438
-        return;
1439
-    }
1438
+		return;
1439
+	}
1440 1440
 
1441
-    /*
1441
+	/*
1442 1442
      *
1443 1443
      * Send the json response back
1444 1444
      *
1445 1445
      */
1446
-    private function send_response($data, $attach_hash = 1)
1447
-    {
1446
+	private function send_response($data, $attach_hash = 1)
1447
+	{
1448 1448
 
1449
-        if ($attach_hash and null !== $this->xcloner_settings->get_hash()) {
1450
-            $data['hash'] = $this->xcloner_settings->get_hash();
1451
-        }
1449
+		if ($attach_hash and null !== $this->xcloner_settings->get_hash()) {
1450
+			$data['hash'] = $this->xcloner_settings->get_hash();
1451
+		}
1452 1452
 
1453
-        if (ob_get_length()) {
1454
-            ob_clean();
1455
-        }
1456
-        wp_send_json($data);
1453
+		if (ob_get_length()) {
1454
+			ob_clean();
1455
+		}
1456
+		wp_send_json($data);
1457 1457
 
1458
-        die();
1459
-    }
1458
+		die();
1459
+	}
1460 1460
 }
Please login to merge, or discard this patch.