Advertisement
Guest User

Untitled

a guest
Nov 16th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.31 KB | None | 0 0
  1. <?php
  2. $url = "http://clareslab.com.br";
  3. $site_url = "http://clareslab.com.br/imobiliariav4-demo/detalhes-do-imovel/";
  4. $host = 'localhost';
  5. $user = 'root';
  6. $pass = 'root';
  7. $dbname = 'v4';
  8. $dbh = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
  9.  
  10. $Headers = $dbh->query('SELECT * FROM config')->fetchAll(\PDO::FETCH_CLASS);
  11. $imoveis = $dbh->query('SELECT * FROM imovel INNER JOIN tipo ON (imovel_tipo = tipo_id)
  12. INNER JOIN negocio ON (imovel_negocio = negocio_id) INNER JOIN opcao ON (imovel_opcao = opcao_id)
  13. INNER JOIN cidade ON (imovel_cidade = cidade_id) INNER JOIN bairro ON (imovel_bairro = bairro_id)
  14. ORDER BY imovel_id DESC ')->fetchAll(\PDO::FETCH_CLASS);
  15.  
  16.  
  17. $handle = @opendir(".");
  18. $xml = fopen("vivareal.xml", "w+");
  19. fwrite($xml, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<ListingDataFeed xmlns=\"http://www.vivareal.com/schemas/1.0/VRSync\"
  20.                 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
  21.                 xsi:schemaLocation=\"http://www.vivareal.com/schemas/1.0/VRSync  http://xml.vivareal.com/vrsync.xsd\">\n
  22.                 <Header>
  23.        <Provider>{$Headers[0]->config_nome}</Provider>
  24.        <Email>{$Headers[0]->config_email}</Email>
  25.        <ContactName>{$Headers[0]->config_nome}</ContactName>
  26.        <Logo>$url. 'midia/' .{$Headers[0]->config_foto}</Logo>
  27.        <Telephone>{$Headers[0]->config_fone1}</Telephone>
  28.  </Header>\n<Listings>\n\n");
  29.  
  30.  
  31. foreach ($imoveis as $imovel) {
  32.     $conteudo = '  <Listing>' . "\n";
  33.     $conteudo .= '<ListingID>' . $imovel->imovel_id . '</ListingID>' . "\n";
  34.     $conteudo .= '<TransactionType>' . $imovel->negocio_nome . '</TransactionType>' . "\n";
  35.     $conteudo .= '     <Featured>' . true . '</Featured>' . "\n"; //imovel em destaque
  36.     $conteudo .= '     <ListDate>' . date('d/m/Y') . '</ListDate>' . "\n";
  37.     $conteudo .= '     <LastUpdateDate>' . date('d/m/Y') . '</LastUpdateDate>' . "\n";
  38.     $conteudo .= '     <DetailViewUrl>' . $site_url . $imovel->cidade_url . '/' . $imovel->bairro_url . '/' . $imovel->imovel_id . '/' . $imovel->tipo_url . '/' . '</DetailViewUrl>' . "\n";
  39.     $fotos = $dbh->query("SELECT * FROM foto WHERE foto_imovel = {$imovel->imovel_id}")->fetchAll(\PDO::FETCH_CLASS);
  40.     $conteudo .= '  <Media>' . "\n";
  41.     $conteudo .= '     <Item medium="image" caption="nome imagem" primary="true">' . $site_url . 'midia/' . $fotos[0]->foto_url . '</Item>' . "\n";
  42.     foreach ($fotos as $foto) {
  43.         $conteudo .= '     <Item medium="image" caption="nome imagem">' . $site_url . 'midia/' . $foto->foto_url . '</Item>' . "\n";
  44.     }
  45.     $conteudo .= '</Media>' . "\n";
  46.     $conteudo .= '<Details>' . "\n";
  47.     $conteudo .= '<PropertyType>' . $imovel->tipo_nome . '</PropertyType>' . "\n";
  48.     $conteudo .= '<Description><![CDATA[' . $imovel->imovel_descricao . ']]></Description>' . "\n";
  49.     $conteudo .= '<ListPrice currency="BRL">' . $imovel->imovel_preco . '</ListPrice>' . "\n";
  50.     $conteudo .= '<RentalPrice currency="BRL" period="Monthly">' . $imovel_preco_locacao . '</RentalPrice>' . "\n";
  51.     $conteudo .= '<PropertyAdministrationFee currency="BRL">' . $imovel_preco_condominio . '</PropertyAdministrationFee>' . "\n";
  52.     $conteudo .= '<YearlyTax currency="BRL">' . $imovel->imovel_preco_iptu . '</YearlyTax>' . "\n";
  53.     $conteudo .= '<LivingArea unit="square metres">' . $imovel->imovel_area . '</LivingArea>' . "\n";
  54.     $conteudo .= '<Bedrooms>' . $imovel->imovel_dormitorio . '</Bedrooms>' . "\n";
  55.     $conteudo .= '<Bathrooms>' . $imovel->imovel_banheiro . '</Bathrooms>' . "\n";
  56.     $conteudo .= '<Suites>' . $imovel->imovel_suite . '</Suites>' . "\n";
  57.     $conteudo .= '<Garage type="Parking Space">' . $imovel->imovel_vaga . '</Garage>' . "\n";
  58.     $opcs = $dbh->query("SELECT * FROM opcao WHERE opcao_id IN ($imovel->imovel_opcao)")->fetchAll(\PDO::FETCH_CLASS);
  59.     $conteudo .= '<Features>' . "\n";
  60.     foreach ($opcs as $opc) {
  61.         $conteudo .= '   <Feature>' . $opc->opcao_nome . '</Feature>' . "\n";
  62.     }
  63.     $conteudo .= '</Features>' . "\n";
  64.     $conteudo .= '</Details>' . "\n";
  65.     $conteudo .= '<Location displayAddress="All">' . "\n";
  66.     $conteudo .= '<Country abbreviation="BR">Brasil</Country>' . "\n";
  67.     $conteudo .= '<State abbreviation="SP">' . "São Paulo" . '</State>' . "\n"; //FICOU FALTANDO
  68.     $conteudo .= '<City>' . $imovel->cidade_nome . '</City>' . "\n";
  69.     $conteudo .= '<Neighborhood>' . $imovel->bairro_nome . '</Neighborhood>' . "\n";
  70.     $conteudo .= '<Address>' . $imovel->imovel_endereco . '</Address>' . "\n";
  71.     $conteudo .= '<StreetNumber>' . $NUMERO . '</StreetNumber>' . "\n";//FICOU FALTANDO
  72.     $conteudo .= '<PostalCode>' . $CEP . '</PostalCode>' . "\n";//FICOU FALTANDO
  73.     $conteudo .= '<Latitude>' . $imovel->imovel_lat . '</Latitude>' . "\n";
  74.     $conteudo .= '<Longitude>' . $imovel->imovel_lon . '</Longitude>' . "\n";
  75.     $conteudo .= '</Location>' . "\n";
  76.     $conteudo .= '<ContactInfo>' . "\n";
  77.     $conteudo .= '<Name>' . $imovel->config_nome . '</Name>' . "\n";
  78.     $conteudo .= '<Email>' . $imovel->config_email . '</Email>' . "\n";
  79.     $conteudo .= '<Website>' . $url . '</Website>' . "\n";
  80.     $conteudo .= '<Photo>' . $url . '/midia/' . $imovel->config_foto . '</Photo>' . "\n";
  81.     $conteudo .= '<Logo>' . $url . '/midia/' . $imovel->config_logo . '</Logo>' . "\n";
  82.     $conteudo .= '<OfficeName>' . $imovel->config_nome . '</OfficeName>' . "\n";
  83.     $conteudo .= '<Telephone>' . $imovel->config_fone1 . '</Telephone>' . "\n";
  84.     $conteudo .= '<Location>' . "\n";
  85.     $conteudo .= '<Country abbreviation="BR">Brasil</Country>' . "\n";
  86.     $conteudo .= '<State abbreviation="SP">' . $ESTADO . '</State>' . "\n";//FICOU FALTANDO
  87.     $conteudo .= '<City>' . $imovel->cidade_nome . '</City>' . "\n";
  88.     $conteudo .= '<Neighborhood> </Neighborhood>' . "\n"; //PEDIU PRA DEIXAR EM BRANCO
  89.     $conteudo .= '<Address>' . $ENDEREÇO . '</Address>' . "\n"; //FICOU FALTANDO
  90.     $conteudo .= '<PostalCode>' . $CEP . '</PostalCode>' . "\n"; //FICOU FALTANDO
  91.     $conteudo .= '<Latitude>' . $imovel->config_lat . '</Latitude>' . "\n";
  92.     $conteudo .= '<Longitude>' . $imovel->config_lon . '</Longitude>' . "\n";
  93.     $conteudo .= '</Location>' . "\n";
  94.     $conteudo .= '</ContactInfo>' . "\n";
  95.     $conteudo .= '</Listing>' . "\n";
  96.     fwrite($xml, $conteudo);
  97. }
  98. closedir($handle);
  99. fwrite($xml, "\n</Listings></ListingDataFeed>");
  100. fclose($xml);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement