$checksum ) { if ( false !== strpos( $file, 'wp-content/' ) ) { unset( $checksumapibody['checksums'][ $file ] ); } } return $checksumapibody; } /** * Parses the results from the WordPress API call * * @uses file_exists() * @uses md5_file() * @uses ABSPATH * * @param array $checksums * * @return array */ static function parse_checksum_results( $checksums ) { $filepath = ABSPATH; $files = array(); // Parse the results. foreach ( $checksums['checksums'] as $file => $checksum ) { // Check the files. if ( file_exists( $filepath . $file ) && md5_file( $filepath . $file ) !== $checksum ) { $reason = esc_html__( 'Content changed', 'health-check' ) . ' ' . esc_html__( '(View Diff)', 'health-check' ) . ''; array_push( $files, array( $file, $reason ) ); } elseif ( ! file_exists( $filepath . $file ) ) { $reason = esc_html__( 'File not found', 'health-check' ); array_push( $files, array( $file, $reason ) ); } } return $files; } /** * Generates the response * * @uses wp_send_json_success() * @uses wp_die() * @uses ABSPATH * * @param null|array $files * * @return void */ static function create_the_response( $files ) { $filepath = ABSPATH; $output = ''; if ( empty( $files ) ) { $output .= '
'; $output .= esc_html__( 'All files passed the check. Everything seems to be ok!', 'health-check' ); $output .= '
'; $output .= __( 'It appears that some files may have been modified.', 'health-check' ); $output .= '
| '; $output .= esc_html__( 'Status', 'health-check' ); $output .= ' | '; $output .= esc_html__( 'File', 'health-check' ); $output .= ' | '; $output .= esc_html__( 'Reason', 'health-check' ); $output .= ' |
|---|---|---|
| '; $output .= esc_html__( 'Status', 'health-check' ); $output .= ' | '; $output .= esc_html__( 'File', 'health-check' ); $output .= ' | '; $output .= esc_html__( 'Reason', 'health-check' ); $output .= ' |
| '; $output .= ' | ' . $filepath . $tampered[0] . ' | '; $output .= '' . $tampered[1] . ' | '; $output .= '
| '; $output .= 'Original'; $output .= ' | '; $output .= 'Modified'; $output .= ' |
|---|