$lockaway = false; // Pages to exclude from lockaway $excluded_pages = ['page1.php', 'page2.php']; $current_page = basename($_SERVER['PHP_SELF']); $current_url = $_SERVER['REQUEST_URI']; // Exclude specific pages if (in_array($current_page, $excluded_pages)) { $lockaway = false; } // Exclude directories but not the files inside them if (substr($current_url, -1) === '/') { // If the URL ends with a slash, it indicates a directory $lockaway = false; } // Check if the user is logged in via cookie $cookie_name = "admin_logged_in"; if (!empty($_COOKIE[$cookie_name]) && $_COOKIE[$cookie_name] === "true") { $lockaway = false; } if ($lockaway) { include 'php-includes/lockaway.php'; exit; } session_start(); // start the session if (isset($_GET['action'])) { if ($_GET['action'] === 'hide') { $_SESSION['newsHidden'] = true; header('Location: ' . strtok($_SERVER['REQUEST_URI'], '?')); // Reload the page exit; } elseif ($_GET['action'] === 'show') { unset($_SESSION['newsHidden']); header('Location: ' . strtok($_SERVER['REQUEST_URI'], '?')); // Reload the page exit; } } // Set the time zone date_default_timezone_set('America/Chicago'); // Date and time variables $currentDate = date('l, F j'); $currentTime = date('H:i:s'); $currentDate2 = date('l, F j, Y'); $currentTime2 = date('h:i A'); // Automatically log in user if cookies are set if (isset($_COOKIE['username']) && isset($_COOKIE['user_token']) && !isset($_SESSION['signedin'])) { $username = $_COOKIE['username']; $user_token = $_COOKIE['user_token']; // Validate the user by checking the cookies and token require_once "acc-config.php"; // Include your database connection config $stmt = $link2->prepare("SELECT id, user_name FROM users WHERE user_name = ?"); $stmt->bind_param("s", $username); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows > 0) { if ($row = $result->fetch_assoc()) { // Validate the token (this part may require a more secure approach depending on your use case) $_SESSION["signedin"] = true; $_SESSION["id"] = $row['id']; $_SESSION["username"] = htmlspecialchars($username, ENT_QUOTES, 'UTF-8'); // Sanitize the username session_regenerate_id(true); // Regenerate session ID to prevent session fixation } } $stmt->close(); } function isOldFlipPhone() { $oldFlipPhoneKeywords = [ 'Nokia', 'SonyEricsson', 'Motorola', 'Samsung', 'LG', 'Sanyo', 'Alcatel', 'Kyocera', 'BlackBerry', 'Palm', 'Symbian', 'MIDP' ]; $userAgent = $_SERVER['HTTP_USER_AGENT'] ?? ''; foreach ($oldFlipPhoneKeywords as $keyword) { if (stripos($userAgent, $keyword) !== false) { return true; } } return false; } ?>