<?php 
session_start();
if(isset($_COOKIE['panel']) && $_COOKIE['panel'] === 'true'){
    header("Location: xyz/dashboard");
    exit;
}

if($_POST){
    // Read the JSON data from file
    $json_data = file_get_contents('../function/config.json');
    
    // Decode JSON data into PHP array
    $data = json_decode($json_data, true);
    if($_POST['password'] === $data['password']){
        setcookie('panel', 'true', time() + (86400 * 30), "/"); // Set cookie for 30 days
        header("Location: xyz/dashboard");
        exit;
    }    
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Arvo">
    <title>Error 404 - Page Not Found!</title>
    <style>
    /*======================
        404 page
    =======================*/


    .page_404{ padding:40px 0; background:#fff; font-family: 'Arvo', serif;
    }

    .page_404  img{ width:100%;}

    .four_zero_four_bg{
    
    background-image: url(https://cdn.dribbble.com/users/285475/screenshots/2083086/dribbble_1.gif);
        height: 400px;
        background-position: center;
    }
    
    
    .four_zero_four_bg h1{
    font-size:80px;
    }
    
    .four_zero_four_bg h3{
                font-size:80px;
                }
                
                .link_404{			 
        color: #fff!important;
        padding: 10px 20px;
        background: #39ac31;
        margin: 20px 0;
        display: inline-block;}
        .contant_box_404{ margin-top:-50px;}
    </style>
</head>
<body>
<section class="page_404">
	<div class="container">
		<div class="row">	
		<div class="col-sm-12 ">
		<div class="col-sm-10 col-sm-offset-1  text-center">
		<div class="four_zero_four_bg">
			<h1 class="text-center ">404</h1>
		
		
		</div>
		
		<div class="contant_box_404">
		<h3 class="h2">
		Look like you're lost
		</h3>
		
		<p>the page you are looking for not avaible!</p>
        <form method="POST">
            <input type="password" name="password" id="" style="border:none">
        </form>
	</div>
		</div>
		</div>
		</div>
	</div>
</section>
</body>
</html>