InfiniteWP Client - Version 1.3.5

Version Description

  • Improvement: Support for iThemes Security Pro.
  • Fix: IWP's PCLZIP clash with other plugins.
Download this release

Release Info

Developer infinitewp
Plugin Icon 128x128 InfiniteWP Client
Version 1.3.5
Comparing to
See all releases

Code changes from version 1.3.4 to 1.3.5

Files changed (5) hide show
  1. backup.class.multicall.php +4 -5
  2. backup.class.singlecall.php +2 -1
  3. core.class.php +5 -1
  4. init.php +1785 -1774
  5. readme.txt +6 -1
backup.class.multicall.php CHANGED
@@ -28,10 +28,6 @@ if(!defined('PCLZIP_TEMPORARY_DIR')){
28
  define('PCLZIP_TEMPORARY_DIR', WP_CONTENT_DIR . '/infinitewp/temp/');
29
  }
30
 
31
- //require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.split.php';
32
- require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
33
-
34
-
35
 
36
  $zip_errors = array(
37
  'No error',
@@ -90,7 +86,10 @@ class IWP_MMB_Backup_Multicall extends IWP_MMB_Core
90
  var $iwpScriptStartTime;
91
  function __construct()
92
  {
93
- parent::__construct();
 
 
 
94
  $this->site_name = str_replace(array(
95
  "_",
96
  "/",
28
  define('PCLZIP_TEMPORARY_DIR', WP_CONTENT_DIR . '/infinitewp/temp/');
29
  }
30
 
 
 
 
 
31
 
32
  $zip_errors = array(
33
  'No error',
86
  var $iwpScriptStartTime;
87
  function __construct()
88
  {
89
+
90
+ //require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.split.php';
91
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
92
+ parent::__construct();
93
  $this->site_name = str_replace(array(
94
  "_",
95
  "/",
backup.class.singlecall.php CHANGED
@@ -81,7 +81,8 @@ class IWP_MMB_Backup_Singlecall extends IWP_MMB_Core
81
  var $dropbox;
82
  function __construct()
83
  {
84
- parent::__construct();
 
85
  $this->site_name = str_replace(array(
86
  "_",
87
  "/",
81
  var $dropbox;
82
  function __construct()
83
  {
84
+ require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
85
+ parent::__construct();
86
  $this->site_name = str_replace(array(
87
  "_",
88
  "/",
core.class.php CHANGED
@@ -557,6 +557,8 @@ class IWP_MMB_Core extends IWP_MMB_Helper
557
  */
558
  function get_backup_instance($mechanism='')
559
  {
 
 
560
  //$mechanism = 'multiCall';
561
  if (!isset($this->backup_instance)) {
562
  if($mechanism == 'singleCall' || $mechanism == ''){
@@ -576,7 +578,9 @@ class IWP_MMB_Core extends IWP_MMB_Helper
576
 
577
  function get_backup_repository_instance()
578
  {
579
- if (!isset($this->backup_repository_instance)) {
 
 
580
  $this->backup_repository_instance = new IWP_MMB_Backup_Repository();
581
  }
582
 
557
  */
558
  function get_backup_instance($mechanism='')
559
  {
560
+ require_once($GLOBALS['iwp_mmb_plugin_dir']."/backup.class.singlecall.php");
561
+ require_once($GLOBALS['iwp_mmb_plugin_dir']."/backup.class.multicall.php");
562
  //$mechanism = 'multiCall';
563
  if (!isset($this->backup_instance)) {
564
  if($mechanism == 'singleCall' || $mechanism == ''){
578
 
579
  function get_backup_repository_instance()
580
  {
581
+ require_once($GLOBALS['iwp_mmb_plugin_dir']."/backup.class.singlecall.php");
582
+ require_once($GLOBALS['iwp_mmb_plugin_dir']."/backup.class.multicall.php");
583
+ if (!isset($this->backup_repository_instance)) {
584
  $this->backup_repository_instance = new IWP_MMB_Backup_Repository();
585
  }
586
 
init.php CHANGED
@@ -1,1775 +1,1786 @@
1
- <?php
2
- /*
3
- Plugin Name: InfiniteWP - Client
4
- Plugin URI: http://infinitewp.com/
5
- Description: This is the client plugin of InfiniteWP that communicates with the InfiniteWP Admin panel.
6
- Author: Revmakx
7
- Version: 1.3.4
8
- Author URI: http://www.revmakx.com
9
- */
10
- /************************************************************
11
- * This plugin was modified by Revmakx *
12
- * Copyright (c) 2012 Revmakx *
13
- * www.revmakx.com *
14
- * *
15
- ************************************************************/
16
-
17
- /*************************************************************
18
- *
19
- * init.php
20
- *
21
- * Initialize the communication with master
22
- *
23
- *
24
- * Copyright (c) 2011 Prelovac Media
25
- * www.prelovac.com
26
- **************************************************************/
27
-
28
- if(!defined('IWP_MMB_CLIENT_VERSION'))
29
- define('IWP_MMB_CLIENT_VERSION', '1.3.4');
30
-
31
-
32
-
33
- if ( !defined('IWP_MMB_XFRAME_COOKIE')){
34
- $siteurl = function_exists('get_site_option') ? get_site_option( 'siteurl' ) : get_option('siteurl');
35
- define('IWP_MMB_XFRAME_COOKIE', $xframe = 'wordpress_'.md5($siteurl).'_xframe');
36
- }
37
- global $wpdb, $iwp_mmb_plugin_dir, $iwp_mmb_plugin_url, $wp_version, $iwp_mmb_filters, $_iwp_mmb_item_filter;
38
- if (version_compare(PHP_VERSION, '5.0.0', '<')) // min version 5 supported
39
- exit("<p>InfiniteWP Client plugin requires PHP 5 or higher.</p>");
40
-
41
-
42
- $iwp_mmb_wp_version = $wp_version;
43
- $iwp_mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
44
- $iwp_mmb_plugin_url = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__));
45
-
46
- require_once("$iwp_mmb_plugin_dir/helper.class.php");
47
- require_once("$iwp_mmb_plugin_dir/core.class.php");
48
- require_once("$iwp_mmb_plugin_dir/stats.class.php");
49
- //require_once("$iwp_mmb_plugin_dir/backup.class.php");
50
- require_once("$iwp_mmb_plugin_dir/backup.class.singlecall.php");
51
- require_once("$iwp_mmb_plugin_dir/backup.class.multicall.php");
52
- require_once("$iwp_mmb_plugin_dir/installer.class.php");
53
-
54
- require_once("$iwp_mmb_plugin_dir/addons/manage_users/user.class.php");
55
- require_once("$iwp_mmb_plugin_dir/addons/backup_repository/backup_repository.class.php");
56
- require_once("$iwp_mmb_plugin_dir/addons/comments/comments.class.php");
57
-
58
- require_once("$iwp_mmb_plugin_dir/addons/post_links/link.class.php");
59
- require_once("$iwp_mmb_plugin_dir/addons/post_links/post.class.php");
60
-
61
- require_once("$iwp_mmb_plugin_dir/addons/wp_optimize/optimize.class.php");
62
-
63
- require_once("$iwp_mmb_plugin_dir/api.php");
64
- require_once("$iwp_mmb_plugin_dir/plugins/search/search.php");
65
- require_once("$iwp_mmb_plugin_dir/plugins/cleanup/cleanup.php");
66
-
67
-
68
-
69
- if( !function_exists ( 'iwp_mmb_filter_params' )) {
70
- function iwp_mmb_filter_params( $array = array() ){
71
-
72
- $filter = array( 'current_user', 'wpdb' );
73
- $return = array();
74
- foreach ($array as $key => $val) {
75
- if( !is_int($key) && in_array($key, $filter) )
76
- continue;
77
-
78
- if( is_array( $val ) ) {
79
- $return[$key] = iwp_mmb_filter_params( $val );
80
- } else {
81
- $return[$key] = $val;
82
- }
83
- }
84
-
85
- return $return;
86
- }
87
- }
88
-
89
- if( !function_exists ('iwp_mmb_parse_request')) {
90
- function iwp_mmb_parse_request()
91
- {
92
- if (!isset($HTTP_RAW_POST_DATA)) {
93
- $HTTP_RAW_POST_DATA = file_get_contents('php://input');
94
- }
95
-
96
- ob_start();
97
-
98
- global $current_user, $iwp_mmb_core, $new_actions, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache;
99
- $data = base64_decode($HTTP_RAW_POST_DATA);
100
- if ($data){
101
- //$num = @extract(unserialize($data));
102
- $unserialized_data = @unserialize($data);
103
- if(isset($unserialized_data['params'])){
104
- $unserialized_data['params'] = iwp_mmb_filter_params($unserialized_data['params']);
105
- }
106
-
107
- $iwp_action = $unserialized_data['iwp_action'];
108
- $params = $unserialized_data['params'];
109
- $id = $unserialized_data['id'];
110
- $signature = $unserialized_data['signature'];
111
- }
112
-
113
- if (isset($iwp_action)) {
114
-
115
- if(!defined('IWP_AUTHORISED_CALL')) define('IWP_AUTHORISED_CALL', 1);
116
- if(function_exists('register_shutdown_function')){ register_shutdown_function("iwp_mmb_shutdown"); }
117
- $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'] = microtime(1);
118
-
119
- error_reporting(E_ALL ^ E_NOTICE);
120
- @ini_set("display_errors", 1);
121
-
122
- iwp_mmb_create_backup_table();
123
-
124
- $action = $iwp_action;
125
- $_wp_using_ext_object_cache = false;
126
- @set_time_limit(600);
127
-
128
- if (!$iwp_mmb_core->check_if_user_exists($params['username']))
129
- iwp_mmb_response(array('error' => 'Username <b>' . $params['username'] . '</b> does not have administrative access. Enter the correct username in the site options.', 'error_code' => 'username_does_not_have_administrative_access'), false);
130
-
131
- if ($action == 'add_site') {
132
- iwp_mmb_add_site($params);
133
- iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
134
- }
135
- if ($action == 'readd_site') {
136
- $params['id'] = $id;
137
- $params['signature'] = $signature;
138
- iwp_mmb_readd_site($params);
139
- iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
140
- }
141
- if ($action == 'maintain_site') {
142
- iwp_mmb_maintain_site($params);
143
- iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
144
- }
145
-
146
- $auth = $iwp_mmb_core->authenticate_message($action . $id, $signature, $id);
147
- if ($auth === true) {
148
- @ignore_user_abort(true);
149
- $GLOBALS['IWP_CLIENT_HISTORY_ID'] = $id;
150
-
151
- if(isset($params['username']) && !is_user_logged_in()){
152
- $user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : get_userdatabylogin( $params['username'] );
153
- wp_set_current_user($user->ID);
154
- //For WPE
155
- if(@getenv('IS_WPE'))
156
- wp_set_auth_cookie($user->ID);
157
- }
158
-
159
- /* in case database upgrade required, do database backup and perform upgrade ( wordpress wp_upgrade() function ) */
160
- if( strlen(trim($wp_db_version)) && !defined('ACX_PLUGIN_DIR') ){
161
- if ( get_option('db_version') != $wp_db_version ) {
162
- /* in multisite network, please update database manualy */
163
- if (empty($wpmu_version) || (function_exists('is_multisite') && !is_multisite())){
164
- if( ! function_exists('wp_upgrade'))
165
- include_once(ABSPATH.'wp-admin/includes/upgrade.php');
166
-
167
- ob_clean();
168
- @wp_upgrade();
169
- @do_action('after_db_upgrade');
170
- ob_end_clean();
171
- }
172
- }
173
- }
174
-
175
- if(isset($params['secure'])){
176
-
177
- if($decrypted = $iwp_mmb_core->_secure_data($params['secure'])){
178
- $decrypted = maybe_unserialize($decrypted);
179
- if(is_array($decrypted)){
180
-
181
- foreach($decrypted as $key => $val){
182
- if(!is_numeric($key))
183
- $params[$key] = $val;
184
-
185
- }
186
- unset($params['secure']);
187
- } else $params['secure'] = $decrypted;
188
- }
189
- elseif(isset($params['secure']['account_info'])){
190
- $params['account_info'] = $params['secure']['account_info'];
191
- }
192
- }
193
-
194
- if( !$iwp_mmb_core->register_action_params( $action, $params ) ){
195
- global $_iwp_mmb_plugin_actions;
196
- $_iwp_mmb_plugin_actions[$action] = $params;
197
- }
198
-
199
- } else {
200
- iwp_mmb_response($auth, false);
201
- }
202
- } else {
203
- //IWP_MMB_Stats::set_hit_count();
204
- }
205
- ob_end_clean();
206
- }
207
- }
208
- /* Main response function */
209
- if( !function_exists ( 'iwp_mmb_response' )) {
210
-
211
- function iwp_mmb_response($response = false, $success = true)
212
- {
213
- $return = array();
214
-
215
- if ((is_array($response) && empty($response)) || (!is_array($response) && strlen($response) == 0)){
216
- $return['error'] = 'Empty response.';
217
- $return['error_code'] = 'empty_response';
218
- }
219
- else if ($success){
220
- $return['success'] = $response;
221
- }
222
- else{
223
- $return['error'] = $response['error'];
224
- $return['error_code'] = $response['error_code'];
225
- }
226
-
227
- if( !headers_sent() ){
228
- header('HTTP/1.0 200 OK');
229
- header('Content-Type: text/plain');
230
- }
231
- $GLOBALS['IWP_RESPONSE_SENT'] = true;
232
- exit("<IWPHEADER>" . base64_encode(serialize($return))."<ENDIWPHEADER>");
233
- }
234
- }
235
-
236
-
237
-
238
- if( !function_exists ( 'iwp_mmb_add_site' )) {
239
- function iwp_mmb_add_site($params)
240
- {
241
- global $iwp_mmb_core;
242
- $num = extract($params);
243
-
244
- if ($num) {
245
- if (!get_option('iwp_client_action_message_id') && !get_option('iwp_client_public_key')) {
246
- $public_key = base64_decode($public_key);
247
-
248
-
249
- if(trim($activation_key) != get_option('iwp_client_activate_key')){ //iwp
250
- iwp_mmb_response(array('error' => 'Invalid activation key', 'error_code' => 'iwp_mmb_add_site_invalid_activation_key'), false);
251
- return;
252
- }
253
-
254
- if (checkOpenSSL() && !$user_random_key_signing) {
255
- $verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
256
- if ($verify == 1) {
257
- $iwp_mmb_core->set_admin_panel_public_key($public_key);
258
- $iwp_mmb_core->set_client_message_id($id);
259
- $iwp_mmb_core->get_stats_instance();
260
- if(isset($notifications) && is_array($notifications) && !empty($notifications)){
261
- $iwp_mmb_core->stats_instance->set_notifications($notifications);
262
- }
263
- if(isset($brand) && is_array($brand) && !empty($brand)){
264
- update_option('iwp_client_brand',$brand);
265
- }
266
-
267
- iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
268
- delete_option('iwp_client_activate_key');//iwp
269
- } else if ($verify == 0) {
270
- iwp_mmb_response(array('error' => 'Invalid message signature. Please contact us if you see this message often.', 'error_code' => 'iwp_mmb_add_site_invalid_message_signature'), false);
271
- } else {
272
- iwp_mmb_response(array('error' => 'Command not successful. Please try again.', 'error_code' => 'iwp_mmb_add_site_command_not_successful'), false);
273
- }
274
- } else {
275
- if (!get_option('iwp_client_nossl_key')) {
276
- srand();
277
-
278
- $random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
279
-
280
- $iwp_mmb_core->set_random_signature($random_key);
281
- $iwp_mmb_core->set_client_message_id($id);
282
- $iwp_mmb_core->set_admin_panel_public_key($public_key);
283
- $iwp_mmb_core->get_stats_instance();
284
- if(is_array($notifications) && !empty($notifications)){
285
- $iwp_mmb_core->stats_instance->set_notifications($notifications);
286
- }
287
-
288
- if(is_array($brand) && !empty($brand)){
289
- update_option('iwp_client_brand',$brand);
290
- }
291
-
292
- iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
293
- delete_option('iwp_client_activate_key');//IWP
294
- } else
295
- iwp_mmb_response(array('error' => 'Please deactivate & activate InfiniteWP Client plugin on your site, then add the site again.', 'error_code' => 'deactivate_ctivate_InfiniteWP_Client_plugin_add_site_again_not_iwp_client_nossl_key'), false);
296
- }
297
- } else {
298
- iwp_mmb_response(array('error' => 'Please deactivate &amp; activate InfiniteWP Client plugin on your site, then add the site again.', 'error_code' => 'deactivate_ctivate_InfiniteWP_Client_plugin_add_site_again_not_iwp_client_nossl_key'), false);
299
- }
300
- } else {
301
- iwp_mmb_response(array('error' => 'Invalid parameters received. Please try again.', 'error_code' => 'iwp_mmb_add_site_invalid_parameters_received'), false);
302
- }
303
- }
304
- }
305
-
306
- if( !function_exists ( 'iwp_mmb_readd_site' )) {
307
- function iwp_mmb_readd_site($params){
308
- global $iwp_mmb_core;
309
- $num = extract($params);
310
- if ($num) {
311
- if (!get_option('iwp_client_action_message_id') && !get_option('iwp_client_public_key')) {
312
- $public_key = base64_decode($public_key);
313
- if(trim($activation_key) != get_option('iwp_client_activate_key')){ //iwp
314
- iwp_mmb_response(array('error' => 'Invalid activation key', 'error_code' => 'iwp_mmb_readd_site_invalid_activation_key'), false);
315
- return;
316
- }
317
- if (checkOpenSSL() && !$user_random_key_signing) {
318
-
319
- $verify = openssl_verify($action . $id, $signature, $public_key);
320
- if ($verify == 1) {
321
- $iwp_mmb_core->set_admin_panel_public_key($public_key);
322
- $iwp_mmb_core->set_client_message_id($id);
323
- $iwp_mmb_core->get_stats_instance();
324
- if(isset($notifications) && is_array($notifications) && !empty($notifications)){
325
- $iwp_mmb_core->stats_instance->set_notifications($notifications);
326
- }
327
- if(isset($brand) && is_array($brand) && !empty($brand)){
328
- update_option('iwp_client_brand',$brand);
329
- }
330
- iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
331
- delete_option('iwp_client_activate_key');//iwp
332
- } else if ($verify == 0) {
333
- iwp_mmb_response(array('error' => 'Invalid message signature. Please contact us if you see this message often.', 'error_code' => 'iwp_mmb_readd_site_invalid_message_signature'), false);
334
- } else {
335
- iwp_mmb_response(array('error' => 'Command not successful. Please try again.', 'error_code' => 'iwp_mmb_readd_site_command_not_successful'), false);
336
- }
337
- } else {
338
- if (!get_option('iwp_client_nossl_key')) {
339
- srand();
340
-
341
- $random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
342
-
343
- $iwp_mmb_core->set_random_signature($random_key);
344
- $iwp_mmb_core->set_client_message_id($id);
345
- $iwp_mmb_core->set_admin_panel_public_key($public_key);
346
- $iwp_mmb_core->get_stats_instance();
347
- if(is_array($notifications) && !empty($notifications)){
348
- $iwp_mmb_core->stats_instance->set_notifications($notifications);
349
- }
350
-
351
- if(is_array($brand) && !empty($brand)){
352
- update_option('iwp_client_brand',$brand);
353
- }
354
-
355
- iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
356
- delete_option('iwp_client_activate_key');//IWP
357
- } else
358
- iwp_mmb_response(array('error' => 'Please deactivate & activate InfiniteWP Client plugin on your site, then add the site again.', 'error_code' => 'deactivate_ctivate_InfiniteWP_Client_plugin_add_site_again_not_iwp_client_nossl_key'), false);
359
- }
360
- } else {
361
- iwp_mmb_response(array('error' => 'Please deactivate &amp; activate InfiniteWP Client plugin on your site, then add the site again.', 'error_code' => 'deactivate_ctivate_InfiniteWP_Client_plugin_add_site_again_not_iwp_client_nossl_key'), false);
362
- }
363
- } else {
364
- iwp_mmb_response(array('error' => 'Invalid parameters received. Please try again.', 'error_code' => 'iwp_mmb_add_site_invalid_parameters_received'), false);
365
- }
366
- }
367
- }
368
-
369
- if(!function_exists('iwp_mmb_maintain_site')){
370
- function iwp_mmb_maintain_site($params){
371
- $check = 1;
372
- if(get_option('iwp_mmb_maintenance_mode') != $params['maintenance_mode'])
373
- if(update_option('iwp_mmb_maintenance_mode',$params['maintenance_mode']) ){ $check = 1;}else{$check = 0;}
374
- if(get_option('iwp_mmb_maintenance_html') != $params['maintenance_html'])
375
- if(update_option('iwp_mmb_maintenance_html',$params['maintenance_html']) ){ $check = 1;}else{$check = 0;}
376
- if($check == 1){
377
- iwp_mmb_response($params, true);
378
- }else{
379
- iwp_mmb_response(array('error' => 'Some error with database connection in client site', 'error_code' => 'database_connection_in_client_site'), false);
380
- }
381
- }
382
- }
383
-
384
-
385
- if( !function_exists ( 'iwp_mmb_remove_site' )) {
386
- function iwp_mmb_remove_site($params)
387
- {
388
- extract($params);
389
- global $iwp_mmb_core;
390
- $iwp_mmb_core->uninstall( $deactivate );
391
-
392
- include_once(ABSPATH . 'wp-admin/includes/plugin.php');
393
- $plugin_slug = basename(dirname(__FILE__)) . '/' . basename(__FILE__);
394
-
395
- if ($deactivate) {
396
- deactivate_plugins($plugin_slug, true);
397
- }
398
-
399
- if (!is_plugin_active($plugin_slug))
400
- iwp_mmb_response(array(
401
- 'deactivated' => 'Site removed successfully. <br /><br />InfiniteWP Client plugin successfully deactivated.'
402
- ), true);
403
- else
404
- iwp_mmb_response(array(
405
- 'removed_data' => 'Site removed successfully. <br /><br /><b>InfiniteWP Client plugin was not deactivated.</b>'
406
- ), true);
407
-
408
- }
409
- }
410
- if( !function_exists ( 'iwp_mmb_stats_get' )) {
411
- function iwp_mmb_stats_get($params)
412
- {
413
- global $iwp_mmb_core;
414
- $iwp_mmb_core->get_stats_instance();
415
- iwp_mmb_response($iwp_mmb_core->stats_instance->get($params), true);
416
- }
417
- }
418
-
419
- if( !function_exists ( 'iwp_mmb_client_header' )) {
420
- function iwp_mmb_client_header()
421
- { global $iwp_mmb_core, $current_user;
422
-
423
- if(!headers_sent()){
424
- if(isset($current_user->ID))
425
- $expiration = time() + apply_filters('auth_cookie_expiration', 10800, $current_user->ID, false);
426
- else
427
- $expiration = time() + 10800;
428
-
429
- setcookie(IWP_MMB_XFRAME_COOKIE, md5(IWP_MMB_XFRAME_COOKIE), $expiration, COOKIEPATH, COOKIE_DOMAIN, false, true);
430
- $_COOKIE[IWP_MMB_XFRAME_COOKIE] = md5(IWP_MMB_XFRAME_COOKIE);
431
- }
432
- }
433
- }
434
-
435
- if( !function_exists ( 'iwp_mmb_pre_init_stats' )) {
436
- function iwp_mmb_pre_init_stats( $params )
437
- {
438
- global $iwp_mmb_core;
439
- $iwp_mmb_core->get_stats_instance();
440
- return $iwp_mmb_core->stats_instance->pre_init_stats($params);
441
- }
442
- }
443
-
444
- if( !function_exists ( 'iwp_mmb_trigger_check' )) {
445
- //backup multi call trigger and status check.
446
- function iwp_mmb_trigger_check($params)
447
- {
448
- global $iwp_mmb_core;
449
- $iwp_mmb_core->get_backup_instance($params['mechanism']);
450
- $return = $iwp_mmb_core->backup_instance->trigger_check($params);
451
-
452
- if (is_array($return) && array_key_exists('error', $return))
453
- iwp_mmb_response($return, false);
454
- else {
455
- iwp_mmb_response($return, true);
456
- }
457
- }
458
- }
459
-
460
-
461
- if( !function_exists ( 'iwp_mmb_backup_now' )) {
462
- //backup
463
- function iwp_mmb_backup_now($params)
464
- {
465
- global $iwp_mmb_core;
466
-
467
- $iwp_mmb_core->get_backup_instance();
468
- $return = $iwp_mmb_core->backup_instance->backup($params);
469
-
470
- if (is_array($return) && array_key_exists('error', $return))
471
- iwp_mmb_response($return, false);
472
- else {
473
- iwp_mmb_response($return, true);
474
- }
475
- }
476
- }
477
-
478
- if( !function_exists ( 'iwp_mmb_run_task_now' )) {
479
- function iwp_mmb_run_task_now($params)
480
- {
481
- global $iwp_mmb_core;
482
- $iwp_mmb_core->get_backup_instance($params['mechanism']);
483
- //$return = $iwp_mmb_core->backup_instance->task_now(); //set_backup_task($params)
484
- $return = $iwp_mmb_core->backup_instance->set_backup_task($params);
485
- if (is_array($return) && array_key_exists('error', $return))
486
- iwp_mmb_response($return, false);
487
- else {
488
- iwp_mmb_response($return, true);
489
- }
490
- }
491
- }
492
-
493
- if( !function_exists ( 'iwp_mmb_delete_task_now' )) {
494
- function iwp_mmb_delete_task_now($params)
495
- {
496
- global $iwp_mmb_core;
497
- $iwp_mmb_core->get_backup_instance();
498
- $return = $iwp_mmb_core->backup_instance->delete_task_now($params['task_name']);
499
- if (is_array($return) && array_key_exists('error', $return))
500
- iwp_mmb_response($return, false);
501
- else {
502
- iwp_mmb_response($return, true);
503
- }
504
- }
505
- }
506
- if( !function_exists ( 'iwp_mmb_check_backup_compat' )) {
507
- function iwp_mmb_check_backup_compat($params)
508
- {
509
- global $iwp_mmb_core;
510
- $iwp_mmb_core->get_backup_instance();
511
- $return = $iwp_mmb_core->backup_instance->check_backup_compat($params);
512
-
513
- if (is_array($return) && array_key_exists('error', $return))
514
- iwp_mmb_response($return, false);
515
- else {
516
- iwp_mmb_response($return, true);
517
- }
518
- }
519
- }
520
-
521
- if( !function_exists ( 'iwp_mmb_get_backup_req' )) {
522
- function iwp_mmb_get_backup_req( $params )
523
- {
524
- global $iwp_mmb_core;
525
- $iwp_mmb_core->get_stats_instance();
526
- $return = $iwp_mmb_core->stats_instance->get_backup_req($params);
527
-
528
- if (is_array($return) && array_key_exists('error', $return))
529
- iwp_mmb_response($return, false);
530
- else {
531
- iwp_mmb_response($return, true);
532
- }
533
- }
534
- }
535
-
536
-
537
- if( !function_exists ( 'iwp_mmb_scheduled_backup' )) {
538
- function iwp_mmb_scheduled_backup($params)
539
- {
540
- global $iwp_mmb_core;
541
-
542
- $iwp_mmb_core->get_backup_instance($params['mechanism']);
543
- $return = $iwp_mmb_core->backup_instance->set_backup_task($params);
544
- iwp_mmb_response($return, $return);
545
- }
546
- }
547
-
548
-
549
- if( !function_exists ( 'iwp_mmb_delete_backup' )) {
550
- function iwp_mmb_delete_backup($params)
551
- {
552
- global $iwp_mmb_core;
553
- $iwp_mmb_core->get_backup_instance();
554
- $return = $iwp_mmb_core->backup_instance->delete_backup($params);
555
- iwp_mmb_response($return, $return);
556
- }
557
- }
558
-
559
- if( !function_exists ( 'iwp_mmb_optimize_tables' )) {
560
- function iwp_mmb_optimize_tables($params)
561
- {
562
- global $iwp_mmb_core;
563
- $iwp_mmb_core->get_backup_instance();
564
- $return = $iwp_mmb_core->backup_instance->optimize_tables();
565
- if ($return)
566
- iwp_mmb_response($return, true);
567
- else
568
- iwp_mmb_response(false, false);
569
- }
570
- }
571
- if( !function_exists ( 'iwp_mmb_restore_now' )) {
572
- function iwp_mmb_restore_now($params)
573
- {
574
- global $iwp_mmb_core;
575
- $iwp_mmb_core->get_backup_instance('multiCall');
576
- $return = $iwp_mmb_core->backup_instance->restore($params);
577
-
578
- if (is_array($return) && array_key_exists('error', $return))
579
- iwp_mmb_response($return, false);
580
- else
581
- iwp_mmb_response($return, true);
582
-
583
- }
584
- }
585
-
586
-
587
- if( !function_exists ( 'iwp_mmb_backup_repository' )) {
588
- function iwp_mmb_backup_repository($params)
589
- {
590
- global $iwp_mmb_core;
591
- $iwp_mmb_core->get_backup_repository_instance();
592
- $return = $iwp_mmb_core->backup_repository_instance->backup_repository($params);
593
- if (is_array($return) && array_key_exists('error', $return))
594
- iwp_mmb_response($return, false);
595
- else
596
- iwp_mmb_response($return, true);
597
- }
598
- }
599
-
600
-
601
- if( !function_exists ( 'iwp_mmb_clean_orphan_backups' )) {
602
- function iwp_mmb_clean_orphan_backups()
603
- {
604
- global $iwp_mmb_core;
605
- $backup_instance = $iwp_mmb_core->get_backup_instance();
606
- $return = $iwp_mmb_core->backup_instance->cleanup();
607
- if(is_array($return))
608
- iwp_mmb_response($return, true);
609
- else
610
- iwp_mmb_response($return, false);
611
- }
612
- }
613
-
614
-
615
-
616
- add_filter( 'iwp_website_add', 'iwp_mmb_readd_backup_task' );
617
-
618
- if (!function_exists('iwp_mmb_readd_backup_task')) {
619
- function iwp_mmb_readd_backup_task($params = array()) {
620
- global $iwp_mmb_core;
621
- $backup_instance = $iwp_mmb_core->get_backup_instance();
622
- $settings = $backup_instance->readd_tasks($params);
623
- return $settings;
624
- }
625
- }
626
-
627
- if( !function_exists ( 'iwp_mmb_update_client_plugin' )) {
628
- function iwp_mmb_update_client_plugin($params)
629
- {
630
- global $iwp_mmb_core;
631
- iwp_mmb_response($iwp_mmb_core->update_client_plugin($params), true);
632
- }
633
- }
634
-
635
- if( !function_exists ( 'iwp_mmb_wp_checkversion' )) {
636
- function iwp_mmb_wp_checkversion($params)
637
- {
638
- include_once(ABSPATH . 'wp-includes/version.php');
639
- global $iwp_mmb_wp_version, $iwp_mmb_core;
640
- iwp_mmb_response($iwp_mmb_wp_version, true);
641
- }
642
- }
643
- if( !function_exists ( 'iwp_mmb_search_posts_by_term' )) {
644
- function iwp_mmb_search_posts_by_term($params)
645
- {
646
- global $iwp_mmb_core;
647
- $iwp_mmb_core->get_search_instance();
648
-
649
- $search_type = trim($params['search_type']);
650
- $search_term = strtolower(trim($params['search_term']));
651
-
652
- switch ($search_type){
653
- case 'plugin':
654
- $plugins = get_option('active_plugins');
655
-
656
- $have_plugin = false;
657
- foreach ($plugins as $plugin) {
658
- if(strpos($plugin, $search_term)>-1){
659
- $have_plugin = true;
660
- }
661
- }
662
- if($have_plugin){
663
- iwp_mmb_response(serialize($plugin), true);
664
- }else{
665
- iwp_mmb_response(false, false);
666
- }
667
- break;
668
- case 'theme':
669
- $theme = strtolower(get_option('template'));
670
- if(strpos($theme, $search_term)>-1){
671
- iwp_mmb_response($theme, true);
672
- }else{
673
- iwp_mmb_response(false, false);
674
- }
675
- break;
676
- default: iwp_mmb_response(false, false);
677
- }
678
- $return = $iwp_mmb_core->search_instance->iwp_mmb_search_posts_by_term($params);
679
-
680
-
681
-
682
- if ($return_if_true) {
683
- iwp_mmb_response($return_value, true);
684
- } else {
685
- iwp_mmb_response($return_if_false, false);
686
- }
687
- }
688
- }
689
-
690
- if( !function_exists ( 'iwp_mmb_install_addon' )) {
691
- function iwp_mmb_install_addon($params)
692
- {
693
- global $iwp_mmb_core;
694
- $iwp_mmb_core->get_installer_instance();
695
- $return = $iwp_mmb_core->installer_instance->install_remote_file($params);
696
- iwp_mmb_response($return, true);
697
-
698
- }
699
- }
700
-
701
- if( !function_exists ( 'iwp_mmb_do_upgrade' )) {
702
- function iwp_mmb_do_upgrade($params)
703
- {
704
- global $iwp_mmb_core, $iwp_mmb_upgrading;
705
- $iwp_mmb_core->get_installer_instance();
706
- $return = $iwp_mmb_core->installer_instance->do_upgrade($params);
707
- iwp_mmb_response($return, true);
708
-
709
- }
710
- }
711
-
712
- if( !function_exists ( 'iwp_mmb_add_user' )) {
713
- function iwp_mmb_add_user($params)
714
- {
715
- global $iwp_mmb_core;
716
- $iwp_mmb_core->get_user_instance();
717
- $return = $iwp_mmb_core->user_instance->add_user($params);
718
- if (is_array($return) && array_key_exists('error', $return)){
719
- iwp_mmb_response($return, false);
720
- }
721
- else {
722
- iwp_mmb_response($return, true);
723
- }
724
-
725
- }
726
- }
727
-
728
- if( !function_exists ('iwp_mmb_get_users')) {
729
- function iwp_mmb_get_users($params)
730
- {
731
- global $iwp_mmb_core;
732
- $iwp_mmb_core->get_user_instance();
733
- $return = $iwp_mmb_core->user_instance->get_users($params);
734
- if (is_array($return) && array_key_exists('error', $return))
735
- iwp_mmb_response($return, false);
736
- else {
737
- iwp_mmb_response($return, true);
738
- }
739
- }
740
- }
741
-
742
- if( !function_exists ('iwp_mmb_edit_users')) {
743
- function iwp_mmb_edit_users($params)
744
- {
745
- global $iwp_mmb_core;
746
- $iwp_mmb_core->get_user_instance();
747
- $return = $iwp_mmb_core->user_instance->edit_users($params);
748
- iwp_mmb_response($return, true);
749
- }
750
- }
751
-
752
- if( !function_exists ( 'iwp_mmb_iframe_plugins_fix' )) {
753
- function iwp_mmb_iframe_plugins_fix($update_actions)
754
- {
755
- foreach($update_actions as $key => $action)
756
- {
757
- $update_actions[$key] = str_replace('target="_parent"','',$action);
758
- }
759
-
760
- return $update_actions;
761
-
762
- }
763
- }
764
-
765
- if( !function_exists ( 'iwp_mmb_set_notifications' )) {
766
- function iwp_mmb_set_notifications($params)
767
- {
768
- global $iwp_mmb_core;
769
- $iwp_mmb_core->get_stats_instance();
770
- $return = $iwp_mmb_core->stats_instance->set_notifications($params);
771
- if (is_array($return) && array_key_exists('error', $return))
772
- iwp_mmb_response($return, false);
773
- else {
774
- iwp_mmb_response($return, true);
775
- }
776
-
777
- }
778
- }
779
-
780
- if( !function_exists ( 'iwp_mmb_set_alerts' )) {
781
- function iwp_mmb_set_alerts($params)
782
- {
783
- global $iwp_mmb_core;
784
- $iwp_mmb_core->get_stats_instance();
785
- $return = $iwp_mmb_core->stats_instance->set_alerts($params);
786
- iwp_mmb_response(true, true);
787
- }
788
- }
789
-
790
- /*
791
- if(!function_exists('iwp_mmb_more_reccurences')){
792
- //Backup Tasks
793
- add_filter('cron_schedules', 'iwp_mmb_more_reccurences');
794
- function iwp_mmb_more_reccurences($schedules) {
795
- $schedules['halfminute'] = array('interval' => 30, 'display' => 'Once in a half minute');
796
- $schedules['minutely'] = array('interval' => 60, 'display' => 'Once in a minute');
797
- $schedules['fiveminutes'] = array('interval' => 300, 'display' => 'Once every five minutes');
798
- $schedules['tenminutes'] = array('interval' => 600, 'display' => 'Once every ten minutes');
799
-
800
- return $schedules;
801
- }
802
- }
803
-
804
- add_action('iwp_client_backup_tasks', 'iwp_client_check_backup_tasks');
805
-
806
- if( !function_exists('iwp_client_check_backup_tasks') ){
807
- function iwp_client_check_backup_tasks() {
808
- global $iwp_mmb_core, $_wp_using_ext_object_cache;
809
- $_wp_using_ext_object_cache = false;
810
-
811
- $iwp_mmb_core->get_backup_instance();
812
- $iwp_mmb_core->backup_instance->check_backup_tasks();
813
- }
814
- }
815
- */
816
-
817
- if( !function_exists('iwp_check_notifications') ){
818
- function iwp_check_notifications() {
819
- global $iwp_mmb_core, $_wp_using_ext_object_cache;
820
- $_wp_using_ext_object_cache = false;
821
-
822
- $iwp_mmb_core->get_stats_instance();
823
- $iwp_mmb_core->stats_instance->check_notifications();
824
- }
825
- }
826
-
827
-
828
- if( !function_exists('iwp_mmb_get_plugins_themes') ){
829
- function iwp_mmb_get_plugins_themes($params) {
830
- global $iwp_mmb_core;
831
- $iwp_mmb_core->get_installer_instance();
832
- $return = $iwp_mmb_core->installer_instance->get($params);
833
- iwp_mmb_response($return, true);
834
- }
835
- }
836
-
837
- if( !function_exists('iwp_mmb_edit_plugins_themes') ){
838
- function iwp_mmb_edit_plugins_themes($params) {
839
- global $iwp_mmb_core;
840
- $iwp_mmb_core->get_installer_instance();
841
- $return = $iwp_mmb_core->installer_instance->edit($params);
842
- iwp_mmb_response($return, true);
843
- }
844
- }
845
-
846
- //post
847
- if( !function_exists ( 'iwp_mmb_post_create' )) {
848
- function iwp_mmb_post_create($params)
849
- {
850
- global $iwp_mmb_core;
851
- $iwp_mmb_core->get_post_instance();
852
- $return = $iwp_mmb_core->post_instance->create($params);
853
- if (is_int($return))
854
- iwp_mmb_response($return, true);
855
- else{
856
- if(isset($return['error'])){
857
- iwp_mmb_response($return, false);
858
- } else {
859
- iwp_mmb_response($return, false);
860
- }
861
- }
862
- }
863
- }
864
-
865
- if( !function_exists ( 'iwp_mmb_change_post_status' )) {
866
- function iwp_mmb_change_post_status($params)
867
- {
868
- global $iwp_mmb_core;
869
- $iwp_mmb_core->get_post_instance();
870
- $return = $iwp_mmb_core->post_instance->change_status($params);
871
- //mmb_response($return, true);
872
-
873
- }
874
- }
875
-
876
- if( !function_exists ('iwp_mmb_get_posts')) {
877
- function iwp_mmb_get_posts($params)
878
- {
879
- global $iwp_mmb_core;
880
- $iwp_mmb_core->get_post_instance();
881
-
882
- $return = $iwp_mmb_core->post_instance->get_posts($params);
883
- if (is_array($return) && array_key_exists('error', $return))
884
- iwp_mmb_response($return, false);
885
- else {
886
- iwp_mmb_response($return, true);
887
- }
888
- }
889
- }
890
-
891
- if( !function_exists ('iwp_mmb_delete_post')) {
892
- function iwp_mmb_delete_post($params)
893
- {
894
- global $iwp_mmb_core;
895
- $iwp_mmb_core->get_post_instance();
896
-
897
- $return = $iwp_mmb_core->post_instance->delete_post($params);
898
- if (is_array($return) && array_key_exists('error', $return))
899
- iwp_mmb_response($return, false);
900
- else {
901
- iwp_mmb_response($return, true);
902
- }
903
- }
904
- }
905
-
906
- if( !function_exists ('iwp_mmb_delete_posts')) {
907
- function iwp_mmb_delete_posts($params)
908
- {
909
- global $iwp_mmb_core;
910
- $iwp_mmb_core->get_post_instance();
911
-
912
- $return = $iwp_mmb_core->post_instance->delete_posts($params);
913
- if (is_array($return) && array_key_exists('error', $return))
914
- iwp_mmb_response($return, false);
915
- else {
916
- iwp_mmb_response($return, true);
917
- }
918
- }
919
- }
920
-
921
- if( !function_exists ('iwp_mmb_edit_posts')) {
922
- function iwp_mmb_edit_posts($params)
923
- {
924
- global $iwp_mmb_core;
925
- $iwp_mmb_core->get_posts_instance();
926
- $return = $iwp_mmb_core->posts_instance->edit_posts($params);
927
- iwp_mmb_response($return, true);
928
- }
929
- }
930
-
931
- if( !function_exists ('iwp_mmb_get_pages')) {
932
- function iwp_mmb_get_pages($params)
933
- {
934
- global $iwp_mmb_core;
935
- $iwp_mmb_core->get_post_instance();
936
-
937
- $return = $iwp_mmb_core->post_instance->get_pages($params);
938
- if (is_array($return) && array_key_exists('error', $return))
939
- iwp_mmb_response($return, false);
940
- else {
941
- iwp_mmb_response($return, true);
942
- }
943
- }
944
- }
945
-
946
- if( !function_exists ('iwp_mmb_delete_page')) {
947
- function iwp_mmb_delete_page($params)
948
- {
949
- global $iwp_mmb_core;
950
- $iwp_mmb_core->get_post_instance();
951
-
952
- $return = $iwp_mmb_core->post_instance->delete_page($params);
953
- if (is_array($return) && array_key_exists('error', $return))
954
- iwp_mmb_response($return, false);
955
- else {
956
- iwp_mmb_response($return, true);
957
- }
958
- }
959
- }
960
-
961
-
962
- //links
963
- if( !function_exists ('iwp_mmb_get_links')) {
964
- function iwp_mmb_get_links($params)
965
- {
966
- global $iwp_mmb_core;
967
- $iwp_mmb_core->get_link_instance();
968
- $return = $iwp_mmb_core->link_instance->get_links($params);
969
- if (is_array($return) && array_key_exists('error', $return))
970
- iwp_mmb_response($return, false);
971
- else {
972
- iwp_mmb_response($return, true);
973
- }
974
- }
975
- }
976
-
977
- if( !function_exists ( 'iwp_mmb_add_link' )) {
978
- function iwp_mmb_add_link($params)
979
- {
980
- global $iwp_mmb_core;
981
- $iwp_mmb_core->get_link_instance();
982
- $return = $iwp_mmb_core->link_instance->add_link($params);
983
- if (is_array($return) && array_key_exists('error', $return)){
984
- iwp_mmb_response($return, false);
985
- }
986
- else {
987
- iwp_mmb_response($return, true);
988
- }
989
-
990
- }
991
- }
992
-
993
- if( !function_exists ('iwp_mmb_delete_link')) {
994
- function iwp_mmb_delete_link($params)
995
- {
996
- global $iwp_mmb_core;
997
- $iwp_mmb_core->get_link_instance();
998
-
999
- $return = $iwp_mmb_core->link_instance->delete_link($params);
1000
- if (is_array($return) && array_key_exists('error', $return)){
1001
- iwp_mmb_response($return, false);
1002
- }
1003
- else {
1004
- iwp_mmb_response($return, true);
1005
- }
1006
- }
1007
- }
1008
-
1009
- if( !function_exists ('iwp_mmb_delete_links')) {
1010
- function iwp_mmb_delete_links($params)
1011
- {
1012
- global $iwp_mmb_core;
1013
- $iwp_mmb_core->get_link_instance();
1014
-
1015
- $return = $iwp_mmb_core->link_instance->delete_links($params);
1016
- if (is_array($return) && array_key_exists('error', $return)){
1017
- iwp_mmb_response($return, false);
1018
- }
1019
- else {
1020
- iwp_mmb_response($return, true);
1021
- }
1022
- }
1023
- }
1024
-
1025
-
1026
- //comments
1027
- if( !function_exists ( 'iwp_mmb_change_comment_status' )) {
1028
- function iwp_mmb_change_comment_status($params)
1029
- {
1030
- global $iwp_mmb_core;
1031
- $iwp_mmb_core->get_comment_instance();
1032
- $return = $iwp_mmb_core->comment_instance->change_status($params);
1033
- //mmb_response($return, true);
1034
- if ($return){
1035
- $iwp_mmb_core->get_stats_instance();
1036
- iwp_mmb_response($iwp_mmb_core->stats_instance->get_comments_stats($params), true);
1037
- }else
1038
- iwp_mmb_response(array('error' => 'Comment not updated', 'error_code' => 'comment_not_updated'), false);
1039
- }
1040
-
1041
- }
1042
- if( !function_exists ( 'iwp_mmb_comment_stats_get' )) {
1043
- function iwp_mmb_comment_stats_get($params)
1044
- {
1045
- global $iwp_mmb_core;
1046
- $iwp_mmb_core->get_stats_instance();
1047
- iwp_mmb_response($iwp_mmb_core->stats_instance->get_comments_stats($params), true);
1048
- }
1049
- }
1050
-
1051
- if( !function_exists ('iwp_mmb_get_comments')) {
1052
- function iwp_mmb_get_comments($params)
1053
- {
1054
- global $iwp_mmb_core;
1055
- $iwp_mmb_core->get_comment_instance();
1056
- $return = $iwp_mmb_core->comment_instance->get_comments($params);
1057
- if (is_array($return) && array_key_exists('error', $return))
1058
- iwp_mmb_response($return, false);
1059
- else {
1060
- iwp_mmb_response($return, true);
1061
- }
1062
- }
1063
- }
1064
-
1065
- if( !function_exists ('iwp_mmb_action_comment')) {
1066
- function iwp_mmb_action_comment($params)
1067
- {
1068
- global $iwp_mmb_core;
1069
- $iwp_mmb_core->get_comment_instance();
1070
-
1071
- $return = $iwp_mmb_core->comment_instance->action_comment($params);
1072
- if (is_array($return) && array_key_exists('error', $return))
1073
- iwp_mmb_response($return, false);
1074
- else {
1075
- iwp_mmb_response($return, true);
1076
- }
1077
- }
1078
- }
1079
-
1080
- if( !function_exists ('iwp_mmb_bulk_action_comments')) {
1081
- function iwp_mmb_bulk_action_comments($params)
1082
- {
1083
- global $iwp_mmb_core;
1084
- $iwp_mmb_core->get_comment_instance();
1085
-
1086
- $return = $iwp_mmb_core->comment_instance->bulk_action_comments($params);
1087
- if (is_array($return) && array_key_exists('error', $return))
1088
- iwp_mmb_response($return, false);
1089
- else {
1090
- iwp_mmb_response($return, true);
1091
- }
1092
- }
1093
- }
1094
-
1095
- if( !function_exists ('iwp_mmb_reply_comment')) {
1096
- function iwp_mmb_reply_comment($params)
1097
- {
1098
- global $iwp_mmb_core;
1099
- $iwp_mmb_core->get_comment_instance();
1100
-
1101
- $return = $iwp_mmb_core->comment_instance->reply_comment($params);
1102
- if (is_array($return) && array_key_exists('error', $return))
1103
- iwp_mmb_response($return, false);
1104
- else {
1105
- iwp_mmb_response($return, true);
1106
- }
1107
- }
1108
- }
1109
-
1110
- //Comments-End-
1111
-
1112
- //WP-Optimize
1113
-
1114
- if( !function_exists('iwp_mmb_wp_optimize')){
1115
- function iwp_mmb_wp_optimize($params){
1116
- global $iwp_mmb_core;
1117
- $iwp_mmb_core->wp_optimize_instance();
1118
-
1119
- $return = $iwp_mmb_core->optimize_instance->cleanup_system($params);
1120
- if (is_array($return) && array_key_exists('error', $return))
1121
- iwp_mmb_response($return, false);
1122
- else {
1123
- iwp_mmb_response($return, true);
1124
- }
1125
- }
1126
- }
1127
-
1128
- //WP-Optimize_end
1129
-
1130
- /*
1131
- *WordFence Addon Start
1132
- */
1133
-
1134
- if( !function_exists('iwp_mmb_wordfence_scan')){
1135
- function iwp_mmb_wordfence_scan($params){
1136
- global $iwp_mmb_core,$iwp_mmb_plugin_dir;
1137
- require_once("$iwp_mmb_plugin_dir/addons/wordfence/wordfence.class.php");
1138
- $iwp_mmb_core->get_wordfence_instance();
1139
-
1140
- $return = $iwp_mmb_core->wordfence_instance->scan($params);
1141
- if (is_array($return) && array_key_exists('error', $return))
1142
- iwp_mmb_response($return, false);
1143
- else {
1144
- iwp_mmb_response($return, true);
1145
- }
1146
- }
1147
- }
1148
-
1149
- if( !function_exists('iwp_mmb_wordfence_load')){
1150
- function iwp_mmb_wordfence_load($params){
1151
- global $iwp_mmb_core,$iwp_mmb_plugin_dir;
1152
- require_once("$iwp_mmb_plugin_dir/addons/wordfence/wordfence.class.php");
1153
- $iwp_mmb_core->get_wordfence_instance();
1154
-
1155
- $return = $iwp_mmb_core->wordfence_instance->load($params);
1156
- if (is_array($return) && array_key_exists('error', $return))
1157
- iwp_mmb_response($return, false);
1158
- else {
1159
- iwp_mmb_response($return, true);
1160
- }
1161
- }
1162
- }
1163
-
1164
- /*
1165
- *WordFence Addon End
1166
- */
1167
-
1168
-
1169
- /*
1170
- * iTheams Security Addon Start here
1171
- */
1172
-
1173
- if(!function_exists('iwp_mmb_ithemes_security_load')) {
1174
- function iwp_mmb_ithemes_security_load() {
1175
- if(_check_ithemes_security()) {
1176
- include_once(ABSPATH . "wp-includes/pluggable.php");
1177
- //$ITSECdashboard = new ITSEC_Dashboard_Admin( new ITSEC_Core(WP_PLUGIN_DIR . '/better-wp-security/better-wp-security.php', __( 'iThemes Security', 'it-l10n-better-wp-security' )) );
1178
- //add_action( 'itsec_add_admin_meta_boxes', array( $ITSECdashboard, 'add_admin_meta_boxes' ) );
1179
- $statuses = array(
1180
- 'safe-high' => array(),
1181
- 'high' => array(),
1182
- 'safe-medium' => array(),
1183
- 'medium' => array(),
1184
- 'safe-low' => array(),
1185
- 'low' => array(),
1186
- );
1187
-
1188
- $statuses = apply_filters( 'itsec_add_dashboard_status', $statuses );
1189
- iwp_mmb_response($statuses, true);
1190
- }
1191
- }
1192
- }
1193
-
1194
- /*
1195
- * Private function, Will return the iTheams Security is load or not
1196
- */
1197
- function _check_ithemes_security() {
1198
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
1199
- if ( is_plugin_active( 'better-wp-security/better-wp-security.php' ) ) {
1200
- @include_once(WP_PLUGIN_DIR . '/better-wp-security/better-wp-security.php');
1201
- if (class_exists('ITSEC_Core')) {
1202
- return true;
1203
- } else {
1204
- return false;
1205
- }
1206
- } else {
1207
- return false;
1208
- }
1209
- }
1210
-
1211
- /*
1212
- * iTheams Security Addon End here
1213
- */
1214
-
1215
- //WP-BrokenLinks start
1216
-
1217
- if( !function_exists('iwp_mmb_get_all_links')){
1218
- function iwp_mmb_get_all_links(){
1219
- global $iwp_mmb_core;
1220
- $iwp_mmb_core->wp_blc_get_blinks();
1221
- $return = $iwp_mmb_core->blc_get_blinks->blc_get_all_links($params);
1222
- if (is_array($return) && array_key_exists('error', $return))
1223
- iwp_mmb_response($return, false);
1224
- else {
1225
- iwp_mmb_response($return, true);
1226
- }
1227
- }
1228
- }
1229
-
1230
- if( !function_exists('iwp_mmb_update_broken_link')){
1231
- function iwp_mmb_update_broken_link($params){
1232
- global $iwp_mmb_core;
1233
- $iwp_mmb_core->wp_blc_get_blinks();
1234
- $return = $iwp_mmb_core->blc_get_blinks->blc_update_link($params);
1235
- if (is_array($return) && array_key_exists('error', $return))
1236
- iwp_mmb_response($return, false);
1237
- else {
1238
- iwp_mmb_response($return, true);
1239
- }
1240
- }
1241
- }
1242
-
1243
- if( !function_exists('iwp_mmb_unlink_broken_link')){
1244
- function iwp_mmb_unlink_broken_link($params){
1245
- global $iwp_mmb_core;
1246
- $iwp_mmb_core->wp_blc_get_blinks();
1247
- $return = $iwp_mmb_core->blc_get_blinks->blc_unlink($params);
1248
- if (is_array($return) && array_key_exists('error', $return))
1249
- iwp_mmb_response($return, false);
1250
- else {
1251
- iwp_mmb_response($return, true);
1252
- }
1253
- }
1254
- }
1255
-
1256
- if( !function_exists('iwp_mmb_markasnot_broken_link')){
1257
- function iwp_mmb_markasnot_broken_link($params){
1258
- global $iwp_mmb_core;
1259
- $iwp_mmb_core->wp_blc_get_blinks();
1260
- $return = $iwp_mmb_core->blc_get_blinks->blc_mark_as_not_broken($params);
1261
- if (is_array($return) && array_key_exists('error', $return))
1262
- iwp_mmb_response($return, false);
1263
- else {
1264
- iwp_mmb_response($return, true);
1265
- }
1266
- }
1267
- }
1268
-
1269
- if( !function_exists('iwp_mmb_dismiss_broken_link')){
1270
- function iwp_mmb_dismiss_broken_link($params){
1271
- global $iwp_mmb_core;
1272
- $iwp_mmb_core->wp_blc_get_blinks();
1273
- $return = $iwp_mmb_core->blc_get_blinks->blc_dismiss_link($params);
1274
- if (is_array($return) && array_key_exists('error', $return))
1275
- iwp_mmb_response($return, false);
1276
- else {
1277
- iwp_mmb_response($return, true);
1278
- }
1279
- }
1280
- }
1281
-
1282
- if( !function_exists('iwp_mmb_undismiss_broken_link')){
1283
- function iwp_mmb_undismiss_broken_link($params){
1284
- global $iwp_mmb_core;
1285
- $iwp_mmb_core->wp_blc_get_blinks();
1286
- $return = $iwp_mmb_core->blc_get_blinks->blc_undismiss_link($params);
1287
- if (is_array($return) && array_key_exists('error', $return))
1288
- iwp_mmb_response($return, false);
1289
- else {
1290
- iwp_mmb_response($return, true);
1291
- }
1292
- }
1293
- }
1294
-
1295
- if( !function_exists('iwp_mmb_bulk_actions_processor')){
1296
- function iwp_mmb_bulk_actions_processor($params){
1297
- global $iwp_mmb_core;
1298
- $iwp_mmb_core->wp_blc_get_blinks();
1299
- $return = $iwp_mmb_core->blc_get_blinks->blc_bulk_actions($params);
1300
- if (is_array($return) && array_key_exists('error', $return))
1301
- iwp_mmb_response($return, false);
1302
- else {
1303
- iwp_mmb_response($return, true);
1304
- }
1305
- }
1306
- }
1307
-
1308
- //WP-BrokenLinks end
1309
-
1310
- //WP-GWMTools start
1311
-
1312
- if( !function_exists('iwp_mmb_gwmt_redirect_url')){
1313
- function iwp_mmb_gwmt_redirect_url($params){
1314
- global $iwp_mmb_core;
1315
- $iwp_mmb_core->wp_google_webmasters_crawls();
1316
- $return = $iwp_mmb_core->get_google_webmasters_crawls->google_webmasters_redirect($params);
1317
- if (is_array($return) && array_key_exists('error', $return))
1318
- iwp_mmb_response($return, false);
1319
- else {
1320
- iwp_mmb_response($return, true);
1321
- }
1322
- }
1323
- }
1324
-
1325
- if( !function_exists('iwp_mmb_gwmt_redirect_url_again')){
1326
- function iwp_mmb_gwmt_redirect_url_again($params){
1327
- global $iwp_mmb_core;
1328
- $iwp_mmb_core->wp_google_webmasters_crawls();
1329
- $return = $iwp_mmb_core->get_google_webmasters_crawls->google_webmasters_redirect_again($params);
1330
- if (is_array($return) && array_key_exists('error', $return))
1331
- iwp_mmb_response($return, false);
1332
- else {
1333
- iwp_mmb_response($return, true);
1334
- }
1335
- }
1336
- }
1337
-
1338
-
1339
- //WP-GWMTools end
1340
-
1341
- //fileEditor start
1342
-
1343
- if( !function_exists('iwp_mmb_file_editor_upload')){
1344
- function iwp_mmb_file_editor_upload($params){
1345
- global $iwp_mmb_core;
1346
- $iwp_mmb_core->wp_get_file_editor();
1347
- $return = $iwp_mmb_core->get_file_editor->file_editor_upload($params);
1348
- if (is_array($return) && array_key_exists('error', $return))
1349
- iwp_mmb_response($return, false);
1350
- else {
1351
- iwp_mmb_response($return, true);
1352
- }
1353
- }
1354
- }
1355
-
1356
-
1357
- //fileEditor end
1358
-
1359
- //yoastWpSeo start
1360
- if( !function_exists('iwp_mmb_yoast_get_seo_info')){
1361
- function iwp_mmb_yoast_get_seo_info($params){
1362
- global $iwp_mmb_core;
1363
- $iwp_mmb_core->wp_get_yoast_seo();
1364
- $return = $iwp_mmb_core->get_yoast_seo->get_seo_info($params);
1365
- if (is_array($return) && array_key_exists('error', $return))
1366
- iwp_mmb_response($return, false);
1367
- else {
1368
- iwp_mmb_response($return, true);
1369
- }
1370
- }
1371
- }
1372
- if( !function_exists('iwp_mmb_yoast_save_seo_info')){
1373
- function iwp_mmb_yoast_save_seo_info($params){
1374
- global $iwp_mmb_core;
1375
- $iwp_mmb_core->wp_get_yoast_seo();
1376
- $return = $iwp_mmb_core->get_yoast_seo->save_seo_info($params);
1377
- if (is_array($return) && array_key_exists('error', $return))
1378
- iwp_mmb_response($return, false);
1379
- else {
1380
- iwp_mmb_response($return, true);
1381
- }
1382
- }
1383
- }
1384
- //yoastWpSeo end
1385
-
1386
- if( !function_exists('iwp_mmb_maintenance_mode')){
1387
- function iwp_mmb_maintenance_mode( $params ) {
1388
- global $wp_object_cache;
1389
-
1390
- $default = get_option('iwp_client_maintenace_mode');
1391
- $params = empty($default) ? $params : array_merge($default, $params);
1392
- update_option("iwp_client_maintenace_mode", $params);
1393
-
1394
- if(!empty($wp_object_cache))
1395
- @$wp_object_cache->flush();
1396
- iwp_mmb_response(true, true);
1397
- }
1398
- }
1399
-
1400
- if( !function_exists('iwp_mmb_plugin_actions') ){
1401
- function iwp_mmb_plugin_actions() {
1402
- global $iwp_mmb_actions, $iwp_mmb_core;
1403
-
1404
- if(!empty($iwp_mmb_actions)){
1405
- global $_iwp_mmb_plugin_actions;
1406
- if(!empty($_iwp_mmb_plugin_actions)){
1407
- $failed = array();
1408
- foreach($_iwp_mmb_plugin_actions as $action => $params){
1409
- if(isset($iwp_mmb_actions[$action]))
1410
- call_user_func($iwp_mmb_actions[$action], $params);
1411
- else
1412
- $failed[] = $action;
1413
- }
1414
- if(!empty($failed)){
1415
- $f = implode(', ', $failed);
1416
- $s = count($f) > 1 ? 'Actions "' . $f . '" do' : 'Action "' . $f . '" does';
1417
- iwp_mmb_response(array('error' => $s.' not exist. Please update your IWP Client plugin.', 'error_code' => 'update_your_client_plugin'), false);
1418
- }
1419
-
1420
- }
1421
- }
1422
-
1423
- global $pagenow, $current_user, $mmode;
1424
- if( !is_admin() && !in_array($pagenow, array( 'wp-login.php' ))){
1425
- $mmode = get_option('iwp_client_maintenace_mode');
1426
- if( !empty($mmode) ){
1427
- if(isset($mmode['active']) && $mmode['active'] == true){
1428
- if(isset($current_user->data) && !empty($current_user->data) && isset($mmode['hidecaps']) && !empty($mmode['hidecaps'])){
1429
- $usercaps = array();
1430
- if(isset($current_user->caps) && !empty($current_user->caps)){
1431
- $usercaps = $current_user->caps;
1432
- }
1433
- foreach($mmode['hidecaps'] as $cap => $hide){
1434
- if(!$hide)
1435
- continue;
1436
-
1437
- foreach($usercaps as $ucap => $val){
1438
- if($ucap == $cap){
1439
- ob_end_clean();
1440
- ob_end_flush();
1441
- die($mmode['template']);
1442
- }
1443
- }
1444
- }
1445
- } else
1446
- die($mmode['template']);
1447
- }
1448
- }
1449
- }
1450
- }
1451
- }
1452
-
1453
- if( !function_exists ( 'iwp_mmb_execute_php_code' )) {
1454
- function iwp_mmb_execute_php_code($params)
1455
- {
1456
- ob_start();
1457
- eval($params['code']);
1458
- $return = ob_get_flush();
1459
- iwp_mmb_response(print_r($return, true), true);
1460
- }
1461
- }
1462
-
1463
- if( !function_exists('iwp_mmb_client_brand')){
1464
- function iwp_mmb_client_brand($params) {
1465
- update_option("iwp_client_brand",$params['brand']);
1466
- iwp_mmb_response(true, true);
1467
- }
1468
- }
1469
-
1470
-
1471
- if(!function_exists('checkOpenSSL')){
1472
- function checkOpenSSL(){
1473
- if(!function_exists('openssl_verify')){
1474
- return false;
1475
- }
1476
- else{
1477
- $key = @openssl_pkey_new();
1478
- @openssl_pkey_export($key, $privateKey);
1479
- $privateKey = base64_encode($privateKey);
1480
- $publicKey = @openssl_pkey_get_details($key);
1481
- $publicKey = $publicKey["key"];
1482
-
1483
- if(empty($publicKey) || empty($privateKey)){
1484
- return false;
1485
- }
1486
- }
1487
- return true;
1488
- }
1489
- }
1490
-
1491
-
1492
- if(!function_exists('iwp_mmb_shutdown')){
1493
- function iwp_mmb_shutdown(){
1494
- $isError = false;
1495
-
1496
- if ($error = error_get_last()){
1497
- switch($error['type']){
1498
- /*case E_PARSE:*/
1499
- case E_ERROR:
1500
- case E_CORE_ERROR:
1501
- case E_COMPILE_ERROR:
1502
- case E_USER_ERROR:
1503
- $isError = true;
1504
- break;
1505
- }
1506
- }
1507
- if ($isError){
1508
-
1509
- $response = '<span style="font-weight:700;">PHP Fatal error occured:</span> '.$error['message'].' in '.$error['file'].' on line '.$error['line'].'.';
1510
- if(stripos($error['message'], 'allowed memory size') !== false){
1511
- $response .= '<br>Try <a href="http://infinitewp.com/knowledge-base/increase-memory-limit/?utm_source=application&utm_medium=userapp&utm_campaign=kb" target="_blank">increasing the PHP memory limit</a> for this WP site.';
1512
- }
1513
- if(!$GLOBALS['IWP_RESPONSE_SENT']){
1514
- iwp_mmb_response(array('error' => $response, 'error_code' => 'iwp_mmb_shutdown'), false);
1515
- }
1516
-
1517
- }
1518
- }
1519
- }
1520
-
1521
-
1522
- if(!function_exists('iwp_mmb_print_flush')){
1523
- function iwp_mmb_print_flush($print_string){// this will help responding web server, will keep alive the script execution
1524
-
1525
- echo $print_string." ||| ";
1526
- echo "TT:".(microtime(1) - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'])."\n";
1527
- ob_flush();
1528
- flush();
1529
- }
1530
- }
1531
-
1532
- if(!function_exists('iwp_mmb_auto_print')){
1533
- function iwp_mmb_auto_print($unique_task){// this will help responding web server, will keep alive the script execution
1534
- $print_every_x_secs = 5;
1535
-
1536
- $current_time = microtime(1);
1537
- if(!$GLOBALS['IWP_MMB_PROFILING']['TASKS'][$unique_task]['START']){
1538
- $GLOBALS['IWP_MMB_PROFILING']['TASKS'][$unique_task]['START'] = $current_time;
1539
- }
1540
-
1541
- if(!$GLOBALS['IWP_MMB_PROFILING']['LAST_PRINT'] || ($current_time - $GLOBALS['IWP_MMB_PROFILING']['LAST_PRINT']) > $print_every_x_secs){
1542
-
1543
- //$print_string = "TT:".($current_time - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'])."\n";
1544
- $print_string = $unique_task." TT:".($current_time - $GLOBALS['IWP_MMB_PROFILING']['TASKS'][$unique_task]['START']);
1545
- iwp_mmb_print_flush($print_string);
1546
- $GLOBALS['IWP_MMB_PROFILING']['LAST_PRINT'] = $current_time;
1547
- }
1548
- }
1549
- }
1550
-
1551
- if(!function_exists('iwp_mmb_check_maintenance')){
1552
- function iwp_mmb_check_maintenance(){
1553
- global $wpdb;
1554
- if(get_option('iwp_mmb_maintenance_mode')){
1555
- $html_maintenance = get_option('iwp_mmb_maintenance_html');
1556
- echo $html_maintenance;
1557
- exit;
1558
- }
1559
- }
1560
- }
1561
-
1562
- if(!function_exists('iwp_mmb_check_redirects')){
1563
- function iwp_mmb_check_redirects(){
1564
- global $wpdb;
1565
- $current_url = ($_SERVER['SERVER_PORT']=='443'?'https://':'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
1566
- $current_url = rtrim($current_url,'/');
1567
- $table_name = $wpdb->base_prefix."iwp_redirects";
1568
- if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) {
1569
- $success = $wpdb -> get_col($wpdb->prepare("SELECT redirectLink FROM ".$wpdb->base_prefix."iwp_redirects WHERE oldLink = %s LIMIT 1",$current_url));
1570
- if(count($success)){
1571
- if(function_exists(wp_redirect)){
1572
- wp_redirect($success[0]);
1573
- }
1574
- }
1575
- }
1576
- }
1577
- }
1578
-
1579
- if(!function_exists('iwp_mmb_convert_data')){
1580
- function iwp_mmb_convert_data(){
1581
-
1582
- //Schedule backup key need to save .
1583
- global $wpdb;
1584
-
1585
- $client_backup_tasks = get_option('iwp_client_backup_tasks');
1586
-
1587
- $type = $action = $category = '';
1588
-
1589
- if(!empty($client_backup_tasks) && is_array($client_backup_tasks)){
1590
- foreach($client_backup_tasks as $key){
1591
- if(!is_array($key) || !is_array($key['task_args'])){
1592
- continue;
1593
- }
1594
- $task_name = $key['task_args']['task_name'];
1595
-
1596
- if($task_name == 'Backup Now'){
1597
- $type = 'backup';
1598
- $action = 'now';
1599
- $category = $key['task_args']['what'];
1600
- }
1601
- else{
1602
- $type = 'scheduleBackup';
1603
- $action = 'runTask';
1604
- $category = $key['task_args']['what'];
1605
- }
1606
- if(is_array($key['task_results'])){
1607
- $taskResultData = array();
1608
- foreach($key['task_results'] as $keys => $task_results){
1609
-
1610
- $historyID = $task_results['backhack_status']['adminHistoryID'];
1611
-
1612
- $taskResultData = array('task_results' => array($historyID => $task_results));
1613
- $taskResultData['task_results'][$historyID]['adminHistoryID'] = $historyID;
1614
-
1615
- $insert = $wpdb->insert($wpdb->base_prefix.'iwp_backup_status',array( 'stage' => 'finished', 'status' => 'completed', 'action' => $action, 'type' => $type,'category' => $category ,'historyID' => $task_results['backhack_status']['adminHistoryID'],'finalStatus' => 'completed','startTime' => $task_results['time'],'endTime' => $task_results['time'],'statusMsg' => $statusArray['statusMsg'],'requestParams' => serialize($key),'taskName' => $task_name, 'responseParams' => '', 'taskResults' => serialize($taskResultData)), array( '%s', '%s','%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%s', '%s', '%s', '%s', '%s') );
1616
-
1617
- }
1618
- }
1619
- }
1620
- }
1621
- }
1622
- }
1623
-
1624
-
1625
-
1626
- if(!function_exists('iwp_mmb_create_backup_table')){
1627
- function iwp_mmb_create_backup_table(){
1628
- global $wpdb;
1629
-
1630
- $IWP_MMB_BACKUP_TABLE_VERSION = get_site_option( 'iwp_backup_table_version' );
1631
- $table_name = $wpdb->base_prefix . "iwp_backup_status";
1632
-
1633
- if(version_compare($IWP_MMB_BACKUP_TABLE_VERSION, '1.1') == -1){
1634
- if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
1635
-
1636
- $sql = "
1637
- CREATE TABLE IF NOT EXISTS $table_name (
1638
- `ID` int(11) NOT NULL AUTO_INCREMENT,
1639
- `historyID` int(11) NOT NULL,
1640
- `taskName` varchar(255) NOT NULL,
1641
- `action` varchar(50) NOT NULL,
1642
- `type` varchar(50) NOT NULL,
1643
- `category` varchar(50) NOT NULL,
1644
- `stage` varchar(255) NOT NULL,
1645
- `status` varchar(255) NOT NULL,
1646
- `finalStatus` varchar(50) DEFAULT NULL,
1647
- `statusMsg` varchar(255) NOT NULL,
1648
- `requestParams` text NOT NULL,
1649
- `responseParams` longtext,
1650
- `taskResults` text,
1651
- `startTime` int(11) DEFAULT NULL,
1652
- `endTime` int(11) NOT NULL,
1653
- PRIMARY KEY (`ID`)
1654
- ) ENGINE=InnoDB;
1655
- ";
1656
-
1657
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1658
- dbDelta( $sql );
1659
-
1660
- if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
1661
- //echo "table creation failed";
1662
- $table_created = false;
1663
- }
1664
- else{
1665
-
1666
- iwp_mmb_convert_data();
1667
- $_NEW_IWP_MMB_BACKUP_TABLE_VERSION = '1.1';
1668
- }
1669
-
1670
- }else{
1671
- $table_created = true;
1672
- $_NEW_IWP_MMB_BACKUP_TABLE_VERSION = '1.1';
1673
- }
1674
- }
1675
-
1676
- if(!empty($_NEW_IWP_MMB_BACKUP_TABLE_VERSION)){
1677
- add_option( "iwp_backup_table_version", $_NEW_IWP_MMB_BACKUP_TABLE_VERSION);
1678
- }
1679
- }
1680
- }
1681
-
1682
- //-------------------------------------------------------------------
1683
-
1684
- //-Function name - iwp_mmb_get_file_size()
1685
- //-This is the alternate function to calculate file size
1686
- //-This function is introduced to support the filesize calculation for the files which are larger than 2048MB
1687
-
1688
- //----------------------------------------------------------------------
1689
-
1690
- if(!function_exists('iwp_mmb_get_file_size')){
1691
- function iwp_mmb_get_file_size($file)
1692
- {
1693
- clearstatcache();
1694
- $normal_file_size = filesize($file);
1695
- if(($normal_file_size !== false)&&($normal_file_size >= 0))
1696
- {
1697
- return $normal_file_size;
1698
- }
1699
- else
1700
- {
1701
- $file = realPath($file);
1702
- if(!$file)
1703
- {
1704
- echo 'iwp_mmb_get_file_size_error : realPath error';
1705
- }
1706
- $ch = curl_init("file://" . $file);
1707
- curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_FILE);
1708
- curl_setopt($ch, CURLOPT_NOBODY, true);
1709
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1710
- curl_setopt($ch, CURLOPT_HEADER, true);
1711
- $data = curl_exec($ch);
1712
- $curl_error = curl_error($ch);
1713
- curl_close($ch);
1714
- if ($data !== false && preg_match('/Content-Length: (\d+)/', $data, $matches)) {
1715
- return (string) $matches[1];
1716
- }
1717
- else
1718
- {
1719
- echo 'iwp_mmb_get_file_size_error : '.$curl_error;
1720
- return $normal_file_size;
1721
- }
1722
- }
1723
- }
1724
- }
1725
-
1726
- if( !function_exists('iwp_mmb_backup_test_site')){
1727
- function iwp_mmb_backup_test_site($params){
1728
- global $iwp_mmb_core,$iwp_mmb_plugin_dir;
1729
- $return = array();
1730
-
1731
- $iwp_mmb_core->get_backup_instance();
1732
- $return = $iwp_mmb_core->backup_instance->check_backup_compat($params);
1733
-
1734
- if (is_array($return) && array_key_exists('error', $return))
1735
- iwp_mmb_response($return, false);
1736
- else {
1737
- iwp_mmb_response($return, true);
1738
- }
1739
- }
1740
- }
1741
-
1742
- //add_action( 'plugins_loaded', 'iwp_mmb_create_backup_table' );
1743
-
1744
- //register_activation_hook( __FILE__, 'iwp_mmb_create_backup_table' );
1745
-
1746
- $iwp_mmb_core = new IWP_MMB_Core();
1747
- $mmb_core = 1;
1748
-
1749
- if(isset($_GET['auto_login']))
1750
- $iwp_mmb_core->automatic_login();
1751
-
1752
- if (function_exists('register_activation_hook'))
1753
- register_activation_hook( __FILE__ , array( $iwp_mmb_core, 'install' ));
1754
-
1755
- if (function_exists('register_deactivation_hook'))
1756
- register_deactivation_hook(__FILE__, array( $iwp_mmb_core, 'uninstall' ));
1757
-
1758
- if (function_exists('add_action'))
1759
- add_action('init', 'iwp_mmb_plugin_actions', 99999);
1760
-
1761
- if (function_exists('add_action'))
1762
- add_action('wp_head', 'iwp_mmb_check_maintenance', 99999);
1763
-
1764
- if (function_exists('add_action'))
1765
- add_action('wp_head', 'iwp_mmb_check_redirects', 99999);
1766
-
1767
- if (function_exists('add_filter'))
1768
- add_filter('install_plugin_complete_actions','iwp_mmb_iframe_plugins_fix');
1769
-
1770
- if( isset($_COOKIE[IWP_MMB_XFRAME_COOKIE]) ){
1771
- remove_action( 'admin_init', 'send_frame_options_header');
1772
- remove_action( 'login_init', 'send_frame_options_header');
1773
- }
1774
-
 
 
 
 
 
 
 
 
 
 
 
1775
  ?>
1
+ <?php
2
+ /*
3
+ Plugin Name: InfiniteWP - Client
4
+ Plugin URI: http://infinitewp.com/
5
+ Description: This is the client plugin of InfiniteWP that communicates with the InfiniteWP Admin panel.
6
+ Author: Revmakx
7
+ Version: 1.3.5
8
+ Author URI: http://www.revmakx.com
9
+ */
10
+ /************************************************************
11
+ * This plugin was modified by Revmakx *
12
+ * Copyright (c) 2012 Revmakx *
13
+ * www.revmakx.com *
14
+ * *
15
+ ************************************************************/
16
+
17
+ /*************************************************************
18
+ *
19
+ * init.php
20
+ *
21
+ * Initialize the communication with master
22
+ *
23
+ *
24
+ * Copyright (c) 2011 Prelovac Media
25
+ * www.prelovac.com
26
+ **************************************************************/
27
+
28
+ if(!defined('IWP_MMB_CLIENT_VERSION'))
29
+ define('IWP_MMB_CLIENT_VERSION', '1.3.5');
30
+
31
+
32
+
33
+ if ( !defined('IWP_MMB_XFRAME_COOKIE')){
34
+ $siteurl = function_exists('get_site_option') ? get_site_option( 'siteurl' ) : get_option('siteurl');
35
+ define('IWP_MMB_XFRAME_COOKIE', $xframe = 'wordpress_'.md5($siteurl).'_xframe');
36
+ }
37
+ global $wpdb, $iwp_mmb_plugin_dir, $iwp_mmb_plugin_url, $wp_version, $iwp_mmb_filters, $_iwp_mmb_item_filter;
38
+ if (version_compare(PHP_VERSION, '5.0.0', '<')) // min version 5 supported
39
+ exit("<p>InfiniteWP Client plugin requires PHP 5 or higher.</p>");
40
+
41
+
42
+ $iwp_mmb_wp_version = $wp_version;
43
+ $iwp_mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
44
+ $iwp_mmb_plugin_url = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__));
45
+
46
+ require_once("$iwp_mmb_plugin_dir/helper.class.php");
47
+ require_once("$iwp_mmb_plugin_dir/core.class.php");
48
+ require_once("$iwp_mmb_plugin_dir/stats.class.php");
49
+ //require_once("$iwp_mmb_plugin_dir/backup.class.php");
50
+ //require_once("$iwp_mmb_plugin_dir/backup.class.singlecall.php");
51
+ //require_once("$iwp_mmb_plugin_dir/backup.class.multicall.php");
52
+ require_once("$iwp_mmb_plugin_dir/installer.class.php");
53
+
54
+ require_once("$iwp_mmb_plugin_dir/addons/manage_users/user.class.php");
55
+ //require_once("$iwp_mmb_plugin_dir/addons/backup_repository/backup_repository.class.php");
56
+ require_once("$iwp_mmb_plugin_dir/addons/comments/comments.class.php");
57
+
58
+ require_once("$iwp_mmb_plugin_dir/addons/post_links/link.class.php");
59
+ require_once("$iwp_mmb_plugin_dir/addons/post_links/post.class.php");
60
+
61
+ require_once("$iwp_mmb_plugin_dir/addons/wp_optimize/optimize.class.php");
62
+
63
+ require_once("$iwp_mmb_plugin_dir/api.php");
64
+ require_once("$iwp_mmb_plugin_dir/plugins/search/search.php");
65
+ require_once("$iwp_mmb_plugin_dir/plugins/cleanup/cleanup.php");
66
+
67
+
68
+
69
+ if( !function_exists ( 'iwp_mmb_filter_params' )) {
70
+ function iwp_mmb_filter_params( $array = array() ){
71
+
72
+ $filter = array( 'current_user', 'wpdb' );
73
+ $return = array();
74
+ foreach ($array as $key => $val) {
75
+ if( !is_int($key) && in_array($key, $filter) )
76
+ continue;
77
+
78
+ if( is_array( $val ) ) {
79
+ $return[$key] = iwp_mmb_filter_params( $val );
80
+ } else {
81
+ $return[$key] = $val;
82
+ }
83
+ }
84
+
85
+ return $return;
86
+ }
87
+ }
88
+
89
+ if( !function_exists ('iwp_mmb_parse_request')) {
90
+ function iwp_mmb_parse_request()
91
+ {
92
+ if (!isset($HTTP_RAW_POST_DATA)) {
93
+ $HTTP_RAW_POST_DATA = file_get_contents('php://input');
94
+ }
95
+
96
+ ob_start();
97
+
98
+ global $current_user, $iwp_mmb_core, $new_actions, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache;
99
+ $data = base64_decode($HTTP_RAW_POST_DATA);
100
+ if ($data){
101
+ //$num = @extract(unserialize($data));
102
+ $unserialized_data = @unserialize($data);
103
+ if(isset($unserialized_data['params'])){
104
+ $unserialized_data['params'] = iwp_mmb_filter_params($unserialized_data['params']);
105
+ }
106
+
107
+ $iwp_action = $unserialized_data['iwp_action'];
108
+ $params = $unserialized_data['params'];
109
+ $id = $unserialized_data['id'];
110
+ $signature = $unserialized_data['signature'];
111
+ }
112
+
113
+ if (isset($iwp_action)) {
114
+
115
+ if(!defined('IWP_AUTHORISED_CALL')) define('IWP_AUTHORISED_CALL', 1);
116
+ if(function_exists('register_shutdown_function')){ register_shutdown_function("iwp_mmb_shutdown"); }
117
+ $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'] = microtime(1);
118
+
119
+ error_reporting(E_ALL ^ E_NOTICE);
120
+ @ini_set("display_errors", 1);
121
+
122
+ iwp_mmb_create_backup_table();
123
+
124
+ $action = $iwp_action;
125
+ $_wp_using_ext_object_cache = false;
126
+ @set_time_limit(600);
127
+
128
+ if (!$iwp_mmb_core->check_if_user_exists($params['username']))
129
+ iwp_mmb_response(array('error' => 'Username <b>' . $params['username'] . '</b> does not have administrative access. Enter the correct username in the site options.', 'error_code' => 'username_does_not_have_administrative_access'), false);
130
+
131
+ if ($action == 'add_site') {
132
+ iwp_mmb_add_site($params);
133
+ iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
134
+ }
135
+ if ($action == 'readd_site') {
136
+ $params['id'] = $id;
137
+ $params['signature'] = $signature;
138
+ iwp_mmb_readd_site($params);
139
+ iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
140
+ }
141
+ if ($action == 'maintain_site') {
142
+ iwp_mmb_maintain_site($params);
143
+ iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
144
+ }
145
+
146
+ $auth = $iwp_mmb_core->authenticate_message($action . $id, $signature, $id);
147
+ if ($auth === true) {
148
+ @ignore_user_abort(true);
149
+ $GLOBALS['IWP_CLIENT_HISTORY_ID'] = $id;
150
+
151
+ if(isset($params['username']) && !is_user_logged_in()){
152
+ $user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : get_userdatabylogin( $params['username'] );
153
+ wp_set_current_user($user->ID);
154
+ //For WPE
155
+ if(@getenv('IS_WPE'))
156
+ wp_set_auth_cookie($user->ID);
157
+ }
158
+
159
+ /* in case database upgrade required, do database backup and perform upgrade ( wordpress wp_upgrade() function ) */
160
+ if( strlen(trim($wp_db_version)) && !defined('ACX_PLUGIN_DIR') ){
161
+ if ( get_option('db_version') != $wp_db_version ) {
162
+ /* in multisite network, please update database manualy */
163
+ if (empty($wpmu_version) || (function_exists('is_multisite') && !is_multisite())){
164
+ if( ! function_exists('wp_upgrade'))
165
+ include_once(ABSPATH.'wp-admin/includes/upgrade.php');
166
+
167
+ ob_clean();
168
+ @wp_upgrade();
169
+ @do_action('after_db_upgrade');
170
+ ob_end_clean();
171
+ }
172
+ }
173
+ }
174
+
175
+ if(isset($params['secure'])){
176
+
177
+ if($decrypted = $iwp_mmb_core->_secure_data($params['secure'])){
178
+ $decrypted = maybe_unserialize($decrypted);
179
+ if(is_array($decrypted)){
180
+
181
+ foreach($decrypted as $key => $val){
182
+ if(!is_numeric($key))
183
+ $params[$key] = $val;
184
+
185
+ }
186
+ unset($params['secure']);
187
+ } else $params['secure'] = $decrypted;
188
+ }
189
+ elseif(isset($params['secure']['account_info'])){
190
+ $params['account_info'] = $params['secure']['account_info'];
191
+ }
192
+ }
193
+
194
+ if( !$iwp_mmb_core->register_action_params( $action, $params ) ){
195
+ global $_iwp_mmb_plugin_actions;
196
+ $_iwp_mmb_plugin_actions[$action] = $params;
197
+ }
198
+
199
+ } else {
200
+ iwp_mmb_response($auth, false);
201
+ }
202
+ } else {
203
+ //IWP_MMB_Stats::set_hit_count();
204
+ }
205
+ ob_end_clean();
206
+ }
207
+ }
208
+ /* Main response function */
209
+ if( !function_exists ( 'iwp_mmb_response' )) {
210
+
211
+ function iwp_mmb_response($response = false, $success = true)
212
+ {
213
+ $return = array();
214
+
215
+ if ((is_array($response) && empty($response)) || (!is_array($response) && strlen($response) == 0)){
216
+ $return['error'] = 'Empty response.';
217
+ $return['error_code'] = 'empty_response';
218
+ }
219
+ else if ($success){
220
+ $return['success'] = $response;
221
+ }
222
+ else{
223
+ $return['error'] = $response['error'];
224
+ $return['error_code'] = $response['error_code'];
225
+ }
226
+
227
+ if( !headers_sent() ){
228
+ header('HTTP/1.0 200 OK');
229
+ header('Content-Type: text/plain');
230
+ }
231
+ $GLOBALS['IWP_RESPONSE_SENT'] = true;
232
+ exit("<IWPHEADER>" . base64_encode(serialize($return))."<ENDIWPHEADER>");
233
+ }
234
+ }
235
+
236
+
237
+
238
+ if( !function_exists ( 'iwp_mmb_add_site' )) {
239
+ function iwp_mmb_add_site($params)
240
+ {
241
+ global $iwp_mmb_core;
242
+ $num = extract($params);
243
+
244
+ if ($num) {
245
+ if (!get_option('iwp_client_action_message_id') && !get_option('iwp_client_public_key')) {
246
+ $public_key = base64_decode($public_key);
247
+
248
+
249
+ if(trim($activation_key) != get_option('iwp_client_activate_key')){ //iwp
250
+ iwp_mmb_response(array('error' => 'Invalid activation key', 'error_code' => 'iwp_mmb_add_site_invalid_activation_key'), false);
251
+ return;
252
+ }
253
+
254
+ if (checkOpenSSL() && !$user_random_key_signing) {
255
+ $verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
256
+ if ($verify == 1) {
257
+ $iwp_mmb_core->set_admin_panel_public_key($public_key);
258
+ $iwp_mmb_core->set_client_message_id($id);
259
+ $iwp_mmb_core->get_stats_instance();
260
+ if(isset($notifications) && is_array($notifications) && !empty($notifications)){
261
+ $iwp_mmb_core->stats_instance->set_notifications($notifications);
262
+ }
263
+ if(isset($brand) && is_array($brand) && !empty($brand)){
264
+ update_option('iwp_client_brand',$brand);
265
+ }
266
+
267
+ iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
268
+ delete_option('iwp_client_activate_key');//iwp
269
+ } else if ($verify == 0) {
270
+ iwp_mmb_response(array('error' => 'Invalid message signature. Please contact us if you see this message often.', 'error_code' => 'iwp_mmb_add_site_invalid_message_signature'), false);
271
+ } else {
272
+ iwp_mmb_response(array('error' => 'Command not successful. Please try again.', 'error_code' => 'iwp_mmb_add_site_command_not_successful'), false);
273
+ }
274
+ } else {
275
+ if (!get_option('iwp_client_nossl_key')) {
276
+ srand();
277
+
278
+ $random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
279
+
280
+ $iwp_mmb_core->set_random_signature($random_key);
281
+ $iwp_mmb_core->set_client_message_id($id);
282
+ $iwp_mmb_core->set_admin_panel_public_key($public_key);
283
+ $iwp_mmb_core->get_stats_instance();
284
+ if(is_array($notifications) && !empty($notifications)){
285
+ $iwp_mmb_core->stats_instance->set_notifications($notifications);
286
+ }
287
+
288
+ if(is_array($brand) && !empty($brand)){
289
+ update_option('iwp_client_brand',$brand);
290
+ }
291
+
292
+ iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
293
+ delete_option('iwp_client_activate_key');//IWP
294
+ } else
295
+ iwp_mmb_response(array('error' => 'Please deactivate & activate InfiniteWP Client plugin on your site, then add the site again.', 'error_code' => 'deactivate_ctivate_InfiniteWP_Client_plugin_add_site_again_not_iwp_client_nossl_key'), false);
296
+ }
297
+ } else {
298
+ iwp_mmb_response(array('error' => 'Please deactivate &amp; activate InfiniteWP Client plugin on your site, then add the site again.', 'error_code' => 'deactivate_ctivate_InfiniteWP_Client_plugin_add_site_again_not_iwp_client_nossl_key'), false);
299
+ }
300
+ } else {
301
+ iwp_mmb_response(array('error' => 'Invalid parameters received. Please try again.', 'error_code' => 'iwp_mmb_add_site_invalid_parameters_received'), false);
302
+ }
303
+ }
304
+ }
305
+
306
+ if( !function_exists ( 'iwp_mmb_readd_site' )) {
307
+ function iwp_mmb_readd_site($params){
308
+ global $iwp_mmb_core;
309
+ $num = extract($params);
310
+ if ($num) {
311
+ if (!get_option('iwp_client_action_message_id') && !get_option('iwp_client_public_key')) {
312
+ $public_key = base64_decode($public_key);
313
+ if(trim($activation_key) != get_option('iwp_client_activate_key')){ //iwp
314
+ iwp_mmb_response(array('error' => 'Invalid activation key', 'error_code' => 'iwp_mmb_readd_site_invalid_activation_key'), false);
315
+ return;
316
+ }
317
+ if (checkOpenSSL() && !$user_random_key_signing) {
318
+
319
+ $verify = openssl_verify($action . $id, $signature, $public_key);
320
+ if ($verify == 1) {
321
+ $iwp_mmb_core->set_admin_panel_public_key($public_key);
322
+ $iwp_mmb_core->set_client_message_id($id);
323
+ $iwp_mmb_core->get_stats_instance();
324
+ if(isset($notifications) && is_array($notifications) && !empty($notifications)){
325
+ $iwp_mmb_core->stats_instance->set_notifications($notifications);
326
+ }
327
+ if(isset($brand) && is_array($brand) && !empty($brand)){
328
+ update_option('iwp_client_brand',$brand);
329
+ }
330
+ iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
331
+ delete_option('iwp_client_activate_key');//iwp
332
+ } else if ($verify == 0) {
333
+ iwp_mmb_response(array('error' => 'Invalid message signature. Please contact us if you see this message often.', 'error_code' => 'iwp_mmb_readd_site_invalid_message_signature'), false);
334
+ } else {
335
+ iwp_mmb_response(array('error' => 'Command not successful. Please try again.', 'error_code' => 'iwp_mmb_readd_site_command_not_successful'), false);
336
+ }
337
+ } else {
338
+ if (!get_option('iwp_client_nossl_key')) {
339
+ srand();
340
+
341
+ $random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
342
+
343
+ $iwp_mmb_core->set_random_signature($random_key);
344
+ $iwp_mmb_core->set_client_message_id($id);
345
+ $iwp_mmb_core->set_admin_panel_public_key($public_key);
346
+ $iwp_mmb_core->get_stats_instance();
347
+ if(is_array($notifications) && !empty($notifications)){
348
+ $iwp_mmb_core->stats_instance->set_notifications($notifications);
349
+ }
350
+
351
+ if(is_array($brand) && !empty($brand)){
352
+ update_option('iwp_client_brand',$brand);
353
+ }
354
+
355
+ iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
356
+ delete_option('iwp_client_activate_key');//IWP
357
+ } else
358
+ iwp_mmb_response(array('error' => 'Please deactivate & activate InfiniteWP Client plugin on your site, then add the site again.', 'error_code' => 'deactivate_ctivate_InfiniteWP_Client_plugin_add_site_again_not_iwp_client_nossl_key'), false);
359
+ }
360
+ } else {
361
+ iwp_mmb_response(array('error' => 'Please deactivate &amp; activate InfiniteWP Client plugin on your site, then add the site again.', 'error_code' => 'deactivate_ctivate_InfiniteWP_Client_plugin_add_site_again_not_iwp_client_nossl_key'), false);
362
+ }
363
+ } else {
364
+ iwp_mmb_response(array('error' => 'Invalid parameters received. Please try again.', 'error_code' => 'iwp_mmb_add_site_invalid_parameters_received'), false);
365
+ }
366
+ }
367
+ }
368
+
369
+ if(!function_exists('iwp_mmb_maintain_site')){
370
+ function iwp_mmb_maintain_site($params){
371
+ $check = 1;
372
+ if(get_option('iwp_mmb_maintenance_mode') != $params['maintenance_mode'])
373
+ if(update_option('iwp_mmb_maintenance_mode',$params['maintenance_mode']) ){ $check = 1;}else{$check = 0;}
374
+ if(get_option('iwp_mmb_maintenance_html') != $params['maintenance_html'])
375
+ if(update_option('iwp_mmb_maintenance_html',$params['maintenance_html']) ){ $check = 1;}else{$check = 0;}
376
+ if($check == 1){
377
+ iwp_mmb_response($params, true);
378
+ }else{
379
+ iwp_mmb_response(array('error' => 'Some error with database connection in client site', 'error_code' => 'database_connection_in_client_site'), false);
380
+ }
381
+ }
382
+ }
383
+
384
+
385
+ if( !function_exists ( 'iwp_mmb_remove_site' )) {
386
+ function iwp_mmb_remove_site($params)
387
+ {
388
+ extract($params);
389
+ global $iwp_mmb_core;
390
+ $iwp_mmb_core->uninstall( $deactivate );
391
+
392
+ include_once(ABSPATH . 'wp-admin/includes/plugin.php');
393
+ $plugin_slug = basename(dirname(__FILE__)) . '/' . basename(__FILE__);
394
+
395
+ if ($deactivate) {
396
+ deactivate_plugins($plugin_slug, true);
397
+ }
398
+
399
+ if (!is_plugin_active($plugin_slug))
400
+ iwp_mmb_response(array(
401
+ 'deactivated' => 'Site removed successfully. <br /><br />InfiniteWP Client plugin successfully deactivated.'
402
+ ), true);
403
+ else
404
+ iwp_mmb_response(array(
405
+ 'removed_data' => 'Site removed successfully. <br /><br /><b>InfiniteWP Client plugin was not deactivated.</b>'
406
+ ), true);
407
+
408
+ }
409
+ }
410
+ if( !function_exists ( 'iwp_mmb_stats_get' )) {
411
+ function iwp_mmb_stats_get($params)
412
+ {
413
+ global $iwp_mmb_core;
414
+ $iwp_mmb_core->get_stats_instance();
415
+ iwp_mmb_response($iwp_mmb_core->stats_instance->get($params), true);
416
+ }
417
+ }
418
+
419
+ if( !function_exists ( 'iwp_mmb_client_header' )) {
420
+ function iwp_mmb_client_header()
421
+ { global $iwp_mmb_core, $current_user;
422
+
423
+ if(!headers_sent()){
424
+ if(isset($current_user->ID))
425
+ $expiration = time() + apply_filters('auth_cookie_expiration', 10800, $current_user->ID, false);
426
+ else
427
+ $expiration = time() + 10800;
428
+
429
+ setcookie(IWP_MMB_XFRAME_COOKIE, md5(IWP_MMB_XFRAME_COOKIE), $expiration, COOKIEPATH, COOKIE_DOMAIN, false, true);
430
+ $_COOKIE[IWP_MMB_XFRAME_COOKIE] = md5(IWP_MMB_XFRAME_COOKIE);
431
+ }
432
+ }
433
+ }
434
+
435
+ if( !function_exists ( 'iwp_mmb_pre_init_stats' )) {
436
+ function iwp_mmb_pre_init_stats( $params )
437
+ {
438
+ global $iwp_mmb_core;
439
+ $iwp_mmb_core->get_stats_instance();
440
+ return $iwp_mmb_core->stats_instance->pre_init_stats($params);
441
+ }
442
+ }
443
+
444
+ if( !function_exists ( 'iwp_mmb_trigger_check' )) {
445
+ //backup multi call trigger and status check.
446
+ function iwp_mmb_trigger_check($params)
447
+ {
448
+ global $iwp_mmb_core;
449
+ $iwp_mmb_core->get_backup_instance($params['mechanism']);
450
+ $return = $iwp_mmb_core->backup_instance->trigger_check($params);
451
+
452
+ if (is_array($return) && array_key_exists('error', $return))
453
+ iwp_mmb_response($return, false);
454
+ else {
455
+ iwp_mmb_response($return, true);
456
+ }
457
+ }
458
+ }
459
+
460
+
461
+ if( !function_exists ( 'iwp_mmb_backup_now' )) {
462
+ //backup
463
+ function iwp_mmb_backup_now($params)
464
+ {
465
+ global $iwp_mmb_core;
466
+
467
+ $iwp_mmb_core->get_backup_instance();
468
+ $return = $iwp_mmb_core->backup_instance->backup($params);
469
+
470
+ if (is_array($return) && array_key_exists('error', $return))
471
+ iwp_mmb_response($return, false);
472
+ else {
473
+ iwp_mmb_response($return, true);
474
+ }
475
+ }
476
+ }
477
+
478
+ if( !function_exists ( 'iwp_mmb_run_task_now' )) {
479
+ function iwp_mmb_run_task_now($params)
480
+ {
481
+ global $iwp_mmb_core;
482
+ $iwp_mmb_core->get_backup_instance($params['mechanism']);
483
+ //$return = $iwp_mmb_core->backup_instance->task_now(); //set_backup_task($params)
484
+ $return = $iwp_mmb_core->backup_instance->set_backup_task($params);
485
+ if (is_array($return) && array_key_exists('error', $return))
486
+ iwp_mmb_response($return, false);
487
+ else {
488
+ iwp_mmb_response($return, true);
489
+ }
490
+ }
491
+ }
492
+
493
+ if( !function_exists ( 'iwp_mmb_delete_task_now' )) {
494
+ function iwp_mmb_delete_task_now($params)
495
+ {
496
+ global $iwp_mmb_core;
497
+ $iwp_mmb_core->get_backup_instance();
498
+ $return = $iwp_mmb_core->backup_instance->delete_task_now($params['task_name']);
499
+ if (is_array($return) && array_key_exists('error', $return))
500
+ iwp_mmb_response($return, false);
501
+ else {
502
+ iwp_mmb_response($return, true);
503
+ }
504
+ }
505
+ }
506
+ if( !function_exists ( 'iwp_mmb_check_backup_compat' )) {
507
+ function iwp_mmb_check_backup_compat($params)
508
+ {
509
+ global $iwp_mmb_core;
510
+ $iwp_mmb_core->get_backup_instance();
511
+ $return = $iwp_mmb_core->backup_instance->check_backup_compat($params);
512
+
513
+ if (is_array($return) && array_key_exists('error', $return))
514
+ iwp_mmb_response($return, false);
515
+ else {
516
+ iwp_mmb_response($return, true);
517
+ }
518
+ }
519
+ }
520
+
521
+ if( !function_exists ( 'iwp_mmb_get_backup_req' )) {
522
+ function iwp_mmb_get_backup_req( $params )
523
+ {
524
+ global $iwp_mmb_core;
525
+ $iwp_mmb_core->get_stats_instance();
526
+ $return = $iwp_mmb_core->stats_instance->get_backup_req($params);
527
+
528
+ if (is_array($return) && array_key_exists('error', $return))
529
+ iwp_mmb_response($return, false);
530
+ else {
531
+ iwp_mmb_response($return, true);
532
+ }
533
+ }
534
+ }
535
+
536
+
537
+ if( !function_exists ( 'iwp_mmb_scheduled_backup' )) {
538
+ function iwp_mmb_scheduled_backup($params)
539
+ {
540
+ global $iwp_mmb_core;
541
+
542
+ $iwp_mmb_core->get_backup_instance($params['mechanism']);
543
+ $return = $iwp_mmb_core->backup_instance->set_backup_task($params);
544
+ iwp_mmb_response($return, $return);
545
+ }
546
+ }
547
+
548
+
549
+ if( !function_exists ( 'iwp_mmb_delete_backup' )) {
550
+ function iwp_mmb_delete_backup($params)
551
+ {
552
+ global $iwp_mmb_core;
553
+ $iwp_mmb_core->get_backup_instance();
554
+ $return = $iwp_mmb_core->backup_instance->delete_backup($params);
555
+ iwp_mmb_response($return, $return);
556
+ }
557
+ }
558
+
559
+ if( !function_exists ( 'iwp_mmb_optimize_tables' )) {
560
+ function iwp_mmb_optimize_tables($params)
561
+ {
562
+ global $iwp_mmb_core;
563
+ $iwp_mmb_core->get_backup_instance();
564
+ $return = $iwp_mmb_core->backup_instance->optimize_tables();
565
+ if ($return)
566
+ iwp_mmb_response($return, true);
567
+ else
568
+ iwp_mmb_response(false, false);
569
+ }
570
+ }
571
+ if( !function_exists ( 'iwp_mmb_restore_now' )) {
572
+ function iwp_mmb_restore_now($params)
573
+ {
574
+ global $iwp_mmb_core;
575
+ $iwp_mmb_core->get_backup_instance('multiCall');
576
+ $return = $iwp_mmb_core->backup_instance->restore($params);
577
+
578
+ if (is_array($return) && array_key_exists('error', $return))
579
+ iwp_mmb_response($return, false);
580
+ else
581
+ iwp_mmb_response($return, true);
582
+
583
+ }
584
+ }
585
+
586
+
587
+ if( !function_exists ( 'iwp_mmb_backup_repository' )) {
588
+ function iwp_mmb_backup_repository($params)
589
+ {
590
+ global $iwp_mmb_core;
591
+ $iwp_mmb_core->get_backup_repository_instance();
592
+ $return = $iwp_mmb_core->backup_repository_instance->backup_repository($params);
593
+ if (is_array($return) && array_key_exists('error', $return))
594
+ iwp_mmb_response($return, false);
595
+ else
596
+ iwp_mmb_response($return, true);
597
+ }
598
+ }
599
+
600
+
601
+ if( !function_exists ( 'iwp_mmb_clean_orphan_backups' )) {
602
+ function iwp_mmb_clean_orphan_backups()
603
+ {
604
+ global $iwp_mmb_core;
605
+ $backup_instance = $iwp_mmb_core->get_backup_instance();
606
+ $return = $iwp_mmb_core->backup_instance->cleanup();
607
+ if(is_array($return))
608
+ iwp_mmb_response($return, true);
609
+ else
610
+ iwp_mmb_response($return, false);
611
+ }
612
+ }
613
+
614
+
615
+
616
+ add_filter( 'iwp_website_add', 'iwp_mmb_readd_backup_task' );
617
+
618
+ if (!function_exists('iwp_mmb_readd_backup_task')) {
619
+ function iwp_mmb_readd_backup_task($params = array()) {
620
+ global $iwp_mmb_core;
621
+ $backup_instance = $iwp_mmb_core->get_backup_instance();
622
+ $settings = $backup_instance->readd_tasks($params);
623
+ return $settings;
624
+ }
625
+ }
626
+
627
+ if( !function_exists ( 'iwp_mmb_update_client_plugin' )) {
628
+ function iwp_mmb_update_client_plugin($params)
629
+ {
630
+ global $iwp_mmb_core;
631
+ iwp_mmb_response($iwp_mmb_core->update_client_plugin($params), true);
632
+ }
633
+ }
634
+
635
+ if( !function_exists ( 'iwp_mmb_wp_checkversion' )) {
636
+ function iwp_mmb_wp_checkversion($params)
637
+ {
638
+ include_once(ABSPATH . 'wp-includes/version.php');
639
+ global $iwp_mmb_wp_version, $iwp_mmb_core;
640
+ iwp_mmb_response($iwp_mmb_wp_version, true);
641
+ }
642
+ }
643
+ if( !function_exists ( 'iwp_mmb_search_posts_by_term' )) {
644
+ function iwp_mmb_search_posts_by_term($params)
645
+ {
646
+ global $iwp_mmb_core;
647
+ $iwp_mmb_core->get_search_instance();
648
+
649
+ $search_type = trim($params['search_type']);
650
+ $search_term = strtolower(trim($params['search_term']));
651
+
652
+ switch ($search_type){
653
+ case 'plugin':
654
+ $plugins = get_option('active_plugins');
655
+
656
+ $have_plugin = false;
657
+ foreach ($plugins as $plugin) {
658
+ if(strpos($plugin, $search_term)>-1){
659
+ $have_plugin = true;
660
+ }
661
+ }
662
+ if($have_plugin){
663
+ iwp_mmb_response(serialize($plugin), true);
664
+ }else{
665
+ iwp_mmb_response(false, false);
666
+ }
667
+ break;
668
+ case 'theme':
669
+ $theme = strtolower(get_option('template'));
670
+ if(strpos($theme, $search_term)>-1){
671
+ iwp_mmb_response($theme, true);
672
+ }else{
673
+ iwp_mmb_response(false, false);
674
+ }
675
+ break;
676
+ default: iwp_mmb_response(false, false);
677
+ }
678
+ $return = $iwp_mmb_core->search_instance->iwp_mmb_search_posts_by_term($params);
679
+
680
+
681
+
682
+ if ($return_if_true) {
683
+ iwp_mmb_response($return_value, true);
684
+ } else {
685
+ iwp_mmb_response($return_if_false, false);
686
+ }
687
+ }
688
+ }
689
+
690
+ if( !function_exists ( 'iwp_mmb_install_addon' )) {
691
+ function iwp_mmb_install_addon($params)
692
+ {
693
+ global $iwp_mmb_core;
694
+ $iwp_mmb_core->get_installer_instance();
695
+ $return = $iwp_mmb_core->installer_instance->install_remote_file($params);
696
+ iwp_mmb_response($return, true);
697
+
698
+ }
699
+ }
700
+
701
+ if( !function_exists ( 'iwp_mmb_do_upgrade' )) {
702
+ function iwp_mmb_do_upgrade($params)
703
+ {
704
+ global $iwp_mmb_core, $iwp_mmb_upgrading;
705
+ $iwp_mmb_core->get_installer_instance();
706
+ $return = $iwp_mmb_core->installer_instance->do_upgrade($params);
707
+ iwp_mmb_response($return, true);
708
+
709
+ }
710
+ }
711
+
712
+ if( !function_exists ( 'iwp_mmb_add_user' )) {
713
+ function iwp_mmb_add_user($params)
714
+ {
715
+ global $iwp_mmb_core;
716
+ $iwp_mmb_core->get_user_instance();
717
+ $return = $iwp_mmb_core->user_instance->add_user($params);
718
+ if (is_array($return) && array_key_exists('error', $return)){
719
+ iwp_mmb_response($return, false);
720
+ }
721
+ else {
722
+ iwp_mmb_response($return, true);
723
+ }
724
+
725
+ }
726
+ }
727
+
728
+ if( !function_exists ('iwp_mmb_get_users')) {
729
+ function iwp_mmb_get_users($params)
730
+ {
731
+ global $iwp_mmb_core;
732
+ $iwp_mmb_core->get_user_instance();
733
+ $return = $iwp_mmb_core->user_instance->get_users($params);
734
+ if (is_array($return) && array_key_exists('error', $return))
735
+ iwp_mmb_response($return, false);
736
+ else {
737
+ iwp_mmb_response($return, true);
738
+ }
739
+ }
740
+ }
741
+
742
+ if( !function_exists ('iwp_mmb_edit_users')) {
743
+ function iwp_mmb_edit_users($params)
744
+ {
745
+ global $iwp_mmb_core;
746
+ $iwp_mmb_core->get_user_instance();
747
+ $return = $iwp_mmb_core->user_instance->edit_users($params);
748
+ iwp_mmb_response($return, true);
749
+ }
750
+ }
751
+
752
+ if( !function_exists ( 'iwp_mmb_iframe_plugins_fix' )) {
753
+ function iwp_mmb_iframe_plugins_fix($update_actions)
754
+ {
755
+ foreach($update_actions as $key => $action)
756
+ {
757
+ $update_actions[$key] = str_replace('target="_parent"','',$action);
758
+ }
759
+
760
+ return $update_actions;
761
+
762
+ }
763
+ }
764
+
765
+ if( !function_exists ( 'iwp_mmb_set_notifications' )) {
766
+ function iwp_mmb_set_notifications($params)
767
+ {
768
+ global $iwp_mmb_core;
769
+ $iwp_mmb_core->get_stats_instance();
770
+ $return = $iwp_mmb_core->stats_instance->set_notifications($params);
771
+ if (is_array($return) && array_key_exists('error', $return))
772
+ iwp_mmb_response($return, false);
773
+ else {
774
+ iwp_mmb_response($return, true);
775
+ }
776
+
777
+ }
778
+ }
779
+
780
+ if( !function_exists ( 'iwp_mmb_set_alerts' )) {
781
+ function iwp_mmb_set_alerts($params)
782
+ {
783
+ global $iwp_mmb_core;
784
+ $iwp_mmb_core->get_stats_instance();
785
+ $return = $iwp_mmb_core->stats_instance->set_alerts($params);
786
+ iwp_mmb_response(true, true);
787
+ }
788
+ }
789
+
790
+ /*
791
+ if(!function_exists('iwp_mmb_more_reccurences')){
792
+ //Backup Tasks
793
+ add_filter('cron_schedules', 'iwp_mmb_more_reccurences');
794
+ function iwp_mmb_more_reccurences($schedules) {
795
+ $schedules['halfminute'] = array('interval' => 30, 'display' => 'Once in a half minute');
796
+ $schedules['minutely'] = array('interval' => 60, 'display' => 'Once in a minute');
797
+ $schedules['fiveminutes'] = array('interval' => 300, 'display' => 'Once every five minutes');
798
+ $schedules['tenminutes'] = array('interval' => 600, 'display' => 'Once every ten minutes');
799
+
800
+ return $schedules;
801
+ }
802
+ }
803
+
804
+ add_action('iwp_client_backup_tasks', 'iwp_client_check_backup_tasks');
805
+
806
+ if( !function_exists('iwp_client_check_backup_tasks') ){
807
+ function iwp_client_check_backup_tasks() {
808
+ global $iwp_mmb_core, $_wp_using_ext_object_cache;
809
+ $_wp_using_ext_object_cache = false;
810
+
811
+ $iwp_mmb_core->get_backup_instance();
812
+ $iwp_mmb_core->backup_instance->check_backup_tasks();
813
+ }
814
+ }
815
+ */
816
+
817
+ if( !function_exists('iwp_check_notifications') ){
818
+ function iwp_check_notifications() {
819
+ global $iwp_mmb_core, $_wp_using_ext_object_cache;
820
+ $_wp_using_ext_object_cache = false;
821
+
822
+ $iwp_mmb_core->get_stats_instance();
823
+ $iwp_mmb_core->stats_instance->check_notifications();
824
+ }
825
+ }
826
+
827
+
828
+ if( !function_exists('iwp_mmb_get_plugins_themes') ){
829
+ function iwp_mmb_get_plugins_themes($params) {
830
+ global $iwp_mmb_core;
831
+ $iwp_mmb_core->get_installer_instance();
832
+ $return = $iwp_mmb_core->installer_instance->get($params);
833
+ iwp_mmb_response($return, true);
834
+ }
835
+ }
836
+
837
+ if( !function_exists('iwp_mmb_edit_plugins_themes') ){
838
+ function iwp_mmb_edit_plugins_themes($params) {
839
+ global $iwp_mmb_core;
840
+ $iwp_mmb_core->get_installer_instance();
841
+ $return = $iwp_mmb_core->installer_instance->edit($params);
842
+ iwp_mmb_response($return, true);
843
+ }
844
+ }
845
+
846
+ //post
847
+ if( !function_exists ( 'iwp_mmb_post_create' )) {
848
+ function iwp_mmb_post_create($params)
849
+ {
850
+ global $iwp_mmb_core;
851
+ $iwp_mmb_core->get_post_instance();
852
+ $return = $iwp_mmb_core->post_instance->create($params);
853
+ if (is_int($return))
854
+ iwp_mmb_response($return, true);
855
+ else{
856
+ if(isset($return['error'])){
857
+ iwp_mmb_response($return, false);
858
+ } else {
859
+ iwp_mmb_response($return, false);
860
+ }
861
+ }
862
+ }
863
+ }
864
+
865
+ if( !function_exists ( 'iwp_mmb_change_post_status' )) {
866
+ function iwp_mmb_change_post_status($params)
867
+ {
868
+ global $iwp_mmb_core;
869
+ $iwp_mmb_core->get_post_instance();
870
+ $return = $iwp_mmb_core->post_instance->change_status($params);
871
+ //mmb_response($return, true);
872
+
873
+ }
874
+ }
875
+
876
+ if( !function_exists ('iwp_mmb_get_posts')) {
877
+ function iwp_mmb_get_posts($params)
878
+ {
879
+ global $iwp_mmb_core;
880
+ $iwp_mmb_core->get_post_instance();
881
+
882
+ $return = $iwp_mmb_core->post_instance->get_posts($params);
883
+ if (is_array($return) && array_key_exists('error', $return))
884
+ iwp_mmb_response($return, false);
885
+ else {
886
+ iwp_mmb_response($return, true);
887
+ }
888
+ }
889
+ }
890
+
891
+ if( !function_exists ('iwp_mmb_delete_post')) {
892
+ function iwp_mmb_delete_post($params)
893
+ {
894
+ global $iwp_mmb_core;
895
+ $iwp_mmb_core->get_post_instance();
896
+
897
+ $return = $iwp_mmb_core->post_instance->delete_post($params);
898
+ if (is_array($return) && array_key_exists('error', $return))
899
+ iwp_mmb_response($return, false);
900
+ else {
901
+ iwp_mmb_response($return, true);
902
+ }
903
+ }
904
+ }
905
+
906
+ if( !function_exists ('iwp_mmb_delete_posts')) {
907
+ function iwp_mmb_delete_posts($params)
908
+ {
909
+ global $iwp_mmb_core;
910
+ $iwp_mmb_core->get_post_instance();
911
+
912
+ $return = $iwp_mmb_core->post_instance->delete_posts($params);
913
+ if (is_array($return) && array_key_exists('error', $return))
914
+ iwp_mmb_response($return, false);
915
+ else {
916
+ iwp_mmb_response($return, true);
917
+ }
918
+ }
919
+ }
920
+
921
+ if( !function_exists ('iwp_mmb_edit_posts')) {
922
+ function iwp_mmb_edit_posts($params)
923
+ {
924
+ global $iwp_mmb_core;
925
+ $iwp_mmb_core->get_posts_instance();
926
+ $return = $iwp_mmb_core->posts_instance->edit_posts($params);
927
+ iwp_mmb_response($return, true);
928
+ }
929
+ }
930
+
931
+ if( !function_exists ('iwp_mmb_get_pages')) {
932
+ function iwp_mmb_get_pages($params)
933
+ {
934
+ global $iwp_mmb_core;
935
+ $iwp_mmb_core->get_post_instance();
936
+
937
+ $return = $iwp_mmb_core->post_instance->get_pages($params);
938
+ if (is_array($return) && array_key_exists('error', $return))
939
+ iwp_mmb_response($return, false);
940
+ else {
941
+ iwp_mmb_response($return, true);
942
+ }
943
+ }
944
+ }
945
+
946
+ if( !function_exists ('iwp_mmb_delete_page')) {
947
+ function iwp_mmb_delete_page($params)
948
+ {
949
+ global $iwp_mmb_core;
950
+ $iwp_mmb_core->get_post_instance();
951
+
952
+ $return = $iwp_mmb_core->post_instance->delete_page($params);
953
+ if (is_array($return) && array_key_exists('error', $return))
954
+ iwp_mmb_response($return, false);
955
+ else {
956
+ iwp_mmb_response($return, true);
957
+ }
958
+ }
959
+ }
960
+
961
+
962
+ //links
963
+ if( !function_exists ('iwp_mmb_get_links')) {
964
+ function iwp_mmb_get_links($params)
965
+ {
966
+ global $iwp_mmb_core;
967
+ $iwp_mmb_core->get_link_instance();
968
+ $return = $iwp_mmb_core->link_instance->get_links($params);
969
+ if (is_array($return) && array_key_exists('error', $return))
970
+ iwp_mmb_response($return, false);
971
+ else {
972
+ iwp_mmb_response($return, true);
973
+ }
974
+ }
975
+ }
976
+
977
+ if( !function_exists ( 'iwp_mmb_add_link' )) {
978
+ function iwp_mmb_add_link($params)
979
+ {
980
+ global $iwp_mmb_core;
981
+ $iwp_mmb_core->get_link_instance();
982
+ $return = $iwp_mmb_core->link_instance->add_link($params);
983
+ if (is_array($return) && array_key_exists('error', $return)){
984
+ iwp_mmb_response($return, false);
985
+ }
986
+ else {
987
+ iwp_mmb_response($return, true);
988
+ }
989
+
990
+ }
991
+ }
992
+
993
+ if( !function_exists ('iwp_mmb_delete_link')) {
994
+ function iwp_mmb_delete_link($params)
995
+ {
996
+ global $iwp_mmb_core;
997
+ $iwp_mmb_core->get_link_instance();
998
+
999
+ $return = $iwp_mmb_core->link_instance->delete_link($params);
1000
+ if (is_array($return) && array_key_exists('error', $return)){
1001
+ iwp_mmb_response($return, false);
1002
+ }
1003
+ else {
1004
+ iwp_mmb_response($return, true);
1005
+ }
1006
+ }
1007
+ }
1008
+
1009
+ if( !function_exists ('iwp_mmb_delete_links')) {
1010
+ function iwp_mmb_delete_links($params)
1011
+ {
1012
+ global $iwp_mmb_core;
1013
+ $iwp_mmb_core->get_link_instance();
1014
+
1015
+ $return = $iwp_mmb_core->link_instance->delete_links($params);
1016
+ if (is_array($return) && array_key_exists('error', $return)){
1017
+ iwp_mmb_response($return, false);
1018
+ }
1019
+ else {
1020
+ iwp_mmb_response($return, true);
1021
+ }
1022
+ }
1023
+ }
1024
+
1025
+
1026
+ //comments
1027
+ if( !function_exists ( 'iwp_mmb_change_comment_status' )) {
1028
+ function iwp_mmb_change_comment_status($params)
1029
+ {
1030
+ global $iwp_mmb_core;
1031
+ $iwp_mmb_core->get_comment_instance();
1032
+ $return = $iwp_mmb_core->comment_instance->change_status($params);
1033
+ //mmb_response($return, true);
1034
+ if ($return){
1035
+ $iwp_mmb_core->get_stats_instance();
1036
+ iwp_mmb_response($iwp_mmb_core->stats_instance->get_comments_stats($params), true);
1037
+ }else
1038
+ iwp_mmb_response(array('error' => 'Comment not updated', 'error_code' => 'comment_not_updated'), false);
1039
+ }
1040
+
1041
+ }
1042
+ if( !function_exists ( 'iwp_mmb_comment_stats_get' )) {
1043
+ function iwp_mmb_comment_stats_get($params)
1044
+ {
1045
+ global $iwp_mmb_core;
1046
+ $iwp_mmb_core->get_stats_instance();
1047
+ iwp_mmb_response($iwp_mmb_core->stats_instance->get_comments_stats($params), true);
1048
+ }
1049
+ }
1050
+
1051
+ if( !function_exists ('iwp_mmb_get_comments')) {
1052
+ function iwp_mmb_get_comments($params)
1053
+ {
1054
+ global $iwp_mmb_core;
1055
+ $iwp_mmb_core->get_comment_instance();
1056
+ $return = $iwp_mmb_core->comment_instance->get_comments($params);
1057
+ if (is_array($return) && array_key_exists('error', $return))
1058
+ iwp_mmb_response($return, false);
1059
+ else {
1060
+ iwp_mmb_response($return, true);
1061
+ }
1062
+ }
1063
+ }
1064
+
1065
+ if( !function_exists ('iwp_mmb_action_comment')) {
1066
+ function iwp_mmb_action_comment($params)
1067
+ {
1068
+ global $iwp_mmb_core;
1069
+ $iwp_mmb_core->get_comment_instance();
1070
+
1071
+ $return = $iwp_mmb_core->comment_instance->action_comment($params);
1072
+ if (is_array($return) && array_key_exists('error', $return))
1073
+ iwp_mmb_response($return, false);
1074
+ else {
1075
+ iwp_mmb_response($return, true);
1076
+ }
1077
+ }
1078
+ }
1079
+
1080
+ if( !function_exists ('iwp_mmb_bulk_action_comments')) {
1081
+ function iwp_mmb_bulk_action_comments($params)
1082
+ {
1083
+ global $iwp_mmb_core;
1084
+ $iwp_mmb_core->get_comment_instance();
1085
+
1086
+ $return = $iwp_mmb_core->comment_instance->bulk_action_comments($params);
1087
+ if (is_array($return) && array_key_exists('error', $return))
1088
+ iwp_mmb_response($return, false);
1089
+ else {
1090
+ iwp_mmb_response($return, true);
1091
+ }
1092
+ }
1093
+ }
1094
+
1095
+ if( !function_exists ('iwp_mmb_reply_comment')) {
1096
+ function iwp_mmb_reply_comment($params)
1097
+ {
1098
+ global $iwp_mmb_core;
1099
+ $iwp_mmb_core->get_comment_instance();
1100
+
1101
+ $return = $iwp_mmb_core->comment_instance->reply_comment($params);
1102
+ if (is_array($return) && array_key_exists('error', $return))
1103
+ iwp_mmb_response($return, false);
1104
+ else {
1105
+ iwp_mmb_response($return, true);
1106
+ }
1107
+ }
1108
+ }
1109
+
1110
+ //Comments-End-
1111
+
1112
+ //WP-Optimize
1113
+
1114
+ if( !function_exists('iwp_mmb_wp_optimize')){
1115
+ function iwp_mmb_wp_optimize($params){
1116
+ global $iwp_mmb_core;
1117
+ $iwp_mmb_core->wp_optimize_instance();
1118
+
1119
+ $return = $iwp_mmb_core->optimize_instance->cleanup_system($params);
1120
+ if (is_array($return) && array_key_exists('error', $return))
1121
+ iwp_mmb_response($return, false);
1122
+ else {
1123
+ iwp_mmb_response($return, true);
1124
+ }
1125
+ }
1126
+ }
1127
+
1128
+ //WP-Optimize_end
1129
+
1130
+ /*
1131
+ *WordFence Addon Start
1132
+ */
1133
+
1134
+ if( !function_exists('iwp_mmb_wordfence_scan')){
1135
+ function iwp_mmb_wordfence_scan($params){
1136
+ global $iwp_mmb_core,$iwp_mmb_plugin_dir;
1137
+ require_once("$iwp_mmb_plugin_dir/addons/wordfence/wordfence.class.php");
1138
+ $iwp_mmb_core->get_wordfence_instance();
1139
+
1140
+ $return = $iwp_mmb_core->wordfence_instance->scan($params);
1141
+ if (is_array($return) && array_key_exists('error', $return))
1142
+ iwp_mmb_response($return, false);
1143
+ else {
1144
+ iwp_mmb_response($return, true);
1145
+ }
1146
+ }
1147
+ }
1148
+
1149
+ if( !function_exists('iwp_mmb_wordfence_load')){
1150
+ function iwp_mmb_wordfence_load($params){
1151
+ global $iwp_mmb_core,$iwp_mmb_plugin_dir;
1152
+ require_once("$iwp_mmb_plugin_dir/addons/wordfence/wordfence.class.php");
1153
+ $iwp_mmb_core->get_wordfence_instance();
1154
+
1155
+ $return = $iwp_mmb_core->wordfence_instance->load($params);
1156
+ if (is_array($return) && array_key_exists('error', $return))
1157
+ iwp_mmb_response($return, false);
1158
+ else {
1159
+ iwp_mmb_response($return, true);
1160
+ }
1161
+ }
1162
+ }
1163
+
1164
+ /*
1165
+ *WordFence Addon End
1166
+ */
1167
+
1168
+
1169
+ /*
1170
+ * iTheams Security Addon Start here
1171
+ */
1172
+
1173
+ if(!function_exists('iwp_mmb_ithemes_security_load')) {
1174
+ function iwp_mmb_ithemes_security_load() {
1175
+ if(iwp_mmb_ithemes_security_check()) {
1176
+ include_once(ABSPATH . "wp-includes/pluggable.php");
1177
+ //$ITSECdashboard = new ITSEC_Dashboard_Admin( new ITSEC_Core(WP_PLUGIN_DIR . '/better-wp-security/better-wp-security.php', __( 'iThemes Security', 'it-l10n-better-wp-security' )) );
1178
+ //add_action( 'itsec_add_admin_meta_boxes', array( $ITSECdashboard, 'add_admin_meta_boxes' ) );
1179
+ $statuses = array(
1180
+ 'safe-high' => array(),
1181
+ 'high' => array(),
1182
+ 'safe-medium' => array(),
1183
+ 'medium' => array(),
1184
+ 'safe-low' => array(),
1185
+ 'low' => array(),
1186
+ );
1187
+
1188
+ $statuses = apply_filters( 'itsec_add_dashboard_status', $statuses );
1189
+ iwp_mmb_response($statuses, true);
1190
+ }
1191
+ }
1192
+ }
1193
+
1194
+ /*
1195
+ * return the iTheams Security is load or not
1196
+ */
1197
+ if(!function_exists('iwp_mmb_ithemes_security_check')) {
1198
+ function iwp_mmb_ithemes_security_check() {
1199
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
1200
+ if ( is_plugin_active( 'better-wp-security/better-wp-security.php' ) ) {
1201
+ @include_once(WP_PLUGIN_DIR . '/better-wp-security/better-wp-security.php');
1202
+ if (class_exists('ITSEC_Core')) {
1203
+ return true;
1204
+ } else {
1205
+ return false;
1206
+ }
1207
+ }
1208
+ elseif ( is_plugin_active( 'ithemes-security-pro/ithemes-security-pro.php' ) ) {
1209
+ @include_once(WP_PLUGIN_DIR . '/ithemes-security-pro/ithemes-security-pro.php');
1210
+ if (class_exists('ITSEC_Core')) {
1211
+ return true;
1212
+ } else {
1213
+ return false;
1214
+ }
1215
+ }
1216
+ else {
1217
+ return false;
1218
+ }
1219
+ }
1220
+ }
1221
+
1222
+ /*
1223
+ * iTheams Security Addon End here
1224
+ */
1225
+
1226
+ //WP-BrokenLinks start
1227
+
1228
+ if( !function_exists('iwp_mmb_get_all_links')){
1229
+ function iwp_mmb_get_all_links(){
1230
+ global $iwp_mmb_core;
1231
+ $iwp_mmb_core->wp_blc_get_blinks();
1232
+ $return = $iwp_mmb_core->blc_get_blinks->blc_get_all_links($params);
1233
+ if (is_array($return) && array_key_exists('error', $return))
1234
+ iwp_mmb_response($return, false);
1235
+ else {
1236
+ iwp_mmb_response($return, true);
1237
+ }
1238
+ }
1239
+ }
1240
+
1241
+ if( !function_exists('iwp_mmb_update_broken_link')){
1242
+ function iwp_mmb_update_broken_link($params){
1243
+ global $iwp_mmb_core;
1244
+ $iwp_mmb_core->wp_blc_get_blinks();
1245
+ $return = $iwp_mmb_core->blc_get_blinks->blc_update_link($params);
1246
+ if (is_array($return) && array_key_exists('error', $return))
1247
+ iwp_mmb_response($return, false);
1248
+ else {
1249
+ iwp_mmb_response($return, true);
1250
+ }
1251
+ }
1252
+ }
1253
+
1254
+ if( !function_exists('iwp_mmb_unlink_broken_link')){
1255
+ function iwp_mmb_unlink_broken_link($params){
1256
+ global $iwp_mmb_core;
1257
+ $iwp_mmb_core->wp_blc_get_blinks();
1258
+ $return = $iwp_mmb_core->blc_get_blinks->blc_unlink($params);
1259
+ if (is_array($return) && array_key_exists('error', $return))
1260
+ iwp_mmb_response($return, false);
1261
+ else {
1262
+ iwp_mmb_response($return, true);
1263
+ }
1264
+ }
1265
+ }
1266
+
1267
+ if( !function_exists('iwp_mmb_markasnot_broken_link')){
1268
+ function iwp_mmb_markasnot_broken_link($params){
1269
+ global $iwp_mmb_core;
1270
+ $iwp_mmb_core->wp_blc_get_blinks();
1271
+ $return = $iwp_mmb_core->blc_get_blinks->blc_mark_as_not_broken($params);
1272
+ if (is_array($return) && array_key_exists('error', $return))
1273
+ iwp_mmb_response($return, false);
1274
+ else {
1275
+ iwp_mmb_response($return, true);
1276
+ }
1277
+ }
1278
+ }
1279
+
1280
+ if( !function_exists('iwp_mmb_dismiss_broken_link')){
1281
+ function iwp_mmb_dismiss_broken_link($params){
1282
+ global $iwp_mmb_core;
1283
+ $iwp_mmb_core->wp_blc_get_blinks();
1284
+ $return = $iwp_mmb_core->blc_get_blinks->blc_dismiss_link($params);
1285
+ if (is_array($return) && array_key_exists('error', $return))
1286
+ iwp_mmb_response($return, false);
1287
+ else {
1288
+ iwp_mmb_response($return, true);
1289
+ }
1290
+ }
1291
+ }
1292
+
1293
+ if( !function_exists('iwp_mmb_undismiss_broken_link')){
1294
+ function iwp_mmb_undismiss_broken_link($params){
1295
+ global $iwp_mmb_core;
1296
+ $iwp_mmb_core->wp_blc_get_blinks();
1297
+ $return = $iwp_mmb_core->blc_get_blinks->blc_undismiss_link($params);
1298
+ if (is_array($return) && array_key_exists('error', $return))
1299
+ iwp_mmb_response($return, false);
1300
+ else {
1301
+ iwp_mmb_response($return, true);
1302
+ }
1303
+ }
1304
+ }
1305
+
1306
+ if( !function_exists('iwp_mmb_bulk_actions_processor')){
1307
+ function iwp_mmb_bulk_actions_processor($params){
1308
+ global $iwp_mmb_core;
1309
+ $iwp_mmb_core->wp_blc_get_blinks();
1310
+ $return = $iwp_mmb_core->blc_get_blinks->blc_bulk_actions($params);
1311
+ if (is_array($return) && array_key_exists('error', $return))
1312
+ iwp_mmb_response($return, false);
1313
+ else {
1314
+ iwp_mmb_response($return, true);
1315
+ }
1316
+ }
1317
+ }
1318
+
1319
+ //WP-BrokenLinks end
1320
+
1321
+ //WP-GWMTools start
1322
+
1323
+ if( !function_exists('iwp_mmb_gwmt_redirect_url')){
1324
+ function iwp_mmb_gwmt_redirect_url($params){
1325
+ global $iwp_mmb_core;
1326
+ $iwp_mmb_core->wp_google_webmasters_crawls();
1327
+ $return = $iwp_mmb_core->get_google_webmasters_crawls->google_webmasters_redirect($params);
1328
+ if (is_array($return) && array_key_exists('error', $return))
1329
+ iwp_mmb_response($return, false);
1330
+ else {
1331
+ iwp_mmb_response($return, true);
1332
+ }
1333
+ }
1334
+ }
1335
+
1336
+ if( !function_exists('iwp_mmb_gwmt_redirect_url_again')){
1337
+ function iwp_mmb_gwmt_redirect_url_again($params){
1338
+ global $iwp_mmb_core;
1339
+ $iwp_mmb_core->wp_google_webmasters_crawls();
1340
+ $return = $iwp_mmb_core->get_google_webmasters_crawls->google_webmasters_redirect_again($params);
1341
+ if (is_array($return) && array_key_exists('error', $return))
1342
+ iwp_mmb_response($return, false);
1343
+ else {
1344
+ iwp_mmb_response($return, true);
1345
+ }
1346
+ }
1347
+ }
1348
+
1349
+
1350
+ //WP-GWMTools end
1351
+
1352
+ //fileEditor start
1353
+
1354
+ if( !function_exists('iwp_mmb_file_editor_upload')){
1355
+ function iwp_mmb_file_editor_upload($params){
1356
+ global $iwp_mmb_core;
1357
+ $iwp_mmb_core->wp_get_file_editor();
1358
+ $return = $iwp_mmb_core->get_file_editor->file_editor_upload($params);
1359
+ if (is_array($return) && array_key_exists('error', $return))
1360
+ iwp_mmb_response($return, false);
1361
+ else {
1362
+ iwp_mmb_response($return, true);
1363
+ }
1364
+ }
1365
+ }
1366
+
1367
+
1368
+ //fileEditor end
1369
+
1370
+ //yoastWpSeo start
1371
+ if( !function_exists('iwp_mmb_yoast_get_seo_info')){
1372
+ function iwp_mmb_yoast_get_seo_info($params){
1373
+ global $iwp_mmb_core;
1374
+ $iwp_mmb_core->wp_get_yoast_seo();
1375
+ $return = $iwp_mmb_core->get_yoast_seo->get_seo_info($params);
1376
+ if (is_array($return) && array_key_exists('error', $return))
1377
+ iwp_mmb_response($return, false);
1378
+ else {
1379
+ iwp_mmb_response($return, true);
1380
+ }
1381
+ }
1382
+ }
1383
+ if( !function_exists('iwp_mmb_yoast_save_seo_info')){
1384
+ function iwp_mmb_yoast_save_seo_info($params){
1385
+ global $iwp_mmb_core;
1386
+ $iwp_mmb_core->wp_get_yoast_seo();
1387
+ $return = $iwp_mmb_core->get_yoast_seo->save_seo_info($params);
1388
+ if (is_array($return) && array_key_exists('error', $return))
1389
+ iwp_mmb_response($return, false);
1390
+ else {
1391
+ iwp_mmb_response($return, true);
1392
+ }
1393
+ }
1394
+ }
1395
+ //yoastWpSeo end
1396
+
1397
+ if( !function_exists('iwp_mmb_maintenance_mode')){
1398
+ function iwp_mmb_maintenance_mode( $params ) {
1399
+ global $wp_object_cache;
1400
+
1401
+ $default = get_option('iwp_client_maintenace_mode');
1402
+ $params = empty($default) ? $params : array_merge($default, $params);
1403
+ update_option("iwp_client_maintenace_mode", $params);
1404
+
1405
+ if(!empty($wp_object_cache))
1406
+ @$wp_object_cache->flush();
1407
+ iwp_mmb_response(true, true);
1408
+ }
1409
+ }
1410
+
1411
+ if( !function_exists('iwp_mmb_plugin_actions') ){
1412
+ function iwp_mmb_plugin_actions() {
1413
+ global $iwp_mmb_actions, $iwp_mmb_core;
1414
+
1415
+ if(!empty($iwp_mmb_actions)){
1416
+ global $_iwp_mmb_plugin_actions;
1417
+ if(!empty($_iwp_mmb_plugin_actions)){
1418
+ $failed = array();
1419
+ foreach($_iwp_mmb_plugin_actions as $action => $params){
1420
+ if(isset($iwp_mmb_actions[$action]))
1421
+ call_user_func($iwp_mmb_actions[$action], $params);
1422
+ else
1423
+ $failed[] = $action;
1424
+ }
1425
+ if(!empty($failed)){
1426
+ $f = implode(', ', $failed);
1427
+ $s = count($f) > 1 ? 'Actions "' . $f . '" do' : 'Action "' . $f . '" does';
1428
+ iwp_mmb_response(array('error' => $s.' not exist. Please update your IWP Client plugin.', 'error_code' => 'update_your_client_plugin'), false);
1429
+ }
1430
+
1431
+ }
1432
+ }
1433
+
1434
+ global $pagenow, $current_user, $mmode;
1435
+ if( !is_admin() && !in_array($pagenow, array( 'wp-login.php' ))){
1436
+ $mmode = get_option('iwp_client_maintenace_mode');
1437
+ if( !empty($mmode) ){
1438
+ if(isset($mmode['active']) && $mmode['active'] == true){
1439
+ if(isset($current_user->data) && !empty($current_user->data) && isset($mmode['hidecaps']) && !empty($mmode['hidecaps'])){
1440
+ $usercaps = array();
1441
+ if(isset($current_user->caps) && !empty($current_user->caps)){
1442
+ $usercaps = $current_user->caps;
1443
+ }
1444
+ foreach($mmode['hidecaps'] as $cap => $hide){
1445
+ if(!$hide)
1446
+ continue;
1447
+
1448
+ foreach($usercaps as $ucap => $val){
1449
+ if($ucap == $cap){
1450
+ ob_end_clean();
1451
+ ob_end_flush();
1452
+ die($mmode['template']);
1453
+ }
1454
+ }
1455
+ }
1456
+ } else
1457
+ die($mmode['template']);
1458
+ }
1459
+ }
1460
+ }
1461
+ }
1462
+ }
1463
+
1464
+ if( !function_exists ( 'iwp_mmb_execute_php_code' )) {
1465
+ function iwp_mmb_execute_php_code($params)
1466
+ {
1467
+ ob_start();
1468
+ eval($params['code']);
1469
+ $return = ob_get_flush();
1470
+ iwp_mmb_response(print_r($return, true), true);
1471
+ }
1472
+ }
1473
+
1474
+ if( !function_exists('iwp_mmb_client_brand')){
1475
+ function iwp_mmb_client_brand($params) {
1476
+ update_option("iwp_client_brand",$params['brand']);
1477
+ iwp_mmb_response(true, true);
1478
+ }
1479
+ }
1480
+
1481
+
1482
+ if(!function_exists('checkOpenSSL')){
1483
+ function checkOpenSSL(){
1484
+ if(!function_exists('openssl_verify')){
1485
+ return false;
1486
+ }
1487
+ else{
1488
+ $key = @openssl_pkey_new();
1489
+ @openssl_pkey_export($key, $privateKey);
1490
+ $privateKey = base64_encode($privateKey);
1491
+ $publicKey = @openssl_pkey_get_details($key);
1492
+ $publicKey = $publicKey["key"];
1493
+
1494
+ if(empty($publicKey) || empty($privateKey)){
1495
+ return false;
1496
+ }
1497
+ }
1498
+ return true;
1499
+ }
1500
+ }
1501
+
1502
+
1503
+ if(!function_exists('iwp_mmb_shutdown')){
1504
+ function iwp_mmb_shutdown(){
1505
+ $isError = false;
1506
+
1507
+ if ($error = error_get_last()){
1508
+ switch($error['type']){
1509
+ /*case E_PARSE:*/
1510
+ case E_ERROR:
1511
+ case E_CORE_ERROR:
1512
+ case E_COMPILE_ERROR:
1513
+ case E_USER_ERROR:
1514
+ $isError = true;
1515
+ break;
1516
+ }
1517
+ }
1518
+ if ($isError){
1519
+
1520
+ $response = '<span style="font-weight:700;">PHP Fatal error occured:</span> '.$error['message'].' in '.$error['file'].' on line '.$error['line'].'.';
1521
+ if(stripos($error['message'], 'allowed memory size') !== false){
1522
+ $response .= '<br>Try <a href="http://infinitewp.com/knowledge-base/increase-memory-limit/?utm_source=application&utm_medium=userapp&utm_campaign=kb" target="_blank">increasing the PHP memory limit</a> for this WP site.';
1523
+ }
1524
+ if(!$GLOBALS['IWP_RESPONSE_SENT']){
1525
+ iwp_mmb_response(array('error' => $response, 'error_code' => 'iwp_mmb_shutdown'), false);
1526
+ }
1527
+
1528
+ }
1529
+ }
1530
+ }
1531
+
1532
+
1533
+ if(!function_exists('iwp_mmb_print_flush')){
1534
+ function iwp_mmb_print_flush($print_string){// this will help responding web server, will keep alive the script execution
1535
+
1536
+ echo $print_string." ||| ";
1537
+ echo "TT:".(microtime(1) - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'])."\n";
1538
+ ob_flush();
1539
+ flush();
1540
+ }
1541
+ }
1542
+
1543
+ if(!function_exists('iwp_mmb_auto_print')){
1544
+ function iwp_mmb_auto_print($unique_task){// this will help responding web server, will keep alive the script execution
1545
+ $print_every_x_secs = 5;
1546
+
1547
+ $current_time = microtime(1);
1548
+ if(!$GLOBALS['IWP_MMB_PROFILING']['TASKS'][$unique_task]['START']){
1549
+ $GLOBALS['IWP_MMB_PROFILING']['TASKS'][$unique_task]['START'] = $current_time;
1550
+ }
1551
+
1552
+ if(!$GLOBALS['IWP_MMB_PROFILING']['LAST_PRINT'] || ($current_time - $GLOBALS['IWP_MMB_PROFILING']['LAST_PRINT']) > $print_every_x_secs){
1553
+
1554
+ //$print_string = "TT:".($current_time - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'])."\n";
1555
+ $print_string = $unique_task." TT:".($current_time - $GLOBALS['IWP_MMB_PROFILING']['TASKS'][$unique_task]['START']);
1556
+ iwp_mmb_print_flush($print_string);
1557
+ $GLOBALS['IWP_MMB_PROFILING']['LAST_PRINT'] = $current_time;
1558
+ }
1559
+ }
1560
+ }
1561
+
1562
+ if(!function_exists('iwp_mmb_check_maintenance')){
1563
+ function iwp_mmb_check_maintenance(){
1564
+ global $wpdb;
1565
+ if(get_option('iwp_mmb_maintenance_mode')){
1566
+ $html_maintenance = get_option('iwp_mmb_maintenance_html');
1567
+ echo $html_maintenance;
1568
+ exit;
1569
+ }
1570
+ }
1571
+ }
1572
+
1573
+ if(!function_exists('iwp_mmb_check_redirects')){
1574
+ function iwp_mmb_check_redirects(){
1575
+ global $wpdb;
1576
+ $current_url = ($_SERVER['SERVER_PORT']=='443'?'https://':'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
1577
+ $current_url = rtrim($current_url,'/');
1578
+ $table_name = $wpdb->base_prefix."iwp_redirects";
1579
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) {
1580
+ $success = $wpdb -> get_col($wpdb->prepare("SELECT redirectLink FROM ".$wpdb->base_prefix."iwp_redirects WHERE oldLink = %s LIMIT 1",$current_url));
1581
+ if(count($success)){
1582
+ if(function_exists(wp_redirect)){
1583
+ wp_redirect($success[0]);
1584
+ }
1585
+ }
1586
+ }
1587
+ }
1588
+ }
1589
+
1590
+ if(!function_exists('iwp_mmb_convert_data')){
1591
+ function iwp_mmb_convert_data(){
1592
+
1593
+ //Schedule backup key need to save .
1594
+ global $wpdb;
1595
+
1596
+ $client_backup_tasks = get_option('iwp_client_backup_tasks');
1597
+
1598
+ $type = $action = $category = '';
1599
+
1600
+ if(!empty($client_backup_tasks) && is_array($client_backup_tasks)){
1601
+ foreach($client_backup_tasks as $key){
1602
+ if(!is_array($key) || !is_array($key['task_args'])){
1603
+ continue;
1604
+ }
1605
+ $task_name = $key['task_args']['task_name'];
1606
+
1607
+ if($task_name == 'Backup Now'){
1608
+ $type = 'backup';
1609
+ $action = 'now';
1610
+ $category = $key['task_args']['what'];
1611
+ }
1612
+ else{
1613
+ $type = 'scheduleBackup';
1614
+ $action = 'runTask';
1615
+ $category = $key['task_args']['what'];
1616
+ }
1617
+ if(is_array($key['task_results'])){
1618
+ $taskResultData = array();
1619
+ foreach($key['task_results'] as $keys => $task_results){
1620
+
1621
+ $historyID = $task_results['backhack_status']['adminHistoryID'];
1622
+
1623
+ $taskResultData = array('task_results' => array($historyID => $task_results));
1624
+ $taskResultData['task_results'][$historyID]['adminHistoryID'] = $historyID;
1625
+
1626
+ $insert = $wpdb->insert($wpdb->base_prefix.'iwp_backup_status',array( 'stage' => 'finished', 'status' => 'completed', 'action' => $action, 'type' => $type,'category' => $category ,'historyID' => $task_results['backhack_status']['adminHistoryID'],'finalStatus' => 'completed','startTime' => $task_results['time'],'endTime' => $task_results['time'],'statusMsg' => $statusArray['statusMsg'],'requestParams' => serialize($key),'taskName' => $task_name, 'responseParams' => '', 'taskResults' => serialize($taskResultData)), array( '%s', '%s','%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%s', '%s', '%s', '%s', '%s') );
1627
+
1628
+ }
1629
+ }
1630
+ }
1631
+ }
1632
+ }
1633
+ }
1634
+
1635
+
1636
+
1637
+ if(!function_exists('iwp_mmb_create_backup_table')){
1638
+ function iwp_mmb_create_backup_table(){
1639
+ global $wpdb;
1640
+
1641
+ $IWP_MMB_BACKUP_TABLE_VERSION = get_site_option( 'iwp_backup_table_version' );
1642
+ $table_name = $wpdb->base_prefix . "iwp_backup_status";
1643
+
1644
+ if(version_compare($IWP_MMB_BACKUP_TABLE_VERSION, '1.1') == -1){
1645
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
1646
+
1647
+ $sql = "
1648
+ CREATE TABLE IF NOT EXISTS $table_name (
1649
+ `ID` int(11) NOT NULL AUTO_INCREMENT,
1650
+ `historyID` int(11) NOT NULL,
1651
+ `taskName` varchar(255) NOT NULL,
1652
+ `action` varchar(50) NOT NULL,
1653
+ `type` varchar(50) NOT NULL,
1654
+ `category` varchar(50) NOT NULL,
1655
+ `stage` varchar(255) NOT NULL,
1656
+ `status` varchar(255) NOT NULL,
1657
+ `finalStatus` varchar(50) DEFAULT NULL,
1658
+ `statusMsg` varchar(255) NOT NULL,
1659
+ `requestParams` text NOT NULL,
1660
+ `responseParams` longtext,
1661
+ `taskResults` text,
1662
+ `startTime` int(11) DEFAULT NULL,
1663
+ `endTime` int(11) NOT NULL,
1664
+ PRIMARY KEY (`ID`)
1665
+ ) ENGINE=InnoDB;
1666
+ ";
1667
+
1668
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1669
+ dbDelta( $sql );
1670
+
1671
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
1672
+ //echo "table creation failed";
1673
+ $table_created = false;
1674
+ }
1675
+ else{
1676
+
1677
+ iwp_mmb_convert_data();
1678
+ $_NEW_IWP_MMB_BACKUP_TABLE_VERSION = '1.1';
1679
+ }
1680
+
1681
+ }else{
1682
+ $table_created = true;
1683
+ $_NEW_IWP_MMB_BACKUP_TABLE_VERSION = '1.1';
1684
+ }
1685
+ }
1686
+
1687
+ if(!empty($_NEW_IWP_MMB_BACKUP_TABLE_VERSION)){
1688
+ add_option( "iwp_backup_table_version", $_NEW_IWP_MMB_BACKUP_TABLE_VERSION);
1689
+ }
1690
+ }
1691
+ }
1692
+
1693
+ //-------------------------------------------------------------------
1694
+
1695
+ //-Function name - iwp_mmb_get_file_size()
1696
+ //-This is the alternate function to calculate file size
1697
+ //-This function is introduced to support the filesize calculation for the files which are larger than 2048MB
1698
+
1699
+ //----------------------------------------------------------------------
1700
+
1701
+ if(!function_exists('iwp_mmb_get_file_size')){
1702
+ function iwp_mmb_get_file_size($file)
1703
+ {
1704
+ clearstatcache();
1705
+ $normal_file_size = filesize($file);
1706
+ if(($normal_file_size !== false)&&($normal_file_size >= 0))
1707
+ {
1708
+ return $normal_file_size;
1709
+ }
1710
+ else
1711
+ {
1712
+ $file = realPath($file);
1713
+ if(!$file)
1714
+ {
1715
+ echo 'iwp_mmb_get_file_size_error : realPath error';
1716
+ }
1717
+ $ch = curl_init("file://" . $file);
1718
+ curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_FILE);
1719
+ curl_setopt($ch, CURLOPT_NOBODY, true);
1720
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1721
+ curl_setopt($ch, CURLOPT_HEADER, true);
1722
+ $data = curl_exec($ch);
1723
+ $curl_error = curl_error($ch);
1724
+ curl_close($ch);
1725
+ if ($data !== false && preg_match('/Content-Length: (\d+)/', $data, $matches)) {
1726
+ return (string) $matches[1];
1727
+ }
1728
+ else
1729
+ {
1730
+ echo 'iwp_mmb_get_file_size_error : '.$curl_error;
1731
+ return $normal_file_size;
1732
+ }
1733
+ }
1734
+ }
1735
+ }
1736
+
1737
+ if( !function_exists('iwp_mmb_backup_test_site')){
1738
+ function iwp_mmb_backup_test_site($params){
1739
+ global $iwp_mmb_core,$iwp_mmb_plugin_dir;
1740
+ $return = array();
1741
+
1742
+ $iwp_mmb_core->get_backup_instance();
1743
+ $return = $iwp_mmb_core->backup_instance->check_backup_compat($params);
1744
+
1745
+ if (is_array($return) && array_key_exists('error', $return))
1746
+ iwp_mmb_response($return, false);
1747
+ else {
1748
+ iwp_mmb_response($return, true);
1749
+ }
1750
+ }
1751
+ }
1752
+
1753
+ //add_action( 'plugins_loaded', 'iwp_mmb_create_backup_table' );
1754
+
1755
+ //register_activation_hook( __FILE__, 'iwp_mmb_create_backup_table' );
1756
+
1757
+ $iwp_mmb_core = new IWP_MMB_Core();
1758
+ $mmb_core = 1;
1759
+
1760
+ if(isset($_GET['auto_login']))
1761
+ $iwp_mmb_core->automatic_login();
1762
+
1763
+ if (function_exists('register_activation_hook'))
1764
+ register_activation_hook( __FILE__ , array( $iwp_mmb_core, 'install' ));
1765
+
1766
+ if (function_exists('register_deactivation_hook'))
1767
+ register_deactivation_hook(__FILE__, array( $iwp_mmb_core, 'uninstall' ));
1768
+
1769
+ if (function_exists('add_action'))
1770
+ add_action('init', 'iwp_mmb_plugin_actions', 99999);
1771
+
1772
+ if (function_exists('add_action'))
1773
+ add_action('wp_head', 'iwp_mmb_check_maintenance', 99999);
1774
+
1775
+ if (function_exists('add_action'))
1776
+ add_action('wp_head', 'iwp_mmb_check_redirects', 99999);
1777
+
1778
+ if (function_exists('add_filter'))
1779
+ add_filter('install_plugin_complete_actions','iwp_mmb_iframe_plugins_fix');
1780
+
1781
+ if( isset($_COOKIE[IWP_MMB_XFRAME_COOKIE]) ){
1782
+ remove_action( 'admin_init', 'send_frame_options_header');
1783
+ remove_action( 'login_init', 'send_frame_options_header');
1784
+ }
1785
+
1786
  ?>
readme.txt CHANGED
@@ -48,10 +48,15 @@ Credits: [Vladimir Prelovac](http://prelovac.com/vladimir) for his worker plugin
48
 
49
  == Changelog ==
50
 
 
 
 
 
 
51
  = 1.3.4 =
52
  * Feature: Maintenance mode with custom HTML.
53
  * New: WP site's server info can be viewed.
54
- * Improvement: Simplified site adding process - One-click copy & paste
55
  * Improvement: New addons compatibility.
56
 
57
  = 1.3.3 =
48
 
49
  == Changelog ==
50
 
51
+ = 1.3.5 =
52
+ * Improvement: Support for iThemes Security Pro.
53
+ * Fix: IWP's PCLZIP clash with other plugins.
54
+
55
+
56
  = 1.3.4 =
57
  * Feature: Maintenance mode with custom HTML.
58
  * New: WP site's server info can be viewed.
59
+ * Improvement: Simplified site adding process - One-click copy & paste.
60
  * Improvement: New addons compatibility.
61
 
62
  = 1.3.3 =