0,
'path' => '/',
'secure' => !empty($_SERVER['HTTPS']),
'httponly' => true,
'samesite' => 'Lax',
]);
session_name('cloudspace_sid');
session_start();
}
/* ────────────────────── SECURITY HEADERS ────────────────────── */
if (!headers_sent() && PHP_SAPI !== 'cli') {
header_remove('X-Powered-By');
header('X-Content-Type-Options: nosniff');
header('X-Frame-Options: SAMEORIGIN');
header('Referrer-Policy: no-referrer');
header('Permissions-Policy: geolocation=(), microphone=(), camera=()');
}
/* ══════════════════════════════════════════════════════════════════
DEVICE CATALOG — Real viewport sizes + real User-Agent strings
══════════════════════════════════════════════════════════════════ */
$DEVICES = [
/* ───────────── ANDROID ───────────── */
'pixel_8_pro' => [
'brand' => 'Google', 'model' => 'Pixel 8 Pro', 'icon' => '📱',
'os' => 'Android 14', 'w' => 412, 'h' => 915, 'r' => 44, 'notch' => 'punch',
'ua' => 'Mozilla/5.0 (Linux; Android 14; Pixel 8 Pro) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36',
'tag' => 'Chrome 120',
],
'pixel_8' => [
'brand' => 'Google', 'model' => 'Pixel 8', 'icon' => '📱',
'os' => 'Android 14', 'w' => 412, 'h' => 870, 'r' => 44, 'notch' => 'punch',
'ua' => 'Mozilla/5.0 (Linux; Android 14; Pixel 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36',
'tag' => 'Chrome 120',
],
'pixel_7' => [
'brand' => 'Google', 'model' => 'Pixel 7', 'icon' => '📱',
'os' => 'Android 13', 'w' => 412, 'h' => 890, 'r' => 38, 'notch' => 'punch',
'ua' => 'Mozilla/5.0 (Linux; Android 13; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.36',
'tag' => 'Chrome 119',
],
'pixel_tablet' => [
'brand' => 'Google', 'model' => 'Pixel Tablet', 'icon' => '📟',
'os' => 'Android 14', 'w' => 800, 'h' => 1280, 'r' => 22, 'notch' => 'bezel',
'ua' => 'Mozilla/5.0 (Linux; Android 14; Pixel Tablet) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'tag' => 'Chrome 120',
],
'galaxy_s24_ultra' => [
'brand' => 'Samsung', 'model' => 'Galaxy S24 Ultra', 'icon' => '📱',
'os' => 'Android 14', 'w' => 412, 'h' => 915, 'r' => 32, 'notch' => 'punch',
'ua' => 'Mozilla/5.0 (Linux; Android 14; SM-S928B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36',
'tag' => 'Chrome 120',
],
'galaxy_s23' => [
'brand' => 'Samsung', 'model' => 'Galaxy S23', 'icon' => '📱',
'os' => 'Android 13', 'w' => 384, 'h' => 854, 'r' => 32, 'notch' => 'punch',
'ua' => 'Mozilla/5.0 (Linux; Android 13; SM-S911B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36',
'tag' => 'Chrome 120',
],
'galaxy_a54' => [
'brand' => 'Samsung', 'model' => 'Galaxy A54', 'icon' => '📱',
'os' => 'Android 14', 'w' => 412, 'h' => 892, 'r' => 28, 'notch' => 'punch',
'ua' => 'Mozilla/5.0 (Linux; Android 14; SM-A546B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36',
'tag' => 'Chrome 120',
],
'oneplus_12' => [
'brand' => 'OnePlus', 'model' => 'OnePlus 12', 'icon' => '📱',
'os' => 'Android 14', 'w' => 412, 'h' => 906, 'r' => 36, 'notch' => 'punch',
'ua' => 'Mozilla/5.0 (Linux; Android 14; CPH2581) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36',
'tag' => 'Chrome 120',
],
'xiaomi_14' => [
'brand' => 'Xiaomi', 'model' => 'Xiaomi 14 Pro', 'icon' => '📱',
'os' => 'Android 14', 'w' => 412, 'h' => 916, 'r' => 34, 'notch' => 'punch',
'ua' => 'Mozilla/5.0 (Linux; Android 14; 23116PN5BC) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36',
'tag' => 'Chrome 120',
],
'nothing_phone_2' => [
'brand' => 'Nothing', 'model' => 'Phone (2)', 'icon' => '📱',
'os' => 'Android 14', 'w' => 412, 'h' => 919, 'r' => 36, 'notch' => 'punch',
'ua' => 'Mozilla/5.0 (Linux; Android 14; A065) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36',
'tag' => 'Chrome 120',
],
/* ───────────── iOS ───────────── */
'iphone_15_pro_max' => [
'brand' => 'Apple', 'model' => 'iPhone 15 Pro Max', 'icon' => '🍎',
'os' => 'iOS 17', 'w' => 430, 'h' => 932, 'r' => 50, 'notch' => 'dynamic',
'ua' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1',
'tag' => 'Safari 17',
],
'iphone_15' => [
'brand' => 'Apple', 'model' => 'iPhone 15', 'icon' => '🍎',
'os' => 'iOS 17', 'w' => 393, 'h' => 852, 'r' => 50, 'notch' => 'dynamic',
'ua' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1',
'tag' => 'Safari 17',
],
'iphone_14' => [
'brand' => 'Apple', 'model' => 'iPhone 14 Pro', 'icon' => '🍎',
'os' => 'iOS 16', 'w' => 393, 'h' => 852, 'r' => 50, 'notch' => 'dynamic',
'ua' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Mobile/15E148 Safari/604.1',
'tag' => 'Safari 16',
],
'iphone_se' => [
'brand' => 'Apple', 'model' => 'iPhone SE (3rd)', 'icon' => '🍎',
'os' => 'iOS 17', 'w' => 375, 'h' => 667, 'r' => 18, 'notch' => 'bezel',
'ua' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1',
'tag' => 'Safari 17',
],
'ipad_pro' => [
'brand' => 'Apple', 'model' => 'iPad Pro 12.9"', 'icon' => '📟',
'os' => 'iPadOS 17', 'w' => 1024, 'h' => 1366, 'r' => 18, 'notch' => 'bezel',
'ua' => 'Mozilla/5.0 (iPad; CPU OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1',
'tag' => 'Safari 17',
],
/* ───────────── DESKTOP ───────────── */
'macbook_air' => [
'brand' => 'Apple', 'model' => 'MacBook Air 13"', 'icon' => '💻',
'os' => 'macOS Sonoma', 'w' => 1280, 'h' => 832, 'r' => 10, 'notch' => 'none', 'desktop' => true,
'ua' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15',
'tag' => 'Safari 17',
],
'windows_11' => [
'brand' => 'Microsoft', 'model' => 'Windows 11 Desktop', 'icon' => '🖥️',
'os' => 'Windows 11', 'w' => 1366, 'h' => 768, 'r' => 10, 'notch' => 'none', 'desktop' => true,
'ua' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'tag' => 'Chrome 120',
],
'windows_10' => [
'brand' => 'Microsoft', 'model' => 'Windows 10 Desktop', 'icon' => '🖥️',
'os' => 'Windows 10', 'w' => 1366, 'h' => 768, 'r' => 10, 'notch' => 'none', 'desktop' => true,
'ua' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'tag' => 'Chrome 120',
],
'ubuntu_desktop' => [
'brand' => 'Canonical', 'model' => 'Ubuntu 24.04 Desktop', 'icon' => '🐧',
'os' => 'Linux', 'w' => 1366, 'h' => 768, 'r' => 10, 'notch' => 'none', 'desktop' => true,
'ua' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'tag' => 'Chrome 120',
],
'chromeos_flex' => [
'brand' => 'Google', 'model' => 'ChromeOS Flex', 'icon' => '🌐',
'os' => 'ChromeOS', 'w' => 1366, 'h' => 768, 'r' => 10, 'notch' => 'none', 'desktop' => true,
'ua' => 'Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'tag' => 'Chrome 120',
],
];
/* ══════════════════════════════════════════════════════════════════
HELPER FUNCTIONS
══════════════════════════════════════════════════════════════════ */
/**
* HTML-escape a string safely.
*/
function e($s): string {
return htmlspecialchars((string)$s, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
}
/**
* Normalize user-supplied URL: if no scheme, try to build one.
* Falls back to Google search for freeform text.
*/
function normalize_url(string $input): string {
$input = trim($input);
if ($input === '') return '';
if (preg_match('#^https?://#i', $input)) return $input;
if (preg_match('#^[\w.-]+\.[a-z]{2,}([/?#]|$)#i', $input)) return 'https://' . $input;
return 'https://www.google.com/search?q=' . urlencode($input);
}
/**
* Extract the domain for display purposes.
*/
function display_host(string $url): string {
$h = parse_url($url, PHP_URL_HOST);
if (!$h) return $url;
return preg_replace('/^www\./i', '', $h);
}
/* ══════════════════════════════════════════════════════════════════
REQUEST HANDLING
══════════════════════════════════════════════════════════════════ */
/* ---- Device selection ---- */
$deviceKey = $_POST['device'] ?? $_GET['device'] ?? $_SESSION['device'] ?? 'pixel_8_pro';
if (!isset($DEVICES[$deviceKey])) $deviceKey = 'pixel_8_pro';
$_SESSION['device'] = $deviceKey;
$device = $DEVICES[$deviceKey];
/* ---- URL handling ---- */
$clear = isset($_POST['clear']) || isset($_GET['clear']);
$rawUrl = trim((string)($_POST['url'] ?? $_GET['url'] ?? ''));
if ($clear) {
$url = '';
unset($_SESSION['url']);
} elseif ($rawUrl !== '') {
$url = normalize_url($rawUrl);
$_SESSION['url'] = $url;
} else {
$url = (string)($_SESSION['url'] ?? '');
}
$hasUrl = ($url !== '');
$frameW = (int)$device['w'];
$frameH = (int)$device['h'];
/* ---- Grouped device list for the dropdown ---- */
$deviceGroups = [
'Android' => ['pixel_8_pro','pixel_8','pixel_7','pixel_tablet','galaxy_s24_ultra','galaxy_s23','galaxy_a54','oneplus_12','xiaomi_14','nothing_phone_2'],
'iOS / iPadOS' => ['iphone_15_pro_max','iphone_15','iphone_14','iphone_se','ipad_pro'],
'Desktop' => ['macbook_air','windows_11','windows_10','ubuntu_desktop','chromeos_flex'],
];
/* ---- Suggested URLs shown on the empty state ---- */
$suggestions = [
'https://example.com',
'https://www.wikipedia.org',
'https://httpbin.org/html',
'https://web.telegram.org/a/',
'https://www.google.com',
];
?>
CloudSpace — Device Emulation Platform
= e($device['brand'] . ' ' . $device['model']) ?>
= $hasUrl ? e(display_host($url)) : 'Ready — enter a URL to begin' ?>
—:—
5G
🌐
Enter a URL to begin
Type a web address above, or try one of these:
Some sites (Google, Telegram, Facebook) send X-Frame-Options and block embedding. Those will show a fallback "Open in new tab" button.
🔒
This site can't be embedded
The site sent X-Frame-Options: DENY or a restrictive Content-Security-Policy header, so it refuses to load inside a frame.