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