rc3/maps/ir/cellar/01/01.php
Stephan Messlinger 95a12398e1 ini
2021-02-15 20:14:50 +01:00

37 lines
985 B
PHP

<?php
# Turn off switch
$state = json_decode(file_get_contents("state.json"), true);
$state["switch"] = 0;
file_put_contents("state.json", json_encode($state));
# Create unique copy of the complete level
$sub = uniqid();
mkdir($sub);
foreach (glob("*.*") as $f)
copy($f, $sub."/".$f);
copy(".htaccess", $sub."/.htaccess");
// Replace level worker
copy("01_sub.php", $sub."/"."01.php");
# Patch paths of the copied level
$data = file_get_contents("$sub"."/01.json");
$data = str_replace("..\/..", "..\/..\/..", $data);
file_put_contents("$sub"."/01.json", $data);
$data = file_get_contents("$sub"."/01_closed.json");
$data = str_replace("..\/..", "..\/..\/..", $data);
file_put_contents("$sub"."/01_closed.json", $data);
# Load current level and patch exits to target the copy
$data = file_get_contents("01.json");
$data = str_replace("01.php#", "$sub"."/"."01.php#", $data);
header("Expires: 0");
header('Content-type: application/json');
echo($data);
exit;
?>