2018-06-26 19:52:53 +02:00
< ? php
2019-02-19 23:52:21 +07:00
/*
*
* Credits
*
* Plugin - Name : WP Time Capsule
* Plugin URI : https :// wptimecapsule . com
* Author : Revmakx
* Author URI : http :// www . revmakx . com
*
* The code is used for the MainWP Time Capsule Extension
* Extension URL : https :// mainwp . com / extension / time - capsule /
*
*/
2018-09-27 19:52:32 +02:00
class MainWP_Child_Timecapsule {
2020-03-26 19:45:07 +00:00
public static $instance = null ;
2018-06-26 19:52:53 +02:00
public $is_plugin_installed = false ;
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
static function Instance () {
2020-03-26 14:05:04 +00:00
if ( null === self :: $instance ) {
self :: $instance = new MainWP_Child_Timecapsule ();
2018-06-26 19:52:53 +02:00
}
2020-03-26 14:05:04 +00:00
return self :: $instance ;
2018-06-26 19:52:53 +02:00
}
2018-09-27 19:52:32 +02:00
public function __construct () {
2020-03-26 14:11:33 +00:00
require_once ABSPATH . 'wp-admin/includes/plugin.php' ;
2018-06-26 19:52:53 +02:00
if ( is_plugin_active ( 'wp-time-capsule/wp-time-capsule.php' ) && defined ( 'WPTC_CLASSES_DIR' )) {
2018-09-27 19:52:32 +02:00
$this -> is_plugin_installed = true ;
}
2020-03-26 17:03:00 +00:00
if ( ! $this -> is_plugin_installed ) {
2018-06-26 19:52:53 +02:00
return ;
2020-03-26 14:11:33 +00:00
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
add_filter ( 'mainwp-site-sync-others-data' , array ( $this , 'syncOthersData' ), 10 , 2 );
}
2018-09-27 19:52:32 +02:00
public function init () {
2020-03-26 17:03:00 +00:00
if ( ! $this -> is_plugin_installed ) {
2018-09-27 19:52:32 +02:00
return ;
2020-03-26 14:11:33 +00:00
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:11:33 +00:00
if ( get_option ( 'mainwp_time_capsule_ext_enabled' ) !== 'Y' ) {
2018-09-27 19:52:32 +02:00
return ;
2020-03-26 14:11:33 +00:00
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
add_action ( 'mainwp_child_site_stats' , array ( $this , 'do_site_stats' ) );
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
if ( get_option ( 'mainwp_time_capsule_hide_plugin' ) === 'hide' ) {
add_filter ( 'all_plugins' , array ( $this , 'all_plugins' ) );
add_action ( 'admin_menu' , array ( $this , 'remove_menu' ) );
add_filter ( 'site_transient_update_plugins' , array ( & $this , 'remove_update_nag' ) );
2018-12-19 17:01:08 +07:00
add_filter ( 'mainwp_child_hide_update_notice' , array ( & $this , 'hide_update_notice' ) );
2018-06-26 19:52:53 +02:00
}
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
public function action () {
2020-03-26 17:03:00 +00:00
if ( ! $this -> is_plugin_installed ) {
2020-03-26 15:29:54 +00:00
MainWP_Helper :: write ( array ( 'error' => 'Please install WP Time Capsule plugin on child website' ) );
2018-09-27 19:52:32 +02:00
}
try {
2018-06-26 19:52:53 +02:00
$this -> require_files ();
} catch ( Exception $e ) {
$error = $e -> getMessage ();
2020-03-26 15:29:54 +00:00
MainWP_Helper :: write ( array ( 'error' => $error ) );
2018-06-26 19:52:53 +02:00
}
2018-09-27 19:52:32 +02:00
$information = array ();
2018-06-26 19:52:53 +02:00
2020-03-26 19:45:07 +00:00
$options_helper = new Wptc_Options_Helper ();
$options = WPTC_Factory :: get ( 'config' );
$is_user_logged_in = $options -> get_option ( 'is_user_logged_in' );
$privileges_wptc = $options_helper -> get_unserialized_privileges ();
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
if ( isset ( $_POST [ 'mwp_action' ] ) ) {
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
if ((
2018-09-27 19:52:32 +02:00
$_POST [ 'mwp_action' ] == 'save_settings' ||
$_POST [ 'mwp_action' ] == 'get_staging_details_wptc' ||
2018-06-26 19:52:53 +02:00
$_POST [ 'mwp_action' ] == 'progress_wptc'
2020-03-26 17:03:00 +00:00
) && ( ! $is_user_logged_in || ! $privileges_wptc )
2018-06-26 19:52:53 +02:00
) {
2020-03-26 15:29:54 +00:00
MainWP_Helper :: write ( array ( 'error' => 'You are not login to your WP Time Capsule account.' ) );
2018-06-26 19:52:53 +02:00
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
switch ( $_POST [ 'mwp_action' ] ) {
case 'set_showhide' :
$information = $this -> set_showhide ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'get_root_files' :
$information = $this -> get_root_files ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'get_tables' :
$information = $this -> get_tables ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'exclude_file_list' :
$information = $this -> exclude_file_list ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'exclude_table_list' :
$information = $this -> exclude_table_list ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'include_table_list' :
$information = $this -> include_table_list ();
break ;
case 'include_table_structure_only' :
$information = $this -> include_table_structure_only ();
break ;
case 'include_file_list' :
$information = $this -> include_file_list ();
break ;
case 'get_files_by_key' :
$information = $this -> get_files_by_key ();
break ;
case 'wptc_login' :
$information = $this -> process_wptc_login ();
break ;
case 'get_installed_plugins' :
$information = $this -> get_installed_plugins ();
break ;
case 'get_installed_themes' :
$information = $this -> get_installed_themes ();
break ;
case 'is_staging_need_request' :
$information = $this -> is_staging_need_request ();
break ;
case 'get_staging_details_wptc' :
$information = $this -> get_staging_details_wptc ();
break ;
case 'start_fresh_staging_wptc' :
$information = $this -> start_fresh_staging_wptc ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'get_staging_url_wptc' :
$information = $this -> get_staging_url_wptc ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'stop_staging_wptc' :
$information = $this -> stop_staging_wptc ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'continue_staging_wptc' :
$information = $this -> continue_staging_wptc ();
break ;
case 'delete_staging_wptc' :
$information = $this -> delete_staging_wptc ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'copy_staging_wptc' :
$information = $this -> copy_staging_wptc ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'get_staging_current_status_key' :
$information = $this -> get_staging_current_status_key ();
break ;
case 'wptc_sync_purchase' :
$information = $this -> wptc_sync_purchase ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'init_restore' :
$information = $this -> init_restore ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'save_settings' :
$information = $this -> save_settings_wptc ();
break ;
case 'analyze_inc_exc' :
$information = $this -> analyze_inc_exc ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'get_enabled_plugins' :
$information = $this -> get_enabled_plugins ();
break ;
case 'get_enabled_themes' :
$information = $this -> get_enabled_themes ();
break ;
case 'get_system_info' :
$information = $this -> get_system_info ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'update_vulns_settings' :
$information = $this -> update_vulns_settings ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'start_fresh_backup' :
$information = $this -> start_fresh_backup_tc_callback_wptc ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'save_manual_backup_name' :
$information = $this -> save_manual_backup_name_wptc ();
break ;
case 'progress_wptc' :
$information = $this -> progress_wptc ();
break ;
case 'stop_fresh_backup' :
$information = $this -> stop_fresh_backup_tc_callback_wptc ();
break ;
case 'wptc_cron_status' :
$information = $this -> wptc_cron_status ();
break ;
case 'get_this_backups_html' :
$information = $this -> get_this_backups_html ();
break ;
case 'start_restore_tc_wptc' :
$information = $this -> start_restore_tc_callback_wptc ();
break ;
case 'get_sibling_files' :
$information = $this -> get_sibling_files_callback_wptc ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'get_logs_rows' :
$information = $this -> get_logs_rows ();
break ;
case 'clear_logs' :
$information = $this -> clear_wptc_logs ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'send_issue_report' :
$information = $this -> send_issue_report ();
2018-09-27 19:52:32 +02:00
break ;
2018-06-26 19:52:53 +02:00
case 'lazy_load_activity_log' :
$information = $this -> lazy_load_activity_log_wptc ();
break ;
}
}
2018-09-27 19:52:32 +02:00
MainWP_Helper :: write ( $information );
}
2018-06-26 19:52:53 +02:00
public function require_files () {
2020-03-26 17:03:00 +00:00
if ( ! class_exists ( 'WPTC_Base_Factory' ) && defined ( 'WPTC_PLUGIN_DIR' ) ) {
2018-09-27 19:52:32 +02:00
if ( MainWP_Helper :: check_files_exists ( WPTC_PLUGIN_DIR . 'Base/Factory.php' ) ) {
2020-03-26 14:05:04 +00:00
include_once WPTC_PLUGIN_DIR . 'Base/Factory.php' ;
2018-06-26 19:52:53 +02:00
}
}
2018-09-27 19:52:32 +02:00
if ( ! class_exists ( 'Wptc_Options_Helper' ) && defined ( 'WPTC_PLUGIN_DIR' ) ) {
if ( MainWP_Helper :: check_files_exists ( WPTC_PLUGIN_DIR . 'Views/wptc-options-helper.php' ) ) {
2018-06-26 19:52:53 +02:00
include_once WPTC_PLUGIN_DIR . 'Views/wptc-options-helper.php' ;
}
}
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
function set_showhide () {
$hide = isset ( $_POST [ 'showhide' ] ) && ( 'hide' === $_POST [ 'showhide' ] ) ? 'hide' : '' ;
MainWP_Helper :: update_option ( 'mainwp_time_capsule_hide_plugin' , $hide , 'yes' );
$information [ 'result' ] = 'SUCCESS' ;
return $information ;
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
// ok
2018-09-27 19:52:32 +02:00
public function syncOthersData ( $information , $data = array () ) {
if ( isset ( $data [ 'syncWPTimeCapsule' ] ) && $data [ 'syncWPTimeCapsule' ] ) {
2018-06-26 19:52:53 +02:00
$information [ 'syncWPTimeCapsule' ] = $this -> get_sync_data ();
2020-03-26 14:11:33 +00:00
if ( get_option ( 'mainwp_time_capsule_ext_enabled' ) !== 'Y' ) {
2019-05-06 22:42:18 +07:00
MainWP_Helper :: update_option ( 'mainwp_time_capsule_ext_enabled' , 'Y' , 'yes' );
2020-03-26 14:11:33 +00:00
}
2018-09-27 19:52:32 +02:00
}
2018-06-26 19:52:53 +02:00
return $information ;
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
// ok
2018-09-27 19:52:32 +02:00
public function get_sync_data () {
try {
2018-06-26 19:52:53 +02:00
$this -> require_files ();
2020-03-26 15:29:54 +00:00
MainWP_Helper :: check_classes_exists ( array ( 'Wptc_Options_Helper' , 'WPTC_Base_Factory' , 'WPTC_Factory' ));
2018-09-27 19:52:32 +02:00
$config = WPTC_Factory :: get ( 'config' );
2018-06-26 19:52:53 +02:00
MainWP_Helper :: check_methods ( $config , 'get_option' );
2018-09-27 19:52:32 +02:00
$main_account_email_var = $config -> get_option ( 'main_account_email' );
2020-03-26 19:45:07 +00:00
$last_backup_time = $config -> get_option ( 'last_backup_time' );
$wptc_settings = WPTC_Base_Factory :: get ( 'Wptc_Settings' );
2018-09-27 19:52:32 +02:00
$options_helper = new Wptc_Options_Helper ();
2020-03-26 15:29:54 +00:00
MainWP_Helper :: check_methods ( $options_helper , array ( 'get_plan_interval_from_subs_info' , 'get_is_user_logged_in' ));
MainWP_Helper :: check_methods ( $wptc_settings , array ( 'get_connected_cloud_info' ));
2018-09-27 19:52:32 +02:00
2020-03-26 19:45:07 +00:00
$all_backups = $this -> getBackups ();
2018-09-27 19:52:32 +02:00
$backups_count = 0 ;
if ( is_array ( $all_backups )) {
$formatted_backups = array ();
foreach ( $all_backups as $key => $value ) {
2020-03-26 19:45:07 +00:00
$value_array = ( array ) $value ;
2020-03-26 15:29:54 +00:00
$formatted_backups [ $value_array [ 'backupID' ] ][] = $value_array ;
2018-09-27 19:52:32 +02:00
}
$backups_count = count ( $formatted_backups );
}
$return = array (
2020-03-26 14:11:33 +00:00
'main_account_email' => $main_account_email_var ,
2020-03-26 17:03:00 +00:00
'signed_in_repos' => $wptc_settings -> get_connected_cloud_info (),
2020-03-26 15:29:54 +00:00
'plan_name' => $options_helper -> get_plan_interval_from_subs_info (),
'plan_interval' => $options_helper -> get_plan_interval_from_subs_info (),
2020-03-26 17:03:00 +00:00
'lastbackup_time' => ! empty ( $last_backup_time ) ? $last_backup_time : 0 ,
2020-03-26 15:29:54 +00:00
'is_user_logged_in' => $options_helper -> get_is_user_logged_in (),
'backups_count' => $backups_count ,
2018-06-26 19:52:53 +02:00
);
return $return ;
} catch ( Exception $e ) {
// do not exit here
2018-09-27 19:52:32 +02:00
}
2018-06-26 19:52:53 +02:00
return false ;
}
2018-09-27 19:52:32 +02:00
protected function getBackups ( $last_time = false ) {
if ( empty ( $last_time )) {
$last_time = strtotime ( date ( 'Y-m-d' , strtotime ( date ( 'Y-m-01' ))));
}
global $wpdb ;
$all_backups = $wpdb -> get_results (
$wpdb -> prepare ( "
SELECT *
FROM { $wpdb -> base_prefix } wptc_processed_files
WHERE backupID > % s " , $last_time )
);
return $all_backups ;
}
public function get_tables () {
2020-03-26 19:45:07 +00:00
$category = $_POST [ 'category' ];
2018-06-26 19:52:53 +02:00
$exclude_class_obj = new Wptc_ExcludeOption ( $category );
2018-09-27 19:52:32 +02:00
$exclude_class_obj -> get_tables ();
die ();
2018-06-26 19:52:53 +02:00
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
public function exclude_file_list () {
2020-03-26 17:03:00 +00:00
if ( ! isset ( $_POST [ 'data' ])) {
2020-03-26 15:29:54 +00:00
wptc_die_with_json_encode ( array ( 'status' => 'no data found' ) );
2018-06-26 19:52:53 +02:00
}
2020-03-26 19:45:07 +00:00
$category = $_POST [ 'category' ];
2018-06-26 19:52:53 +02:00
$exclude_class_obj = new Wptc_ExcludeOption ( $category );
2018-09-27 19:52:32 +02:00
$exclude_class_obj -> exclude_file_list ( $_POST [ 'data' ]);
2018-06-26 19:52:53 +02:00
die ();
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
function progress_wptc () {
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$config = WPTC_Factory :: get ( 'config' );
global $wpdb ;
2020-03-26 17:03:00 +00:00
if ( ! $config -> get_option ( 'in_progress' )) {
2018-06-26 19:52:53 +02:00
spawn_cron ();
}
2018-09-27 19:52:32 +02:00
$processed_files = WPTC_Factory :: get ( 'processed-files' );
2020-03-26 19:45:07 +00:00
$return_array = array ();
$return_array [ 'stored_backups' ] = $processed_files -> get_stored_backups ();
$return_array [ 'backup_progress' ] = array ();
$return_array [ 'starting_first_backup' ] = $config -> get_option ( 'starting_first_backup' );
$return_array [ 'meta_data_backup_process' ] = $config -> get_option ( 'meta_data_backup_process' );
2018-06-26 19:52:53 +02:00
$return_array [ 'backup_before_update_progress' ] = $config -> get_option ( 'backup_before_update_progress' );
2020-03-26 19:45:07 +00:00
$return_array [ 'is_staging_running' ] = apply_filters ( 'is_any_staging_process_going_on' , '' );
$cron_status = $config -> get_option ( 'wptc_own_cron_status' );
2018-06-26 19:52:53 +02:00
2020-03-26 17:03:00 +00:00
if ( ! empty ( $cron_status )) {
2020-03-26 19:45:07 +00:00
$return_array [ 'wptc_own_cron_status' ] = unserialize ( $cron_status );
2018-06-26 19:52:53 +02:00
$return_array [ 'wptc_own_cron_status_notified' ] = ( int ) $config -> get_option ( 'wptc_own_cron_status_notified' );
}
$start_backups_failed_server = $config -> get_option ( 'start_backups_failed_server' );
2020-03-26 17:03:00 +00:00
if ( ! empty ( $start_backups_failed_server )) {
2018-06-26 19:52:53 +02:00
$return_array [ 'start_backups_failed_server' ] = unserialize ( $start_backups_failed_server );
$config -> set_option ( 'start_backups_failed_server' , false );
}
$processed_files -> get_current_backup_progress ( $return_array );
$return_array [ 'user_came_from_existing_ver' ] = ( int ) $config -> get_option ( 'user_came_from_existing_ver' );
2020-03-26 19:45:07 +00:00
$return_array [ 'show_user_php_error' ] = $config -> get_option ( 'show_user_php_error' );
$return_array [ 'bbu_setting_status' ] = apply_filters ( 'get_backup_before_update_setting_wptc' , '' );
$return_array [ 'bbu_note_view' ] = apply_filters ( 'get_bbu_note_view' , '' );
$return_array [ 'staging_status' ] = apply_filters ( 'staging_status_wptc' , '' );
2018-06-26 19:52:53 +02:00
2020-03-26 19:45:07 +00:00
$processed_files = WPTC_Factory :: get ( 'processed-files' );
2018-06-26 19:52:53 +02:00
$last_backup_time = $config -> get_option ( 'last_backup_time' );
2018-09-27 19:52:32 +02:00
2020-03-26 17:03:00 +00:00
if ( ! empty ( $last_backup_time )) {
2018-06-26 19:52:53 +02:00
$user_time = $config -> cnvt_UTC_to_usrTime ( $last_backup_time );
$processed_files -> modify_schedule_backup_time ( $user_time );
2020-03-26 19:45:07 +00:00
$formatted_date = date ( 'M d @ g:i a' , $user_time );
2018-06-26 19:52:53 +02:00
$return_array [ 'last_backup_time' ] = $formatted_date ;
} else {
2020-03-26 19:45:07 +00:00
$return_array [ 'last_backup_time' ] = 'No Backup Taken' ;
2018-06-26 19:52:53 +02:00
}
return array ( 'result' => $return_array );
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
function wptc_cron_status () {
2018-06-26 19:52:53 +02:00
$config = WPTC_Factory :: get ( 'config' );
wptc_own_cron_status ();
2020-03-26 19:45:07 +00:00
$status = array ();
2018-06-26 19:52:53 +02:00
$cron_status = $config -> get_option ( 'wptc_own_cron_status' );
2020-03-26 17:03:00 +00:00
if ( ! empty ( $cron_status )) {
2018-06-26 19:52:53 +02:00
$cron_status = unserialize ( $cron_status );
2018-09-27 19:52:32 +02:00
if ( $cron_status [ 'status' ] == 'success' ) {
2018-06-26 19:52:53 +02:00
$status [ 'status' ] = 'success' ;
2018-09-27 19:52:32 +02:00
} else {
2020-03-26 19:45:07 +00:00
$status [ 'status' ] = 'failed' ;
2018-06-26 19:52:53 +02:00
$status [ 'status_code' ] = $cron_status [ 'statusCode' ];
2020-03-26 19:45:07 +00:00
$status [ 'err_msg' ] = $cron_status [ 'body' ];
$status [ 'cron_url' ] = $cron_status [ 'cron_url' ];
$status [ 'ips' ] = $cron_status [ 'ips' ];
2018-09-27 19:52:32 +02:00
}
2020-03-26 15:29:54 +00:00
return array ( 'result' => $status );
2018-06-26 19:52:53 +02:00
}
return false ;
}
2018-09-27 19:52:32 +02:00
function get_this_backups_html () {
2020-03-26 19:45:07 +00:00
$this_backup_ids = $_POST [ 'this_backup_ids' ];
$specific_dir = $_POST [ 'specific_dir' ];
$type = $_POST [ 'type' ];
2018-06-26 19:52:53 +02:00
$treeRecursiveCount = $_POST [ 'treeRecursiveCount' ];
2020-03-26 19:45:07 +00:00
$processed_files = WPTC_Factory :: get ( 'processed-files' );
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$result = $processed_files -> get_this_backups_html ( $this_backup_ids , $specific_dir , $type , $treeRecursiveCount );
return array ( 'result' => $result );
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
function start_restore_tc_callback_wptc () {
if ( apply_filters ( 'is_restore_to_staging_wptc' , '' )) {
$request = apply_filters ( 'get_restore_to_staging_request_wptc' , '' );
} else {
$request = $_POST [ 'data' ];
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:11:33 +00:00
include_once WPTC_CLASSES_DIR . 'class-prepare-restore-bridge.php' ;
2018-06-26 19:52:53 +02:00
new WPTC_Prepare_Restore_Bridge ( $request );
}
2018-09-27 19:52:32 +02:00
function get_sibling_files_callback_wptc () {
2018-06-26 19:52:53 +02:00
//note that we are getting the ajax function data via $_POST.
2020-03-26 19:45:07 +00:00
$file_name = $_POST [ 'data' ][ 'file_name' ];
$file_name = wp_normalize_path ( $file_name );
$backup_id = $_POST [ 'data' ][ 'backup_id' ];
2018-06-26 19:52:53 +02:00
$recursive_count = $_POST [ 'data' ][ 'recursive_count' ];
// //getting the backups
2018-09-27 19:52:32 +02:00
$processed_files = WPTC_Factory :: get ( 'processed-files' );
2018-06-26 19:52:53 +02:00
echo $processed_files -> get_this_backups_html ( $backup_id , $file_name , $type = 'sibling' , ( int ) $recursive_count );
die ();
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
function send_issue_report () {
WPTC_Base_Factory :: get ( 'Wptc_App_Functions' ) -> send_report ();
die ();
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
function get_logs_rows () {
2020-03-26 19:45:07 +00:00
$result = $this -> prepare_items ();
2018-06-26 19:52:53 +02:00
$result [ 'display_rows' ] = base64_encode ( serialize ( $this -> get_display_rows ( $result [ 'items' ])));
return $result ;
}
2018-09-27 19:52:32 +02:00
function prepare_items () {
global $wpdb ;
2018-06-26 19:52:53 +02:00
if ( isset ( $_POST [ 'type' ])) {
$type = $_POST [ 'type' ];
switch ( $type ) {
case 'backups' :
2020-03-26 14:05:04 +00:00
$query = 'SELECT * FROM ' . $wpdb -> base_prefix . " wptc_activity_log WHERE type LIKE '%backup%' AND show_user = 1 GROUP BY action_id " ;
break ;
2018-06-26 19:52:53 +02:00
case 'restores' :
2020-03-26 14:05:04 +00:00
$query = 'SELECT * FROM ' . $wpdb -> base_prefix . " wptc_activity_log WHERE type LIKE 'restore%' GROUP BY action_id " ;
break ;
2018-06-26 19:52:53 +02:00
case 'staging' :
2020-03-26 14:05:04 +00:00
$query = 'SELECT * FROM ' . $wpdb -> base_prefix . " wptc_activity_log WHERE type LIKE 'staging%' GROUP BY action_id " ;
break ;
2018-06-26 19:52:53 +02:00
case 'backup_and_update' :
2020-03-26 14:05:04 +00:00
$query = 'SELECT * FROM ' . $wpdb -> base_prefix . " wptc_activity_log WHERE type LIKE 'backup_and_update%' GROUP BY action_id " ;
break ;
2018-06-26 19:52:53 +02:00
case 'auto_update' :
2020-03-26 14:05:04 +00:00
$query = 'SELECT * FROM ' . $wpdb -> base_prefix . " wptc_activity_log WHERE type LIKE 'auto_update%' GROUP BY action_id " ;
break ;
2018-06-26 19:52:53 +02:00
case 'others' :
2020-03-26 14:05:04 +00:00
$query = 'SELECT * FROM ' . $wpdb -> base_prefix . " wptc_activity_log WHERE type NOT LIKE 'restore%' AND type NOT LIKE 'backup%' AND show_user = 1 " ;
break ;
2018-06-26 19:52:53 +02:00
default :
2020-03-26 14:05:04 +00:00
$query = 'SELECT * FROM ' . $wpdb -> base_prefix . 'wptc_activity_log GROUP BY action_id UNION SELECT * FROM ' . $wpdb -> base_prefix . " wptc_activity_log WHERE action_id='' AND show_user = 1 " ;
break ;
2018-06-26 19:52:53 +02:00
}
} else {
2020-03-26 14:05:04 +00:00
$query = 'SELECT * FROM ' . $wpdb -> base_prefix . 'wptc_activity_log WHERE show_user = 1 GROUP BY action_id ' ;
2018-06-26 19:52:53 +02:00
}
/* -- Preparing your query -- */
2020-03-26 14:05:04 +00:00
/*
-- Ordering parameters -- */
2018-06-26 19:52:53 +02:00
//Parameters that are going to be used to order the result
2020-03-26 17:03:00 +00:00
$orderby = ! empty ( $_POST [ 'orderby' ]) ? mysql_real_escape_string ( $_POST [ 'orderby' ]) : 'id' ;
2020-03-26 19:45:07 +00:00
$order = ! empty ( $_POST [ 'order' ]) ? mysql_real_escape_string ( $_POST [ 'order' ]) : 'DESC' ;
2020-03-26 17:03:00 +00:00
if ( ! empty ( $orderby ) & ! empty ( $order )) {
$query .= ' ORDER BY ' . $orderby . ' ' . $order ;}
2018-06-26 19:52:53 +02:00
2020-03-26 14:05:04 +00:00
/*
-- Pagination parameters -- */
2018-06-26 19:52:53 +02:00
//Number of elements in your table?
$totalitems = $wpdb -> query ( $query ); //return the total number of affected rows
//How many to display per page?
$perpage = 20 ;
//Which page is this?
2020-03-26 17:03:00 +00:00
$paged = ! empty ( $_POST [ 'paged' ]) ? $_POST [ 'paged' ] : '' ;
if ( empty ( $paged ) || ! is_numeric ( $paged ) || $paged <= 0 ) {
$paged = 1 ;} //Page Number
2018-06-26 19:52:53 +02:00
//How many pages do we have in total?
$totalpages = ceil ( $totalitems / $perpage ); //Total number of pages
//adjust the query to take pagination into account
2020-03-26 17:03:00 +00:00
if ( ! empty ( $paged ) && ! empty ( $perpage )) {
2020-03-26 15:29:54 +00:00
$offset = ( $paged - 1 ) * $perpage ;
2018-06-26 19:52:53 +02:00
$query .= ' LIMIT ' . ( int ) $offset . ',' . ( int ) $perpage ;
2018-09-27 19:52:32 +02:00
}
2020-03-26 15:29:54 +00:00
return array (
'items' => $wpdb -> get_results ( $query ),
'totalitems' => $totalitems ,
'perpage' => $perpage ,
2020-03-26 14:11:33 +00:00
);
2018-06-26 19:52:53 +02:00
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
function lazy_load_activity_log_wptc () {
2018-09-27 19:52:32 +02:00
2020-03-26 17:03:00 +00:00
if ( ! isset ( $_POST [ 'data' ])) {
2018-06-26 19:52:53 +02:00
return false ;
}
$data = $_POST [ 'data' ];
2020-03-26 17:03:00 +00:00
if ( ! isset ( $data [ 'action_id' ]) || ! isset ( $data [ 'limit' ])) {
2018-06-26 19:52:53 +02:00
return false ;
}
global $wpdb ;
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$action_id = $data [ 'action_id' ];
$from_limit = $data [ 'limit' ];
$detailed = '' ;
$load_more = false ;
$current_limit = WPTC_Factory :: get ( 'config' ) -> get_option ( 'activity_log_lazy_load_limit' );
$to_limit = $from_limit + $current_limit ;
2020-03-26 14:05:04 +00:00
$sql = 'SELECT * FROM ' . $wpdb -> base_prefix . 'wptc_activity_log WHERE action_id=' . $action_id . ' AND show_user = 1 ORDER BY id DESC LIMIT ' . $from_limit . ' , ' . $current_limit ;
2018-06-26 19:52:53 +02:00
$sub_records = $wpdb -> get_results ( $sql );
$row_count = count ( $sub_records );
if ( $row_count == $current_limit ) {
$load_more = true ;
}
$detailed = $this -> get_activity_log ( $sub_records );
if ( isset ( $load_more ) && $load_more ) {
2020-03-26 14:05:04 +00:00
$detailed .= '<tr><td></td><td><a style="cursor:pointer; position:relative" class="wptc_activity_log_load_more" action_id="' . esc_attr ( $action_id ) . '" limit="' . esc_attr ( $to_limit ) . '">Load more</a></td><td></td></tr>' ;
2018-06-26 19:52:53 +02:00
}
2020-03-26 15:29:54 +00:00
return array ( 'result' => $detailed );
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
//die($detailed);
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
function get_display_rows ( $records ) {
2018-06-26 19:52:53 +02:00
global $wpdb ;
//Get the records registered in the prepare_items method
2020-03-26 17:03:00 +00:00
if ( ! is_array ( $records )) {
2018-06-26 19:52:53 +02:00
return '' ;
2020-03-26 14:11:33 +00:00
}
2018-09-27 19:52:32 +02:00
2020-03-26 19:45:07 +00:00
$i = 0 ;
2018-06-26 19:52:53 +02:00
$limit = WPTC_Factory :: get ( 'config' ) -> get_option ( 'activity_log_lazy_load_limit' );
//Get the columns registered in the get_columns and get_sortable_columns methods
// $columns = $this->get_columns();
$timezone = WPTC_Factory :: get ( 'config' ) -> get_option ( 'wptc_timezone' );
if ( count ( $records ) > 0 ) {
foreach ( $records as $key => $rec ) {
$html = '' ;
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$more_logs = false ;
$load_more = false ;
if ( $rec -> action_id != '' ) {
2020-03-26 19:45:07 +00:00
$sql = 'SELECT * FROM ' . $wpdb -> base_prefix . 'wptc_activity_log WHERE action_id=' . $rec -> action_id . ' AND show_user = 1 ORDER BY id DESC LIMIT 0 , ' . $limit ;
2018-06-26 19:52:53 +02:00
$sub_records = $wpdb -> get_results ( $sql );
2020-03-26 19:45:07 +00:00
$row_count = count ( $sub_records );
2018-06-26 19:52:53 +02:00
if ( $row_count == $limit ) {
$load_more = true ;
}
if ( $row_count > 0 ) {
$more_logs = true ;
2020-03-26 19:45:07 +00:00
$detailed = '<table>' ;
2018-06-26 19:52:53 +02:00
$detailed .= $this -> get_activity_log ( $sub_records );
if ( isset ( $load_more ) && $load_more ) {
2020-03-26 14:05:04 +00:00
$detailed .= '<tr><td></td><td><a style="cursor:pointer; position:relative" class="mainwp_wptc_activity_log_load_more" action_id="' . $rec -> action_id . '" limit="' . $limit . '">Load more</a></td><td></td></tr>' ;
2018-06-26 19:52:53 +02:00
}
$detailed .= '</table>' ;
}
}
//Open the line
2020-03-26 19:45:07 +00:00
$html .= '<tr class="act-tr">' ;
$Ldata = unserialize ( $rec -> log_data );
2018-06-26 19:52:53 +02:00
$user_time = WPTC_Factory :: get ( 'config' ) -> cnvt_UTC_to_usrTime ( $Ldata [ 'log_time' ]);
WPTC_Factory :: get ( 'processed-files' ) -> modify_schedule_backup_time ( $user_time );
// $user_tz = new DateTime('@' . $Ldata['log_time'], new DateTimeZone(date_default_timezone_get()));
// $user_tz->setTimeZone(new DateTimeZone($timezone));
// $user_tz_now = $user_tz->format("M d, Y @ g:i:s a");
2020-03-26 14:05:04 +00:00
$user_tz_now = date ( 'M d, Y @ g:i:s a' , $user_time );
2020-03-26 19:45:07 +00:00
$msg = '' ;
2020-03-26 17:03:00 +00:00
if ( ! ( strpos ( $rec -> type , 'backup' ) === false )) {
2018-06-26 19:52:53 +02:00
//Backup process
$msg = 'Backup Process' ;
2020-03-26 17:03:00 +00:00
} elseif ( ! ( strpos ( $rec -> type , 'restore' ) === false )) {
2018-06-26 19:52:53 +02:00
//Restore Process
$msg = 'Restore Process' ;
2020-03-26 17:03:00 +00:00
} elseif ( ! ( strpos ( $rec -> type , 'staging' ) === false )) {
2018-06-26 19:52:53 +02:00
//Restore Process
$msg = 'Staging Process' ;
} else {
if ( $row_count < 2 ) {
$more_logs = false ;
}
$msg = $Ldata [ 'msg' ];
}
$html .= '<td class="wptc-act-td">' . $user_tz_now . '</td><td class="wptc-act-td">' . $msg ;
if ( $more_logs ) {
$html .= "     <a class='wptc-show-more' action_id=' " . round ( $rec -> action_id ) . " '>View details</a></td> " ;
} else {
2020-03-26 14:05:04 +00:00
$html .= '</td>' ;
2018-06-26 19:52:53 +02:00
}
$html .= '<td class="wptc-act-td"><a class="report_issue_wptc" id="' . $rec -> id . '" href="#">Send report to plugin developer</a></td>' ;
if ( $more_logs ) {
2020-03-26 14:05:04 +00:00
$html .= " </tr><tr id=' " . round ( $rec -> action_id ) . " ' class='wptc-more-logs'><td colspan=3> " . $detailed . '</td>' ;
2018-06-26 19:52:53 +02:00
} else {
2020-03-26 14:05:04 +00:00
$html .= '</td>' ;
2018-06-26 19:52:53 +02:00
}
//Close the line
$html .= '</tr>' ;
2018-09-27 19:52:32 +02:00
2020-03-26 15:29:54 +00:00
$display_rows [ $key ] = $html ;
2018-06-26 19:52:53 +02:00
}
}
return $display_rows ;
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
function get_activity_log ( $sub_records ) {
2018-06-26 19:52:53 +02:00
if ( count ( $sub_records ) < 1 ) {
return false ;
}
$detailed = '' ;
$timezone = WPTC_Factory :: get ( 'config' ) -> get_option ( 'wptc_timezone' );
foreach ( $sub_records as $srec ) {
$Moredata = unserialize ( $srec -> log_data );
$user_tmz = new DateTime ( '@' . $Moredata [ 'log_time' ], new DateTimeZone ( date_default_timezone_get ()));
$user_tmz -> setTimeZone ( new DateTimeZone ( $timezone ));
2020-03-26 14:05:04 +00:00
$user_tmz_now = $user_tmz -> format ( 'M d @ g:i:s a' );
2020-03-26 19:45:07 +00:00
$detailed .= '<tr><td>' . $user_tmz_now . '</td><td>' . $Moredata [ 'msg' ] . '</td><td></td></tr>' ;
2018-06-26 19:52:53 +02:00
}
return $detailed ;
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
function clear_wptc_logs () {
global $wpdb ;
2020-03-26 14:05:04 +00:00
if ( $wpdb -> query ( 'TRUNCATE TABLE `' . $wpdb -> base_prefix . 'wptc_activity_log`' )) {
2018-06-26 19:52:53 +02:00
$result = 'yes' ;
} else {
$result = 'no' ;
}
2020-03-26 15:29:54 +00:00
return array ( 'result' => $result );
2018-06-26 19:52:53 +02:00
}
2018-09-27 19:52:32 +02:00
function stop_fresh_backup_tc_callback_wptc () {
2018-06-26 19:52:53 +02:00
//for backup during update
$deactivated_plugin = null ;
2020-03-26 19:45:07 +00:00
$backup = new WPTC_BackupController ();
2018-09-27 19:52:32 +02:00
$backup -> stop ( $deactivated_plugin );
2020-03-26 15:29:54 +00:00
return array ( 'result' => 'ok' );
2018-06-26 19:52:53 +02:00
}
2018-09-27 19:52:32 +02:00
function get_root_files () {
2020-03-26 19:45:07 +00:00
$category = $_POST [ 'category' ];
2018-06-26 19:52:53 +02:00
$exclude_class_obj = new Wptc_ExcludeOption ( $category );
2018-09-27 19:52:32 +02:00
$exclude_class_obj -> get_root_files ();
die ();
2018-06-26 19:52:53 +02:00
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
public function exclude_table_list () {
2020-03-26 17:03:00 +00:00
if ( ! isset ( $_POST [ 'data' ])) {
2020-03-26 15:29:54 +00:00
wptc_die_with_json_encode ( array ( 'status' => 'no data found' ) );
2018-09-27 19:52:32 +02:00
}
2020-03-26 19:45:07 +00:00
$category = $_POST [ 'data' ][ 'category' ];
2018-06-26 19:52:53 +02:00
$exclude_class_obj = new Wptc_ExcludeOption ( $category );
2018-09-27 19:52:32 +02:00
$exclude_class_obj -> exclude_table_list ( $_POST [ 'data' ]);
2018-06-26 19:52:53 +02:00
die ();
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
function do_site_stats () {
if ( has_action ( 'mainwp_child_reports_log' )) {
do_action ( 'mainwp_child_reports_log' , 'wptimecapsule' );
} else {
$this -> do_reports_log ( 'wptimecapsule' );
}
}
2018-09-27 19:52:32 +02:00
// ok
2020-03-26 14:05:04 +00:00
public function do_reports_log ( $ext = '' ) {
2018-09-27 19:52:32 +02:00
2020-03-26 17:03:00 +00:00
if ( $ext !== 'wptimecapsule' ) {
return ;
2020-03-26 14:11:33 +00:00
}
2018-09-27 19:52:32 +02:00
2020-03-26 17:03:00 +00:00
if ( ! $this -> is_plugin_installed ) {
2018-06-26 19:52:53 +02:00
return ;
2020-03-26 14:11:33 +00:00
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
try {
2020-03-26 15:29:54 +00:00
MainWP_Helper :: check_classes_exists ( array ( 'WPTC_Factory' ));
2018-09-27 19:52:32 +02:00
$config = WPTC_Factory :: get ( 'config' );
2018-06-26 19:52:53 +02:00
MainWP_Helper :: check_methods ( $config , 'get_option' );
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$backup_time = $config -> get_option ( 'last_backup_time' );
2018-09-27 19:52:32 +02:00
2020-03-26 17:03:00 +00:00
if ( ! empty ( $backup_time )) {
2018-06-26 19:52:53 +02:00
MainWP_Helper :: update_lasttime_backup ( 'wptimecapsule' , $backup_time ); // to support backup before update feature
}
2018-09-27 19:52:32 +02:00
2020-03-26 19:45:07 +00:00
$last_time = time () - 24 * 7 * 2 * 60 * 60 ; // 2 weeks ago
2019-05-06 22:42:18 +07:00
$lasttime_logged = MainWP_Helper :: get_lasttime_backup ( 'wptimecapsule' );
2020-03-26 14:11:33 +00:00
if ( empty ( $lasttime_logged )) {
2019-05-06 22:42:18 +07:00
$last_time = time () - 24 * 7 * 8 * 60 * 60 ; // 8 weeks ago
2020-03-26 14:11:33 +00:00
}
2019-05-06 22:42:18 +07:00
2018-09-27 19:52:32 +02:00
$all_last_backups = $this -> getBackups ( $last_time );
if ( is_array ( $all_last_backups )) {
$formatted_backups = array ();
foreach ( $all_last_backups as $key => $value ) {
2020-03-26 19:45:07 +00:00
$value_array = ( array ) $value ;
2020-03-26 15:29:54 +00:00
$formatted_backups [ $value_array [ 'backupID' ] ][] = $value_array ;
2018-09-27 19:52:32 +02:00
}
2020-03-26 19:45:07 +00:00
$message = 'WP Time Capsule backup finished' ;
2018-09-27 19:52:32 +02:00
$backup_type = 'WP Time Capsule backup' ;
if ( count ( $formatted_backups ) > 0 ) {
2020-03-26 17:03:00 +00:00
foreach ( $formatted_backups as $key => $value ) {
2018-09-27 19:52:32 +02:00
$backup_time = $key ;
2019-12-09 22:02:19 +07:00
do_action ( 'mainwp_reports_wptimecapsule_backup' , $message , $backup_type , $backup_time );
2018-09-27 19:52:32 +02:00
}
}
}
2020-03-26 17:03:00 +00:00
} catch ( Exception $e ) {
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
}
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
public function include_table_list () {
2020-03-26 17:03:00 +00:00
if ( ! isset ( $_POST [ 'data' ])) {
2020-03-26 15:29:54 +00:00
wptc_die_with_json_encode ( array ( 'status' => 'no data found' ) );
2018-09-27 19:52:32 +02:00
}
2020-03-26 19:45:07 +00:00
$category = $_POST [ 'data' ][ 'category' ];
2018-06-26 19:52:53 +02:00
$exclude_class_obj = new Wptc_ExcludeOption ( $category );
2018-09-27 19:52:32 +02:00
$exclude_class_obj -> include_table_list ( $_POST [ 'data' ]);
die ();
2018-06-26 19:52:53 +02:00
}
2020-03-26 14:05:04 +00:00
public function include_table_structure_only () {
2018-09-27 19:52:32 +02:00
2020-03-26 17:03:00 +00:00
if ( ! isset ( $_POST [ 'data' ])) {
2020-03-26 15:29:54 +00:00
wptc_die_with_json_encode ( array ( 'status' => 'no data found' ) );
2018-06-26 19:52:53 +02:00
}
2018-09-27 19:52:32 +02:00
2020-03-26 19:45:07 +00:00
$category = $_POST [ 'data' ][ 'category' ];
2018-06-26 19:52:53 +02:00
$exclude_class_obj = new Wptc_ExcludeOption ( $category );
2018-09-27 19:52:32 +02:00
$exclude_class_obj -> include_table_structure_only ( $_POST [ 'data' ]);
2018-06-26 19:52:53 +02:00
die ();
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
public function include_file_list () {
2018-09-27 19:52:32 +02:00
2020-03-26 17:03:00 +00:00
if ( ! isset ( $_POST [ 'data' ])) {
2020-03-26 15:29:54 +00:00
wptc_die_with_json_encode ( array ( 'status' => 'no data found' ) );
2018-06-26 19:52:53 +02:00
}
2020-03-26 19:45:07 +00:00
$category = $_POST [ 'category' ];
2018-06-26 19:52:53 +02:00
$exclude_class_obj = new Wptc_ExcludeOption ( $category );
2018-09-27 19:52:32 +02:00
$exclude_class_obj -> include_file_list ( $_POST [ 'data' ]);
2018-06-26 19:52:53 +02:00
die ();
}
2018-09-27 19:52:32 +02:00
public function get_files_by_key () {
2020-03-26 19:45:07 +00:00
$key = $_POST [ 'key' ];
$category = $_POST [ 'category' ];
2018-06-26 19:52:53 +02:00
$exclude_class_obj = new Wptc_ExcludeOption ( $category );
2018-09-27 19:52:32 +02:00
$exclude_class_obj -> get_files_by_key ( $key );
2018-06-26 19:52:53 +02:00
die ();
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
private function process_wptc_login () {
2018-09-27 19:52:32 +02:00
$options_helper = new Wptc_Options_Helper ();
2020-03-26 17:03:00 +00:00
if ( $options_helper -> get_is_user_logged_in ()) {
2018-06-26 19:52:53 +02:00
return array (
2020-03-26 15:29:54 +00:00
'result' => 'is_user_logged_in' ,
2020-03-26 14:05:04 +00:00
'sync_data' => $this -> get_sync_data (),
2018-06-26 19:52:53 +02:00
);
2018-09-27 19:52:32 +02:00
}
2018-06-26 19:52:53 +02:00
$email = $_POST [ 'acc_email' ];
2020-03-26 19:45:07 +00:00
$pwd = $_POST [ 'acc_pwd' ];
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
if ( empty ( $email ) || empty ( $pwd )) {
2020-03-26 15:29:54 +00:00
return array ( 'error' => 'Username and password cannot be empty' );
2018-06-26 19:52:53 +02:00
}
2018-09-27 19:52:32 +02:00
2020-03-26 19:45:07 +00:00
$config = WPTC_Base_Factory :: get ( 'Wptc_InitialSetup_Config' );
2018-06-26 19:52:53 +02:00
$options = WPTC_Factory :: get ( 'config' );
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$config -> set_option ( 'wptc_main_acc_email_temp' , base64_encode ( $email ));
$config -> set_option ( 'wptc_main_acc_pwd_temp' , base64_encode ( md5 ( trim ( wp_unslash ( $pwd ) ))));
$config -> set_option ( 'wptc_token' , false );
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$options -> request_service (
array (
'email' => $email ,
'pwd' => trim ( wp_unslash ( $pwd )),
'return_response' => false ,
2020-03-26 14:05:04 +00:00
'sub_action' => false ,
2018-06-26 19:52:53 +02:00
'login_request' => true ,
'reset_login_if_failed' => true ,
)
);
2018-09-27 19:52:32 +02:00
2020-03-26 19:45:07 +00:00
$is_user_logged_in = $options -> get_option ( 'is_user_logged_in' );
2018-06-26 19:52:53 +02:00
2020-03-26 17:03:00 +00:00
if ( ! $is_user_logged_in ) {
2020-03-26 15:29:54 +00:00
return array ( 'error' => 'Login failed.' );
2018-06-26 19:52:53 +02:00
}
2020-03-26 15:29:54 +00:00
return array (
'result' => 'ok' ,
'sync_data' => $this -> get_sync_data (),
);
2018-06-26 19:52:53 +02:00
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
function get_installed_plugins () {
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$backup_before_auto_update_settings = WPTC_Pro_Factory :: get ( 'Wptc_Backup_Before_Auto_Update_Settings' );
2020-03-26 19:45:07 +00:00
$plugins = $backup_before_auto_update_settings -> get_installed_plugins ();
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
if ( $plugins ) {
2020-03-26 17:03:00 +00:00
return array ( 'results' => $plugins );
2018-06-26 19:52:53 +02:00
}
2020-03-26 15:29:54 +00:00
return array ( 'results' => array () );
2018-06-26 19:52:53 +02:00
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
function get_installed_themes () {
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$backup_before_auto_update_settings = WPTC_Pro_Factory :: get ( 'Wptc_Backup_Before_Auto_Update_Settings' );
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$plugins = $backup_before_auto_update_settings -> get_installed_themes ();
if ( $plugins ) {
2020-03-26 17:03:00 +00:00
return array ( 'results' => $plugins );
2018-06-26 19:52:53 +02:00
}
2020-03-26 15:29:54 +00:00
return array ( 'results' => array () );
2018-06-26 19:52:53 +02:00
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
function is_staging_need_request () {
2018-06-26 19:52:53 +02:00
$staging = WPTC_Pro_Factory :: get ( 'Wptc_Staging' );
$staging -> is_staging_need_request ();
die ();
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
function get_staging_details_wptc () {
2020-03-26 19:45:07 +00:00
$staging = WPTC_Pro_Factory :: get ( 'Wptc_Staging' );
$details = $staging -> get_staging_details ();
2018-06-26 19:52:53 +02:00
$details [ 'is_running' ] = $staging -> is_any_staging_process_going_on ();
2018-09-27 19:52:32 +02:00
wptc_die_with_json_encode ( $details , 1 );
}
2020-03-26 14:05:04 +00:00
function start_fresh_staging_wptc () {
2018-06-26 19:52:53 +02:00
$staging = WPTC_Pro_Factory :: get ( 'Wptc_Staging' );
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
if ( empty ( $_POST [ 'path' ])) {
2020-03-26 15:29:54 +00:00
wptc_die_with_json_encode ( array (
'status' => 'error' ,
'msg' => 'path is missing' ,
) );
2018-06-26 19:52:53 +02:00
}
$staging -> choose_action ( $_POST [ 'path' ], $reqeust_type = 'fresh' );
die ();
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
function get_staging_url_wptc () {
2018-06-26 19:52:53 +02:00
$staging = WPTC_Pro_Factory :: get ( 'Wptc_Staging' );
2018-09-27 19:52:32 +02:00
$staging -> get_staging_url_wptc ();
2018-06-26 19:52:53 +02:00
die ();
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
function stop_staging_wptc () {
2018-09-27 19:52:32 +02:00
$staging = WPTC_Pro_Factory :: get ( 'Wptc_Staging' );
$staging -> stop_staging_wptc ();
2018-06-26 19:52:53 +02:00
die ();
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
function continue_staging_wptc () {
2018-06-26 19:52:53 +02:00
$staging = WPTC_Pro_Factory :: get ( 'Wptc_Staging' );
2018-09-27 19:52:32 +02:00
$staging -> choose_action ();
2018-06-26 19:52:53 +02:00
die ();
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
function delete_staging_wptc () {
2018-06-26 19:52:53 +02:00
$staging = WPTC_Pro_Factory :: get ( 'Wptc_Staging' );
$staging -> delete_staging_wptc ();
die ();
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
function copy_staging_wptc () {
2018-06-26 19:52:53 +02:00
$staging = WPTC_Pro_Factory :: get ( 'Wptc_Staging' );
$staging -> choose_action ( false , $reqeust_type = 'copy' );
die ();
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
function get_staging_current_status_key () {
2018-06-26 19:52:53 +02:00
$staging = WPTC_Pro_Factory :: get ( 'Wptc_Staging' );
$staging -> get_staging_current_status_key ();
die ();
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
function wptc_sync_purchase () {
2018-06-26 19:52:53 +02:00
$config = WPTC_Factory :: get ( 'config' );
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$config -> request_service (
array (
'email' => false ,
'pwd' => false ,
'return_response' => false ,
2020-03-26 14:05:04 +00:00
'sub_action' => 'sync_all_settings_to_node' ,
2018-06-26 19:52:53 +02:00
'login_request' => true ,
)
);
die ();
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
public function init_restore () {
if ( empty ( $_POST )) {
2020-03-26 15:29:54 +00:00
return ( array ( 'error' => 'Backup id is empty !' ) );
2018-06-26 19:52:53 +02:00
}
$restore_to_staging = WPTC_Base_Factory :: get ( 'Wptc_Restore_To_Staging' );
$restore_to_staging -> init_restore ( $_POST );
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
die ();
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
function save_settings_wptc () {
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$options_helper = new Wptc_Options_Helper ();
2018-09-27 19:52:32 +02:00
2020-03-26 17:03:00 +00:00
if ( ! $options_helper -> get_is_user_logged_in () ) {
2018-09-27 19:52:32 +02:00
return array (
2018-06-26 19:52:53 +02:00
'sync_data' => $this -> get_sync_data (),
2020-03-26 15:29:54 +00:00
'error' => 'Login to your WP Time Capsule account first' ,
2018-06-26 19:52:53 +02:00
);
2018-09-27 19:52:32 +02:00
}
2018-06-26 19:52:53 +02:00
$data = unserialize ( base64_decode ( $_POST [ 'data' ]));
2018-09-27 19:52:32 +02:00
2020-03-26 19:45:07 +00:00
$tabName = $_POST [ 'tabname' ];
2020-03-26 17:03:00 +00:00
$is_general = $_POST [ 'is_general' ];
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$saved = false ;
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$config = WPTC_Factory :: get ( 'config' );
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
if ( $tabName == 'backup' ) { // save_backup_settings_wptc()
$config -> set_option ( 'user_excluded_extenstions' , $data [ 'user_excluded_extenstions' ]);
2018-09-27 19:52:32 +02:00
$config -> set_option ( 'user_excluded_files_more_than_size_settings' , $data [ 'user_excluded_files_more_than_size_settings' ]);
2020-03-26 17:03:00 +00:00
if ( ! empty ( $data [ 'backup_slot' ])) {
2018-09-27 19:52:32 +02:00
$config -> set_option ( 'old_backup_slot' , $config -> get_option ( 'backup_slot' ));
2018-06-26 19:52:53 +02:00
$config -> set_option ( 'backup_slot' , $data [ 'backup_slot' ]);
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$config -> set_option ( 'backup_db_query_limit' , $data [ 'backup_db_query_limit' ]);
$config -> set_option ( 'database_encrypt_settings' , $data [ 'database_encrypt_settings' ]);
$config -> set_option ( 'wptc_timezone' , $data [ 'wptc_timezone' ]);
$config -> set_option ( 'schedule_time_str' , $data [ 'schedule_time_str' ]);
2018-09-27 19:52:32 +02:00
2020-03-26 17:03:00 +00:00
if ( ! empty ( $data [ 'schedule_time_str' ]) && ! empty ( $data [ 'wptc_timezone' ]) ) {
2020-03-26 14:11:33 +00:00
if ( function_exists ( 'wptc_modify_schedule_backup' )) {
2018-06-26 19:52:53 +02:00
wptc_modify_schedule_backup ();
2020-03-26 14:11:33 +00:00
}
2018-09-27 19:52:32 +02:00
}
2018-06-26 19:52:53 +02:00
$notice = apply_filters ( 'check_requirements_auto_backup_wptc' , '' );
2020-03-26 17:03:00 +00:00
if ( ! empty ( $data [ 'revision_limit' ]) && ! $notice ) {
2018-06-26 19:52:53 +02:00
$notice = apply_filters ( 'save_settings_revision_limit_wptc' , $data [ 'revision_limit' ]);
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$saved = true ;
2018-09-27 19:52:32 +02:00
2020-03-26 14:11:33 +00:00
} elseif ( $tabName == 'backup_auto' ) { // update_auto_update_settings()
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$config -> set_option ( 'backup_before_update_setting' , $data [ 'backup_before_update_setting' ]);
$current = $config -> get_option ( 'wptc_auto_update_settings' );
$current = unserialize ( $current );
2020-03-26 19:45:07 +00:00
$new = unserialize ( $data [ 'wptc_auto_update_settings' ]);
2018-09-27 19:52:32 +02:00
2020-03-26 19:45:07 +00:00
$current [ 'update_settings' ][ 'status' ] = $new [ 'update_settings' ][ 'status' ];
$current [ 'update_settings' ][ 'schedule' ][ 'enabled' ] = $new [ 'update_settings' ][ 'schedule' ][ 'enabled' ];
$current [ 'update_settings' ][ 'schedule' ][ 'time' ] = $new [ 'update_settings' ][ 'schedule' ][ 'time' ];
$current [ 'update_settings' ][ 'core' ][ 'major' ][ 'status' ] = $new [ 'update_settings' ][ 'core' ][ 'major' ][ 'status' ];
$current [ 'update_settings' ][ 'core' ][ 'minor' ][ 'status' ] = $new [ 'update_settings' ][ 'core' ][ 'minor' ][ 'status' ];
$current [ 'update_settings' ][ 'themes' ][ 'status' ] = $new [ 'update_settings' ][ 'themes' ][ 'status' ];
$current [ 'update_settings' ][ 'plugins' ][ 'status' ] = $new [ 'update_settings' ][ 'plugins' ][ 'status' ];
2018-09-27 19:52:32 +02:00
2020-03-26 17:03:00 +00:00
if ( ! $is_general ) {
2020-03-26 14:11:33 +00:00
if ( isset ( $new [ 'update_settings' ][ 'plugins' ][ 'included' ])) {
2020-03-26 19:45:07 +00:00
$current [ 'update_settings' ][ 'plugins' ][ 'included' ] = $new [ 'update_settings' ][ 'plugins' ][ 'included' ];
2020-03-26 14:11:33 +00:00
} else {
2018-06-26 19:52:53 +02:00
$current [ 'update_settings' ][ 'plugins' ][ 'included' ] = array ();
2020-03-26 14:11:33 +00:00
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:11:33 +00:00
if ( isset ( $new [ 'update_settings' ][ 'themes' ][ 'included' ])) {
2020-03-26 19:45:07 +00:00
$current [ 'update_settings' ][ 'themes' ][ 'included' ] = $new [ 'update_settings' ][ 'themes' ][ 'included' ];
2020-03-26 14:11:33 +00:00
} else {
2020-03-26 19:45:07 +00:00
$current [ 'update_settings' ][ 'themes' ][ 'included' ] = array ();
2020-03-26 14:11:33 +00:00
}
2018-09-27 19:52:32 +02:00
}
2018-06-26 19:52:53 +02:00
$config -> set_option ( 'wptc_auto_update_settings' , serialize ( $current ));
$saved = true ;
2018-09-27 19:52:32 +02:00
2020-03-26 14:11:33 +00:00
} elseif ( $tabName == 'vulns_update' ) {
2018-06-26 19:52:53 +02:00
$current = $config -> get_option ( 'vulns_settings' );
$current = unserialize ( $current );
2020-03-26 19:45:07 +00:00
$new = unserialize ( $data [ 'vulns_settings' ]);
2018-09-27 19:52:32 +02:00
2020-03-26 19:45:07 +00:00
$current [ 'status' ] = $new [ 'status' ];
$current [ 'core' ][ 'status' ] = $new [ 'core' ][ 'status' ];
$current [ 'themes' ][ 'status' ] = $new [ 'themes' ][ 'status' ];
2018-06-26 19:52:53 +02:00
$current [ 'plugins' ][ 'status' ] = $new [ 'plugins' ][ 'status' ];
2018-09-27 19:52:32 +02:00
2020-03-26 17:03:00 +00:00
if ( ! $is_general ) {
$vulns_plugins_included = ! empty ( $new [ 'plugins' ][ 'vulns_plugins_included' ]) ? $new [ 'plugins' ][ 'vulns_plugins_included' ] : array ();
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$plugin_include_array = array ();
2020-03-26 17:03:00 +00:00
if ( ! empty ( $vulns_plugins_included )) {
2018-06-26 19:52:53 +02:00
$plugin_include_array = explode ( ',' , $vulns_plugins_included );
2020-03-26 17:03:00 +00:00
$plugin_include_array = ! empty ( $plugin_include_array ) ? $plugin_include_array : array ();
2018-06-26 19:52:53 +02:00
}
wptc_log ( $plugin_include_array , '--------$plugin_include_array--------' );
$included_plugins = $this -> filter_plugins ( $plugin_include_array );
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
wptc_log ( $included_plugins , '--------$included_plugins--------' );
$current [ 'plugins' ][ 'excluded' ] = serialize ( $included_plugins );
2020-03-26 17:03:00 +00:00
$vulns_themes_included = ! empty ( $new [ 'themes' ][ 'vulns_themes_included' ]) ? $new [ 'themes' ][ 'vulns_themes_included' ] : array ();
2018-09-27 19:52:32 +02:00
2020-03-26 19:45:07 +00:00
$themes_include_array = array ();
2018-06-26 19:52:53 +02:00
2020-03-26 17:03:00 +00:00
if ( ! empty ( $vulns_themes_included )) {
2018-06-26 19:52:53 +02:00
$themes_include_array = explode ( ',' , $vulns_themes_included );
}
2020-03-26 19:45:07 +00:00
$included_themes = $this -> filter_themes ( $themes_include_array );
2018-06-26 19:52:53 +02:00
$current [ 'themes' ][ 'excluded' ] = serialize ( $included_themes );
}
$config -> set_option ( 'vulns_settings' , serialize ( $current ));
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$saved = true ;
2018-09-27 19:52:32 +02:00
2020-03-26 14:11:33 +00:00
} elseif ( $tabName == 'staging_opts' ) {
2019-08-26 23:29:16 +07:00
$config -> set_option ( 'user_excluded_extenstions_staging' , $data [ 'user_excluded_extenstions_staging' ]);
2018-06-26 19:52:53 +02:00
$config -> set_option ( 'internal_staging_db_rows_copy_limit' , $data [ 'internal_staging_db_rows_copy_limit' ]);
$config -> set_option ( 'internal_staging_file_copy_limit' , $data [ 'internal_staging_file_copy_limit' ]);
$config -> set_option ( 'internal_staging_deep_link_limit' , $data [ 'internal_staging_deep_link_limit' ]);
$config -> set_option ( 'internal_staging_enable_admin_login' , $data [ 'internal_staging_enable_admin_login' ]);
2018-09-27 19:52:32 +02:00
$config -> set_option ( 'staging_is_reset_permalink' , $data [ 'staging_is_reset_permalink' ]);
2020-03-26 17:03:00 +00:00
if ( ! $is_general ) {
2018-09-27 19:52:32 +02:00
$config -> set_option ( 'staging_login_custom_link' , $data [ 'staging_login_custom_link' ]);
}
2018-06-26 19:52:53 +02:00
$saved = true ;
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
if ( ! $saved ) {
2020-03-26 15:29:54 +00:00
return array ( 'error' => 'Error: Not saved settings' );
2018-06-26 19:52:53 +02:00
}
2018-09-27 19:52:32 +02:00
2020-03-26 15:29:54 +00:00
return array ( 'result' => 'ok' );
2018-06-26 19:52:53 +02:00
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
private function filter_plugins ( $included_plugins ) {
2020-03-26 19:45:07 +00:00
$app_functions = WPTC_Base_Factory :: get ( 'Wptc_App_Functions' );
$plugins_data = $app_functions -> get_all_plugins_data ( $specific = true , $attr = 'slug' );
2018-06-26 19:52:53 +02:00
$not_included_plugin = array_diff ( $plugins_data , $included_plugins );
wptc_log ( $plugins_data , '--------$plugins_data--------' );
wptc_log ( $not_included_plugin , '--------$not_included_plugin--------' );
return $not_included_plugin ;
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
private function filter_themes ( $included_themes ) {
2020-03-26 19:45:07 +00:00
$app_functions = WPTC_Base_Factory :: get ( 'Wptc_App_Functions' );
$themes_data = $app_functions -> get_all_themes_data ( $specific = true , $attr = 'slug' );
2018-06-26 19:52:53 +02:00
$not_included_theme = array_diff ( $themes_data , $included_themes );
wptc_log ( $themes_data , '--------$themes_data--------' );
wptc_log ( $not_included_theme , '--------$not_included_theme--------' );
return $not_included_theme ;
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
public function analyze_inc_exc () {
2018-09-27 19:52:32 +02:00
$exclude_opts_obj = WPTC_Base_Factory :: get ( 'Wptc_ExcludeOption' );
2018-06-26 19:52:53 +02:00
$exclude_opts_obj = $exclude_opts_obj -> analyze_inc_exc (); // raw response
die ();
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
public function get_enabled_plugins () {
2018-06-26 19:52:53 +02:00
$vulns_obj = WPTC_Base_Factory :: get ( 'Wptc_Vulns' );
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
$plugins = $vulns_obj -> get_enabled_plugins ();
$plugins = WPTC_Base_Factory :: get ( 'Wptc_App_Functions' ) -> fancytree_format ( $plugins , 'plugins' );
2018-09-27 19:52:32 +02:00
2020-03-26 15:29:54 +00:00
return array ( 'results' => $plugins );
2018-06-26 19:52:53 +02:00
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
public function get_enabled_themes () {
2018-09-27 19:52:32 +02:00
$vulns_obj = WPTC_Base_Factory :: get ( 'Wptc_Vulns' );
2020-03-26 19:45:07 +00:00
$themes = $vulns_obj -> get_enabled_themes ();
$themes = WPTC_Base_Factory :: get ( 'Wptc_App_Functions' ) -> fancytree_format ( $themes , 'themes' );
2020-03-26 15:29:54 +00:00
return array ( 'results' => $themes );
2018-06-26 19:52:53 +02:00
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
public function get_system_info () {
2018-06-26 19:52:53 +02:00
global $wpdb ;
2018-09-27 19:52:32 +02:00
$wptc_settings = WPTC_Base_Factory :: get ( 'Wptc_Settings' );
2018-06-26 19:52:53 +02:00
ob_start ();
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
echo '<table class="wp-list-table widefat fixed" cellspacing="0" >' ;
echo '<thead><tr><th width="35%">' . __ ( 'Setting' , 'wp-time-capsule' ) . '</th><th>' . __ ( 'Value' , 'wp-time-capsule' ) . '</th></tr></thead>' ;
echo '<tr title=">=3.9.14"><td>' . __ ( 'WordPress version' , 'wp-time-capsule' ) . '</td><td>' . esc_html ( $wptc_settings -> get_plugin_data ( 'wp_version' ) ) . '</td></tr>' ;
echo '<tr title=""><td>' . __ ( 'WP Time Capsule version' , 'wp-time-capsule' ) . '</td><td>' . esc_html ( $wptc_settings -> get_plugin_data ( 'Version' ) ) . '</td></tr>' ;
$bit = '' ;
if ( PHP_INT_SIZE === 4 ) {
$bit = ' (32bit)' ;
}
if ( PHP_INT_SIZE === 8 ) {
$bit = ' (64bit)' ;
}
echo '<tr title=">=5.3.1"><td>' . __ ( 'PHP version' , 'wp-time-capsule' ) . '</td><td>' . esc_html ( PHP_VERSION . ' ' . $bit ) . '</td></tr>' ;
2020-03-26 14:05:04 +00:00
echo '<tr title=">=5.0.15"><td>' . __ ( 'MySQL version' , 'wp-time-capsule' ) . '</td><td>' . esc_html ( $wpdb -> get_var ( 'SELECT VERSION() AS version' ) ) . '</td></tr>' ;
2018-06-26 19:52:53 +02:00
if ( function_exists ( 'curl_version' ) ) {
$curlversion = curl_version ();
2020-03-26 15:29:54 +00:00
echo '<tr title=""><td>' . __ ( 'cURL version' , 'wp-time-capsule' ) . '</td><td>' . esc_html ( $curlversion [ 'version' ] ) . '</td></tr>' ;
echo '<tr title=""><td>' . __ ( 'cURL SSL version' , 'wp-time-capsule' ) . '</td><td>' . esc_html ( $curlversion [ 'ssl_version' ] ) . '</td></tr>' ;
2020-03-26 17:03:00 +00:00
} else {
2018-06-26 19:52:53 +02:00
echo '<tr title=""><td>' . __ ( 'cURL version' , 'wp-time-capsule' ) . '</td><td>' . __ ( 'unavailable' , 'wp-time-capsule' ) . '</td></tr>' ;
}
echo '</td></tr>' ;
2020-03-26 15:29:54 +00:00
echo '<tr title=""><td>' . __ ( 'Server' , 'wp-time-capsule' ) . '</td><td>' . esc_html ( $_SERVER [ 'SERVER_SOFTWARE' ] ) . '</td></tr>' ;
2018-06-26 19:52:53 +02:00
echo '<tr title=""><td>' . __ ( 'Operating System' , 'wp-time-capsule' ) . '</td><td>' . esc_html ( PHP_OS ) . '</td></tr>' ;
echo '<tr title=""><td>' . __ ( 'PHP SAPI' , 'wp-time-capsule' ) . '</td><td>' . esc_html ( PHP_SAPI ) . '</td></tr>' ;
$php_user = __ ( 'Function Disabled' , 'wp-time-capsule' );
if ( function_exists ( 'get_current_user' ) ) {
$php_user = get_current_user ();
}
2020-03-26 14:05:04 +00:00
echo '<tr title=""><td>' . __ ( 'Current PHP user' , 'wp-time-capsule' ) . '</td><td>' . esc_html ( $php_user ) . '</td></tr>' ;
2018-06-26 19:52:53 +02:00
echo '<tr title=">=30"><td>' . __ ( 'Maximum execution time' , 'wp-time-capsule' ) . '</td><td>' . esc_html ( ini_get ( 'max_execution_time' ) ) . ' ' . __ ( 'seconds' , 'wp-time-capsule' ) . '</td></tr>' ;
2020-03-26 14:11:33 +00:00
if ( defined ( 'FS_CHMOD_DIR' ) ) {
2018-06-26 19:52:53 +02:00
echo '<tr title="FS_CHMOD_DIR"><td>' . __ ( 'CHMOD Dir' , 'wp-time-capsule' ) . '</td><td>' . esc_html ( FS_CHMOD_DIR ) . '</td></tr>' ;
2020-03-26 14:11:33 +00:00
} else {
2018-06-26 19:52:53 +02:00
echo '<tr title="FS_CHMOD_DIR"><td>' . __ ( 'CHMOD Dir' , 'wp-time-capsule' ) . '</td><td>0755</td></tr>' ;
2020-03-26 14:11:33 +00:00
}
2018-06-26 19:52:53 +02:00
2020-03-26 14:05:04 +00:00
$now = localtime ( time (), true );
2020-03-26 15:29:54 +00:00
echo '<tr title=""><td>' . __ ( 'Server Time' , 'wp-time-capsule' ) . '</td><td>' . esc_html ( $now [ 'tm_hour' ] . ':' . $now [ 'tm_min' ] ) . '</td></tr>' ;
2018-06-26 19:52:53 +02:00
echo '<tr title=""><td>' . __ ( 'Blog Time' , 'wp-time-capsule' ) . '</td><td>' . date ( 'H:i' , current_time ( 'timestamp' ) ) . '</td></tr>' ;
echo '<tr title="WPLANG"><td>' . __ ( 'Blog language' , 'wp-time-capsule' ) . '</td><td>' . get_bloginfo ( 'language' ) . '</td></tr>' ;
echo '<tr title="utf8"><td>' . __ ( 'MySQL Client encoding' , 'wp-time-capsule' ) . '</td><td>' ;
echo defined ( 'DB_CHARSET' ) ? DB_CHARSET : '' ;
echo '</td></tr>' ;
echo '<tr title="URF-8"><td>' . __ ( 'Blog charset' , 'wp-time-capsule' ) . '</td><td>' . get_bloginfo ( 'charset' ) . '</td></tr>' ;
echo '<tr title=">=128M"><td>' . __ ( 'PHP Memory limit' , 'wp-time-capsule' ) . '</td><td>' . esc_html ( ini_get ( 'memory_limit' ) ) . '</td></tr>' ;
echo '<tr title="WP_MEMORY_LIMIT"><td>' . __ ( 'WP memory limit' , 'wp-time-capsule' ) . '</td><td>' . esc_html ( WP_MEMORY_LIMIT ) . '</td></tr>' ;
echo '<tr title="WP_MAX_MEMORY_LIMIT"><td>' . __ ( 'WP maximum memory limit' , 'wp-time-capsule' ) . '</td><td>' . esc_html ( WP_MAX_MEMORY_LIMIT ) . '</td></tr>' ;
2020-03-26 14:05:04 +00:00
echo '<tr title=""><td>' . __ ( 'Memory in use' , 'wp-time-capsule' ) . '</td><td>' . size_format ( @ memory_get_usage ( true ), 2 ) . '</td></tr>' ;
2018-06-26 19:52:53 +02:00
//disabled PHP functions
$disabled = esc_html ( ini_get ( 'disable_functions' ) );
if ( ! empty ( $disabled ) ) {
$disabledarry = explode ( ',' , $disabled );
echo '<tr title=""><td>' . __ ( 'Disabled PHP Functions:' , 'wp-time-capsule' ) . '</td><td>' ;
echo implode ( ', ' , $disabledarry );
echo '</td></tr>' ;
}
//Loaded PHP Extensions
echo '<tr title=""><td>' . __ ( 'Loaded PHP Extensions:' , 'wp-time-capsule' ) . '</td><td>' ;
$extensions = get_loaded_extensions ();
sort ( $extensions );
2020-03-26 14:05:04 +00:00
echo esc_html ( implode ( ', ' , $extensions ) );
2018-06-26 19:52:53 +02:00
echo '</td></tr>' ;
echo '</table>' ;
$html = ob_get_clean ();
2020-03-26 15:29:54 +00:00
return array ( 'result' => $html );
2018-06-26 19:52:53 +02:00
}
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
public function update_vulns_settings () {
2018-06-26 19:52:53 +02:00
$vulns_obj = WPTC_Base_Factory :: get ( 'Wptc_Vulns' );
2018-09-27 19:52:32 +02:00
2020-03-26 14:05:04 +00:00
$data = isset ( $_POST [ 'data' ]) ? $_POST [ 'data' ] : array ();
2018-06-26 19:52:53 +02:00
$vulns_obj -> update_vulns_settings ( $data );
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
return array ( 'success' => 1 );
}
2018-09-27 19:52:32 +02:00
function start_fresh_backup_tc_callback_wptc () {
2018-06-26 19:52:53 +02:00
start_fresh_backup_tc_callback_wptc ( $type = '' , $args = null , $test_connection = true , $ajax_check = false );
2020-03-26 15:29:54 +00:00
return array ( 'result' => 'success' );
2018-06-26 19:52:53 +02:00
}
public function save_manual_backup_name_wptc () {
2020-03-26 19:45:07 +00:00
$backup_name = $_POST [ 'backup_name' ];
2018-06-26 19:52:53 +02:00
$processed_files = WPTC_Factory :: get ( 'processed-files' );
$processed_files -> save_manual_backup_name_wptc ( $backup_name );
die ();
}
2018-09-27 19:52:32 +02:00
2018-06-26 19:52:53 +02:00
public function all_plugins ( $plugins ) {
foreach ( $plugins as $key => $value ) {
$plugin_slug = basename ( $key , '.php' );
if ( 'wp-time-capsule' === $plugin_slug ) {
unset ( $plugins [ $key ] );
}
}
return $plugins ;
}
public function remove_menu () {
remove_menu_page ( 'wp-time-capsule-monitor' );
$pos = stripos ( $_SERVER [ 'REQUEST_URI' ], 'admin.php?page=wp-time-capsule-monitor' );
if ( false !== $pos ) {
wp_redirect ( get_option ( 'siteurl' ) . '/wp-admin/index.php' );
exit ();
}
}
2018-09-27 19:52:32 +02:00
2018-12-19 17:01:08 +07:00
function hide_update_notice ( $slugs ) {
$slugs [] = 'wp-time-capsule/wp-time-capsule.php' ;
return $slugs ;
}
2018-06-26 19:52:53 +02:00
function remove_update_nag ( $value ) {
if ( isset ( $_POST [ 'mainwpsignature' ] ) ) {
return $value ;
}
2020-03-26 17:03:00 +00:00
if ( ! MainWP_Helper :: is_screen_with_update ()) {
2018-12-19 17:01:08 +07:00
return $value ;
}
2018-06-26 19:52:53 +02:00
if ( isset ( $value -> response [ 'wp-time-capsule/wp-time-capsule.php' ] ) ) {
unset ( $value -> response [ 'wp-time-capsule/wp-time-capsule.php' ] );
}
return $value ;
}
}