Initial commit
This commit is contained in:
25
playarea/scripts/city.php
Normal file
25
playarea/scripts/city.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
$b->router_add("/set-city/%", function () { city_save(); }, array("get"));
|
||||
|
||||
// Сохранить город
|
||||
function city_save()
|
||||
{
|
||||
global $b;
|
||||
$link = $b->router_get_segment(1);
|
||||
$b->session_set("city", $link);
|
||||
echo json_encode(array("ok" => true));
|
||||
exit();
|
||||
}
|
||||
|
||||
// Получить текущий город
|
||||
function get_city()
|
||||
{
|
||||
global $b;
|
||||
$session_city = $b->session_get("city");
|
||||
$cities = $b->setting_get_value("cities");
|
||||
if($session_city === false) return $cities[0]["label"];
|
||||
foreach ($cities as $key => $city)
|
||||
if($city["link"] == $session_city) return $city["label"];
|
||||
return $cities[0]["label"];
|
||||
}
|
||||
Reference in New Issue
Block a user