<?php
/**
 * HappyFenceNG Total Enterprise Security Plugin
 * HAPPYWPRISS is a RazorVue Trademark.
 *
 * @package     HappyFenceNG
 * @developer   Simonluca Scillitani
 * @copyright   2025 RazorVue di Scillitani Simonluca
 * @link        https://razorvue.it
 * @author      RazorVue di Scillitani Simonluca
 * @brand       HappyWPRIss
 * @uri         https://happywPRIss.com
 * @set all
 */

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

/**PHPCS -> code compliance: we put useful comments where needed.. */
class HappyFenceNGVRSUSQ extends HappyFenceNGAVRoute {

	/**PHPCS -> code compliance: we put useful comments where needed.. */
	public function doRoute() {
		try {

			$nonce_save_settings = wp_create_nonce( 'happyfenceng_SUSQ_save_settings' );
			$burn                = HappyFenceNGFailFast::setup();

			$params = array(
				'texts'  => array(
					'title'                 => esc_html__( 'Suspicious URI Filters', 'happyfenceng-total-enterprise-security' ),
					'description_1'         => esc_html__( 'In this page you can select which suspicious query filters activate to improve your WP security. If unsure, we strongly suggest to select all.', 'happyfenceng-total-enterprise-security' ),
					'select_all'            => esc_html__( 'Select all', 'happyfenceng-total-enterprise-security' ),
					'unselect_all'          => esc_html__( 'Unselect all', 'happyfenceng-total-enterprise-security' ),
					'important'             => esc_html__( 'Important!', 'happyfenceng-total-enterprise-security' ),
					'enabled_patterns_info' => esc_html__( 'Warning: some aggressive filters like mod_security can interfere with HappyFenceNG while dealing with the patterns below. For this reason we use leet encoding. If you expericence troubles when saving this options and/or get Unauthorized message, you know where to point your finger.', 'happyfenceng-total-enterprise-security' ),
					'feature_requires'      => esc_html__( 'THIS FEATURE REQUIRES ENTERPRISE', 'happyfenceng-total-enterprise-security' ),
					'save_settings'         => esc_html__( 'Save Settings', 'happyfenceng-total-enterprise-security' ),
					'settings_saved'        => esc_html__( 'Settings Saved', 'happyfenceng-total-enterprise-security' ),
					'error_saving_settings' => esc_html__( 'Error saving settings', 'happyfenceng-total-enterprise-security' ),

				),
				'links'  => array(
					'happyfenceng_logo_url' => esc_url( HAPPYFENCENG_PLUGIN_URL . 'assets/images/happyfenceng-small.png' ),

				),
				'values' => array(
					'patterns'        => HappyFenceNGSusqPattern::get_selectable_keys(),

					'checkbox_on'     => HappyFenceNGPlaceholder::CHECKBOX_ON,
					'checkbox_off'    => HappyFenceNGPlaceholder::CHECKBOX_OFF,
					'nonce'           => $nonce_save_settings,
					'burnNonce'       => $burn,
					'feature_enabled' => ( function_exists( 'htes_fs' ) && HappyFenceNGTR::is_in( static::class, array( HappyFenceNGTR::BUNKER ) ) ),

				),
			);

			ob_start();
			HappyFenceNGVControl::renderView( $params, 'susq' );
			// phpcs:ignore WordPress.Security.EscapeOutput
			echo ob_get_clean();

		} catch ( Throwable $e ) {
			HappyFenceNGLOGCORE::logcore(
				'HappyFenceNGVRSUSQ - cannot render UI ' . $e->getMessage(),
				HappyFenceNGSyslogFacility::UI,
				HappyFenceNGSyslogSeverity::ERROR
			);
			ob_end_clean();
			HappyFenceNGCleaner::cleaner_oops();
		}
	}
}
