asdasd
This commit is contained in:
@@ -37,13 +37,42 @@ $GLOBALS['app_base_url'] = APP_URL_PRIMARY;
|
|||||||
$GLOBALS['app_api_base'] = $apiBaseUrl;
|
$GLOBALS['app_api_base'] = $apiBaseUrl;
|
||||||
$GLOBALS['app_version'] = "{$mainversion}.{$subversion}.{$patchversion}";
|
$GLOBALS['app_version'] = "{$mainversion}.{$subversion}.{$patchversion}";
|
||||||
|
|
||||||
if (!function_exists('render_app_version_badge')) {
|
if (!function_exists('get_version_badge_markup')) {
|
||||||
function render_app_version_badge(): void
|
function get_version_badge_markup(): string
|
||||||
{
|
{
|
||||||
|
$version = $GLOBALS['app_version'] ?? null;
|
||||||
|
if (!$version || php_sapi_name() === 'cli') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
$versionText = htmlspecialchars((string)$version, ENT_QUOTES, 'UTF-8');
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
?>
|
||||||
|
<style>
|
||||||
|
.app-version-badge{position:fixed;right:12px;bottom:12px;z-index:2147483000;font-size:12px;font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#0f172a;background:rgba(248,250,252,.85);border:1px solid rgba(148,163,184,.6);border-radius:999px;padding:4px 10px;box-shadow:0 8px 20px rgba(15,23,42,.15);backdrop-filter:blur(6px);}
|
||||||
|
@media print {.app-version-badge{display:none}}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
(function(){
|
||||||
|
var prev=document.querySelector('.app-version-badge');
|
||||||
|
if(prev){prev.remove();}
|
||||||
|
var badge=document.createElement('div');
|
||||||
|
badge.className='app-version-badge';
|
||||||
|
badge.textContent='v <?= $versionText ?>';
|
||||||
|
var append=function(){document.body?document.body.appendChild(badge):document.addEventListener('DOMContentLoaded',function(){document.body.appendChild(badge);});};
|
||||||
|
if(window.requestAnimationFrame){requestAnimationFrame(append);}else{append();}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
return ob_get_clean() ?: '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!defined('APP_VERSION_BADGE_REGISTERED')) {
|
||||||
|
register_shutdown_function(function () {
|
||||||
if (php_sapi_name() === 'cli') {
|
if (php_sapi_name() === 'cli') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$headers = headers_list();
|
$headers = headers_list();
|
||||||
$isHtmlResponse = true;
|
$isHtmlResponse = true;
|
||||||
if (!headers_sent() && !empty($headers)) {
|
if (!headers_sent() && !empty($headers)) {
|
||||||
@@ -58,44 +87,10 @@ if (!function_exists('render_app_version_badge')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($isHtmlResponse) {
|
||||||
if (!$isHtmlResponse) {
|
echo get_version_badge_markup();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
static $badgeRendered = false;
|
|
||||||
if ($badgeRendered) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$badgeRendered = true;
|
|
||||||
|
|
||||||
$version = $GLOBALS['app_version'] ?? null;
|
|
||||||
if (!$version) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$versionText = htmlspecialchars((string)$version, ENT_QUOTES, 'UTF-8');
|
|
||||||
|
|
||||||
echo <<<HTML
|
|
||||||
<style>
|
|
||||||
.app-version-badge{position:fixed;right:12px;bottom:12px;z-index:2147483000;font-size:12px;font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#0f172a;background:rgba(248,250,252,.85);border:1px solid rgba(148,163,184,.6);border-radius:999px;padding:4px 10px;box-shadow:0 8px 20px rgba(15,23,42,.15);backdrop-filter:blur(6px);}
|
|
||||||
@media print {.app-version-badge{display:none}}
|
|
||||||
</style>
|
|
||||||
<script>
|
|
||||||
(function(){
|
|
||||||
var prev=document.querySelector('.app-version-badge');
|
|
||||||
if(prev){prev.remove();}
|
|
||||||
var badge=document.createElement('div');
|
|
||||||
badge.className='app-version-badge';
|
|
||||||
badge.textContent='v {$versionText}';
|
|
||||||
(window.requestAnimationFrame?requestAnimationFrame(function(){document.body?document.body.appendChild(badge):document.addEventListener('DOMContentLoaded',function(){document.body.appendChild(badge);});}):document.addEventListener('DOMContentLoaded',function(){document.body.appendChild(badge);}));
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
HTML;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!defined('APP_VERSION_BADGE_REGISTERED')) {
|
|
||||||
register_shutdown_function('render_app_version_badge');
|
|
||||||
define('APP_VERSION_BADGE_REGISTERED', true);
|
define('APP_VERSION_BADGE_REGISTERED', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user