jablonka.czprosek.czf

czfgmap

Subversion Repositories:
[/] [mapa_genxml.php] - Blame information for rev 13

 

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

Powered by WebSVN 2.2.1