HEX
Server: nginx/1.18.0
System: Linux vps-9dcdb12e 5.15.0-176-generic #186-Ubuntu SMP Fri Mar 13 11:01:42 UTC 2026 x86_64
User: ubuntu (1000)
PHP: 8.1.2-1ubuntu2.24
Disabled: exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source
Upload Files
File: /var/www/lascalaswidnik.pl/wp-content/plugins/integromat-connector/class/class-guard.php
<?php
namespace Integromat;

defined( 'ABSPATH' ) || die( 'No direct access allowed' );

class Guard {
	/**
	 * Is currently requested endpoint protected?
	 *
	 * @return bool
	 */
	public static function is_protected() {
		// Only guard if IWC-API-KEY header is present
		if ( ! isset( $_SERVER['HTTP_IWC_API_KEY'] ) || empty( $_SERVER['HTTP_IWC_API_KEY'] ) ) {
			return false; // No protection if no IWC-API-KEY header
		}
		
		// Validate required server variables
		if ( ! isset( $_SERVER['REQUEST_URI'] ) || ! isset( $_SERVER['REQUEST_METHOD'] ) ) {
			return true; // Err on the side of caution
		}
		
		$entities      = array( 'posts', 'users', 'comments', 'tags', 'categories', 'media' );
		$json_base     = str_replace( get_site_url(), '', get_rest_url( null, 'wp/v2/' ) );
		$request_uri   = sanitize_url( wp_unslash( $_SERVER['REQUEST_URI'] ) );
		$endpoint      = str_replace( $json_base, '', $request_uri );
		$request_method = sanitize_text_field( wp_unslash( $_SERVER['REQUEST_METHOD'] ) );
		
		// Parse endpoint safely
		$endpoint_parts = explode( '/', trim( $endpoint, '/' ) );
		$first_part     = isset( $endpoint_parts[0] ) ? sanitize_text_field( $endpoint_parts[0] ) : '';
		
		$protected_methods = array( 'POST', 'PUT', 'DELETE', 'PATCH' );
		
		return in_array( $first_part, $entities, true ) && in_array( $request_method, $protected_methods, true );
	}
}