<?php
session_start();
if (!isset($_SESSION['user'])) {
	header("Location: https://glink.zip/");
	exit();
}
?>
<html>
<head>
    <title>GLink</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="output.css">
</head>
<body class="bg-gray-50 mx-[10%]">
<h1 class="ml-4 text-5xl font-narrow">Link Shortener</h1>
<p class="ml-4 font-fingerpaint">Hello There!</p>

<?php 
// The reason this works (i.e. I can use PHP in a .html file)
// is because I have configured my .htaccess file to treat every file
// ending in .html, as if it contains embedded PHP.
// However, this is a strain on resources as it means _every_ HTML
// file will be parsed for PHP code, even if it doesn't contain any.
// An alternative to doing this, is to use the .php file extension for
// any HTML file that has embedded PHP code, and the .html extension
// for static HTML files.
?>

<?php include 'header.php'; ?>

<div id="root">
   <form id="form" method="GET" action="result.php" onsubmit="return validate()">

        <div class="flex flex-wrap">
            <label for="URL" class="text-2xl ml-4 font-rubik self-center">URL</label>
            <span class="mandatory font-rubik self-center text-2xl">*</span>
            <span class="font-rubik self-center m-1 text-2xl">:</span>
            <div class="p-0.5 m-4 rounded-lg max-w-sm bg-gradient-to-r from-cyan-500 to-cyan-500 focus-within:from-rose-400 focus-within:via-fuchsia-500 focus-within:to-indigo-500 focus-within:caret-gray-600 focus-within:p-[3.2px]">
		<input type="text" name="url" id="URL" placeholder="https://example.com" required class="p-2 w-full rounded-lg focus:outline-none focus:shadow-lg focus:focus:shadow-black/50 text-center text-lg text-black font-bold">
            </div>
        </div>

        <div class="flex flex-wrap">
            <label for="labels" class="text-2xl ml-4 font-rubik self-center">GLink</label>
            <span class="mandatory font-rubik text-2xl self-center">*</span>
            <span class="font-rubik self-center m-1 text-2xl">:</span>
            <label for="GLink" id="labels" class=" ml-2 glink text-center text-xl self-center">glink.zip/</label>
            <div class="p-0.5 ml-2 mr-4 my-4 rounded-lg max-w-sm bg-gradient-to-r from-cyan-500 to-cyan-500 focus-within:from-rose-400 focus-within:via-fuchsia-500 focus-within:to-indigo-500 focus-within:caret-gray-600 focus-within:p-[3.2px]">
                <input type="text" name="glink" id="GLink" class="glink p-2 w-full rounded-lg focus:outline-none focus:shadow-lg focus:focus:shadow-black/50 text-center text-lg text-black font-bold" placeholder="exampleWebsite">
            </div>
        </div>

        <label for="restricted" class="ml-4 self-center text-2xl font-rubik">Geo-restricted? : </label><input type="checkbox" name="restricted" id="restricted" class="ml-2 mr-4 my-4 text-center font-rubik ease-soft rounded-1.4 w-6 h-6 cursor-pointer checked:accent-blue-700 shadow-lg shadow-black/50 peer"><span id="loadingText" class="font-rubik self-center text-center text-xl" style="position: relative; left: 20px;"></span>

        <span class="flex flex-wrap invisible peer-checked:visible" id="js-enabled">
            <label for="radiusSelect" id="radius_label" class="ml-4 font-rubik text-2xl self-center">Radius</label><span id="mandatory-radius" class="mandatory font-rubik text-2xl self-center">*</span><span class="font-rubik self-center m-1 text-2xl">:</span>
            <div class="p-0.5 ml-2 mr-4 my-4 rounded-lg max-w-sm bg-gradient-to-r from-cyan-500 to-cyan-500 focus-within:from-rose-400 focus-within:via-fuchsia-500 focus-within:to-indigo-500 focus-within:p-[3.2px]">
                <select name="radius" id="radius" class="cursor-pointer text-lg p-2 w-full rounded-lg focus:outline-none invalid:text-gray-400 font-bold">
                    <option value="" selected disabled hidden>Choose a radius for your geo link</option>
                    <option value="5">5 mi</option>
                    <option value="10">10 mi</option>
                    <option value="15">15 mi</option>
                    <option value="20">20 mi</option>
                </select>
            </div>
        </span>
        <noscript>
            <style>
                #js-enabled {display: none;}
            </style>
        </noscript>
        <span role="alert" class="m-4 font-rubik" id="error" aria-hidden="true">Invalid entry</span>
        <input type="submit" id="button" value="Zip It!" class="scale-125 brightness-125 ml-20 font-rubik bg-gradient-to-r from-cyan-500 to-blue-500 hover:from-cyan-400 hover:to-blue-400 hover:shadow-lg hover:shadow-black/50 transition hover:-translate-y-1 hover:scale-150 duration-600 ease-in-out rounded-full cursor-pointer">
        <input type="hidden" name="latitude" id="latitude">
        <input type="hidden" name="longitude" id="longitude">

    </form>
    <hr>
    <img src="./cat.gif">
    <p id="footer" class="object-none object-bottom">Insert Footer Here</p>
    <script src="./index.js"></script>

</div>
</body>
</html>
