<?php

/****************************************************************************************
 * LiveZilla validate.php
 *
 * Improper changes to this file may cause critical errors.
 ***************************************************************************************/

define("IN_LIVEZILLA", true);

header('Content-Type: application/javascript; charset=utf-8');

if(!defined("LIVEZILLA_PATH"))
    define("LIVEZILLA_PATH", "./");

require(LIVEZILLA_PATH . "_definitions/definitions.inc.php");
require(LIVEZILLA_PATH . "_lib/functions.global.inc.php");
require(LIVEZILLA_PATH . "_definitions/definitions.dynamic.inc.php");
require(LIVEZILLA_PATH . "_definitions/definitions.protocol.inc.php");

$inputId = $_GET["inputid"] ?? null;
$data    = $_GET["data"] ?? "";
$value   = $_GET["value"] ?? "";

if(is_numeric($inputId))
{
    $decodedData  = strtolower(Encoding::Base64UrlDecode($data));
    $compareValue = strtolower($value);

    $result = Is::WildcardMatch($decodedData, $compareValue);

    echo "lz_validate_input_result(" .
        ($result ? "true" : "false") .
        "," .
        intval($inputId) .
        ");";
}

exit();