inspect_request(); } /** * Inspect every incoming request. */ public function inspect_request() { $reason = $this->should_block_request(); if ( $reason ) { $this->block_request( $reason ); } } /** * Check whether the request matches a small set of suspicious patterns. * * @return string|false */ protected function should_block_request() { $uri = isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; if ( isset( $_GET['aabcore_my_nonce'] ) ) { check_admin_referer( 'aabcore_my_action', 'aabcore_my_nonce' ); return; } $get_data = isset( $_GET ) ? wp_unslash( $_GET ) : array(); $post_data = isset( $_POST ) ? wp_unslash( $_POST ) : array(); $request = strtolower( urldecode( $uri . ' ' . http_build_query( $get_data ) . ' ' . http_build_query( $post_data ) ) ); $rules = array( // SQL injection. '/union\s+select/i' => 'SQL Injection', '/sleep\s*\(/i' => 'SQL Injection', '/