router.php 851 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * @package Grav\Core
  4. *
  5. * @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. if (PHP_SAPI !== 'cli-server') {
  9. die('This script cannot be run from browser. Run it from a CLI.');
  10. }
  11. $_SERVER['PHP_CLI_ROUTER'] = true;
  12. if (is_file($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $_SERVER['SCRIPT_NAME'])) {
  13. return false;
  14. }
  15. $_SERVER = array_merge($_SERVER, $_ENV);
  16. $_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'index.php';
  17. $_SERVER['SCRIPT_NAME'] = DIRECTORY_SEPARATOR . 'index.php';
  18. $_SERVER['PHP_SELF'] = DIRECTORY_SEPARATOR . 'index.php';
  19. error_log(sprintf('%s:%d [%d]: %s', $_SERVER['REMOTE_ADDR'], $_SERVER['REMOTE_PORT'], http_response_code(), $_SERVER['REQUEST_URI']), 4);
  20. require 'index.php';