diff --git a/cli.php b/cli.php index 69ac2f1..8e239d1 100644 --- a/cli.php +++ b/cli.php @@ -38,7 +38,7 @@ function connectDatabase() { } function printHelp() { - + // TODO: help } function handleDatabase($argv) { @@ -155,6 +155,31 @@ function handleDatabase($argv) { proc_close($process); } + } else { + die("Usage: cli.php db [options...]"); + } +} + +function onMaintenance($argv) { + $action = $argv[2] ?? "status"; + $maintenanceFile = "MAINTENANCE"; + $isMaintenanceEnabled = file_exists($maintenanceFile); + + if ($action === "status") { + die("Maintenance: " . ($isMaintenanceEnabled ? "on" : "off") . "\n"); + } else if ($action === "on") { + $file = fopen($maintenanceFile, 'w') or die("Unable to create maintenance file\n"); + fclose($file); + die("Maintenance enabled\n"); + } else if ($action === "off") { + if (file_exists($maintenanceFile)) { + if (!unlink($maintenanceFile)) { + die("Unable to delete maintenance file\n"); + } + } + die("Maintenance disabled\n"); + } else { + die("Usage: cli.php maintenance \n"); } } @@ -172,6 +197,10 @@ switch ($command) { handleDatabase($argv); break; case 'routes': + // TODO: routes + break; + case 'maintenance': + onMaintenance($argv); break; default: echo "Unknown command '$command'\n\n"; diff --git a/img/maintenance.png b/img/maintenance.png new file mode 100644 index 0000000..7ca3c03 Binary files /dev/null and b/img/maintenance.png differ diff --git a/index.php b/index.php index 7830ffc..6bb4965 100644 --- a/index.php +++ b/index.php @@ -1,14 +1,21 @@ false, "msg" => "Configuration directory is not readable, check permissions before proceeding." ))); diff --git a/static/maintenance.html b/static/maintenance.html new file mode 100644 index 0000000..d954309 --- /dev/null +++ b/static/maintenance.html @@ -0,0 +1,36 @@ + + + + + + + + Maintenance + + + + + +
+
+
+
+

Service unavailable

+

Temporarily down for maintenance

+
+

+ Sorry for the inconvenience but we're performing some maintenance at the moment. + we'll be back online shortly! +

+
+ + Retry + +
+
+
+ [maintenance] +
+
+
+ \ No newline at end of file