<?php
require_once(dirname(__FILE__).'/config.inc.php');

// Allow specifying main window URL for permalinks, etc.
$url = 'main.php';

if ("@COREWINDOW@" == "yes" && isset($_GET['corewindow'])) {

	// The default window url may have been overridden with a permalink...
	// Parse the URL and remove permalink option from base.
	$a = parse_url($_GET['corewindow']);

	// Build the base url.
	$url = htmlentities($a['path']).'?';
	$url = (isset($a['host'])) ? $a['scheme'].'://'.$a['host'].$url : '/'.$url;

	$query = isset($a['query']) ? $a['query'] : '';
	$pairs = explode('&', $query);
	foreach ($pairs as $pair) {
		$v = explode('=', $pair);
		if (is_array($v)) {
			$key = urlencode($v[0]);
			$val = urlencode(isset($v[1]) ? $v[1] : '');
			$url .= "&$key=$val";
		}
	}
	if (preg_match("/^http:\/\/|^https:\/\/|^\//", $url) != 1)
		$url = "main.php";
}

$this_year = '2026';
$theme = $cfg['theme'] ?? 'dark';
if ($theme != 'dark' && $theme != 'light') {
	$theme = 'dark';
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

<html class="<?= $theme ?>">
<head>
	<meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
	<title>Nagios: <?php echo $_SERVER['SERVER_NAME']; ?></title>
	<link rel="shortcut icon" href="images/favicon.ico" type="image/ico">

	<style>
		#root {
			display: flex;
			margin:0;
		}

		:root {
			--border: #28303E
		}

		.light {
			--border: #D6D6D6
		}

		iframe[name="side"] {
			height: 100vh;
			width: 200px;
			border: none;
			border-right: 1px solid var(--border);
		}

		iframe[name="main"] {
			height: 100vh;
			width: 100%;
			border: none;
		}
	</style>
</head>

<body id="root">
	<iframe src="side.php" name="side"></iframe>
	<iframe src="<?php echo $url; ?>" name="main"></iframe>
</body>

</html>
