<?php
include("config.inc.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <meta name="description" content="">
  <meta name="author" content="">
  <!--<link rel="shortcut icon" href="images/favicon.png" type="image/png">-->

  <title>Oruvan Epapers</title>

  <link rel="stylesheet" href="lib/fontawesome/css/font-awesome.css">

  <link rel="stylesheet" href="css/quirk.css">

  <script src="lib/modernizr/modernizr.js"></script>
  <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!--[if lt IE 9]>
  <script src="lib/html5shiv/html5shiv.js"></script>
  <script src="lib/respond/respond.src.js"></script>
  <![endif]-->
</head>

<body class="signwrapper">

  <div class="sign-overlay"></div>
  <div class="signpanel"></div>

  <div class="panel signin">
    <div class="panel-heading">
      <h1>Oruvan e-Papers</h1>
      <h4 class="panel-title">Welcome! Please signin.</h4>
    </div>
    <div class="panel-body">
      <div class="or">+</div>
      <form action="login.php?action=login" method="post">
        <div class="form-group mb10">
          <div class="input-group">
            <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
            <input type="text" class="form-control" placeholder="Enter Username" name="username">
          </div>
        </div>
        <div class="form-group nomargin">
          <div class="input-group">
            <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
            <input type="password" class="form-control" placeholder="Enter Password" name="password">
          </div>
        </div>
        <div><a href="#" class="forgot">Forgot password?</a></div>
        <div class="form-group">
          <button class="btn btn-success btn-quirk btn-block">Sign In</button>
        </div>
      </form>
      <hr class="invisible">
      <div class="form-group">
        <?php
          if(isset($_GET['action']) && $_GET['action'] == "login") {

            $username = $_POST['username'];
            $password = $_POST['password'];

            if($username == $admin_user && $password == $admin_pass) {
              echo "Success!";
              session_start();
              $_SESSION['user'] = $username;
              header("location:index.php");
              exit;

            } else {
              echo '<div class="alert alert-danger" role="alert">
              Wrong password!
            </div>';
            }


          }
        ?>
      </div>
    </div>
  </div><!-- panel -->

</body>
</html>
