39 lines
1.0 KiB
PHP
39 lines
1.0 KiB
PHP
<?php
|
|
// Workadventure cache destroyer
|
|
|
|
// URL rewrite rule calls us with the original filename in URL paramter "target"
|
|
if (!isset($_GET['target'])) {
|
|
echo("No target");
|
|
exit;
|
|
}
|
|
$target = $_GET["target"];
|
|
|
|
if (file_exists($target.".php"))
|
|
{
|
|
// If a PHP file target.php exists:
|
|
// Run that file and capture its output
|
|
ob_start();
|
|
include $target.".php";
|
|
ob_end_flush();
|
|
}
|
|
else
|
|
{
|
|
// If no PHP file target.php exists:
|
|
// Load contents from target.json
|
|
if (!file_exists($target.".json"))
|
|
{
|
|
echo($target.".json"." not found.");
|
|
exit;
|
|
}
|
|
$data = str_replace(".php#", ".".$tstamp.".php#", $data); // Patch php-exits to prevent caching
|
|
}
|
|
|
|
// 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
|
|
header("Expires: 0");
|
|
header('Content-type: application/json');
|
|
echo($data);
|
|
exit;
|
|
?>
|