Initial commit

This commit is contained in:
2026-07-08 22:36:54 +02:00
commit 08f7d9c6a9
13 changed files with 414 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
<?php
function timestamp_in_words($timestamp) {
if (!is_numeric($timestamp) || $timestamp < 0) {
return "";
}
$seconds = time() - $timestamp;
$future = $seconds < 0;
$seconds = abs($seconds);
$minutes = round($seconds / 60);
$hours = round($seconds / 3600);
$days = round($seconds / 86400);
$months = round($seconds / 2592000);
$years = round($seconds / 31536000);
if ($seconds < 60) { $w = 'less than a minute'; }
elseif ($seconds < 90) { $w = 'about a minute'; }
elseif ($minutes < 50) { $w = "$minutes minutes"; }
elseif ($hours < 2) { $w = 'about an hour'; }
elseif ($hours < 24) { $w = "$hours hours"; }
elseif ($days < 2) { $w = 'a day'; }
elseif ($days < 30) { $w = "$days days"; }
elseif ($days < 45) { $w = 'about a month'; }
elseif ($days < 365) { $w = "$months months"; }
elseif ($years < 2) { $w = 'about a year'; }
else { $w = "$years years"; }
return $future ? "$w from now" : "$w ago";
}
function guess_os() {
$os_guess = 'linux';
$user_agent = $_SERVER['HTTP_USER_AGENT'] ?? '';
if (stripos($user_agent, 'Android') !== false) {}
elseif (stripos($user_agent, 'iPhone') !== false) {}
elseif (stripos($user_agent, 'iPad') !== false) {}
elseif (stripos($user_agent, 'CrOS') !== false) { $os_guess = 'linux'; }
elseif (stripos($user_agent, 'Windows') !== false) { $os_guess = 'windows'; }
elseif (stripos($user_agent, 'Macintosh') !== false) {}
elseif (stripos($user_agent, 'Linux') !== false) { $os_guess = 'linux'; }
elseif (stripos($user_agent, 'FreeBSD') !== false) {}
return $os_guess;
}