jablonka.czprosek.czf

czfgmap

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

 

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']) {
32 echo '</nodes>';
33 die();
34}
35 
361simandl$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 
43switch (@$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:
574simandl require("mapa_dbinfo_czfmutf.php");
581simandl}
59 
60if(!@$latmin) $latmin="50.11389119307087";
61if(!@$latmax) $latmax="50.13040037545383";
62if(!@$lonmin) $lonmin="14.483671188354492";
63if(!@$lonmax) $lonmax="14.518003463745117";
64#$limit=10;
65 
66if(!@$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 
78if((!@$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 
89if((!@$where)) {
90 $sqlwhere="";
91} else {
92 $where=str_replace(" ","",@$where);
93 $sqlwhere="AND $where";
94}
95 
96function parseToXML($htmlStr)
97{
98$xmlStr=str_replace('<','&lt;',$htmlStr);
99$xmlStr=str_replace('>','&gt;',$xmlStr);
100$xmlStr=str_replace('"','&quot;',$xmlStr);
101$xmlStr=str_replace("'",'&#39;',$xmlStr);
102$xmlStr=str_replace("&",'&amp;',$xmlStr);
103return $xmlStr;
104}
105 
106// Opens a connection to a MySQL server
107$host="localhost";
108$connection=mysql_connect ($host, $username, $password);
109if (!$connection) {
110 die('Not connected : ' . mysql_error());
111}
112 
113// Set the active MySQL database
114$db_selected = mysql_select_db($database, $connection);
115if (!$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);
123if (!$result) {
124 die('Invalid query: ' . mysql_error());
125}
126 
127 
1285simandl // Start XML file, echo parent node
1291simandl$allowed_args = ',f_name,l_name,subject,msg,';
130 
131 
1325simandl//if (@$_SERVER['HTTP_REFERER']!="http://connected.czf/mapa/") {
1331simandl//foreach(array_keys($_SERVER) as $k) {
134//echo $k.".......".$_SERVER[$k]."<br>";
135//}
1365simandl// if (@$_ENV['HOSTNAME']!="ztop") {
137// echo "fatal - response too slow";
138// die();
139// }
140//}
1411simandl 
142// Iterate through the rows, printing XML nodes for each
143while ($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
179echo '</nodes>';
180 
181?>

Powered by WebSVN 2.2.1