Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $url = "http://clareslab.com.br/imobiliariav4";
- $site_url = "http://clareslab.com.br/imobiliariav4-demo/detalhes-do-imovel";
- $host = 'localhost';
- $user = 'root';
- $pass = 'root';
- $dbname = 'v4';
- $dbh = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
- $Headers = $dbh->query('SELECT * FROM config')->fetchAll(\PDO::FETCH_CLASS);
- $imobiliaria = $Headers[0];
- $imoveis = $dbh->query('SELECT * FROM imovel INNER JOIN tipo ON (imovel_tipo = tipo_id)
- INNER JOIN negocio ON (imovel_negocio = negocio_id) INNER JOIN opcao ON (imovel_opcao = opcao_id)
- INNER JOIN cidade ON (imovel_cidade = cidade_id) INNER JOIN bairro ON (imovel_bairro = bairro_id)
- WHERE imovel_xml = 1
- ORDER BY imovel_id DESC ')->fetchAll(\PDO::FETCH_CLASS);
- $imobiliaria->config_logo = $imobiliaria->config_foto;
- $handle = @opendir(".");
- $xml = fopen("vivareal.xml", "w+");
- fwrite($xml, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<ListingDataFeed xmlns=\"http://www.vivareal.com/schemas/1.0/VRSync\"
- xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
- xsi:schemaLocation=\"http://www.vivareal.com/schemas/1.0/VRSync http://xml.vivareal.com/vrsync.xsd\">\n
- <Header>
- <Provider>{$imobiliaria->config_nome}</Provider>
- <Email>{$imobiliaria->config_email}</Email>
- <ContactName>{$imobiliaria->config_nome}</ContactName>
- <Logo>$url/midias/logo/{$imobiliaria->config_logo}</Logo>
- <Telephone>{$imobiliaria->config_fone1}</Telephone>
- </Header>\n<Listings>\n\n");
- foreach ($imoveis as $imovel) {
- $listdate = date_create("$imovel->imovel_create");
- $lastupdate = date_create("$imovel->imovel_update");
- $featured = ($imovel->imovel_destaque == 0) ? 'false' : 'true';
- $conteudo = ' <Listing>' . "\n";
- $conteudo = '<Title><![CDATA[' . $imovel->tipo_nome . 'em' . $imovel->cidade_nome . ']]></Title>' . "\n";
- $conteudo .= '<ListingID>' . $imovel->imovel_id . '</ListingID>' . "\n";
- switch ($imovel->negocio_nome) {
- case 'Venda':
- $conteudo .= '<TransactionType>For Rent</TransactionType>' . "\n";
- break;
- case 'Locação':
- $conteudo .= '<TransactionType>For Sale</TransactionType>' . "\n";
- break;
- }
- $conteudo .= ' <Featured>' . $featured . '</Featured>' . "\n";
- $conteudo .= ' <ListDate>' . date_format($listdate, "Y-m-d") . '</ListDate>' . "\n";
- $conteudo .= ' <LastUpdateDate>' . date_format($lastupdate, "Y-m-d") . '</LastUpdateDate>' . "\n";
- $conteudo .= ' <DetailViewUrl>' . $site_url . '/' . $imovel->cidade_url . '/' . $imovel->bairro_url . '/' . $imovel->imovel_id . '/' . $imovel->tipo_url . '/' . '</DetailViewUrl>' . "\n";
- $fotos = $dbh->query("SELECT * FROM foto WHERE foto_imovel = {$imovel->imovel_id}")->fetchAll(\PDO::FETCH_CLASS);
- $conteudo .= ' <Media>' . "\n";
- $conteudo .= '<Item medium="image" caption="' . $fotos[0]->foto_url . '" primary="true">' . $site_url . '/midias/fotos/' . $fotos[0]->foto_url . '</Item>' . "\n";
- foreach ($fotos as $foto) {
- $conteudo .= '<Item medium="image" caption="' . $foto->foto_url . '">' . $site_url . '/midias/fotos/' . $foto->foto_url . '</Item>' . "\n";
- }
- $conteudo .= '</Media>' . "\n";
- $conteudo .= '<Details>' . "\n";
- switch ($imovel->tipo_nome) {
- case 'Apartamento':
- $conteudo .= '<PropertyType>Residential/Apartment</PropertyType>' . "\n";
- break;
- case 'Casa':
- $conteudo .= '<PropertyType>Residential/Home</PropertyType>' . "\n";
- break;
- case 'Chácara':
- $conteudo .= '<PropertyType>Residential/Farm Ranch</PropertyType>' . "\n";
- break;
- case 'Casa de Condomínio':
- $conteudo .= '<PropertyType>Residential/Condo</PropertyType>' . "\n";
- break;
- case 'Flat':
- $conteudo .= '<PropertyType>Residential/Flat</PropertyType>' . "\n";
- break;
- case 'Lote/Terreno Residencial':
- $conteudo .= '<PropertyType>Residential/Land Lot</PropertyType>' . "\n";
- break;
- case 'Sobrado':
- $conteudo .= '<PropertyType>Residential/Sobrado</PropertyType>' . "\n";
- break;
- case 'Cobertura':
- $conteudo .= '<PropertyType>Residential/Penthouse</PropertyType>' . "\n";
- break;
- case 'Kitnet':
- $conteudo .= '<PropertyType>Residential/Kitnet</PropertyType>' . "\n";
- break;
- case 'Consultório':
- $conteudo .= '<PropertyType>Commercial/Consultorio</PropertyType>' . "\n";
- break;
- case 'Sala Comercial':
- $conteudo .= '<PropertyType>Commercial/Office</PropertyType>' . "\n";
- break;
- case 'Fazenda/Sitio':
- $conteudo .= '<PropertyType>Commercial/Agricultural</PropertyType>' . "\n";
- break;
- case 'Galpão/Depósito/Armazém':
- $conteudo .= '<PropertyType>Commercial/Industrial</PropertyType>' . "\n";
- break;
- case 'Imóvel Comercial':
- $conteudo .= '<PropertyType>Commercial/Building</PropertyType>' . "\n";
- break;
- case 'Loja':
- $conteudo .= '<PropertyType>Commercial/Loja</PropertyType>' . "\n";
- break;
- case 'Lote/Terreno Comercial':
- $conteudo .= '<PropertyType>Commercial/Land Lot</PropertyType>' . "\n";
- break;
- case 'Ponto Comercial':
- $conteudo .= '<PropertyType>Commercial/Business</PropertyType>' . "\n";
- break;
- case 'Edifício Residencial':
- $conteudo .= '<PropertyType>Commercial/Residential Income</PropertyType>' . "\n";
- break;
- }
- $conteudo .= '<Description><![CDATA[' . $imovel->imovel_descricao . ']]></Description>' . "\n";
- switch ($imovel->negocio_nome) {
- case 'Venda':
- $conteudo .= '<ListPrice currency="BRL">' . substr($imovel->imovel_preco, 0, -3) . '</ListPrice>' . "\n";
- break;
- case 'Locação':
- $conteudo .= '<RentalPrice currency="BRL" period="Monthly">' . substr($imovel->imovel_preco_locacao, 0, -3) . '</RentalPrice>' . "\n";
- break;
- }
- $conteudo .= '<PropertyAdministrationFee currency="BRL">' . $imovel->imovel_preco_condominio . '</PropertyAdministrationFee>' . "\n";
- $conteudo .= '<YearlyTax currency="BRL">' . $imovel->imovel_preco_iptu . '</YearlyTax>' . "\n";
- $conteudo .= '<LivingArea unit="square metres">' . $imovel->imovel_area . '</LivingArea>' . "\n";
- $conteudo .= '<Bedrooms>' . $imovel->imovel_dormitorio . '</Bedrooms>' . "\n";
- $conteudo .= '<Bathrooms>' . $imovel->imovel_banheiro . '</Bathrooms>' . "\n";
- $conteudo .= '<Suites>' . $imovel->imovel_suite . '</Suites>' . "\n";
- $conteudo .= '<Garage type="Parking Space">' . $imovel->imovel_vaga . '</Garage>' . "\n";
- $opcs = $dbh->query("SELECT * FROM opcao WHERE opcao_id IN ($imovel->imovel_opcao)")->fetchAll(\PDO::FETCH_CLASS);
- $conteudo .= '<Features>' . "\n";
- foreach ($opcs as $opc) {
- $conteudo .= ' <Feature>' . $opc->opcao_nome . '</Feature>' . "\n";
- }
- $conteudo .= '</Features>' . "\n";
- $conteudo .= '</Details>' . "\n";
- $conteudo .= '<Location displayAddress="' . $imovel->imovel_mapa == 1 ? 'All' : 'Street' . '">' . "\n";
- $conteudo .= '<Country abbreviation="BR">Brasil</Country>' . "\n";
- $conteudo .= '<State abbreviation="SP">' . "$imovel->config_estado" . '</State>' . "\n";
- $conteudo .= '<City>' . $imovel->cidade_nome . '</City>' . "\n";
- $conteudo .= '<Neighborhood>' . $imovel->bairro_nome . '</Neighborhood>' . "\n";
- $conteudo .= '<Address>' . $imovel->imovel_endereco . '</Address>' . "\n";
- $conteudo .= '<StreetNumber>' . $imovel->imovel_num . '</StreetNumber>' . "\n";
- $conteudo .= '<PostalCode>' . $imovel->imovel_cep . '</PostalCode>' . "\n";
- $conteudo .= '<Latitude>' . $imovel->imovel_lat . '</Latitude>' . "\n";
- $conteudo .= '<Longitude>' . $imovel->imovel_lon . '</Longitude>' . "\n";
- $conteudo .= '</Location>' . "\n";
- $conteudo .= '<ContactInfo>' . "\n";
- $conteudo .= '<Name>' . $imobiliaria->config_nome . '</Name>' . "\n";
- $conteudo .= '<Email>' . $imobiliaria->config_email . '</Email>' . "\n";
- $conteudo .= '<Website>' . $url . '</Website>' . "\n";
- $conteudo .= '<Photo>' . $url . '/midia/' . $imobiliaria->config_logo . '</Photo>' . "\n";
- $conteudo .= '<Logo>' . $url . '/midia/' . $imobiliaria->config_logo . '</Logo>' . "\n";
- $conteudo .= '<OfficeName>' . $imobiliaria->config_nome . '</OfficeName>' . "\n";
- $conteudo .= '<Telephone>' . $imobiliaria->config_fone1 . '</Telephone>' . "\n";
- $conteudo .= '<Location>' . "\n";
- $conteudo .= '<Country abbreviation="BR">Brasil</Country>' . "\n";
- $conteudo .= '<State abbreviation="SP">' . $imobiliaria->config_estado . '</State>' . "\n";
- $conteudo .= '<City>' . $imobiliaria->config_cidade . '</City>' . "\n";
- $conteudo .= '<Neighborhood>' . $imobiliaria->config_bairro . '</Neighborhood>' . "\n";
- $conteudo .= '<Address>' . $imobiliaria->config_end . '</Address>' . "\n";
- $conteudo .= '<PostalCode>' . $imobiliaria->config_cep . '</PostalCode>' . "\n";
- $conteudo .= '<Latitude>' . $imobiliaria->config_lat . '</Latitude>' . "\n";
- $conteudo .= '<Longitude>' . $imobiliaria->config_lon . '</Longitude>' . "\n";
- $conteudo .= '</Location>' . "\n";
- $conteudo .= '</ContactInfo>' . "\n";
- $conteudo .= '</Listing>' . "\n";
- fwrite($xml, $conteudo);
- }
- closedir($handle);
- fwrite($xml, "\n</Listings></ListingDataFeed>");
- fclose($xml);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement