| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- require dirname(__DIR__) . '/app/bootstrap.php';
- auth_require();
- // Hosting without cron: the client creates a backup once
- // MANAGE_BACKUP_AUTO_INTERVAL_SECONDS has passed and returns immediately
- // otherwise, so this is the dashboard's cost for having backups at all. Off by
- // default (interval 0) because cron is the better place for it — see
- // manage-client/config.sample.php.
- //
- // Only with a config.php present: without one the client would fall back to its
- // own defaults and start writing weekly backups nobody asked for. A backup that
- // fails must never cost the operator the dashboard.
- if (is_file(APP_ROOT . '/manage-client/config.php')) {
- require_once APP_ROOT . '/manage-client/lib/client.php';
- try {
- manageBackupCreateAutomaticIfDue();
- } catch (Throwable $e) {
- error_log('Automatic backup failed: ' . $e->getMessage());
- }
- }
- $site = site_get();
- $galleries = galleries_all();
- $active = count(array_filter($galleries, fn($g) => !gallery_is_expired($g)));
- $stats = array_map(fn($g) => gallery_stats($g['slug']), $galleries);
- $views = array_sum(array_column($stats, 'views'));
- $downloads = array_sum(array_column($stats, 'downloads'));
- // Computed from the galleries already loaded above rather than by rescanning:
- // this is the page an operator lands on after an update, so it is where a
- // pending migration should announce itself.
- $pending = array_filter($galleries, fn($g) => migrate_pending_for($g) !== []);
- admin_header('Dashboard');
- flash_render();
- ?>
- <h1>Dashboard</h1>
- <?php if ($pending !== []): ?>
- <div class="flash flash-error">
- <?= count($pending) ?> galler<?= count($pending) === 1 ? 'y needs' : 'ies need' ?>
- a one-time data migration after the last software update.
- <a href="migrate.php">Run it now →</a>
- </div>
- <?php endif; ?>
- <div class="card">
- <table>
- <tr><td>Showreel images</td><td><?= count($site['showreel'] ?? []) ?></td>
- <td><a href="showreel.php">Manage →</a></td></tr>
- <tr><td>Galleries</td><td><?= count($galleries) ?> (<?= $active ?> active)</td>
- <td><a href="galleries.php">Manage →</a></td></tr>
- <tr><td>Gallery views</td><td><?= $views ?></td>
- <td><a href="galleries.php">Per gallery →</a></td></tr>
- <tr><td>Archive downloads</td><td><?= $downloads ?></td>
- <td><a href="galleries.php">Per gallery →</a></td></tr>
- <tr><td>Front page</td><td><?= e($site['intro_title']) ?></td>
- <td><a href="frontpage.php">Edit →</a></td></tr>
- <tr><td>Data format</td>
- <td><?= $pending === [] ? 'up to date (v' . (int)SCHEMA_VERSION . ')' : count($pending) . ' pending' ?></td>
- <td><a href="migrate.php">Migration →</a></td></tr>
- <!-- Version from the constant, never from the manage server: the
- dashboard must not wait on a network call to render. -->
- <tr><td>Software version</td><td><?= e(APP_VERSION) ?></td>
- <td><a href="maintenance.php">Update & backup →</a></td></tr>
- </table>
- </div>
- <p class="help">
- Tip: create a gallery under <em>Galleries</em>, then share its link with your client.
- Password and expiry date are optional per gallery.
- </p>
- <?php admin_footer(); ?>
|