-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathcities_js.php
70 lines (67 loc) · 2.44 KB
/
cities_js.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
define('IS_PHP_JS', true);
require_once $_SERVER["DOCUMENT_ROOT"]."/classes/stdf.php";
require_once($_SERVER['DOCUMENT_ROOT'] . "/classes/city.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/classes/country.php");
$membuf = new memBuff();
$memkey = "b-combo-getcitiesandcountries";
$s = 0;//$membuf->get($memkey);
if (!$s) {
$rows = country::GetCountriesByCountUser();
$result = array(0=>"'0' : 'Âñå ñòðàíû'");
foreach ($rows as $k=>$i) {
$i["name"] = str_replace('"', "\"", $i["name"]);
$result[$i["id"]] = str_replace("'", "\'", $i["name"]);
}
//ãîðîäà Ðîññèè 1
$rows = city::GetCities(1);
$cResult = array("0"=>"'0' : 'Ðîññèÿ'", "undefined_value"=>"'undefined_value' : 'Âñå ãîðîäà'");
foreach ($rows as $k=>$i) {
$i = str_replace('"', "\"", $i);
$i = str_replace("'", "\'", $i);
$cResult[$k] = "'$k' : '$i'";
}
$result[1] = $cResult;
//ãîðîäà Óêðàèíû 2
$rows = city::GetCities(2);
$cResult = array("0"=>"'0' : 'Óêðàèíà'", "undefined_value"=>"'undefined_value' : 'Âñå ãîðîäà'");
foreach ($rows as $k=>$i) {
$i = str_replace('"', "\"", $i);
$i = str_replace("'", "\'", $i);
$cResult[$k] = "'$k' : '$i'";
}
$result[2] = $cResult;
//ãîðîäà Áåëàðóñèè 10
$rows = city::GetCities(10);
$cResult = array("0"=>"'0' : 'Áåëàðóñü'", "undefined_value"=>"'undefined_value' : 'Âñå ãîðîäà'");
foreach ($rows as $k=>$i) {
$i = str_replace('"', "\"", $i);
$i = str_replace("'", "\'", $i);
$cResult[$k] = "'$k' : '$i'";
}
$result[10] = $cResult;
//ãîðîäà Êàçàõñòàíà 38
$rows = city::GetCities(38);
$cResult = array("0"=>"'0' : 'Êàçàõñòàí'", "undefined_value"=>"'undefined_value' : 'Âñå ãîðîäà'");
foreach ($rows as $k=>$i) {
$i = str_replace('"', "\"", $i);
$i = str_replace("'", "\'", $i);
$cResult[$k] = "'$k' : '$i'";
}
$result[38] = $cResult;
$tdata = array();
foreach ($result as $k=>$i) {
$inner = "'$i'";
$item = "'$k' : $inner";
if (is_array($i)) {
$inner = join(",", $i); //join(",\n\t\t\t",
$item = "'$k' : "."{".$inner."}"; //"'$k' : \n\t{\n\t\t\t$inner\n\t\t}";
}
$tdata[] = $item;
}
$result = $tdata;
$s = join(",", $result); //join(",\n"
$s = "{".$s."}";
$membuf->add($memkey, $s, 3600);
}
print('var citiesList = '.$s.'; citiesList["1"]["0"] = "Ðîññèÿ"; ' );