1<?php
2/**
3 * Maintenance Control Panel — theservice4u.com
4 * Access requires password in URL: ?pw=YOUR_PASSWORD
5 */
6
7define('CONTROL_PASSWORD', '7fd0cae74ce866bb');
8define('DB_FLAG_TABLE', 'tbl_maintenance_flag_s4u');
9
10// ── Password gate ─────────────────────────────────────────────────────────────
11$pw = $_GET['pw'] ?? $_POST['pw'] ?? '';
12if (!hash_equals(CONTROL_PASSWORD, $pw)) {
13 http_response_code(403);
14 die('<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Access Denied</title>
15<style>body{background:#0f1117;color:#fff;font-family:sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;}
16.box{background:#181c27;border:1px solid #e03131;border-radius:10px;padding:40px;text-align:center;}
17h2{color:#e03131;}p{color:#888;margin-top:10px;}
18input{padding:10px;border-radius:6px;border:1px solid #444;background:#0f1117;color:#fff;font-size:16px;width:260px;text-align:center;}
19button{margin-top:12px;padding:10px 30px;background:#e03131;color:#fff;border:none;border-radius:6px;cursor:pointer;font-weight:700;font-size:15px;display:block;width:100%;}
20</style></head><body>
21<div class="box"><h2>🔒 Access Denied</h2><p>Password required.</p>
22<form method="get"><input type="password" name="pw" placeholder="Enter password" autofocus/><button type="submit">Unlock</button></form>
23</div></body></html>');
24}
25
26// ── Boot WHMCS ────────────────────────────────────────────────────────────────
27define('WHMCS', true);
28require __DIR__ . '/init.php';
29use WHMCS\Database\Capsule;
30
31// ── Ensure flag table exists ──────────────────────────────────────────────────
32if (!Capsule::schema()->hasTable(DB_FLAG_TABLE)) {
33 Capsule::schema()->create(DB_FLAG_TABLE, function($table) {
34 $table->string('key')->primary();
35 $table->string('value');
36 $table->timestamp('updated_at');
37 });
38 Capsule::table(DB_FLAG_TABLE)->insert([
39 'key' => 'maintenance',
40 'value' => '0',
41 'updated_at' => date('Y-m-d H:i:s'),
42 ]);
43}
44
45// ── Handle toggle action ──────────────────────────────────────────────────────
46if (isset($_POST['toggle'])) {
47 $current = Capsule::table(DB_FLAG_TABLE)->where('key', 'maintenance')->value('value');
48 $new = $current === '1' ? '0' : '1';
49 Capsule::table(DB_FLAG_TABLE)->where('key', 'maintenance')->update([
50 'value' => $new,
51 'updated_at' => date('Y-m-d H:i:s'),
52 ]);
53 header('Location: ?pw=' . CONTROL_PASSWORD);
54 exit;
55}
56
57// ── Get current status ────────────────────────────────────────────────────────
58$status = Capsule::table(DB_FLAG_TABLE)->where('key', 'maintenance')->value('value');
59$isOn = $status === '1';
60$label = $isOn ? 'ON' : 'OFF';
61$color = $isOn ? '#e03131' : '#2f9e44';
62$btnLabel = $isOn ? '✅ Turn Off Maintenance' : '🔴 Turn On Maintenance';
63$btnColor = $isOn ? '#2f9e44' : '#e03131';
64$desc = $isOn
65 ? 'Support tickets are currently <strong style="color:#e03131;">BLOCKED</strong>. Clients see the maintenance page.'
66 : 'Support tickets are currently <strong style="color:#2f9e44;">OPEN</strong>. Clients can submit tickets normally.';
67
68echo <<<HTML
69<!DOCTYPE html>
70<html lang="en">
71<head>
72<meta charset="UTF-8"/>
73<meta name="viewport" content="width=device-width,initial-scale=1"/>
74<title>Maintenance Control — theservice4u.com</title>
75<style>
76 *{box-sizing:border-box;margin:0;padding:0;}
77 body{background:#0f1117;font-family:'Segoe UI',sans-serif;display:flex;align-items:center;justify-content:center;min-height:100vh;padding:20px;}
78 .card{background:#181c27;border:1px solid {$color};border-top:4px solid {$color};border-radius:10px;padding:40px;max-width:460px;width:100%;text-align:center;box-shadow:0 8px 40px rgba(0,0,0,0.4);}
79 h1{color:#fff;font-size:20px;margin-bottom:6px;}
80 .site{color:#666;font-size:13px;margin-bottom:30px;}
81 .status-badge{display:inline-block;padding:10px 28px;border-radius:999px;font-size:22px;font-weight:900;letter-spacing:.1em;margin-bottom:20px;}
82 .desc{color:#aab;font-size:14px;line-height:1.6;margin-bottom:30px;}
83 form button{width:100%;padding:14px;border:none;border-radius:8px;font-size:16px;font-weight:700;cursor:pointer;transition:opacity .15s;}
84 form button:hover{opacity:.85;}
85</style>
86</head>
87<body>
88<div class="card">
89 <h1>🛠 Maintenance Control</h1>
90 <div class="site">theservice4u.com</div>
91 <div class="status-badge" style="background:{$color}22;color:{$color};border:2px solid {$color};">{$label}</div>
92 <p class="desc">{$desc}</p>
93 <form method="post" action="?pw=7fd0cae74ce866bb">
94 <button type="submit" name="toggle" style="background:{$btnColor};color:#fff;">{$btnLabel}</button>
95 </form>
96</div>
97</body>
98</html>
99HTML;
100