id = 'file-change'; $this->title = __( 'File Change Detection', 'better-wp-security' ); $this->description = __( 'Monitor the site for unexpected file changes.', 'better-wp-security' ); $this->type = 'recommended'; parent::__construct(); } public function enqueue_scripts_and_styles() { require_once( ABSPATH . 'wp-admin/includes/file.php' ); $vars = array( 'ABSPATH' => get_home_path(), 'nonce' => wp_create_nonce( 'itsec_do_file_check' ), ); if ( ! class_exists( 'ITSEC_File_Change_Admin' ) ) { require_once( dirname( __FILE__ ) . '/admin.php' ); } ITSEC_Lib::enqueue_util(); ITSEC_File_Change_Admin::enqueue_scanner(); wp_enqueue_script( 'itsec-file-change-settings-script', plugins_url( 'js/settings-page.js', __FILE__ ), array( 'jquery', 'itsec-file-change-scanner', 'itsec-util' ), $this->script_version, true ); wp_localize_script( 'itsec-file-change-settings-script', 'itsec_file_change_settings', $vars ); $vars = array( 'nonce' => wp_create_nonce( 'itsec_jquery_filetree' ), ); wp_enqueue_script( 'itsec-file-change-admin-filetree-script', plugins_url( 'js/filetree/jqueryFileTree.js', __FILE__ ), array( 'jquery' ), $this->script_version, true ); wp_localize_script( 'itsec-file-change-admin-filetree-script', 'itsec_jquery_filetree', $vars ); wp_enqueue_style( 'itsec-file-change-admin-filetree-style', plugins_url( 'js/filetree/jqueryFileTree.css', __FILE__ ), array(), $this->script_version ); wp_enqueue_style( 'itsec-file-change-admin-style', plugins_url( 'css/settings.css', __FILE__ ), array(), $this->script_version ); } public function handle_ajax_request( $data ) { if ( 'one-time-scan' === $data['method'] ) { require_once( dirname( __FILE__ ) . '/scanner.php' ); $results = ITSEC_File_Change_Scanner::schedule_start(); if ( is_wp_error( $results ) ) { ITSEC_Response::add_error( $results ); } else { ITSEC_Response::set_success( true ); } } elseif ( 'abort' === $data['method'] ) { require_once( dirname( __FILE__ ) . '/scanner.php' ); ITSEC_File_Change_Scanner::abort( true ); ITSEC_Response::set_success( true ); } else if ( 'get-filetree-data' === $data['method'] ) { ITSEC_Response::set_response( $this->get_filetree_data( $data ) ); } } protected function render_description( $form ) { ?>

get_option( 'file_list' ); if ( is_array( $file_list ) ) { $file_list = implode( "\n", $file_list ); } else { $file_list = ''; } $form->set_option( 'file_list', $file_list ); require_once( dirname( __FILE__ ) . '/scanner.php' ); if ( $is_running = ITSEC_File_Change_Scanner::is_running() ) { $status = ITSEC_File_Change_Scanner::get_status(); $button = array( 'value' => empty( $status['message'] ) ? __( 'Scan in Progress', 'better-wp-security' ) : $status['message'], 'disabled' => 'disabled', 'class' => 'button-secondary', ); } else { $button = array( 'value' => __( 'Scan Files Now', 'better-wp-security' ), 'class' => 'button-primary', ); } ?>

add_button( 'one_time_check', $button ); ?> add_button( 'abort', array( 'value' => _x( 'Cancel', 'Cancel File Change scan.', 'better-wp-security' ), 'class' => 'button' ) ); ?>

add_textarea( 'file_list', array( 'wrap' => 'off' ) ); ?>
add_textarea( 'types', array( 'wrap' => 'off', 'cols' => 20, 'rows' => 10 ) ); ?>
add_checkbox( 'notify_admin' ); ?>

"; //two loops keep directories sorted before files // All files and directories (alphabetical sorting) foreach ( $files as $file ) { if ( '.' === $file || '..' === $file ) { continue; } if ( ! file_exists( $directory . $file ) ) { continue; } if ( is_dir( $directory . $file ) ) { echo ''; } else { $ext = pathinfo( $file, PATHINFO_EXTENSION ); echo '
  • ' . htmlentities( $file ) . '
  • '; } } echo ""; } } return ob_get_clean(); } } new ITSEC_File_Change_Settings_Page();