security_nonces ) ) { $this->security_nonces = array(); } if ( ! function_exists( 'wp_create_nonce' ) ) { include_once ABSPATH . WPINC . '/pluggable.php'; } $this->security_nonces[ $action ] = wp_create_nonce( $action ); } public function get_security_nonces() { return $this->security_nonces; } public function add_action( $action, $callback ) { add_action( 'wp_ajax_' . $action, $callback ); $this->add_security_nonce( $action ); } public function secure_request( $action = '', $query_arg = 'security' ) { if ( ! MainWP_Helper::is_admin() ) { die( 0 ); } if ( '' == $action ) { return; } if ( ! $this->check_security( $action, $query_arg ) ) { die( json_encode( array( 'error' => __( 'Invalid request!', 'mainwp-child' ) ) ) ); } if ( isset( $_POST['dts'] ) ) { $ajaxPosts = get_option( 'mainwp_ajaxposts' ); if ( ! is_array( $ajaxPosts ) ) { $ajaxPosts = array(); } // If already processed, just quit! if ( isset( $ajaxPosts[ $action ] ) && ( $ajaxPosts[ $action ] == $_POST['dts'] ) ) { die( json_encode( array( 'error' => __( 'Double request!', 'mainwp-child' ) ) ) ); } $ajaxPosts[ $action ] = $_POST['dts']; MainWP_Helper::update_option( 'mainwp_ajaxposts', $ajaxPosts ); } } public function check_security( $action = - 1, $query_arg = 'security' ) { if ( - 1 == $action ) { return false; } $adminurl = strtolower( admin_url() ); $referer = strtolower( wp_get_referer() ); $result = isset( $_REQUEST[ $query_arg ] ) ? wp_verify_nonce( $_REQUEST[ $query_arg ], $action ) : false; if ( ! $result && ! ( - 1 == $action && 0 === strpos( $referer, $adminurl ) ) ) { return false; } return true; } public function init() { add_action( 'check_admin_referer', array( self::get_class_name(), 'permalink_changed' ) ); if ( get_option( 'mainwp_child_clone_permalink' ) || get_option( 'mainwp_child_restore_permalink' ) ) { add_action( 'admin_notices', array( self::get_class_name(), 'permalink_admin_notice' ) ); } } public static function print_scripts() { wp_enqueue_script( 'jquery-ui-tooltip' ); wp_enqueue_script( 'jquery-ui-autocomplete' ); wp_enqueue_script( 'jquery-ui-progressbar' ); wp_enqueue_script( 'jquery-ui-dialog' ); global $wp_scripts; $ui = $wp_scripts->query( 'jquery-ui-core' ); $version = $ui->ver; if ( MainWP_Helper::starts_with( $version, '1.10' ) ) { wp_enqueue_style( 'jquery-ui-style', plugins_url( '/css/1.10.4/jquery-ui.min.css', dirname( __FILE__ ) ), array(), '1.10', 'all' ); } else { wp_enqueue_style( 'jquery-ui-style', plugins_url( '/css/1.11.1/jquery-ui.min.css', dirname( __FILE__ ) ), array(), '1.11', 'all' ); } } public static function upload_mimes( $mime_types = array() ) { if ( ! isset( $mime_types['tar.bz2'] ) ) { $mime_types['tar.bz2'] = 'application/x-tar'; } return $mime_types; } public static function render() { $uploadError = false; $uploadFile = false; if ( isset( $_REQUEST['upload'] ) && wp_verify_nonce( $_POST['_nonce'], 'cloneRestore' ) ) { if ( isset( $_FILES['file'] ) ) { if ( ! function_exists( 'wp_handle_upload' ) ) { require_once ABSPATH . 'wp-admin/includes/file.php'; } $uploadedfile = $_FILES['file']; $upload_overrides = array( 'test_form' => false ); add_filter( 'upload_mimes', array( self::get_class_name(), 'upload_mimes' ) ); $movefile = wp_handle_upload( $uploadedfile, $upload_overrides ); if ( $movefile ) { $uploadFile = str_replace( ABSPATH, '', $movefile['file'] ); } else { $uploadError = __( 'File could not be uploaded.', 'mainwp-child' ); } } else { $uploadError = __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.', 'mainwp-child' ); } } $sitesToClone = get_option( 'mainwp_child_clone_sites' ); $uploadSizeInBytes = min( MainWP_Helper::return_bytes( ini_get( 'upload_max_filesize' ) ), MainWP_Helper::return_bytes( ini_get( 'post_max_size' ) ) ); $uploadSize = MainWP_Helper::human_filesize( $uploadSizeInBytes ); self::render_style(); if ( '0' === $sitesToClone ) { echo '
)
)
get_branding_title(); if ( '' != $branding_title ) { $branding_msg = 'If you have a FULL backup created by basic ' . esc_html( stripslashes( $branding_title ) ) . ' Backup system you may restore it by uploading here. Backups created by 3rd party plugins will not work.'; } else { $branding_msg = esc_html__( 'If you have a FULL backup created by basic MainWP Backup system you may restore it by uploading here. Backups created by 3rd party plugins will not work.', 'mainwp-child' ); } ?>