<?php
if (!isset($_GET['c'])) {
header("Location: /");
exit;
}
error_reporting(0);
ini_set('display_errors', 'Off');
header("Content-Type: application/xml; charset=utf-8");
require_once "functions.php";
require_once "mod/route.php";
require_once "mod/fields.php";
route::need('db');
$xml = '<?xml version="1.0" encoding="UTF-8"?><Ads formatVersion="3" target="Avito.ru">';
$keys = array(
'Description',
'Images',
'LeaseDeposit',
'Square',
'Category',
'BuildingClass',
'Floor',
'Floors',
'PropertyRights',
'AllowEmail',
'BuildingType',
'Latitude',
'Longitude',
'OperationType',
'Id',
'CompanyName',
'Address',
'ObjectType',
'Price',
'PriceType'
);
$l_currency = db::i()->selectArr("select id AS _K, curr AS _V from l_currency;");
$l_category = db::i()->selectArr("select id AS _K, i as _V from l_avito_category;");
$objects = db::i()->select("
SELECT
c_object.*,
c_object.floor AS Floor,
c_object.floors AS Floors,
'Посредник' AS PropertyRights,
'Да' AS AllowEmail,
c_object.__lat AS Latitude,
c_object.__lng AS Longitude,
IF(c_object.l_deal_type=1, 'Сдам', 'Продам') AS OperationType,
c_object.id AS Id,
c_object.BuildingType AS BuildingType");
$count = 0;
if (!empty($objects)) {
$count = count($objects);
foreach ($objects as $object_key => $object) {
$object['Images'] = fields::images($object['id'], 'images', false);
$object['Plan'] = @array_shift(fields::images($object['id'], 'planes', false));
$object['Description'] = fields::description($object['id'], $object['Description']);
$xmlObj = '<Ad>';
$id = fields::id($object['id']);
$xmlObj .= "<Id>{$id}</Id>";
$xmlObj .= "<Category>{$object['Category']}</Category>";
$xmlObj .= "<CompanyName>{$object['CompanyName']}</CompanyName>";
$xmlObj .= "<ObjectType>{$object['ObjectType']}</ObjectType>";
$xmlObj .= "<PropertyRights>{$object['PropertyRights']}</PropertyRights>";
$xmlObj .= "<OperationType>{$object['OperationType']}</OperationType>";
$xmlObj .= '</Ad>';
$xml .= $xmlObj;
}
}
$xml .= '</Ads>';
if ($count)
echo $xml;
такое?