diff options
Diffstat (limited to 'inc')
-rw-r--r-- | inc/taskmanagercallback.inc.php | 9 | ||||
-rw-r--r-- | inc/util.inc.php | 40 |
2 files changed, 49 insertions, 0 deletions
diff --git a/inc/taskmanagercallback.inc.php b/inc/taskmanagercallback.inc.php index c6b447c9..9f276020 100644 --- a/inc/taskmanagercallback.inc.php +++ b/inc/taskmanagercallback.inc.php @@ -240,4 +240,13 @@ class TaskmanagerCallback SystemStatus::setUpgradableData($task); } + public static function acmeErrors(array $task): void + { + $mod = Module::get('webinterface'); + if ($mod === false) + return; + $mod->activate(1, false); + Acme::callbackErrorCheck($task); + } + } diff --git a/inc/util.inc.php b/inc/util.inc.php index 0ff6fdad..ed0b40ae 100644 --- a/inc/util.inc.php +++ b/inc/util.inc.php @@ -471,4 +471,44 @@ class Util } } + public static function shouldRedirectDomain(): ?string + { + if ($_SERVER['HTTP_HOST'] === 'satellite.bwlehrpool') + return null; + if (!Property::get('webinterface.redirect-domain') || empty(Property::get('webinterface.https-domains'))) + return null; // Disabled, or unknown domain + $curDomain = $_SERVER['HTTP_HOST']; + if ($curDomain[-1] === '.') { + $curDomain = substr($curDomain, 0, -1); + } + $domains = explode(' ', Property::get('webinterface.https-domains')); + foreach ($domains as $domain) { + if ($domain === $curDomain) + return null; // MATCH + if (substr_compare($domain, '*.', 0, 2) === 0) { + if (substr($domain, 2) === $curDomain) + return null; // MATCH + $len = strlen($domain) - 1; + if (substr($curDomain, -$len) === substr($domain, 1)) + return null; // MATCH + } + } + // No match + return $domains[0]; + /* + $str = '//' . $domains[0] . '/' . $_SERVER['REQUEST_URI']; + if (!empty($_SERVER['QUERY_STRING'])) { + $str .= '?' . $_SERVER['QUERY_STRING']; + } + Header('Location: ' . $str); + exit; + */ + } + + public static function osUptime(): int + { + $a = file_get_contents('/proc/uptime'); + return (int)preg_replace('/[^0-9].*$/s', '', $a); + } + } |