| 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.13.10 |
| 8 |
Author URI: http://www.revmakx.com |
| 9 |
Network: true |
| 10 |
*/ |
| 11 |
/************************************************************ |
| 12 |
* This plugin was modified by Revmakx * |
| 13 |
* Copyright (c) 2012 Revmakx * |
| 14 |
* www.revmakx.com * |
| 15 |
* * |
| 16 |
************************************************************/ |
| 17 |
|
| 18 |
/************************************************************* |
| 19 |
* |
| 20 |
* init.php |
| 21 |
* |
| 22 |
* Initialize the communication with master |
| 23 |
* |
| 24 |
* |
| 25 |
* Copyright (c) 2011 Prelovac Media |
| 26 |
* www.prelovac.com |
| 27 |
**************************************************************/ |
| 28 |
if ( ! defined('ABSPATH') ) |
| 29 |
die(); |
| 30 |
|
| 31 |
if(!defined('IWP_MMB_CLIENT_VERSION')) |
| 32 |
define('IWP_MMB_CLIENT_VERSION', '1.13.10'); |
| 33 |
|
| 34 |
if ( !defined('IWP_MMB_XFRAME_COOKIE')){ |
| 35 |
$siteurl = function_exists('get_site_option') ? get_site_option( 'siteurl' ) : get_option('siteurl'); |
| 36 |
define('IWP_MMB_XFRAME_COOKIE', $xframe = 'wordpress_'.md5($siteurl).'_xframe'); |
| 37 |
} |
| 38 |
global $wpdb, $iwp_mmb_plugin_dir, $iwp_mmb_plugin_url, $wp_version, $iwp_mmb_filters, $_iwp_mmb_item_filter; |
| 39 |
if (version_compare(PHP_VERSION, '5.0.0', '<')) // min version 5 supported |
| 40 |
exit("<p>InfiniteWP Client plugin requires PHP 5 or higher.</p>"); |
| 41 |
|
| 42 |
|
| 43 |
$iwp_mmb_wp_version = $wp_version; |
| 44 |
$iwp_mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__)); |
| 45 |
$iwp_mmb_plugin_url = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)); |
| 46 |
|
| 47 |
if(!defined('IWP_BACKUP_DIR')){ |
| 48 |
define('IWP_BACKUP_DIR', WP_CONTENT_DIR . '/infinitewp/backups'); |
| 49 |
} |
| 50 |
|
| 51 |
if(!defined('IWP_DB_DIR')){ |
| 52 |
define('IWP_DB_DIR', IWP_BACKUP_DIR . '/iwp_db'); |
| 53 |
} |
| 54 |
|
| 55 |
if(!defined('IWP_PCLZIP_TEMPORARY_DIR')){ |
| 56 |
define('IWP_PCLZIP_TEMPORARY_DIR', WP_CONTENT_DIR . '/infinitewp/temp/'); |
| 57 |
} |
| 58 |
|
| 59 |
require_once("$iwp_mmb_plugin_dir/helper.class.php"); |
| 60 |
require_once("$iwp_mmb_plugin_dir/backup/backup.options.php"); |
| 61 |
require_once("$iwp_mmb_plugin_dir/backup/functions.php"); |
| 62 |
require_once("$iwp_mmb_plugin_dir/backup/databaseencrypt.php"); |
| 63 |
require_once("$iwp_mmb_plugin_dir/backup/encrypt.php"); |
| 64 |
require_once("$iwp_mmb_plugin_dir/core.class.php"); |
| 65 |
require_once("$iwp_mmb_plugin_dir/activities_log.class.php"); |
| 66 |
require_once("$iwp_mmb_plugin_dir/stats.class.php"); |
| 67 |
//require_once("$iwp_mmb_plugin_dir/backup.class.php"); |
| 68 |
//require_once("$iwp_mmb_plugin_dir/backup.class.singlecall.php"); |
| 69 |
//require_once("$iwp_mmb_plugin_dir/backup.class.multicall.php"); |
| 70 |
require_once("$iwp_mmb_plugin_dir/installer.class.php"); |
| 71 |
|
| 72 |
require_once("$iwp_mmb_plugin_dir/addons/manage_users/user.class.php"); |
| 73 |
//require_once("$iwp_mmb_plugin_dir/addons/backup_repository/backup_repository.class.php"); |
| 74 |
require_once("$iwp_mmb_plugin_dir/addons/comments/comments.class.php"); |
| 75 |
|
| 76 |
require_once("$iwp_mmb_plugin_dir/addons/post_links/link.class.php"); |
| 77 |
require_once("$iwp_mmb_plugin_dir/addons/post_links/post.class.php"); |
| 78 |
|
| 79 |
require_once("$iwp_mmb_plugin_dir/addons/wp_optimize/optimize.class.php"); |
| 80 |
|
| 81 |
require_once("$iwp_mmb_plugin_dir/addons.api.php"); |
| 82 |
require_once("$iwp_mmb_plugin_dir/plugin.compatibility.class.php"); |
| 83 |
require_once("$iwp_mmb_plugin_dir/plugins/search/search.php"); |
| 84 |
require_once("$iwp_mmb_plugin_dir/plugins/cleanup/cleanup.php"); |
| 85 |
|
| 86 |
add_action('wp_enqueue_scripts', 'iwp_add_staging_scripts'); |
| 87 |
add_action('admin_enqueue_scripts', 'iwp_add_staging_scripts'); |
| 88 |
|
| 89 |
if( !function_exists ( 'iwp_add_staging_scripts' )) { |
| 90 |
function iwp_add_staging_scripts(){ |
| 91 |
$is_iwp_staged_site = get_option('iwp_staged_site'); |
| 92 |
|
| 93 |
// file_put_contents(WP_CONTENT_DIR . '/iwp-logs.txt', '------iwp_staged_site--------' . var_export($is_iwp_staged_site . "\n", true), FILE_APPEND); |
| 94 |
|
| 95 |
if(empty($is_iwp_staged_site)){ |
| 96 |
|
| 97 |
return; |
| 98 |
} |
| 99 |
|
| 100 |
$this_plugin_dir_url = plugins_url() . '/' . basename(dirname(__FILE__)); |
| 101 |
|
| 102 |
wp_enqueue_style('iwp-staging-css', $this_plugin_dir_url . '/iwp-staging.css', [], IWP_MMB_CLIENT_VERSION); |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
if( !function_exists ( 'iwp_mmb_filter_params' )) { |
| 107 |
function iwp_mmb_filter_params( $array = array() ){ |
| 108 |
|
| 109 |
$filter = array( 'current_user', 'wpdb' ); |
| 110 |
$return = array(); |
| 111 |
foreach ($array as $key => $val) { |
| 112 |
if( !is_int($key) && in_array($key, $filter) ) |
| 113 |
continue; |
| 114 |
|
| 115 |
if( is_array( $val ) ) { |
| 116 |
$return[$key] = iwp_mmb_filter_params( $val ); |
| 117 |
} else { |
| 118 |
$return[$key] = $val; |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
return $return; |
| 123 |
} |
| 124 |
} |
| 125 |
|
| 126 |
if( !function_exists ('iwp_mmb_parse_request')) { |
| 127 |
function iwp_mmb_parse_request() |
| 128 |
{ |
| 129 |
global $post_data, $iwp_mmb_activities_log; |
| 130 |
$post_data_local = NULL; |
| 131 |
$post_data_local = file_get_contents('php://input'); |
| 132 |
if(empty($post_data_local)){ |
| 133 |
if (isset($post_data)) { |
| 134 |
$post_data_local = $post_data; |
| 135 |
} |
| 136 |
} |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
global $current_user, $iwp_mmb_core, $new_actions, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache; |
| 141 |
if (strrpos($post_data_local, '_IWP_JSON_PREFIX_') !== false) { |
| 142 |
$request_data_array = explode('_IWP_JSON_PREFIX_', $post_data_local); |
| 143 |
$request_raw_data = $request_data_array[1]; |
| 144 |
$data = trim(base64_decode($request_raw_data)); |
| 145 |
$GLOBALS['IWP_JSON_COMMUNICATION'] = 1; |
| 146 |
}else{ |
| 147 |
$data = false; |
| 148 |
$request_raw_data = $post_data_local; |
| 149 |
$serialized_data = trim(base64_decode($request_raw_data)); |
| 150 |
if (is_serialized($serialized_data)) { |
| 151 |
iwp_mmb_response(array('error' => 'Please update your IWP Admin Panel to latest version', 'error_code' => 'update_panel'), false, true); |
| 152 |
} |
| 153 |
} |
| 154 |
|
| 155 |
if ($data){ |
| 156 |
|
| 157 |
//$num = @extract(unserialize($data)); |
| 158 |
$request_data = json_decode($data, true); |
| 159 |
|
| 160 |
if(isset($request_data['params'])){ |
| 161 |
$request_data['params'] = iwp_mmb_filter_params($request_data['params']); |
| 162 |
} |
| 163 |
$defaults = array( |
| 164 |
'id' => NULL, |
| 165 |
'activities_log_datetime' =>NULL, |
| 166 |
'is_save_activity_log' =>FALSE, |
| 167 |
'signature' => NULL, |
| 168 |
'params' => array( |
| 169 |
'numberOfRevisions' => '0' |
| 170 |
), |
| 171 |
); |
| 172 |
$request_data = iwp_recursive_parse_args( $request_data, $defaults ); |
| 173 |
|
| 174 |
if (isset($GLOBALS['IWP_JSON_COMMUNICATION']) && $GLOBALS['IWP_JSON_COMMUNICATION']) { |
| 175 |
$signature = !empty($request_data['signature'])?base64_decode($request_data['signature']): ''; |
| 176 |
$signature_new = !empty($request_data['signature_new'])?base64_decode($request_data['signature_new']): ''; |
| 177 |
}else{ |
| 178 |
$signature = $request_data['signature']; |
| 179 |
} |
| 180 |
|
| 181 |
$iwp_action = $request_data['iwp_action']; |
| 182 |
$params = $request_data['params']; |
| 183 |
$id = $request_data['id']; |
| 184 |
if(isset($request_data['is_save_activity_log'])) { |
| 185 |
$is_save_activity_log = $request_data['is_save_activity_log']; |
| 186 |
} |
| 187 |
$GLOBALS['activities_log_datetime'] = $request_data['activities_log_datetime']; |
| 188 |
} |
| 189 |
if (isset($iwp_action) && $iwp_action != 'restoreNew') { |
| 190 |
if(!defined('IWP_AUTHORISED_CALL')) define('IWP_AUTHORISED_CALL', 1); |
| 191 |
if(function_exists('register_shutdown_function')){ register_shutdown_function("iwp_mmb_shutdown"); } |
| 192 |
$GLOBALS['IWP_MMB_PROFILING']['ACTION_START'] = microtime(1); |
| 193 |
if(!defined('IWP_DEBUG_MODE')){ |
| 194 |
error_reporting(0); |
| 195 |
@ini_set("display_errors", 0); |
| 196 |
} |
| 197 |
run_hash_change_process(); |
| 198 |
iwp_plugin_compatibility_fix(); |
| 199 |
$action = $iwp_action; |
| 200 |
$_wp_using_ext_object_cache = false; |
| 201 |
@set_time_limit(600); |
| 202 |
|
| 203 |
if (!$iwp_mmb_core->check_if_user_exists($params['username'])) |
| 204 |
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); |
| 205 |
|
| 206 |
if ($action == 'add_site') { |
| 207 |
$params['iwp_action'] = $action; |
| 208 |
if(empty($params['is_save_activity_log'])) { |
| 209 |
$params['is_save_activity_log'] = false; |
| 210 |
} |
| 211 |
$iwp_mmb_core->request_params = $params; |
| 212 |
return; |
| 213 |
}elseif ($action == 'readd_site') { |
| 214 |
$params['id'] = $id; |
| 215 |
$params['iwp_action'] = $action; |
| 216 |
$params['signature'] = $signature; |
| 217 |
$params['signature_new'] = $signature_new; |
| 218 |
if(empty($params['is_save_activity_log'])) { |
| 219 |
$params['is_save_activity_log'] = false; |
| 220 |
} |
| 221 |
$iwp_mmb_core->request_params = $params; |
| 222 |
return; |
| 223 |
} |
| 224 |
|
| 225 |
$auth = $iwp_mmb_core->authenticate_message($action . $id, $signature, $signature_new , $id); |
| 226 |
if ($auth === true) { |
| 227 |
if (!defined('WP_ADMIN') && $action == 'get_stats' || $action == 'do_upgrade' || $action == 'install_addon' || $action == 'edit_plugins_themes' || $action == 'bulk_actions_processor' || $action == 'update_broken_link' || $action == 'undismiss_broken_link' || $action == 'changelog_plugin') { |
| 228 |
if (!defined('WP_ADMIN')) { |
| 229 |
define('WP_ADMIN', true); |
| 230 |
} |
| 231 |
} |
| 232 |
if ($action == 'get_stats') { |
| 233 |
iwp_mu_plugin_loader(); |
| 234 |
} |
| 235 |
if (is_multisite() && !defined('WP_NETWORK_ADMIN')) { |
| 236 |
define('WP_NETWORK_ADMIN', true); |
| 237 |
}elseif(!defined('WP_NETWORK_ADMIN')){ |
| 238 |
define('WP_NETWORK_ADMIN', false); |
| 239 |
} |
| 240 |
$params['id'] = $id; |
| 241 |
$params['iwp_action'] = $action; |
| 242 |
$params['is_save_activity_log'] = $is_save_activity_log; |
| 243 |
$iwp_mmb_core->request_params = $params; |
| 244 |
} else { |
| 245 |
iwp_mmb_response($auth, false); |
| 246 |
} |
| 247 |
} |
| 248 |
|
| 249 |
} |
| 250 |
} |
| 251 |
if ( ! function_exists( 'iwp_recursive_parse_args' ) ) { |
| 252 |
function iwp_recursive_parse_args( $args, $defaults ) { |
| 253 |
$new_args = (array) $defaults; |
| 254 |
|
| 255 |
foreach ( $args as $key => $value ) { |
| 256 |
if ( is_array( $value ) && isset( $new_args[ $key ] ) ) { |
| 257 |
$new_args[ $key ] = iwp_recursive_parse_args( $value, $new_args[ $key ] ); |
| 258 |
} |
| 259 |
else { |
| 260 |
$new_args[ $key ] = $value; |
| 261 |
} |
| 262 |
} |
| 263 |
|
| 264 |
return $new_args; |
| 265 |
} |
| 266 |
} |
| 267 |
|
| 268 |
if (!function_exists ('iwp_mmb_add_readd_request')) { |
| 269 |
function iwp_mmb_add_readd_request(){ |
| 270 |
global $current_user, $iwp_mmb_core, $new_actions, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache, $iwp_mmb_activities_log; |
| 271 |
if (empty($iwp_mmb_core->request_params)) { |
| 272 |
return false; |
| 273 |
} |
| 274 |
$params = $iwp_mmb_core->request_params; |
| 275 |
$action = $iwp_mmb_core->request_params['iwp_action']; |
| 276 |
|
| 277 |
if ($action == 'add_site') { |
| 278 |
iwp_mmb_add_site($params); |
| 279 |
iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false); |
| 280 |
} |
| 281 |
if ($action == 'readd_site') { |
| 282 |
$params['id'] = $params['id']; |
| 283 |
$params['signature'] = $params['signature']; |
| 284 |
$params['signature_new'] = $params['signature_new']; |
| 285 |
iwp_mmb_readd_site($params); |
| 286 |
iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false); |
| 287 |
} |
| 288 |
} |
| 289 |
} |
| 290 |
if (!function_exists ('iwp_mmb_set_request')) { |
| 291 |
function iwp_mmb_set_request(){ |
| 292 |
global $current_user, $iwp_mmb_core, $new_actions, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache, $iwp_mmb_activities_log; |
| 293 |
if (is_user_logged_in()) { |
| 294 |
iwp_plugin_compatibility_fix(); |
| 295 |
} |
| 296 |
if (empty($iwp_mmb_core->request_params)) { |
| 297 |
return false; |
| 298 |
} |
| 299 |
$params = $iwp_mmb_core->request_params; |
| 300 |
$action = $iwp_mmb_core->request_params['iwp_action']; |
| 301 |
$is_save_activity_log = $iwp_mmb_core->request_params['is_save_activity_log']; |
| 302 |
if ($action == 'add_site' || $action == 'readd_site') { |
| 303 |
return false; |
| 304 |
} |
| 305 |
if ($action == 'maintain_site') { |
| 306 |
iwp_mmb_maintain_site($params); |
| 307 |
iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false); |
| 308 |
} |
| 309 |
if(!defined('IWP_DEBUG_MODE')){ |
| 310 |
@ignore_user_abort(true); |
| 311 |
} |
| 312 |
$GLOBALS['IWP_CLIENT_HISTORY_ID'] = $iwp_mmb_core->request_params['id']; |
| 313 |
iwp_mmb_backup_db_changes(); |
| 314 |
if(isset($params['username']) && !is_user_logged_in()){ |
| 315 |
$user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : iwp_mmb_get_user_by( 'login', $params['username'] ); |
| 316 |
if (isset($user) && isset($user->ID)) { |
| 317 |
wp_set_current_user($user->ID); |
| 318 |
// Compatibility with All In One Security |
| 319 |
update_user_meta($user->ID, 'last_login_time', current_time('mysql')); |
| 320 |
} |
| 321 |
$isHTTPS = (bool)is_ssl(); |
| 322 |
if($isHTTPS){ |
| 323 |
wp_set_auth_cookie($user->ID); |
| 324 |
}else{ |
| 325 |
wp_set_auth_cookie($user->ID, false, false); |
| 326 |
wp_set_auth_cookie($user->ID, false, true); |
| 327 |
} |
| 328 |
} |
| 329 |
if ($action == 'get_cookie') { |
| 330 |
iwp_mmb_response(true, true); |
| 331 |
} |
| 332 |
|
| 333 |
if(isset($params['secure'])){ |
| 334 |
if (isset($GLOBALS['IWP_JSON_COMMUNICATION']) && $GLOBALS['IWP_JSON_COMMUNICATION']) { |
| 335 |
$params['secure'] = iwp_mmb_safe_unserialize(base64_decode($params['secure'])); |
| 336 |
} |
| 337 |
if($decrypted = $iwp_mmb_core->_secure_data($params['secure'])){ |
| 338 |
if (is_serialized($decrypted)) { |
| 339 |
$decrypted = iwp_mmb_safe_unserialize($decrypted); |
| 340 |
} |
| 341 |
if(is_array($decrypted)){ |
| 342 |
|
| 343 |
foreach($decrypted as $key => $val){ |
| 344 |
if(!is_numeric($key)) |
| 345 |
$params[$key] = $val; |
| 346 |
|
| 347 |
} |
| 348 |
unset($params['secure']); |
| 349 |
} else $params['secure'] = $decrypted; |
| 350 |
} |
| 351 |
elseif(isset($params['secure']['account_info'])){ |
| 352 |
$params['account_info'] = $params['secure']['account_info']; |
| 353 |
}elseif(empty($params['secure']['account_info'])){ |
| 354 |
$params['account_info'] = NULL; |
| 355 |
} |
| 356 |
} |
| 357 |
|
| 358 |
if( !$iwp_mmb_core->register_action_params( $action, $params ) ){ |
| 359 |
global $_iwp_mmb_plugin_actions; |
| 360 |
$_iwp_mmb_plugin_actions[$action] = $params; |
| 361 |
} |
| 362 |
$iwp_mmb_activities_log->iwp_mmb_update_is_save_activity_log($is_save_activity_log); |
| 363 |
$iwp_mmb_activities_log->iwp_mmb_save_options_for_activity_log('parse_request'); |
| 364 |
} |
| 365 |
} |
| 366 |
|
| 367 |
if( !function_exists('iwp_mmb_convert_wperror_obj_to_arr')){ |
| 368 |
function iwp_mmb_convert_wperror_obj_to_arr($obj,$state="initial"){ |
| 369 |
$result = array(); |
| 370 |
if( is_array($obj) ){ |
| 371 |
foreach ($obj as $key => $value) { |
| 372 |
$result[$key] = iwp_mmb_convert_wperror_obj_to_arr($value,"intermediate"); |
| 373 |
} |
| 374 |
}elseif(is_object($obj) && is_wp_error($obj)){ |
| 375 |
$result['error_codes'] = $obj->get_error_codes(); |
| 376 |
$result['errors'] = $obj->get_error_messages(); |
| 377 |
$result['error_data'] = $obj->get_error_data(); |
| 378 |
}else{ |
| 379 |
return $obj; |
| 380 |
} |
| 381 |
if($state == 'initial' ){ |
| 382 |
if(isset($obj['error']) && is_wp_error($obj['error'])){ |
| 383 |
$errMsgTemp = $result['error']['errors']; |
| 384 |
$errCodesTemp = $result['error']['error_codes']; |
| 385 |
if(!empty($result['error']['error_data']) ){ |
| 386 |
$errData = ":::".$result['error']['error_data']; |
| 387 |
}else{ |
| 388 |
$errData = ''; |
| 389 |
} |
| 390 |
|
| 391 |
$errMsg =''; |
| 392 |
$errCode = ''; |
| 393 |
|
| 394 |
if(count($errMsgTemp) > 1 ){$errMsg = implode("|&|",$errMsgTemp);}elseif(count($errMsgTemp) == 1){$errMsg = $errMsgTemp[0];} |
| 395 |
if(count($errCodesTemp) > 1 ){$errCode = implode("|&|",$errCodesTemp);}elseif(count($errCodesTemp) == 1){$errCode = $errCodesTemp[0];} |
| 396 |
|
| 397 |
$wpErr = array('error'=>$errMsg.$errData,'error_code'=>$errCode,'error_data'=>$errData); |
| 398 |
return $wpErr; |
| 399 |
} |
| 400 |
} |
| 401 |
return $result; |
| 402 |
} |
| 403 |
} |
| 404 |
|
| 405 |
/* Main response function */ |
| 406 |
if( !function_exists ( 'iwp_mmb_response' )) { |
| 407 |
|
| 408 |
function iwp_mmb_response($response = false, $success = true, $send_serialize_response=false) |
| 409 |
{ |
| 410 |
$return = array(); |
| 411 |
|
| 412 |
$response = iwp_mmb_convert_wperror_obj_to_arr($response,'initial'); |
| 413 |
|
| 414 |
if ((is_array($response) && empty($response)) || (!is_array($response) && strlen($response) == 0)){ |
| 415 |
$return['error'] = 'Empty response.'; |
| 416 |
$return['error_code'] = 'empty_response'; |
| 417 |
} |
| 418 |
else if ($success){ |
| 419 |
$return['success'] = $response; |
| 420 |
} |
| 421 |
else{ |
| 422 |
$return['error'] = $response['error']; |
| 423 |
$return['error_code'] = !empty($response['error_code'])?$response['error_code']: ''; |
| 424 |
} |
| 425 |
|
| 426 |
if( !headers_sent() ){ |
| 427 |
$protocol = 'HTTP/1.1'; |
| 428 |
if (isset($_SERVER['SERVER_PROTOCOL'])) { |
| 429 |
$protocol = $_SERVER['SERVER_PROTOCOL']; |
| 430 |
} |
| 431 |
header($protocol.' 200 OK'); |
| 432 |
header('Content-Type: text/plain'); |
| 433 |
} |
| 434 |
if (!$send_serialize_response) { |
| 435 |
$GLOBALS['IWP_RESPONSE_SENT'] = true; |
| 436 |
$response_data = '_IWP_JSON_PREFIX_'.base64_encode(iwp_mmb_json_encode($return)); |
| 437 |
}else{ |
| 438 |
$GLOBALS['IWP_RESPONSE_SENT'] = true; |
| 439 |
$response_data = base64_encode(serialize($return)); |
| 440 |
} |
| 441 |
$txt= "<IWPHEADER>" .$response_data."<ENDIWPHEADER>"; |
| 442 |
if (defined('IWP_RESPONSE_HEADER_CLOSE') && IWP_RESPONSE_HEADER_CLOSE) { |
| 443 |
ignore_user_abort(true); |
| 444 |
ob_end_clean(); |
| 445 |
ob_start(); |
| 446 |
echo ($txt); |
| 447 |
$size = ob_get_length(); |
| 448 |
header("Connection: close\r\n"); |
| 449 |
header("Content-Encoding: none\r\n"); |
| 450 |
header("Content-Length: $size"); |
| 451 |
@ob_flush(); |
| 452 |
flush(); |
| 453 |
ob_end_flush(); |
| 454 |
exit(1); |
| 455 |
}else{ |
| 456 |
exit($txt); |
| 457 |
} |
| 458 |
} |
| 459 |
} |
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
if( !function_exists ( 'iwp_mmb_add_site' )) { |
| 464 |
function iwp_mmb_add_site($params) |
| 465 |
{ |
| 466 |
global $iwp_mmb_core, $iwp_mmb_activities_log; |
| 467 |
$num = extract($params); |
| 468 |
|
| 469 |
if ($num) { |
| 470 |
if (!$iwp_mmb_core->get_option('iwp_client_action_message_id') && !$iwp_mmb_core->get_option('iwp_client_public_key')) { |
| 471 |
$public_key = base64_decode($public_key); |
| 472 |
$activation_key = trim($activation_key); |
| 473 |
if(empty($activation_key) || empty(get_option('iwp_client_activate_key'))){ |
| 474 |
iwp_mmb_response(array('error' => 'Invalid activation key', 'error_code' => 'iwp_mmb_add_site_invalid_activation_key'), false); |
| 475 |
return; |
| 476 |
} |
| 477 |
if($activation_key !== get_option('iwp_client_activate_key')){ //iwp |
| 478 |
iwp_mmb_response(array('error' => 'Invalid activation key', 'error_code' => 'iwp_mmb_add_site_invalid_activation_key'), false); |
| 479 |
return; |
| 480 |
} |
| 481 |
|
| 482 |
if (checkOpenSSL() && empty($user_random_key_signing)) { |
| 483 |
$verify = 0; |
| 484 |
if(!empty($signature_new) && defined('OPENSSL_ALGO_SHA256')){ |
| 485 |
$verify = openssl_verify($action . $id, base64_decode($signature_new), $public_key, OPENSSL_ALGO_SHA256); |
| 486 |
}elseif (!empty($signature)) { |
| 487 |
$verify = openssl_verify($action . $id, base64_decode($signature), $public_key); |
| 488 |
} |
| 489 |
if ($verify == 1) { |
| 490 |
$iwp_mmb_core->set_admin_panel_public_key($public_key); |
| 491 |
$iwp_mmb_core->set_client_message_id($id); |
| 492 |
$iwp_mmb_core->get_stats_instance(); |
| 493 |
if(isset($notifications) && is_array($notifications) && !empty($notifications)){ |
| 494 |
$iwp_mmb_core->stats_instance->set_notifications($notifications); |
| 495 |
} |
| 496 |
if(isset($brand) && is_array($brand) && !empty($brand)){ |
| 497 |
update_option('iwp_client_brand',$brand); |
| 498 |
} |
| 499 |
|
| 500 |
iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true); |
| 501 |
$iwp_mmb_activities_log->iwp_mmb_update_is_save_activity_log($params['is_save_activity_log']); |
| 502 |
$iwp_mmb_activities_log->iwp_mmb_save_options_for_activity_log('add_site'); |
| 503 |
delete_option('iwp_client_activate_key');//iwp |
| 504 |
} else if ($verify == 0) { |
| 505 |
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); |
| 506 |
} else { |
| 507 |
iwp_mmb_response(array('error' => 'Command not successful. Please try again.', 'error_code' => 'iwp_mmb_add_site_command_not_successful'), false); |
| 508 |
} |
| 509 |
} else { |
| 510 |
if (!get_option('iwp_client_nossl_key')) { |
| 511 |
srand(); |
| 512 |
|
| 513 |
$random_key = md5(base64_encode($public_key) . rand(0, getrandmax())); |
| 514 |
|
| 515 |
$iwp_mmb_core->set_random_signature($random_key); |
| 516 |
$iwp_mmb_core->set_client_message_id($id); |
| 517 |
$iwp_mmb_core->set_admin_panel_public_key($public_key); |
| 518 |
$iwp_mmb_core->get_stats_instance(); |
| 519 |
if(isset($notifications) && is_array($notifications) && !empty($notifications)){ |
| 520 |
$iwp_mmb_core->stats_instance->set_notifications($notifications); |
| 521 |
} |
| 522 |
|
| 523 |
if(isset($brand) && is_array($brand) && !empty($brand)){ |
| 524 |
update_option('iwp_client_brand',$brand); |
| 525 |
} |
| 526 |
$iwp_mmb_activities_log->iwp_mmb_update_is_save_activity_log($params['is_save_activity_log']); |
| 527 |
$iwp_mmb_activities_log->iwp_mmb_save_options_for_activity_log('add_site'); |
| 528 |
iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true); |
| 529 |
delete_option('iwp_client_activate_key');//IWP |
| 530 |
} else |
| 531 |
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); |
| 532 |
} |
| 533 |
} else { |
| 534 |
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); |
| 535 |
} |
| 536 |
} else { |
| 537 |
iwp_mmb_response(array('error' => 'Invalid parameters received. Please try again.', 'error_code' => 'iwp_mmb_add_site_invalid_parameters_received'), false); |
| 538 |
} |
| 539 |
} |
| 540 |
} |
| 541 |
|
| 542 |
if( !function_exists ( 'iwp_mmb_readd_site' )) { |
| 543 |
function iwp_mmb_readd_site($params){ |
| 544 |
global $iwp_mmb_core,$iwp_mmb_activities_log; |
| 545 |
$num = extract($params); |
| 546 |
if ($num) { |
| 547 |
if (!get_option('iwp_client_action_message_id') && !get_option('iwp_client_public_key')) { |
| 548 |
$public_key = base64_decode($public_key); |
| 549 |
$activation_key = trim($activation_key); |
| 550 |
if(empty($activation_key) || empty(get_option('iwp_client_activate_key'))){ |
| 551 |
iwp_mmb_response(array('error' => 'Invalid activation key', 'error_code' => 'iwp_mmb_add_site_invalid_activation_key'), false); |
| 552 |
return; |
| 553 |
} |
| 554 |
if($activation_key !== get_option('iwp_client_activate_key')){ //iwp |
| 555 |
iwp_mmb_response(array('error' => 'Invalid activation key', 'error_code' => 'iwp_mmb_add_site_invalid_activation_key'), false); |
| 556 |
return; |
| 557 |
} |
| 558 |
if (checkOpenSSL() && empty($user_random_key_signing)) { |
| 559 |
$verify = 0; |
| 560 |
if(!empty($signature_new) && defined('OPENSSL_ALGO_SHA256')){ |
| 561 |
$verify = openssl_verify($action . $id, $signature_new, $public_key, OPENSSL_ALGO_SHA256); |
| 562 |
}else{ |
| 563 |
$verify = openssl_verify($action . $id, $signature, $public_key); |
| 564 |
} |
| 565 |
if ($verify == 1) { |
| 566 |
$iwp_mmb_core->set_admin_panel_public_key($public_key); |
| 567 |
$iwp_mmb_core->set_client_message_id($id); |
| 568 |
$iwp_mmb_core->get_stats_instance(); |
| 569 |
if(isset($notifications) && is_array($notifications) && !empty($notifications)){ |
| 570 |
$iwp_mmb_core->stats_instance->set_notifications($notifications); |
| 571 |
} |
| 572 |
if(isset($brand) && is_array($brand) && !empty($brand)){ |
| 573 |
update_option('iwp_client_brand',$brand); |
| 574 |
} |
| 575 |
$iwp_mmb_activities_log->iwp_mmb_update_is_save_activity_log($params['is_save_activity_log']); |
| 576 |
$iwp_mmb_activities_log->iwp_mmb_save_options_for_activity_log('readd_site'); |
| 577 |
iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true); |
| 578 |
delete_option('iwp_client_activate_key');//iwp |
| 579 |
} else if ($verify == 0) { |
| 580 |
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); |
| 581 |
} else { |
| 582 |
iwp_mmb_response(array('error' => 'Command not successful. Please try again.', 'error_code' => 'iwp_mmb_readd_site_command_not_successful'), false); |
| 583 |
} |
| 584 |
} else { |
| 585 |
if (!get_option('iwp_client_nossl_key')) { |
| 586 |
srand(); |
| 587 |
|
| 588 |
$random_key = md5(base64_encode($public_key) . rand(0, getrandmax())); |
| 589 |
|
| 590 |
$iwp_mmb_core->set_random_signature($random_key); |
| 591 |
$iwp_mmb_core->set_client_message_id($id); |
| 592 |
$iwp_mmb_core->set_admin_panel_public_key($public_key); |
| 593 |
$iwp_mmb_core->get_stats_instance(); |
| 594 |
if(isset($notifications) && is_array($notifications) && !empty($notifications)){ |
| 595 |
$iwp_mmb_core->stats_instance->set_notifications($notifications); |
| 596 |
} |
| 597 |
|
| 598 |
if(isset($brand) && is_array($brand) && !empty($brand)){ |
| 599 |
update_option('iwp_client_brand',$brand); |
| 600 |
} |
| 601 |
$iwp_mmb_activities_log->iwp_mmb_update_is_save_activity_log($params['is_save_activity_log']); |
| 602 |
$iwp_mmb_activities_log->iwp_mmb_save_options_for_activity_log('readd_site'); |
| 603 |
iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true); |
| 604 |
delete_option('iwp_client_activate_key');//IWP |
| 605 |
} else |
| 606 |
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); |
| 607 |
} |
| 608 |
} else { |
| 609 |
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); |
| 610 |
} |
| 611 |
} else { |
| 612 |
iwp_mmb_response(array('error' => 'Invalid parameters received. Please try again.', 'error_code' => 'iwp_mmb_add_site_invalid_parameters_received'), false); |
| 613 |
} |
| 614 |
} |
| 615 |
} |
| 616 |
|
| 617 |
if(!function_exists('iwp_mmb_maintain_site')){ |
| 618 |
function iwp_mmb_maintain_site($params){ |
| 619 |
$check = 1; |
| 620 |
if(get_option('iwp_mmb_maintenance_mode') != $params['maintenance_mode']) |
| 621 |
if(update_option('iwp_mmb_maintenance_mode',$params['maintenance_mode']) ){ $check = 1;}else{$check = 0;} |
| 622 |
if(get_option('iwp_mmb_maintenance_html') != $params['maintenance_html']) |
| 623 |
if(update_option('iwp_mmb_maintenance_html',$params['maintenance_html']) ){ $check = 1;}else{$check = 0;} |
| 624 |
if($check == 1){ |
| 625 |
iwp_mmb_response($params, true); |
| 626 |
}else{ |
| 627 |
iwp_mmb_response(array('error' => 'Some error with database connection in client site', 'error_code' => 'database_connection_in_client_site'), false); |
| 628 |
} |
| 629 |
} |
| 630 |
} |
| 631 |
|
| 632 |
|
| 633 |
if( !function_exists ( 'iwp_mmb_remove_site' )) { |
| 634 |
function iwp_mmb_remove_site($params) |
| 635 |
{ |
| 636 |
extract($params); |
| 637 |
global $iwp_mmb_core; |
| 638 |
$iwp_mmb_core->uninstall( $deactivate ); |
| 639 |
|
| 640 |
include_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
| 641 |
$plugin_slug = basename(dirname(__FILE__)) . '/' . basename(__FILE__); |
| 642 |
|
| 643 |
if ($deactivate) { |
| 644 |
deactivate_plugins($plugin_slug, true); |
| 645 |
} |
| 646 |
|
| 647 |
if (!is_plugin_active($plugin_slug)) |
| 648 |
iwp_mmb_response(array( |
| 649 |
'deactivated' => 'Site removed successfully. <br /><br />InfiniteWP Client plugin successfully deactivated.' |
| 650 |
), true); |
| 651 |
else |
| 652 |
iwp_mmb_response(array( |
| 653 |
'removed_data' => 'Site removed successfully. <br /><br /><b>InfiniteWP Client plugin was not deactivated.</b>' |
| 654 |
), true); |
| 655 |
|
| 656 |
} |
| 657 |
} |
| 658 |
if( !function_exists ( 'iwp_mmb_stats_get' )) { |
| 659 |
function iwp_mmb_stats_get($params) |
| 660 |
{ |
| 661 |
global $iwp_mmb_core; |
| 662 |
$iwp_mmb_core->get_stats_instance(); |
| 663 |
iwp_mmb_response($iwp_mmb_core->stats_instance->get($params), true); |
| 664 |
} |
| 665 |
} |
| 666 |
|
| 667 |
if( !function_exists ( 'iwp_mmb_client_header' )) { |
| 668 |
function iwp_mmb_client_header() |
| 669 |
{ global $iwp_mmb_core, $current_user; |
| 670 |
|
| 671 |
if(!headers_sent()){ |
| 672 |
if(isset($current_user->ID)) |
| 673 |
$expiration = time() + apply_filters('auth_cookie_expiration', 10800, $current_user->ID, false); |
| 674 |
else |
| 675 |
$expiration = time() + 10800; |
| 676 |
|
| 677 |
setcookie(IWP_MMB_XFRAME_COOKIE, md5(IWP_MMB_XFRAME_COOKIE), $expiration, COOKIEPATH, COOKIE_DOMAIN, false, true); |
| 678 |
$_COOKIE[IWP_MMB_XFRAME_COOKIE] = md5(IWP_MMB_XFRAME_COOKIE); |
| 679 |
} |
| 680 |
} |
| 681 |
} |
| 682 |
|
| 683 |
if( !function_exists ( 'iwp_mmb_pre_init_stats' )) { |
| 684 |
function iwp_mmb_pre_init_stats( $params ) |
| 685 |
{ |
| 686 |
global $iwp_mmb_core; |
| 687 |
$iwp_mmb_core->get_stats_instance(); |
| 688 |
return $iwp_mmb_core->stats_instance->pre_init_stats($params); |
| 689 |
} |
| 690 |
} |
| 691 |
|
| 692 |
if( !function_exists ( 'iwp_mmb_trigger_check_new' )) { |
| 693 |
//backup multi call trigger and status check. |
| 694 |
function iwp_mmb_trigger_check_new($params) |
| 695 |
{ |
| 696 |
global $iwp_backup_core; |
| 697 |
$return = $iwp_backup_core->getRunningBackupStatus($params); |
| 698 |
|
| 699 |
if (is_array($return) && array_key_exists('error', $return)) |
| 700 |
iwp_mmb_response($return, false); |
| 701 |
else { |
| 702 |
iwp_mmb_response($return, true); |
| 703 |
} |
| 704 |
} |
| 705 |
} |
| 706 |
|
| 707 |
if( !function_exists ( 'iwp_pheonix_backup_cron_do_action' )) { |
| 708 |
//backup multi call trigger and status check. |
| 709 |
function iwp_pheonix_backup_cron_do_action($params) |
| 710 |
{ |
| 711 |
global $iwp_backup_core; |
| 712 |
$return = $iwp_backup_core->iwp_pheonix_backup_cron_do_action($params); |
| 713 |
|
| 714 |
if (is_array($return) && array_key_exists('error', $return)) |
| 715 |
iwp_mmb_response($return, false); |
| 716 |
else { |
| 717 |
iwp_mmb_response($return, true); |
| 718 |
} |
| 719 |
} |
| 720 |
} |
| 721 |
|
| 722 |
if( !function_exists ( 'iwp_mmb_trigger_check' )) { |
| 723 |
//backup multi call trigger and status check. |
| 724 |
function iwp_mmb_trigger_check($params) |
| 725 |
{ |
| 726 |
global $iwp_mmb_core; |
| 727 |
$iwp_mmb_core->get_backup_instance($params['mechanism']); |
| 728 |
$return = $iwp_mmb_core->backup_instance->trigger_check($params); |
| 729 |
|
| 730 |
if (is_array($return) && array_key_exists('error', $return)) |
| 731 |
iwp_mmb_response($return, false); |
| 732 |
else { |
| 733 |
iwp_mmb_response($return, true); |
| 734 |
} |
| 735 |
} |
| 736 |
} |
| 737 |
|
| 738 |
|
| 739 |
if( !function_exists ( 'iwp_mmb_backup_now' )) { |
| 740 |
//backup |
| 741 |
function iwp_mmb_backup_now($params) |
| 742 |
{ |
| 743 |
global $iwp_mmb_core; |
| 744 |
|
| 745 |
$iwp_mmb_core->get_backup_instance(); |
| 746 |
$return = $iwp_mmb_core->backup_instance->backup($params); |
| 747 |
|
| 748 |
if (is_array($return) && array_key_exists('error', $return)) |
| 749 |
iwp_mmb_response($return, false); |
| 750 |
else { |
| 751 |
iwp_mmb_response($return, true); |
| 752 |
} |
| 753 |
} |
| 754 |
} |
| 755 |
|
| 756 |
if( !function_exists ( 'iwp_get_additional_stats' )) { |
| 757 |
//backup |
| 758 |
function iwp_get_additional_stats($params) |
| 759 |
{ |
| 760 |
global $iwp_mmb_core, $iwp_mmb_plugin_dir; |
| 761 |
$response = array(); |
| 762 |
if (!empty($params['requiredActions']) && isset($params['requiredActions']['get_all_links'])) { |
| 763 |
$iwp_mmb_core->wp_blc_get_blinks(); |
| 764 |
$brokenlinks = $iwp_mmb_core->blc_get_blinks->blc_get_all_links(); |
| 765 |
if (is_array($brokenlinks) && !array_key_exists('error', $brokenlinks)) |
| 766 |
$response['get_all_links'] = $brokenlinks; |
| 767 |
} |
| 768 |
if (!empty($params['requiredActions']) && isset($params['requiredActions']['ithemes_security_check'])) { |
| 769 |
if (iwp_mmb_ithemes_security_check()) { |
| 770 |
$ithemessec_instance = $iwp_mmb_core->get_ithemessec_instance(); |
| 771 |
$return = $ithemessec_instance->securityCheck(); |
| 772 |
if (isset($return['security_check'])) { |
| 773 |
$response['ithemes_security_check'] = $return['security_check']; |
| 774 |
} |
| 775 |
} |
| 776 |
} |
| 777 |
if (!empty($params['requiredActions']) && isset($params['requiredActions']['sucuri_fetch_result'])) { |
| 778 |
require_once("$iwp_mmb_plugin_dir/addons/malware_scanner_sucuri/malware_scanner_sucuri.class.php"); |
| 779 |
$iwp_mmb_core->get_sucuri_instance(); |
| 780 |
|
| 781 |
$return = $iwp_mmb_core->sucuri_instance->getScannedCacheResult(); |
| 782 |
if (is_array($return) && !array_key_exists('error', $return)) |
| 783 |
$response['sucuri_fetch_result'] = $return; |
| 784 |
} |
| 785 |
|
| 786 |
if (!empty($params['requiredActions']) && isset($params['requiredActions']['get_comments'])) { |
| 787 |
require_once("$iwp_mmb_plugin_dir/addons/malware_scanner_sucuri/malware_scanner_sucuri.class.php"); |
| 788 |
$iwp_mmb_core->get_comment_instance(); |
| 789 |
|
| 790 |
$return = $iwp_mmb_core->comment_instance->get_comments($params['requiredActions']['get_comments']); |
| 791 |
if (is_array($return) && !array_key_exists('error', $return)) |
| 792 |
$response['get_comments'] = $return; |
| 793 |
} |
| 794 |
|
| 795 |
if (!empty($params['requiredActions']) && isset($params['requiredActions']['get_users'])) { |
| 796 |
$iwp_mmb_core->get_user_instance(); |
| 797 |
|
| 798 |
$return = $iwp_mmb_core->user_instance->get_users($params['requiredActions']['get_users']); |
| 799 |
if (is_array($return) && !array_key_exists('error', $return)) |
| 800 |
$response['get_users'] = $return; |
| 801 |
} |
| 802 |
|
| 803 |
if (!empty($params['requiredActions']) && isset($params['requiredActions']['wordfence_load'])) { |
| 804 |
global $iwp_mmb_core,$iwp_mmb_plugin_dir; |
| 805 |
require_once("$iwp_mmb_plugin_dir/addons/wordfence/wordfence.class.php"); |
| 806 |
$iwp_mmb_core->get_wordfence_instance(); |
| 807 |
|
| 808 |
$return = $iwp_mmb_core->wordfence_instance->load($params); |
| 809 |
if (is_array($return) && !array_key_exists('error', $return)) |
| 810 |
$response['wordfence_load'] = $return; |
| 811 |
} |
| 812 |
// bulk publish |
| 813 |
if (!empty($params['requiredActions']) && isset($params['requiredActions']['get_bulkposts'])) { |
| 814 |
$iwp_mmb_core->get_post_instance(); |
| 815 |
$return = $iwp_mmb_core->post_instance->get_posts($params['requiredActions']['get_bulkposts']); |
| 816 |
if (is_array($return) && !array_key_exists('error', $return)) |
| 817 |
$response['get_bulkposts'] = $return; |
| 818 |
} |
| 819 |
|
| 820 |
if (!empty($params['requiredActions']) && isset($params['requiredActions']['get_bulkpages'])) { |
| 821 |
$iwp_mmb_core->get_post_instance(); |
| 822 |
$return = $iwp_mmb_core->post_instance->get_pages($params['requiredActions']['get_bulkpages']); |
| 823 |
if (is_array($return) && !array_key_exists('error', $return)) |
| 824 |
$response['get_bulkpages'] = $return; |
| 825 |
} |
| 826 |
|
| 827 |
if (!empty($params['requiredActions']) && isset($params['requiredActions']['get_bulklinks'])) { |
| 828 |
$iwp_mmb_core->get_link_instance(); |
| 829 |
$return = $iwp_mmb_core->link_instance->get_links($params['requiredActions']['get_bulklinks']); |
| 830 |
if (is_array($return) && !array_key_exists('error', $return)) |
| 831 |
$response['get_bulklinks'] = $return; |
| 832 |
} |
| 833 |
|
| 834 |
if (is_array($response) && array_key_exists('error', $response)) |
| 835 |
iwp_mmb_response($response, false); |
| 836 |
else { |
| 837 |
iwp_mmb_response($response, true); |
| 838 |
} |
| 839 |
} |
| 840 |
} |
| 841 |
|
| 842 |
if( !function_exists ( 'iwp_mmb_new_scheduled_backup' )) { |
| 843 |
function iwp_mmb_new_scheduled_backup($params) |
| 844 |
{ |
| 845 |
global $iwp_mmb_core; |
| 846 |
$iwp_mmb_core->flush_redis_cache(); |
| 847 |
|
| 848 |
require_once($GLOBALS['iwp_mmb_plugin_dir']."/backup/backup-repo-test.php"); |
| 849 |
global $iwp_backup_core; |
| 850 |
|
| 851 |
if (!empty($params['backup_nounce'])) { |
| 852 |
$backupId = $params['backup_nounce']; |
| 853 |
}else{ |
| 854 |
$backupId = $iwp_backup_core->backup_time_nonce(); |
| 855 |
} |
| 856 |
|
| 857 |
$msg = array( |
| 858 |
'backup_id' => $backupId, |
| 859 |
'parentHID' => $params['args']['parentHID'], |
| 860 |
'success' => 'Backup started', |
| 861 |
'wp_content_url' => content_url(), |
| 862 |
); |
| 863 |
$iwp_backup_dir = $iwp_backup_core->backups_dir_location(); |
| 864 |
if (is_array($iwp_backup_dir) && array_key_exists('error', $iwp_backup_dir)){ |
| 865 |
iwp_closeBrowserConnection($iwp_backup_dir, false); |
| 866 |
} |
| 867 |
// Close browser connection not working for some servers so we suggest IWP_PHOENIX_BACKUP_CRON |
| 868 |
// iwp_closeBrowserConnection( $msg ); |
| 869 |
if ((!defined('DISABLE_IWP_CLOUD_VERIFICATION')) && (empty($params['args']['disable_iwp_cloud_verification']))) { |
| 870 |
require_once($GLOBALS['iwp_mmb_plugin_dir']."/backup.class.multicall.php"); |
| 871 |
$backup_repo_test_obj = new IWP_BACKUP_REPO_TEST(); |
| 872 |
$backup_repo_test_result = $backup_repo_test_obj->repositoryTestConnection($params['account_info']); |
| 873 |
if (!empty($backup_repo_test_result['error']) && $backup_repo_test_result['status'] != 'success') { |
| 874 |
$return = array('error' => $backup_repo_test_result['error'], 'error_code' => $backup_repo_test_result['error_code']); |
| 875 |
iwp_mmb_response($return, false); |
| 876 |
} |
| 877 |
} |
| 878 |
if (is_array($msg) && array_key_exists('error', $msg)) |
| 879 |
iwp_closeBrowserConnection($msg, false); |
| 880 |
else { |
| 881 |
iwp_closeBrowserConnection($msg, true); |
| 882 |
} |
| 883 |
$iwp_backup_core->set_backup_task_option($params); |
| 884 |
if (!empty($params['args']['exclude'])) { |
| 885 |
$params['restrict_files_to_override']= explode(',', $params['args']['exclude']); |
| 886 |
} |
| 887 |
// return true; |
| 888 |
if (defined('IWP_PHOENIX_BACKUP_CRON_START') && IWP_PHOENIX_BACKUP_CRON_START) { |
| 889 |
$params['cron_start'] = 1; |
| 890 |
} |
| 891 |
$params['use_nonce'] = $backupId; |
| 892 |
$params['label'] = $params['task_name']; |
| 893 |
$params['backup_name'] = $params['args']['backup_name']; |
| 894 |
if ($params['args']['what'] == 'db') { |
| 895 |
// $return = $iwp_mmb_core->backup_new_instance->backupnow_database($params); |
| 896 |
do_action( 'IWP_backupnow_backup_database', $params ); |
| 897 |
} elseif ($params['args']['what'] == 'files') { |
| 898 |
// $return = $iwp_mmb_core->backup_new_instance->backupnow_files($params); |
| 899 |
do_action( 'IWP_backupnow_backup', $params ); |
| 900 |
} else { |
| 901 |
// $return = $iwp_mmb_core->backup_new_instance->backup_all($params); |
| 902 |
do_action( 'IWP_backupnow_backup_all', $params ); |
| 903 |
} |
| 904 |
|
| 905 |
} |
| 906 |
} |
| 907 |
|
| 908 |
if( !function_exists ( 'iwp_mmb_run_task_now' )) { |
| 909 |
function iwp_mmb_run_task_now($params) |
| 910 |
{ |
| 911 |
global $iwp_mmb_core; |
| 912 |
$iwp_mmb_core->get_backup_instance($params['mechanism']); |
| 913 |
//$return = $iwp_mmb_core->backup_instance->task_now(); //set_backup_task($params) |
| 914 |
$return = $iwp_mmb_core->backup_instance->set_backup_task($params); |
| 915 |
if (is_array($return) && array_key_exists('error', $return)) |
| 916 |
iwp_mmb_response($return, false); |
| 917 |
else { |
| 918 |
iwp_mmb_response($return, true); |
| 919 |
} |
| 920 |
} |
| 921 |
} |
| 922 |
|
| 923 |
if( !function_exists ( 'iwp_mmb_delete_task_now' )) { |
| 924 |
function iwp_mmb_delete_task_now($params) |
| 925 |
{ |
| 926 |
global $iwp_mmb_core; |
| 927 |
$iwp_mmb_core->get_backup_instance(); |
| 928 |
$return = $iwp_mmb_core->backup_instance->delete_task_now($params['task_name']); |
| 929 |
if (is_array($return) && array_key_exists('error', $return)) |
| 930 |
iwp_mmb_response($return, false); |
| 931 |
else { |
| 932 |
iwp_mmb_response($return, true); |
| 933 |
} |
| 934 |
} |
| 935 |
} |
| 936 |
if( !function_exists ( 'iwp_mmb_check_backup_compat' )) { |
| 937 |
function iwp_mmb_check_backup_compat($params) |
| 938 |
{ |
| 939 |
global $iwp_mmb_core; |
| 940 |
$iwp_mmb_core->get_backup_instance(); |
| 941 |
$return = $iwp_mmb_core->backup_instance->check_backup_compat($params); |
| 942 |
|
| 943 |
if (is_array($return) && array_key_exists('error', $return)) |
| 944 |
iwp_mmb_response($return, false); |
| 945 |
else { |
| 946 |
iwp_mmb_response($return, true); |
| 947 |
} |
| 948 |
} |
| 949 |
} |
| 950 |
|
| 951 |
if( !function_exists ( 'iwp_mmb_get_backup_req' )) { |
| 952 |
function iwp_mmb_get_backup_req( $params ) |
| 953 |
{ |
| 954 |
global $iwp_mmb_core; |
| 955 |
$iwp_mmb_core->get_stats_instance(); |
| 956 |
$return = $iwp_mmb_core->stats_instance->get_backup_req($params); |
| 957 |
|
| 958 |
if (is_array($return) && array_key_exists('error', $return)) |
| 959 |
iwp_mmb_response($return, false); |
| 960 |
else { |
| 961 |
iwp_mmb_response($return, true); |
| 962 |
} |
| 963 |
} |
| 964 |
} |
| 965 |
|
| 966 |
|
| 967 |
if( !function_exists ( 'iwp_mmb_scheduled_backup' )) { |
| 968 |
function iwp_mmb_scheduled_backup($params) |
| 969 |
{ |
| 970 |
global $iwp_mmb_core; |
| 971 |
$iwp_mmb_core->get_backup_instance($params['mechanism']); |
| 972 |
$return = $iwp_mmb_core->backup_instance->set_backup_task($params); |
| 973 |
iwp_mmb_response($return, $return); |
| 974 |
} |
| 975 |
} |
| 976 |
|
| 977 |
if( !function_exists ( 'iwp_get_db_details' )) { |
| 978 |
function iwp_get_db_details($params) |
| 979 |
{ |
| 980 |
global $iwp_mmb_core; |
| 981 |
$return = $iwp_mmb_core->get_db_details($params); |
| 982 |
iwp_mmb_response($return, $return); |
| 983 |
} |
| 984 |
} |
| 985 |
|
| 986 |
if( !function_exists ( 'iwp_client_report_delete_log' )) { |
| 987 |
function iwp_client_report_delete_log($params) |
| 988 |
{ |
| 989 |
global $iwp_mmb_activities_log; |
| 990 |
$return = $iwp_mmb_activities_log->iwp_client_report_delete_log($params['params']); |
| 991 |
if (is_array($return) && array_key_exists('error', $return)) |
| 992 |
iwp_mmb_response($return, false); |
| 993 |
else { |
| 994 |
iwp_mmb_response($return, true); |
| 995 |
} |
| 996 |
} |
| 997 |
} |
| 998 |
|
| 999 |
if( !function_exists ( 'iwp_mmb_new_run_task_now' )) { |
| 1000 |
function iwp_mmb_new_run_task_now($params) |
| 1001 |
{ |
| 1002 |
global $iwp_mmb_core; |
| 1003 |
$iwp_mmb_core->flush_redis_cache(); |
| 1004 |
|
| 1005 |
require_once($GLOBALS['iwp_mmb_plugin_dir']."/backup/backup-repo-test.php"); |
| 1006 |
global $iwp_backup_core; |
| 1007 |
|
| 1008 |
if (!empty($params['backup_nounce'])) { |
| 1009 |
$backupId = $params['backup_nounce']; |
| 1010 |
}else{ |
| 1011 |
$backupId = $iwp_backup_core->backup_time_nonce(); |
| 1012 |
} |
| 1013 |
|
| 1014 |
$msg = array( |
| 1015 |
'backup_id' => $backupId, |
| 1016 |
'parentHID' => $params['args']['parentHID'], |
| 1017 |
'success' => 'Backup started', |
| 1018 |
'wp_content_url' => content_url(), |
| 1019 |
); |
| 1020 |
$iwp_backup_dir = $iwp_backup_core->backups_dir_location(); |
| 1021 |
if (is_array($iwp_backup_dir) && array_key_exists('error', $iwp_backup_dir)){ |
| 1022 |
iwp_closeBrowserConnection($iwp_backup_dir, false); |
| 1023 |
} |
| 1024 |
// Close browser connection not working for some servers so we suggest IWP_PHOENIX_BACKUP_CRON |
| 1025 |
// iwp_closeBrowserConnection( $msg ); |
| 1026 |
if ((!defined('DISABLE_IWP_CLOUD_VERIFICATION')) && (empty($params['args']['disable_iwp_cloud_verification']))) { |
| 1027 |
require_once($GLOBALS['iwp_mmb_plugin_dir']."/backup.class.multicall.php"); |
| 1028 |
$backup_repo_test_obj = new IWP_BACKUP_REPO_TEST(); |
| 1029 |
$backup_repo_test_result = $backup_repo_test_obj->repositoryTestConnection($params['account_info']); |
| 1030 |
if (!empty($backup_repo_test_result['error']) && $backup_repo_test_result['status'] != 'success') { |
| 1031 |
$return = array('error' => $backup_repo_test_result['error'], 'error_code' => $backup_repo_test_result['error_code']); |
| 1032 |
iwp_mmb_response($return, false); |
| 1033 |
} |
| 1034 |
} |
| 1035 |
if (is_array($msg) && array_key_exists('error', $msg)) |
| 1036 |
iwp_closeBrowserConnection($msg, false); |
| 1037 |
else { |
| 1038 |
iwp_closeBrowserConnection($msg, true); |
| 1039 |
} |
| 1040 |
$iwp_backup_core->set_backup_task_option($params); |
| 1041 |
if (!empty($params['args']['exclude'])) { |
| 1042 |
$params['restrict_files_to_override']= explode(',', $params['args']['exclude']); |
| 1043 |
} |
| 1044 |
// return true; |
| 1045 |
if (defined('IWP_PHOENIX_BACKUP_CRON_START') && IWP_PHOENIX_BACKUP_CRON_START) { |
| 1046 |
$params['cron_start'] = 1; |
| 1047 |
} |
| 1048 |
$params['use_nonce'] = $backupId; |
| 1049 |
$params['label'] = $params['task_name']; |
| 1050 |
$params['backup_name'] = $params['args']['backup_name']; |
| 1051 |
if ($params['args']['what'] == 'db') { |
| 1052 |
// $return = $iwp_mmb_core->backup_new_instance->backupnow_database($params); |
| 1053 |
do_action( 'IWP_backupnow_backup_database', $params ); |
| 1054 |
} elseif ($params['args']['what'] == 'files') { |
| 1055 |
// $return = $iwp_mmb_core->backup_new_instance->backupnow_files($params); |
| 1056 |
do_action( 'IWP_backupnow_backup', $params ); |
| 1057 |
} else { |
| 1058 |
// $return = $iwp_mmb_core->backup_new_instance->backup_all($params); |
| 1059 |
do_action( 'IWP_backupnow_backup_all', $params ); |
| 1060 |
} |
| 1061 |
|
| 1062 |
} |
| 1063 |
} |
| 1064 |
|
| 1065 |
if( !function_exists ( 'iwp_mmb_delete_backup_new' )) { |
| 1066 |
function iwp_mmb_delete_backup_new($params) |
| 1067 |
{ |
| 1068 |
global $iwp_mmb_core; |
| 1069 |
$iwp_mmb_core->get_new_backup_instance($params); |
| 1070 |
$return = $iwp_mmb_core->backup_new_instance->delete_backup($params); |
| 1071 |
iwp_mmb_response($return, $return); |
| 1072 |
} |
| 1073 |
} |
| 1074 |
|
| 1075 |
if( !function_exists ( 'iwp_mmb_kill_new_backup' )) { |
| 1076 |
function iwp_mmb_kill_new_backup($params) |
| 1077 |
{ |
| 1078 |
global $iwp_mmb_core; |
| 1079 |
$iwp_mmb_core->get_new_backup_instance($params); |
| 1080 |
$return = $iwp_mmb_core->backup_new_instance->kill_new_backup($params); |
| 1081 |
iwp_mmb_response($return, $return); |
| 1082 |
} |
| 1083 |
} |
| 1084 |
|
| 1085 |
if( !function_exists ( 'iwp_mmb_delete_backup' )) { |
| 1086 |
function iwp_mmb_delete_backup($params) |
| 1087 |
{ |
| 1088 |
global $iwp_mmb_core; |
| 1089 |
$iwp_mmb_core->get_backup_instance(); |
| 1090 |
$return = $iwp_mmb_core->backup_instance->delete_backup($params); |
| 1091 |
iwp_mmb_response($return, $return); |
| 1092 |
} |
| 1093 |
} |
| 1094 |
|
| 1095 |
if( !function_exists ( 'iwp_mmb_backup_downlaod' )) { |
| 1096 |
function iwp_mmb_backup_downlaod($params) |
| 1097 |
{ |
| 1098 |
global $iwp_mmb_core; |
| 1099 |
$iwp_mmb_core->get_new_backup_instance(); |
| 1100 |
//$return = $iwp_mmb_core->backup_instance->task_now(); //set_backup_task($params) |
| 1101 |
$return = $iwp_mmb_core->backup_new_instance->do_iwp_download_backup($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 |
if( !function_exists ( 'iwp_mmb_optimize_tables' )) { |
| 1111 |
function iwp_mmb_optimize_tables($params) |
| 1112 |
{ |
| 1113 |
global $iwp_mmb_core; |
| 1114 |
$iwp_mmb_core->get_backup_instance(); |
| 1115 |
$return = $iwp_mmb_core->backup_instance->optimize_tables(); |
| 1116 |
if ($return) |
| 1117 |
iwp_mmb_response($return, true); |
| 1118 |
else |
| 1119 |
iwp_mmb_response(false, false); |
| 1120 |
} |
| 1121 |
} |
| 1122 |
if( !function_exists ( 'iwp_mmb_restore_now' )) { |
| 1123 |
function iwp_mmb_restore_now($params) |
| 1124 |
{ |
| 1125 |
global $iwp_mmb_core; |
| 1126 |
$iwp_mmb_core->get_backup_instance('multiCall'); |
| 1127 |
$return = $iwp_mmb_core->backup_instance->restore($params); |
| 1128 |
|
| 1129 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1130 |
iwp_mmb_response($return, false); |
| 1131 |
else |
| 1132 |
iwp_mmb_response($return, true); |
| 1133 |
|
| 1134 |
} |
| 1135 |
} |
| 1136 |
|
| 1137 |
|
| 1138 |
if( !function_exists ( 'iwp_mmb_backup_repository' )) { |
| 1139 |
function iwp_mmb_backup_repository($params) |
| 1140 |
{ |
| 1141 |
global $iwp_mmb_core; |
| 1142 |
$iwp_mmb_core->get_backup_repository_instance(); |
| 1143 |
$return = $iwp_mmb_core->backup_repository_instance->backup_repository($params); |
| 1144 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1145 |
iwp_mmb_response($return, false); |
| 1146 |
else |
| 1147 |
iwp_mmb_response($return, true); |
| 1148 |
} |
| 1149 |
} |
| 1150 |
|
| 1151 |
|
| 1152 |
if( !function_exists ( 'iwp_mmb_clean_orphan_backups' )) { |
| 1153 |
function iwp_mmb_clean_orphan_backups() |
| 1154 |
{ |
| 1155 |
global $iwp_mmb_core; |
| 1156 |
$backup_instance = $iwp_mmb_core->get_backup_instance(); |
| 1157 |
$return = $iwp_mmb_core->backup_instance->cleanup(); |
| 1158 |
if(is_array($return)) |
| 1159 |
iwp_mmb_response($return, true); |
| 1160 |
else |
| 1161 |
iwp_mmb_response($return, false); |
| 1162 |
} |
| 1163 |
} |
| 1164 |
|
| 1165 |
|
| 1166 |
|
| 1167 |
add_filter( 'iwp_website_add', 'iwp_mmb_readd_backup_task' ); |
| 1168 |
|
| 1169 |
if (!function_exists('iwp_mmb_readd_backup_task')) { |
| 1170 |
function iwp_mmb_readd_backup_task($params = array()) { |
| 1171 |
global $iwp_mmb_core; |
| 1172 |
$backup_instance = $iwp_mmb_core->get_backup_instance(); |
| 1173 |
$settings = $backup_instance->readd_tasks($params); |
| 1174 |
return $settings; |
| 1175 |
} |
| 1176 |
} |
| 1177 |
|
| 1178 |
if( !function_exists ( 'iwp_mmb_update_client_plugin' )) { |
| 1179 |
function iwp_mmb_update_client_plugin($params) |
| 1180 |
{ |
| 1181 |
global $iwp_mmb_core; |
| 1182 |
iwp_mmb_response($iwp_mmb_core->update_client_plugin($params), true); |
| 1183 |
} |
| 1184 |
} |
| 1185 |
|
| 1186 |
if( !function_exists ( 'iwp_mmb_wp_checkversion' )) { |
| 1187 |
function iwp_mmb_wp_checkversion($params) |
| 1188 |
{ |
| 1189 |
include_once(ABSPATH . 'wp-includes/version.php'); |
| 1190 |
global $iwp_mmb_wp_version, $iwp_mmb_core; |
| 1191 |
iwp_mmb_response($iwp_mmb_wp_version, true); |
| 1192 |
} |
| 1193 |
} |
| 1194 |
if( !function_exists ( 'iwp_mmb_search_posts_by_term' )) { |
| 1195 |
function iwp_mmb_search_posts_by_term($params) |
| 1196 |
{ |
| 1197 |
global $iwp_mmb_core; |
| 1198 |
$iwp_mmb_core->get_search_instance(); |
| 1199 |
|
| 1200 |
$search_type = trim($params['search_type']); |
| 1201 |
$search_term = strtolower(trim($params['search_term'])); |
| 1202 |
|
| 1203 |
switch ($search_type){ |
| 1204 |
case 'plugin': |
| 1205 |
$plugins = get_option('active_plugins'); |
| 1206 |
|
| 1207 |
$have_plugin = false; |
| 1208 |
foreach ($plugins as $plugin) { |
| 1209 |
if(strpos($plugin, $search_term)>-1){ |
| 1210 |
$have_plugin = true; |
| 1211 |
} |
| 1212 |
} |
| 1213 |
if($have_plugin){ |
| 1214 |
iwp_mmb_response(serialize($plugin), true); |
| 1215 |
}else{ |
| 1216 |
iwp_mmb_response(false, false); |
| 1217 |
} |
| 1218 |
break; |
| 1219 |
case 'theme': |
| 1220 |
$theme = strtolower(get_option('template')); |
| 1221 |
if(strpos($theme, $search_term)>-1){ |
| 1222 |
iwp_mmb_response($theme, true); |
| 1223 |
}else{ |
| 1224 |
iwp_mmb_response(false, false); |
| 1225 |
} |
| 1226 |
break; |
| 1227 |
default: iwp_mmb_response(false, false); |
| 1228 |
} |
| 1229 |
$return = $iwp_mmb_core->search_instance->iwp_mmb_search_posts_by_term($params); |
| 1230 |
|
| 1231 |
iwp_mmb_response(false, false); |
| 1232 |
} |
| 1233 |
} |
| 1234 |
|
| 1235 |
if( !function_exists ( 'iwp_mmb_install_addon' )) { |
| 1236 |
function iwp_mmb_install_addon($params) |
| 1237 |
{ |
| 1238 |
global $iwp_mmb_core; |
| 1239 |
$iwp_mmb_core->get_installer_instance(); |
| 1240 |
$return = $iwp_mmb_core->installer_instance->install_remote_file($params); |
| 1241 |
iwp_mmb_response($return, true); |
| 1242 |
|
| 1243 |
} |
| 1244 |
} |
| 1245 |
|
| 1246 |
if( !function_exists ( 'iwp_mmb_do_upgrade' )) { |
| 1247 |
function iwp_mmb_do_upgrade($params) |
| 1248 |
{ |
| 1249 |
global $iwp_mmb_core, $iwp_mmb_upgrading; |
| 1250 |
$iwp_mmb_core->get_installer_instance(); |
| 1251 |
$return = $iwp_mmb_core->installer_instance->do_upgrade($params); |
| 1252 |
iwp_mmb_response($return, true); |
| 1253 |
|
| 1254 |
} |
| 1255 |
} |
| 1256 |
|
| 1257 |
if( !function_exists ( 'iwp_mmb_add_user' )) { |
| 1258 |
function iwp_mmb_add_user($params) |
| 1259 |
{ |
| 1260 |
global $iwp_mmb_core; |
| 1261 |
$iwp_mmb_core->get_user_instance(); |
| 1262 |
if(!empty($params['additional_params'])){ |
| 1263 |
$return['action_response'] = $iwp_mmb_core->user_instance->add_user($params['action_params']); |
| 1264 |
$return['additional_response'] = $iwp_mmb_core->user_instance->get_users($params['additional_params']); |
| 1265 |
if(isset($return['action_response']['error'])){ |
| 1266 |
iwp_mmb_response($return['action_response'], false); |
| 1267 |
} else { |
| 1268 |
iwp_mmb_response($return, true); |
| 1269 |
} |
| 1270 |
}else{ |
| 1271 |
$return = $iwp_mmb_core->user_instance->add_user($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 |
|
| 1281 |
if( !function_exists ('iwp_mmb_get_users')) { |
| 1282 |
function iwp_mmb_get_users($params) |
| 1283 |
{ |
| 1284 |
global $iwp_mmb_core; |
| 1285 |
$iwp_mmb_core->get_user_instance(); |
| 1286 |
$return = $iwp_mmb_core->user_instance->get_users($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_edit_users')) { |
| 1296 |
function iwp_mmb_edit_users($params) |
| 1297 |
{ |
| 1298 |
global $iwp_mmb_core; |
| 1299 |
$iwp_mmb_core->get_user_instance(); |
| 1300 |
if(!empty($params['additional_params'])){ |
| 1301 |
$params['action_params']['username'] = $params['username']; |
| 1302 |
$return['action_response'] = $iwp_mmb_core->user_instance->edit_users($params['action_params']); |
| 1303 |
$return['additional_response'] = $iwp_mmb_core->user_instance->get_users($params['additional_params']); |
| 1304 |
}else{ |
| 1305 |
$return = $iwp_mmb_core->user_instance->edit_users($params); |
| 1306 |
} |
| 1307 |
|
| 1308 |
iwp_mmb_response($return, true); |
| 1309 |
} |
| 1310 |
} |
| 1311 |
|
| 1312 |
if( !function_exists ( 'iwp_mmb_iframe_plugins_fix' )) { |
| 1313 |
function iwp_mmb_iframe_plugins_fix($update_actions) |
| 1314 |
{ |
| 1315 |
foreach($update_actions as $key => $action) |
| 1316 |
{ |
| 1317 |
$update_actions[$key] = str_replace('target="_parent"','',$action); |
| 1318 |
} |
| 1319 |
|
| 1320 |
return $update_actions; |
| 1321 |
|
| 1322 |
} |
| 1323 |
} |
| 1324 |
|
| 1325 |
if( !function_exists ( 'iwp_mmb_set_notifications' )) { |
| 1326 |
function iwp_mmb_set_notifications($params) |
| 1327 |
{ |
| 1328 |
global $iwp_mmb_core; |
| 1329 |
$iwp_mmb_core->get_stats_instance(); |
| 1330 |
$return = $iwp_mmb_core->stats_instance->set_notifications($params); |
| 1331 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1332 |
iwp_mmb_response($return, false); |
| 1333 |
else { |
| 1334 |
iwp_mmb_response($return, true); |
| 1335 |
} |
| 1336 |
|
| 1337 |
} |
| 1338 |
} |
| 1339 |
|
| 1340 |
if( !function_exists ( 'iwp_mmb_set_alerts' )) { |
| 1341 |
function iwp_mmb_set_alerts($params) |
| 1342 |
{ |
| 1343 |
global $iwp_mmb_core; |
| 1344 |
$iwp_mmb_core->get_stats_instance(); |
| 1345 |
$return = $iwp_mmb_core->stats_instance->set_alerts($params); |
| 1346 |
iwp_mmb_response(true, true); |
| 1347 |
} |
| 1348 |
} |
| 1349 |
|
| 1350 |
/* |
| 1351 |
if(!function_exists('iwp_mmb_more_reccurences')){ |
| 1352 |
//Backup Tasks |
| 1353 |
add_filter('cron_schedules', 'iwp_mmb_more_reccurences'); |
| 1354 |
function iwp_mmb_more_reccurences($schedules) { |
| 1355 |
$schedules['halfminute'] = array('interval' => 30, 'display' => 'Once in a half minute'); |
| 1356 |
$schedules['minutely'] = array('interval' => 60, 'display' => 'Once in a minute'); |
| 1357 |
$schedules['fiveminutes'] = array('interval' => 300, 'display' => 'Once every five minutes'); |
| 1358 |
$schedules['tenminutes'] = array('interval' => 600, 'display' => 'Once every ten minutes'); |
| 1359 |
|
| 1360 |
return $schedules; |
| 1361 |
} |
| 1362 |
} |
| 1363 |
|
| 1364 |
add_action('iwp_client_backup_tasks', 'iwp_client_check_backup_tasks'); |
| 1365 |
|
| 1366 |
if( !function_exists('iwp_client_check_backup_tasks') ){ |
| 1367 |
function iwp_client_check_backup_tasks() { |
| 1368 |
global $iwp_mmb_core, $_wp_using_ext_object_cache; |
| 1369 |
$_wp_using_ext_object_cache = false; |
| 1370 |
|
| 1371 |
$iwp_mmb_core->get_backup_instance(); |
| 1372 |
$iwp_mmb_core->backup_instance->check_backup_tasks(); |
| 1373 |
} |
| 1374 |
} |
| 1375 |
*/ |
| 1376 |
|
| 1377 |
if( !function_exists('iwp_check_notifications') ){ |
| 1378 |
function iwp_check_notifications() { |
| 1379 |
global $iwp_mmb_core, $_wp_using_ext_object_cache; |
| 1380 |
$_wp_using_ext_object_cache = false; |
| 1381 |
|
| 1382 |
$iwp_mmb_core->get_stats_instance(); |
| 1383 |
$iwp_mmb_core->stats_instance->check_notifications(); |
| 1384 |
} |
| 1385 |
} |
| 1386 |
|
| 1387 |
|
| 1388 |
if( !function_exists('iwp_mmb_get_plugins_themes') ){ |
| 1389 |
function iwp_mmb_get_plugins_themes($params) { |
| 1390 |
global $iwp_mmb_core; |
| 1391 |
$iwp_mmb_core->get_installer_instance(); |
| 1392 |
$return = $iwp_mmb_core->installer_instance->get($params); |
| 1393 |
iwp_mmb_response($return, true); |
| 1394 |
} |
| 1395 |
} |
| 1396 |
|
| 1397 |
if( !function_exists('iwp_mmb_edit_plugins_themes') ){ |
| 1398 |
function iwp_mmb_edit_plugins_themes($params) { |
| 1399 |
global $iwp_mmb_core; |
| 1400 |
$iwp_mmb_core->get_installer_instance(); |
| 1401 |
$return = $iwp_mmb_core->installer_instance->edit($params); |
| 1402 |
iwp_mmb_response($return, true); |
| 1403 |
} |
| 1404 |
} |
| 1405 |
|
| 1406 |
//post |
| 1407 |
if( !function_exists ( 'iwp_mmb_post_create' )) { |
| 1408 |
function iwp_mmb_post_create($params) |
| 1409 |
{ |
| 1410 |
global $iwp_mmb_core; |
| 1411 |
$iwp_mmb_core->get_post_instance(); |
| 1412 |
if(!empty($params['action_params'])){ |
| 1413 |
// v3 |
| 1414 |
$return['action_response'] = $iwp_mmb_core->post_instance->create($params['action_params']); |
| 1415 |
$return['additional_response']['additional_posts'] = $iwp_mmb_core->post_instance->get_posts($params['additional_params']); |
| 1416 |
$return['additional_response']['additional_pages'] = $iwp_mmb_core->post_instance->get_pages($params['additional_params']); |
| 1417 |
if (is_int($return['action_response'])) |
| 1418 |
iwp_mmb_response($return, true); |
| 1419 |
else{ |
| 1420 |
if(isset($return['action_response']['error'])){ |
| 1421 |
iwp_mmb_response($return['action_response'], false); |
| 1422 |
} else { |
| 1423 |
iwp_mmb_response($return['action_response'], false); |
| 1424 |
} |
| 1425 |
} |
| 1426 |
|
| 1427 |
}else{ |
| 1428 |
// V2 |
| 1429 |
$return = $iwp_mmb_core->post_instance->create($params); |
| 1430 |
if (is_int($return)) |
| 1431 |
iwp_mmb_response($return, true); |
| 1432 |
else{ |
| 1433 |
if(isset($return['error'])){ |
| 1434 |
iwp_mmb_response($return, false); |
| 1435 |
} else { |
| 1436 |
iwp_mmb_response($return, false); |
| 1437 |
} |
| 1438 |
} |
| 1439 |
} |
| 1440 |
|
| 1441 |
} |
| 1442 |
} |
| 1443 |
|
| 1444 |
if( !function_exists ( 'iwp_mmb_change_post_status' )) { |
| 1445 |
function iwp_mmb_change_post_status($params) |
| 1446 |
{ |
| 1447 |
global $iwp_mmb_core; |
| 1448 |
$iwp_mmb_core->get_post_instance(); |
| 1449 |
$return = $iwp_mmb_core->post_instance->change_status($params); |
| 1450 |
//mmb_response($return, true); |
| 1451 |
|
| 1452 |
} |
| 1453 |
} |
| 1454 |
|
| 1455 |
if( !function_exists ('iwp_mmb_get_posts')) { |
| 1456 |
function iwp_mmb_get_posts($params) |
| 1457 |
{ |
| 1458 |
global $iwp_mmb_core; |
| 1459 |
$iwp_mmb_core->get_post_instance(); |
| 1460 |
|
| 1461 |
$return = $iwp_mmb_core->post_instance->get_posts($params); |
| 1462 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1463 |
iwp_mmb_response($return, false); |
| 1464 |
else { |
| 1465 |
iwp_mmb_response($return, true); |
| 1466 |
} |
| 1467 |
} |
| 1468 |
} |
| 1469 |
|
| 1470 |
if( !function_exists ('iwp_mmb_delete_post')) { |
| 1471 |
function iwp_mmb_delete_post($params) |
| 1472 |
{ |
| 1473 |
global $iwp_mmb_core; |
| 1474 |
$iwp_mmb_core->get_post_instance(); |
| 1475 |
if(!empty($params['additional_params'])){ |
| 1476 |
$return['action_response'] = $iwp_mmb_core->post_instance->delete_post($params['action_params']); |
| 1477 |
$return['additional_response'] = $iwp_mmb_core->post_instance->get_posts($params['additional_params']); |
| 1478 |
}else{ |
| 1479 |
$return = $iwp_mmb_core->post_instance->delete_post($params); |
| 1480 |
} |
| 1481 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1482 |
iwp_mmb_response($return, false); |
| 1483 |
else { |
| 1484 |
iwp_mmb_response($return, true); |
| 1485 |
} |
| 1486 |
} |
| 1487 |
} |
| 1488 |
|
| 1489 |
if( !function_exists ('iwp_mmb_delete_posts')) { |
| 1490 |
function iwp_mmb_delete_posts($params) |
| 1491 |
{ |
| 1492 |
global $iwp_mmb_core; |
| 1493 |
$iwp_mmb_core->get_post_instance(); |
| 1494 |
if(!empty($params['action_params'])){ |
| 1495 |
$return['action_response'] = $iwp_mmb_core->post_instance->delete_posts($params['action_params']); |
| 1496 |
$return['additional_response']['additional_posts'] = $iwp_mmb_core->post_instance->get_posts($params['additional_params']); |
| 1497 |
$return['additional_response']['additional_pages'] = $iwp_mmb_core->post_instance->get_pages($params['additional_params']); |
| 1498 |
}else{ |
| 1499 |
$return = $iwp_mmb_core->post_instance->delete_posts($params); |
| 1500 |
} |
| 1501 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1502 |
iwp_mmb_response($return, false); |
| 1503 |
else { |
| 1504 |
iwp_mmb_response($return, true); |
| 1505 |
} |
| 1506 |
} |
| 1507 |
} |
| 1508 |
|
| 1509 |
if( !function_exists ('iwp_mmb_get_pages')) { |
| 1510 |
function iwp_mmb_get_pages($params) |
| 1511 |
{ |
| 1512 |
global $iwp_mmb_core; |
| 1513 |
$iwp_mmb_core->get_post_instance(); |
| 1514 |
|
| 1515 |
$return = $iwp_mmb_core->post_instance->get_pages($params); |
| 1516 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1517 |
iwp_mmb_response($return, false); |
| 1518 |
else { |
| 1519 |
iwp_mmb_response($return, true); |
| 1520 |
} |
| 1521 |
} |
| 1522 |
} |
| 1523 |
|
| 1524 |
if( !function_exists ('iwp_mmb_delete_page')) { |
| 1525 |
function iwp_mmb_delete_page($params) |
| 1526 |
{ |
| 1527 |
global $iwp_mmb_core; |
| 1528 |
$iwp_mmb_core->get_post_instance(); |
| 1529 |
if(!empty($params['action_params'])){ |
| 1530 |
$return['action_response'] = $iwp_mmb_core->post_instance->delete_page($params['action_params']); |
| 1531 |
$return['additional_response'] = $iwp_mmb_core->post_instance->get_pages($params['additional_params']); |
| 1532 |
}else{ |
| 1533 |
$return = $iwp_mmb_core->post_instance->delete_page($params); |
| 1534 |
} |
| 1535 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1536 |
iwp_mmb_response($return, false); |
| 1537 |
else { |
| 1538 |
iwp_mmb_response($return, true); |
| 1539 |
} |
| 1540 |
} |
| 1541 |
} |
| 1542 |
|
| 1543 |
|
| 1544 |
//links |
| 1545 |
if( !function_exists ('iwp_mmb_get_links')) { |
| 1546 |
function iwp_mmb_get_links($params) |
| 1547 |
{ |
| 1548 |
global $iwp_mmb_core; |
| 1549 |
$iwp_mmb_core->get_link_instance(); |
| 1550 |
$return = $iwp_mmb_core->link_instance->get_links($params); |
| 1551 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1552 |
iwp_mmb_response($return, false); |
| 1553 |
else { |
| 1554 |
iwp_mmb_response($return, true); |
| 1555 |
} |
| 1556 |
} |
| 1557 |
} |
| 1558 |
|
| 1559 |
if( !function_exists ( 'iwp_mmb_add_link' )) { |
| 1560 |
function iwp_mmb_add_link($params) |
| 1561 |
{ |
| 1562 |
global $iwp_mmb_core; |
| 1563 |
$iwp_mmb_core->get_link_instance(); |
| 1564 |
if(!empty($params['action_params'])){ |
| 1565 |
$return['action_response'] = $iwp_mmb_core->link_instance->add_link($params['action_params']); |
| 1566 |
$return['additional_response'] = $iwp_mmb_core->link_instance->get_links($params['additional_params']); |
| 1567 |
}else{ |
| 1568 |
$return = $iwp_mmb_core->link_instance->add_link($params); |
| 1569 |
} |
| 1570 |
if (is_array($return) && array_key_exists('error', $return)){ |
| 1571 |
iwp_mmb_response($return, false); |
| 1572 |
} |
| 1573 |
else { |
| 1574 |
iwp_mmb_response($return, true); |
| 1575 |
} |
| 1576 |
|
| 1577 |
} |
| 1578 |
} |
| 1579 |
|
| 1580 |
if( !function_exists ('iwp_mmb_delete_link')) { |
| 1581 |
function iwp_mmb_delete_link($params) |
| 1582 |
{ |
| 1583 |
global $iwp_mmb_core; |
| 1584 |
$iwp_mmb_core->get_link_instance(); |
| 1585 |
if(!empty($params['action_params'])){ |
| 1586 |
$return['action_response'] = $iwp_mmb_core->link_instance->delete_link($params['action_params']); |
| 1587 |
$return['additional_response'] = $iwp_mmb_core->link_instance->get_links($params['additional_params']); |
| 1588 |
}else{ |
| 1589 |
$return = $iwp_mmb_core->link_instance->delete_link($params); |
| 1590 |
} |
| 1591 |
if (is_array($return) && array_key_exists('error', $return)){ |
| 1592 |
iwp_mmb_response($return, false); |
| 1593 |
} |
| 1594 |
else { |
| 1595 |
iwp_mmb_response($return, true); |
| 1596 |
} |
| 1597 |
} |
| 1598 |
} |
| 1599 |
|
| 1600 |
if( !function_exists ('iwp_mmb_delete_links')) { |
| 1601 |
function iwp_mmb_delete_links($params) |
| 1602 |
{ |
| 1603 |
global $iwp_mmb_core; |
| 1604 |
$iwp_mmb_core->get_link_instance(); |
| 1605 |
if(!empty($params['action_params'])){ |
| 1606 |
$return['action_response'] = $iwp_mmb_core->link_instance->delete_links($params['action_params']); |
| 1607 |
$return['additional_response'] = $iwp_mmb_core->link_instance->get_links($params['additional_params']); |
| 1608 |
}else{ |
| 1609 |
$return = $iwp_mmb_core->link_instance->delete_links($params); |
| 1610 |
} |
| 1611 |
if (is_array($return) && array_key_exists('error', $return)){ |
| 1612 |
iwp_mmb_response($return, false); |
| 1613 |
} |
| 1614 |
else { |
| 1615 |
iwp_mmb_response($return, true); |
| 1616 |
} |
| 1617 |
} |
| 1618 |
} |
| 1619 |
|
| 1620 |
|
| 1621 |
//comments |
| 1622 |
if( !function_exists ( 'iwp_mmb_change_comment_status' )) { |
| 1623 |
function iwp_mmb_change_comment_status($params) |
| 1624 |
{ |
| 1625 |
global $iwp_mmb_core; |
| 1626 |
$iwp_mmb_core->get_comment_instance(); |
| 1627 |
$return = $iwp_mmb_core->comment_instance->change_status($params); |
| 1628 |
//mmb_response($return, true); |
| 1629 |
if ($return){ |
| 1630 |
$iwp_mmb_core->get_stats_instance(); |
| 1631 |
iwp_mmb_response($iwp_mmb_core->stats_instance->get_comments_stats($params), true); |
| 1632 |
}else |
| 1633 |
iwp_mmb_response(array('error' => 'Comment not updated', 'error_code' => 'comment_not_updated'), false); |
| 1634 |
} |
| 1635 |
|
| 1636 |
} |
| 1637 |
if( !function_exists ( 'iwp_mmb_comment_stats_get' )) { |
| 1638 |
function iwp_mmb_comment_stats_get($params) |
| 1639 |
{ |
| 1640 |
global $iwp_mmb_core; |
| 1641 |
$iwp_mmb_core->get_stats_instance(); |
| 1642 |
iwp_mmb_response($iwp_mmb_core->stats_instance->get_comments_stats($params), true); |
| 1643 |
} |
| 1644 |
} |
| 1645 |
|
| 1646 |
if( !function_exists ('iwp_mmb_get_comments')) { |
| 1647 |
function iwp_mmb_get_comments($params) |
| 1648 |
{ |
| 1649 |
global $iwp_mmb_core; |
| 1650 |
$iwp_mmb_core->get_comment_instance(); |
| 1651 |
$return = $iwp_mmb_core->comment_instance->get_comments($params); |
| 1652 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1653 |
iwp_mmb_response($return, false); |
| 1654 |
else { |
| 1655 |
iwp_mmb_response($return, true); |
| 1656 |
} |
| 1657 |
} |
| 1658 |
} |
| 1659 |
|
| 1660 |
if( !function_exists ('iwp_mmb_action_comment')) { |
| 1661 |
function iwp_mmb_action_comment($params) |
| 1662 |
{ |
| 1663 |
global $iwp_mmb_core; |
| 1664 |
$iwp_mmb_core->get_comment_instance(); |
| 1665 |
if(!empty($params['additional_params'])){ |
| 1666 |
$return['action_response'] = $iwp_mmb_core->comment_instance->action_comment($params['action_params']); |
| 1667 |
$return['additional_response'] = $iwp_mmb_core->comment_instance->get_comments($params['additional_params']); |
| 1668 |
}else{ |
| 1669 |
$return = $iwp_mmb_core->comment_instance->action_comment($params); |
| 1670 |
} |
| 1671 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1672 |
iwp_mmb_response($return, false); |
| 1673 |
else { |
| 1674 |
iwp_mmb_response($return, true); |
| 1675 |
} |
| 1676 |
} |
| 1677 |
} |
| 1678 |
|
| 1679 |
if( !function_exists ('iwp_mmb_bulk_action_comments')) { |
| 1680 |
function iwp_mmb_bulk_action_comments($params) |
| 1681 |
{ |
| 1682 |
global $iwp_mmb_core; |
| 1683 |
$iwp_mmb_core->get_comment_instance(); |
| 1684 |
if(!empty($params['additional_params'])){ |
| 1685 |
$return['action_response'] = $iwp_mmb_core->comment_instance->bulk_action_comments($params['action_params']); |
| 1686 |
$return['additional_response'] = $iwp_mmb_core->comment_instance->get_comments($params['additional_params']); |
| 1687 |
}else{ |
| 1688 |
$return = $iwp_mmb_core->comment_instance->bulk_action_comments($params); |
| 1689 |
} |
| 1690 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1691 |
iwp_mmb_response($return, false); |
| 1692 |
else { |
| 1693 |
iwp_mmb_response($return, true); |
| 1694 |
} |
| 1695 |
} |
| 1696 |
} |
| 1697 |
|
| 1698 |
if( !function_exists ('iwp_mmb_reply_comment')) { |
| 1699 |
function iwp_mmb_reply_comment($params) |
| 1700 |
{ |
| 1701 |
global $iwp_mmb_core; |
| 1702 |
$iwp_mmb_core->get_comment_instance(); |
| 1703 |
if(!empty($params['additional_params'])){ |
| 1704 |
$return['action_response'] = $iwp_mmb_core->comment_instance->reply_comment($params['action_params']); |
| 1705 |
$return['additional_response'] = $iwp_mmb_core->comment_instance->get_comments($params['additional_params']); |
| 1706 |
}else{ |
| 1707 |
$return = $iwp_mmb_core->comment_instance->reply_comment($params); |
| 1708 |
} |
| 1709 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1710 |
iwp_mmb_response($return, false); |
| 1711 |
else { |
| 1712 |
iwp_mmb_response($return, true); |
| 1713 |
} |
| 1714 |
} |
| 1715 |
} |
| 1716 |
|
| 1717 |
//Comments-End- |
| 1718 |
|
| 1719 |
//WP-Optimize |
| 1720 |
|
| 1721 |
if( !function_exists('iwp_mmb_wp_optimize')){ |
| 1722 |
function iwp_mmb_wp_optimize($params){ |
| 1723 |
global $iwp_mmb_core; |
| 1724 |
$iwp_mmb_core->wp_optimize_instance(); |
| 1725 |
|
| 1726 |
$return = $iwp_mmb_core->optimize_instance->cleanup_system($params); |
| 1727 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1728 |
iwp_mmb_response($return, false); |
| 1729 |
else { |
| 1730 |
iwp_mmb_response($return, true); |
| 1731 |
} |
| 1732 |
} |
| 1733 |
} |
| 1734 |
|
| 1735 |
//WP-Optimize_end |
| 1736 |
if( !function_exists('iwp_mmb_wp_purge_cache')){ |
| 1737 |
function iwp_mmb_wp_purge_cache($params){ |
| 1738 |
global $iwp_mmb_core; |
| 1739 |
$iwp_mmb_core->wp_purge_cache_instance(); |
| 1740 |
|
| 1741 |
$return = $iwp_mmb_core->wp_purge_cache_instance->purgeAllCache($params['type']); |
| 1742 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1743 |
iwp_mmb_response($return, false); |
| 1744 |
else { |
| 1745 |
iwp_mmb_response($return, true); |
| 1746 |
} |
| 1747 |
} |
| 1748 |
} |
| 1749 |
/* |
| 1750 |
*WordFence Addon Start |
| 1751 |
*/ |
| 1752 |
|
| 1753 |
if( !function_exists('iwp_mmb_wordfence_scan')){ |
| 1754 |
function iwp_mmb_wordfence_scan($params){ |
| 1755 |
global $iwp_mmb_core,$iwp_mmb_plugin_dir; |
| 1756 |
require_once("$iwp_mmb_plugin_dir/addons/wordfence/wordfence.class.php"); |
| 1757 |
$iwp_mmb_core->get_wordfence_instance(); |
| 1758 |
|
| 1759 |
$return = $iwp_mmb_core->wordfence_instance->scan($params); |
| 1760 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1761 |
iwp_mmb_response($return, false); |
| 1762 |
else { |
| 1763 |
iwp_mmb_response($return, true); |
| 1764 |
} |
| 1765 |
} |
| 1766 |
} |
| 1767 |
|
| 1768 |
if( !function_exists('iwp_mmb_wordfence_load')){ |
| 1769 |
function iwp_mmb_wordfence_load($params){ |
| 1770 |
global $iwp_mmb_core,$iwp_mmb_plugin_dir; |
| 1771 |
require_once("$iwp_mmb_plugin_dir/addons/wordfence/wordfence.class.php"); |
| 1772 |
$iwp_mmb_core->get_wordfence_instance(); |
| 1773 |
|
| 1774 |
$return = $iwp_mmb_core->wordfence_instance->load($params); |
| 1775 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1776 |
iwp_mmb_response($return, false); |
| 1777 |
else { |
| 1778 |
iwp_mmb_response($return, true); |
| 1779 |
} |
| 1780 |
} |
| 1781 |
} |
| 1782 |
|
| 1783 |
/* |
| 1784 |
*WordFence Addon End |
| 1785 |
*/ |
| 1786 |
|
| 1787 |
/* |
| 1788 |
* Sucuri Addon Start |
| 1789 |
*/ |
| 1790 |
|
| 1791 |
if( !function_exists('iwp_mmb_sucuri_fetch_result')){ |
| 1792 |
function iwp_mmb_sucuri_fetch_result($params){ |
| 1793 |
global $iwp_mmb_core,$iwp_mmb_plugin_dir; |
| 1794 |
require_once("$iwp_mmb_plugin_dir/addons/malware_scanner_sucuri/malware_scanner_sucuri.class.php"); |
| 1795 |
$iwp_mmb_core->get_sucuri_instance(); |
| 1796 |
|
| 1797 |
$return = $iwp_mmb_core->sucuri_instance->getScannedCacheResult(); |
| 1798 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1799 |
iwp_mmb_response($return, false); |
| 1800 |
else { |
| 1801 |
iwp_mmb_response($return, true); |
| 1802 |
} |
| 1803 |
} |
| 1804 |
} |
| 1805 |
|
| 1806 |
if( !function_exists('iwp_mmb_sucuri_scan')){ |
| 1807 |
function iwp_mmb_sucuri_scan($params){ |
| 1808 |
global $iwp_mmb_core,$iwp_mmb_plugin_dir; |
| 1809 |
require_once("$iwp_mmb_plugin_dir/addons/malware_scanner_sucuri/malware_scanner_sucuri.class.php"); |
| 1810 |
$iwp_mmb_core->get_sucuri_instance(); |
| 1811 |
|
| 1812 |
$return = $iwp_mmb_core->sucuri_instance->runAndSaveScanResult(); |
| 1813 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1814 |
iwp_mmb_response($return, false); |
| 1815 |
else { |
| 1816 |
iwp_mmb_response($return, true); |
| 1817 |
} |
| 1818 |
} |
| 1819 |
} |
| 1820 |
|
| 1821 |
if( !function_exists('iwp_mmb_sucuri_change_alert')){ |
| 1822 |
function iwp_mmb_sucuri_change_alert($params){ |
| 1823 |
global $iwp_mmb_core,$iwp_mmb_plugin_dir; |
| 1824 |
require_once("$iwp_mmb_plugin_dir/addons/malware_scanner_sucuri/malware_scanner_sucuri.class.php"); |
| 1825 |
$iwp_mmb_core->get_sucuri_instance(); |
| 1826 |
|
| 1827 |
$return = $iwp_mmb_core->sucuri_instance->changeAlertEmail($params); |
| 1828 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1829 |
iwp_mmb_response($return, false); |
| 1830 |
else { |
| 1831 |
iwp_mmb_response($return, true); |
| 1832 |
} |
| 1833 |
} |
| 1834 |
} |
| 1835 |
|
| 1836 |
/* |
| 1837 |
* iTheams Security Addon Start here |
| 1838 |
*/ |
| 1839 |
|
| 1840 |
if(!function_exists('iwp_mmb_ithemes_security_load')) { |
| 1841 |
function iwp_phx_ithemes_security_check() { |
| 1842 |
if (iwp_mmb_ithemes_security_check()) { |
| 1843 |
global $iwp_mmb_core; |
| 1844 |
$ithemessec_instance = $iwp_mmb_core->get_ithemessec_instance(); |
| 1845 |
$return = $ithemessec_instance->securityCheck(); |
| 1846 |
if (isset($return['security_check'])) { |
| 1847 |
iwp_mmb_response($return['security_check'], true); |
| 1848 |
} else { |
| 1849 |
iwp_mmb_response($return, false); |
| 1850 |
} |
| 1851 |
} else { |
| 1852 |
iwp_mmb_response(array('error' => 'iThemes Security plugin is not installed or deactivated.', 'error_code' => 'ithemes_missing_or_not_active'), false); |
| 1853 |
} |
| 1854 |
} |
| 1855 |
} |
| 1856 |
|
| 1857 |
/* |
| 1858 |
* return the iTheams Security is load or not |
| 1859 |
*/ |
| 1860 |
if(!function_exists('iwp_mmb_ithemes_security_check')) { |
| 1861 |
function iwp_mmb_ithemes_security_check() { |
| 1862 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 1863 |
if ( is_plugin_active( 'better-wp-security/better-wp-security.php' ) ) { |
| 1864 |
@include_once(WP_PLUGIN_DIR . '/better-wp-security/better-wp-security.php'); |
| 1865 |
if (class_exists('ITSEC_Core')) { |
| 1866 |
return true; |
| 1867 |
} else { |
| 1868 |
return false; |
| 1869 |
} |
| 1870 |
} |
| 1871 |
elseif ( is_plugin_active( 'ithemes-security-pro/ithemes-security-pro.php' ) ) { |
| 1872 |
@include_once(WP_PLUGIN_DIR . '/ithemes-security-pro/ithemes-security-pro.php'); |
| 1873 |
if (class_exists('ITSEC_Core')) { |
| 1874 |
return true; |
| 1875 |
} else { |
| 1876 |
return false; |
| 1877 |
} |
| 1878 |
} |
| 1879 |
else { |
| 1880 |
return false; |
| 1881 |
} |
| 1882 |
} |
| 1883 |
} |
| 1884 |
|
| 1885 |
if(!function_exists('iwp_mmb_is_wordfence')) { |
| 1886 |
function iwp_mmb_is_wordfence() { |
| 1887 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 1888 |
if ( is_plugin_active( 'wordfence/wordfence.php' ) ) { |
| 1889 |
@include_once(WP_PLUGIN_DIR . '/wordfence/wordfence.php'); |
| 1890 |
if (class_exists('wordfence')) { |
| 1891 |
return true; |
| 1892 |
} else { |
| 1893 |
return false; |
| 1894 |
} |
| 1895 |
} else { |
| 1896 |
return false; |
| 1897 |
} |
| 1898 |
|
| 1899 |
|
| 1900 |
|
| 1901 |
} |
| 1902 |
} |
| 1903 |
/* |
| 1904 |
* iTheams Security Addon End here |
| 1905 |
*/ |
| 1906 |
|
| 1907 |
//WP-BrokenLinks start |
| 1908 |
|
| 1909 |
if( !function_exists('iwp_mmb_get_all_links')){ |
| 1910 |
function iwp_mmb_get_all_links(){ |
| 1911 |
global $iwp_mmb_core; |
| 1912 |
$iwp_mmb_core->wp_blc_get_blinks(); |
| 1913 |
$return = $iwp_mmb_core->blc_get_blinks->blc_get_all_links(); |
| 1914 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1915 |
iwp_mmb_response($return, false); |
| 1916 |
else { |
| 1917 |
iwp_mmb_response($return, true); |
| 1918 |
} |
| 1919 |
} |
| 1920 |
} |
| 1921 |
|
| 1922 |
if( !function_exists('iwp_mmb_update_broken_link')){ |
| 1923 |
function iwp_mmb_update_broken_link($params){ |
| 1924 |
global $iwp_mmb_core; |
| 1925 |
$iwp_mmb_core->wp_blc_get_blinks(); |
| 1926 |
if(!empty($params['additional_params'])){ |
| 1927 |
$return['action_response'] = $iwp_mmb_core->blc_get_blinks->blc_update_link($params['action_params']); |
| 1928 |
$brokenlinks = $iwp_mmb_core->blc_get_blinks->blc_get_all_links(); |
| 1929 |
if($brokenlinks =='nolinks'){ |
| 1930 |
$brokenlinks = array('status'=>'nolinks'); |
| 1931 |
} |
| 1932 |
$return['additional_response'] = $brokenlinks; |
| 1933 |
}else{ |
| 1934 |
$return = $iwp_mmb_core->blc_get_blinks->blc_update_link($params); |
| 1935 |
} |
| 1936 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1937 |
iwp_mmb_response($return, false); |
| 1938 |
else { |
| 1939 |
iwp_mmb_response($return, true); |
| 1940 |
} |
| 1941 |
} |
| 1942 |
} |
| 1943 |
|
| 1944 |
if( !function_exists('iwp_mmb_unlink_broken_link')){ |
| 1945 |
function iwp_mmb_unlink_broken_link($params){ |
| 1946 |
global $iwp_mmb_core; |
| 1947 |
$iwp_mmb_core->wp_blc_get_blinks(); |
| 1948 |
$return = $iwp_mmb_core->blc_get_blinks->blc_unlink($params); |
| 1949 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1950 |
iwp_mmb_response($return, false); |
| 1951 |
else { |
| 1952 |
iwp_mmb_response($return, true); |
| 1953 |
} |
| 1954 |
} |
| 1955 |
} |
| 1956 |
|
| 1957 |
if( !function_exists('iwp_mmb_markasnot_broken_link')){ |
| 1958 |
function iwp_mmb_markasnot_broken_link($params){ |
| 1959 |
global $iwp_mmb_core; |
| 1960 |
$iwp_mmb_core->wp_blc_get_blinks(); |
| 1961 |
$return = $iwp_mmb_core->blc_get_blinks->blc_mark_as_not_broken($params); |
| 1962 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1963 |
iwp_mmb_response($return, false); |
| 1964 |
else { |
| 1965 |
iwp_mmb_response($return, true); |
| 1966 |
} |
| 1967 |
} |
| 1968 |
} |
| 1969 |
|
| 1970 |
if( !function_exists('iwp_mmb_dismiss_broken_link')){ |
| 1971 |
function iwp_mmb_dismiss_broken_link($params){ |
| 1972 |
global $iwp_mmb_core; |
| 1973 |
$iwp_mmb_core->wp_blc_get_blinks(); |
| 1974 |
$return = $iwp_mmb_core->blc_get_blinks->blc_dismiss_link($params); |
| 1975 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1976 |
iwp_mmb_response($return, false); |
| 1977 |
else { |
| 1978 |
iwp_mmb_response($return, true); |
| 1979 |
} |
| 1980 |
} |
| 1981 |
} |
| 1982 |
|
| 1983 |
if( !function_exists('iwp_mmb_undismiss_broken_link')){ |
| 1984 |
function iwp_mmb_undismiss_broken_link($params){ |
| 1985 |
global $iwp_mmb_core; |
| 1986 |
$iwp_mmb_core->wp_blc_get_blinks(); |
| 1987 |
$return = $iwp_mmb_core->blc_get_blinks->blc_undismiss_link($params); |
| 1988 |
if (is_array($return) && array_key_exists('error', $return)) |
| 1989 |
iwp_mmb_response($return, false); |
| 1990 |
else { |
| 1991 |
iwp_mmb_response($return, true); |
| 1992 |
} |
| 1993 |
} |
| 1994 |
} |
| 1995 |
|
| 1996 |
if( !function_exists('iwp_mmb_bulk_actions_processor')){ |
| 1997 |
function iwp_mmb_bulk_actions_processor($params){ |
| 1998 |
global $iwp_mmb_core; |
| 1999 |
$iwp_mmb_core->wp_blc_get_blinks(); |
| 2000 |
if(!empty($params['additional_params'])){ |
| 2001 |
$return['action_response'] = $iwp_mmb_core->blc_get_blinks->blc_bulk_actions($params['action_params']); |
| 2002 |
$brokenlinks = $iwp_mmb_core->blc_get_blinks->blc_get_all_links(); |
| 2003 |
if($brokenlinks =='nolinks'){ |
| 2004 |
$brokenlinks = array('status'=>'nolinks'); |
| 2005 |
} |
| 2006 |
$return['additional_response'] = $brokenlinks; |
| 2007 |
}else{ |
| 2008 |
$return = $iwp_mmb_core->blc_get_blinks->blc_bulk_actions($params); |
| 2009 |
} |
| 2010 |
if (is_array($return) && array_key_exists('error', $return)) |
| 2011 |
iwp_mmb_response($return, false); |
| 2012 |
else { |
| 2013 |
iwp_mmb_response($return, true); |
| 2014 |
} |
| 2015 |
|
| 2016 |
} |
| 2017 |
} |
| 2018 |
|
| 2019 |
//WP-BrokenLinks end |
| 2020 |
|
| 2021 |
//WP-GWMTools start |
| 2022 |
|
| 2023 |
if( !function_exists('iwp_mmb_gwmt_redirect_url')){ |
| 2024 |
function iwp_mmb_gwmt_redirect_url($params){ |
| 2025 |
global $iwp_mmb_core; |
| 2026 |
$iwp_mmb_core->wp_google_webmasters_crawls(); |
| 2027 |
$return = $iwp_mmb_core->get_google_webmasters_crawls->google_webmasters_redirect($params); |
| 2028 |
if (is_array($return) && array_key_exists('error', $return)) |
| 2029 |
iwp_mmb_response($return, false); |
| 2030 |
else { |
| 2031 |
iwp_mmb_response($return, true); |
| 2032 |
} |
| 2033 |
} |
| 2034 |
} |
| 2035 |
|
| 2036 |
if( !function_exists('iwp_mmb_gwmt_redirect_url_again')){ |
| 2037 |
function iwp_mmb_gwmt_redirect_url_again($params){ |
| 2038 |
global $iwp_mmb_core; |
| 2039 |
$iwp_mmb_core->wp_google_webmasters_crawls(); |
| 2040 |
$return = $iwp_mmb_core->get_google_webmasters_crawls->google_webmasters_redirect_again($params); |
| 2041 |
if (is_array($return) && array_key_exists('error', $return)) |
| 2042 |
iwp_mmb_response($return, false); |
| 2043 |
else { |
| 2044 |
iwp_mmb_response($return, true); |
| 2045 |
} |
| 2046 |
} |
| 2047 |
} |
| 2048 |
|
| 2049 |
|
| 2050 |
//WP-GWMTools end |
| 2051 |
|
| 2052 |
//fileEditor start |
| 2053 |
|
| 2054 |
if( !function_exists('iwp_mmb_file_editor_upload')){ |
| 2055 |
function iwp_mmb_file_editor_upload($params){ |
| 2056 |
global $iwp_mmb_core; |
| 2057 |
$iwp_mmb_core->wp_get_file_editor(); |
| 2058 |
$return = $iwp_mmb_core->get_file_editor->file_editor_upload($params); |
| 2059 |
if (is_array($return) && array_key_exists('error', $return)) |
| 2060 |
iwp_mmb_response($return, false); |
| 2061 |
else { |
| 2062 |
iwp_mmb_response($return, true); |
| 2063 |
} |
| 2064 |
} |
| 2065 |
} |
| 2066 |
|
| 2067 |
|
| 2068 |
//fileEditor end |
| 2069 |
|
| 2070 |
//yoastWpSeo start |
| 2071 |
if( !function_exists('iwp_mmb_yoast_get_seo_info')){ |
| 2072 |
function iwp_mmb_yoast_get_seo_info($params){ |
| 2073 |
global $iwp_mmb_core; |
| 2074 |
$iwp_mmb_core->wp_get_yoast_seo(); |
| 2075 |
$return = $iwp_mmb_core->get_yoast_seo->get_seo_info($params); |
| 2076 |
if (is_array($return) && array_key_exists('error', $return)) |
| 2077 |
iwp_mmb_response($return, false); |
| 2078 |
else { |
| 2079 |
iwp_mmb_response($return, true); |
| 2080 |
} |
| 2081 |
} |
| 2082 |
} |
| 2083 |
if( !function_exists('iwp_mmb_yoast_save_seo_info')){ |
| 2084 |
function iwp_mmb_yoast_save_seo_info($params){ |
| 2085 |
global $iwp_mmb_core; |
| 2086 |
$iwp_mmb_core->wp_get_yoast_seo(); |
| 2087 |
$return = $iwp_mmb_core->get_yoast_seo->save_seo_info($params); |
| 2088 |
if (is_array($return) && array_key_exists('error', $return)) |
| 2089 |
iwp_mmb_response($return, false); |
| 2090 |
else { |
| 2091 |
iwp_mmb_response($return, true); |
| 2092 |
} |
| 2093 |
} |
| 2094 |
} |
| 2095 |
//yoastWpSeo end |
| 2096 |
|
| 2097 |
if( !function_exists('iwp_mmb_maintenance_mode')){ |
| 2098 |
function iwp_mmb_maintenance_mode( $params ) { |
| 2099 |
global $wp_object_cache; |
| 2100 |
|
| 2101 |
$default = get_option('iwp_client_maintenace_mode'); |
| 2102 |
$params = empty($default) ? $params : array_merge($default, $params); |
| 2103 |
update_option("iwp_client_maintenace_mode", $params); |
| 2104 |
|
| 2105 |
if(!empty($wp_object_cache)) |
| 2106 |
@$wp_object_cache->flush(); |
| 2107 |
iwp_mmb_response(true, true); |
| 2108 |
} |
| 2109 |
} |
| 2110 |
|
| 2111 |
if( !function_exists('iwp_mmb_plugin_actions') ){ |
| 2112 |
function iwp_mmb_plugin_actions() { |
| 2113 |
global $iwp_mmb_actions, $iwp_mmb_core; |
| 2114 |
|
| 2115 |
if(!empty($iwp_mmb_actions)){ |
| 2116 |
global $_iwp_mmb_plugin_actions; |
| 2117 |
if(!empty($_iwp_mmb_plugin_actions)){ |
| 2118 |
$failed = array(); |
| 2119 |
foreach($_iwp_mmb_plugin_actions as $action => $params){ |
| 2120 |
if(isset($iwp_mmb_actions[$action])) |
| 2121 |
call_user_func($iwp_mmb_actions[$action], $params); |
| 2122 |
else |
| 2123 |
$failed[] = $action; |
| 2124 |
} |
| 2125 |
if(!empty($failed)){ |
| 2126 |
$f = implode(', ', $failed); |
| 2127 |
$s = count($failed) > 1 ? 'Actions "' . $f . '" do' : 'Action "' . $f . '" does'; |
| 2128 |
iwp_mmb_response(array('error' => $s.' not exist. Please update your IWP Client plugin.', 'error_code' => 'update_your_client_plugin'), false); |
| 2129 |
} |
| 2130 |
|
| 2131 |
} |
| 2132 |
} |
| 2133 |
|
| 2134 |
global $pagenow, $current_user, $mmode; |
| 2135 |
if( !is_admin() && !in_array($pagenow, array( 'wp-login.php' ))){ |
| 2136 |
$mmode = get_option('iwp_client_maintenace_mode'); |
| 2137 |
if( !empty($mmode) ){ |
| 2138 |
if(isset($mmode['active']) && $mmode['active'] == true){ |
| 2139 |
if(isset($current_user->data) && !empty($current_user->data) && isset($mmode['hidecaps']) && !empty($mmode['hidecaps'])){ |
| 2140 |
$usercaps = array(); |
| 2141 |
if(isset($current_user->caps) && !empty($current_user->caps)){ |
| 2142 |
$usercaps = $current_user->caps; |
| 2143 |
} |
| 2144 |
foreach($mmode['hidecaps'] as $cap => $hide){ |
| 2145 |
if(!$hide) |
| 2146 |
continue; |
| 2147 |
|
| 2148 |
foreach($usercaps as $ucap => $val){ |
| 2149 |
if($ucap == $cap){ |
| 2150 |
ob_end_clean(); |
| 2151 |
ob_end_flush(); |
| 2152 |
die($mmode['template']); |
| 2153 |
} |
| 2154 |
} |
| 2155 |
} |
| 2156 |
} else |
| 2157 |
die($mmode['template']); |
| 2158 |
} |
| 2159 |
} |
| 2160 |
} |
| 2161 |
} |
| 2162 |
} |
| 2163 |
|
| 2164 |
if(!function_exists('iwp_mmb_minimal_maintenance_plugin_fix')){ |
| 2165 |
function iwp_mmb_minimal_maintenance_plugin_fix(){ |
| 2166 |
if(get_option('iwp_mmb_maintenance_mode')){ |
| 2167 |
if ( ! function_exists( 'is_plugin_active' )) { |
| 2168 |
@include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 2169 |
} |
| 2170 |
if(is_plugin_active('minimal-coming-soon-maintenance-mode/minimal-coming-soon-maintenance-mode.php')){ |
| 2171 |
remove_action('init', 'csmm_plugin_init'); |
| 2172 |
} |
| 2173 |
} |
| 2174 |
} |
| 2175 |
} |
| 2176 |
|
| 2177 |
if( !function_exists ( 'iwp_mmb_execute_php_code' )) { |
| 2178 |
function iwp_mmb_execute_php_code($params) |
| 2179 |
{ |
| 2180 |
ob_start(); |
| 2181 |
eval($params['code']); |
| 2182 |
$return = ob_get_flush(); |
| 2183 |
if (empty($return)) { |
| 2184 |
$return = "Code executed successfully. No output generated."; |
| 2185 |
} |
| 2186 |
iwp_mmb_response(print_r($return, true), true); |
| 2187 |
} |
| 2188 |
} |
| 2189 |
|
| 2190 |
if( !function_exists('iwp_mmb_client_brand')){ |
| 2191 |
function iwp_mmb_client_brand($params) { |
| 2192 |
update_option("iwp_client_brand",$params['brand']); |
| 2193 |
iwp_mmb_response(true, true); |
| 2194 |
} |
| 2195 |
} |
| 2196 |
|
| 2197 |
|
| 2198 |
if(!function_exists('checkOpenSSL')){ |
| 2199 |
function checkOpenSSL(){ |
| 2200 |
if(!function_exists('openssl_verify')){ |
| 2201 |
return false; |
| 2202 |
} |
| 2203 |
else{ |
| 2204 |
//$ossl_err = @openssl_error_string();if($ossl_err!=false) return false; |
| 2205 |
$key = @openssl_pkey_new(); |
| 2206 |
if($key === false){ |
| 2207 |
return false; |
| 2208 |
} |
| 2209 |
|
| 2210 |
// $ossl_err = @openssl_error_string();if($ossl_err!=false) return false; |
| 2211 |
$pkey = @openssl_pkey_export($key, $privateKey); |
| 2212 |
if($pkey === false){ |
| 2213 |
return false; |
| 2214 |
} |
| 2215 |
$privateKey = base64_encode($privateKey); |
| 2216 |
|
| 2217 |
// $ossl_err = @openssl_error_string();if($ossl_err!=false) return false; |
| 2218 |
$publicKey = @openssl_pkey_get_details($key); |
| 2219 |
if($publicKey === false){ |
| 2220 |
return false; |
| 2221 |
} |
| 2222 |
|
| 2223 |
//$ossl_err = @openssl_error_string();if($ossl_err!=false) return false; |
| 2224 |
$publicKey = $publicKey["key"]; |
| 2225 |
|
| 2226 |
if(empty($publicKey) || empty($privateKey)){ |
| 2227 |
return false; |
| 2228 |
} |
| 2229 |
$filename = getenv('HOME') . '/.rnd'; |
| 2230 |
if (@file_exists($filename)) { |
| 2231 |
@unlink($filename); |
| 2232 |
} |
| 2233 |
} |
| 2234 |
return true; |
| 2235 |
} |
| 2236 |
} |
| 2237 |
|
| 2238 |
|
| 2239 |
if(!function_exists('iwp_mmb_shutdown')){ |
| 2240 |
function iwp_mmb_shutdown(){ |
| 2241 |
$isError = false; |
| 2242 |
|
| 2243 |
if ($error = error_get_last()){ |
| 2244 |
switch($error['type']){ |
| 2245 |
/*case E_PARSE:*/ |
| 2246 |
case E_ERROR: |
| 2247 |
case E_CORE_ERROR: |
| 2248 |
case E_COMPILE_ERROR: |
| 2249 |
case E_USER_ERROR: |
| 2250 |
$isError = true; |
| 2251 |
break; |
| 2252 |
} |
| 2253 |
} |
| 2254 |
if ($isError){ |
| 2255 |
|
| 2256 |
$response = '<span style="font-weight:700;">PHP Fatal error occurred:</span> '.$error['message'].' in '.$error['file'].' on line '.$error['line'].'.'; |
| 2257 |
if(stripos($error['message'], 'allowed memory size') !== false){ |
| 2258 |
$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.'; |
| 2259 |
} |
| 2260 |
if(!isset($GLOBALS['IWP_RESPONSE_SENT'])){ |
| 2261 |
iwp_mmb_response(array('error' => $response, 'error_code' => 'iwp_mmb_shutdown'), false); |
| 2262 |
} |
| 2263 |
|
| 2264 |
} |
| 2265 |
} |
| 2266 |
} |
| 2267 |
|
| 2268 |
|
| 2269 |
if(!function_exists('iwp_mmb_print_flush')){ |
| 2270 |
function iwp_mmb_print_flush($print_string){// this will help responding web server, will keep alive the script execution |
| 2271 |
|
| 2272 |
echo $print_string." ||| "; |
| 2273 |
echo "TT:".(microtime(1) - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'])."\n"; |
| 2274 |
if (ob_get_length()){ |
| 2275 |
@ob_flush(); |
| 2276 |
} |
| 2277 |
flush(); |
| 2278 |
} |
| 2279 |
} |
| 2280 |
|
| 2281 |
if(!function_exists('iwp_mmb_auto_print')){ |
| 2282 |
function iwp_mmb_auto_print($unique_task){// this will help responding web server, will keep alive the script execution |
| 2283 |
$print_every_x_secs = 5; |
| 2284 |
|
| 2285 |
$current_time = microtime(1); |
| 2286 |
if(empty($GLOBALS['IWP_MMB_PROFILING']['TASKS'][$unique_task]['START'])){ |
| 2287 |
$GLOBALS['IWP_MMB_PROFILING']['TASKS'][$unique_task]['START'] = $current_time; |
| 2288 |
} |
| 2289 |
|
| 2290 |
if(empty($GLOBALS['IWP_MMB_PROFILING']['LAST_PRINT']) || ($current_time - $GLOBALS['IWP_MMB_PROFILING']['LAST_PRINT']) > $print_every_x_secs){ |
| 2291 |
|
| 2292 |
//$print_string = "TT:".($current_time - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'])."\n"; |
| 2293 |
$print_string = $unique_task." TT:".($current_time - $GLOBALS['IWP_MMB_PROFILING']['TASKS'][$unique_task]['START']); |
| 2294 |
iwp_mmb_print_flush($print_string); |
| 2295 |
$GLOBALS['IWP_MMB_PROFILING']['LAST_PRINT'] = $current_time; |
| 2296 |
} |
| 2297 |
} |
| 2298 |
} |
| 2299 |
|
| 2300 |
if(!function_exists('iwp_mmb_check_maintenance')){ |
| 2301 |
function iwp_mmb_check_maintenance(){ |
| 2302 |
if(get_option('iwp_mmb_maintenance_mode') && !current_user_can( 'manage_options' )){ |
| 2303 |
$html_maintenance = get_option('iwp_mmb_maintenance_html'); |
| 2304 |
echo $html_maintenance; |
| 2305 |
exit; |
| 2306 |
} |
| 2307 |
} |
| 2308 |
} |
| 2309 |
|
| 2310 |
if(!function_exists('iwp_mmb_check_redirects')){ |
| 2311 |
function iwp_mmb_check_redirects(){ |
| 2312 |
$iwp_webmasters_redirect_table_version = get_site_option('iwp_webmasters_redirect_table_version'); |
| 2313 |
if (empty($iwp_webmasters_redirect_table_version)) { |
| 2314 |
return false; |
| 2315 |
} |
| 2316 |
global $wpdb; |
| 2317 |
$current_url = ($_SERVER['SERVER_PORT']=='443'?'https://':'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
| 2318 |
$current_url = rtrim($current_url,'/'); |
| 2319 |
$table_name = $wpdb->base_prefix."iwp_redirects"; |
| 2320 |
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) { |
| 2321 |
$success = $wpdb -> get_col($wpdb->prepare("SELECT redirectLink FROM ".$wpdb->base_prefix."iwp_redirects WHERE oldLink = %s LIMIT 1",$current_url)); |
| 2322 |
if(count($success)){ |
| 2323 |
if(function_exists(wp_redirect)){ |
| 2324 |
wp_redirect($success[0]); |
| 2325 |
} |
| 2326 |
} |
| 2327 |
} |
| 2328 |
} |
| 2329 |
} |
| 2330 |
|
| 2331 |
if(!function_exists('iwp_mmb_convert_data')){ |
| 2332 |
function iwp_mmb_convert_data(){ |
| 2333 |
|
| 2334 |
//Schedule backup key need to save . |
| 2335 |
global $wpdb; |
| 2336 |
|
| 2337 |
$client_backup_tasks = get_option('iwp_client_backup_tasks'); |
| 2338 |
|
| 2339 |
$type = $action = $category = ''; |
| 2340 |
|
| 2341 |
if(!empty($client_backup_tasks) && is_array($client_backup_tasks)){ |
| 2342 |
foreach($client_backup_tasks as $key){ |
| 2343 |
if(!is_array($key) || !is_array($key['task_args'])){ |
| 2344 |
continue; |
| 2345 |
} |
| 2346 |
$task_name = $key['task_args']['task_name']; |
| 2347 |
|
| 2348 |
if($task_name == 'Backup Now'){ |
| 2349 |
$type = 'backup'; |
| 2350 |
$action = 'now'; |
| 2351 |
$category = $key['task_args']['what']; |
| 2352 |
} |
| 2353 |
else{ |
| 2354 |
$type = 'scheduleBackup'; |
| 2355 |
$action = 'runTask'; |
| 2356 |
$category = $key['task_args']['what']; |
| 2357 |
} |
| 2358 |
if(is_array($key['task_results'])){ |
| 2359 |
$taskResultData = array(); |
| 2360 |
foreach($key['task_results'] as $keys => $task_results){ |
| 2361 |
|
| 2362 |
$historyID = $task_results['backhack_status']['adminHistoryID']; |
| 2363 |
|
| 2364 |
$taskResultData = array('task_results' => array($historyID => $task_results)); |
| 2365 |
$taskResultData['task_results'][$historyID]['adminHistoryID'] = $historyID; |
| 2366 |
|
| 2367 |
$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' => null,'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') ); |
| 2368 |
|
| 2369 |
} |
| 2370 |
} |
| 2371 |
} |
| 2372 |
} |
| 2373 |
} |
| 2374 |
} |
| 2375 |
|
| 2376 |
if (!function_exists('iwp_mmb_backup_db_changes')) { |
| 2377 |
function iwp_mmb_backup_db_changes(){ |
| 2378 |
$IWP_MMB_BACKUP_TABLE_VERSION = iwp_mmb_get_site_option('iwp_backup_table_version'); |
| 2379 |
if (empty($IWP_MMB_BACKUP_TABLE_VERSION) || $IWP_MMB_BACKUP_TABLE_VERSION == false ) { |
| 2380 |
iwp_mmb_create_backup_status_table(); |
| 2381 |
} |
| 2382 |
if(version_compare(iwp_mmb_get_site_option('iwp_backup_table_version'), '1.1.2', '<')){ |
| 2383 |
iwp_mmb_change_collation_backup_status_table(); |
| 2384 |
} |
| 2385 |
if(version_compare(iwp_mmb_get_site_option('iwp_backup_table_version'), '1.1.3', '<')){ |
| 2386 |
iwp_mmb_add_lastUpdateTime_column_backup_status_table(); |
| 2387 |
} |
| 2388 |
if(version_compare(iwp_mmb_get_site_option('iwp_backup_table_version'), '1.1.4', '<')){ |
| 2389 |
iwp_mmb_change_stausMsg_column_type_backup_status_table(); |
| 2390 |
} |
| 2391 |
if(version_compare(iwp_mmb_get_site_option('iwp_backup_table_version'), '1.1.5', '<')){ |
| 2392 |
iwp_mmb_change_taskResults_column_type_backup_status_table(); |
| 2393 |
} |
| 2394 |
$IWP_MMB_BACKUP_PROCESSED_TABLE_VERSION = iwp_mmb_get_site_option('iwp_backup_processed_iterator_version'); |
| 2395 |
if (empty($IWP_MMB_BACKUP_PROCESSED_TABLE_VERSION) || $IWP_MMB_BACKUP_PROCESSED_TABLE_VERSION == false ) { |
| 2396 |
iwp_mmb_create_processed_iterator(); |
| 2397 |
} |
| 2398 |
} |
| 2399 |
} |
| 2400 |
|
| 2401 |
if(!function_exists('iwp_mmb_create_backup_status_table')){ |
| 2402 |
//write new backup_status_table changes also in this function. |
| 2403 |
function iwp_mmb_create_backup_status_table(){ |
| 2404 |
global $wpdb; |
| 2405 |
if(method_exists($wpdb, 'get_charset_collate')){ |
| 2406 |
$charset_collate = $wpdb->get_charset_collate(); |
| 2407 |
} |
| 2408 |
|
| 2409 |
$table_name = $wpdb->base_prefix . "iwp_backup_status"; |
| 2410 |
|
| 2411 |
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name){ |
| 2412 |
if (!empty($charset_collate)){ |
| 2413 |
$cachecollation = $charset_collate; |
| 2414 |
} |
| 2415 |
else{ |
| 2416 |
$cachecollation = ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci '; |
| 2417 |
} |
| 2418 |
|
| 2419 |
$sql = " |
| 2420 |
CREATE TABLE `$table_name` ( |
| 2421 |
`ID` int(11) NOT NULL AUTO_INCREMENT, |
| 2422 |
`historyID` int(11) NOT NULL, |
| 2423 |
`taskName` varchar(255) NOT NULL, |
| 2424 |
`action` varchar(50) NOT NULL, |
| 2425 |
`type` varchar(50) NOT NULL, |
| 2426 |
`category` varchar(50) NOT NULL, |
| 2427 |
`stage` varchar(255) NOT NULL, |
| 2428 |
`status` varchar(255) NOT NULL, |
| 2429 |
`finalStatus` varchar(50) DEFAULT NULL, |
| 2430 |
`statusMsg` longtext, |
| 2431 |
`requestParams` text NOT NULL, |
| 2432 |
`responseParams` longtext, |
| 2433 |
`taskResults` text, |
| 2434 |
`startTime` int(11) DEFAULT NULL, |
| 2435 |
`lastUpdateTime` int(10) unsigned DEFAULT NULL, |
| 2436 |
`endTime` int(11) NOT NULL, |
| 2437 |
PRIMARY KEY (`ID`) |
| 2438 |
)".$cachecollation." ; |
| 2439 |
"; |
| 2440 |
|
| 2441 |
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
| 2442 |
dbDelta( $sql ); |
| 2443 |
|
| 2444 |
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) { |
| 2445 |
update_option( "iwp_backup_table_version", '1.1.4'); |
| 2446 |
} |
| 2447 |
} |
| 2448 |
} |
| 2449 |
} |
| 2450 |
|
| 2451 |
if(!function_exists('iwp_mmb_create_processed_iterator')){ |
| 2452 |
//write new backup_status_table changes also in this function. |
| 2453 |
function iwp_mmb_create_processed_iterator(){ |
| 2454 |
global $wpdb; |
| 2455 |
if(method_exists($wpdb, 'get_charset_collate')){ |
| 2456 |
$charset_collate = $wpdb->get_charset_collate(); |
| 2457 |
} |
| 2458 |
|
| 2459 |
$table_name = $wpdb->base_prefix . "iwp_processed_iterator"; |
| 2460 |
|
| 2461 |
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name){ |
| 2462 |
if (!empty($charset_collate)){ |
| 2463 |
$cachecollation = $charset_collate; |
| 2464 |
} |
| 2465 |
else{ |
| 2466 |
$cachecollation = ' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci '; |
| 2467 |
} |
| 2468 |
|
| 2469 |
$sql = " |
| 2470 |
CREATE TABLE `$table_name` ( |
| 2471 |
`id` int(11) NOT NULL AUTO_INCREMENT, |
| 2472 |
`name` longtext, |
| 2473 |
`offset` text, |
| 2474 |
PRIMARY KEY (`id`) |
| 2475 |
)".$cachecollation." ; |
| 2476 |
"; |
| 2477 |
|
| 2478 |
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
| 2479 |
dbDelta( $sql ); |
| 2480 |
|
| 2481 |
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) { |
| 2482 |
update_option( "iwp_backup_processed_iterator_version", '1.0.0'); |
| 2483 |
} |
| 2484 |
} |
| 2485 |
} |
| 2486 |
} |
| 2487 |
|
| 2488 |
if(!function_exists('iwp_mmb_change_collation_backup_status_table')){ |
| 2489 |
function iwp_mmb_change_collation_backup_status_table(){ |
| 2490 |
global $wpdb; |
| 2491 |
if(method_exists($wpdb, 'get_charset_collate')){ |
| 2492 |
$charset_collate = $wpdb->get_charset_collate(); |
| 2493 |
} |
| 2494 |
|
| 2495 |
$table_name = $wpdb->base_prefix . "iwp_backup_status"; |
| 2496 |
|
| 2497 |
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) { |
| 2498 |
if (!empty($charset_collate)){ |
| 2499 |
$cachecollation_table = $charset_collate; |
| 2500 |
$cachecollation = str_ireplace('DEFAULT ', '', $charset_collate); |
| 2501 |
} |
| 2502 |
else{ |
| 2503 |
$cachecollation = ' CHARACTER SET utf8 COLLATE utf8_general_ci '; |
| 2504 |
$cachecollation_table = $cachecollation; |
| 2505 |
} |
| 2506 |
|
| 2507 |
$sql = array(); |
| 2508 |
|
| 2509 |
$sql[] = "alter table " . $table_name . " change `taskName` `taskName` VARBINARY(255);"; |
| 2510 |
$sql[] = "alter table " . $table_name . " change `taskName` `taskName` VARCHAR(255) $cachecollation not null;"; |
| 2511 |
|
| 2512 |
$sql[] = "alter table " . $table_name . " change action action VARBINARY(50);"; |
| 2513 |
$sql[] = "alter table " . $table_name . " change action action VARCHAR(50) $cachecollation not null ;"; |
| 2514 |
|
| 2515 |
$sql[] = "alter table " . $table_name . " change type type VARBINARY(50);"; |
| 2516 |
$sql[] = "alter table " . $table_name . " change type type VARCHAR(50) $cachecollation not null ;"; |
| 2517 |
|
| 2518 |
$sql[] = "alter table " . $table_name . " change category category VARBINARY(50);"; |
| 2519 |
$sql[] = "alter table " . $table_name . " change category category VARCHAR(50) $cachecollation not null ;"; |
| 2520 |
|
| 2521 |
$sql[] = "alter table " . $table_name . " change stage stage VARBINARY(255);"; |
| 2522 |
$sql[] = "alter table " . $table_name . " change stage stage VARCHAR(255) $cachecollation not null ;"; |
| 2523 |
|
| 2524 |
$sql[] = "alter table " . $table_name . " change status status VARBINARY(255);"; |
| 2525 |
$sql[] = "alter table " . $table_name . " change status status VARCHAR(255) $cachecollation not null ;"; |
| 2526 |
|
| 2527 |
$sql[] = "alter table " . $table_name . " change finalStatus finalStatus VARBINARY(50);"; |
| 2528 |
$sql[] = "alter table " . $table_name . " change finalStatus finalStatus VARCHAR(50) $cachecollation default null ;"; |
| 2529 |
|
| 2530 |
$sql[] = "alter table " . $table_name . " change statusMsg statusMsg VARBINARY(255);"; |
| 2531 |
$sql[] = "alter table " . $table_name . " change statusMsg statusMsg VARCHAR(255) $cachecollation not null ;"; |
| 2532 |
|
| 2533 |
$sql[] = "alter table " . $table_name . " change requestParams requestParams BLOB;"; |
| 2534 |
$sql[] = "alter table " . $table_name . " change requestParams requestParams TEXT $cachecollation not null;"; |
| 2535 |
|
| 2536 |
$sql[] = "alter table " . $table_name . " change responseParams responseParams LONGBLOB;"; |
| 2537 |
$sql[] = "alter table " . $table_name . " change responseParams responseParams LONGTEXT $cachecollation ;"; |
| 2538 |
|
| 2539 |
$sql[] = "alter table " . $table_name . " change taskResults taskResults BLOB;"; |
| 2540 |
$sql[] = "alter table " . $table_name . " change taskResults taskResults TEXT $cachecollation ;"; |
| 2541 |
|
| 2542 |
$sql[] = "ALTER TABLE " . $table_name . " $cachecollation_table ;"; |
| 2543 |
$this_reurn = array(); |
| 2544 |
foreach($sql as $v){ |
| 2545 |
//global $wpdb; |
| 2546 |
$this_reurn[] = $wpdb->query($v); |
| 2547 |
} |
| 2548 |
update_option( "iwp_backup_table_version", '1.1.2'); |
| 2549 |
} |
| 2550 |
} |
| 2551 |
} |
| 2552 |
|
| 2553 |
if(!function_exists('iwp_mmb_add_lastUpdateTime_column_backup_status_table')){ |
| 2554 |
function iwp_mmb_add_lastUpdateTime_column_backup_status_table(){ |
| 2555 |
global $wpdb; |
| 2556 |
$table_name = $wpdb->base_prefix . "iwp_backup_status"; |
| 2557 |
if($wpdb->get_var("SHOW COLUMNS FROM `$table_name` WHERE Field = 'lastUpdateTime'")){ |
| 2558 |
update_option( "iwp_backup_table_version", '1.1.3'); |
| 2559 |
return false; |
| 2560 |
} |
| 2561 |
$sql = "ALTER TABLE ".$table_name." ADD `lastUpdateTime` INT(10) UNSIGNED NULL;"; |
| 2562 |
$isDone = $wpdb->query($sql); |
| 2563 |
if ($isDone) { |
| 2564 |
update_option( "iwp_backup_table_version", '1.1.3'); |
| 2565 |
} |
| 2566 |
|
| 2567 |
} |
| 2568 |
} |
| 2569 |
|
| 2570 |
if (!function_exists('iwp_mmb_change_stausMsg_column_type_backup_status_table')) { |
| 2571 |
function iwp_mmb_change_stausMsg_column_type_backup_status_table(){ |
| 2572 |
global $wpdb; |
| 2573 |
$table_name = $wpdb->base_prefix . "iwp_backup_status"; |
| 2574 |
$sql = "alter table " . $table_name . " change statusMsg statusMsg LONGTEXT;"; |
| 2575 |
$isDone = $wpdb->query($sql); |
| 2576 |
if ($isDone) { |
| 2577 |
update_option( "iwp_backup_table_version", '1.1.4'); |
| 2578 |
} |
| 2579 |
} |
| 2580 |
} |
| 2581 |
|
| 2582 |
if (!function_exists('iwp_mmb_change_taskResults_column_type_backup_status_table')) { |
| 2583 |
function iwp_mmb_change_taskResults_column_type_backup_status_table(){ |
| 2584 |
global $wpdb; |
| 2585 |
$table_name = $wpdb->base_prefix . "iwp_backup_status"; |
| 2586 |
$sql = "alter table " . $table_name . " change taskResults taskResults LONGTEXT;"; |
| 2587 |
$isDone = $wpdb->query($sql); |
| 2588 |
if ($isDone) { |
| 2589 |
update_option( "iwp_backup_table_version", '1.1.5'); |
| 2590 |
} |
| 2591 |
} |
| 2592 |
} |
| 2593 |
//------------------------------------------------------------------- |
| 2594 |
|
| 2595 |
//-Function name - iwp_mmb_get_file_size() |
| 2596 |
//-This is the alternate function to calculate file size |
| 2597 |
//-This function is introduced to support the filesize calculation for the files which are larger than 2048MB |
| 2598 |
|
| 2599 |
//---------------------------------------------------------------------- |
| 2600 |
|
| 2601 |
if(!function_exists('iwp_mmb_get_file_size')){ |
| 2602 |
function iwp_mmb_get_file_size($file) |
| 2603 |
{ |
| 2604 |
clearstatcache(); |
| 2605 |
if(!empty($file) && is_array($file)){ |
| 2606 |
// it will work on multipart mechanisam |
| 2607 |
$key = key($file); |
| 2608 |
$normal_file_size = filesize($file[$key]); |
| 2609 |
}else{ |
| 2610 |
$normal_file_size = filesize($file); |
| 2611 |
} |
| 2612 |
|
| 2613 |
if(($normal_file_size !== false)&&($normal_file_size >= 0)) |
| 2614 |
{ |
| 2615 |
return $normal_file_size; |
| 2616 |
} |
| 2617 |
else |
| 2618 |
{ |
| 2619 |
$file = realPath($file); |
| 2620 |
if(!$file) |
| 2621 |
{ |
| 2622 |
echo 'iwp_mmb_get_file_size_error : realPath error'; |
| 2623 |
echo "File Name: $file"; |
| 2624 |
} |
| 2625 |
$ch = curl_init("file://" . $file); |
| 2626 |
curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_FILE); |
| 2627 |
curl_setopt($ch, CURLOPT_NOBODY, true); |
| 2628 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 2629 |
curl_setopt($ch, CURLOPT_HEADER, true); |
| 2630 |
$data = curl_exec($ch); |
| 2631 |
$curl_error = curl_error($ch); |
| 2632 |
curl_close($ch); |
| 2633 |
if ($data !== false && preg_match('/Content-Length: (\d+)/', $data, $matches)) { |
| 2634 |
return (string) $matches[1]; |
| 2635 |
} |
| 2636 |
else |
| 2637 |
{ |
| 2638 |
echo 'iwp_mmb_get_file_size_error : '.$curl_error; |
| 2639 |
echo "File Name: $file"; |
| 2640 |
return $normal_file_size; |
| 2641 |
} |
| 2642 |
} |
| 2643 |
} |
| 2644 |
} |
| 2645 |
|
| 2646 |
if( !function_exists('iwp_mmb_backup_test_site')){ |
| 2647 |
function iwp_mmb_backup_test_site($params){ |
| 2648 |
global $iwp_mmb_core,$iwp_mmb_plugin_dir; |
| 2649 |
$return = array(); |
| 2650 |
|
| 2651 |
$iwp_mmb_core->get_backup_instance(); |
| 2652 |
$return = $iwp_mmb_core->backup_instance->check_backup_compat($params); |
| 2653 |
|
| 2654 |
if (is_array($return) && array_key_exists('error', $return)) |
| 2655 |
iwp_mmb_response($return, false); |
| 2656 |
else { |
| 2657 |
iwp_mmb_response($return, true); |
| 2658 |
} |
| 2659 |
} |
| 2660 |
} |
| 2661 |
|
| 2662 |
if( !function_exists('iwp_get_changelog_plugin')){ |
| 2663 |
function iwp_get_changelog_plugin($params){ |
| 2664 |
$return = array(); |
| 2665 |
if (empty($params['slug'])) { |
| 2666 |
return iwp_mmb_response(array('error' => 'Plugin slug not available', 'error_code' => 'changelog_plugin_slug_not_available'), false); |
| 2667 |
} |
| 2668 |
if (!function_exists('plugins_api')) { |
| 2669 |
include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
| 2670 |
} |
| 2671 |
$request = plugins_api( 'plugin_information', array('slug' =>$params['slug']) ); |
| 2672 |
|
| 2673 |
if ( is_wp_error( $request ) ) { |
| 2674 |
$return['error'] = $request->get_error_message(); |
| 2675 |
$return['error_code'] = 'changelog_plugin_api_error'; |
| 2676 |
}else{ |
| 2677 |
if (is_object($request)) { |
| 2678 |
$return = (array)$request; |
| 2679 |
} |
| 2680 |
} |
| 2681 |
|
| 2682 |
if (is_array($return) && array_key_exists('error', $return)) |
| 2683 |
iwp_mmb_response($return, false); |
| 2684 |
else { |
| 2685 |
iwp_mmb_response($return, true); |
| 2686 |
} |
| 2687 |
} |
| 2688 |
} |
| 2689 |
|
| 2690 |
//add_action( 'plugins_loaded', 'iwp_mmb_create_backup_table' ); |
| 2691 |
|
| 2692 |
//register_activation_hook( __FILE__, 'iwp_mmb_create_backup_table' ); |
| 2693 |
|
| 2694 |
if(!function_exists('iwp_mmb_add_clipboard_scripts')){ |
| 2695 |
function iwp_mmb_add_clipboard_scripts(){ |
| 2696 |
if (!wp_script_is( 'iwp-clipboard', 'enqueued' )) { |
| 2697 |
if(file_exists(WP_PLUGIN_DIR.'/iwp-client/clipboard.min.js') ){ |
| 2698 |
wp_enqueue_script( |
| 2699 |
'iwp-clipboard', |
| 2700 |
plugins_url( 'clipboard.min.js', __FILE__ ), |
| 2701 |
array( 'jquery' ) |
| 2702 |
); |
| 2703 |
} |
| 2704 |
} |
| 2705 |
} |
| 2706 |
} |
| 2707 |
|
| 2708 |
if (!function_exists('run_hash_change_process')) { |
| 2709 |
function run_hash_change_process(){ |
| 2710 |
//code to check whether old hash files are already changed from wp_option table flag |
| 2711 |
$is_replaced = get_option('iwp_client_replaced_old_hash_backup_files'); |
| 2712 |
if($is_replaced){ |
| 2713 |
return true; |
| 2714 |
} |
| 2715 |
|
| 2716 |
global $wpdb; |
| 2717 |
$table_name = $wpdb->base_prefix . "iwp_backup_status"; |
| 2718 |
$rows = $wpdb->get_results("SELECT historyID,taskResults FROM ".$table_name, ARRAY_A); |
| 2719 |
|
| 2720 |
$hash_changed_files = array(); |
| 2721 |
$hash_changed_urls = array(); |
| 2722 |
foreach($rows as $k => $v){ |
| 2723 |
$this_his_id = $v['historyID']; |
| 2724 |
$this_task_result = unserialize($v['taskResults']); |
| 2725 |
if(!empty($this_task_result) && !empty($this_task_result['task_results']) && !empty($this_task_result['task_results'][$this_his_id]) && !empty($this_task_result['task_results'][$this_his_id]['server']) && !empty($this_task_result['task_results'][$this_his_id]['server']) && !empty($this_task_result['task_results'][$this_his_id]['server']['file_path']) && !empty($this_task_result['task_results'][$this_his_id]['server']['file_url'])){ |
| 2726 |
$new_task_result_server = modify_task_result_server($this_task_result['task_results'][$this_his_id]['server']); |
| 2727 |
if(is_array($new_task_result_server) && array_key_exists("error", $new_task_result_server)){ |
| 2728 |
continue; |
| 2729 |
} |
| 2730 |
$this_task_result['task_results'][$this_his_id]['server'] = $new_task_result_server; |
| 2731 |
} |
| 2732 |
if(!empty($this_task_result) && !empty($this_task_result['server']) && !empty($new_task_result_server['hash'])){ |
| 2733 |
$new_task_result_server = modify_task_result_server($this_task_result['server'], $new_task_result_server['hash']); |
| 2734 |
if(is_array($new_task_result_server) && array_key_exists("error", $new_task_result_server)){ |
| 2735 |
return $new_task_result_server; |
| 2736 |
break; |
| 2737 |
} |
| 2738 |
$this_task_result['server'] = $new_task_result_server; |
| 2739 |
|
| 2740 |
} |
| 2741 |
|
| 2742 |
//updating table with new fileNames |
| 2743 |
$new_task_result = serialize($this_task_result); |
| 2744 |
$update = $wpdb->update($wpdb->base_prefix.'iwp_backup_status',array('taskResults' => $new_task_result ),array( 'historyID' => $this_his_id),array('%s'),array('%d')); |
| 2745 |
} |
| 2746 |
update_option('iwp_client_replaced_old_hash_backup_files', true); |
| 2747 |
return true; |
| 2748 |
} |
| 2749 |
} |
| 2750 |
|
| 2751 |
if (!function_exists('modify_task_result_server')) { |
| 2752 |
function modify_task_result_server($task_result_server, $useThisHash=''){ |
| 2753 |
if(!is_array($task_result_server['file_path'])){ |
| 2754 |
$current_file = $task_result_server['file_path']; |
| 2755 |
$task_result_server['file_path'] = array(); |
| 2756 |
$task_result_server['file_path'][0] = $current_file; |
| 2757 |
} |
| 2758 |
if(!is_array($task_result_server['file_url'])){ |
| 2759 |
$current_url = $task_result_server['file_url']; |
| 2760 |
$task_result_server['file_url'] = array(); |
| 2761 |
$task_result_server['file_url'][0] = $current_url; |
| 2762 |
} |
| 2763 |
|
| 2764 |
$old_file_path = $task_result_server['file_path']; |
| 2765 |
$old_file_url = $task_result_server['file_url']; |
| 2766 |
|
| 2767 |
$new_file_path = replace_old_hash_with_new_hash($old_file_path, $useThisHash); |
| 2768 |
foreach($new_file_path['files'] as $ke => $va){ |
| 2769 |
|
| 2770 |
//rename file |
| 2771 |
$rename_result = rename_old_backup_file_name($va['old'], $va['new']); |
| 2772 |
if(is_array($rename_result) && array_key_exists("error", $rename_result)){ |
| 2773 |
return $rename_result; |
| 2774 |
break; |
| 2775 |
} |
| 2776 |
$task_result_server['file_path'][$ke] = $va['new']; |
| 2777 |
} |
| 2778 |
$task_result_server['hash'] = $new_file_path['hash']; |
| 2779 |
|
| 2780 |
$new_file_url = replace_old_hash_with_new_hash($old_file_url, $new_file_path['hash']); |
| 2781 |
foreach($new_file_url['files'] as $ke => $va){ |
| 2782 |
$task_result_server['file_url'][$ke] = $va['new']; |
| 2783 |
} |
| 2784 |
|
| 2785 |
//for single backup fix |
| 2786 |
if(count($task_result_server['file_path']) === 1){ |
| 2787 |
$temp_val = $task_result_server['file_path'][0]; |
| 2788 |
unset($task_result_server['file_path']); |
| 2789 |
$task_result_server['file_path'] = $temp_val; |
| 2790 |
} |
| 2791 |
if(count($task_result_server['file_url']) === 1){ |
| 2792 |
$temp_val = $task_result_server['file_url'][0]; |
| 2793 |
unset($task_result_server['file_url']); |
| 2794 |
$task_result_server['file_url'] = $temp_val; |
| 2795 |
} |
| 2796 |
return $task_result_server; |
| 2797 |
} |
| 2798 |
} |
| 2799 |
|
| 2800 |
if (!function_exists('replace_old_hash_with_new_hash')) { |
| 2801 |
|
| 2802 |
function replace_old_hash_with_new_hash($backFileArr, $useThisHash='') { |
| 2803 |
$newbackupfileArr = array(); |
| 2804 |
$newbackupfileArr['files'] = array(); |
| 2805 |
$newbackupfileArr['hash'] = ''; |
| 2806 |
|
| 2807 |
if(empty($useThisHash)){ |
| 2808 |
$newBackupHash = md5(microtime(true).uniqid('',true).substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, rand(20,60))); |
| 2809 |
$useThisHash = $newBackupHash; |
| 2810 |
} |
| 2811 |
else{ |
| 2812 |
$newBackupHash = $useThisHash; |
| 2813 |
} |
| 2814 |
foreach($backFileArr as $k => $backFile){ |
| 2815 |
$iwpPart = '.zip'; |
| 2816 |
$tempBackupFile = $backFile; |
| 2817 |
|
| 2818 |
$iwpPartIndex = strpos($backFile, '_iwp_part'); |
| 2819 |
if($iwpPartIndex !== false){ |
| 2820 |
$iwpPart = substr($backFile, $iwpPartIndex); |
| 2821 |
$backFile = substr($backFile, 0, $iwpPartIndex); |
| 2822 |
} |
| 2823 |
|
| 2824 |
$backFileInArray = explode("_", $backFile); |
| 2825 |
$hashIndex = count($backFileInArray) - 1; |
| 2826 |
|
| 2827 |
$backupHashWithZip = $backFileInArray[$hashIndex]; |
| 2828 |
$backupHash = substr($backupHashWithZip, 0, 32); |
| 2829 |
|
| 2830 |
$newBackupHashWithZip = $newBackupHash . $iwpPart; |
| 2831 |
$newBackupFile = substr($backFile, 0, strpos($backFile, $backupHashWithZip)); |
| 2832 |
$newBackupFile = $newBackupFile . $newBackupHashWithZip; |
| 2833 |
$newbackupfileArr['files'][$k]['new'] = $newBackupFile; |
| 2834 |
$newbackupfileArr['files'][$k]['old'] = $tempBackupFile; |
| 2835 |
} |
| 2836 |
$newbackupfileArr['hash'] = $newBackupHash; |
| 2837 |
return $newbackupfileArr; |
| 2838 |
} |
| 2839 |
|
| 2840 |
} |
| 2841 |
|
| 2842 |
|
| 2843 |
if (!function_exists('rename_old_backup_file_name')) { |
| 2844 |
|
| 2845 |
function rename_old_backup_file_name($oldName, $newName) { |
| 2846 |
if (!@rename($oldName, $newName)) { |
| 2847 |
return array('error' => 'Unable to rename old files', 'error_code' => 'unable_to_remane_old_backup_files'); |
| 2848 |
} |
| 2849 |
return true; |
| 2850 |
} |
| 2851 |
} |
| 2852 |
|
| 2853 |
if(!function_exists('iwp_mmb_get_site_option')) { |
| 2854 |
|
| 2855 |
function iwp_mmb_get_site_option($option_name){ |
| 2856 |
if(is_multisite()){ |
| 2857 |
$blog_id = get_current_blog_id(); |
| 2858 |
$option_value = get_blog_option($blog_id,$option_name); |
| 2859 |
} |
| 2860 |
else { |
| 2861 |
$option_value = get_site_option($option_name); |
| 2862 |
} |
| 2863 |
return $option_value; |
| 2864 |
} |
| 2865 |
} |
| 2866 |
|
| 2867 |
if ( !get_option('iwp_client_public_key') && function_exists('add_action')){ |
| 2868 |
add_action('admin_enqueue_scripts', 'iwp_mmb_add_clipboard_scripts'); |
| 2869 |
} |
| 2870 |
|
| 2871 |
if (!function_exists('iwp_mmb_json_encode')) { |
| 2872 |
function iwp_mmb_json_encode($data, $options = 0, $depth = 512){ |
| 2873 |
if ( version_compare( PHP_VERSION, '5.5', '>=' ) ) { |
| 2874 |
$args = array( $data, $options, $depth ); |
| 2875 |
} elseif ( version_compare( PHP_VERSION, '5.3', '>=' ) ) { |
| 2876 |
$args = array( $data, $options ); |
| 2877 |
} else { |
| 2878 |
$args = array( $data ); |
| 2879 |
} |
| 2880 |
$json = @call_user_func_array( 'json_encode', $args ); |
| 2881 |
|
| 2882 |
if ( false !== $json && ( version_compare( PHP_VERSION, '5.5', '>=' ) || false === strpos( $json, 'null' ) ) ) { |
| 2883 |
return $json; |
| 2884 |
} |
| 2885 |
|
| 2886 |
$args[0] = iwp_mmb_json_compatible_check( $data, $depth ); |
| 2887 |
return @call_user_func_array( 'json_encode', $args ); |
| 2888 |
} |
| 2889 |
} |
| 2890 |
|
| 2891 |
if (!function_exists('json_encode')) |
| 2892 |
{ |
| 2893 |
function json_encode($a=false) |
| 2894 |
{ |
| 2895 |
if (is_null($a)) return 'null'; |
| 2896 |
if ($a === false) return 'false'; |
| 2897 |
if ($a === true) return 'true'; |
| 2898 |
if (is_scalar($a)) |
| 2899 |
{ |
| 2900 |
if (is_float($a)) |
| 2901 |
{ |
| 2902 |
// Always use "." for floats. |
| 2903 |
return floatval(str_replace(",", ".", strval($a))); |
| 2904 |
} |
| 2905 |
|
| 2906 |
if (is_string($a)) |
| 2907 |
{ |
| 2908 |
static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"')); |
| 2909 |
return '"' . str_replace($jsonReplaces[0], $jsonReplaces[1], $a) . '"'; |
| 2910 |
} |
| 2911 |
else |
| 2912 |
return $a; |
| 2913 |
} |
| 2914 |
$isList = true; |
| 2915 |
for ($i = 0, reset($a); $i < count($a); $i++, next($a)) |
| 2916 |
{ |
| 2917 |
if (key($a) !== $i) |
| 2918 |
{ |
| 2919 |
$isList = false; |
| 2920 |
break; |
| 2921 |
} |
| 2922 |
} |
| 2923 |
$result = array(); |
| 2924 |
if ($isList) |
| 2925 |
{ |
| 2926 |
foreach ($a as $v) $result[] = iwp_mmb_json_encode($v); |
| 2927 |
return '[' . join(',', $result) . ']'; |
| 2928 |
} |
| 2929 |
else |
| 2930 |
{ |
| 2931 |
foreach ($a as $k => $v) $result[] = iwp_mmb_json_encode($k).':'.iwp_mmb_json_encode($v); |
| 2932 |
return '{' . join(',', $result) . '}'; |
| 2933 |
} |
| 2934 |
} |
| 2935 |
} |
| 2936 |
if (!function_exists('iwp_mmb_json_compatible_check')) { |
| 2937 |
function iwp_mmb_json_compatible_check( $data, $depth ) { |
| 2938 |
if ( $depth < 0 ) { |
| 2939 |
return false; |
| 2940 |
} |
| 2941 |
|
| 2942 |
if ( is_array( $data ) ) { |
| 2943 |
$output = array(); |
| 2944 |
foreach ( $data as $key => $value ) { |
| 2945 |
if ( is_string( $key ) ) { |
| 2946 |
$id = iwp_mmb_json_convert_string( $key ); |
| 2947 |
} else { |
| 2948 |
$id = $key; |
| 2949 |
} |
| 2950 |
if ( is_array( $value ) || is_object( $value ) ) { |
| 2951 |
$output[ $id ] = iwp_mmb_json_compatible_check( $value, $depth - 1 ); |
| 2952 |
} elseif ( is_string( $value ) ) { |
| 2953 |
$output[ $id ] = iwp_mmb_json_convert_string( $value ); |
| 2954 |
} else { |
| 2955 |
$output[ $id ] = $value; |
| 2956 |
} |
| 2957 |
} |
| 2958 |
} elseif ( is_object( $data ) ) { |
| 2959 |
$output = new stdClass; |
| 2960 |
foreach ( $data as $key => $value ) { |
| 2961 |
if ( is_string( $key ) ) { |
| 2962 |
$id = iwp_mmb_json_convert_string( $key ); |
| 2963 |
} else { |
| 2964 |
$id = $key; |
| 2965 |
} |
| 2966 |
|
| 2967 |
if ( is_array( $value ) || is_object( $value ) ) { |
| 2968 |
$output->$id = iwp_mmb_json_compatible_check( $value, $depth - 1 ); |
| 2969 |
} elseif ( is_string( $value ) ) { |
| 2970 |
$output->$id = iwp_mmb_json_convert_string( $value ); |
| 2971 |
} else { |
| 2972 |
$output->$id = $value; |
| 2973 |
} |
| 2974 |
} |
| 2975 |
} elseif ( is_string( $data ) ) { |
| 2976 |
return iwp_mmb_json_convert_string( $data ); |
| 2977 |
} else { |
| 2978 |
return $data; |
| 2979 |
} |
| 2980 |
|
| 2981 |
return $output; |
| 2982 |
} |
| 2983 |
} |
| 2984 |
if (!function_exists('iwp_mmb_json_convert_string')) { |
| 2985 |
function iwp_mmb_json_convert_string( $string ) { |
| 2986 |
if ( function_exists( 'mb_convert_encoding' ) ) { |
| 2987 |
$encoding = mb_detect_encoding( $string, mb_detect_order(), true ); |
| 2988 |
if ( $encoding ) { |
| 2989 |
return mb_convert_encoding( $string, 'UTF-8', $encoding ); |
| 2990 |
} else { |
| 2991 |
return mb_convert_encoding( $string, 'UTF-8', 'UTF-8' ); |
| 2992 |
} |
| 2993 |
} else { |
| 2994 |
return check_invalid_UTF8( $string, true); |
| 2995 |
} |
| 2996 |
} |
| 2997 |
} |
| 2998 |
|
| 2999 |
if ( !function_exists('mb_detect_encoding') ) { |
| 3000 |
function mb_detect_encoding ($string, $enc=null, $ret=null) { |
| 3001 |
|
| 3002 |
static $enclist = array( |
| 3003 |
'UTF-8', |
| 3004 |
// 'ASCII', |
| 3005 |
// 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4', 'ISO-8859-5', |
| 3006 |
// 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9', 'ISO-8859-10', |
| 3007 |
// 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'ISO-8859-16', |
| 3008 |
// 'Windows-1251', 'Windows-1252', 'Windows-1254', |
| 3009 |
); |
| 3010 |
|
| 3011 |
$result = false; |
| 3012 |
|
| 3013 |
foreach ($enclist as $item) { |
| 3014 |
$sample = $string; |
| 3015 |
if(function_exists('iconv')) |
| 3016 |
$sample = iconv($item, $item, $string); |
| 3017 |
if (md5($sample) == md5($string)) { |
| 3018 |
if ($ret === NULL) { $result = $item; } else { $result = true; } |
| 3019 |
break; |
| 3020 |
} |
| 3021 |
} |
| 3022 |
|
| 3023 |
return $result; |
| 3024 |
} |
| 3025 |
} |
| 3026 |
|
| 3027 |
if (!function_exists('check_invalid_UTF8')) { |
| 3028 |
function check_invalid_UTF8( $string, $strip = false ) { |
| 3029 |
$string = (string) $string; |
| 3030 |
|
| 3031 |
if ( 0 === strlen( $string ) ) { |
| 3032 |
return ''; |
| 3033 |
} |
| 3034 |
|
| 3035 |
// Check for support for utf8 in the installed PCRE library once and store the result in a static |
| 3036 |
static $utf8_pcre = null; |
| 3037 |
if ( ! isset( $utf8_pcre ) ) { |
| 3038 |
$utf8_pcre = @preg_match( '/^./u', 'a' ); |
| 3039 |
} |
| 3040 |
// We can't demand utf8 in the PCRE installation, so just return the string in those cases |
| 3041 |
if ( !$utf8_pcre ) { |
| 3042 |
return $string; |
| 3043 |
} |
| 3044 |
|
| 3045 |
// preg_match fails when it encounters invalid UTF8 in $string |
| 3046 |
if ( 1 === @preg_match( '/^./us', $string ) ) { |
| 3047 |
return $string; |
| 3048 |
} |
| 3049 |
|
| 3050 |
// Attempt to strip the bad chars if requested (not recommended) |
| 3051 |
if ( $strip && function_exists( 'iconv' ) ) { |
| 3052 |
return iconv( 'utf-8', 'utf-8', $string ); |
| 3053 |
} |
| 3054 |
|
| 3055 |
return ''; |
| 3056 |
} |
| 3057 |
} |
| 3058 |
|
| 3059 |
define('IWP_MAX_SERIALIZED_INPUT_LENGTH', 2*8192); |
| 3060 |
define('IWP_MAX_SERIALIZED_ARRAY_LENGTH', 512); |
| 3061 |
define('IWP_MAX_SERIALIZED_ARRAY_DEPTH', 20); |
| 3062 |
function _iwp_mmb_safe_unserialize($str) |
| 3063 |
{ |
| 3064 |
if(strlen($str) > IWP_MAX_SERIALIZED_INPUT_LENGTH) |
| 3065 |
{ |
| 3066 |
// input exceeds IWP_MAX_SERIALIZED_INPUT_LENGTH |
| 3067 |
return false; |
| 3068 |
} |
| 3069 |
if(empty($str) || !is_string($str)) |
| 3070 |
{ |
| 3071 |
return false; |
| 3072 |
} |
| 3073 |
$stack = array(); |
| 3074 |
$expected = array(); |
| 3075 |
$list = array(); |
| 3076 |
$data = array(); |
| 3077 |
/* |
| 3078 |
* states: |
| 3079 |
* 0 - initial state, expecting a single value or array |
| 3080 |
* 1 - terminal state |
| 3081 |
* 2 - in array, expecting end of array or a key |
| 3082 |
* 3 - in array, expecting value or another array |
| 3083 |
*/ |
| 3084 |
$state = 0; |
| 3085 |
$key =0; |
| 3086 |
while($state != 1) |
| 3087 |
{ |
| 3088 |
$type = isset($str[0]) ? $str[0] : ''; |
| 3089 |
if($type == '}') |
| 3090 |
{ |
| 3091 |
$str = substr($str, 1); |
| 3092 |
} |
| 3093 |
else if($type == 'N' && $str[1] == ';') |
| 3094 |
{ |
| 3095 |
$value = null; |
| 3096 |
$str = substr($str, 2); |
| 3097 |
} |
| 3098 |
else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
| 3099 |
{ |
| 3100 |
$value = $matches[1] == '1' ? true : false; |
| 3101 |
$str = substr($str, 4); |
| 3102 |
} |
| 3103 |
else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
| 3104 |
{ |
| 3105 |
$value = (int)$matches[1]; |
| 3106 |
$str = $matches[2]; |
| 3107 |
} |
| 3108 |
else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
| 3109 |
{ |
| 3110 |
$value = (float)$matches[1]; |
| 3111 |
$str = $matches[3]; |
| 3112 |
} |
| 3113 |
else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
| 3114 |
{ |
| 3115 |
$value = substr($matches[2], 0, (int)$matches[1]); |
| 3116 |
$str = substr($matches[2], (int)$matches[1] + 2); |
| 3117 |
} |
| 3118 |
else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches) && $matches[1] < IWP_MAX_SERIALIZED_ARRAY_LENGTH) |
| 3119 |
{ |
| 3120 |
$expectedLength = (int)$matches[1]; |
| 3121 |
$str = $matches[2]; |
| 3122 |
} |
| 3123 |
else |
| 3124 |
{ |
| 3125 |
// object or unknown/malformed type |
| 3126 |
return false; |
| 3127 |
} |
| 3128 |
switch($state) |
| 3129 |
{ |
| 3130 |
case 3: // in array, expecting value or another array |
| 3131 |
if($type == 'a') |
| 3132 |
{ |
| 3133 |
if(count($stack) >= IWP_MAX_SERIALIZED_ARRAY_DEPTH) |
| 3134 |
{ |
| 3135 |
// array nesting exceeds IWP_MAX_SERIALIZED_ARRAY_DEPTH |
| 3136 |
return false; |
| 3137 |
} |
| 3138 |
$stack[] = &$list; |
| 3139 |
$list[$key] = array(); |
| 3140 |
$list = &$list[$key]; |
| 3141 |
$expected[] = $expectedLength; |
| 3142 |
$state = 2; |
| 3143 |
break; |
| 3144 |
} |
| 3145 |
if($type != '}') |
| 3146 |
{ |
| 3147 |
$list[$key] = $value; |
| 3148 |
$state = 2; |
| 3149 |
break; |
| 3150 |
} |
| 3151 |
// missing array value |
| 3152 |
return false; |
| 3153 |
case 2: // in array, expecting end of array or a key |
| 3154 |
if($type == '}') |
| 3155 |
{ |
| 3156 |
if(count($list) < end($expected)) |
| 3157 |
{ |
| 3158 |
// array size less than expected |
| 3159 |
return false; |
| 3160 |
} |
| 3161 |
unset($list); |
| 3162 |
$list = &$stack[count($stack)-1]; |
| 3163 |
array_pop($stack); |
| 3164 |
// go to terminal state if we're at the end of the root array |
| 3165 |
array_pop($expected); |
| 3166 |
if(count($expected) == 0) { |
| 3167 |
$state = 1; |
| 3168 |
} |
| 3169 |
break; |
| 3170 |
} |
| 3171 |
if($type == 'i' || $type == 's') |
| 3172 |
{ |
| 3173 |
if(count($list) >= IWP_MAX_SERIALIZED_ARRAY_LENGTH) |
| 3174 |
{ |
| 3175 |
// array size exceeds IWP_MAX_SERIALIZED_ARRAY_LENGTH |
| 3176 |
return false; |
| 3177 |
} |
| 3178 |
if(count($list) >= end($expected)) |
| 3179 |
{ |
| 3180 |
// array size exceeds expected length |
| 3181 |
return false; |
| 3182 |
} |
| 3183 |
$key = $value; |
| 3184 |
$state = 3; |
| 3185 |
break; |
| 3186 |
} |
| 3187 |
// illegal array index type |
| 3188 |
return false; |
| 3189 |
case 0: // expecting array or value |
| 3190 |
if($type == 'a') |
| 3191 |
{ |
| 3192 |
if(count($stack) >= IWP_MAX_SERIALIZED_ARRAY_DEPTH) |
| 3193 |
{ |
| 3194 |
// array nesting exceeds IWP_MAX_SERIALIZED_ARRAY_DEPTH |
| 3195 |
return false; |
| 3196 |
} |
| 3197 |
$data = array(); |
| 3198 |
$list = &$data; |
| 3199 |
$expected[] = $expectedLength; |
| 3200 |
$state = 2; |
| 3201 |
break; |
| 3202 |
} |
| 3203 |
if($type != '}') |
| 3204 |
{ |
| 3205 |
$data = $value; |
| 3206 |
$state = 1; |
| 3207 |
break; |
| 3208 |
} |
| 3209 |
// not in array |
| 3210 |
return false; |
| 3211 |
} |
| 3212 |
} |
| 3213 |
if(!empty($str)) |
| 3214 |
{ |
| 3215 |
// trailing data in input |
| 3216 |
return false; |
| 3217 |
} |
| 3218 |
return $data; |
| 3219 |
} |
| 3220 |
/** |
| 3221 |
* Wrapper for _safe_unserialize() that handles exceptions and multibyte encoding issue |
| 3222 |
* |
| 3223 |
* @param string $str |
| 3224 |
* @return mixed |
| 3225 |
*/ |
| 3226 |
function iwp_mmb_safe_unserialize( $str ) |
| 3227 |
{ |
| 3228 |
// ensure we use the byte count for strings even when strlen() is overloaded by mb_strlen() |
| 3229 |
if (function_exists('mb_internal_encoding') && |
| 3230 |
(((int) ini_get('mbstring.func_overload')) & 2)) |
| 3231 |
{ |
| 3232 |
$mbIntEnc = mb_internal_encoding(); |
| 3233 |
mb_internal_encoding('ASCII'); |
| 3234 |
} |
| 3235 |
$out = _iwp_mmb_safe_unserialize($str); |
| 3236 |
if (isset($mbIntEnc)) |
| 3237 |
{ |
| 3238 |
mb_internal_encoding($mbIntEnc); |
| 3239 |
} |
| 3240 |
return $out; |
| 3241 |
} |
| 3242 |
|
| 3243 |
function iwp_mmb_get_hosting_disk_quota_free() { |
| 3244 |
if (!@is_dir('/usr/local/cpanel') || !function_exists('popen') || (!@is_executable('/usr/local/bin/perl') && !@is_executable('/usr/local/cpanel/3rdparty/bin/perl')) ) return false; |
| 3245 |
|
| 3246 |
$perl = (@is_executable('/usr/local/cpanel/3rdparty/bin/perl')) ? '/usr/local/cpanel/3rdparty/bin/perl' : '/usr/local/bin/perl'; |
| 3247 |
|
| 3248 |
$exec = "IWPKEY=IWP $perl ".WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__))."/lib/cpanel-quota-usage.pl"; |
| 3249 |
$handle = popen($exec, 'r'); |
| 3250 |
if (!is_resource($handle)) return false; |
| 3251 |
|
| 3252 |
$found = false; |
| 3253 |
$lines = 0; |
| 3254 |
while (false === $found && !feof($handle) && $lines<100) { |
| 3255 |
$lines++; |
| 3256 |
$w = fgets($handle); |
| 3257 |
# Used, limit, remain |
| 3258 |
if (preg_match('/RESULT: (\d+) (\d+) (\d+) /', $w, $matches)) { $found = true; } |
| 3259 |
} |
| 3260 |
$ret = pclose($handle); |
| 3261 |
if (false === $found ||$ret != 0) return false; |
| 3262 |
|
| 3263 |
if ((int)$matches[2]<100 || ($matches[1] + $matches[3] != $matches[2])) return false; |
| 3264 |
|
| 3265 |
return $matches; |
| 3266 |
} |
| 3267 |
|
| 3268 |
function iwp_mmb_check_disk_space(){ |
| 3269 |
$hosting_bytes_free = iwp_mmb_get_hosting_disk_quota_free(); |
| 3270 |
if (is_array($hosting_bytes_free)) { |
| 3271 |
$perc = round(100*$hosting_bytes_free[1]/(max($hosting_bytes_free[2], 1)), 1); |
| 3272 |
$quota_free = round($hosting_bytes_free[3]/1048576, 1); |
| 3273 |
if ($hosting_bytes_free[3] < 1048576*50) { |
| 3274 |
$quota_free_mb = round($hosting_bytes_free[3]/1048576, 1); |
| 3275 |
return $quota_free_mb; |
| 3276 |
} |
| 3277 |
} |
| 3278 |
|
| 3279 |
$disk_free_space = @disk_free_space(dirname(__FILE__)); |
| 3280 |
# == rather than === here is deliberate; support experience shows that a result of (int)0 is not reliable. i.e. 0 can be returned when the real result should be false. |
| 3281 |
if ($disk_free_space == false) { |
| 3282 |
return false; |
| 3283 |
} else { |
| 3284 |
|
| 3285 |
$disk_free_mb = round($disk_free_space/1048576, 1); |
| 3286 |
if ($disk_free_space < 50*1048576) return $disk_free_mb; |
| 3287 |
} |
| 3288 |
return false; |
| 3289 |
} |
| 3290 |
|
| 3291 |
function iwp_closeBrowserConnection($response = false, $success = true){ |
| 3292 |
$response = iwp_mmb_convert_wperror_obj_to_arr($response,'initial'); |
| 3293 |
|
| 3294 |
if ((is_array($response) && empty($response)) || (!is_array($response) && strlen($response) == 0)){ |
| 3295 |
$return['error'] = 'Empty response.'; |
| 3296 |
$return['error_code'] = 'empty_response'; |
| 3297 |
} |
| 3298 |
elseif ($success){ |
| 3299 |
$return['success'] = $response; |
| 3300 |
} |
| 3301 |
else{ |
| 3302 |
$return['error'] = $response['error']; |
| 3303 |
$return['error_code'] = $response['error_code']; |
| 3304 |
} |
| 3305 |
|
| 3306 |
$txt = '<IWPHEADER>_IWP_JSON_PREFIX_' . base64_encode( iwp_mmb_json_encode( $return ) ) . '<ENDIWPHEADER>'; |
| 3307 |
ignore_user_abort(true); |
| 3308 |
if (ob_get_contents()) ob_end_clean(); |
| 3309 |
ob_start(); |
| 3310 |
echo ($txt); |
| 3311 |
$size = ob_get_length(); |
| 3312 |
header("Connection: close\r\n"); |
| 3313 |
header("Content-Encoding: none\r\n"); |
| 3314 |
header("Content-Length: $size"); |
| 3315 |
@ob_flush(); |
| 3316 |
flush(); |
| 3317 |
ob_end_flush(); |
| 3318 |
} |
| 3319 |
|
| 3320 |
function iwp_mmb_set_plugin_priority() |
| 3321 |
{ |
| 3322 |
$activePlugins = get_option('active_plugins'); |
| 3323 |
if (!is_array($activePlugins)) { |
| 3324 |
return; |
| 3325 |
} |
| 3326 |
$pluginBasename = 'iwp-client/init.php'; |
| 3327 |
$wptcPluginBasename = 'wp-time-capsule/wp-time-capsule.php'; |
| 3328 |
$array_slice = array_slice($activePlugins, 1, true); |
| 3329 |
if (!is_array($activePlugins) || (reset($activePlugins) == $wptcPluginBasename && (reset($array_slice) == $pluginBasename))) { |
| 3330 |
return; |
| 3331 |
} |
| 3332 |
|
| 3333 |
$iwpKey = array_search($pluginBasename, $activePlugins); |
| 3334 |
$wptcKey = array_search($wptcPluginBasename, $activePlugins); |
| 3335 |
if ($iwpKey == false && $wptcKey == false) { |
| 3336 |
return; |
| 3337 |
}elseif ($iwpKey == false) { |
| 3338 |
return; |
| 3339 |
}elseif ($iwpKey == true && $wptcKey == false) { |
| 3340 |
unset($activePlugins[$iwpKey]); |
| 3341 |
array_unshift($activePlugins, $pluginBasename); |
| 3342 |
update_option('active_plugins', array_values($activePlugins)); |
| 3343 |
return; |
| 3344 |
} |
| 3345 |
unset($activePlugins[$iwpKey]); |
| 3346 |
unset($activePlugins[$wptcKey]); |
| 3347 |
array_unshift($activePlugins, $pluginBasename); |
| 3348 |
array_unshift($activePlugins, $wptcPluginBasename); |
| 3349 |
|
| 3350 |
update_option('active_plugins', array_values($activePlugins)); |
| 3351 |
} |
| 3352 |
|
| 3353 |
function iwp_mmb_get_user_by( $field, $value ) { |
| 3354 |
$userdata = WP_User::get_data_by( $field, $value ); |
| 3355 |
|
| 3356 |
if ( !$userdata ) |
| 3357 |
return false; |
| 3358 |
|
| 3359 |
$user = new WP_User; |
| 3360 |
$user->init( $userdata ); |
| 3361 |
|
| 3362 |
return $user; |
| 3363 |
} |
| 3364 |
|
| 3365 |
function iwp_plugin_compatibility_fix(){ |
| 3366 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 3367 |
$iwp_plugin_fix = new IWP_MMB_FixCompatibility(); |
| 3368 |
$iwp_plugin_fix->fixAllInOneSecurity(); |
| 3369 |
$iwp_plugin_fix->fixWpSimpleFirewall(); |
| 3370 |
$iwp_plugin_fix->fixDuoFactor(); |
| 3371 |
$iwp_plugin_fix->fixShieldUserManagementICWP(); |
| 3372 |
$iwp_plugin_fix->fixSidekickPlugin(); |
| 3373 |
$iwp_plugin_fix->fixSpamShield(); |
| 3374 |
$iwp_plugin_fix->fixWpSpamShieldBan(); |
| 3375 |
$iwp_plugin_fix->fixGlobals(); |
| 3376 |
|
| 3377 |
} |
| 3378 |
|
| 3379 |
function iwp_mu_plugin_loader(){ |
| 3380 |
if (defined('IWP_MU_PLUGIN_LOADER_DISABLED') && IWP_MU_PLUGIN_LOADER_DISABLED === true) { |
| 3381 |
return; |
| 3382 |
} |
| 3383 |
global $iwp_mmb_core; |
| 3384 |
$loaderName = 'mu-iwp-client.php'; |
| 3385 |
$mustUsePluginDir = rtrim(WPMU_PLUGIN_DIR, '/'); |
| 3386 |
$loaderPath = $mustUsePluginDir.'/'.$loaderName; |
| 3387 |
if(is_multisite()){ |
| 3388 |
$blog_id = get_current_blog_id(); |
| 3389 |
if($blog_id !='1'){ // $blog_id = 1 network parent id |
| 3390 |
return ; |
| 3391 |
} |
| 3392 |
} |
| 3393 |
if (file_exists($loaderPath)) { |
| 3394 |
$iwp_mu_plugin_db_version = get_option('iwp_mu_plugin_version'); |
| 3395 |
$iwp_new_mu_plugin_version = '1.0.1'; |
| 3396 |
if(empty($iwp_mu_plugin_db_version) || version_compare($iwp_mu_plugin_db_version, $iwp_new_mu_plugin_version,'<')){ |
| 3397 |
$data = build_mu_plugin_version($loaderPath,$iwp_new_mu_plugin_version,$iwp_mu_plugin_db_version); |
| 3398 |
if(!$data){ |
| 3399 |
iwp_mmb_response(array('error' => 'Unable to read InfiniteWP must use plugin', 'error_code' => 'iwp_mu_plugin_read_failed'), false); |
| 3400 |
return; |
| 3401 |
} |
| 3402 |
}else{ |
| 3403 |
return; //Both file and version number exisit |
| 3404 |
} |
| 3405 |
}else{ |
| 3406 |
$data = $iwp_mmb_core->buildLoaderContent('iwp-client/init.php'); |
| 3407 |
} |
| 3408 |
try { |
| 3409 |
$iwp_mmb_core->registerMustUse($loaderName,$data); |
| 3410 |
} catch (Exception $e) { |
| 3411 |
iwp_mmb_response(array('error' => 'Unable to write InfiniteWP Client loader:'.$e->getMessage(), 'error_code' => 'iwp_mu_plugin_loader_failed'), false); |
| 3412 |
} |
| 3413 |
} |
| 3414 |
|
| 3415 |
function build_mu_plugin_version($loaderPath,$iwp_new_mu_plugin_version,$iwp_mu_plugin_db_version){ |
| 3416 |
$res = false; |
| 3417 |
$loaderWritten = @file_get_contents($loaderPath); |
| 3418 |
if($loaderWritten){ |
| 3419 |
if (strpos($loaderWritten, 'Version') === false) { |
| 3420 |
$res = preg_replace('/Author: Revmakx/', "Author: Revmakx ".PHP_EOL."Version:" .$iwp_new_mu_plugin_version." ", $loaderWritten); |
| 3421 |
}elseif(!empty($iwp_mu_plugin_db_version) && version_compare($iwp_mu_plugin_db_version, '1.0.0','==')){ |
| 3422 |
if (strpos($loaderWritten, 'Version :1.0.0') !== false) { // |
| 3423 |
$res = str_replace('Version :1.0.0', 'Version:'.' '.$iwp_new_mu_plugin_version, $loaderWritten); |
| 3424 |
}elseif(strpos($loaderWritten, 'Version: 1.0.0') !== false){ |
| 3425 |
$res = str_replace('Version: 1.0.0', 'Version:'.' '.$iwp_new_mu_plugin_version, $loaderWritten); |
| 3426 |
}else{ |
| 3427 |
return ; |
| 3428 |
} |
| 3429 |
}else{ |
| 3430 |
// May be customer manually uploaded the file. |
| 3431 |
update_option('iwp_mu_plugin_version',$iwp_new_mu_plugin_version); |
| 3432 |
return ; |
| 3433 |
} |
| 3434 |
} |
| 3435 |
return $res; |
| 3436 |
} |
| 3437 |
|
| 3438 |
function set_iwp_dropbox_auth_setting($dropbox_details){ |
| 3439 |
if ( !empty($dropbox_details['dropbox_email']) ) { |
| 3440 |
$opts = array( |
| 3441 |
'appkey' => $dropbox_details['dropbox_app_key'], |
| 3442 |
'secret' => $dropbox_details['dropbox_app_secure_key'], |
| 3443 |
'tk_access_token' => $dropbox_details['dropbox_access_token'], |
| 3444 |
'folder' => $dropbox_details['dropbox_destination'], |
| 3445 |
'ownername' => '', |
| 3446 |
'email' => $dropbox_details['dropbox_email'], |
| 3447 |
'CSRF' => '', |
| 3448 |
'dropbox_site_folder' => $dropbox_details['dropbox_site_folder'] |
| 3449 |
); |
| 3450 |
IWP_MMB_Backup_Options::update_iwp_backup_option('IWP_dropbox', $opts); |
| 3451 |
} |
| 3452 |
} |
| 3453 |
|
| 3454 |
if(!function_exists('iwp_mmb_is_WPTC')) { |
| 3455 |
function iwp_mmb_is_WPTC() { |
| 3456 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 3457 |
if ( is_plugin_active( 'wp-time-capsule/wp-time-capsule.php' ) ) { |
| 3458 |
return true; |
| 3459 |
} else { |
| 3460 |
return false; |
| 3461 |
} |
| 3462 |
} |
| 3463 |
} |
| 3464 |
|
| 3465 |
function iwp_mmb_remove_log_files(){ |
| 3466 |
$restore_log = ABSPATH.'iwp-restore-log.txt'; |
| 3467 |
$clone_log = ABSPATH.'iwp-clone-log.txt'; |
| 3468 |
$is_restore_log_exists = file_exists($restore_log); |
| 3469 |
$is_clone_log_exists = file_exists($clone_log); |
| 3470 |
if ($is_restore_log_exists == false && $is_clone_log_exists == false) { |
| 3471 |
return false; |
| 3472 |
} |
| 3473 |
global $wp_filesystem; |
| 3474 |
if (!is_object($wp_filesystem)) { |
| 3475 |
WP_Filesystem(); |
| 3476 |
} |
| 3477 |
if (!is_object($wp_filesystem)) { |
| 3478 |
return false; |
| 3479 |
} |
| 3480 |
if ($is_restore_log_exists) { |
| 3481 |
$wp_filesystem->delete($restore_log); |
| 3482 |
} |
| 3483 |
if ($is_clone_log_exists) { |
| 3484 |
$wp_filesystem->delete($clone_log); |
| 3485 |
} |
| 3486 |
} |
| 3487 |
|
| 3488 |
iwp_mmb_set_plugin_priority(); |
| 3489 |
$iwp_mmb_core = new IWP_MMB_Core(); |
| 3490 |
$GLOBALS['iwp_mmb_activities_log'] = new IWP_MMB_Activities_log(); |
| 3491 |
$mmb_core = 1; |
| 3492 |
$GLOBALS['iwp_activities_log_post_type'] = 'iwp_log'; |
| 3493 |
|
| 3494 |
if(isset($_GET['auto_login'])){ |
| 3495 |
$GLOBALS['__itsec_core_is_rest_api_request'] = true; |
| 3496 |
$iwp_mmb_core->add_login_action(); |
| 3497 |
} |
| 3498 |
if (function_exists('register_activation_hook')) |
| 3499 |
register_activation_hook( __FILE__ , array( $iwp_mmb_core, 'install' )); |
| 3500 |
|
| 3501 |
if (function_exists('register_deactivation_hook')) |
| 3502 |
register_deactivation_hook(__FILE__, array( $iwp_mmb_core, 'uninstall' )); |
| 3503 |
if (function_exists('add_action')) |
| 3504 |
add_action('plugins_loaded', 'iwp_mmb_minimal_maintenance_plugin_fix'); |
| 3505 |
|
| 3506 |
if (function_exists('add_action')) |
| 3507 |
add_action('init', 'iwp_mmb_plugin_actions', 99999); |
| 3508 |
|
| 3509 |
if (function_exists('add_action')) |
| 3510 |
add_action('template_redirect', 'iwp_mmb_check_maintenance',99999); |
| 3511 |
|
| 3512 |
if (function_exists('add_action')) |
| 3513 |
add_action('template_redirect', 'iwp_mmb_check_redirects', 99999); |
| 3514 |
|
| 3515 |
if (function_exists('add_filter')) |
| 3516 |
add_filter('install_plugin_complete_actions','iwp_mmb_iframe_plugins_fix'); |
| 3517 |
|
| 3518 |
if( isset($_COOKIE[IWP_MMB_XFRAME_COOKIE]) ){ |
| 3519 |
remove_action( 'admin_init', 'send_frame_options_header'); |
| 3520 |
remove_action( 'login_init', 'send_frame_options_header'); |
| 3521 |
} |
| 3522 |
|
| 3523 |
if (function_exists('add_action')) |
| 3524 |
add_action('admin_init', 'iwp_mmb_remove_log_files', 10); |
| 3525 |
|
| 3526 |
//added for jQuery compatibility |
| 3527 |
if(!function_exists('iwp_mmb_register_ext_scripts')){ |
| 3528 |
function iwp_mmb_register_ext_scripts(){ |
| 3529 |
wp_register_script( 'iwp-clipboard', plugins_url( 'clipboard.min.js', __FILE__ ) ); |
| 3530 |
} |
| 3531 |
} |
| 3532 |
|
| 3533 |
add_action( 'admin_init', 'iwp_mmb_register_ext_scripts' ); |
| 3534 |
$iwp_mmb_core->get_new_backup_instance(); |
| 3535 |
iwp_mmb_parse_request(); |
| 3536 |
|
| 3537 |
?> |