Skip to content

Commit cd70ce6

Browse files
Merge PR #2
Add "type" url-parameter. values: "raw", "check"
2 parents a1e891a + 01c5b6c commit cd70ce6

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
return [
4-
'version' => 'v1.1.0',
4+
'version' => 'v1.2.0',
55
'services' => [
66
[
77
'address' => 'https://mtex.dev',
@@ -29,7 +29,7 @@
2929
'name' => 'GimySite',
3030
'description' => 'Free static website hosting for modern developers.',
3131
'github' => 'https://github.com/MTEX-dev/gimy.site',
32-
'is_deployed' => true,
32+
'is_deployed' => false,
3333
],
3434
[
3535
'address' => 'https://getmy.name',

index.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

index.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
11
<?php
22
date_default_timezone_set('Europe/Berlin');
33
$config = require 'config.php';
4+
5+
if (isset($_GET['type'])) {
6+
$type = strtolower($_GET['type']);
7+
if ($type === 'raw') {
8+
header('Content-Type: application/json');
9+
echo json_encode($config['services']);
10+
exit();
11+
}
12+
if ($type === 'check') {
13+
header('Content-Type: application/json');
14+
$all_online = true;
15+
foreach ($config['services'] as $service) {
16+
if ($service['is_deployed']) {
17+
$ch = curl_init($service['address']);
18+
curl_setopt($ch, CURLOPT_NOBODY, true);
19+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
20+
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
21+
curl_exec($ch);
22+
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
23+
curl_close($ch);
24+
if ($code < 200 || $code >= 400) {
25+
$all_online = false;
26+
break;
27+
}
28+
}
29+
}
30+
echo json_encode(['operational' => $all_online]);
31+
exit();
32+
}
33+
}
434
?>
535
<!DOCTYPE html>
636
<html lang="en">
@@ -101,7 +131,9 @@ function updateUI(card, dot, label, stateKey, colorClass, borderClass) {
101131
}
102132

103133
function checkAllServices() {
104-
document.getElementById('last-update').textContent = `Live · Updated ${new RegExp(/\d{2}:\d{2}:\d{2}/).exec(new Date().toString())[0]}`;
134+
const now = new Date();
135+
const timeString = now.toLocaleTimeString('de-DE', { hour: '2-digit', minute: '2-digit', second: '2-digit' });
136+
document.getElementById('last-update').textContent = `Live · Updated ${timeString}`;
105137
document.querySelectorAll('.service-card').forEach(checkService);
106138
}
107139

0 commit comments

Comments
 (0)