<?php
/*!
* Copyright Anucha Puangpaka
* Contact anucha.ppk@icloud.com 062-479-9836
*/
session_start();
include('../../config.php');
if($_GET['nu']==""){
function parseToXML($htmlStr){
$xmlStr = str_replace("<p",'',$htmlStr);
$xmlStr = str_replace('/p>','',$xmlStr);
return $xmlStr;
}
function parseToXML2($htmlStr){
$xmlStr = str_replace('<','',$htmlStr);
$xmlStr = str_replace('>','',$xmlStr);
$xmlStr = str_replace('"','',$xmlStr);
$xmlStr = str_replace(' ','',$xmlStr);
//$xmlStr = str_replace('<','<',$htmlStr);
//$xmlStr = str_replace('>','>',$xmlStr);
//$xmlStr = str_replace('"','"',$xmlStr);
$xmlStr = str_replace("'",''',$xmlStr);
$xmlStr = str_replace("&",'&',$xmlStr);
return $xmlStr;
}
if(empty($_GET['id'])){
$sql = "select * from ap_maps";
}else{
$sql = "select * from ap_maps where id='$_GET[id]'";
}
$query = mysqli_query($conn,$sql);
if (!$query) {
die('Invalid query: ' . mysqli_error());
}
$m = '<markers>';
while ($rows = @mysqli_fetch_assoc($query)){
$m .= '<marker name="'.parseToXML("$rows[code]) ".$rows['name']).'" ';
//echo 'address="' . parseToXML($rows['address']." ".$rows[tumboon]." ".$rows[amphoe]." ".$rows[province]." ".$rows[phone]).'" ';
$sql2 = "select * from ap_maps where code='$rows[code]' order by code asc";
$query2 = mysqli_query($conn,$sql2);
while($rows2 = mysqli_fetch_array($query2)){
/*$t = parseToXML("Lat: $rows2[lat] Lng: $rows2[lng]");*/
$t = parseToXML("");
$t = parseToXML2($t);
$m .= 'address="' . $t . '" ';
$m .= 'lat="' . $rows2['lat'] . '" ';
$m .= 'lng="' . $rows2['lng'] . '" ';
$m .= 'type="lacation" ';
$m .= 'image="'.$rows2['images'].'" ';
$m .= 'url="' . htmlspecialchars("$ap_site$ap_folder"."ap/maps/?id=$rows2[id]").'" ';
$m .= 'website="' . htmlspecialchars("$rows2[url]").'" ';
$m .= '/>';
}
}
$m .= '<marker name="ตำแหน่งของคุณ" address="'."Lat: $_COOKIE[lat] Lng: $_COOKIE[lng]".'" lat="'.$_COOKIE['lat'].'" lng="'.$_COOKIE['lng'].'" type="You" image="" url="" website="" />';
$m .= '</markers>';
header("Content-type: text/xml");
echo $m;
}
mysqli_close($conn);
?>