Uname: Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux
Software: Apache
PHP version: 5.6.40 [ PHP INFO ] PHP os: Linux
Server Ip: 217.160.0.194
Your Ip: 216.73.216.203
User: u72294154 (9179942) | Group: ftpusers (600)
Safe Mode: OFF
Disable Function:
NONE

name : xml-pisocasas.php
<?
/* XML PARA TROVIT */

ini_set("memory_limit","256M");
ini_set("max_execution_time",0);


function url($datos,$base=null){
	
	if($base != null)
		$url = "/$base/";
	else
		$url = '/';
		
	$temp = array();
	
	if($datos['localidad'])
		$temp[] = format_url($datos['localidad']);
	if($datos['tipologia'])
		$temp[] = format_url($datos['tipologia']);
	if($datos['zona'])
		$temp[] = format_url("zona-".$datos['zona']);
	if($datos['habitaciones'])
		$temp[] = format_url($datos['habitaciones']."-habitaciones");
	if($datos['referencia'] && $datos['id'])
		$temp[] = format_url($datos['referencia']."_".$datos['id']);

	$url .= implode('/',$temp);
	
	return $url;
}

require_once $_SERVER['DOCUMENT_ROOT'].'/requires/sources/__requires.php';



$xml = new DOMDocument('1.0','UTF-8');

//if($_GET['export']){
	$inmuebles = $xml->createElement('pisocasas');
	
 
	$SQL = "SELECT 
					i.*, 
					l.nombre AS localidad, 
					p.nombre AS provincia, 
					z.nombre AS zona,
					t.nombre AS tipologia,
					tv.nombre AS tipo_via
			FROM 
					inmuebles i
			LEFT JOIN 
					poblaciones l ON l.id = i.id_poblacion
			LEFT JOIN 
					provincias p ON p.id = i.id_provincia
			LEFT JOIN 
					zonas z ON z.id = i.id_zona
			LEFT JOIN 
					tipos_inmueble t ON t.id = i.id_tipo_inmueble
			LEFT JOIN 
					tipos_de_via tv ON tv.id = i.id_tipo_via
			LEFT JOIN
					inmuebles_galeria ig ON ig.id_inmueble = i.id
			WHERE
				i.activa = '1' AND i.estado = 'inmueble' AND ig.principal = '1'
			";

	$consulta = @mysql_query($SQL);

	 //echo $SQL;
	 //die;
	
	if(mysql_error())
		// echo $SQL;
		echo "Se ha producido un error";

	if(mysql_num_rows($consulta)){

		while($resultado = mysql_fetch_assoc($consulta)){
			$inmueble = $xml->createElement('inmueble');

			$nombreComercial = $xml->createElement('nombrecomercial');
			$nombreComercial->appendChild($xml->createCDATASection("Altamira21"));
			$inmueble->appendChild($nombreComercial);

			$email1 = $xml->createElement('email1');
			$email1->appendChild($xml->createCDATASection("info@altamira21.com"));
			$inmueble->appendChild($email1);


			$tlf1 = $xml->createElement('tlf1');
			$tlf1->appendChild($xml->createCDATASection("942 882 595"));
			$inmueble->appendChild($tlf1);

			$web = $xml->createElement('web');
			$web->appendChild($xml->createCDATASection("http://altamira21.com"));
			$inmueble->appendChild($web);

			$logo = $xml->createElement('logo');
			$logo->appendChild($xml->createCDATASection("http://altamira21.com/imagenes/comunes/logo.png"));
			$inmueble->appendChild($logo);

			$direccionusu = $xml->createElement('direccionusu');
			$direccionusu->appendChild($xml->createCDATASection("C/ Julián Ceballos 15 entlo. 6"));
			$inmueble->appendChild($direccionusu);

			$codpostalusu = $xml->createElement('codpostalusu');
			$codpostalusu->appendChild($xml->createCDATASection("39300"));
			$inmueble->appendChild($codpostalusu);

			$poblacionusu = $xml->createElement('poblacionusu');
			$poblacionusu->appendChild($xml->createCDATASection("Torrelavega"));
			$inmueble->appendChild($poblacionusu);

			$provinciausu = $xml->createElement('provinciausu');
			$provinciausu->appendChild($xml->createCDATASection("Cantabria"));
			$inmueble->appendChild($provinciausu);

			$url = $xml->createElement('url_cliente');
			$url->appendChild($xml->createCDATASection("http://www.altamira21.com".url($resultado)));
			$inmueble->appendChild($url);

			$ref = $xml->createElement('referencia');
			$ref->appendChild($xml->createCDATASection($resultado['referencia']));
			$inmueble->appendChild($ref);

			$tipologia = $xml->createElement('tipo_inmueble');
			$tipologia->appendChild($xml->createCDATASection($resultado['tipologia']));
			$inmueble->appendChild($tipologia);

			$operacion = $xml->createElement('operacion');
			$operacion->appendChild($xml->createCDATASection($resultado['gestion']));
			$inmueble->appendChild($operacion);


			if($resultado["gestion"]=="Venta")
				$price=$resultado['precio_venta'];
			else
				$price=$resultado['precio_alquiler'];

			$precio = $xml->createElement('precio');
			$precio->appendChild($xml->createCDATASection($price));
			$inmueble->appendChild($precio);

			$codpostal = $xml->createElement('codpostal');
			$codpostal->appendChild($xml->createCDATASection($resultado['cp']));
			$inmueble->appendChild($codpostal);

			$poblacion = $xml->createElement('poblacion');
			$poblacion->appendChild($xml->createCDATASection($resultado['localidad']));
			$inmueble->appendChild($poblacion);

			$provincia = $xml->createElement('provincia');
			$provincia->appendChild($xml->createCDATASection($resultado['provincia']));
			$inmueble->appendChild($provincia);

			$zona = $xml->createElement('zona');
			$zona->appendChild($xml->createCDATASection($resultado['zona']));
			$inmueble->appendChild($zona);

			$calle = $xml->createElement('calle');
			$calle->appendChild($xml->createCDATASection($resultado['direccion_calle']));
			$inmueble->appendChild($calle);

			$portal = $xml->createElement('portal');
			$portal->appendChild($xml->createCDATASection($resultado['direccion_numero']));
			$inmueble->appendChild($portal);

			$planta = $xml->createElement('planta');
			$planta->appendChild($xml->createCDATASection($resultado['direccion_piso']));
			$inmueble->appendChild($planta);

			$metros_parcela = $xml->createElement('metros_parcela');
			$metros_parcela->appendChild($xml->createCDATASection($resultado['superficie_terreno']));
			$inmueble->appendChild($metros_parcela);

			
			$floor_area = $xml->createElement('metros');
			$floor_area->appendChild($xml->createCDATASection($resultado['superficie_construida']));
			$inmueble->appendChild($floor_area);
			

			$metros_utiles = $xml->createElement('metros_utiles');
			$metros_utiles->appendChild($xml->createCDATASection($resultado['superficie_util']));
			$inmueble->appendChild($metros_utiles);


			if($resultado['habitaciones'] > 0){
				$rooms = $xml->createElement('dormitorios');
				$rooms->appendChild($xml->createCDATASection($resultado['habitaciones']));
				$inmueble->appendChild($rooms);
			}
			
			if($resultado['banos'] > 0 && $resultado['banos'] <= 20){
				$bathrooms = $xml->createElement('bathrooms');
				$bathrooms->appendChild($xml->createCDATASection($resultado['banos']));
				$inmueble->appendChild($bathrooms);
			}

			if($resultado['aseos'] > 0 && $resultado['aseos'] <= 20){
				$aseos = $xml->createElement('aseos');
				$aseos->appendChild($xml->createCDATASection($resultado['aseos']));
				$inmueble->appendChild($aseos);
			}

			
			$parking = $xml->createElement('garajes');
			$parking->appendChild($xml->createCDATASection( ($resultado['garaje']==0?"No":"Sí") ));
			$inmueble->appendChild($parking);


			$trastero = $xml->createElement('trastero');
			$trastero->appendChild($xml->createCDATASection( ($resultado["trastero"]==0?"No":"Sí") ));
			$inmueble->appendChild($trastero);

			$ascensor = $xml->createElement('ascensor');
			$ascensor->appendChild($xml->createCDATASection( ($resultado["ascensor"]==0?"No":"Sí") ));
			$inmueble->appendChild($ascensor);

			$piscina = $xml->createElement('piscina');
			$piscina->appendChild($xml->createCDATASection( ($resultado["piscina"]==0?"No":"Sí") ));
			$inmueble->appendChild($piscina);


		
		
			if($resultado['latitud'] >= -90 && $resultado['latitud'] <= 90 && $resultado['longitud'] >= -180 && $resultado['longitud'] <= 180){
			
				$latitude = $xml->createElement('latitude');
				$latitude->appendChild($xml->createCDATASection($resultado['latitud']));
				$inmueble->appendChild($latitude);
				
				$longitude = $xml->createElement('longitude');
				$longitude->appendChild($xml->createCDATASection($resultado['longitud']));
				$inmueble->appendChild($longitude);
			}

			
			
			

			
			$descripcion = $xml->createElement('datos_adicionales');
			
			$content = strip_tags(trim($resultado['descripcion']));
			$content = str_replace( array('vacacional','VACACIONAL'),array('en vacaciones','EN VACACIONES'),$content);
			$content = str_replace( array('naves industriales','NAVES INDUSTRIALES'),array('nave/s industrial/es','NAVE/S INDUSTRIAL/ES'),$content);
			$content = str_replace( array('se vende','SE VENDE'),array('',''),$content);
			$content = str_replace( array('naves en alquiler','NAVES EN ALQUILER'),array('naves','NAVES'),$content);
			$content = str_replace( array('negocio rentable','NEGOCIO RENTABLE'),array('negocio','NEGOCIO'),$content);
			$palabrasCadena = explode(" ",$content); // Separamos la cadena por los espacios
			$contenido="";
			foreach($palabrasCadena as $valor){

				if(strlen($valor)<42){
					$contenido.=" ";
					$contenido.=$valor;	
				}
			}

			if($contenido != ''){
				if(strlen($contenido) < 30 )
					$descripcion->appendChild($xml->createCDATASection("$contenido. {$resultado['tipologia']} en {$resultado['localidad']} de {$resultado['superficie_construida']} m2, {$resultado['habitaciones']} habitacion/es, {$resultado['banos']} baño/s."));
				else
				$descripcion->appendChild($xml->createCDATASection($contenido));
			}
			else
				$descripcion->appendChild($xml->createCDATASection("{$resultado['tipologia']} en {$resultado['localidad']} de {$resultado['superficie_construida']} m2, {$resultado['habitaciones']} habitacion/es, {$resultado['banos']} baño/s."));
			
			$inmueble->appendChild($descripcion);
			
			
			

			
			
			//$pictures = $xml->createElement('pictures');
			$SQLfotos = "
						 SELECT 
							* 
						 FROM 
							inmuebles_galeria
						 WHERE
							id_inmueble = '{$resultado['id']}'
						 AND 
							tipo = 'imagen'
						ORDER BY
							principal DESC, orden ASC
						 ";
						 
			$consulta2 = @mysql_query($SQLfotos);
			
			if(mysql_error()){
				// echo $SQL;
				echo "Se ha producido un error";
				die;
			}
			if(mysql_num_rows($consulta2)){
				$i=1;
				while($resultado2 = mysql_fetch_assoc($consulta2)){
					$fotos = $xml->createElement('foto'.$i);
					$fotos->appendChild($xml->createCDATASection($resultado2['url']));
					$inmueble->appendChild($fotos);
					$i++;
				}
			}
				
			
			//$inmueble->appendChild($pictures);
			
			$inmuebles->appendChild($inmueble);
		}

	}
	
	$xml->appendChild($inmuebles);

//}

// header('Content-Type: text/xml');
// echo $xml->saveXML();
$xml->save('pisocasas_feed.xml');
?>
© 2026 GrazzMean