router.php 851 B

1234567891011121314151617181920212223242526
  1. <?php
  2. /**
  3. * @package Grav.Core
  4. *
  5. * @copyright Copyright (C) 2015 - 2018 Trilby Media, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. if (PHP_SAPI !== 'cli-server') {
  9. exit('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. require 'index.php';
  20. error_log(sprintf('%s:%d [%d]: %s', $_SERVER['REMOTE_ADDR'], $_SERVER['REMOTE_PORT'], http_response_code(), $_SERVER['REQUEST_URI']), 4);