WebOrbiton
v3.0.0.2

FlatlyPage

38 lines · 969 B
  1. <?php
  2. $isCli = PHP_SAPI === 'cli';
  3. if ($isCli) {
  4. $_SERVER['HTTP_HOST'] ??= 'localhost';
  5. $_SERVER['SERVER_PORT'] ??= 80;
  6. $_SERVER['SCRIPT_NAME'] = '/cron-update.php';
  7. }
  8. ​
  9. require_once __DIR__ . '/config.php';
  10. require_once __DIR__ . '/admin/updater-lib.php';
  11. ​
  12. if (!$isCli) {
  13. header('Content-Type: text/plain; charset=utf-8');
  14. header('Cache-Control: no-store');
  15. header('X-Robots-Tag: noindex, nofollow');
  16. ​
  17. $token = (string) ($_GET['token'] ?? $_POST['token'] ?? '');
  18. if (!Updater::enabled() || !Updater::autoUpdate() || $token === '' || !hash_equals(Updater::cronToken(), $token)) {
  19. http_response_code(403);
  20. exit("Forbidden.\n");
  21. }
  22. session_write_close();
  23. }
  24. ​
  25. ignore_user_abort(true);
  26. @set_time_limit(600);
  27. ​
  28. $result = Updater::runAutomatic();
  29. ​
  30. if (!$isCli) {
  31. http_response_code($result['ok'] ? 200 : 500);
  32. }
  33. echo '[' . date('c') . '] ' . $result['message'] . "\n";
  34. ​
  35. if ($isCli) {
  36. exit($result['ok'] ? 0 : 1);
  37. }
  38. ​