rc3/maps/ir/gmaze/uncache.php

39 lines
997 B
PHP
Raw Permalink Normal View History

2021-02-15 19:14:50 +00:00
<?php
// Workadventure cache destroyer
// URL rewrite rule calls us with the original filename in URL paramter "target"
2021-02-16 03:22:04 +00:00
if (!isset($_GET['target'])) {
2021-02-15 19:14:50 +00:00
echo("No target");
exit;
}
$target = $_GET["target"];
2021-02-16 03:22:04 +00:00
if (file_exists($target.".php")) {
2021-02-15 19:14:50 +00:00
// If a PHP file target.php exists:
// Run that file and capture its output
ob_start();
include $target.".php";
ob_end_flush();
}
2021-02-16 03:22:04 +00:00
else {
2021-02-15 19:14:50 +00:00
// If no PHP file target.php exists:
// Load contents from target.json
2021-02-16 03:22:04 +00:00
if (file_exists($target.".json"))
$data = file_get_contents($target.".json");
else {
2021-02-15 19:14:50 +00:00
echo($target.".json"." not found.");
exit;
}
2021-02-16 03:22:04 +00:00
2021-02-15 19:14:50 +00:00
}
// Replace map exit names with timestamps:
// destination.php#start --> destination.number.php#start
$tstamp = round(microtime(true)*100); # 0.01 sec resolution
$data = str_replace(".php#", ".".$tstamp.".php#", $data); // Patch php-exits to prevent caching
2021-02-16 03:22:04 +00:00
2021-02-15 19:14:50 +00:00
header('Content-type: application/json');
echo($data);
exit;
2021-02-16 03:22:04 +00:00
?>