router.php 673 B

12345678910111213141516171819202122
  1. <?php
  2. $path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
  3. // Exclude some paths from being rewritten
  4. if (str_starts_with(dirname($path), "/themes") || (dirname($path) == '/' && (pathinfo($path, PATHINFO_EXTENSION) == 'css' || pathinfo($path, PATHINFO_EXTENSION) == 'js'))) {
  5. return false;
  6. }
  7. else if ($_SERVER["REQUEST_METHOD"] === "POST" && $_SERVER["CONTENT_TYPE"] === "application/pprf") {
  8. $file = 'pprf.php';
  9. }
  10. else {
  11. $file = 'index.php';
  12. // Split into two parts, the ppub and the path within the ppub
  13. $parts = explode("/", $path, 3);
  14. $_GET['ppub'] = $parts[1];
  15. $_GET['asset'] = $parts[2];
  16. }
  17. $_SERVER['SCRIPT_NAME'] = '/' . $file;
  18. require $file;