Compare commits

..
4 Commits
Author SHA1 Message Date
thayol b27aefd102 Add setup instructions to README 2026-08-09 16:21:47 +02:00
thayol 90cb617281 Remove tracked releases folder 2026-08-09 16:18:56 +02:00
thayol cb4bfc34b8 Make releases dir configurable 2026-08-09 16:18:20 +02:00
thayol 39ef494605 Collapse most files into index.php 2026-08-09 16:11:37 +02:00
8 changed files with 105 additions and 99 deletions
+1
View File
@@ -1,3 +1,4 @@
/online /online
/releases/* /releases/*
/releases
/config.php /config.php
+6
View File
@@ -3,3 +3,9 @@
The official Supercardinality website. The official Supercardinality website.
https://uncensored.hu/supercardinality/ https://uncensored.hu/supercardinality/
## Setup
Create the `config.php` file based on `config.php.example`.
Host the repo root using a PHP capable web server.
+5 -3
View File
@@ -1,6 +1,8 @@
<?php <?php
$contact_name = "Example Contact"; $contact_name = "Thayol"; // The contact name displayed on the page.
$contact_link = "https://example.com"; $contact_link = "mailto:thayol@uncensored.hu"; // Can be any type of link. This will be a href on the contact name.
$online_services_source_url = "https://example.com"; $online_services_source_url = "https://git.uncensored.hu/supercardinality/supercardinality-online"; // The URL to the online services source.
$releases_dir = "releases"; // The path to scan for releases.
-46
View File
@@ -1,46 +0,0 @@
<?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;
}
+93 -1
View File
@@ -1,4 +1,96 @@
<?php require "script.php"; ?> <?php
require "config.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;
}
$options = [
"linux" => [
"name" => "Linux",
"architecture" => "x86-64",
"download_path" => "",
"download_filename" => "supercardinality",
],
"windows" => [
"name" => "Windows",
"architecture" => "x86-64",
"download_path" => "",
"download_filename" => "supercardinality.exe",
],
];
$os_guess = guess_os();
$latest = json_decode(file_get_contents($releases_dir . '/latest.json'), true);
$version = empty($latest["version"]) ? "" : $latest["version"];
$version_timestamp = empty($latest["timestamp"]) ? -1 : $latest["timestamp"];
$version_timestamp_in_words = timestamp_in_words($version_timestamp);
if (!empty($latest["linux_path"])) {
$options["linux"]["download_path"] = $latest["linux_path"];
if (!str_contains($latest["linux_path"], "://")) {
$options["linux"]["download_path"] = $releases_dir . "/" . $options["linux"]["download_path"];
}
}
if (!empty($latest["windows_path"])) {
$options["windows"]["download_path"] = $latest["windows_path"];
if (!str_contains($latest["windows_path"], "://")) {
$options["windows"]["download_path"] = $releases_dir . "/" . $options["windows"]["download_path"];
}
}
$display_other_builds = false;
foreach($options as $os => $target) {
if (!empty($target["download_path"])) {
$display_other_builds = true;
}
}
?>
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
-16
View File
@@ -1,16 +0,0 @@
<?php
$options = [
"linux" => [
"name" => "Linux",
"architecture" => "x86-64",
"download_path" => "",
"download_filename" => "supercardinality",
],
"windows" => [
"name" => "Windows",
"architecture" => "x86-64",
"download_path" => "",
"download_filename" => "supercardinality.exe",
],
];
View File
-33
View File
@@ -1,33 +0,0 @@
<?php
require "config.php";
require "functions.php";
require "options.php";
$os_guess = guess_os();
$latest = json_decode(file_get_contents('releases/latest.json'), true);
$version = empty($latest["version"]) ? "" : $latest["version"];
$version_timestamp = empty($latest["timestamp"]) ? -1 : $latest["timestamp"];
$version_timestamp_in_words = timestamp_in_words($version_timestamp);
if (!empty($latest["linux_path"])) {
$options["linux"]["download_path"] = $latest["linux_path"];
if (!str_contains($latest["linux_path"], "://")) {
$options["linux"]["download_path"] = "releases/" . $options["linux"]["download_path"];
}
}
if (!empty($latest["windows_path"])) {
$options["windows"]["download_path"] = $latest["windows_path"];
if (!str_contains($latest["windows_path"], "://")) {
$options["windows"]["download_path"] = "releases/" . $options["windows"]["download_path"];
}
}
$display_other_builds = false;
foreach($options as $os => $target) {
if (!empty($target["download_path"])) {
$display_other_builds = true;
}
}