jablonka.czprosek.czf

czfgmap

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

 

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 
3014simandl//not logged in users gets everyone data
315simandlif (!$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 
12014simandl//
121$lattitude = mysql_real_escape_string($lattitude);
122$longitude = mysql_real_escape_string($longitude);
123$latmin = mysql_real_escape_string($latmin);
124$latmax = mysql_real_escape_string($latmax);
125$lonmin = mysql_real_escape_string($lonmin);
126$lonmax = mysql_real_escape_string($lonmax);
127$sqlwhere = mysql_real_escape_string($sqlwhere);
128$sqlorder = mysql_real_escape_string($sqlorder);
129$sqllimit = mysql_real_escape_string($sqllimit);
1301simandl 
131$query = "SELECT * FROM $table WHERE $lattitude>$latmin AND $lattitude<$latmax AND $longitude>$lonmin AND $longitude<$lonmax $sqlwhere $sqlorder $sqllimit";
132$result = mysql_query($query);
133if (!$result) {
134 die('Invalid query: ' . mysql_error());
135}
136 
137// Iterate through the rows, printing XML nodes for each
138while ($row = @mysql_fetch_assoc($result)){
139 // ADD TO XML DOCUMENT NODE
140 echo '<node ';
141 echo 'id="' . @$row[$id] . '" ';
142 echo 'name="' . parseToXML(@$row[$name]) . '" ';
143 echo 'address="' . parseToXML(@$row[$address]) . '" ';
144 echo 'lat="' . @$row[$lattitude] . '" ';
145 echo 'lng="' . @$row[$longitude] . '" ';
146 echo 'type="' . @$row[$type] . '" ';
147 echo 'status="' . @$row[$status] . '" ';
148 echo '/>';
149 echo '';
150 
151 if (@$row[$id]) {
152 $query = "SELECT * FROM line WHERE id1=$row[$id]";
153 $resultl = mysql_query($query);
154 if (!$resultl) {
155 die('Invalid query: ' . mysql_error());
156 }
157 
158 while ($rowl = @mysql_fetch_assoc($resultl)){
159 echo '<link ';
160 echo 'id1="' . @$rowl[$id1] . '" ';
161 echo 'id2="' . @$rowl[$id2] . '" ';
162 echo 'type="' . @$rowl[$type] . '" ';
163 echo 'status="' . @$rowl[$status] . '" ';
164 echo 'backbone="' . @$rowl[$backbone] . '" ';
165 echo 'inplanning="' . @$rowl[$inplanning] . '" ';
166 echo '/>';
167 }
168 }
169 
170}
171 
172// End XML file
173echo '</nodes>';
174 
175?>

Powered by WebSVN 2.2.1