Example #1
0
    $conf = Yaml::parse($yaml);
    foreach ($conf['buildings']['resources'] as $building => $resourcess) {
        if ($_SERVER['REQUEST_URI'] == '/' . $building) {
            $buildingValue = Building::box($resourcess);
            setcookie('building-in-progress', $building);
            $secondsToBuildBuilding = $buildingValue->secondsToBuild();
            $dateTimeModifier = "+{$secondsToBuildBuilding} seconds";
            $buildingBuiltAt = (new DateTime($dateTimeModifier))->setTimezone(new DateTimezone('UTC'))->format('Y-m-dTH:i:s');
            setcookie('building-built-at', $buildingBuiltAt);
            Header("HTTP/1.1 301 Moved Permanently");
            Header("Location: http://localhost:8000");
        }
    }
}
if ($_SERVER['REQUEST_URI'] == '/status') {
    echo Json::toJson();
    die;
}
if ($_SERVER['REQUEST_URI'] == '/logout') {
    foreach ($_COOKIE as $key => $value) {
        setcookie($key, null);
    }
    Header("HTTP/1.1 301 Moved Permanently");
    Header("Location: http://localhost:8000");
}
if ($_SERVER['REQUEST_URI'] == '/village' && isset($_POST['village-name'])) {
    $villageName = $_POST['village-name'];
    setcookie('village', $villageName);
    Header("HTTP/1.1 301 Moved Permanently");
    Header("Location: http://localhost:8000");
}
Example #2
0
 public static function toJson()
 {
     $json = new Json();
     return json_encode($json->jsonContent());
 }