from textwrap import dedent
import os, zipfile
html = dedent("""
UAE Live Conflict Map
UAE Live Conflict Map
Server-side version for Hostinger. It shows fallback markers immediately, then loads live data through a same-origin PHP proxy.
Newest events are shown first.
Idle
Loaded
0
Mapped
0
New
0
Last update
—
Severity
Attack / hit / damage
Intercept / explosion / alert
Debris / wreckage / fallout
General report / low confidence
Recent mapped events
Ready
""")
php = dedent(""" false, 'error' => $message], JSON_UNESCAPED_SLASHES);
exit;
}
$source = $_GET['source'] ?? 'gdelt';
if ($source !== 'gdelt') {
fail(400, 'Unsupported source');
}
$query = '(missile OR drone OR debris OR intercept OR explosion OR strike) AND (UAE OR "United Arab Emirates" OR Dubai OR Abu Dhabi OR Sharjah)';
$url = 'https://api.gdeltproject.org/api/v2/doc/doc?query=' . rawurlencode($query) . '&mode=ArtList&maxrecords=100&format=json&sort=DateDesc';
if (!function_exists('curl_init')) {
fail(500, 'cURL is not enabled on this hosting environment');
}
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_TIMEOUT => 12,
CURLOPT_CONNECTTIMEOUT => 8,
CURLOPT_USERAGENT => 'JaitraNivesh-UAE-Map/1.0',
CURLOPT_HTTPHEADER => ['Accept: application/json']
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
if ($response === false) {
fail(502, 'Proxy fetch failed: ' . $error);
}
if ($httpCode < 200 || $httpCode >= 300) {
fail(502, 'Upstream returned HTTP ' . $httpCode);
}
$data = json_decode($response, true);
if (!is_array($data)) {
fail(502, 'Invalid JSON from upstream');
}
echo json_encode([
'ok' => true,
'source' => 'gdelt',
'fetched_at' => gmdate('c'),
'articles' => $data['articles'] ?? []
], JSON_UNESCAPED_SLASHES);
""")
base = "/mnt/data/uae_hostinger_fix"
os.makedirs(base, exist_ok=True)
with open(os.path.join(base, "index.html"), "w", encoding="utf-8") as f:
f.write(html)
with open(os.path.join(base, "proxy.php"), "w", encoding="utf-8") as f:
f.write(php)
zip_path = "/mnt/data/uae_hostinger_fix.zip"
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as z:
z.write(os.path.join(base, "index.html"), arcname="index.html")
z.write(os.path.join(base, "proxy.php"), arcname="proxy.php")
print(zip_path)
print(os.path.join(base, "index.html"))
print(os.path.join(base, "proxy.php"))