forked from hypercities/hypercities
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcitiesList.php
More file actions
56 lines (49 loc) · 1.98 KB
/
Copy pathcitiesList.php
File metadata and controls
56 lines (49 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
include_once('includes/connect_db.inc');
include_once('includes/util.inc');
include_once('includes/serverSession.inc');
include_once('includes/dbUtil.inc');
cServerSession::start();
HC_checkReferer();
$default_thumbnail_url = './files/defaultCity.gif';
$query_str = "SELECT c.id, c.name, c.country, c.lat, c.lon, c.zoom,"
. " c.thumbnail_url FROM cities c order by c.name";
try {
$result = sqlCommand($query_str);
} catch (MysqlException $e) {
$message = 'Caught exception: '.$e->getMessage();
HC_errorLog($message);
HC_reportDBError("adding your object");
} catch (Exception $e) {
$message = 'Caught exception: '.$e->getMessage();
HC_errorLog($message);
HC_reportGeneralError("adding your object");
}
$dom = new DomDocument('1.0', 'utf-8');
$cities_data = $dom->appendChild($dom->createElement('Cities'));
foreach($result as $row) {
$Result = $cities_data->appendChild($dom->createElement('City'));
$id = $Result->appendChild($dom->createElement('id'));
$id->appendChild($dom->createTextNode($row['id']));
$city = $Result->appendChild($dom->createElement('city'));
$city->appendChild($dom->createTextNode($row['name']));
$country = $Result->appendChild($dom->createElement('country'));
$country->appendChild($dom->createTextNode($row['country']));
$lat = $Result->appendChild($dom->createElement('lat'));
$lat->appendChild($dom->createTextNode($row['lat']));
$lon = $Result->appendChild($dom->createElement('lon'));
$lon->appendChild($dom->createTextNode($row['lon']));
$zoom = $Result->appendChild($dom->createElement('zoom'));
$zoom->appendChild($dom->createTextNode($row['zoom']));
$thumbnail_url = $Result->appendChild($dom->createElement('thumbnail_url'));
if($row['thumbnail_url'] == NULL) {
$thumbnail_url->appendChild($dom->createTextNode($default_thumbnail_url));
} else {
$thumbnail_url->appendChild($dom->createTextNode($row['thumbnail_url']));
}
}
$dom->formatOutput = true;
$map_list_xml = $dom->saveXML();
header('Content-type: application/xml');
echo $map_list_xml;
?>