1 | 1 | simandl | <?php |
2 | | | |
3 | | | $db=str_replace(" ","",@$db); |
4 | | | $latmin=str_replace(" ","",@$latmin); |
5 | | | $latmax=str_replace(" ","",@$latmax); |
6 | | | $lonmin=str_replace(" ","",@$lonmin); |
7 | | | $lonmax=str_replace(" ","",@$lonmax); |
8 | | | $where=str_replace(" ","",@$where); |
9 | | | |
10 | | | switch (@$db) { |
11 | | | case "czfreemapa": |
12 | | | require("mapa_dbinfo_czfreemapa.php"); |
13 | | | break; |
14 | | | case "czfmutf": |
15 | | | require("mapa_dbinfo_czfmutf.php"); |
16 | | | break; |
17 | | | case "ajax": |
18 | | | require("mapa_dbinfo_ajax.php"); |
19 | | | break; |
20 | | | case "gendb": |
21 | | | require("mapa_dbinfo_gendb.php"); |
22 | | | break; |
23 | | | default: |
24 | | | require("mapa_dbinfo_gendb.php"); |
25 | | | } |
26 | | | |
27 | | | if(!@$latmin) $latmin="50.11389119307087"; |
28 | | | if(!@$latmax) $latmax="50.13040037545383"; |
29 | | | if(!@$lonmin) $lonmin="14.483671188354492"; |
30 | | | if(!@$lonmax) $lonmax="14.518003463745117"; |
31 | | | #$limit=10; |
32 | | | |
33 | | | if(!@$sortby) { |
34 | | | $sqlorder="ORDER BY name"; |
35 | | | } else { |
36 | | | $sortby=str_replace(" ","",@$sortby); |
37 | | | if(!@$order) { |
38 | | | $sqlorder="ORDER BY $sortby"; |
39 | | | } else { |
40 | | | $order=str_replace(" ","",@$order); |
41 | | | $sqlorder="ORDER BY $sortby $order "; |
42 | | | } |
43 | | | } |
44 | | | |
45 | | | if((!@$limit)) { |
46 | | | $sqllimit=""; |
47 | | | } else { |
48 | | | $limit=str_replace(" ","",@$limit); |
49 | | | if($limit == 0) { |
50 | | | $sqllimit=""; |
51 | | | } else { |
52 | | | $sqllimit="LIMIT $limit"; |
53 | | | } |
54 | | | } |
55 | | | |
56 | | | if((!@$where)) { |
57 | | | $sqlwhere=""; |
58 | | | } else { |
59 | | | $where=str_replace(" ","",@$where); |
60 | | | $sqlwhere="AND $where"; |
61 | | | } |
62 | | | |
63 | | | function parseToXML($htmlStr) |
64 | | | { |
65 | | | $xmlStr=str_replace('<','<',$htmlStr); |
66 | | | $xmlStr=str_replace('>','>',$xmlStr); |
67 | | | $xmlStr=str_replace('"','"',$xmlStr); |
68 | | | $xmlStr=str_replace("'",''',$xmlStr); |
69 | | | $xmlStr=str_replace("&",'&',$xmlStr); |
70 | | | return $xmlStr; |
71 | | | } |
72 | | | |
73 | | | // Opens a connection to a MySQL server |
74 | | | $host="localhost"; |
75 | | | $connection=mysql_connect ($host, $username, $password); |
76 | | | if (!$connection) { |
77 | | | die('Not connected : ' . mysql_error()); |
78 | | | } |
79 | | | |
80 | | | // Set the active MySQL database |
81 | | | $db_selected = mysql_select_db($database, $connection); |
82 | | | if (!$db_selected) { |
83 | | | die ('Can\'t use db : ' . mysql_error()); |
84 | | | } |
85 | | | |
86 | | | // Select all the rows in the markers table |
87 | | | |
88 | | | $query = "SELECT * FROM $table WHERE $lattitude>$latmin AND $lattitude<$latmax AND $longitude>$lonmin AND $longitude<$lonmax $sqlwhere $sqlorder $sqllimit"; |
89 | | | $result = mysql_query($query); |
90 | | | if (!$result) { |
91 | | | die('Invalid query: ' . mysql_error()); |
92 | | | } |
93 | | | |
94 | | | header("Content-type: text/xml"); |
95 | | | |
96 | | | // Start XML file, echo parent node |
97 | | | $allowed_args = ',f_name,l_name,subject,msg,'; |
98 | | | |
99 | | | echo '<nodes>'; |
100 | | | |
101 | | | if (@$_SERVER['HTTP_REFERER']!="http://mapa.prosek.czf/") { |
102 | | | //foreach(array_keys($_SERVER) as $k) { |
103 | | | //echo $k.".......".$_SERVER[$k]."<br>"; |
104 | | | //} |
105 | | | if (@$_ENV['HOSTNAME']!="ztop") { |
106 | | | echo "fatal - response too slow"; |
107 | | | die(); |
108 | | | } |
109 | | | } |
110 | | | |
111 | | | // Iterate through the rows, printing XML nodes for each |
112 | | | while ($row = @mysql_fetch_assoc($result)){ |
113 | | | // ADD TO XML DOCUMENT NODE |
114 | | | echo '<node '; |
115 | | | echo 'id="' . @$row[$id] . '" '; |
116 | | | echo 'name="' . parseToXML(@$row[$name]) . '" '; |
117 | | | echo 'address="' . parseToXML(@$row[$address]) . '" '; |
118 | | | echo 'lat="' . @$row[$lattitude] . '" '; |
119 | | | echo 'lng="' . @$row[$longitude] . '" '; |
120 | | | echo 'type="' . @$row[$type] . '" '; |
121 | | | echo 'status="' . @$row[$status] . '" '; |
122 | | | echo '/>'; |
123 | | | echo ''; |
124 | | | |
125 | | | if (@$row[$id]) { |
126 | | | $query = "SELECT * FROM line WHERE id1=$row[$id]"; |
127 | | | $resultl = mysql_query($query); |
128 | | | if (!$resultl) { |
129 | | | die('Invalid query: ' . mysql_error()); |
130 | | | } |
131 | | | |
132 | | | while ($rowl = @mysql_fetch_assoc($resultl)){ |
133 | | | echo '<link '; |
134 | | | echo 'id1="' . @$rowl[$id1] . '" '; |
135 | | | echo 'id2="' . @$rowl[$id2] . '" '; |
136 | | | echo 'type="' . @$rowl[$type] . '" '; |
137 | | | echo 'status="' . @$rowl[$status] . '" '; |
138 | | | echo 'backbone="' . @$rowl[$backbone] . '" '; |
139 | | | echo 'inplanning="' . @$rowl[$inplanning] . '" '; |
140 | | | echo '/>'; |
141 | | | } |
142 | | | } |
143 | | | |
144 | | | |
145 | | | } |
146 | | | |
147 | | | // End XML file |
148 | | | echo '</nodes>'; |
149 | | | |
150 | | | ?> |