request->getBody(); $json = json_decode($body); $location = new IpGeoLocator($app->request->getIp()); if($location->city() != $json["city"]){ return json_encode(["result" => "unprovenlocation", "message" => "You send "]); } $app->response()->header("Content-Type", "application/json"); echo json_encode($json); } catch(Exception $exception){ error_log("Caught exception handling request stationsRegister: ". $exception->getMessage()); $app->response()->status(400); $app->response()->header("X-Status-Reason", $exception->getMessage()); } } $app = new \Slim\Slim ( array ( "mode" => $settings->getConfig("mode"), ) ); $app->setName("siweather"); // Only invoked if mode is "production" $app->configureMode('production', function () use ($app) { $app->config(array( "log.enable" => true, "log.level" => \Slim\Log::WARN, "debug" => false, )); }); // Only invoked if mode is "development" $app->configureMode('development', function () use ($app) { $app->config(array( "log.enable" => true, "log.level" => \Slim\Log::DEBUG, "debug" => true )); }); $app->notFound(function () use ($app) { $html = ""; if($app->config("debug")){ ob_start(); phpinfo( INFO_VARIABLES ^ INFO_ENVIRONMENT ); $html = ob_get_contents(); ob_end_clean(); } $app->render("404.php", array("dump" => $html)); }); $app->get("/setup", function () use ($app){ $app->render("setup.php"); }); $app->get("/stations", "stations"); $app->post("/stations/register", "stationsRegister"); $app->run(); ?>