Files
itflow/includes/managed_blocked.php
johnnyq 3b5c11c552 Add managed mode, so one ITFlow can manage others - Admin > Managed Instances adds an instance and gives a one-time connection code (a week) that the other ITFlow pastes into the new Admin > Managed By, after which it checks in every minute from the new Manager Check-in cron job with a health report (versions, update waiting and whether it has security fixes, cron, last backup, errors today, agents against the seat limit, clients, storage) and takes back what the manager sets; the manager lists each instance's version, health, seats and last check-in with a page per instance showing what needs a look, its requests and everything it reported, can update it by hand or automatically after a set number of days (security releases straight away, not retried for six hours after a failure), set its seat limit and white-label key (locked on the instance while set), make it read-only (look, export and download only, across agents, portal, guest links and the API) or suspended (a notice with the manager's message and contact, 503 for the API) with other cron jobs paused until it is active again, sign in to it as support through a signed one-time two-minute link into a two-hour session that takes no seat, can't open the vault and can't set passwords or make API keys, and remove it, while the new Managed Instances job notifies when one stops checking in and closes requests never answered; instances only call the manager, can disconnect unless config.php sets $config_manager_required, and the Update page and queue_update defer to the manager; database 3.5.8 adds managed_instances, managed_instance_commands, settings.config_manager_keys and settings.config_managed, the logic is in the new functions/managed.php with api/managed/enroll.php, api/managed/checkin.php, login_support.php and includes/managed_blocked.php, cronJobClaim() takes a paused reason that leaves a due job due, getAgentUserLimit() and getActiveAgentUserCount() honour the manager's limit and leave out the support user, the vault helpers read a missing session key as empty, the audit log knows the new types and actions, and the email parser no longer logs an App Logs error every minute while parsing is switched off; changelog updated
2026-11-05 15:22:41 -05:00

79 lines
4.0 KiB
PHP

<?php
/*
* The page a managed instance shows in place of what was asked for - suspended by its manager,
* or (for someone with no session to carry a message back) a change turned away while it's
* read-only. Shown by managedRequestGuard() (functions/managed.php), which sets:
*
* $managed_blocked_title the heading
* $managed_blocked_message what the manager says, or a plain notice
* $managed_blocked_contact how to reach the manager - its email and phone
* $managed_blocked_signout where signing out goes, '' when nobody is signed in
* $managed_blocked_back where going back goes (read-only), '' for no way back
*
* Standalone - nothing here may need a session, settings beyond the company, or the layout.
*/
isset($mysqli) || die("Direct file access is not allowed");
$managed_blocked_company = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT company_name, company_logo FROM companies WHERE company_id = 1")) ?: [];
$managed_blocked_name = (string) ($managed_blocked_company['company_name'] ?? 'ITFlow');
$managed_blocked_logo = (string) ($managed_blocked_company['company_logo'] ?? '');
header('Cache-Control: no-store');
header('Content-Type: text/html; charset=UTF-8');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?= escapeHtml($managed_blocked_name) ?> | <?= escapeHtml($managed_blocked_title) ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex">
<link rel="stylesheet" href="/libs/fontawesome-free/css/all.min.css">
<?php if (file_exists(__DIR__ . '/../uploads/favicon.ico')) { ?>
<link rel="icon" type="image/x-icon" href="/uploads/favicon.ico">
<?php } ?>
<link rel="stylesheet" href="/libs/adminlte/css/adminlte.min.css">
<link rel="stylesheet" href="/css/itflow_custom.css">
</head>
<body class="hold-transition login-page">
<div class="login-box" style="width: min(30rem, 100% - 2rem)">
<div class="login-logo">
<?php if ($managed_blocked_logo !== '') { ?>
<img alt="<?= escapeHtml($managed_blocked_name) ?> logo" height="110" width="380" class="img-fluid" src="/uploads/settings/<?= escapeHtml($managed_blocked_logo) ?>">
<?php } else { ?>
<?= escapeHtml($managed_blocked_name) ?>
<?php } ?>
</div>
<div class="card" data-managed-blocked>
<div class="card-body p-4 text-center">
<span class="d-inline-flex align-items-center justify-content-center rounded-circle bg-<?= $managed_blocked_back !== '' ? 'warning' : 'danger' ?>-subtle text-<?= $managed_blocked_back !== '' ? 'warning' : 'danger' ?>-emphasis mb-3" style="width: 3.5rem; height: 3.5rem; font-size: 1.5rem" aria-hidden="true">
<i class="fas fa-<?= $managed_blocked_back !== '' ? 'lock' : 'ban' ?>"></i>
</span>
<h1 class="h4 mb-2"><?= escapeHtml($managed_blocked_title) ?></h1>
<p class="mb-0 text-body-secondary" style="white-space: pre-line"><?= escapeHtml($managed_blocked_message) ?></p>
<?php if ($managed_blocked_contact !== '') { ?>
<p class="mt-3 mb-0 small"><i class="fas fa-fw fa-headset me-1 text-body-secondary"></i><?= escapeHtml($managed_blocked_contact) ?></p>
<?php } ?>
<?php if ($managed_blocked_back !== '' || $managed_blocked_signout !== '') { ?>
<div class="d-flex flex-wrap justify-content-center gap-2 mt-4">
<?php if ($managed_blocked_back !== '') { ?>
<a href="<?= escapeHtml($managed_blocked_back) ?>" class="btn btn-light"><i class="fas fa-fw fa-arrow-left me-2"></i>Go back</a>
<?php } ?>
<?php if ($managed_blocked_signout !== '') { ?>
<a href="<?= escapeHtml($managed_blocked_signout) ?>" class="btn btn-outline-secondary"><i class="fas fa-fw fa-sign-out-alt me-2"></i>Sign out</a>
<?php } ?>
</div>
<?php } ?>
</div>
</div>
</div>
</body>
</html>