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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
| <?php
ini_set('display_errors', true);
ini_set('display_startup_errors', true);
error_reporting(E_ALL);
if(isset($_GET['hotelId']) || isset($_GET['login']) || isset($_GET['pass']) )
{
# Get the ID
$hotelId = $_GET['hotelId'];
$login = $_GET['login'];
$pass = $_GET['pass'];
include_once 'connect.php';
mysql_select_db($dbname, $conn);
$sqlp ="SELECT partenaire.login, partenaire.pass
FROM partenaire where login='$login' and pass='$pass' ";
$req = mysql_query($sqlp)or die(mysql_error());
$datalog = mysql_fetch_assoc($req);
# Make sure the ID is in fact a valid ID
if(!is_numeric($hotelId) || ($hotelId <= 0)) {
die("HotelID is unidentified");
}
if($datalog['login']!=$login || ($datalog['pass']!=$pass)) {
header('Content-type: text/xml');
$xml = new DOMDocument('1.0', 'UTF-8');
$message = $xml->createElement('message');
$message = $xml->appendChild($message);
$failure = $xml->createElement('failure');
$failure = $message->appendChild($failure);
$comment = $xml->createElement('comment');
$comment = $failure->appendChild($comment);
// create CDATA section
$cdata = $xml->createCDATASection("Incorrect login/password");
$comment->appendChild($cdata);
echo $xml->saveXML();
// die("The Login or pass is invalid!");
}
$sql = "SELECT DISTINCT propertys.propertys_uid,propertys.property_name,rooms.room_uid,rooms.room_name,rates.rates_uid, where propertys.propertys_uid='$hotelId' ORDER BY rooms.room_uid";
$qry = mysql_query($sql) or die(mysql_error());
$xml = new DOMDocument('1.0', 'UTF-8');
$xml->formatOutput = true;
$message = $xml->createElementNS(NULL, 'message');
$message->setAttributeNS('http://www.w3.org/2000/xmlns/','xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$message->setAttributeNS('http://www.w3.org/2000/xmlns/','xmlns:xsd','http://www.w3.org/2001/XMLSchema');
$xml->appendChild($message);
if (mysql_num_rows($qry))
{
$rooms= $xml->createElement('rooms');
$rooms = $message->appendChild($rooms);
$data = mysql_fetch_assoc($qry);
$rooms->setAttribute("hotelId",$data['propertys_uid']);
$rooms->setAttribute("hotelName", $data['property_name']);
while ($data = mysql_fetch_assoc($qry)) {
if (!isset($room) || $data['room_uid'] != $room->getAttribute('code')) {
$room = $xml->createElement('room');
$room = $rooms->appendChild($room);
$room->setAttribute("code",$data['room_uid']);
$room->setAttribute("name", $data['room_name']);
$room->setAttribute("maxOccupancy", $data['maxpeople']);
$room->setAttribute("minOccupancy", $data['minpeople']);
$rooms->appendChild($room);
}
$rate = $xml->createElement('rate');
$rate = $room->appendChild($rate);
$rate->setAttribute("code",$data['rates_uid']);
$rate->setAttribute("name", $data['rate_title']);
//$rate->setAttribute("regime", $data['room_class_abbv']);
}
// $xml->appendChild($rooms);
$xml->appendChild($message);
}
header('Content-type: text/xml');
mysql_set_charset('utf8');
//header('Content-type: text/plain');
header('Charset: utf-8');
//echo htmlentities($xml->saveXML());
echo $xml->saveXML();
}
else
{
header('Content-type: text/xml');
$xml = new DOMDocument('1.0', 'UTF-8');
$message = $xml->createElement('message');
$message = $xml->appendChild($message);
$failure = $xml->createElement('failure');
$failure = $message->appendChild($failure);
$comment = $xml->createElement('comment');
$comment = $failure->appendChild($comment);
// create CDATA section
$cdata = $xml->createCDATASection("Incorrect login/password");
$comment->appendChild($cdata);
echo $xml->saveXML();
//echo "Error! No ID was passed.";
}
?> |
Partager