<?php
//read the websitedata.dat file into some array.
$lines = file('websitedata.dat');
$root = "";
// Loop through our array, show HTML source as HTML source; and line numbers too.
for ($i = 0; $i < count($lines); $i++) {
	//echo $lines[$i];	
	if(preg_replace( "/\r|\n/", "", $lines[$i]) == "ProjectName"){
		$ProjectName = preg_replace( "/\r|\n/", "", $lines[$i+1]);
	}		
	if(preg_replace( "/\r|\n/", "", $lines[$i]) == "BackupEmailList"){
		$BackupEmailList = preg_replace( "/\r|\n/", "", $lines[$i+1]);
	}		
	if(preg_replace( "/\r|\n/", "", $lines[$i]) == "BackupEmailFrom"){
		$BackupEmailFrom = preg_replace( "/\r|\n/", "", $lines[$i+1]);
	}	
	if(preg_replace( "/\r|\n/", "", $lines[$i]) == "URL"){
		$URL = preg_replace( "/\r|\n/", "", $lines[$i+1]);
	}
	if(preg_replace( "/\r|\n/", "", $lines[$i]) == "Sub-directory"){
		$SubDir = preg_replace( "/\r|\n/", "", $lines[$i+1]);
	}	
	if(preg_replace( "/\r|\n/", "", $lines[$i]) == "RootDirectory"){
		$root = preg_replace( "/\r|\n/", "", $lines[$i+1]);
	}			
}
if($root == ""){
	$root = $_SERVER['DOCUMENT_ROOT'];
}
?>
<!DOCTYPE html>
<html>
<link rel="icon" href="images/favicon.png">
<head>
<script src="https://kit.fontawesome.com/e738e53c92.js" crossorigin="anonymous"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
body {margin:0;font-family:Arial}

.topnav {
  overflow: hidden;
  background-color: teal;
  margin:auto;
}

.topnav a {
  float: left;
  display: block;
  color: #f2f2f2;
  text-align: center;
  padding: 23px 15px;
  text-decoration: none;
  font-size: 20px;
  margin: auto;
}

.active {
  background-color: #04AA6D;
  color: white;
}

.topnav .icon {
  display: none;
}

.dropdown {
  float: left;
  overflow: hidden;
}

.dropdown .dropbtn {
  font-size: 17px;    
  border: none;
  outline: none;
  color: white;
  padding: 14px 16px;
  background-color: inherit;
  font-family: inherit;
  margin: 0;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 1;
}

.dropdown-content a {
  float: none;
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  text-align: left;
}

.topnav a:hover, .dropdown:hover .dropbtn {
  background-color: #555;
  color: white;
}

.dropdown-content a:hover {
  background-color: #ddd;
  color: black;
}

.dropdown:hover .dropdown-content {
  display: block;
}

@media screen and (max-width: 1387px) {
  .topnav a:not(:first-child), .dropdown .dropbtn {
    display: none;
  }
  .topnav a.icon {
    float: right;
    display: block;
  }
}

@media screen and (max-width: 1387px) {
  .topnav.responsive {position: relative;}
  .topnav.responsive .icon {
    position: absolute;
    right: 0;
    top: 0;
	background-color: #555;
  }
  .topnav.responsive a {
    float: none;
    display: block;
    text-align: left;
  }
  .topnav.responsive .dropdown {float: none;}
  .topnav.responsive .dropdown-content {position: relative;}
  .topnav.responsive .dropdown .dropbtn {
    display: block;
    width: 100%;
    text-align: left;
  }
}
</style>
</head>
<body>

<div class="topnav" id="myTopnav">
  <a href="https://www.bosl.com.au" style="background-color:white; padding:0px;margin: auto;"><img height=65px src="https://www.bosl.com.au/wiki/BoSL_Logo4.png"></a>
  
  <a href="?page=map_v3" style="margin: auto;"><i class="fa-solid fa-map-location"></i> Map</a>
  <a href="?page=data"><i class="fa-solid fa-database"></i> Data</a>
  <a href="?page=viewrecent"><i class="fa-solid fa-bolt-lightning"></i> Recent</a>
  <a href="?page=graphall"><i class="fa-solid fa-chart-line"></i></i> Charts</a>
  <a href="?page=control"><i class="fa-solid fa-gamepad"></i> Control</a>
  <a href="?page=radar"><i class="fa-solid fa-cloud-showers-heavy"></i> Radar</a>
  <a href="?page=alarms"><i class="fa-solid fa-sliders"></i> Alarms</a>
  <a href="?page=videos"><i class="fa-solid fa-video"></i> Videos</a>
  <a href="mailto:david.mccarthy@monash.edu"><i class="fa-solid fa-envelope"></i> Contact</a>
  <a href="javascript:void(0);" style="font-size:17px;" class="icon" onclick="myFunction()">&#9776;</a>
</div>

<div style="padding:5px">

<?php 


if(isset($_GET['page'])){
	if($_GET['page']=='map'){
		//echo $root . "/DTM/webpages/map_v2.php";
		include($root . "/DTM/webpages/map_v2.php");
		//include("114.142.160.204/~bosl" . "/DTM/webpages/map_v2.php");
	}elseif($_GET['page']=='data'){
		include($root . "/DTM/webpages/list_v2.php");
	}elseif($_GET['page']=='control'){
		echo 'Page under construction';
	}elseif($_GET['page']=='viewrecent'){
		include($root . "/DTM/webpages/a.php");
	}elseif($_GET['page']=='graphall'){
		include($root . "/DTM/webpages/plot_all_sites.php");
	}elseif($_GET['page']=='radar'){
		include($root . "/DTM/webpages/radar.php");
	}elseif($_GET['page']=='alarms'){
		include($root . "/DTM/webpages/alarms.php");
	}elseif($_GET['page']=='videos'){
		include($root . "/DTM/webpages/videos.php");
	}elseif($_GET['page']=='map_v3'){
		include($root . "/DTM/webpages/map_v3.php");
	}elseif($_GET['page']=='forecasts'){
		include($root . "/DTM/webpages/forecasts.php");
	}
	
}else{
	include($root . "/DTM/webpages/map_v3.php");
	//include("114.142.160.204/~bosl" . "/DTM/webpages/map_v2.php");
}
?>
<br>
<table style="width:100%;background-color:teal; border-collapse: collapse;"><tr><th style="width:100%;text-align:right"><p/></th><th style="background-color:white;text-align:right"><a href="https://www.bosl.com.au" style="background-color:white"><img height=30px src="https://www.bosl.com.au/wiki/BoSL_Logo4.png"></a></th></tr></table>

<script>
function myFunction() {
  var x = document.getElementById("myTopnav");
  if (x.className === "topnav") {
    x.className += " responsive";
  } else {
    x.className = "topnav";
  }
}
</script>