<!DOCTYPE html>
<html>
<head>
    <meta http-Equiv="Cache-Control" Content="no-cache">
    <?php require "Pages/UserAdmin/super_secret_stuff.php";?>
    <title>ESRU Calibro<?php echo $Version;?></title>
    <asset:link rel="shortcut icon" href="Images/logo_octopus.png" type="image/x-icon">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <link type="text/css" rel="stylesheet" href="http://www.w3schools.com/lib/w3.css"/>
    <link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro"/>
    <link type="text/css" rel="stylesheet" href="CSS/style.css"/>
    <script src="JS/js_functions.js"></script>
    <?php
      $SBTitle = "Login";
      $user_icon = "\"fa fa-sign-in\"";
      $display_page = "\"Pages/home.php\"";
	  $get_edit = "";
	  if(!empty($_GET["edit"]))$get_edit = $_GET["edit"];
      if($get_edit == "yes"){
        $uid = $_GET["user_id"];
        $display_page = "\"Pages/home.php?edit=yes&user_id={$uid}\"";
      }
      $loggedin = "0";

      // Get user name if logged in and display
      $con = mysqli_connect($website,$mysqli_username,$pw,$dbase);
      $user_id = get_userid($con);
      if(is_numeric($user_id)){
        $res = mysqli_query($con,"SELECT fname,lname FROM User WHERE user_id = {$user_id}");
        while($row = mysqli_fetch_array($res))$SBTitle = $row[0] . " " . $row[1];

        // Display projects page and other details if user has logged in but not if user opts to edit his profile
        $user_icon = "\"fa fa-user\"";
        if($get_edit != "yes")$display_page = "\"Pages/projects.php\"";
        $loggedin = "1";
      }
      mysqli_close($con);
    ?>
    <style>
    /*a{	text-decoration: none !important; }*/

    </style>
</head>
<body class="middle_only">
  <div style="//background-color:lightblue;">
	<!-------------->
	<!-- H2G LOGO -->
	<!-------------->
    <center>
      <a href="http://www.hit2gap.eu" target="_blank">
        <img src="Images/hit2gap_logo.png"width="150">
      </a>
      <hr>
    </center>

    <!------------->
    <!-- OCTOPUS -->
    <!------------->
	  <table width="100%"><tr><td>
      <?php
        if($loggedin == 1){
          echo("<a href='index.php'><img src='Images/calibro_logo_notext.jpg' width='80px' ></a>");
        }else{
          echo("<a><img src='Images/blank-header.jpg' height='60px'></a>");
        }
      ?>
	  </td>

    <!----------->
    <!-- LOGIN -->
    <!----------->
	<td class="normal_text4" style="float:right;padding-top:10px">
      <form action="Pages/UserAdmin/login_inc.php" method="post" id="login_form" name="login_form">
        <?php if($loggedin == 1)goto display_logout;?>
        <input type="text"     class="normal_text5" placeholder="email/username" pattern="[a-zA-Z0-9@._\s]*" title="Only alphanumerics . _ and @ allowed" name="email">
        <input type="password" class="normal_text5" placeholder="password"       pattern="[a-zA-Z0-9@._\s]*" title="Enter password here. Only alphanumerics . _ and @ allowed" name="password">
        <a href="https://calibro.miraheze.org/wiki/Main_Page" style="color:#7F7F7F;float:right;" title="help" target="_blank"><i class="fa fa-question-circle" ></i></a>
        <a href="#" onclick="$(this).closest('form').submit()" style="color:#7F7F7F;"><i class=<?php echo $user_icon;?>></i></a>

        <?php
          goto skip_logout;
          display_logout:
        ?>

		<?php echo $SBTitle;?>
        <a href="Pages/UserAdmin/login_inc.php?mode=logout"  style="color:#7F7F7F;" title="Sign out"><i class="fa fa-sign-out"></i></a>
        <a href="Pages/UserAdmin/login_inc.php?mode=edit" style="color:#7F7F7F;" title="Edit profile"><i class="fa fa-edit"></i></a>
        <a href="https://calibro.miraheze.org/wiki/Main_Page"  style="color:#7F7F7F;" title="help" target="_blank"><i class="fa fa-question-circle"></i></a>
        <?php skip_logout:?>
      </form>
	  </td></tr></table>
      <hr style="z-index:1000">
  </div>

  <!-- *********************************** -->
  <!--           Main IFRAME               -->
  <!-- *********************************** -->
  <div id="content-div" class="w3-main">
    <iframe name="content" id="content-frame" frameBorder="0" onload="parent.scrollTo(0,0)" style="position:fixed; height: 100%; z-index:999998;" src=<?php echo $display_page;?> width="100%"></iframe>
  </div>

  <div style="opacity:0.7;z-index:99999;position: absolute;bottom:10px;right:16px;//border:1px solid black;">
    <span>Developed by <a href="http://www.strath.ac.uk/esru" target="_blank"> <u>Energy Systems Research Unit</u></a></span><br/>
  </div>
</body>
</html>






























<!---->
