v1.0.0.8
Publisium
- <?php
-
- declare(strict_types=1);
-
- if (PHP_SAPI !== 'cli') {
- http_response_code(403);
- exit('This script can only be run from the command line (cron).');
- }
-
- require_once __DIR__ . '/includes/config.php';
- require_once __DIR__ . '/includes/database.php';
- require_once __DIR__ . '/includes/activity-log.php';
- require_once __DIR__ . '/includes/updater.php';
-
- if (!Config::isInstalled()) {
- fwrite(STDERR, "Publisium is not installed.\n");
- exit(1);
- }
-
- if (Updater::lockedByConfig()) {
- fwrite(STDOUT, "The updater is disabled in the server configuration (UPDATER_DISABLED=1).\n");
- exit(0);
- }
-
- set_time_limit(600);
-
- try {
- $db = Database::site();
- $outcome = Updater::runAutomatic($db);
- } catch (Throwable $exception) {
- fwrite(STDERR, 'Automatic update failed: ' . $exception->getMessage() . "\n");
- exit(1);
- }
-
- if ($outcome['installed']) {
- ActivityLog::record('updater.auto_install', 'updater', null, $outcome['message'], true);
- }
-
- fwrite($outcome['ok'] ? STDOUT : STDERR, $outcome['message'] . "\n");
- exit($outcome['ok'] ? 0 : 1);
-