<?php
session_start();

// Get user agent
$userAgent = $_SERVER['HTTP_USER_AGENT'];

// Check for various devices
$isIphone = strpos($userAgent, "iPhone") !== false;
$isAndroid = strpos($userAgent, "Android") !== false;
$isWebOS = strpos($userAgent, "webOS") !== false;
$isBlackBerry = strpos($userAgent, "BlackBerry") !== false;
$isIPod = strpos($userAgent, "iPod") !== false;
$isMac = strpos($userAgent, "Macintosh") !== false;
$isIPad = strpos($userAgent, "iPad") !== false;
$isWindows = strpos($userAgent, "Windows") !== false;

// For local testing (localhost), bypass device check
if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1' || $_SERVER['REMOTE_ADDR'] == '::1') {
    // Allow access on localhost
    header('Location: main.php');
    exit;
}

// Check if it's a Windows device
if ($isWindows) {
    // Allow access
    header('Location: main.php');
    exit;
} else {
    // Redirect non-Windows devices to error page
    header('Location: Device-error.php');
    exit;
}
?>