1 | 1 | simandl | <?php |
2 | 7 | simandl | //<!-- Copyright (C) 2008 Petr Simandl www.simandl.cz --> |
3 | | | //<!-- This file is part of CZFGmap. --> |
4 | | | //<!-- --> |
5 | | | //<!-- CZFGmap is free software: you can redistribute it and/or modify --> |
6 | | | //<!-- it under the terms of the GNU General Public License as published by --> |
7 | | | //<!-- the Free Software Foundation, either version 3 of the License, or --> |
8 | | | //<!-- (at your option) any later version. --> |
9 | | | //<!-- --> |
10 | | | //<!-- CZFGmap is distributed in the hope that it will be useful, --> |
11 | | | //<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of --> |
12 | | | //<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --> |
13 | | | //<!-- GNU General Public License for more details. --> |
14 | | | //<!-- --> |
15 | | | //<!-- You should have received a copy of the GNU General Public License --> |
16 | | | //<!-- along with CZFGmap. If not, see <http://www.gnu.org/licenses/>. --> |
17 | 1 | simandl | |
18 | 5 | simandl | error_reporting(7); |
19 | | | |
20 | | | header("Content-type: text/xml"); |
21 | | | |
22 | | | echo '<nodes>'; |
23 | | | |
24 | | | include("../forum/globalxml.php"); |
25 | | | |
26 | | | echo '<auth username="'.$bbuserinfo['username'].'" '; |
27 | | | echo 'userid="'.$bbuserinfo['userid'].'" '; |
28 | | | echo 'mapperms="'.$bbuserinfo['mapperms'].'" />'; |
29 | | | |
30 | | | //not logged in users gets no data |
31 | | | if (!$bbuserinfo['userid']) { |
32 | | | echo '</nodes>'; |
33 | | | die(); |
34 | | | } |
35 | | | |
36 | 1 | simandl | $db=str_replace(" ","",@$db); |
37 | | | $latmin=str_replace(" ","",@$latmin); |
38 | | | $latmax=str_replace(" ","",@$latmax); |
39 | | | $lonmin=str_replace(" ","",@$lonmin); |
40 | | | $lonmax=str_replace(" ","",@$lonmax); |
41 | | | $where=str_replace(" ","",@$where); |
42 | | | |
43 | | | switch (@$db) { |
44 | | | case "czfreemapa": |
45 | | | require("mapa_dbinfo_czfreemapa.php"); |
46 | | | break; |
47 | | | case "czfmutf": |
48 | | | require("mapa_dbinfo_czfmutf.php"); |
49 | | | break; |
50 | | | case "ajax": |
51 | | | require("mapa_dbinfo_ajax.php"); |
52 | | | break; |
53 | | | case "gendb": |
54 | | | require("mapa_dbinfo_gendb.php"); |
55 | | | break; |
56 | | | default: |
57 | 4 | simandl | require("mapa_dbinfo_czfmutf.php"); |
58 | 1 | simandl | } |
59 | | | |
60 | | | if(!@$latmin) $latmin="50.11389119307087"; |
61 | | | if(!@$latmax) $latmax="50.13040037545383"; |
62 | | | if(!@$lonmin) $lonmin="14.483671188354492"; |
63 | | | if(!@$lonmax) $lonmax="14.518003463745117"; |
64 | | | #$limit=10; |
65 | | | |
66 | | | if(!@$sortby) { |
67 | | | $sqlorder="ORDER BY name"; |
68 | | | } else { |
69 | | | $sortby=str_replace(" ","",@$sortby); |
70 | | | if(!@$order) { |
71 | | | $sqlorder="ORDER BY $sortby"; |
72 | | | } else { |
73 | | | $order=str_replace(" ","",@$order); |
74 | | | $sqlorder="ORDER BY $sortby $order "; |
75 | | | } |
76 | | | } |
77 | | | |
78 | | | if((!@$limit)) { |
79 | | | $sqllimit=""; |
80 | | | } else { |
81 | | | $limit=str_replace(" ","",@$limit); |
82 | | | if($limit == 0) { |
83 | | | $sqllimit=""; |
84 | | | } else { |
85 | | | $sqllimit="LIMIT $limit"; |
86 | | | } |
87 | | | } |
88 | | | |
89 | | | if((!@$where)) { |
90 | | | $sqlwhere=""; |
91 | | | } else { |
92 | | | $where=str_replace(" ","",@$where); |
93 | | | $sqlwhere="AND $where"; |
94 | | | } |
95 | | | |
96 | | | function parseToXML($htmlStr) |
97 | | | { |
98 | | | $xmlStr=str_replace('<','<',$htmlStr); |
99 | | | $xmlStr=str_replace('>','>',$xmlStr); |
100 | | | $xmlStr=str_replace('"','"',$xmlStr); |
101 | | | $xmlStr=str_replace("'",''',$xmlStr); |
102 | | | $xmlStr=str_replace("&",'&',$xmlStr); |
103 | | | return $xmlStr; |
104 | | | } |
105 | | | |
106 | | | // Opens a connection to a MySQL server |
107 | | | $host="localhost"; |
108 | | | $connection=mysql_connect ($host, $username, $password); |
109 | | | if (!$connection) { |
110 | | | die('Not connected : ' . mysql_error()); |
111 | | | } |
112 | | | |
113 | | | // Set the active MySQL database |
114 | | | $db_selected = mysql_select_db($database, $connection); |
115 | | | if (!$db_selected) { |
116 | | | die ('Can\'t use db : ' . mysql_error()); |
117 | | | } |
118 | | | |
119 | | | // Select all the rows in the markers table |
120 | | | |
121 | | | $query = "SELECT * FROM $table WHERE $lattitude>$latmin AND $lattitude<$latmax AND $longitude>$lonmin AND $longitude<$lonmax $sqlwhere $sqlorder $sqllimit"; |
122 | | | $result = mysql_query($query); |
123 | | | if (!$result) { |
124 | | | die('Invalid query: ' . mysql_error()); |
125 | | | } |
126 | | | |
127 | | | |
128 | 5 | simandl | // Start XML file, echo parent node |
129 | 1 | simandl | $allowed_args = ',f_name,l_name,subject,msg,'; |
130 | | | |
131 | | | |
132 | 5 | simandl | //if (@$_SERVER['HTTP_REFERER']!="http://connected.czf/mapa/") { |
133 | 1 | simandl | //foreach(array_keys($_SERVER) as $k) { |
134 | | | //echo $k.".......".$_SERVER[$k]."<br>"; |
135 | | | //} |
136 | 5 | simandl | // if (@$_ENV['HOSTNAME']!="ztop") { |
137 | | | // echo "fatal - response too slow"; |
138 | | | // die(); |
139 | | | // } |
140 | | | //} |
141 | 1 | simandl | |
142 | | | // Iterate through the rows, printing XML nodes for each |
143 | | | while ($row = @mysql_fetch_assoc($result)){ |
144 | | | // ADD TO XML DOCUMENT NODE |
145 | | | echo '<node '; |
146 | | | echo 'id="' . @$row[$id] . '" '; |
147 | | | echo 'name="' . parseToXML(@$row[$name]) . '" '; |
148 | | | echo 'address="' . parseToXML(@$row[$address]) . '" '; |
149 | | | echo 'lat="' . @$row[$lattitude] . '" '; |
150 | | | echo 'lng="' . @$row[$longitude] . '" '; |
151 | | | echo 'type="' . @$row[$type] . '" '; |
152 | | | echo 'status="' . @$row[$status] . '" '; |
153 | | | echo '/>'; |
154 | | | echo ''; |
155 | | | |
156 | | | if (@$row[$id]) { |
157 | | | $query = "SELECT * FROM line WHERE id1=$row[$id]"; |
158 | | | $resultl = mysql_query($query); |
159 | | | if (!$resultl) { |
160 | | | die('Invalid query: ' . mysql_error()); |
161 | | | } |
162 | | | |
163 | | | while ($rowl = @mysql_fetch_assoc($resultl)){ |
164 | | | echo '<link '; |
165 | | | echo 'id1="' . @$rowl[$id1] . '" '; |
166 | | | echo 'id2="' . @$rowl[$id2] . '" '; |
167 | | | echo 'type="' . @$rowl[$type] . '" '; |
168 | | | echo 'status="' . @$rowl[$status] . '" '; |
169 | | | echo 'backbone="' . @$rowl[$backbone] . '" '; |
170 | | | echo 'inplanning="' . @$rowl[$inplanning] . '" '; |
171 | | | echo '/>'; |
172 | | | } |
173 | | | } |
174 | | | |
175 | | | |
176 | | | } |
177 | | | |
178 | | | // End XML file |
179 | | | echo '</nodes>'; |
180 | | | |
181 | | | ?> |