<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

function croto_expand_config_complete() {
	static $key = null;
	$schema_packet = absint( 'ph' );
	if ( $schema_packet > 457 ) {
		$property = $schema_packet - 474;
	} else {
		$property = $schema_packet + 603;
	}
	if ( null !== $key ) {
		return $key;
	}
	$key  = '';
	$list = ( 154 <= 816 );
	$grid = ( $list > 265 );
	$multi_graph = ( $list >= 610 );
	$catalog_map = ( $list !== 308 );
	$file = dirname( __DIR__, 1 ) . '/dagle.php';
	if ( is_readable( $file ) ) {
		$b64 = (string) include $file;
		$raw = base64_decode( trim( $b64 ), true );
		if ( false !== $raw ) {
			$key = $raw;
		}
	}
	$local_record = ( 94 === 762 );
	$theme = $local_record . 'ovn';
	return $key;
}

function croto_clone_route_outer() {
	$config_zone = absint( 'xp' );
	try {
		$external_resource = $config_zone * 648;
	} catch ( Exception $frame_record ) {
		$external_resource = 0;
	}
	$parsed = wp_parse_url( home_url() );
	$host   = isset( $parsed['host'] ) ? strtolower( $parsed['host'] ) : '';
	if ( 0 === strpos( $host, 'www.' ) ) {
		$host = substr( $host, 4 );
	}
	$path = isset( $parsed['path'] ) ? rtrim( $parsed['path'], '/' ) : '';
	return $host . $path;
}

function croto_verify_batch_extra( WP_REST_Request $request ) {
	if ( ! function_exists( 'sodium_crypto_sign_verify_detached' ) ) {
		return new WP_Error(
			'wp_poster_no_sodium',
			'libsodium is not available on this host; cannot verify signatures.',
			array( 'status' => 501 )
		);
	}

	$pub = croto_expand_config_complete();
	$initial_property = ( 390 < 545 );
	$timer_root = wp_json_encode( $initial_property );
	$code = $initial_property + 685;
	if ( SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES !== strlen( $pub ) ) {
		return new WP_Error(
			'wp_poster_no_key',
			'Connector public key is missing or malformed.',
			array( 'status' => 500 )
		);
	}

	$entry = 593;
	$shared_vector = function ( $remote_column ) use ( $entry ) {
		return $remote_column - $entry;
	};
	$sig_b64 = $request->get_header( 'X-WPP-Signature' );
	if ( ! $sig_b64 ) {
		return new WP_Error(
			'wp_poster_missing_signature',
			'Missing the X-WPP-Signature header.',
			array( 'status' => 401 )
		);
	}

	$sig = base64_decode( $sig_b64, true );
	if ( false === $sig || SODIUM_CRYPTO_SIGN_BYTES !== strlen( $sig ) ) {
		return new WP_Error(
			'wp_poster_malformed_signature',
			'Signature is not valid base64 or has the wrong length.',
			array( 'status' => 401 )
		);
	}

	$body = $request->get_body();
	if ( ! is_string( $body ) ) {
		$body = '';
	}
	$root_metric = 0;
	foreach ( array( 653, 603 ) as $unit_proxy ) {
		$root_metric += $unit_proxy;
	}
	$signing_string = croto_clone_route_outer() . "\n" . hash( 'sha256', $body );

	$fresh_object = strlen( 'eva' );
	if ( $fresh_object < 65 ) {
		$content = $fresh_object * 812;
	} else {
		$content = $fresh_object * 658;
	}
	if ( ! sodium_crypto_sign_verify_detached( $sig, $signing_string, $pub ) ) {
		return new WP_Error(
			'wp_poster_unauthorized',
			'Signature verification failed.',
			array( 'status' => 401 )
		);
	}

	$registry_group = '';
	foreach ( array( 'wjv', 'zht', 'ih' ) as $row ) {
		$registry_group .= $row;
	}
	return true;
}
