jablonka.czprosek.czf

czfgmap

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

 

Line No. Rev Author Line
11simandl<?php
2 
35simandlerror_reporting(7);
4 
5header("Content-type: text/xml");
6 
7echo '<nodes>';
8 
9include("../forum/globalxml.php");
10 
11echo '<auth username="'.$bbuserinfo['username'].'" ';
12echo 'userid="'.$bbuserinfo['userid'].'" ';
13echo 'mapperms="'.$bbuserinfo['mapperms'].'" />';
14 
15//not logged in users gets no data
16if (!$bbuserinfo['userid']) {
17 echo '</nodes>';
18 die();
19}
20 
211simandl$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 
28switch (@$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:
424simandl require("mapa_dbinfo_czfmutf.php");
431simandl}
44 
45if(!@$latmin) $latmin="50.11389119307087";
46if(!@$latmax) $latmax="50.13040037545383";
47if(!@$lonmin) $lonmin="14.483671188354492";
48if(!@$lonmax) $lonmax="14.518003463745117";
49#$limit=10;
50 
51if(!@$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 
63if((!@$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 
74if((!@$where)) {
75 $sqlwhere="";
76} else {
77 $where=str_replace(" ","",@$where);
78 $sqlwhere="AND $where";
79}
80 
81function parseToXML($htmlStr)
82{
83$xmlStr=str_replace('<','&lt;',$htmlStr);
84$xmlStr=str_replace('>','&gt;',$xmlStr);
85$xmlStr=str_replace('"','&quot;',$xmlStr);
86$xmlStr=str_replace("'",'&#39;',$xmlStr);
87$xmlStr=str_replace("&",'&amp;',$xmlStr);
88return $xmlStr;
89}
90 
91// Opens a connection to a MySQL server
92$host="localhost";
93$connection=mysql_connect ($host, $username, $password);
94if (!$connection) {
95 die('Not connected : ' . mysql_error());
96}
97 
98// Set the active MySQL database
99$db_selected = mysql_select_db($database, $connection);
100if (!$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);
108if (!$result) {
109 die('Invalid query: ' . mysql_error());
110}
111 
112 
1135simandl // Start XML file, echo parent node
1141simandl$allowed_args = ',f_name,l_name,subject,msg,';
115 
116 
1175simandl//if (@$_SERVER['HTTP_REFERER']!="http://connected.czf/mapa/") {
1181simandl//foreach(array_keys($_SERVER) as $k) {
119//echo $k.".......".$_SERVER[$k]."<br>";
120//}
1215simandl// if (@$_ENV['HOSTNAME']!="ztop") {
122// echo "fatal - response too slow";
123// die();
124// }
125//}
1261simandl 
127// Iterate through the rows, printing XML nodes for each
128while ($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
164echo '</nodes>';
165 
166?>

Powered by WebSVN 2.2.1