id = 'file-permissions'; $this->title = __( 'File Permissions', 'better-wp-security' ); $this->description = __( 'Lists file and directory permissions of key areas of the site.', 'better-wp-security' ); $this->type = 'recommended'; $this->information_only = true; $this->can_save = false; parent::__construct(); } protected function render_description( $form ) {} protected function render_settings( $form ) { if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) { echo '
' . __( 'Click the button to load the current file permissions.', 'better-wp-security' ) . '
'; echo '' . $form->add_button( 'load_file_permissions', array( 'value' => __( 'Load File Permissions Details', 'better-wp-security' ), 'class' => 'button-primary itsec-reload-module' ) ) . '
'; return; } require_once( ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php' ); $wp_upload_dir = ITSEC_Core::get_wp_upload_dir(); $path_data = array( array( ABSPATH, 0755, ), array( ABSPATH . WPINC, 0755, ), array( ABSPATH . 'wp-admin', 0755, ), array( ABSPATH . 'wp-admin/js', 0755, ), array( WP_CONTENT_DIR, 0755, ), array( get_theme_root(), 0755, ), array( WP_PLUGIN_DIR, 0755 ), array( $wp_upload_dir['basedir'], 0755, ), array( ITSEC_Lib_Config_File::get_wp_config_file_path(), 0444, ), array( ITSEC_Lib_Config_File::get_server_config_file_path(), 0444, ), ); $rows = array(); foreach ( $path_data as $path ) { $row = array(); list( $path, $suggested_permissions ) = $path; $display_path = preg_replace( '/^' . preg_quote( ABSPATH, '/' ) . '/', '', $path ); $display_path = ltrim( $display_path, '/' ); if ( empty( $display_path ) ) { $display_path = '/'; } $row[] = $display_path; $row[] = sprintf( '%o', $suggested_permissions ); $permissions = fileperms( $path ) & 0777; $row[] = sprintf( '%o', $permissions ); if ( ! $permissions || $permissions != $suggested_permissions ) { $row[] = __( 'WARNING', 'better-wp-security' ); $row[] = 'add_button( 'reload_file_permissions', array( 'value' => __( 'Reload File Permissions Details', 'better-wp-security' ), 'class' => 'button-primary itsec-reload-module' ) ); ?>