<?php 
// If you intended to redirect, use: header("Location: https://eftpay.eft.xyz/prelander.php?serviceid=<serviceid>"); 
/*

https://disclaimer.eft.xyz/?serviceid=<serviceid>&{follwed by any set of key:value pairs}   =>
Eg:-
https://disclaimer.eft.xyz/?serviceid=<serviceid>&clickid=<clickid>&publisherid=<publisherid>....

https://disclaimer.eft.xyz/prelander.php?serviceid=<serviceid>

https://disclaimer.eft.xyz/?serviceId=32&a=1111&b=2222&c=3333
*/
?>
<?php
require_once("includes/dbparameters.php");
include("includes/eftpay-lk-commonVariables.php");
$db = mysqli_connect($db_host, $db_username ,$db_password, $db_name);
mysqli_set_charset($db,"utf8");

    $serviceId = $_REQUEST['serviceId'];
    $rawQueryString = $_SERVER['QUERY_STRING'];

$service_query = mysqli_query($db,"SELECT * FROM $eftpay_services_table WHERE serviceId = $serviceId AND serviceStatus = 'active'");  
if($service_query_array = mysqli_fetch_assoc($service_query))
{
    $merchantUserId = $service_query_array['merchantUserId'];
    $merchant_query = mysqli_query($db,"SELECT * FROM $eftpay_merchants_table WHERE merchantUserId = '$merchantUserId' AND merchantStatus = 'active'");  
    if($merchant_query_array = mysqli_fetch_assoc($merchant_query))
    {
        $merchantPassword = $merchant_query_array['merchantPassword'];
    }

    $allowed_landing_pages_affiliate = $service_query_array['allowed_landing_pages_affiliate'];
}

    $requesting_page = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'Direct Access';    
    $timestamp = time();
    $ip = $_SERVER['REMOTE_ADDR'];
    $signature = hash_hmac('sha256', $merchantUserId . ':' . $merchantPassword . ':' . $timestamp . ':' . $ip, $merchantPassword);

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Subscription Disclaimer</title>
    <script src="https://eftpay.eft.xyz/js/eftpay-prelander.js?merchantUserId=<?=$merchantUserId?>&serviceId=<?=$serviceId?>&ts=<?=$timestamp?>&ip=<?=$ip?>&signature=<?=$signature?>"></script>

    <style>
        body, html {
            margin: 0;
            padding: 0;
            height: 100%;
            background-color: #000000; /* Black background */
            color: #FFFFFF;           /* Default text color: White */
            font-family: sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            text-align: center;
        }

        .container {
            padding: 30px;
            max-width: 600px;
        }

        /* Red text for the Disclaimer content */
        .disclaimer-text {
            color: #FF0000;
            font-size: 1.1rem;
            line-height: 1.6;
            margin-bottom: 25px;
        }

        /* White text for the headers/labels */
        .label {
            color: #FFFFFF;
            font-weight: bold;
            display: block;
            margin-bottom: 10px;
            font-size: 1.2rem;
        }

        .btn-continue {
            background-color: #007BFF;
            color: white;
            border: none;
            padding: 15px 35px;
            font-size: 1.1rem;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s ease;
            text-decoration: none;
            display: inline-block;
            margin-top: 10px;
        }

        .btn-continue:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>

    <div class="container">
        <!-- White Label -->
        <span class="label">සැලකිය යුතුයි:</span>
        
        <!-- Red Message (Sinhala) -->
        <div class="disclaimer-text">
            "ඔබ දැන් පිවිසෙන්නේ ගාස්තු ගෙවා ලබාගත යුතු සේවාවකට අදාළ පිටුවකටයි (Subscription Service). 
            මෙම සේවාවට අදාළ වන සියලුම ගාස්තු මෙම පිටුවේ සඳහන් කර ඇත. 
            මෙය කිසිදු අයුරකින් මුදල් හෝ වෙනත් තෑගි නොමිලේ ලබා දෙන වැඩසටහනක් නොවන බව කරුණාවෙන් සලකන්න. 
            මෙම සේවාව සඳහා සම්භන්ද වීම ඔබගේ කැමැත්ත මත පමණක් සිදු වන්නක් බව කාරුණිකව සලකන්න."
        </div>

        <!-- White Label -->
        <span class="label">Disclaimer:</span>

        <!-- Red Message (English) -->
        <div class="disclaimer-text">
            You are about to enter a page for a subscription service. All the charges applicable 
            after subscribing to this service will be mentioned in the page. This is in no way 
            related to a free give-away of Cash or any other gifts. Subscribing to the service 
            will be at your own discretion.
        </div>

        <input type='hidden' id='server_key'>
        <button class="btn-continue" onclick="redirectToAffiliate('<?=$allowed_landing_pages_affiliate?>', '<?=$rawQueryString?>')">Continue</button>

    </div>

</body>
</html>