v3.0.0.2
FlatlyPage
- <?php
- $isCli = PHP_SAPI === 'cli';
- if ($isCli) {
- $_SERVER['HTTP_HOST'] ??= 'localhost';
- $_SERVER['SERVER_PORT'] ??= 80;
- $_SERVER['SCRIPT_NAME'] = '/cron-update.php';
- }
-
- require_once __DIR__ . '/config.php';
- require_once __DIR__ . '/admin/updater-lib.php';
-
- if (!$isCli) {
- header('Content-Type: text/plain; charset=utf-8');
- header('Cache-Control: no-store');
- header('X-Robots-Tag: noindex, nofollow');
-
- $token = (string) ($_GET['token'] ?? $_POST['token'] ?? '');
- if (!Updater::enabled() || !Updater::autoUpdate() || $token === '' || !hash_equals(Updater::cronToken(), $token)) {
- http_response_code(403);
- exit("Forbidden.\n");
- }
- session_write_close();
- }
-
- ignore_user_abort(true);
- @set_time_limit(600);
-
- $result = Updater::runAutomatic();
-
- if (!$isCli) {
- http_response_code($result['ok'] ? 200 : 500);
- }
- echo '[' . date('c') . '] ' . $result['message'] . "\n";
-
- if ($isCli) {
- exit($result['ok'] ? 0 : 1);
- }
-