<?php
$pragmatic = file_get_contents("./data/pragmatic.json");
$pgsoft = file_get_contents("./data/pgsoft.json");
$key = json_decode(file_get_contents("./data/key.json"), true);
$key1 = $key['key1'];
$key2 = $key['key2'];
$key3 = $key['key3'];
$key4 = $key['key4'];
$key5 = $key['key5'];
$provider = isset($_GET['provider']) ? $_GET['provider'] : null;
$auth = isset($_GET['key']) ? $_GET['key'] : null;
$invalid_key = array("status" => "401 Unauthorized", "message" => "Authentication Required!", 'Author' => "['Name: NuLz', 'Telegram: @haxorstars']", "Attention" => "If You Need Key, Please Contact The Author");
$invalid_param = array("status" => "400 Bad Requests", "message" => "Invalid Parameter");

if ($provider === null) {
    header("HTTP/1.1 400 Bad Requests");
    header("Content-Type: application/json");
    echo json_encode($invalid_param);
} elseif ($provider === "pragmatic") {
    if ($auth === null) {
        header("HTTP/1.1 401 Unauthorized");
        header("Content-Type: application/json");
        echo json_encode($invalid_key);
    } elseif ($auth === $key1) {
        header("HTTP/1.1 200 OK");
        header("Content-Type: application/json");
        echo $pragmatic;
    } elseif ($auth === $key2) {
        header("HTTP/1.1 200 OK");
        header("Content-Type: application/json");
        echo $pragmatic;
    } elseif ($auth === $key3) {
        header("HTTP/1.1 200 OK");
        header("Content-Type: application/json");
        echo $pragmatic;
    } elseif ($auth === $key4) {
        header("HTTP/1.1 200 OK");
        header("Content-Type: application/json");
        echo $pragmatic;
    } elseif ($auth === $key5) {
        header("HTTP/1.1 200 OK");
        header("Content-Type: application/json");
        echo $pragmatic;
    } else {
        header("HTTP/1.1 401 Unauthorized");
        header("Content-Type: application/json");
        echo json_encode($invalid_key);
    }
} elseif ($provider === "pgsoft")  {
    if ($auth === null) {
        header("HTTP/1.1 401 Unauthorized");
        header("Content-Type: application/json");
        echo json_encode($invalid_key);
    } elseif ($auth === $key1) {
        header("HTTP/1.1 200 OK");
        header("Content-Type: application/json");
        echo $pgsoft;
    } elseif ($auth === $key2) {
        header("HTTP/1.1 200 OK");
        header("Content-Type: application/json");
        echo $pgsoft;
    } elseif ($auth === $key3) {
        header("HTTP/1.1 200 OK");
        header("Content-Type: application/json");
        echo $pgsoft;
    } elseif ($auth === $key4) {
        header("HTTP/1.1 200 OK");
        header("Content-Type: application/json");
        echo $pgsoft;
    } elseif ($auth === $key5) {
        header("HTTP/1.1 200 OK");
        header("Content-Type: application/json");
        echo $pgsoft;
    } else {
        header("HTTP/1.1 401 Unauthorized");
        header("Content-Type: application/json");
        echo json_encode($invalid_key);
    }
} else {
    header("HTTP/1.1 400 Bad Requests");
    header("Content-Type: application/json");
    echo json_encode($invalid_param);
}
?>