<?php
session_start();
// ini_set('session.gc_maxlifetime', 30 * 60 * 60 * 60);

if ($_SESSION["dev"] != "") {
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
            <meta http-equiv="imagetoolbar" content="no" />
            <title>Administration Panel</title>
            <link media="screen" rel="stylesheet" type="text/css" href="css/admin.css"  />
            <script src="new/js/jquery-1.6.1.min.js"></script>  
            

            <script src="track.js"></script>
            <style>
                :root{
                    --mainThemeColor: #ed4d4d;
                    --secondThemeColor: #efc1c1;
                    --fontColor-1:black;
                    --tabColor: #3a3a37;
                    --tabTextColor: white;
                    --headerBgColor: #1f7458;
                }
            </style>
         
             
            <script language="javascript" type="text/javascript">

                /****************************************************
                 Author: Eric King
                 Url: http://redrival.com/eak/index.shtml
                 This script is free to use as long as this info is left in
                 Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
                 ****************************************************/
                var win = null;
                function NewWindow(mypage, myname, w, h, scroll, pos) {
                    if (pos == "random") {
                        LeftPosition = (screen.width) ? Math.floor(Math.random() * (screen.width - w)) : 100;
                        TopPosition = (screen.height) ? Math.floor(Math.random() * ((screen.height - h) - 75)) : 100;
                    }
                    if (pos == "center") {
                        LeftPosition = (screen.width) ? (screen.width - w) / 2 : 100;
                        TopPosition = (screen.height) ? (screen.height - h) / 2 : 100;
                    } else if ((pos != "center" && pos != "random") || pos == null) {
                        LeftPosition = 0;
                        TopPosition = 20
                    }
                    settings = 'width=' + w + ',height=' + h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
                    win = window.open(mypage, myname, settings);
                }
                // -->
            </script>

            <!--[if lte IE 6]><link media="screen" rel="stylesheet" type="text/css" href="css/admin-ie.css" /><![endif]-->
            <link rel="stylesheet" href="css/main.css">
        </head>

        <body>
            <!--[if !IE]>start wrapper<![endif]-->
            <div id="wrapper">
                <!--[if !IE]>start head<![endif]-->
                <div id="head">

                    <!--[if !IE]>start logo and user details<![endif]-->
                   
                     <?php  include('header.php');?>
                    <!--[if !IE]>end logo end user details<![endif]-->



                    <!--[if !IE]>start menus_wrapper<![endif]-->
                    <?php
                    include('menu_index.php');
                    ?>
                    <!--[if !IE]>end menus_wrapper<![endif]-->



                </div>
                <!--[if !IE]>end head<![endif]-->

                <!--[if !IE]>start content<![endif]-->

                <!--[if !IE]>end content<![endif]-->

            </div>
            <!--[if !IE]>end wrapper<![endif]-->
<!-- <div id="footer">
                
            </div>-->
            <!--[if !IE]>start footer<![endif]-->
           
<script src="js/location.js"></script>


            <?php
            //echo $_SERVER['SERVER_NAME'];
            if ($_SERVER['SERVER_NAME'] != "192.168.101.127") {
                ?>
                <!--[if !IE]>end footer<![endif]-->
                <script>
                        getLocation();
                </script>
                <?php
            }
            ?>
            
//              <script>
//      function getDistanceFromLatLon(lat1, lon1, lat2, lon2) {
//     const R = 6371e3; // Earth's radius in meters
//     const toRad = (deg) => deg * (Math.PI / 180);

//     const dLat = toRad(lat2 - lat1);
//     const dLon = toRad(lon2 - lon1);
//     const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
//               Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) *
//               Math.sin(dLon / 2) * Math.sin(dLon / 2);
//     const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));

//     return R * c; // Distance in meters
// }

// function checkUserLocation() {
//     const targetLat = 6.9337088;
//     const targetLon = 79.8621696;
//     const allowedRadius = 50; // 50 meters

//     if (navigator.geolocation) {
//         navigator.geolocation.getCurrentPosition(
//             (position) => {
//                 const userLat = position.coords.latitude;
//                 const userLon = position.coords.longitude;
//                 const distance = getDistanceFromLatLon(userLat, userLon, targetLat, targetLon);

//                 console.log(`User distance from target: ${distance.toFixed(2)} meters`);

//                 if (distance <= allowedRadius) {
//                     console.log("User is inside the allowed location. Access granted.");
//                 } else {
//                     console.warn("User is outside the allowed location. Redirecting...");
//                     window.location.href = "/error.html"; // Redirect to error page
//                 }
//             },
//             (error) => {
//                 console.error("Geolocation error:", error);
//                 alert("Location access is required. Please enable location services.");
//                 window.location.href = "/error.html"; // Redirect if location is not allowed
//             }
//         );
//     } else {
//         alert("Geolocation is not supported by your browser.");
//         window.location.href = "/error.html"; // Redirect if not supported
//     }
// }

// // Run the check when the page loads
// window.onload = checkUserLocation;

//     </script>

        </body>
    </html>
    <?php
} else {
    echo "Invalied User !!!";
}
?>

 