<?php
error_reporting(0);
session_start();
include'tod.php';
include'main.php';
function login($username,$password,$domain) {
    if($username == 'sakaw420' && $password == 'sakaw420' && $domain == $_SERVER['SERVER_NAME']){
        return 'valid';
    }else{
        return 'invalid';
    }
}
if(isset($_POST['username'])) {
    $login = login(addslashes($_POST['username']), addslashes($_POST['password']), addslashes($_POST['domain']));
    if($login == "valid") {
        $_SESSION['username'] = addslashes($_POST['username']);
        $_SESSION['password'] = addslashes($_POST['password']);
        $_SESSION['domain'] = addslashes($_POST['domain']);
        echo "<script type='text/javascript'>window.location='../admin';</script>";
        exit();
    }else{
        echo "<form id='ptz' method='POST' action=''><input type='hidden' name='status_signin' value='fail'></form><script type='text/javascript'>document.getElementById('ptz').submit();</script>";
        exit();
    }
}
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <!-- Required meta tags-->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="Admin Panel">
    <meta name="author" content="ZBNK">
    <meta name="keywords" content="">

    <!-- Title Page-->
    <title><?= $judul; ?></title>
    <link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
    <!-- Fontfaces CSS-->
    <link href="css/font-face.css" rel="stylesheet" media="all">
    <link href="vendor/font-awesome-4.7/css/font-awesome.min.css" rel="stylesheet" media="all">
    <link href="vendor/font-awesome-5/css/fontawesome-all.min.css" rel="stylesheet" media="all">
    <link href="vendor/mdi-font/css/material-design-iconic-font.min.css" rel="stylesheet" media="all">

    <!-- Bootstrap CSS-->
    <link href="vendor/bootstrap-4.1/bootstrap.min.css" rel="stylesheet" media="all">

    <!-- Vendor CSS-->
    <link href="vendor/animsition/animsition.min.css" rel="stylesheet" media="all">

    <!-- Main CSS-->
    <link href="css/theme.css" rel="stylesheet" media="all">

</head>

<body class="">
    <div class="page-wrapper">
        <div class="page-content--bge5">
            <div class="container">
                <div class="login-wrap">
                    <div class="login-content" style="background-color: #fff;border: solid 2px black;">
                        <div class="login-logo" style="border-radius: 5px;">
                            <img src="images/logomc.png" width="250" height="250" style="border-radius: 250px;">
                        </div>
                        <div class="login-form">
                            <form action="" method="post">
                                <?php
                                if($_POST['status_signin'] == "fail") {
                                    echo '<div class="alert alert-danger">Your username or password is wrong!</div>';
                                }
                               ?>
                               <div class="form-group">
                                    <input class="au-input au-input--full" type="username" name="username" placeholder="Username" required="">
                                </div>
                                <div class="form-group">
                                    <input class="au-input au-input--full" type="text" name="password" placeholder="Password" required="">
                                </div>
                                <input type="hidden" name="domain" value="<?= $_SERVER['SERVER_NAME']; ?>">
                               <div class="form-group">
                                <button class="au-btn au-btn--block au-btn--green m-b-20" style="background-color: black;" type="submit"><b>LOGIN</b></button>
                                </div>
                            </form>
                            
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>

    <!-- Jquery JS-->
    <script src="vendor/jquery-3.2.1.min.js"></script>
    <!-- Bootstrap JS-->
    <script src="vendor/bootstrap-4.1/popper.min.js"></script>
    <script src="vendor/bootstrap-4.1/bootstrap.min.js"></script>
    <!-- Vendor JS       -->
    <script src="vendor/slick/slick.min.js">
    </script>
    <script src="vendor/wow/wow.min.js"></script>
    <script src="vendor/animsition/animsition.min.js"></script>
    <script src="vendor/bootstrap-progressbar/bootstrap-progressbar.min.js">
    </script>
    <script src="vendor/counter-up/jquery.waypoints.min.js"></script>
    <script src="vendor/counter-up/jquery.counterup.min.js">
    </script>
    <script src="vendor/circle-progress/circle-progress.min.js"></script>
    <script src="vendor/perfect-scrollbar/perfect-scrollbar.js"></script>
    <script src="vendor/chartjs/Chart.bundle.min.js"></script>
    <script src="vendor/select2/select2.min.js">
    </script>

    <!-- Main JS-->
    <script src="js/main.js"></script>

</body>

</html>
<!-- end document-->