Advertisement
Googleinurl

Funções Gerais php

Oct 31st, 2012
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 137.41 KB | None | 0 0
  1. <?php
  2. //-----------------------------------------------------------------------\\
  3. //          busca_cep($cep)                                              \\
  4. //  DESC:   Busca cep retornando os valores da cidade e estado           \\
  5. //                                                                       \\
  6. //   $resultado_busca = busca_cep('87040250');                           \\
  7. //   print_r($resultado_busca, true);                                    \\
  8. //                                                                       \\
  9. //    echo $resultado_busca['cidade'];                                   \\
  10. //                                                                       \\
  11. //-----------------------------------------------------------------------\\
  12.  
  13. function busca_cep($cep){
  14.  
  15.  
  16.  
  17.     ini_set("allow_url_fopen", 1);
  18.  
  19.     ini_set("allow_url_include", 1);
  20.  
  21.  
  22.  
  23.     $cep = $cep.'000';
  24.  
  25.     $resultado = @file_get_contents('http://republicavirtual.com.br/web_cep.php?cep='.urlencode($cep).'&formato=query_string');
  26.  
  27.     if(!$resultado){
  28.  
  29.         $resultado = "&resultado=0&resultado_txt=erro+ao+buscar+cep";
  30.  
  31.     }
  32.  
  33.     ini_set("allow_url_fopen", 0);
  34.  
  35.     ini_set("allow_url_include", 0);
  36.  
  37.  
  38.  
  39.     parse_str($resultado, $retorno);
  40.  
  41.     return $retorno;
  42.  
  43. }
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57. //-----------------------------------------------------------------------\\
  58.  
  59. //  busca2_cep($cep)                                                     \\
  60.  
  61. //  Função que busca a cidade e o estado                                 \\
  62.  
  63. //  http://comercio.locaweb.com.br/correios/calcula_sedex.asp            \\
  64.  
  65. //                                                                       \\
  66.  
  67. //   $resultado_busca = busca_cep('87040250');                           \\
  68.  
  69. //   print_r($resultado_busca, true);                                    \\
  70.  
  71. //                                                                       \\
  72.  
  73. //    echo $resultado_busca['cidade'];                                   \\
  74.  
  75. //                                                                       \\
  76.  
  77. //$resultado = file_get_contents('http://republicavirtual.com.br/web_cep.php?cep='.urlencode($cep).'&formato=query_string');
  78.  
  79. //$resultado = file_get_contents('http://viavirtual.com.br/webservicecep.php?cep='.$cep.'');
  80.  
  81. //-----------------------------------------------------------------------\\
  82.  
  83. function busca_cep2($cep){
  84.  
  85.  
  86.  
  87.     ini_set("allow_url_fopen", 1);
  88.  
  89.     ini_set("allow_url_include", 1);
  90.  
  91.  
  92.  
  93.     $cepOK = $cep.'000';
  94.  
  95.  
  96.  
  97.  
  98.  
  99.     $resultado = file_get_contents("http://comercio.locaweb.com.br/correios/calcula_sedex.asp?cepOrig=$cepOK&cepDest=$cepOK&pesoDeclarado=10&vlrDeclarado=40&metodo=leitura");
  100.  
  101.  
  102.  
  103.     $explode = explode('<br>',$resultado);
  104.  
  105.  
  106.  
  107.     if($explode[0] == 'OK'){
  108.  
  109.  
  110.  
  111.         $cidade = explode('Cidade: ',$explode[3]);
  112.  
  113.         $cidadeOK = $cidade[1];
  114.  
  115.         $estado = explode('UF: ',$explode[4]);
  116.  
  117.         $estadoOK = $estado[1];
  118.  
  119.         return "$cidadeOK|$estadoOK";
  120.  
  121.  
  122.  
  123.     }else{
  124.  
  125.         return 0;
  126.  
  127.     }
  128.  
  129.  
  130.  
  131.  
  132.  
  133.     ini_set("allow_url_fopen", 0);
  134.  
  135.     ini_set("allow_url_include", 0);
  136.  
  137.  
  138.  
  139.     //print_r($retorno);
  140.  
  141. }
  142.  
  143.  
  144.  
  145. function busca_cep3($cep){
  146.  
  147.  
  148.  
  149.     ini_set("allow_url_fopen", 1);
  150.  
  151.     ini_set("allow_url_include", 1);
  152.  
  153.  
  154.  
  155.     $cepOK = $cep;
  156.  
  157.  
  158.  
  159.  
  160.  
  161.     $resultado = file_get_contents("http://comercio.locaweb.com.br/correios/calcula_sedex.asp?cepOrig=$cepOK&cepDest=$cepOK&pesoDeclarado=10&vlrDeclarado=40&metodo=leitura");
  162.  
  163.  
  164.  
  165.     $explode = explode('<br>',$resultado);
  166.  
  167.  
  168.  
  169.     if($explode[0] == 'OK'){
  170.  
  171.  
  172.  
  173.         $cidade = explode('Cidade: ',$explode[3]);
  174.  
  175.         $cidadeOK = $cidade[1];
  176.  
  177.         $estado = explode('UF: ',$explode[4]);
  178.  
  179.         $estadoOK = $estado[1];
  180.  
  181.         return "$cidadeOK|$estadoOK";
  182.  
  183.  
  184.  
  185.     }else{
  186.  
  187.         return 0;
  188.  
  189.     }
  190.  
  191.  
  192.  
  193.  
  194.  
  195.     ini_set("allow_url_fopen", 0);
  196.  
  197.     ini_set("allow_url_include", 0);
  198.  
  199.  
  200.  
  201.     //print_r($retorno);
  202.  
  203. }
  204.  
  205.  
  206.  
  207. /*
  208.  
  209. * Funcao para retornar o nome da cidade
  210.  
  211. */
  212.  
  213. function RetornaNomeCidade($codcid){
  214.  
  215.  
  216.  
  217.     $sqlCidade = "SELECT nome FROM cidades WHERE ID=$codcid";
  218.  
  219.     $sqlCidade = mysql_query($sqlCidade);
  220.  
  221.     $nomeCidade = mysql_result($sqlCidade,0,'nome');
  222.  
  223.     return $nomeCidade;
  224.  
  225. }
  226.  
  227.  
  228.  
  229.  
  230.  
  231. /*
  232.  
  233. * Funcao para apaga o ultimo título duplicado do usuario
  234.  
  235. */
  236.  
  237. function ApagaTituloDuplicado($fk_usuario,$titulo){
  238.  
  239.  
  240.     $sql = "SELECT ID FROM anuncio WHERE titulo='$titulo' AND fk_usuario='$fk_usuario' order by ID ASC";   
  241.  
  242.     $sql = mysql_query($sql);
  243.  
  244.    
  245.  
  246.     while ($row = mysql_fetch_array($sql)) {
  247.  
  248.         ExcluiAnuncio($row['ID'],$fk_usuario,'Anúncio com título duplicado');
  249.  
  250.     }
  251.  
  252. }
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260. /*
  261.  
  262. * Funcao que retorna 's' ou 'n' para o campo robotsnoindex
  263.  
  264. */
  265.  
  266. function ReturnNoIndex($fk_usuario,$descricao){
  267.  
  268.     $sql = "SELECT ID FROM anuncio WHERE descricao='$descricao'";  
  269.  
  270.     $sql = mysql_query($sql);
  271.  
  272.     $total = mysql_num_rows($sql);
  273.  
  274.    
  275.  
  276.     if($total > 0){
  277.  
  278.         $resposta = 's';
  279.  
  280.     }else{
  281.  
  282.         $resposta = 'n';
  283.  
  284.     }
  285.  
  286.     return $resposta;
  287.  
  288. }
  289.  
  290.  
  291.  
  292. /*
  293.  
  294. * Funcao para adcionar a meta tag Noindex nos anúncios com descricao duplicada do mesmo anunciante
  295.  
  296. */
  297.  
  298. function NoIndex($fk_usuario,$descricao){
  299.  
  300.     global $db;
  301.  
  302.    
  303.  
  304.     $sql = "SELECT ID FROM anuncio WHERE descricao='$descricao' AND fk_usuario='$fk_usuario'"; 
  305.  
  306.     $sql = mysql_query($sql);
  307.  
  308.     $total = mysql_num_rows($sql); 
  309.  
  310.    
  311.  
  312.  
  313.  
  314.  
  315.  
  316.     if($total > 0){
  317.  
  318.    
  319.  
  320.         $sql2 = "SELECT MIN(ID) FROM anuncio WHERE descricao='$descricao' AND fk_usuario='$fk_usuario'";   
  321.  
  322.         $sql2 = mysql_query($sql2);
  323.  
  324.         $IDminimo = mysql_result($sql2,0);
  325.  
  326.        
  327.  
  328.  
  329.  
  330.  
  331.  
  332.         while ($row = mysql_fetch_array($sql)) {
  333.  
  334.             $up = "UPDATE anuncio SET robotsnoindex='s' WHERE fk_usuario=$fk_usuario AND ID=$row[ID]";
  335.  
  336.             $up_query = mysql_db_query($db['db'],$up);
  337.  
  338.         }
  339.  
  340.  
  341.  
  342.         $up = "UPDATE anuncio SET robotsnoindex='n' WHERE fk_usuario=$fk_usuario AND ID=$IDminimo";
  343.  
  344.         $up_query = mysql_db_query($db['db'],$up);     
  345.  
  346.        
  347.  
  348.    
  349.  
  350.     }
  351.  
  352.  
  353.  
  354.    
  355.  
  356.  
  357.  
  358.  
  359.  
  360.    
  361.  
  362.  
  363.  
  364.  
  365.  
  366. }
  367.  
  368.  
  369.  
  370.  
  371.  
  372. /*
  373.  
  374. * Funcao para estrair caracteres especiais das meta tags
  375.  
  376. */
  377.  
  378. function ClearTags($string){
  379.  
  380.     $filtro = array('/' => '', ' - ' => '', '  ' => '');
  381.  
  382.     $string = strTr($string, $filtro);
  383.  
  384.    
  385.  
  386.     $string = preg_replace('/\s/',' ',$string);
  387.  
  388.     $string = ereg_replace(' +', ' ', $string);
  389.     //$string = preg_replace(' +', ' ', $string);
  390.  
  391.     $string = trim($string);
  392.  
  393.     $string  = strtolower($string);
  394.  
  395.  
  396.  
  397.     return $string;
  398.  
  399. }
  400.  
  401. /* Funcoes para montar os menus da página inicial */
  402. function CriaMenu($valor,$estado,$cidade){
  403.  
  404.     $sql = "SELECT ID, nome, url FROM categoria_mae where ID = $valor";
  405.     $sql = mysql_query($sql);
  406.     //$total = mysql_num_rows($sql);// total de registros
  407.  
  408.     /* Exemplo 1 */
  409.     $nome = mysql_result($sql,0,"nome");
  410.     $urls = mysql_result($sql,0,"url");
  411.     $IDmenu = mysql_result($sql,0,"ID");
  412.     @$nomeEstado = NomeEstado($estado);
  413.     if($nomeEstado){
  414.         $nomeEstado = $nomeEstado;
  415.     }else{
  416.         $nomeEstado = 'Brasil';
  417.     }
  418.  
  419.     //$completaURL1 = StringUrlAmigavel("$nome $nomeEstado");
  420.     $nomeEstUrl = StringUrlAmigavel($nomeEstado);
  421.    
  422.  
  423.     if($nomeEstUrl != 'brasil'){
  424.         $estadoUrlShow1 = $nomeEstUrl.'-';
  425.     }else{
  426.        $estadoUrlShow1 = 'brasil';
  427.     }      
  428.    
  429.     $completaURL1 =  $urls.'-'.$estadoUrlShow1."__$estado-$cidade-$IDmenu--.htm";
  430.  
  431.     if($valor == 8){
  432.        $linkMenu = "<a href=\"$completaURL1\" class=\"menu_bot_amarelo\" onclick=\"
  433. Modalbox.show('confirm_age.php?url=$completaURL1', {beforeLoad: function() { Modalbox.deactivate(); },title: 'Info', width: 750, overlayClose:false, inactiveFade:false}); return false;
  434. \">$nome</a>";
  435.  
  436.     }else{
  437.         $linkMenu = "<a href=\"$completaURL1\" class=\"menu_bot_amarelo\">$nome</a>";
  438.     }
  439.  
  440.     echo "
  441.        <div class=\"menu_amarelo\">
  442.        <div style=\" padding-top:5px;\">
  443.        <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"$nome\" /></div>
  444.        <div style=\"margin-left:20px; margin-top:0px\">$linkMenu</div>
  445.        </div>
  446.        </div>";
  447. }
  448.  
  449. /* Funcoes para montar os menus da página inicial */
  450. function CriaSubMenu($valor,$estado,$cidade){
  451.  
  452.     $sqlCategoria1 = "SELECT nome,url FROM categoria_mae WHERE ID=$valor";
  453.     $sqlCategoria1 = mysql_query($sqlCategoria1);
  454.     $categoria_mae = mysql_result($sqlCategoria1,0,"nome");
  455.     $categoria_url = mysql_result($sqlCategoria1,0,"url");
  456.  
  457.     $sql = "SELECT ID, nome,url FROM sub_categoria where fk_categoria = $valor limit 18";
  458.     $sql = mysql_query($sql);
  459.     //$total = mysql_num_rows($sql);// total de registros
  460.  
  461.     @$nomeEstado = NomeEstado($estado);
  462.     if($nomeEstado){
  463.         $nomeEstado = $nomeEstado;
  464.     }else{
  465.         $nomeEstado = 'Brasil';
  466.     }
  467.  
  468.     while ($row = mysql_fetch_array($sql)) { //retorna a lista
  469.        
  470.         $estadoURL1 = StringUrlAmigavel($nomeEstado);
  471.        
  472.         if($estadoURL1 != 'brasil'){
  473.         $estadoUrlShow2 = $estadoURL1.'-';
  474.         }else{
  475.         $estadoUrlShow2 = 'brasil';
  476.         }
  477.        
  478.         $completaURL1 =  $categoria_url.'-'.$row['url'].'-'.$estadoUrlShow2."__$estado-$cidade-$valor-$row[ID]-.htm";
  479.  
  480.         if($valor == 8){
  481.  
  482.                   echo "<div class=\"menu_bot_links\" style=\"margin-top:3px;\"><div style=\" padding-left:8px; padding-top:2px;\"><a href=\"$completaURL1\" class=\"menu_bot_links\" onclick=\"
  483.  
  484. Modalbox.show('confirm_age.php?url=$completaURL1', {beforeLoad: function() { Modalbox.deactivate(); },title: 'Info', width: 750, overlayClose:false, inactiveFade:false}); return false;
  485.  
  486. \">$row[nome]</a></div></div>";
  487.  
  488.         }else{
  489.  
  490.                 echo "<div class=\"menu_bot_links\" style=\"margin-top:3px;\"><div style=\" padding-left:8px; padding-top:2px;\"><a href=\"$completaURL1\" class=\"menu_bot_links\">$row[nome]</a></div></div>";
  491.  
  492.         }
  493.  
  494.  
  495.  
  496.  
  497.  
  498.    }
  499.  
  500. }
  501.  
  502.  
  503.  
  504.  
  505.  
  506. function CropTexto($integra,$n_caracter) {
  507.  
  508.     //-----------------------------------------------------------------------\\
  509.  
  510.     //           CropTexto(string,number)                                    \\
  511.  
  512.     //  DESC: Esta função vai cortar a string e colocar ... caso o numero    \\
  513.  
  514.     //        for menor q o tamanho da string                                \\
  515.  
  516.     //-----------------------------------------------------------------------\\
  517.  
  518.  
  519.  
  520.         $corta_integra = substr($integra, 0, $n_caracter);
  521.  
  522.         $conta_integra = strlen($corta_integra);
  523.  
  524.  
  525.  
  526.         if($conta_integra >= $n_caracter){
  527.  
  528.             $textoCrop = $corta_integra."...";
  529.  
  530.         }else{
  531.  
  532.             $textoCrop = $corta_integra;
  533.  
  534.         }
  535.  
  536.  
  537.  
  538.         return $textoCrop;
  539.  
  540. }
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548. function GetMidString($str,$iS,$iE) {
  549.  
  550.     //-----------------------------------------------------------------------\\
  551.  
  552.     //              GetMidString(string $str, int $iS, int $iE)              \\
  553.  
  554.     //  DESC: Returns the portion of $str starting at $iS and ending at $iE  \\
  555.  
  556.     //-----------------------------------------------------------------------\\
  557.  
  558.     return substr($str,$iS,$iE - $iS + 1);
  559.  
  560. }
  561.  
  562.  
  563.  
  564. function RemoveArrayElement($srcArray,$intEIndex) {
  565.  
  566.     //-----------------------------------------------------------------------\\
  567.  
  568.     //           RemoveArrayElement(array $srcArray, int $intEIndex          \\
  569.  
  570.     //  DESC: Removes the item $intEIndex from $srcArray and changes         \\
  571.  
  572.     //        all the keys from it in order not to leave any blank items     \\
  573.  
  574.     //        and returns the resultant array.                               \\
  575.  
  576.     //-----------------------------------------------------------------------\\
  577.  
  578.  
  579.  
  580.     $retArray = array();
  581.  
  582.     for ($i=0;$i<$intEIndex;$i++) {
  583.  
  584.         $retArray[$i] = $srcArray[$i];
  585.  
  586.     }
  587.  
  588.  
  589.  
  590.     for ($i=$intEIndex+1;$i<count($srcArray);$i++) {
  591.  
  592.         $retArray[$i-1] = $srcArray[$i];
  593.  
  594.     }
  595.  
  596.  
  597.  
  598.     return $retArray;
  599.  
  600. }
  601.  
  602.  
  603.  
  604. function ClearBlankElements($arr) {
  605.  
  606.     //-----------------------------------------------------------------------\\
  607.  
  608.     //                    ClearBlankElements(array $arr)                     \\
  609.  
  610.     //  DESC: Searches $arr for blank items (including items containing      \\
  611.  
  612.     //        only a white space) and removes them using the                 \\
  613.  
  614.     //        RemoveArrayElement function. Also trims the item value.        \\
  615.  
  616.     //-----------------------------------------------------------------------\\
  617.  
  618.  
  619.  
  620.     $thearr = array();
  621.  
  622.     foreach ($arr as $val) {
  623.  
  624.         if ($val != "" && $val != " ") {
  625.  
  626.             array_push($thearr,trim($val));
  627.  
  628.         }
  629.  
  630.     }
  631.  
  632.     return $thearr;
  633.  
  634. }
  635.  
  636.  
  637.  
  638. function CreateWordList($strQuery) {
  639.  
  640.     //-----------------------------------------------------------------------\\
  641.  
  642.     //                   CreateWordList(string $strQuery)                    \\
  643.  
  644.     //  DESC: Returns a array containing the words the user wants to search  \\
  645.  
  646.     //        for, including boolean keywords and literal phrases.           \\
  647.  
  648.     //        This means, the array returned by this function may contain    \\
  649.  
  650.     //        only a keyword (AND,OR,NOT or similars) or contain more than   \\
  651.  
  652.     //        one word. This is necessary for proper work of the ParseQuery  \\
  653.  
  654.     //        function.                                                      \\
  655.  
  656.     //-----------------------------------------------------------------------\\
  657.  
  658.  
  659.  
  660.     $q = $strQuery;
  661.  
  662.     $q = stripslashes($q);
  663.  
  664.     $QueryLength = strlen($strQuery);
  665.  
  666.     for ($i=0;$i<$QueryLength-1;$i++) {
  667.  
  668.     if ($i >= strlen($q)) {
  669.  
  670.         break;
  671.  
  672.     }
  673.  
  674.         if ($q{$i} == " ") {
  675.  
  676.             $q{$i} = chr(0);
  677.  
  678.         }
  679.  
  680.         if ($q{$i} == '"') {
  681.  
  682.             $q{$i} = chr(0);
  683.  
  684.             $nextQuote = ($i!=$QueryLength) ? strpos($q,'"',$i+1) : $QueryLength;
  685.  
  686.             if ($nextQuote !== false) {
  687.  
  688.                 $q{$nextQuote} = chr(0);
  689.  
  690.             }
  691.  
  692.             if ($nextQuote != $QueryLength - 1) {
  693.  
  694.                 $i = $nextQuote+1;
  695.  
  696.             }
  697.  
  698.         }
  699.  
  700.     }
  701.  
  702.  
  703.  
  704.     if ($q{0} == chr(0)) {
  705.  
  706.         $q = GetMidString($q,1,strlen($q));
  707.  
  708.     }
  709.  
  710.  
  711.  
  712.     $theArray = explode(chr(0),$q);
  713.  
  714.     $theArray = ClearBlankElements($theArray);
  715.  
  716.     return $theArray;
  717.  
  718. }
  719.  
  720.  
  721.  
  722. function ParseQuery($strDBField,$strQuery) {
  723.  
  724.     //-----------------------------------------------------------------------\\
  725.  
  726.     //           ParseQuery(string $strDBField, string $strQuery)            \\
  727.  
  728.     //  DESC: Main function of the system. Returns a string containing       \\
  729.  
  730.     //        a valid mySQL clause to be appendded to a SELECT statement     \\
  731.  
  732.     //        using $strDBField as the column name to be searched in and     \\
  733.  
  734.     //        $strQuery (parsed) as the search arguments.                    \\
  735.  
  736.     //-----------------------------------------------------------------------\\
  737.  
  738.  
  739.  
  740.     $TempQuery = $strQuery;
  741.  
  742.     $FirstPart = "";
  743.  
  744.     $ANDPart = "";
  745.  
  746.     $NOTPart = "";
  747.  
  748.     $ORPart = "";
  749.  
  750.  
  751.  
  752.     //IF THERE IS NOTHING TO SEARCH, FUNCTION RETURNS FALSE
  753.  
  754.     if ($TempQuery == "") {
  755.  
  756.         return false;
  757.  
  758.     }
  759.  
  760.  
  761.  
  762.     //CONVERTS THE QUERY TO UPPERCASE
  763.  
  764.     $TempQuery = strtoupper($TempQuery);
  765.  
  766.  
  767.  
  768.     //CREATES THE ACRONYM LIST
  769.  
  770.     $arrAcronyms = array("-","||","&");
  771.  
  772.     $arrBase = array("NOT","OR","AND");
  773.  
  774.     $TempQuery = str_replace($arrAcronyms,$arrBase,$TempQuery);
  775.  
  776.  
  777.  
  778.     //TAKE OUT SQL KEYWORDS IN ORDER TO AVOID SQL INJECTION
  779.  
  780.     $arrForbiddenWords = array("INSERT","SELECT","UPDATE","DELETE","DROP","--","CREATE","UNION");
  781.  
  782.     $TempQuery = str_replace($arrForbiddenWords,"",$TempQuery);
  783.  
  784.  
  785.  
  786.     //FORBIDS QUERY TO HAVE TWO OR MORE ADJACENT SPACES
  787.  
  788.     $strPattern = "/(\s{2,})/";
  789.  
  790.     $TempQuery = preg_replace($strPattern," ",$TempQuery);
  791.  
  792.  
  793.  
  794.     //FORBIDS QUERY TO HAVE TAGS
  795.  
  796.     $TempQuery = str_replace(array("<",">"),"",$TempQuery);
  797.  
  798.  
  799.  
  800.     $ArrWords = CreateWordList($TempQuery);
  801.  
  802.  
  803.  
  804.     //CHECK THAT FIRST ITEM IS NOT A OPERATOR
  805.  
  806.     if ($ArrWords[0] == "AND" || $ArrWords[0] == "OR" || $ArrWords[0] == "NOT") {
  807.  
  808.         $ArrWords = RemoveArrayElement($ArrWords,0);
  809.  
  810.     }
  811.  
  812.  
  813.  
  814.     //CHECK FIRST KEYWORD
  815.  
  816.     if ($ArrWords[0] != "AND") {
  817.  
  818.         $FirstPart = $strDBField . " LIKE '%" . $ArrWords[0] . "%'";
  819.  
  820.     }
  821.  
  822.  
  823.  
  824.     //BULID AND PART
  825.  
  826.     for ($i=1;$i<=count($ArrWords)-1;$i++) {
  827.  
  828.         if (trim($ArrWords[$i]) == "AND") {
  829.  
  830.             if ($i != 0) {
  831.  
  832.                 $ANDPart .= " AND " . $strDBField . " LIKE '%" . $ArrWords[$i+1] . "%'";
  833.  
  834.                 $i++;
  835.  
  836.             }
  837.  
  838.         }
  839.  
  840.         else {
  841.  
  842.             if (trim($ArrWords[$i]) != "NOT" && trim($ArrWords[$i]) != "OR") {
  843.  
  844.                 $ANDPart .= " AND " . $strDBField . " LIKE '%" . $ArrWords[$i] . "%'";
  845.  
  846.             }
  847.  
  848.             else {
  849.  
  850.                 $i++;
  851.  
  852.             }
  853.  
  854.         }
  855.  
  856.     }
  857.  
  858.  
  859.  
  860.     //BULID OR PART
  861.  
  862.     for ($i=1;$i<=count($ArrWords)-1;$i++) {
  863.  
  864.         if (trim($ArrWords[$i]) == "OR") {
  865.  
  866.             if ($i != 0) {
  867.  
  868.                 $ANDPart .= " OR " . $strDBField . " LIKE '%" . $ArrWords[$i+1] . "%'";
  869.  
  870.                 $i++;
  871.  
  872.             }
  873.  
  874.         }
  875.  
  876.     }
  877.  
  878.  
  879.  
  880.     //BULID NOT PART
  881.  
  882.     for ($i=1;$i<=count($ArrWords)-1;$i++) {
  883.  
  884.         if (trim($ArrWords[$i]) == "NOT") {
  885.  
  886.             if ($i != 0) {
  887.  
  888.                 $ANDPart .= " AND NOT (" . $strDBField . " LIKE '%" . $ArrWords[$i+1] . "%')";
  889.  
  890.                 $i++;
  891.  
  892.             }
  893.  
  894.         }
  895.  
  896.     }
  897.  
  898.  
  899.  
  900.     $FinalQuery = $FirstPart . $ANDPart . $ORPart . $NOTPart;
  901.  
  902.     return $FinalQuery;
  903.  
  904. }
  905.  
  906.  
  907.  
  908.  
  909.  
  910. //-----------------------------------------------------------------------\\
  911.  
  912. //          masc_tel($TEL)                                               \\
  913.  
  914. //  DESC: Esta função retorna o telefone no formato (44) 2222-2222       \\
  915.  
  916. //                                                                       \\
  917.  
  918. //-----------------------------------------------------------------------\\
  919.  
  920. function masc_tel($TEL) {
  921.  
  922.     $caract = array(".", "-", "(", ")", "/");
  923.  
  924.     $TEL = str_replace($caract, "", $TEL);
  925.  
  926.     $tam = strlen($TEL);
  927.  
  928.     // COM CÓDIGO DE ÁREA NACIONAL E DO PAIS
  929.  
  930.     if ($tam > 10) {
  931.  
  932.         return "+".substr($TEL,0,$tam-10)." (".substr($TEL,$tam-10,2).") ".substr($TEL,$tam-8,4)."-".substr($TEL,-4);
  933.  
  934.     }
  935.  
  936.     if ($tam == 10) {
  937.  
  938.         // COM CÓDIGO DE ÁREA NACIONAL
  939.  
  940.         return "(".substr($TEL,0,2).") ".substr($TEL,2,4)."-".substr($TEL,6,10);
  941.  
  942.     }
  943.  
  944.     if ($tam <= 8) {
  945.  
  946.         // SEM CÓDIGO DE ÁREA
  947.  
  948.         return substr($TEL,0,$tam-4)."-".substr($TEL,-4);
  949.  
  950.     }
  951.  
  952. }
  953.  
  954.  
  955.  
  956.  
  957.  
  958. //-----------------------------------------------------------------------\\
  959.  
  960. //          formataTel($valor)                                           \\
  961.  
  962. //  DESC:  Função para tirar todos os caracter e espaço do telefone      \\
  963.  
  964. //                                                                       \\
  965.  
  966. //-----------------------------------------------------------------------\\
  967.  
  968. function TelOnlyNumber($valor)
  969.  
  970. {
  971.  
  972.     $telefone = str_replace("(","",$valor);
  973.  
  974.     $telefone = str_replace(")","",$telefone);
  975.  
  976.     $telefone = str_replace("-","",$telefone);
  977.  
  978.     $telefone = str_replace(" ","",$telefone);
  979.  
  980.     return $telefone;
  981.  
  982. }
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990. //-----------------------------------------------------------------------\\
  991.  
  992. //          formataTel($valor)                                           \\
  993.  
  994. //  DESC:  Função para validar E-mail                                    \\
  995.  
  996. //                                                                       \\
  997.  
  998. //-----------------------------------------------------------------------\\
  999.  
  1000. function verificar_email($email){
  1001.  
  1002.  
  1003.  
  1004.        $mail_correcto = 0;
  1005.  
  1006.        //verifico umas coisas
  1007.  
  1008.        if ((strlen($email) >= 6) && (substr_count($email,"@") == 1) && (substr($email,0,1) != "@") && (substr($email,strlen($email)-1,1) != "@")){
  1009.  
  1010.           if ((!strstr($email,"'")) && (!strstr($email,"\"")) && (!strstr($email,"\\")) && (!strstr($email,"\$")) && (!strstr($email," "))) {
  1011.  
  1012.              //vejo se tem caracter .
  1013.  
  1014.              if (substr_count($email,".")>= 1){
  1015.  
  1016.                 //obtenho a terminação do dominio
  1017.  
  1018.                 $term_dom = substr(strrchr ($email, '.'),1);
  1019.  
  1020.                 //verifico que a terminação do dominio seja correcta
  1021.  
  1022.              if (strlen($term_dom)>1 && strlen($term_dom)<5 && (!strstr($term_dom,"@")) ){
  1023.  
  1024.                 //verifico que o de antes do dominio seja correcto
  1025.  
  1026.                 $antes_dom = substr($email,0,strlen($email) - strlen($term_dom) - 1);
  1027.  
  1028.                 $caracter_ult = substr($antes_dom,strlen($antes_dom)-1,1);
  1029.  
  1030.                 if ($caracter_ult != "@" && $caracter_ult != "."){
  1031.  
  1032.                    $mail_correcto = 1;
  1033.  
  1034.                 }
  1035.  
  1036.              }
  1037.  
  1038.           }
  1039.  
  1040.        }
  1041.  
  1042. }
  1043.  
  1044.  
  1045.  
  1046. if ($mail_correcto)
  1047.  
  1048.    return 1;
  1049.  
  1050. else
  1051.  
  1052.    return 0;
  1053.  
  1054. }
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. //-----------------------------------------------------------------------\\
  1061.  
  1062. //          Função para deixar a data no formato                         \\
  1063.  
  1064. //          americano aonde o banco de dados usa o tipo date             \\
  1065.  
  1066. //                                                                       \\
  1067.  
  1068. //-----------------------------------------------------------------------\\
  1069.  
  1070. function formataDataNasc($valor)
  1071.  
  1072. {
  1073.  
  1074.     $data_nasc = explode("/",$valor);
  1075.  
  1076.     $data_nasc = "$data_nasc[2]-$data_nasc[1]-$data_nasc[0]";
  1077.  
  1078.     return $data_nasc;
  1079.  
  1080. }
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086. //-----------------------------------------------------------------------\\
  1087.  
  1088. //          Função para formatar o CEP                                   \\
  1089.  
  1090. //          00000-000                                                    \\
  1091.  
  1092. //                                                                       \\
  1093.  
  1094. //-----------------------------------------------------------------------\\
  1095.  
  1096. function masc_cep($valor)
  1097.  
  1098. {
  1099.  
  1100. $cep1 = substr($valor, 0, 5);
  1101.  
  1102. $cep2 = substr($valor, 5);
  1103.  
  1104. return $cep1."-".$cep2;
  1105.  
  1106. }
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112. //-----------------------------------------------------------------------\\
  1113.  
  1114. //          cepOnlyNumber($valor)                                        \\
  1115.  
  1116. //  DESC:  Função para tirar todos os caracter e espaço do cep           \\
  1117.  
  1118. //                                                                       \\
  1119.  
  1120. //-----------------------------------------------------------------------\\
  1121.  
  1122. function cepOnlyNumber($valor)
  1123.  
  1124. {
  1125.  
  1126.     $cep = str_replace("-","",$valor);
  1127.  
  1128.     return $cep;
  1129.  
  1130. }
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142. //-----------------------------------------------------------------------\\
  1143.  
  1144. //          Função para formatar o CPF                                   \\
  1145.  
  1146. //          000.000.000-00                                               \\
  1147.  
  1148. //                                                                       \\
  1149.  
  1150. //-----------------------------------------------------------------------\\
  1151.  
  1152. function masc_cpf($var)
  1153.  
  1154. {
  1155.  
  1156.    $var = ereg_replace("[^0-9]", "", $var);
  1157.  
  1158.    $result = strlen($var);
  1159.  
  1160.    if($result == 14){
  1161.  
  1162.    $var = preg_replace("/([0-9]{2})[ \.-]?([0-9]{3})[ \.-]?([0-9]{3})[ \.\/-]?([0-9]{4})[ \.-]?([0-9]{2})/", "\\1.\\2.\\3/\\4-\\5", $var);
  1163.  
  1164.    }elseif($result == 11){
  1165.  
  1166.    $var = preg_replace("/([0-9]{3})[ \.-]?([0-9]{3})[ \.-]?([0-9]{3})[ \.\/-]?([0-9]{2})/", "\\1.\\2.\\3-\\4", $var);
  1167.  
  1168.    }
  1169.  
  1170.    return $var;
  1171.  
  1172. }
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182. //-----------------------------------------------------------------------\\
  1183.  
  1184. //          formataTel($valor)                                           \\
  1185.  
  1186. //  DESC:  Função para tirar todos os caracter e espaço do CPD           \\
  1187.  
  1188. //                                                                       \\
  1189.  
  1190. //-----------------------------------------------------------------------\\
  1191.  
  1192. function CpfOnlyNumber($valor)
  1193.  
  1194. {
  1195.  
  1196.     $cpf = str_replace(".","",$valor);
  1197.  
  1198.     $cpf = str_replace("-","",$cpf);
  1199.  
  1200.     $cpf = str_replace(" ","",$cpf);
  1201.  
  1202.     return $cpf;
  1203.  
  1204. }
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212. //-----------------------------------------------------------------------\\
  1213.  
  1214. //          getEnumValues($table, $field)                                \\
  1215.  
  1216. //  DESC:  Função que retorna os campos ENUM de uma tabela mysql         \\
  1217.  
  1218. //                                                                       \\
  1219.  
  1220. //-----------------------------------------------------------------------\\
  1221.  
  1222. function getEnumValues($table, $field) {
  1223.  
  1224.     $enum_array = array();
  1225.  
  1226.     $query = 'SHOW COLUMNS FROM `' . $table . '` LIKE "' . $field . '"';
  1227.  
  1228.     $result = mysql_query($query);
  1229.  
  1230.     $row = mysql_fetch_row($result);
  1231.  
  1232.     preg_match_all('/\'(.*?)\'/', $row[1], $enum_array);
  1233.  
  1234.     if(!empty($enum_array[1])) {
  1235.  
  1236.         // Shift array keys to match original enumerated index in MySQL (allows for use of index values instead of strings)
  1237.  
  1238.         foreach($enum_array[1] as $mkey => $mval) $enum_fields[$mkey+1] = $mval;
  1239.  
  1240.         return $enum_fields;
  1241.  
  1242.     }
  1243.  
  1244.     else return array(); // Return an empty array to avoid possible errors/warnings if array is passed to foreach() without first being checked with !empty().
  1245.  
  1246. }
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254. //---------------------------------------------------------------------------\\
  1255.  
  1256. //  Função que coloca os valores de um campo ENUM dentro de um SELECT HTML   \\
  1257.  
  1258. //                                                                           \\
  1259.  
  1260. //                                                                           \\
  1261.  
  1262. //---------------------------------------------------------------------------\\
  1263.  
  1264. function ShowCampoInSelect($tabela,$campo,$selecionado){
  1265.  
  1266.  
  1267.  
  1268.     $ArrayTipos = getEnumValues($tabela,$campo);
  1269.  
  1270.     $NumInt = count($ArrayTipos);
  1271.  
  1272.     $selected='';
  1273.  
  1274.         for ($i = 1; $i <= $NumInt; $i++) {
  1275.  
  1276.             if(@$selecionado){
  1277.  
  1278.                 if($ArrayTipos[$i] == $selecionado){$selected='selected';}else{$selected='';}
  1279.  
  1280.             }
  1281.  
  1282.             echo "<option value=\"$ArrayTipos[$i]\"$selected>$ArrayTipos[$i]</option>";
  1283.  
  1284.     }
  1285.  
  1286. }
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292. //-----------------------------------------------------------------------\\
  1293.  
  1294. //          realParaFloat ($str)                                         \\
  1295.  
  1296. //  DESC:   Transforma Reais em float                                    \\
  1297.  
  1298. //                                                                       \\
  1299.  
  1300. //  OBS: O campo do banco de dados deveser do tipo float (10,3)          \\
  1301.  
  1302. //-----------------------------------------------------------------------\\
  1303.  
  1304. function realParaFloat ($str) {
  1305.  
  1306.  
  1307.  
  1308.     if(strstr($str, ",")) {
  1309.  
  1310.         $str = str_replace(".", "", $str);
  1311.  
  1312.         $str = str_replace(",", ".", $str);
  1313.  
  1314.     }
  1315.  
  1316.  
  1317.  
  1318.     if (preg_match("#([0-9\.]+)#", $str, $match)) {
  1319.  
  1320.         return floatval($match[0]);
  1321.  
  1322.     }else{
  1323.  
  1324.         return floatval($str);
  1325.  
  1326.     }
  1327.  
  1328.  
  1329.  
  1330. } // Fim function
  1331.  
  1332.  
  1333.  
  1334.  
  1335.  
  1336. //-----------------------------------------------------------------------\\
  1337.  
  1338. //          SelectHtmlEstado ($str)                                      \\
  1339.  
  1340. //  DESC:   Retorna preenchido o campo select do html                    \\
  1341.  
  1342. //                                                                       \\
  1343.  
  1344. //  OBS:                                                                 \\
  1345.  
  1346. //-----------------------------------------------------------------------\\
  1347.  
  1348. function SelectHtmlEstado($valor) {
  1349.  
  1350.  
  1351.  
  1352.     // Selecionando os estados
  1353.  
  1354.     $sql = "SELECT ID,sigla FROM estados ORDER BY sigla ASC";
  1355.  
  1356.     $qry = mysql_query($sql) or die(mysql_error());
  1357.  
  1358.     $row = mysql_fetch_assoc($qry);
  1359.  
  1360.  
  1361.  
  1362.     do {
  1363.  
  1364.         if (!(strcmp($row['ID'], htmlentities($valor)))) {$selected = 'selected';}else{$selected = "";}
  1365.  
  1366.             @$option .= "<option value=\"$row[ID]\" $selected > $row[sigla]</option>";
  1367.  
  1368.     }
  1369.  
  1370.     while ( $row = mysql_fetch_assoc($qry));
  1371.  
  1372.     return $option;
  1373.  
  1374.  
  1375.  
  1376. } // Fim function
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382. //-----------------------------------------------------------------------\\
  1383.  
  1384. //          SelectHtmlTabela($tabela,$valor)                                      \\
  1385.  
  1386. //  DESC:   Retorna preenchido o campo select do html                    \\
  1387.  
  1388. //                                                                       \\
  1389.  
  1390. //  OBS:                                                                 \\
  1391.  
  1392. //-----------------------------------------------------------------------\\
  1393.  
  1394. function SelectHtmlTabela($tabela,$valor) {
  1395.  
  1396.  
  1397.  
  1398.     // Selecionando os estados
  1399.  
  1400.     $sql = "SELECT ID,nome FROM $tabela ORDER BY nome ASC";
  1401.  
  1402.     $qry = mysql_query($sql) or die(mysql_error());
  1403.  
  1404.     $row = mysql_fetch_assoc($qry);
  1405.  
  1406.  
  1407.  
  1408.     do {
  1409.  
  1410.         if (!(strcmp($row['ID'], htmlentities($valor)))) {$selected = 'selected';}else{$selected = "";}
  1411.  
  1412.             @$option .= "<option value=\"$row[ID]\" $selected > $row[nome]</option>";
  1413.  
  1414.     }
  1415.  
  1416.     while ( $row = mysql_fetch_assoc($qry));
  1417.  
  1418.     return $option;
  1419.  
  1420.  
  1421.  
  1422. } // Fim function
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430. //-----------------------------------------------------------------------\\
  1431.  
  1432. //          SelectHtmlTabela2($tabela,$valor)                                      \\
  1433.  
  1434. //  DESC:   Retorna preenchido o campo select do html                    \\
  1435.  
  1436. //                                                                       \\
  1437.  
  1438. //  OBS:                                                                 \\
  1439.  
  1440. //-----------------------------------------------------------------------\\
  1441.  
  1442. function SelectHtmlTabela2($tabela,$valor) {
  1443.  
  1444.  
  1445.  
  1446.     // Selecionando os estados
  1447.  
  1448.     $sql = "SELECT ID,nome,nome_inteiro FROM $tabela ORDER BY nome ASC";
  1449.  
  1450.     $qry = mysql_query($sql) or die(mysql_error());
  1451.  
  1452.     $row = mysql_fetch_assoc($qry);
  1453.  
  1454.  
  1455.  
  1456.     do {
  1457.  
  1458.         if (!(strcmp($row['ID'], htmlentities($valor)))) {$selected = 'selected';}else{$selected = "";}
  1459.  
  1460.             @$option .= "<option value=\"$row[ID]-$row[nome_inteiro]\" $selected > $row[nome]</option>";
  1461.  
  1462.     }
  1463.  
  1464.     while ( $row = mysql_fetch_assoc($qry));
  1465.  
  1466.     return $option;
  1467.  
  1468.  
  1469.  
  1470. } // Fim function
  1471.  
  1472.  
  1473.  
  1474.  
  1475.  
  1476. //-----------------------------------------------------------------------\\
  1477.  
  1478. //          SelectSubCat($tabela,$valor,$valorAnterior)                                 \\
  1479.  
  1480. //  DESC:   Retorna preenchido o campo select do html                    \\
  1481.  
  1482. //                                                                       \\
  1483.  
  1484. //  OBS:                                                                 \\
  1485.  
  1486. //-----------------------------------------------------------------------\\
  1487.  
  1488. function SelectSubCat($tabela,$valor,$valorAnterior) {
  1489.  
  1490.  
  1491.  
  1492.     // Selecionando os estados
  1493.  
  1494.     $sql = "SELECT ID,nome FROM $tabela WHERE fk_categoria=$valorAnterior ORDER BY nome ASC";
  1495.  
  1496.     $qry = mysql_query($sql) or die(mysql_error());
  1497.  
  1498.     $row = mysql_fetch_assoc($qry);
  1499.  
  1500.  
  1501.  
  1502.     do {
  1503.  
  1504.         if (!(strcmp($row['ID'], htmlentities($valor)))) {$selected = 'selected';}else{$selected = "";}
  1505.  
  1506.             @$option .= "<option value=\"$row[ID]\" $selected > $row[nome]</option>";
  1507.  
  1508.     }
  1509.  
  1510.     while ( $row = mysql_fetch_assoc($qry));
  1511.  
  1512.     return $option;
  1513.  
  1514.  
  1515.  
  1516. } // Fim function
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522. //-----------------------------------------------------------------------\\
  1523.  
  1524. //          SelectEspc($tabela,$valor,$valorAnterior)                                 \\
  1525.  
  1526. //  DESC:   Retorna preenchido o campo select do html                    \\
  1527.  
  1528. //                                                                       \\
  1529.  
  1530. //  OBS:                                                                 \\
  1531.  
  1532. //-----------------------------------------------------------------------\\
  1533.  
  1534. function SelectEspc($tabela,$valor,$valorAnterior) {
  1535.  
  1536.  
  1537.  
  1538.     // Selecionando os estados
  1539.  
  1540.     $sql = "SELECT ID,nome FROM $tabela WHERE fK_sub_categoria=$valorAnterior ORDER BY nome ASC";
  1541.  
  1542.     $qry = mysql_query($sql) or die(mysql_error());
  1543.  
  1544.     $row = mysql_fetch_assoc($qry);
  1545.  
  1546.  
  1547.  
  1548.     do {
  1549.  
  1550.         if (!(strcmp($row['ID'], htmlentities($valor)))) {$selected = 'selected';}else{$selected = "";}
  1551.  
  1552.             @$option .= "<option value=\"$row[ID]\" $selected > $row[nome]</option>";
  1553.  
  1554.     }
  1555.  
  1556.     while ( $row = mysql_fetch_assoc($qry));
  1557.  
  1558.     return $option;
  1559.  
  1560.  
  1561.  
  1562. } // Fim function
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582. //-----------------------------------------------------------------------\\
  1583.  
  1584. //          SelectHtmlTabela($tabela,$valor)                                      \\
  1585.  
  1586. //  DESC:   Retorna preenchido o campo select do html                    \\
  1587.  
  1588. //                                                                       \\
  1589.  
  1590. //  OBS:                                                                 \\
  1591.  
  1592. //-----------------------------------------------------------------------\\
  1593.  
  1594. function SelectHtmlCidades($estado,$valor) {
  1595.  
  1596.  
  1597.  
  1598.     // Selecionando as cidades
  1599.  
  1600.     $sql = "SELECT ID,nome FROM cidades WHERE fk_estado=$estado ORDER BY nome ASC";
  1601.  
  1602.     $qry = mysql_query($sql) or die(mysql_error());
  1603.  
  1604.     $row = mysql_fetch_assoc($qry);
  1605.  
  1606.  
  1607.  
  1608.     do {
  1609.  
  1610.         if (!(strcmp($row['ID'], htmlentities($valor)))) {$selected = 'selected';}else{$selected = "";}
  1611.  
  1612.             @$option .= "<option value=\"$row[ID]\" $selected > $row[nome]</option>";
  1613.  
  1614.     }
  1615.  
  1616.     while ( $row = mysql_fetch_assoc($qry));
  1617.  
  1618.     return $option;
  1619.  
  1620.  
  1621.  
  1622. } // Fim function
  1623.  
  1624.  
  1625.  
  1626. //-----------------------------------------------------------------------\\
  1627.  
  1628. //          SelectCkeckAcessorio($tabela,$valor)                         \\
  1629.  
  1630. //  DESC:   retorna chackbox                                             \\
  1631.  
  1632. //                                                                       \\
  1633.  
  1634. //  OBS:                                                                 \\
  1635.  
  1636. //-----------------------------------------------------------------------\\
  1637.  
  1638. function SelectCkeckAcessorio($tabela,$valor) {
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.     $sql = "SELECT ID,nome FROM $tabela ORDER BY nome ASC";
  1647.  
  1648.     $sql = mysql_query($sql);
  1649.  
  1650.  
  1651.  
  1652.     while ($row = mysql_fetch_array($sql)) {
  1653.  
  1654.  
  1655.  
  1656.     if($valor){
  1657.  
  1658.         $valorArray = explode(' ',$valor);
  1659.  
  1660.         if(in_array($row['ID'],$valorArray)){
  1661.  
  1662.             $cheked = 'checked=\"checked\"';
  1663.  
  1664.         }else{
  1665.  
  1666.             $cheked = '';
  1667.  
  1668.         }
  1669.  
  1670.     }else{
  1671.  
  1672.         $cheked = '';
  1673.  
  1674.     }
  1675.  
  1676.  
  1677.  
  1678.         echo "<div style=\" width:180px; float:left; margin-right:15px;\">
  1679.  
  1680. <div style=\"float:left\"><input name=\"acessorio[]\" $cheked  type=\"checkbox\" value=\"$row[ID]\" /></div>
  1681.  
  1682. <div style=\"margin-top:5px;\">$row[nome]</div>
  1683.  
  1684. </div>";
  1685.  
  1686.     }
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696. } // Fim function
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704. //-----------------------------------------------------------------------\\
  1705.  
  1706. //          SelectCkeckempIdiomas($tabela,$valor)                         \\
  1707.  
  1708. //  DESC:   retorna chackbox                                             \\
  1709.  
  1710. //                                                                       \\
  1711.  
  1712. //  OBS:                                                                 \\
  1713.  
  1714. //-----------------------------------------------------------------------\\
  1715.  
  1716. function SelectCkeckempIdiomas($tabela,$valor) {
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.     $sql = "SELECT ID,nome FROM $tabela ORDER BY nome ASC";
  1725.  
  1726.     $sql = mysql_query($sql);
  1727.  
  1728.  
  1729.  
  1730.     while ($row = mysql_fetch_array($sql)) {
  1731.  
  1732.  
  1733.  
  1734.     if($valor){
  1735.  
  1736.         $valorArray = explode(' ',$valor);
  1737.  
  1738.         if(in_array($row['ID'],$valorArray)){
  1739.  
  1740.             $cheked = 'checked=\"checked\"';
  1741.  
  1742.         }else{
  1743.  
  1744.             $cheked = '';
  1745.  
  1746.         }
  1747.  
  1748.     }else{
  1749.  
  1750.         $cheked = '';
  1751.  
  1752.     }
  1753.  
  1754.  
  1755.  
  1756.         echo "<div style=\" width:180px; float:left; margin-right:15px;\">
  1757.  
  1758. <div style=\"float:left\"><input name=\"idiomas[]\" $cheked  type=\"checkbox\" value=\"$row[ID]\" /></div>
  1759.  
  1760. <div style=\"margin-top:5px;\">$row[nome]</div>
  1761.  
  1762. </div>";
  1763.  
  1764.     }
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774. } // Fim function
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780. //-----------------------------------------------------------------------\\
  1781.  
  1782. //          SelectCkeckEspImoves($tabela,$valor)                         \\
  1783.  
  1784. //  DESC:   retorna chackbox                                             \\
  1785.  
  1786. //                                                                       \\
  1787.  
  1788. //  OBS:                                                                 \\
  1789.  
  1790. //-----------------------------------------------------------------------\\
  1791.  
  1792. function SelectCkeckEspImoves($tabela,$valor) {
  1793.  
  1794.  
  1795.  
  1796.  
  1797.  
  1798.  
  1799.  
  1800.     $sql = "SELECT ID,nome FROM $tabela ORDER BY nome ASC";
  1801.  
  1802.     $sql = mysql_query($sql);
  1803.  
  1804.  
  1805.  
  1806.     while ($row = mysql_fetch_array($sql)) {
  1807.  
  1808.  
  1809.  
  1810.     if($valor){
  1811.  
  1812.         $valorArray = explode(' ',$valor);
  1813.  
  1814.         if(in_array($row['ID'],$valorArray)){
  1815.  
  1816.             $cheked = 'checked=\"checked\"';
  1817.  
  1818.         }else{
  1819.  
  1820.             $cheked = '';
  1821.  
  1822.         }
  1823.  
  1824.     }else{
  1825.  
  1826.         $cheked = '';
  1827.  
  1828.     }
  1829.  
  1830.  
  1831.  
  1832.         echo "<div style=\" width:180px; float:left; margin-right:15px;\">
  1833.  
  1834. <div style=\"float:left\"><input name=\"esp_imoves[]\" $cheked  type=\"checkbox\" value=\"$row[ID]\" /></div>
  1835.  
  1836. <div style=\"margin-top:5px;\">$row[nome]</div>
  1837.  
  1838. </div>";
  1839.  
  1840.     }
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850. } // Fim function
  1851.  
  1852.  
  1853.  
  1854.  
  1855.  
  1856.  
  1857.  
  1858. //---------------------------------------------------------------------------\\
  1859.  
  1860. //  Função que que envia a imagem para o servidor e                          \\
  1861.  
  1862. //  retorna o nome da imagem                                                 \\
  1863.  
  1864. //                                                                           \\
  1865.  
  1866. //                                                                           \\
  1867.  
  1868. //---------------------------------------------------------------------------\\
  1869.  
  1870. function criaFoto($file,$pasta,$larguraThumbs,$larguraFull,$larguraMedia){
  1871.  
  1872.  
  1873.  
  1874.  
  1875.  
  1876.     global $PathAbsoluto;
  1877.  
  1878.     global $Path;
  1879.  
  1880.     global $logoClassiaqui;
  1881.  
  1882.  
  1883.  
  1884.     $pastaLocal = $Path.'/'.$pasta;
  1885.  
  1886.  
  1887.  
  1888.     // O nome da foto é o timestamp do segundo em que o upload foi feito
  1889.  
  1890.     $finalNome = rand(0,1000);
  1891.  
  1892.     $nomefoto = time().$finalNome;
  1893.  
  1894.  
  1895.  
  1896.     // Define a largura ou a altura máxima
  1897.  
  1898.     $maxThumbs = $larguraThumbs;
  1899.  
  1900.     $maxFull = $larguraFull;
  1901.  
  1902.     $maxMedia = $larguraMedia;
  1903.  
  1904.  
  1905.  
  1906.     // Pega os dados da imagem
  1907.  
  1908.     $dados_imagem = getImageSize ($file['tmp_name']);
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.     if((($file['type']) != 'image/pjpeg')
  1915.  
  1916.     && (($file['type']) != 'image/jpeg')
  1917.  
  1918.     && (($file['type']) != 'image/jpg')
  1919.  
  1920.     && (($file['type']) != 'image/pjpg')
  1921.  
  1922.     && (($file['type']) != 'image/gif')
  1923.  
  1924.     && (($file['type']) != 'image/x-png')
  1925.  
  1926.     ) {
  1927.  
  1928.  
  1929.  
  1930.         echo "<SCRIPT LANGUAGE=\"JavaScript\">alert('Este arquivo não pode ser enviado.');</script>";
  1931.  
  1932.         echo "<SCRIPT LANGUAGE=\"JavaScript\"> history.go(-1) </script>;";
  1933.  
  1934.         exit;
  1935.  
  1936.     }
  1937.  
  1938.  
  1939.  
  1940.  
  1941.  
  1942.     // Se for uma imagem válida (gif, jpg, ou png)
  1943.  
  1944.     if ((($dados_imagem[2] == 1) || ($dados_imagem[2] == 2) || ($dados_imagem[2] == 3))){
  1945.  
  1946.  
  1947.  
  1948.          // Se a largura e a altura forem maiores que a largura máxima do thumbnail
  1949.  
  1950.          if ($dados_imagem[0] > $maxThumbs && $dados_imagem[1] > $maxThumbs){
  1951.  
  1952.  
  1953.  
  1954.             // Switch no tipo de imagem (gif, jpg ou png)
  1955.  
  1956.             switch ($dados_imagem[2]){
  1957.  
  1958.  
  1959.  
  1960.                case 1:
  1961.  
  1962.                   $img_src = imageCreateFromGif ($file['tmp_name']);
  1963.  
  1964.                   break;
  1965.  
  1966.  
  1967.  
  1968.                case 2:
  1969.  
  1970.                   $img_src = imageCreateFromJpeg ($file['tmp_name']);
  1971.  
  1972.                   break;
  1973.  
  1974.  
  1975.  
  1976.                case 3:
  1977.  
  1978.                   $img_src = imageCreateFromPng ($file['tmp_name']);
  1979.  
  1980.                   break;
  1981.  
  1982.  
  1983.  
  1984.             }
  1985.  
  1986.             //======================================
  1987.  
  1988.             // A largura é maior que a altura
  1989.  
  1990.             if ($dados_imagem[0] > $dados_imagem[1]){
  1991.  
  1992.  
  1993.  
  1994.                /* ######## Thumb  ######## */
  1995.  
  1996.  
  1997.  
  1998.                // A largura vai ter como valor $maxThumbs. Define a nova altura abaixo
  1999.  
  2000.                $nova_altura = round (($maxThumbs * $dados_imagem[1]) / $dados_imagem[0]);
  2001.  
  2002.  
  2003.  
  2004.                // Cria a nova imagem do thumbnail
  2005.  
  2006.                $img_destino = imageCreateTrueColor ($maxThumbs, $nova_altura);
  2007.  
  2008.  
  2009.  
  2010.                // Copia a imagem
  2011.  
  2012.                imagecopyresampled ($img_destino, $img_src, 0, 0, 0, 0, $maxThumbs, $nova_altura, $dados_imagem[0], $dados_imagem[1]);
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018.                /* ######## Media  ######## */
  2019.  
  2020.  
  2021.  
  2022.                // A largura vai ter como valor $maxThumbs. Define a nova altura abaixo
  2023.  
  2024.                $nova_altura2 = round (($maxMedia * $dados_imagem[1]) / $dados_imagem[0]);
  2025.  
  2026.  
  2027.  
  2028.                // Cria a nova imagem do thumbnail
  2029.  
  2030.                $img_destino2 = imageCreateTrueColor ($maxMedia, $nova_altura2);
  2031.  
  2032.  
  2033.  
  2034.                // Copia a imagem
  2035.  
  2036.                imagecopyresampled ($img_destino, $img_src, 0, 0, 0, 0, $maxThumbs, $nova_altura, $dados_imagem[0], $dados_imagem[1]);
  2037.  
  2038.  
  2039.  
  2040.                // Copia a imagem
  2041.  
  2042.                imagecopyresampled ($img_destino2, $img_src, 0, 0, 0, 0, $maxMedia, $nova_altura2, $dados_imagem[0], $dados_imagem[1]);
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.  
  2052.  
  2053.  
  2054.             }
  2055.  
  2056.  
  2057.  
  2058.             //======================================
  2059.  
  2060.             // A alatura é maior do que a largura
  2061.  
  2062.             if ($dados_imagem[0] < $dados_imagem[1]){
  2063.  
  2064.  
  2065.  
  2066.  
  2067.  
  2068.                /* ######## Thumb  ######## */
  2069.  
  2070.  
  2071.  
  2072.                // A altura vai ter como valor $maxThumbs. Define a nova largura abaixo
  2073.  
  2074.                $nova_largura = round (($maxThumbs * $dados_imagem[0]) / $dados_imagem[1]);
  2075.  
  2076.  
  2077.  
  2078.                // Cria a nova imagem do thumbnail
  2079.  
  2080.                $img_destino = imageCreateTrueColor ($nova_largura, $maxThumbs);
  2081.  
  2082.  
  2083.  
  2084.                // Copia a imagem
  2085.  
  2086.                imagecopyresampled ($img_destino, $img_src, 0, 0, 0, 0, $nova_largura, $maxThumbs, $dados_imagem[0], $dados_imagem[1]);
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.                /* ######## Media  ######## */
  2093.  
  2094.  
  2095.  
  2096.                // A altura vai ter como valor $maxThumbs. Define a nova largura abaixo
  2097.  
  2098.                $nova_largura2 = round (($maxMedia * $dados_imagem[0]) / $dados_imagem[1]);
  2099.  
  2100.  
  2101.  
  2102.                // Cria a nova imagem do thumbnail
  2103.  
  2104.                $img_destino2 = imageCreateTrueColor ($nova_largura2, $maxMedia);
  2105.  
  2106.  
  2107.  
  2108.                // Copia a imagem
  2109.  
  2110.                imagecopyresampled ($img_destino2, $img_src, 0, 0, 0, 0, $nova_largura2, $maxMedia, $dados_imagem[0], $dados_imagem[1]);
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.             }
  2119.  
  2120.  
  2121.  
  2122.             //======================================
  2123.  
  2124.             // A alatura é igual a largura
  2125.  
  2126.             if ($dados_imagem[0] == $dados_imagem[1]){
  2127.  
  2128.  
  2129.  
  2130.                /* ######## Thumb  ######## */
  2131.  
  2132.  
  2133.  
  2134.                // Cria a nova imagem do thumbnail
  2135.  
  2136.                $img_destino = imageCreateTrueColor ($maxThumbs, $maxThumbs);
  2137.  
  2138.  
  2139.  
  2140.                // Copia a imagem
  2141.  
  2142.                imagecopyresampled ($img_destino, $img_src, 0, 0, 0, 0, $maxThumbs, $maxThumbs, $dados_imagem[0], $dados_imagem[1]);
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.                /* ######## Media  ######## */
  2149.  
  2150.  
  2151.  
  2152.                // Cria a nova imagem do thumbnail
  2153.  
  2154.                $img_destino2 = imageCreateTrueColor ($maxMedia, $maxMedia);
  2155.  
  2156.  
  2157.  
  2158.                // Copia a imagem
  2159.  
  2160.                imagecopyresampled ($img_destino2, $img_src, 0, 0, 0, 0, $maxMedia, $maxMedia, $dados_imagem[0], $dados_imagem[1]);
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.             }
  2167.  
  2168.  
  2169.  
  2170.             //======================================
  2171.  
  2172.             // A largura maior que o valor máximo difinido
  2173.  
  2174.             if($dados_imagem[0] > $larguraFull){
  2175.  
  2176.  
  2177.  
  2178.                 // Define a altura da nova imagem
  2179.  
  2180.                 $novaAltura = $dados_imagem[1] / $dados_imagem[0] * $larguraFull;
  2181.  
  2182.  
  2183.  
  2184.                 // Cria a nova imagem
  2185.  
  2186.                 $novaImagem = imageCreateTrueColor ($larguraFull, $novaAltura);
  2187.  
  2188.  
  2189.  
  2190.                 // Copia a danada
  2191.  
  2192.                 imageCopyResampled ($novaImagem,$img_src, 0, 0, 0, 0, $larguraFull, $novaAltura, $dados_imagem[0], $dados_imagem[1]);
  2193.  
  2194.  
  2195.  
  2196.                 $larguraOK = $larguraFull;
  2197.  
  2198.                 $AlturaOk =  $novaAltura;
  2199.  
  2200.  
  2201.  
  2202.  
  2203.  
  2204.             }else {
  2205.  
  2206.                 // Cria uma nova imagem maior com o mesmo tamanho da original
  2207.  
  2208.                 $novaImagem = imageCreateTrueColor ($dados_imagem[0], $dados_imagem[1]);
  2209.  
  2210.  
  2211.  
  2212.                  // Copia a imagem original
  2213.  
  2214.                 imagecopyresampled ($novaImagem, $img_src, 0, 0, 0, 0, $dados_imagem[0], $dados_imagem[1], $dados_imagem[0], $dados_imagem[1]);
  2215.  
  2216.  
  2217.  
  2218.                 $larguraOK = $dados_imagem[0];
  2219.  
  2220.                 $AlturaOk = $dados_imagem[1];
  2221.  
  2222.  
  2223.  
  2224.             }
  2225.  
  2226.  
  2227.  
  2228.             //==================================================================
  2229.  
  2230.             // Copia a imagem do logotipo e cola na imagem maior, se ele existir
  2231.  
  2232.             if (is_file ($Path.'/'.$logoClassiaqui)){
  2233.  
  2234.  
  2235.  
  2236.                // Copia o logo
  2237.  
  2238.                $logo_src = imageCreateFromPng ($Path.'/'.$logoClassiaqui);
  2239.  
  2240.  
  2241.  
  2242.                // Pega os dados do logo (largura e altura)
  2243.  
  2244.                $dados_logo = getImageSize ($Path.'/'.$logoClassiaqui);
  2245.  
  2246.  
  2247.  
  2248.                // Define o X e Y para aonde o logo deve ser colado
  2249.  
  2250.                $x = ($larguraOK - $dados_logo[0]) - 5;
  2251.  
  2252.                $y = ($AlturaOk - $dados_logo[1]) - 5;
  2253.  
  2254.  
  2255.  
  2256.  
  2257.  
  2258.                // Cola o logo
  2259.  
  2260.                imagecopy ($novaImagem, $logo_src, $x, $y, 0, 0, $dados_logo[0], $dados_logo[1]);
  2261.  
  2262.  
  2263.  
  2264.                // Solta a imagem full
  2265.  
  2266.                imageJpeg ($novaImagem, $pastaLocal.'/'.$nomefoto.'.jpg');
  2267.  
  2268.  
  2269.  
  2270.             }
  2271.  
  2272.  
  2273.  
  2274.             // Solta o thumb
  2275.  
  2276.             imageJpeg ($img_destino,  $pastaLocal.'/'.$nomefoto.'_thumb.jpg');
  2277.  
  2278.  
  2279.  
  2280.             // Solta a Media
  2281.  
  2282.             imageJpeg ($img_destino2,  $pastaLocal.'/'.$nomefoto.'_media.jpg');
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.          }
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.     }
  2297.  
  2298.  
  2299.  
  2300.           return $nomefoto;
  2301.  
  2302.  
  2303.  
  2304. } // Fim function
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310. //---------------------------------------------------------------------------\\
  2311.  
  2312. //  Função que verifica se o usuario é dono do anuncio                       \\
  2313.  
  2314. //                                                                           \\
  2315.  
  2316. //                                                                           \\
  2317.  
  2318. //---------------------------------------------------------------------------\\
  2319.  
  2320. function VerificaPropriedade($fk_anunio,$fk_usuario)
  2321.  
  2322. {
  2323.  
  2324.     $sql = "SELECT ID FROM anuncio WHERE ID='$fk_anunio' AND fk_usuario='$fk_usuario'";
  2325.  
  2326.     $sql = mysql_query($sql);
  2327.  
  2328.     $total = mysql_num_rows($sql);
  2329.  
  2330.     return $total;
  2331.  
  2332. }
  2333.  
  2334.  
  2335.  
  2336. //---------------------------------------------------------------------------\\
  2337.  
  2338. //  Função que verifica se o usuario é dono da msag                       \\
  2339.  
  2340. //                                                                           \\
  2341.  
  2342. //                                                                           \\
  2343.  
  2344. //---------------------------------------------------------------------------\\
  2345.  
  2346. function VerificaPropriedadeMsg($fk_anunio,$fk_usuario)
  2347.  
  2348. {
  2349.  
  2350.     $sql = "SELECT ID FROM anuncio_msg WHERE ID='$fk_anunio' AND fk_usuario='$fk_usuario'";
  2351.  
  2352.     $sql = mysql_query($sql);
  2353.  
  2354.     $total = mysql_num_rows($sql);
  2355.  
  2356.     return $total;
  2357.  
  2358. }
  2359.  
  2360.  
  2361.  
  2362. //---------------------------------------------------------------------------\\
  2363.  
  2364. //  Função  converter_dataSQL($strData)                                      \\
  2365.  
  2366. //  Desc: Cobverte as data para o formato americano 0000-00-00               \\
  2367.  
  2368. //                                                                           \\
  2369.  
  2370. //---------------------------------------------------------------------------\\
  2371.  
  2372. function converter_dataSQL($strData) {
  2373.  
  2374.     // Recebemos a data no formato: dd/mm/aaaa
  2375.  
  2376.     // Convertemos a data para o formato: aaaa-mm-dd
  2377.  
  2378.     $strDataFinal = implode('-', array_reverse(explode('/',$strData)));
  2379.  
  2380.     return $strDataFinal;
  2381.  
  2382. }
  2383.  
  2384.  
  2385.  
  2386. //---------------------------------------------------------------------------\\
  2387.  
  2388. //  Função RetornaOutrasInfo($tabela,$valor)                                 \\
  2389.  
  2390. //  Desc: Retorna das tabelas as informacoes adcionais                       \\
  2391.  
  2392. //                                                                           \\
  2393.  
  2394. //---------------------------------------------------------------------------\\
  2395.  
  2396. function RetornaOutrasInfo($tabela,$valor,$label) {
  2397.  
  2398.     $sql = "SELECT nome FROM $tabela where ID='$valor'";
  2399.  
  2400.     $sql = mysql_query($sql);
  2401.  
  2402.     @$nome = mysql_result($sql,0,"nome");
  2403.  
  2404.     echo "<div style=\"margin-bottom:10px;\"><strong>$label:</strong> $nome</div>";
  2405.  
  2406. }
  2407.  
  2408.  
  2409.  
  2410.  
  2411.  
  2412. //---------------------------------------------------------------------------\\
  2413.  
  2414. //  Função RetornaOutrasInfo2($tabela,$valor)                                \\
  2415.  
  2416. //  Desc: Retorna varios campos                                              \\
  2417.  
  2418. //                                                                           \\
  2419.  
  2420. //---------------------------------------------------------------------------\\
  2421.  
  2422. function RetornaOutrasInfo2($tabela,$valor,$label) {
  2423.  
  2424.  
  2425.  
  2426.     $exp_IdEmp = explode(" ", $valor);
  2427.  
  2428.     $exp_IdEmpPop = array_pop($exp_IdEmp); //retira o ultimo elemento da array
  2429.  
  2430.  
  2431.  
  2432.     for ($ilaco=0;$ilaco<count($exp_IdEmp);$ilaco++){
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.         $sql = "SELECT nome FROM $tabela where ID=$exp_IdEmp[$ilaco]";
  2439.  
  2440.         $sql = mysql_query($sql);
  2441.  
  2442.         @$nome .= mysql_result($sql,0,'nome').', ';
  2443.  
  2444.  
  2445.  
  2446.    }
  2447.  
  2448.  
  2449.  
  2450.     // Retira a ultima virgula di final da string
  2451.  
  2452.     $tamanho =  strlen($nome);
  2453.  
  2454.     $nome = substr($nome, 0, $tamanho - 2);
  2455.  
  2456.  
  2457.  
  2458.     echo "<div style=\"margin-bottom:10px;\"><strong>$label: </strong>$nome</div>";
  2459.  
  2460. }
  2461.  
  2462.  
  2463. //---------------------------------------------------------------------------\\
  2464. //  Função ShowLinkNav($codest,$codcid,$codcat1,$codcat2,$codcat3)           \\
  2465. //  Desc: Mostra os links de navegação:  Brasil - Veículos - venda           \\
  2466. //                                                                           \\
  2467. //---------------------------------------------------------------------------\\
  2468. function ShowLinkNav($codest,$codcid,$codcat1,$codcat2,$codcat3) {
  2469.  
  2470.     /* Estado */
  2471.     if($codest == ''){
  2472.         $link = "<a href=\"/\" class=\"link_titulo_classi_2\">Brasil</a>";
  2473.     }else{
  2474.        
  2475.         $sqlEstado = "SELECT nome_inteiro FROM estados WHERE ID=$codest";
  2476.         $sqlEstado = mysql_query($sqlEstado);
  2477.         $nomeEstado = mysql_result($sqlEstado,0,'nome_inteiro');
  2478.          @$nomeEstado = NomeEstado($codest);
  2479.         if($nomeEstado){
  2480.             $nomeEstado = $nomeEstado;
  2481.         }else{
  2482.             $nomeEstado = 'Brasil';
  2483.         }
  2484.  
  2485.         $completaURL2 = StringUrlAmigavel($nomeEstado);
  2486.         $completaURL2 = $completaURL2."-$codest.htm";
  2487.         $completaURL2 = str_replace("--", "-", $completaURL2);
  2488.  
  2489.         $link = "<a href=\"/\" class=\"link_titulo_classi_2\">Brasil</a>";
  2490.         $link .= " - <a href=\"$completaURL2\" class=\"link_titulo_classi_2\" rel=\"nofollow\">$nomeEstado</a>";
  2491.  
  2492.     }
  2493.  
  2494.     /* Cidade */
  2495.     if($codcid != ''){
  2496.  
  2497.         $sqlCidade = "SELECT ID,nome FROM cidades WHERE ID=$codcid";
  2498.         $sqlCidade = mysql_query($sqlCidade);
  2499.         $nomeCidade = mysql_result($sqlCidade,0,'nome');
  2500.         $IDCidade = mysql_result($sqlCidade,0,'ID');
  2501.         @$nomeEstado = NomeEstado($codest);
  2502.         if($nomeEstado){
  2503.             $nomeEstado = $nomeEstado;
  2504.         }else{
  2505.             $nomeEstado = 'Brasil';
  2506.         }
  2507.  
  2508.         @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
  2509.         @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
  2510.         @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
  2511.  
  2512.         $completaURL3 = StringUrlAmigavel($nomeCidade);
  2513.         $completaURL3 =  $completaURL3."__$IDCidade.htm";
  2514.         $link .= " - <a href=\"$completaURL3\" rel=\"nofollow\" class=\"link_titulo_classi_2\">$nomeCidade</a>";
  2515.  
  2516.     }
  2517.  
  2518.     /* Categoria 1 */
  2519.     if(@$codcat1 != ''){
  2520.  
  2521.         @$sqlCat1 = "SELECT nome FROM categoria_mae WHERE ID=$codcat1";
  2522.         @$sqlCat1 = mysql_query($sqlCat1);
  2523.         @$nomeCat1 = mysql_result($sqlCat1,0,'nome');
  2524.  
  2525.         @$nomeEstado = NomeEstado($codest);
  2526.         if($nomeEstado){
  2527.             $nomeEstado = $nomeEstado;
  2528.         }else{
  2529.             $nomeEstado = 'Brasil';
  2530.         }
  2531.  
  2532.         @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
  2533.         @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
  2534.         @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
  2535.  
  2536.         //$completaURL4 = StringUrlAmigavel("$nomecat1 $nomeEstado");
  2537.         $completaURL4 = trim(StringUrlAmigavel($nomecat1));
  2538.         $nome_estadoUrl = trim(StringUrlAmigavel($nomeEstado));
  2539.         $completaURL4 = str_replace("--", "-", $completaURL4);
  2540.         $completaURL4 = $completaURL4.'-'.$nome_estadoUrl.'-'."__$codest-$codcid-$codcat1--.htm";
  2541.  
  2542.         $link .= " - <a href=\"$completaURL4\" rel=\"nofollow\" class=\"link_titulo_classi_2\">$nomeCat1</a>";
  2543.  
  2544.     }
  2545.  
  2546.  
  2547.     /* Categoria 2 */
  2548.     if(@$codcat2 != ''){
  2549.  
  2550.         $sqlCat2 = "SELECT nome FROM sub_categoria WHERE ID=$codcat2";
  2551.         $sqlCat2 = mysql_query($sqlCat2);
  2552.         $nomeCat2 = mysql_result($sqlCat2,0,'nome');
  2553.  
  2554.         @$nomeEstado = NomeEstado($codest);
  2555.         if($nomeEstado){
  2556.             $nomeEstado = $nomeEstado;
  2557.         }else{
  2558.             $nomeEstado = 'Brasil';
  2559.         }
  2560.  
  2561.         @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
  2562.         @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
  2563.         @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
  2564.  
  2565.         //$completaURL5 = StringUrlAmigavel("$nomecat1 $nomecat2 $nomeEstado");
  2566.         $completaURL5 = StringUrlAmigavel($nomecat1);
  2567.         $nomecatURL5 = StringUrlAmigavel($nomecat2);
  2568.         $nomeEstado2URL5 = StringUrlAmigavel($nomeEstado);
  2569.  
  2570.         $completaURL5 = str_replace("--", "-", $completaURL5);
  2571.  
  2572.         $completaURL5 = $completaURL5.'-'.$nomecatURL5.'-'.$nomeEstado2URL5.'-'."__$codest-$codcid-$codcat1-$codcat2-.htm";
  2573.  
  2574.         $link .= " - <a href=\"$completaURL5\" rel=\"nofollow\" class=\"link_titulo_classi_2\">$nomeCat2</a>";
  2575.  
  2576.     }
  2577.  
  2578.     /* Categoria 3 */
  2579.     if(@$codcat3 != ''){
  2580.  
  2581.         @$sqlCat3 = "SELECT nome FROM sub_categoria_n_2 WHERE ID=$codcat3";
  2582.         @$sqlCat3 = mysql_query($sqlCat3);
  2583.         @$nomeCat3 = mysql_result($sqlCat3,0,'nome');
  2584.  
  2585.         @$nomeEstado = NomeEstado($codest);
  2586.         if($nomeEstado){
  2587.             $nomeEstado = $nomeEstado;
  2588.         }else{
  2589.             $nomeEstado = 'Brasil';
  2590.         }
  2591.  
  2592.         @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
  2593.         @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
  2594.         @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
  2595.  
  2596.         //$completaURL6 = StringUrlAmigavel("$nomecat1 $nomecat2 $nomecat3 $nomeEstado");
  2597.         $completaURL6 = StringUrlAmigavel($nomecat1);
  2598.         $nomecat2URL6 = StringUrlAmigavel($nomecat2);
  2599.         $nomecat3URL6 = StringUrlAmigavel($nomecat3);
  2600.         $nomeEstado2URL6 = StringUrlAmigavel($nomeEstado);
  2601.         $completaURL6 = str_replace("--", "-", $completaURL6);
  2602.         $completaURL6 = $completaURL6.'-'.$nomecat2URL6.'-'.$nomecat3URL6.'-'.$nomeEstado2URL6.'-'."__$codest-$codcid-$codcat1-$codcat2-$codcat3.htm";
  2603.  
  2604.         $link .= " - <a href=\"$completaURL6\" rel=\"nofollow\" class=\"link_titulo_classi_2\">$nomeCat3</a>";
  2605.     }
  2606.    
  2607.     echo $link;
  2608. }
  2609.  
  2610.  
  2611. //---------------------------------------------------------------------------\\
  2612. //  Função RefinaBusca($codcat2,$codcat3)                                    \\
  2613. //  Desc: mostra elementos para refinas a busca                              \\
  2614. //  conforme a subcategoria e a categoria                                    \\
  2615. //                                                                           \\
  2616. //---------------------------------------------------------------------------\\
  2617. function RefinaBusca($codcat1,$codcat2,$codcat3) {
  2618.  
  2619.     // Veiculos - carro caminhoes e onibus  novos e seminovos
  2620.     if(
  2621.     (($codcat2 == 5) AND ($codcat3 == 30)) OR
  2622.     (($codcat2 == 6) AND ($codcat3 == 34)) OR
  2623.     (($codcat2 == 5) AND ($codcat3 == 31)) OR
  2624.     (($codcat2 == 6) AND ($codcat3 == 35)) OR
  2625.     (($codcat2 == 5) AND ($codcat3 == 32)) OR
  2626.     (($codcat2 == 6) AND ($codcat3 == 36))
  2627.     ){
  2628.         $sqlAcess = "SELECT ID,nome FROM auto_acessorio";
  2629.         $sqlAcess = mysql_query($sqlAcess);
  2630.  
  2631.         echo "
  2632.        <script>
  2633.        function BuscaAvancada(valor){
  2634.            if(valor == 'none'){
  2635.                document.getElementById('dv_avancada').style.display='block';
  2636.                document.getElementById('mostra_inner').innerHTML='Busca Simples';
  2637.                document.form_refina_busca.reset();
  2638.            }else{
  2639.                document.getElementById('dv_avancada').style.display='none';
  2640.                document.getElementById('mostra_inner').innerHTML='Busca Avançada';
  2641.                document.form_refina_busca.reset();
  2642.            }
  2643.        }
  2644.        </script>
  2645.        <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"Busca Simples\"/></div>
  2646.        <div  style=\"margin-left:20px; margin-bottom:15px; margin-top:0px\"> <a href=\"javascript:void(0)\" onclick=\"BuscaAvancada(document.getElementById('dv_avancada').style.display)\" class= \"bnt_busca_avanc\"><div id=\"mostra_inner\">Busca Simples</div></a> </div>";
  2647.  
  2648.  
  2649.         /* Busca avançada */
  2650.         echo "<div id=\"dv_avancada\" style=\"display:block\" >";
  2651.  
  2652.         /* Faixa de Preço */
  2653.         echo "
  2654.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Faixa de preço</span></div>
  2655.        <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Mínimo R\$</span></div>
  2656.        <div style=\"margin-top:0px; margin-left:6px;\">
  2657.        <input name=\"preco_minimo\" type=\"text\" class=\"form\" id=\"preco_minimo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
  2658.        </div>
  2659.  
  2660.  
  2661.  
  2662.        <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Máximo R\$</span></div>
  2663.  
  2664.        <div style=\"margin-top:0px; margin-left:6px;\">
  2665.  
  2666.        <input name=\"preco_maximo\" type=\"text\" class=\"form\" id=\"preco_maximo\"  onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
  2667.  
  2668.        </div>
  2669.  
  2670.        <hr class=\"estiloHr\">
  2671.  
  2672.        ";
  2673.  
  2674.  
  2675.  
  2676.         /* Acessórios */
  2677.  
  2678.         echo "
  2679.  
  2680.        <!-- acessorios -->
  2681.  
  2682.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Acessórios</span></div>
  2683.  
  2684.        <div style=\"margin-top:5px; margin-left:6px;\">";
  2685.  
  2686.  
  2687.  
  2688.         while ($rowAcess = mysql_fetch_array($sqlAcess)) {
  2689.  
  2690.  
  2691.  
  2692.             $nomeAcessorio = CropTexto($rowAcess['nome'],19);
  2693.  
  2694.             echo "
  2695.  
  2696.            <div class=\"menu_bot_links\" style=\"margin-top:3px;\">
  2697.  
  2698.            <div style=\" padding-left:0px; padding-top:2px;\" >
  2699.  
  2700.  
  2701.  
  2702.            <div style=\"float:left; margin-top:3px;\"><input name=\"veiculos_acessorios[]\" type=\"checkbox\" value=\"$rowAcess[ID]\" /></div>
  2703.  
  2704.            <div style=\"margin-top:5px;\" class=\"texto_pequeno\">$nomeAcessorio</div>
  2705.  
  2706.  
  2707.  
  2708.            </div>
  2709.  
  2710.            </div>
  2711.  
  2712.  
  2713.  
  2714.            ";
  2715.  
  2716.         }
  2717.  
  2718.  
  2719.  
  2720.         echo "
  2721.  
  2722.        </div>
  2723.  
  2724.        <hr class=\"estiloHr\">";
  2725.  
  2726.  
  2727.  
  2728.         /* Cor do veículo */
  2729.  
  2730.  
  2731.  
  2732.         echo "
  2733.  
  2734.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Cor</span></div>
  2735.  
  2736.        <div style=\"margin-top:5px; margin-left:6px;\">
  2737.  
  2738.  
  2739.  
  2740.        <select name=\"auto_cor\" class=\"form\" id=\"auto_cor\" style=\"width:145px;\">
  2741.  
  2742.        <option value=\"\">Indiferente</option>
  2743.  
  2744.  
  2745.  
  2746.        ";
  2747.  
  2748.         $cor = SelectHtmlTabela('auto_cor','');
  2749.  
  2750.         echo $cor;
  2751.  
  2752.         echo "
  2753.  
  2754.        </select>
  2755.  
  2756.        </div>
  2757.  
  2758.        <hr class=\"estiloHr\">
  2759.  
  2760.        ";
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.         /* final da placa */
  2767.  
  2768.  
  2769.  
  2770.         echo "
  2771.  
  2772.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Final da placa</span></div>
  2773.  
  2774.        <div style=\"margin-top:5px; margin-left:6px;\">
  2775.  
  2776.  
  2777.  
  2778.        <select name=\"auto_final_placa\" class=\"form\" id=\"auto_final_placa\" style=\"width:145px;\">
  2779.  
  2780.        <option value=\"\">Indiferente</option>
  2781.  
  2782.  
  2783.  
  2784.        ";
  2785.  
  2786.         $finalPlaca = SelectHtmlTabela('auto_final_placa','');
  2787.  
  2788.         echo $finalPlaca;
  2789.  
  2790.         echo "
  2791.  
  2792.        </select>
  2793.  
  2794.        </div>
  2795.  
  2796.        <hr class=\"estiloHr\">
  2797.  
  2798.        ";
  2799.  
  2800.  
  2801.  
  2802.  
  2803.  
  2804.         /* Número de postas */
  2805.  
  2806.         if($codcat3 != 32){
  2807.  
  2808.             if($codcat3 != 36){
  2809.  
  2810.         echo "
  2811.  
  2812.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Número de portas</span></div>
  2813.  
  2814.        <div style=\"margin-top:5px; margin-left:6px;\">
  2815.  
  2816.  
  2817.  
  2818.        <select name=\"auto_n_porta\" class=\"form\" id=\"auto_n_porta\" style=\"width:145px;\">
  2819.  
  2820.        <option value=\"\">Indiferente</option>
  2821.  
  2822.  
  2823.  
  2824.        ";
  2825.  
  2826.         $n_porta = SelectHtmlTabela('auto_n_porta','');
  2827.  
  2828.         echo $n_porta;
  2829.  
  2830.         echo "
  2831.  
  2832.        </select>
  2833.  
  2834.        </div>
  2835.  
  2836.        <hr class=\"estiloHr\">
  2837.  
  2838.        ";
  2839.  
  2840.             }
  2841.  
  2842.         }
  2843.  
  2844.  
  2845.  
  2846.         /* Fabricante */
  2847.  
  2848.  
  2849.  
  2850.         echo "
  2851.  
  2852.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Fabricante</span></div>
  2853.  
  2854.        <div style=\"margin-top:5px; margin-left:6px;\">
  2855.  
  2856.  
  2857.  
  2858.        <select name=\"auto_fabricante\" class=\"form\" id=\"auto_fabricante\" style=\"width:145px;\">
  2859.  
  2860.        <option value=\"\">Indiferente</option>
  2861.  
  2862.  
  2863.  
  2864.        ";
  2865.  
  2866.         $fabricante = SelectHtmlTabela('auto_fabricante','');
  2867.  
  2868.         echo $fabricante;
  2869.  
  2870.         echo "
  2871.  
  2872.        </select>
  2873.  
  2874.        </div>
  2875.  
  2876.        <hr class=\"estiloHr\">
  2877.  
  2878.        ";
  2879.  
  2880.  
  2881.  
  2882.  
  2883.  
  2884.          /* Ano */
  2885.  
  2886.  
  2887.  
  2888.         echo "
  2889.  
  2890.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Ano de fabricação</span></div>
  2891.  
  2892.        <div style=\"margin-top:5px; margin-left:6px;\">
  2893.  
  2894.  
  2895.  
  2896.        <select name=\"auto_ano_fab\" class=\"form\" id=\"auto_ano_fab\" style=\"width:145px;\">
  2897.  
  2898.        <option value=\"\">Indiferente</option>
  2899.  
  2900.  
  2901.  
  2902.        ";
  2903.  
  2904.         $anofabri = SelectHtmlTabela('auto_ano_fab','');
  2905.  
  2906.         echo $anofabri;
  2907.  
  2908.         echo "
  2909.  
  2910.        </select>
  2911.  
  2912.        </div>
  2913.  
  2914.        <hr class=\"estiloHr\">
  2915.  
  2916.        ";
  2917.  
  2918.  
  2919.  
  2920.         /* and busca avançada */
  2921.  
  2922.         echo "</div>";
  2923.  
  2924.  
  2925.  
  2926.     }
  2927.  
  2928.  
  2929.  
  2930.     // Veiculos - motos e seminovos
  2931.  
  2932.     if(
  2933.  
  2934.     (($codcat2 == 5) AND ($codcat3 == 33)) OR
  2935.  
  2936.     (($codcat2 == 6) AND ($codcat3 == 37))
  2937.  
  2938.     ){
  2939.  
  2940.  
  2941.  
  2942.  
  2943.  
  2944.         echo "
  2945.  
  2946.        <script>
  2947.  
  2948.        function BuscaAvancada(valor){
  2949.  
  2950.  
  2951.  
  2952.            if(valor == 'none'){
  2953.  
  2954.                document.getElementById('dv_avancada').style.display='block';
  2955.  
  2956.                document.getElementById('mostra_inner').innerHTML='Busca Simples';
  2957.  
  2958.                document.form_refina_busca.reset();
  2959.  
  2960.            }else{
  2961.  
  2962.                document.getElementById('dv_avancada').style.display='none';
  2963.  
  2964.                document.getElementById('mostra_inner').innerHTML='Busca Avançada';
  2965.  
  2966.                document.form_refina_busca.reset();
  2967.  
  2968.            }
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.        }
  2975.  
  2976.        </script>
  2977.  
  2978.  
  2979.  
  2980.        <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"Busca Simples\"/></div>
  2981.  
  2982.        <div  style=\"margin-left:20px; margin-bottom:15px; margin-top:0px\"> <a href=\"javascript:void(0)\" onclick=\"BuscaAvancada(document.getElementById('dv_avancada').style.display)\" class= \"bnt_busca_avanc\"><div id=\"mostra_inner\">Busca Simples</div></a> </div>";
  2983.  
  2984.  
  2985.  
  2986.  
  2987.  
  2988.  
  2989.  
  2990.         /* Busca avançada */
  2991.  
  2992.         echo "<div id=\"dv_avancada\" style=\"display:block\" >";
  2993.  
  2994.  
  2995.  
  2996.  
  2997.  
  2998.  
  2999.  
  3000.         /* Faixa de Preço */
  3001.  
  3002.  
  3003.  
  3004.         echo "
  3005.  
  3006.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Faixa de preço</span></div>
  3007.  
  3008.        <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Mínimo R\$</span></div>
  3009.  
  3010.        <div style=\"margin-top:0px; margin-left:6px;\">
  3011.  
  3012.        <input name=\"preco_minimo\" type=\"text\" class=\"form\" id=\"preco_minimo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
  3013.  
  3014.        </div>
  3015.  
  3016.  
  3017.  
  3018.        <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Máximo R\$</span></div>
  3019.  
  3020.        <div style=\"margin-top:0px; margin-left:6px;\">
  3021.  
  3022.        <input name=\"preco_maximo\" type=\"text\" class=\"form\" id=\"preco_maximo\"  onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
  3023.  
  3024.        </div>
  3025.  
  3026.        <hr class=\"estiloHr\">
  3027.  
  3028.        ";
  3029.  
  3030.  
  3031.  
  3032.         /* Cor do veículo */
  3033.  
  3034.  
  3035.  
  3036.         echo "
  3037.  
  3038.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Cor</span></div>
  3039.  
  3040.        <div style=\"margin-top:5px; margin-left:6px;\">
  3041.  
  3042.  
  3043.  
  3044.        <select name=\"auto_cor\" class=\"form\" id=\"auto_cor\" style=\"width:145px;\">
  3045.  
  3046.        <option value=\"\">Indiferente</option>
  3047.  
  3048.  
  3049.  
  3050.        ";
  3051.  
  3052.         $cor = SelectHtmlTabela('auto_cor','');
  3053.  
  3054.         echo $cor;
  3055.  
  3056.         echo "
  3057.  
  3058.        </select>
  3059.  
  3060.        </div>
  3061.  
  3062.        <hr class=\"estiloHr\">
  3063.  
  3064.        ";
  3065.  
  3066.  
  3067.  
  3068.  
  3069.  
  3070.         /* final da placa */
  3071.  
  3072.  
  3073.  
  3074.         echo "
  3075.  
  3076.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Final da placa</span></div>
  3077.  
  3078.        <div style=\"margin-top:5px; margin-left:6px;\">
  3079.  
  3080.  
  3081.  
  3082.        <select name=\"auto_final_placa\" class=\"form\" id=\"auto_final_placa\" style=\"width:145px;\">
  3083.  
  3084.        <option value=\"\">Indiferente</option>
  3085.  
  3086.  
  3087.  
  3088.        ";
  3089.  
  3090.         $finalPlaca = SelectHtmlTabela('auto_final_placa','');
  3091.  
  3092.         echo $finalPlaca;
  3093.  
  3094.         echo "
  3095.  
  3096.        </select>
  3097.  
  3098.        </div>
  3099.  
  3100.        <hr class=\"estiloHr\">
  3101.  
  3102.        ";
  3103.  
  3104.  
  3105.  
  3106.         /* Ano */
  3107.  
  3108.         echo "
  3109.  
  3110.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Ano de fabricação</span></div>
  3111.  
  3112.        <div style=\"margin-top:5px; margin-left:6px;\">
  3113.  
  3114.  
  3115.  
  3116.        <select name=\"auto_ano_fab\" class=\"form\" id=\"auto_ano_fab\" style=\"width:145px;\">
  3117.  
  3118.        <option value=\"\">Indiferente</option>
  3119.  
  3120.  
  3121.  
  3122.        ";
  3123.  
  3124.         $anofabri = SelectHtmlTabela('auto_ano_fab','');
  3125.  
  3126.         echo $anofabri;
  3127.  
  3128.         echo "
  3129.  
  3130.        </select>
  3131.  
  3132.        </div>
  3133.  
  3134.        <hr class=\"estiloHr\">
  3135.  
  3136.        ";
  3137.  
  3138.  
  3139.  
  3140.  
  3141.  
  3142.         /* and busca avançada */
  3143.  
  3144.         echo "</div>";
  3145.  
  3146.  
  3147.  
  3148.     }
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.      // Imoveis Venda Aluguel Apartamento Casa
  3155.  
  3156.     if(
  3157.  
  3158.     (($codcat2 == 7) AND ($codcat3 == 96)) OR
  3159.  
  3160.     (($codcat2 == 8) AND ($codcat3 == 101)) OR
  3161.  
  3162.     (($codcat2 == 7) AND ($codcat3 == 97)) OR
  3163.  
  3164.     (($codcat2 == 8) AND ($codcat3 == 102)) OR
  3165.  
  3166.     (($codcat2 == 9) AND ($codcat3 == 99))  OR
  3167.  
  3168.     (($codcat2 == 8) AND ($codcat3 == 104))
  3169.  
  3170.     ){
  3171.  
  3172.  
  3173.  
  3174.  
  3175.  
  3176.         echo "
  3177.  
  3178.        <script>
  3179.  
  3180.        function BuscaAvancada(valor){
  3181.  
  3182.  
  3183.  
  3184.            if(valor == 'none'){
  3185.  
  3186.                document.getElementById('dv_avancada').style.display='block';
  3187.  
  3188.                document.getElementById('mostra_inner').innerHTML='Busca Simples';
  3189.  
  3190.                document.form_refina_busca.reset();
  3191.  
  3192.            }else{
  3193.  
  3194.                document.getElementById('dv_avancada').style.display='none';
  3195.  
  3196.                document.getElementById('mostra_inner').innerHTML='Busca Avançada';
  3197.  
  3198.                document.form_refina_busca.reset();
  3199.  
  3200.            }
  3201.  
  3202.  
  3203.  
  3204.  
  3205.  
  3206.        }
  3207.  
  3208.        </script>
  3209.  
  3210.  
  3211.  
  3212.        <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"Busca Simples\"/></div>
  3213.  
  3214.        <div  style=\"margin-left:20px; margin-bottom:15px; margin-top:0px\"> <a href=\"javascript:void(0)\" onclick=\"BuscaAvancada(document.getElementById('dv_avancada').style.display)\" class= \"bnt_busca_avanc\"><div id=\"mostra_inner\">Busca Simples</div></a> </div>";
  3215.  
  3216.  
  3217.  
  3218.  
  3219.  
  3220.  
  3221.  
  3222.         /* Busca avançada */
  3223.  
  3224.         echo "<div id=\"dv_avancada\" style=\"display:block\" >";
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.         /* Faixa de Preço */
  3233.  
  3234.  
  3235.  
  3236.         echo "
  3237.  
  3238.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Faixa de preço</span></div>
  3239.  
  3240.        <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Mínimo R\$</span></div>
  3241.  
  3242.        <div style=\"margin-top:0px; margin-left:6px;\">
  3243.  
  3244.        <input name=\"preco_minimo\" type=\"text\" class=\"form\" id=\"preco_minimo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
  3245.  
  3246.        </div>
  3247.  
  3248.  
  3249.  
  3250.        <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Máximo R\$</span></div>
  3251.  
  3252.        <div style=\"margin-top:0px; margin-left:6px;\">
  3253.  
  3254.        <input name=\"preco_maximo\" type=\"text\" class=\"form\" id=\"preco_maximo\"  onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
  3255.  
  3256.        </div>
  3257.  
  3258.        <hr class=\"estiloHr\">
  3259.  
  3260.        ";
  3261.  
  3262.  
  3263.  
  3264.         /* àreea  */
  3265.  
  3266.  
  3267.  
  3268.         echo "
  3269.  
  3270.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Área (m2)</span></div>
  3271.  
  3272.        <div style=\"margin-top:5px; margin-left:6px;\">
  3273.  
  3274.  
  3275.  
  3276.        <select name=\"imoveis_area\" class=\"form\" id=\"imoveis_area\" style=\"width:145px;\">
  3277.  
  3278.        <option value=\"\">Indiferente</option>
  3279.  
  3280.  
  3281.  
  3282.        ";
  3283.  
  3284.         $area = SelectHtmlTabela('imoveis_area','');
  3285.  
  3286.         echo $area;
  3287.  
  3288.         echo "
  3289.  
  3290.        </select>
  3291.  
  3292.        </div>
  3293.  
  3294.        <hr class=\"estiloHr\">
  3295.  
  3296.        ";
  3297.  
  3298.  
  3299.  
  3300.  
  3301.  
  3302.         /* Quartos */
  3303.  
  3304.  
  3305.  
  3306.         echo "
  3307.  
  3308.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Quartos</span></div>
  3309.  
  3310.        <div style=\"margin-top:5px; margin-left:6px;\">
  3311.  
  3312.  
  3313.  
  3314.        <select name=\"imoveis_quartos\" class=\"form\" id=\"imoveis_quartos\" style=\"width:145px;\">
  3315.  
  3316.        <option value=\"\">Indiferente</option>
  3317.  
  3318.  
  3319.  
  3320.        ";
  3321.  
  3322.         $quartos = SelectHtmlTabela('imoveis_quartos','');
  3323.  
  3324.         echo $quartos;
  3325.  
  3326.         echo "
  3327.  
  3328.        </select>
  3329.  
  3330.        </div>
  3331.  
  3332.        <hr class=\"estiloHr\">
  3333.  
  3334.        ";
  3335.  
  3336.  
  3337.  
  3338.         /* Suites */
  3339.  
  3340.         echo "
  3341.  
  3342.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Suítes</span></div>
  3343.  
  3344.        <div style=\"margin-top:5px; margin-left:6px;\">
  3345.  
  3346.  
  3347.  
  3348.        <select name=\"imoveis_suite\" class=\"form\" id=\"imoveis_suite\" style=\"width:145px;\">
  3349.  
  3350.        <option value=\"\">Indiferente</option>
  3351.  
  3352.  
  3353.  
  3354.        ";
  3355.  
  3356.         $suites = SelectHtmlTabela('imoveis_suite','');
  3357.  
  3358.         echo $suites;
  3359.  
  3360.         echo "
  3361.  
  3362.        </select>
  3363.  
  3364.        </div>
  3365.  
  3366.        <hr class=\"estiloHr\">
  3367.  
  3368.        ";
  3369.  
  3370.  
  3371.  
  3372.         /* vagas */
  3373.  
  3374.         echo "
  3375.  
  3376.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Vagas</span></div>
  3377.  
  3378.        <div style=\"margin-top:5px; margin-left:6px;\">
  3379.  
  3380.  
  3381.  
  3382.        <select name=\"imoveis_vagas\" class=\"form\" id=\"imoveis_vagas\" style=\"width:145px;\">
  3383.  
  3384.        <option value=\"\">Indiferente</option>
  3385.  
  3386.  
  3387.  
  3388.        ";
  3389.  
  3390.         $vagas = SelectHtmlTabela('imoveis_vagas','');
  3391.  
  3392.         echo $vagas;
  3393.  
  3394.         echo "
  3395.  
  3396.        </select>
  3397.  
  3398.        </div>
  3399.  
  3400.        <hr class=\"estiloHr\">
  3401.  
  3402.        ";
  3403.  
  3404.  
  3405.  
  3406.  
  3407.  
  3408.         /* and busca avançada */
  3409.  
  3410.         echo "</div>";
  3411.  
  3412.  
  3413.  
  3414.     }
  3415.  
  3416.  
  3417.  
  3418.  
  3419.  
  3420.  
  3421.  
  3422.      // Imoveis Venda Aluguel Salas Comerciais
  3423.  
  3424.     if(
  3425.  
  3426.     (($codcat2 == 7) AND ($codcat3 == 98)) OR
  3427.  
  3428.     (($codcat2 == 8) AND ($codcat3 == 103))
  3429.  
  3430.     ){
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436.         echo "
  3437.  
  3438.        <script>
  3439.  
  3440.        function BuscaAvancada(valor){
  3441.  
  3442.  
  3443.  
  3444.            if(valor == 'none'){
  3445.  
  3446.                document.getElementById('dv_avancada').style.display='block';
  3447.  
  3448.                document.getElementById('mostra_inner').innerHTML='Busca Simples';
  3449.  
  3450.                document.form_refina_busca.reset();
  3451.  
  3452.            }else{
  3453.  
  3454.                document.getElementById('dv_avancada').style.display='none';
  3455.  
  3456.                document.getElementById('mostra_inner').innerHTML='Busca Avançada';
  3457.  
  3458.                document.form_refina_busca.reset();
  3459.  
  3460.            }
  3461.  
  3462.  
  3463.  
  3464.  
  3465.  
  3466.        }
  3467.  
  3468.        </script>
  3469.  
  3470.  
  3471.  
  3472.        <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"Busca Simples\"/></div>
  3473.  
  3474.        <div  style=\"margin-left:20px; margin-bottom:15px; margin-top:0px\"> <a href=\"javascript:void(0)\" onclick=\"BuscaAvancada(document.getElementById('dv_avancada').style.display)\" class= \"bnt_busca_avanc\"><div id=\"mostra_inner\">Busca Simples</div></a> </div>";
  3475.  
  3476.  
  3477.  
  3478.  
  3479.  
  3480.  
  3481.  
  3482.         /* Busca avançada */
  3483.  
  3484.         echo "<div id=\"dv_avancada\" style=\"display:block\" >";
  3485.  
  3486.  
  3487.  
  3488.  
  3489.  
  3490.  
  3491.  
  3492.         /* Faixa de Preço */
  3493.  
  3494.  
  3495.  
  3496.         echo "
  3497.  
  3498.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Faixa de preço</span></div>
  3499.  
  3500.        <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Mínimo R\$</span></div>
  3501.  
  3502.        <div style=\"margin-top:0px; margin-left:6px;\">
  3503.  
  3504.        <input name=\"preco_minimo\" type=\"text\" class=\"form\" id=\"preco_minimo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
  3505.  
  3506.        </div>
  3507.  
  3508.  
  3509.  
  3510.        <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Máximo R\$</span></div>
  3511.  
  3512.        <div style=\"margin-top:0px; margin-left:6px;\">
  3513.  
  3514.        <input name=\"preco_maximo\" type=\"text\" class=\"form\" id=\"preco_maximo\"  onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
  3515.  
  3516.        </div>
  3517.  
  3518.        <hr class=\"estiloHr\">
  3519.  
  3520.        ";
  3521.  
  3522.  
  3523.  
  3524.  
  3525.  
  3526.         /* vagas */
  3527.  
  3528.         echo "
  3529.  
  3530.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Vagas</span></div>
  3531.  
  3532.        <div style=\"margin-top:5px; margin-left:6px;\">
  3533.  
  3534.  
  3535.  
  3536.        <select name=\"imoveis_vagas\" class=\"form\" id=\"imoveis_vagas\" style=\"width:145px;\">
  3537.  
  3538.        <option value=\"\">Indiferente</option>
  3539.  
  3540.  
  3541.  
  3542.        ";
  3543.  
  3544.         $vagas = SelectHtmlTabela('imoveis_vagas','');
  3545.  
  3546.         echo $vagas;
  3547.  
  3548.         echo "
  3549.  
  3550.        </select>
  3551.  
  3552.        </div>
  3553.  
  3554.        <hr class=\"estiloHr\">
  3555.  
  3556.        ";
  3557.  
  3558.  
  3559.  
  3560.  
  3561.  
  3562.         /* and busca avançada */
  3563.  
  3564.         echo "</div>";
  3565.  
  3566.  
  3567.  
  3568.     }
  3569.  
  3570.  
  3571.  
  3572.  
  3573.  
  3574.      // Imoveis Venda Aluguel Terrenos
  3575.  
  3576.     if(
  3577.  
  3578.     (($codcat2 == 7) AND ($codcat3 == 100)) OR
  3579.  
  3580.     (($codcat2 == 8) AND ($codcat3 == 105))
  3581.  
  3582.     ){
  3583.  
  3584.  
  3585.  
  3586.  
  3587.  
  3588.         echo "
  3589.  
  3590.        <script>
  3591.  
  3592.        function BuscaAvancada(valor){
  3593.  
  3594.  
  3595.  
  3596.            if(valor == 'none'){
  3597.  
  3598.                document.getElementById('dv_avancada').style.display='block';
  3599.  
  3600.                document.getElementById('mostra_inner').innerHTML='Busca Simples';
  3601.  
  3602.                document.form_refina_busca.reset();
  3603.  
  3604.            }else{
  3605.  
  3606.                document.getElementById('dv_avancada').style.display='none';
  3607.  
  3608.                document.getElementById('mostra_inner').innerHTML='Busca Avançada';
  3609.  
  3610.                document.form_refina_busca.reset();
  3611.  
  3612.            }
  3613.  
  3614.  
  3615.  
  3616.  
  3617.  
  3618.        }
  3619.  
  3620.        </script>
  3621.  
  3622.  
  3623.  
  3624.        <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"Busca Simples\"/></div>
  3625.  
  3626.        <div  style=\"margin-left:20px; margin-bottom:15px; margin-top:0px\"> <a href=\"javascript:void(0)\" onclick=\"BuscaAvancada(document.getElementById('dv_avancada').style.display)\" class= \"bnt_busca_avanc\"><div id=\"mostra_inner\">Busca Simples</div></a> </div>";
  3627.  
  3628.  
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634.         /* Busca avançada */
  3635.  
  3636.         echo "<div id=\"dv_avancada\" style=\"display:block\" >";
  3637.  
  3638.  
  3639.  
  3640.  
  3641.  
  3642.  
  3643.  
  3644.         /* Faixa de Preço */
  3645.  
  3646.  
  3647.  
  3648.         echo "
  3649.  
  3650.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Faixa de preço</span></div>
  3651.  
  3652.        <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Mínimo R\$</span></div>
  3653.  
  3654.        <div style=\"margin-top:0px; margin-left:6px;\">
  3655.  
  3656.        <input name=\"preco_minimo\" type=\"text\" class=\"form\" id=\"preco_minimo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
  3657.  
  3658.        </div>
  3659.  
  3660.  
  3661.  
  3662.        <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Máximo R\$</span></div>
  3663.  
  3664.        <div style=\"margin-top:0px; margin-left:6px;\">
  3665.  
  3666.        <input name=\"preco_maximo\" type=\"text\" class=\"form\" id=\"preco_maximo\"  onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
  3667.  
  3668.        </div>
  3669.  
  3670.        <hr class=\"estiloHr\">
  3671.  
  3672.        ";
  3673.  
  3674.  
  3675.  
  3676.  
  3677.  
  3678.  
  3679.  
  3680.         /* àreea  */
  3681.  
  3682.         echo "
  3683.  
  3684.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Área (m2)</span></div>
  3685.  
  3686.        <div style=\"margin-top:5px; margin-left:6px;\">
  3687.  
  3688.  
  3689.  
  3690.        <select name=\"imoveis_area\" class=\"form\" id=\"imoveis_area\" style=\"width:145px;\">
  3691.  
  3692.        <option value=\"\">Indiferente</option>
  3693.  
  3694.  
  3695.  
  3696.        ";
  3697.  
  3698.         $area = SelectHtmlTabela('imoveis_area','');
  3699.  
  3700.         echo $area;
  3701.  
  3702.         echo "
  3703.  
  3704.        </select>
  3705.  
  3706.        </div>
  3707.  
  3708.        <hr class=\"estiloHr\">
  3709.  
  3710.        ";
  3711.  
  3712.  
  3713.  
  3714.  
  3715.  
  3716.  
  3717.  
  3718.  
  3719.  
  3720.         /* and busca avançada */
  3721.  
  3722.         echo "</div>";
  3723.  
  3724.  
  3725.  
  3726.     }
  3727.  
  3728.  
  3729.  
  3730.  
  3731.  
  3732.  
  3733.  
  3734.  
  3735.  
  3736.      // Produtos A venda
  3737.  
  3738.     if(
  3739.  
  3740.     (($codcat1 == 1) AND ($codcat2 == 1))
  3741.  
  3742.     ){
  3743.  
  3744.  
  3745.  
  3746.  
  3747.  
  3748.         echo "
  3749.  
  3750.        <script>
  3751.  
  3752.        function BuscaAvancada(valor){
  3753.  
  3754.  
  3755.  
  3756.            if(valor == 'none'){
  3757.  
  3758.                document.getElementById('dv_avancada').style.display='block';
  3759.  
  3760.                document.getElementById('mostra_inner').innerHTML='Busca Simples';
  3761.  
  3762.                document.form_refina_busca.reset();
  3763.  
  3764.            }else{
  3765.  
  3766.                document.getElementById('dv_avancada').style.display='none';
  3767.  
  3768.                document.getElementById('mostra_inner').innerHTML='Busca Avançada';
  3769.  
  3770.                document.form_refina_busca.reset();
  3771.  
  3772.            }
  3773.  
  3774.  
  3775.  
  3776.  
  3777.  
  3778.        }
  3779.  
  3780.        </script>
  3781.  
  3782.  
  3783.  
  3784.        <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"Busca Simples\"/></div>
  3785.  
  3786.        <div  style=\"margin-left:20px; margin-bottom:15px; margin-top:0px\"> <a href=\"javascript:void(0)\" onclick=\"BuscaAvancada(document.getElementById('dv_avancada').style.display)\" class= \"bnt_busca_avanc\"><div id=\"mostra_inner\">Busca Simples</div></a> </div>";
  3787.  
  3788.  
  3789.  
  3790.  
  3791.  
  3792.  
  3793.  
  3794.         /* Busca avançada */
  3795.  
  3796.         echo "<div id=\"dv_avancada\" style=\"display:block\" >";
  3797.  
  3798.  
  3799.  
  3800.  
  3801.  
  3802.  
  3803.  
  3804.         /* Faixa de Preço */
  3805.  
  3806.  
  3807.  
  3808.         echo "
  3809.  
  3810.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Faixa de preço</span></div>
  3811.  
  3812.        <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Mínimo R\$</span></div>
  3813.  
  3814.        <div style=\"margin-top:0px; margin-left:6px;\">
  3815.  
  3816.        <input name=\"preco_minimo\" type=\"text\" class=\"form\" id=\"preco_minimo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
  3817.  
  3818.        </div>
  3819.  
  3820.  
  3821.  
  3822.        <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Máximo R\$</span></div>
  3823.  
  3824.        <div style=\"margin-top:0px; margin-left:6px;\">
  3825.  
  3826.        <input name=\"preco_maximo\" type=\"text\" class=\"form\" id=\"preco_maximo\"  onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
  3827.  
  3828.        </div>
  3829.  
  3830.        <hr class=\"estiloHr\">
  3831.  
  3832.        ";
  3833.  
  3834.  
  3835.  
  3836.  
  3837.  
  3838.  
  3839.  
  3840.         /* Produtos estado  */
  3841.  
  3842.         echo "
  3843.  
  3844.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Estado do Produto</span></div>
  3845.  
  3846.        <div style=\"margin-top:5px; margin-left:6px;\">
  3847.  
  3848.  
  3849.  
  3850.        <select name=\"produtos_estado\" class=\"form\" id=\"produtos_estado\" style=\"width:145px;\">
  3851.  
  3852.        <option value=\"\">Indiferente</option>
  3853.  
  3854.  
  3855.  
  3856.        ";
  3857.  
  3858.         $prod = SelectHtmlTabela('produtos_estado','');
  3859.  
  3860.         echo $prod;
  3861.  
  3862.         echo "
  3863.  
  3864.        </select>
  3865.  
  3866.        </div>
  3867.  
  3868.        <hr class=\"estiloHr\">
  3869.  
  3870.        ";
  3871.  
  3872.  
  3873.  
  3874.         /* and busca avançada */
  3875.  
  3876.         echo "</div>";
  3877.  
  3878.  
  3879.  
  3880.     }
  3881.  
  3882.  
  3883.  
  3884.  
  3885.  
  3886.  
  3887.  
  3888.      // Produtos oferta de compra
  3889.  
  3890.     if(
  3891.  
  3892.     (($codcat1 == 1) AND ($codcat2 == 2))
  3893.  
  3894.     ){
  3895.  
  3896.  
  3897.  
  3898.  
  3899.  
  3900.         echo "
  3901.  
  3902.        <script>
  3903.  
  3904.        function BuscaAvancada(valor){
  3905.  
  3906.  
  3907.  
  3908.            if(valor == 'none'){
  3909.  
  3910.                document.getElementById('dv_avancada').style.display='block';
  3911.  
  3912.                document.getElementById('mostra_inner').innerHTML='Busca Simples';
  3913.  
  3914.                document.form_refina_busca.reset();
  3915.  
  3916.            }else{
  3917.  
  3918.                document.getElementById('dv_avancada').style.display='none';
  3919.  
  3920.                document.getElementById('mostra_inner').innerHTML='Busca Avançada';
  3921.  
  3922.                document.form_refina_busca.reset();
  3923.  
  3924.            }
  3925.  
  3926.  
  3927.  
  3928.  
  3929.  
  3930.        }
  3931.  
  3932.        </script>
  3933.  
  3934.  
  3935.  
  3936.        <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"Busca Simples\"/></div>
  3937.  
  3938.        <div  style=\"margin-left:20px; margin-bottom:15px; margin-top:0px\"> <a href=\"javascript:void(0)\" onclick=\"BuscaAvancada(document.getElementById('dv_avancada').style.display)\" class= \"bnt_busca_avanc\"><div id=\"mostra_inner\">Busca Simples</div></a> </div>";
  3939.  
  3940.  
  3941.  
  3942.  
  3943.  
  3944.  
  3945.  
  3946.         /* Busca avançada */
  3947.  
  3948.         echo "<div id=\"dv_avancada\" style=\"display:block\" >";
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.  
  3956.         /* Faixa de Preço */
  3957.  
  3958.  
  3959.  
  3960.         echo "
  3961.  
  3962.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Faixa de preço</span></div>
  3963.  
  3964.        <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Mínimo R\$</span></div>
  3965.  
  3966.        <div style=\"margin-top:0px; margin-left:6px;\">
  3967.  
  3968.        <input name=\"preco_minimo\" type=\"text\" class=\"form\" id=\"preco_minimo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
  3969.  
  3970.        </div>
  3971.  
  3972.  
  3973.  
  3974.        <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Máximo R\$</span></div>
  3975.  
  3976.        <div style=\"margin-top:0px; margin-left:6px;\">
  3977.  
  3978.        <input name=\"preco_maximo\" type=\"text\" class=\"form\" id=\"preco_maximo\"  onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
  3979.  
  3980.        </div>
  3981.  
  3982.        <hr class=\"estiloHr\">
  3983.  
  3984.        ";
  3985.  
  3986.  
  3987.  
  3988.         /* and busca avançada */
  3989.  
  3990.         echo "</div>";
  3991.  
  3992.  
  3993.  
  3994.     }
  3995.  
  3996.  
  3997.  
  3998.  
  3999.  
  4000.  
  4001.  
  4002.      // Produtos oferta de compra
  4003.  
  4004.     if(
  4005.  
  4006.     (($codcat1 == 5) AND ($codcat2 == 24))
  4007.  
  4008.     ){
  4009.  
  4010.  
  4011.  
  4012.  
  4013.  
  4014.         echo "
  4015.  
  4016.        <script>
  4017.  
  4018.        function BuscaAvancada(valor){
  4019.  
  4020.  
  4021.  
  4022.            if(valor == 'none'){
  4023.  
  4024.                document.getElementById('dv_avancada').style.display='block';
  4025.  
  4026.                document.getElementById('mostra_inner').innerHTML='Busca Simples';
  4027.  
  4028.                document.form_refina_busca.reset();
  4029.  
  4030.            }else{
  4031.  
  4032.                document.getElementById('dv_avancada').style.display='none';
  4033.  
  4034.                document.getElementById('mostra_inner').innerHTML='Busca Avançada';
  4035.  
  4036.                document.form_refina_busca.reset();
  4037.  
  4038.            }
  4039.  
  4040.  
  4041.  
  4042.  
  4043.  
  4044.        }
  4045.  
  4046.        </script>
  4047.  
  4048.  
  4049.  
  4050.        <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"Busca Simples\"/></div>
  4051.  
  4052.        <div  style=\"margin-left:20px; margin-bottom:15px; margin-top:0px\"> <a href=\"javascript:void(0)\" onclick=\"BuscaAvancada(document.getElementById('dv_avancada').style.display)\" class= \"bnt_busca_avanc\"><div id=\"mostra_inner\">Busca Simples</div></a> </div>";
  4053.  
  4054.  
  4055.  
  4056.  
  4057.  
  4058.  
  4059.  
  4060.         /* Busca avançada */
  4061.  
  4062.         echo "<div id=\"dv_avancada\" style=\"display:block\" >";
  4063.  
  4064.  
  4065.  
  4066.  
  4067.  
  4068.  
  4069.  
  4070.         /* àreea de atuação */
  4071.  
  4072.         echo "
  4073.  
  4074.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Área de atuação</span></div>
  4075.  
  4076.        <div style=\"margin-top:5px; margin-left:6px;\">
  4077.  
  4078.  
  4079.  
  4080.        <select name=\"empregos_area_atuacao\" class=\"form\" style=\"width:145px;\" id=\"empregos_area_atuacao\">
  4081.  
  4082.        <option value=\"\">Indiferente</option>
  4083.  
  4084.  
  4085.  
  4086.        ";
  4087.  
  4088.         $areaAtuacao = SelectHtmlTabela('empregos_area_atuacao','');
  4089.  
  4090.         echo $areaAtuacao;
  4091.  
  4092.         echo "
  4093.  
  4094.        </select>
  4095.  
  4096.        </div>
  4097.  
  4098.        <hr class=\"estiloHr\">
  4099.  
  4100.        ";
  4101.  
  4102.  
  4103.  
  4104.  
  4105.  
  4106.         /* grau escolaridade */
  4107.  
  4108.         echo "
  4109.  
  4110.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Grau de escolaridade</span></div>
  4111.  
  4112.        <div style=\"margin-top:5px; margin-left:6px;\">
  4113.  
  4114.  
  4115.  
  4116.        <select name=\"empregos_escolaridade\" class=\"form\" id=\"empregos_escolaridade\" style=\"width:145px;\">
  4117.  
  4118.        <option value=\"\">Indiferente</option>
  4119.  
  4120.  
  4121.  
  4122.        ";
  4123.  
  4124.         $grauEscolaridade = SelectHtmlTabela('empregos_escolaridade','');
  4125.  
  4126.         echo $grauEscolaridade;
  4127.  
  4128.         echo "
  4129.  
  4130.        </select>
  4131.  
  4132.        </div>
  4133.  
  4134.        <hr class=\"estiloHr\">
  4135.  
  4136.        ";
  4137.  
  4138.  
  4139.  
  4140.  
  4141.  
  4142.  
  4143.  
  4144.         /* perfil */
  4145.  
  4146.         echo "
  4147.  
  4148.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Perfil</span></div>
  4149.  
  4150.        <div style=\"margin-top:5px; margin-left:6px;\">
  4151.  
  4152.  
  4153.  
  4154.        <select name=\"empregos_perfil\" class=\"form\" id=\"empregos_perfil\" style=\"width:145px;\">
  4155.  
  4156.        <option value=\"\">Indiferente</option>
  4157.  
  4158.  
  4159.  
  4160.        ";
  4161.  
  4162.         $perfil = SelectHtmlTabela('empregos_perfil','');
  4163.  
  4164.         echo $perfil;
  4165.  
  4166.         echo "
  4167.  
  4168.        </select>
  4169.  
  4170.        </div>
  4171.  
  4172.        <hr class=\"estiloHr\">
  4173.  
  4174.        ";
  4175.  
  4176.  
  4177.  
  4178.  
  4179.  
  4180.         /* salário */
  4181.  
  4182.         echo "
  4183.  
  4184.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Salário</span></div>
  4185.  
  4186.        <div style=\"margin-top:5px; margin-left:6px;\">
  4187.  
  4188.  
  4189.  
  4190.        <select name=\"empregos_salario\" class=\"form\" id=\"empregos_salario\" style=\"width:145px;\">
  4191.  
  4192.        <option value=\"\">Indiferente</option>
  4193.  
  4194.  
  4195.  
  4196.        ";
  4197.  
  4198.         $salario = SelectHtmlTabela('empregos_salario','');
  4199.  
  4200.         echo $salario;
  4201.  
  4202.         echo "
  4203.  
  4204.        </select>
  4205.  
  4206.        </div>
  4207.  
  4208.        <hr class=\"estiloHr\">
  4209.  
  4210.        ";
  4211.  
  4212.  
  4213.  
  4214.     }
  4215.  
  4216.  
  4217.  
  4218.  
  4219.  
  4220.      // Produtos oferta de compra
  4221.  
  4222.     if(
  4223.  
  4224.     (($codcat1 == 5) AND ($codcat2 == 25)) OR
  4225.  
  4226.     (($codcat1 == 5) AND ($codcat2 == 27))
  4227.  
  4228.     ){
  4229.  
  4230.  
  4231.  
  4232.  
  4233.  
  4234.         echo "
  4235.  
  4236.        <script>
  4237.  
  4238.        function BuscaAvancada(valor){
  4239.  
  4240.  
  4241.  
  4242.            if(valor == 'none'){
  4243.  
  4244.                document.getElementById('dv_avancada').style.display='block';
  4245.  
  4246.                document.getElementById('mostra_inner').innerHTML='Busca Simples';
  4247.  
  4248.                document.form_refina_busca.reset();
  4249.  
  4250.            }else{
  4251.  
  4252.                document.getElementById('dv_avancada').style.display='none';
  4253.  
  4254.                document.getElementById('mostra_inner').innerHTML='Busca Avançada';
  4255.  
  4256.                document.form_refina_busca.reset();
  4257.  
  4258.            }
  4259.  
  4260.  
  4261.  
  4262.  
  4263.  
  4264.        }
  4265.  
  4266.        </script>
  4267.  
  4268.  
  4269.  
  4270.        <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"Busca Simples\"/></div>
  4271.  
  4272.        <div  style=\"margin-left:20px; margin-bottom:15px; margin-top:0px\"> <a href=\"javascript:void(0)\" onclick=\"BuscaAvancada(document.getElementById('dv_avancada').style.display)\" class= \"bnt_busca_avanc\"><div id=\"mostra_inner\">Busca Simples</div></a> </div>";
  4273.  
  4274.  
  4275.  
  4276.  
  4277.  
  4278.  
  4279.  
  4280.         /* Busca avançada */
  4281.  
  4282.         echo "<div id=\"dv_avancada\" style=\"display:block\" >";
  4283.  
  4284.  
  4285.  
  4286.  
  4287.  
  4288.  
  4289.  
  4290.         /* àreea de atuação */
  4291.  
  4292.         echo "
  4293.  
  4294.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Área de atuação</span></div>
  4295.  
  4296.        <div style=\"margin-top:5px; margin-left:6px;\">
  4297.  
  4298.  
  4299.  
  4300.        <select name=\"empregos_area_atuacao\" class=\"form\" style=\"width:145px;\" id=\"empregos_area_atuacao\">
  4301.  
  4302.        <option value=\"\">Indiferente</option>
  4303.  
  4304.  
  4305.  
  4306.        ";
  4307.  
  4308.         $areaAtuacao = SelectHtmlTabela('empregos_area_atuacao','');
  4309.  
  4310.         echo $areaAtuacao;
  4311.  
  4312.         echo "
  4313.  
  4314.        </select>
  4315.  
  4316.        </div>
  4317.  
  4318.        <hr class=\"estiloHr\">
  4319.  
  4320.        ";
  4321.  
  4322.  
  4323.  
  4324.  
  4325.  
  4326.         /* perfil */
  4327.  
  4328.         echo "
  4329.  
  4330.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Perfil</span></div>
  4331.  
  4332.        <div style=\"margin-top:5px; margin-left:6px;\">
  4333.  
  4334.  
  4335.  
  4336.        <select name=\"empregos_perfil\" class=\"form\" id=\"empregos_perfil\" style=\"width:145px;\">
  4337.  
  4338.        <option value=\"\">Indiferente</option>
  4339.  
  4340.  
  4341.  
  4342.        ";
  4343.  
  4344.         $perfil = SelectHtmlTabela('empregos_perfil','');
  4345.  
  4346.         echo $perfil;
  4347.  
  4348.         echo "
  4349.  
  4350.        </select>
  4351.  
  4352.        </div>
  4353.  
  4354.        <hr class=\"estiloHr\">
  4355.  
  4356.        ";
  4357.  
  4358.  
  4359.  
  4360.  
  4361.  
  4362.         /* salário */
  4363.  
  4364.         echo "
  4365.  
  4366.        <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Salário</span></div>
  4367.  
  4368.        <div style=\"margin-top:5px; margin-left:6px;\">
  4369.  
  4370.  
  4371.  
  4372.        <select name=\"empregos_salario\" class=\"form\" id=\"empregos_salario\" style=\"width:145px;\">
  4373.  
  4374.        <option value=\"\">Indiferente</option>
  4375.  
  4376.  
  4377.  
  4378.        ";
  4379.  
  4380.         $salario = SelectHtmlTabela('empregos_salario','');
  4381.  
  4382.         echo $salario;
  4383.  
  4384.         echo "
  4385.  
  4386.        </select>
  4387.  
  4388.        </div>
  4389.  
  4390.        <hr class=\"estiloHr\">
  4391.  
  4392.        ";
  4393.  
  4394.  
  4395.  
  4396.     }
  4397.  
  4398.  
  4399.  
  4400.  
  4401.  
  4402.  
  4403.  
  4404. }
  4405.  
  4406.  
  4407.  
  4408.  
  4409.  
  4410. //---------------------------------------------------------------------------\\
  4411.  
  4412. //  Função Função para mostrar o tempo em dias que o anúncio tem para        \\
  4413.  
  4414. //  expirar                                                                  \\
  4415.  
  4416. //                                                                           \\
  4417.  
  4418. //---------------------------------------------------------------------------\\
  4419.  
  4420. function ContDowClassi($timeExpira){
  4421.  
  4422.     //$agoraH = (mktime() + 300);
  4423.  
  4424.     //echo $agoraH;
  4425.  
  4426.     if($timeExpira){
  4427.  
  4428.         if($timeExpira >= mktime()){
  4429.  
  4430.  
  4431.  
  4432.             $agora = mktime();
  4433.  
  4434.             $restante = ($timeExpira - $agora);
  4435.  
  4436.  
  4437.  
  4438.             //echo $restante;
  4439.  
  4440.             if($restante <= 86400){// se for maior que 1 Dia
  4441.  
  4442.                 if($restante <= 3600){// se for menor que 1 Hora
  4443.  
  4444.                     $minutos = round ($restante / 60);
  4445.  
  4446.                     $dataExpira = "$minutos minutos";
  4447.  
  4448.                     return $dataExpira;
  4449.  
  4450.                 }else{
  4451.  
  4452.                     $minutos = round ($restante / 3600);
  4453.  
  4454.                     $dataExpira = "$minutos Horas";
  4455.  
  4456.                     return $dataExpira;
  4457.  
  4458.                 }
  4459.  
  4460.             }
  4461.  
  4462.             if($restante >= 86400){// se for maior que 1 Dia
  4463.  
  4464.                 $minutos = round ($restante / 86400);
  4465.  
  4466.                 $dataExpira = "$minutos dias";
  4467.  
  4468.                 return $dataExpira;
  4469.  
  4470.             }
  4471.  
  4472.  
  4473.  
  4474.     }
  4475.  
  4476.  
  4477.  
  4478.     if($timeExpira <= mktime()){
  4479.  
  4480.         $dataExpira = "Apagar";
  4481.  
  4482.         return $dataExpira;
  4483.  
  4484.  
  4485.  
  4486.  
  4487.  
  4488.     }
  4489.  
  4490.  
  4491.  
  4492.     }else {
  4493.  
  4494.         $dataExpira = "Não expira";
  4495.  
  4496.     }
  4497.  
  4498. }
  4499.  
  4500.  
  4501.  
  4502.  
  4503.  
  4504. //---------------------------------------------------------------------------\\
  4505.  
  4506. //  Função Apaga anúncio ExcluiAnuncio($fk_anunio,$motivo,$fk_usuario)       \\
  4507.  
  4508. //  obs: Apaga o anuncio e todas as duas dependecias.                        \\
  4509.  
  4510. //  A váriavel motovo, refere-se ao motivo da exclusão do anúncio            \\
  4511.  
  4512. //                                                                           \\
  4513.  
  4514. //---------------------------------------------------------------------------\\
  4515.  
  4516. function ExcluiAnuncio($fk_anunio,$fk_usuario,$motivo){
  4517.  
  4518.     global $Path;
  4519.  
  4520.     global $pasta_img;
  4521.  
  4522.     $sql = mysql_query("
  4523.     SELECT
  4524.     anuncio.ID AS ID,
  4525.     anuncio.data_cad_timestamp AS data_cad_timestamp,
  4526.     anuncio.data_cad AS data_cad,
  4527.     anuncio.titulo AS titulo,
  4528.     anuncio.uri AS url,
  4529.     anuncio.ip_add AS ip_add,
  4530.     anuncio.ip_edit AS ip_edit,
  4531.     anuncio.site AS site,
  4532.     anuncio.telefone1 AS telefone1,
  4533.     anuncio.telefone2 AS telefone2,
  4534.     anuncio.fax AS fax,
  4535.     anuncio.email AS email,
  4536.     anuncio.nome AS nome,
  4537.     anuncio.fk_usuario AS fk_usuario,
  4538.     usuarios.email AS login,
  4539.     usuarios.shopping_user AS vitrine,
  4540.     usuarios.ip_log AS ip_last_log,
  4541.     usuarios.data_log AS data_last_log,
  4542.     cidades.nome AS cidade,
  4543.     estados.nome_inteiro AS estado
  4544.     FROM  (anuncio
  4545.     LEFT JOIN usuarios ON anuncio.fk_usuario = anuncio.ID
  4546.     LEFT JOIN cidades ON anuncio.fk_cidade = cidades.ID
  4547.     LEFT JOIN estados ON anuncio.fk_estado = estados.ID
  4548.     )
  4549.     WHERE anuncio.ID = $fk_anunio");
  4550.    
  4551.     $row =  mysql_fetch_assoc($sql);
  4552.  
  4553.     $tituloAnuncio = $row['titulo'];
  4554.     $urlAnuncio = $row['url'];
  4555.     $ip_add = $row['ip_add'];
  4556.     $ip_edit = $row['ip_edit'];
  4557.     $site = $row['site'];
  4558.     $telefone = $row['telefone1'].' - '.$row['telefone2'].' '.$row['fax'];
  4559.     $email = $row['email'];
  4560.     $nome = $row['nome'];
  4561.     $login = $row['login'];
  4562.     $vitrine = $row['vitrine'];
  4563.     $ip_last_log = $row['ip_last_log'];
  4564.     $data_last_log = $row['data_last_log'];
  4565.     $cidade = $row['cidade'];
  4566.     $estado = $row['estado'];
  4567.     $data_cad_timestamp = $row['data_cad_timestamp'];
  4568.     $data_cad = $row['data_cad'];
  4569.    
  4570.  
  4571.     /* Insere no banco de dados os dados do anúncio excluso */
  4572.  
  4573.     $queryInsere = mysql_query ("INSERT INTO anuncio_excluidos (fk_usuario,titulo_anuncio,url,data_cad,data_cad_timestamp,motivo,ip_add,ip_edit,nome,email,cidade,estado,telefone,usuario,vitrine,data_exclui) VALUES ('$fk_usuario','$tituloAnuncio','$urlAnuncio','$data_cad','$data_cad_timestamp','$motivo','$ip_add','$ip_edit','$nome','$email','$cidade','$estado','$telefone','$login','$vitrine',now())");
  4574.  
  4575.     $total = mysql_num_rows($sql);
  4576.  
  4577.     if($total == 0){
  4578.         echo "<script language=\"JavaScript\">alert('Operação ilegal! Não existe nenhum anúncio com o código $fk_anunio')</script>";
  4579.     }else{
  4580.         /* Apaga as imagens  */
  4581.         @$sqlImg = "SELECT ID,imagem,imagem_thumb,imagem_media FROM imagens WHERE fk_anuncio=$fk_anunio";
  4582.         @$sqlImg = mysql_query($sqlImg);
  4583.         while ($rowImg = mysql_fetch_array($sqlImg)) {
  4584.             @unlink($Path.'/'.$pasta_img.'/'.$rowImg['imagem']);
  4585.             @unlink($Path.'/'.$pasta_img.'/'.$rowImg['imagem_thumb']);
  4586.             @unlink($Path.'/'.$pasta_img.'/'.$rowImg['imagem_media']);
  4587.         }
  4588.  
  4589.         mysql_query("DELETE FROM anuncio_classifique WHERE fk_anuncio=$fk_anunio");
  4590.         mysql_query("DELETE FROM imagens WHERE fk_anuncio=$fk_anunio");
  4591.  
  4592.         //mysql_query("DELETE FROM anuncio_salvo WHERE fk_anuncio='$fk_anunio'");
  4593.  
  4594.         //mysql_query("DELETE FROM perguntas WHERE fk_anuncio='$fk_anunio'");
  4595.         mysql_query("DELETE FROM anuncio WHERE ID='$fk_anunio'");
  4596.         RemoveCache($fk_anunio);
  4597.     }
  4598.     //return $total;
  4599. }
  4600.  
  4601.  
  4602.  
  4603.  
  4604.  
  4605. //---------------------------------------------------------------------------\\
  4606.  
  4607. //  Função para retornar o nome do estado                                    \\
  4608.  
  4609. //---------------------------------------------------------------------------\\
  4610.  
  4611. function NomeEstado($valor){
  4612.  
  4613.     $sql = "SELECT nome_inteiro FROM estados where ID=$valor";
  4614.  
  4615.     $sql = mysql_query($sql);
  4616.  
  4617.  
  4618.  
  4619.     @$nomeEstado = mysql_result($sql,0,"nome_inteiro");
  4620.  
  4621.     return $nomeEstado;
  4622.  
  4623.  
  4624.  
  4625. }
  4626.  
  4627.  
  4628.  
  4629. //---------------------------------------------------------------------------\\
  4630.  
  4631. //  Função para retornar o ID do estado                                      \\
  4632.  
  4633. //---------------------------------------------------------------------------\\
  4634.  
  4635. function IDEstado($valor){
  4636.  
  4637.     $sql = "SELECT ID FROM estados where nome='$valor'";
  4638.  
  4639.     $sql = mysql_query($sql);
  4640.  
  4641.  
  4642.  
  4643.     @$IDEstado = mysql_result($sql,0,"ID");
  4644.  
  4645.     return $IDEstado;
  4646.  
  4647.  
  4648.  
  4649. }
  4650.  
  4651.  
  4652.  
  4653.  
  4654.  
  4655. //---------------------------------------------------------------------------\\
  4656.  
  4657. //  Função para remover acento                                               \\
  4658.  
  4659. //---------------------------------------------------------------------------\\
  4660.  
  4661. function strSemAcentos($string="", $mesma=1)
  4662.  
  4663. {
  4664.  
  4665.  
  4666.  
  4667.    $string = str_replace(" ", "-", $string);
  4668.  
  4669.    $string =     strtolower($string);
  4670.  
  4671.  
  4672.  
  4673.    if($string != "")
  4674.  
  4675.    {
  4676.  
  4677.       $com_acento = "à á â ã ä è é ê ë ì í î ï ò ó ô õ ö ù ú û ü À Á Â Ã Ä È É Ê Ë Ì Í Î Ò Ó Ô Õ Ö Ù Ú Û Ü ç Ç ñ Ñ";
  4678.  
  4679.       $sem_acento = "a a a a a e e e e i i i i o o o o o u u u u a a a a a e e e e i i i o o o o o u u u u c c n n";
  4680.  
  4681.       $c = explode(' ',$com_acento);
  4682.  
  4683.       $s = explode(' ',$sem_acento);
  4684.  
  4685.  
  4686.  
  4687.       $i=0;
  4688.  
  4689.       foreach($c as $letra)
  4690.  
  4691.       {
  4692.  
  4693.          if(ereg($letra, $string))
  4694.  
  4695.          {
  4696.  
  4697.             $pattern[] = $letra;
  4698.  
  4699.             $replacement[] = $s[$i];
  4700.  
  4701.          }
  4702.  
  4703.          $i=$i+1;
  4704.  
  4705.       }
  4706.  
  4707.  
  4708.  
  4709.       if(isset($pattern))
  4710.  
  4711.       {
  4712.  
  4713.          $i=0;
  4714.  
  4715.          foreach($pattern as $letra)
  4716.  
  4717.          {
  4718.  
  4719.             $string = eregi_replace($letra, $replacement[$i], $string);
  4720.  
  4721.             $i=$i+1;
  4722.  
  4723.          }
  4724.  
  4725.          return $string; # retorna string alterada
  4726.  
  4727.       }
  4728.  
  4729.       if ($mesma != 0)
  4730.  
  4731.       {
  4732.  
  4733.          return $string; # retorna a mesma string se nada mudou
  4734.  
  4735.       }
  4736.  
  4737.    }
  4738.  
  4739.  
  4740.  
  4741. return ""; # sem mudança retorna nada
  4742.  
  4743. }
  4744.  
  4745.  
  4746.  
  4747.  
  4748.  
  4749. //---------------------------------------------------------------------------\\
  4750.  
  4751. //  Cria Meta Tags para o Google                                             \\
  4752.  
  4753. //---------------------------------------------------------------------------\\
  4754.  
  4755. function MetaTagGoogle($codcat1,$codcat2,$codcat3)
  4756.  
  4757. {
  4758.  
  4759.  
  4760.  
  4761.  
  4762.  
  4763.  
  4764.  
  4765.         if($codcat2 == ''){
  4766.  
  4767.  
  4768.  
  4769.             /*  Verifica as subcategoria 1 */
  4770.  
  4771.             @$sqlSub1 = "SELECT ID,nome FROM sub_categoria WHERE fk_categoria=$codcat1";
  4772.  
  4773.             @$sqlSub1 = mysql_query($sqlSub1);
  4774.  
  4775.             @$totalSub1 = mysql_num_rows($sqlSub1);
  4776.  
  4777.             if($totalSub1 > 0){
  4778.  
  4779.                 while (@$rowSub1 = mysql_fetch_array($sqlSub1)) {
  4780.  
  4781.                    @$rowSub1_OK .= $rowSub1['nome'].' ';
  4782.  
  4783.                 }
  4784.  
  4785.                 return @$rowSub1_OK.',';
  4786.  
  4787.             }
  4788.  
  4789.         }else{
  4790.  
  4791.             /* Verifica as subcategoria 2 */
  4792.  
  4793.             @$sqlSub2 = "SELECT ID,nome FROM sub_categoria_n_2 WHERE fk_sub_categoria=$codcat2";
  4794.  
  4795.             @$sqlSub2 = mysql_query($sqlSub2);
  4796.  
  4797.             @$totalSub2 = mysql_num_rows($sqlSub2);
  4798.  
  4799.             if($totalSub2 > 0){
  4800.  
  4801.                 while (@$rowSub2 = mysql_fetch_array($sqlSub2)) {
  4802.  
  4803.                     @$rowSub2_OK .= $rowSub2['nome'].' ';
  4804.  
  4805.                 }
  4806.  
  4807.                 return @$rowSub2_OK.',';
  4808.  
  4809.             }
  4810.  
  4811.         }
  4812.  
  4813.         if($codcat3 == ''){
  4814.  
  4815.                     /*  Verifica as subcategoria 1 */
  4816.  
  4817.             @$sqlSub1 = "SELECT ID,nome FROM sub_categoria WHERE fk_categoria=$codcat1";
  4818.  
  4819.             @$sqlSub1 = mysql_query($sqlSub1);
  4820.  
  4821.             @$totalSub1 = mysql_num_rows($sqlSub1);
  4822.  
  4823.             if($totalSub1 > 0){
  4824.  
  4825.                 while (@$rowSub1 = mysql_fetch_array($sqlSub1)) {
  4826.  
  4827.                    @$rowSub1_OK .= $rowSub1['nome'].' ';
  4828.  
  4829.                 }
  4830.  
  4831.                 return @$rowSub1_OK.',';
  4832.  
  4833.             }
  4834.  
  4835.         }else{
  4836.  
  4837.  
  4838.  
  4839.                     /*  Verifica as subcategoria 1 */
  4840.  
  4841.             @$sqlSub3 = "SELECT ID,nome FROM sub_categoria_n_2 WHERE fk_categoria=$codcat3";
  4842.  
  4843.             @$sqlSub3 = mysql_query($sqlSub3);
  4844.  
  4845.             @$totalSub3 = mysql_num_rows($sqlSub3);
  4846.  
  4847.             if($totalSub3 > 0){
  4848.  
  4849.                 while (@$rowSub3 = mysql_fetch_array($sqlSub3)) {
  4850.  
  4851.                    @$rowSub3_OK .= $rowSub1['nome'].' ';
  4852.  
  4853.                 }
  4854.  
  4855.                 return @$rowSub3_OK.',';
  4856.  
  4857.             }
  4858.  
  4859.  
  4860.  
  4861.         }
  4862.  
  4863. }
  4864.  
  4865.  
  4866.  
  4867. //---------------------------------------------------------------------------\\
  4868.  
  4869. //  Verifica se o anúncio expirou e encia email ao usuario                   \\
  4870.  
  4871. //---------------------------------------------------------------------------\\
  4872.  
  4873.  
  4874.  
  4875. function AnuncioExpira()
  4876.  
  4877. {
  4878.  
  4879.     $teste='teste';
  4880.  
  4881. }
  4882.  
  4883. /*
  4884.  
  4885. function AnuncioExpira()
  4886.  
  4887. {
  4888.  
  4889.     global $db;
  4890.  
  4891.     global $PathAbsoluto;
  4892.  
  4893.     global $smtp_Servers;
  4894.  
  4895.     global $smtp_Username;
  4896.  
  4897.     global $smtp_Passworde;
  4898.  
  4899.     global $smtp_From_Name;
  4900.  
  4901.     global $smtp_From_Mail;
  4902.  
  4903.  
  4904.  
  4905.     $mkTime = mktime();
  4906.  
  4907.  
  4908.  
  4909.     $sqlapaga = "SELECT ID,data_expira_timestamp,fk_usuario,titulo FROM anuncio WHERE ($mkTime > data_expira_timestamp) AND statuss='Ativo'";
  4910.  
  4911.     $sqlapaga = mysql_query($sqlapaga);
  4912.  
  4913.  
  4914.  
  4915.     if(mysql_num_rows($sqlapaga) != "0"){
  4916.  
  4917.  
  4918.  
  4919.         while($array_apaga = mysql_fetch_array($sqlapaga)) {
  4920.  
  4921.  
  4922.  
  4923.             // Pegando as informacoes do Usuario
  4924.  
  4925.             $sqlUser = "SELECT email FROM usuarios WHERE ID=$array_apaga[fk_usuario]";
  4926.  
  4927.             $sqlUser = mysql_query($sqlUser);
  4928.  
  4929.  
  4930.  
  4931.             // E-mail do usuario
  4932.  
  4933.             $email_user = mysql_result($sqlUser,0,'email');
  4934.  
  4935.  
  4936.  
  4937.             // Função que retorna o tempo de expiracao
  4938.  
  4939.             $tempoExpira = ContDowClassi($array_apaga['data_expira_timestamp']);
  4940.  
  4941.  
  4942.  
  4943.  
  4944.  
  4945.             if($tempoExpira == 'Apagar'){
  4946.  
  4947.  
  4948.  
  4949.  
  4950.  
  4951.                 $mkTime24Horas = $mkTime+86400;
  4952.  
  4953.                 // Setando como Inativo os anúncios expirados
  4954.  
  4955.                 $up = "UPDATE anuncio SET expirado='s', statuss='Inativo', data_expira_timestamp=$mkTime24Horas WHERE ID=$array_apaga[ID]";
  4956.  
  4957.                 $up_query = mysql_db_query($db['db'],$up);
  4958.  
  4959.  
  4960.  
  4961.  
  4962.  
  4963.                 // Enviando email para o usuario
  4964.  
  4965.                 if (!class_exists("phpmailer")) {
  4966.  
  4967.                      require_once("include/phpmailer/class.phpmailer.php");
  4968.  
  4969.                 }
  4970.  
  4971.                 //require("include/phpmailer/class.phpmailer.php");
  4972.  
  4973.                 $mail = new PHPMailer();
  4974.  
  4975.  
  4976.  
  4977.                 $mail->IsSMTP();// send via SMTP
  4978.  
  4979.                 $mail->Host     = $smtp_Servers; // SMTP servers
  4980.  
  4981.                 $mail->SMTPAuth = true;     // turn on SMTP authentication
  4982.  
  4983.                 $mail->Username = $smtp_Username;  // SMTP username
  4984.  
  4985.                 $mail->Password = $smtp_Passworde; // SMTP password
  4986.  
  4987.  
  4988.  
  4989.                 $mail->FromName = $smtp_From_Name;
  4990.  
  4991.                 $mail->From = $smtp_From_Mail;
  4992.  
  4993.  
  4994.  
  4995.                 $mail->AddAddress($email_user,$email_user);
  4996.  
  4997.  
  4998.  
  4999.  
  5000.  
  5001.                 //$mail->AddBCC("alacrann@hotmail.com");
  5002.  
  5003.                 $mail->Subject =  "Anúncio expirado";
  5004.  
  5005.                 $mail->IsHTML(true); // send as HTML
  5006.  
  5007.                 $mail->Body = "<style type=\"text/css\">
  5008.  
  5009. <!--
  5010.  
  5011. .style1 {
  5012.  
  5013.         font-family: Verdana, Arial, Helvetica, sans-serif;
  5014.  
  5015.         font-size: 11px;
  5016.  
  5017.         color: #666666;
  5018.  
  5019. }
  5020.  
  5021. -->
  5022.  
  5023. </style>
  5024.  
  5025.  
  5026.  
  5027. <table width=\"578\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  5028.  
  5029.   <tr>
  5030.  
  5031.     <td bgcolor=\"#FFCC00\"><img src=\"$PathAbsoluto/img/logo_email.jpg\" alt=\"ClassiAQUI!\" width=\"127\" height=\"39\" /></td>
  5032.  
  5033.   </tr>
  5034.  
  5035.   <tr>
  5036.  
  5037.     <td bgcolor=\"#666666\" style=\"height:5px;\">&nbsp;</td>
  5038.  
  5039.   </tr>
  5040.  
  5041. </table>
  5042.  
  5043. <table width=\"578\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"border: 1px solid #CCCCCC;\">
  5044.  
  5045.   <tr>
  5046.  
  5047.     <td><div class=\"style1\" style=\"padding:8px;\">
  5048.  
  5049.       <p>Cara(o) Usuária(o),<br />
  5050.  
  5051.         <br />
  5052.  
  5053.  
  5054.  
  5055. Gostaríamos de informar que o anúncio de título (<strong>$array_apaga[titulo]</strong>)  expirou!<br /><br />
  5056.  
  5057. Para reinserí-lo agora, <a href=\"$PathAbsoluto/expirados_logado.php\">CLIQUE AQUI</a><br /><br />
  5058.  
  5059. Em 24 horas o anúncio será apagado do nosso banco de dados caso você não reinserí-lo.<br /><br />
  5060.  
  5061. Obrigado por utilizar o ClassiAqui!<br>
  5062.  
  5063. Atenciosamente<br />
  5064.  
  5065. Equipe ClassiAqui!<br />
  5066.  
  5067. <a href=\"$PathAbsoluto\">$PathAbsoluto</a></p><br />
  5068.  
  5069.     </div></td>
  5070.  
  5071.   </tr>
  5072.  
  5073. </table>
  5074.  
  5075. ";
  5076.  
  5077.  
  5078.  
  5079.                     if(!($mail->Send())){
  5080.  
  5081.                         echo "<script>alert('Erro ao enviar o e-mail')</script>";
  5082.  
  5083.                      }
  5084.  
  5085.  
  5086.  
  5087.  
  5088.  
  5089.  
  5090.  
  5091.             }
  5092.  
  5093.  
  5094.  
  5095.  
  5096.  
  5097.         }//fim while
  5098.  
  5099.  
  5100.  
  5101.  
  5102.  
  5103.     }//fim if
  5104.  
  5105.  
  5106.  
  5107.  
  5108.  
  5109. }
  5110.  
  5111.  
  5112.  
  5113. */
  5114.  
  5115.  
  5116.  
  5117. //---------------------------------------------------------------------------\\
  5118.  
  5119. //  Apaga os anuncios expirados                                              \\
  5120.  
  5121. //---------------------------------------------------------------------------\\
  5122.  
  5123. function ApagaExpirados(){
  5124.  
  5125.     $teste = 'teste';
  5126.  
  5127. }
  5128.  
  5129. /*
  5130.  
  5131. function ApagaExpirados(){
  5132.  
  5133.  
  5134.  
  5135.     $mkTime = mktime();
  5136.  
  5137.  
  5138.  
  5139.     $sqlapaga = "SELECT ID,data_expira_timestamp,fk_usuario,titulo FROM anuncio WHERE ($mkTime > data_expira_timestamp) AND statuss='Inativo' AND expirado='s'";
  5140.  
  5141.     $sqlapaga = mysql_query($sqlapaga);
  5142.  
  5143.  
  5144.  
  5145.     if(mysql_num_rows($sqlapaga) != "0"){
  5146.  
  5147.  
  5148.  
  5149.         while($array_apaga = mysql_fetch_array($sqlapaga)) {
  5150.  
  5151.  
  5152.  
  5153.             ExcluiAnuncio($array_apaga['ID'],$array_apaga['fk_usuario'],'Anúncio expirado');
  5154.  
  5155.  
  5156.  
  5157.         }
  5158.  
  5159.     }
  5160.  
  5161. }
  5162.  
  5163. */
  5164.  
  5165.  
  5166.  
  5167. //---------------------------------------------------------------------------\\
  5168.  
  5169. //  String URL amigavel                                                      \\
  5170.  
  5171. //---------------------------------------------------------------------------\\
  5172.  
  5173. function StringUrlAmigavel($string)
  5174.  
  5175. {
  5176.  
  5177.     $frase = $string;
  5178.  
  5179.     $frase = ereg_replace("[^a-zA-Z0-9_.]", "",
  5180.     //$frase = preg_replace("[^a-zA-Z0-9_.]", "",
  5181.  
  5182.       strtr($frase, "áàãâéêëíóôõúüçÁÀÃÂÉÊÍÓÔÕÚÜÇ ",
  5183.  
  5184.       "aaaaeeeiooouucaaaaeeiooouuc_"));
  5185.  
  5186.  
  5187.  
  5188.  
  5189.  
  5190.     $frase = str_replace("_", "-", $frase);
  5191.  
  5192.     $frase = strtolower($frase);
  5193.  
  5194.     $frase = str_replace(".", "-", $frase);
  5195.  
  5196.     $frase = str_replace("--", "-", $frase);
  5197.  
  5198.     $frase = str_replace("---", "-", $frase);
  5199.  
  5200.     $frase = str_replace("----", "-", $frase);
  5201.  
  5202.     $frase = str_replace("-----", "-", $frase);
  5203.  
  5204.     $frase = str_replace("------", "-", $frase);
  5205.  
  5206.     $frase = str_replace("-------", "-", $frase);
  5207.  
  5208.     $frase = str_replace("--------", "-", $frase);
  5209.  
  5210.     $frase = str_replace("---------", "-", $frase);
  5211.  
  5212.     $frase = str_replace("----------", "-", $frase);
  5213.  
  5214.     $frase = str_replace("-----------", "-", $frase);
  5215.  
  5216.     //return $frase;
  5217.  
  5218.     return $frase;
  5219.  
  5220. }
  5221.  
  5222.  
  5223.  
  5224. //---------------------------------------------------------------------------\\
  5225.  
  5226. //  Retorna o nome das Cat Sub                                               \\
  5227.  
  5228. //---------------------------------------------------------------------------\\
  5229.  
  5230. function RetornaNomeCategoria($opt,$ID)
  5231.  
  5232. {
  5233.  
  5234.     // Categoria Mãe
  5235.  
  5236.     if($opt == 1){
  5237.  
  5238.         $sql1 = "SELECT nome FROM categoria_mae WHERE ID=$ID";
  5239.  
  5240.         $sql1 = mysql_query($sql1);
  5241.  
  5242.         @$nome1 = mysql_result($sql1,0,"nome");
  5243.  
  5244.         return $nome1;
  5245.  
  5246.     }
  5247.  
  5248.  
  5249.  
  5250.     // Sub Categoria 1
  5251.  
  5252.     if($opt == 2){
  5253.  
  5254.         $sql2 = "SELECT nome FROM sub_categoria WHERE ID=$ID";
  5255.  
  5256.         $sql2 = mysql_query($sql2);
  5257.  
  5258.         @$nome2 = mysql_result($sql2,0,"nome");
  5259.  
  5260.         return $nome2;
  5261.  
  5262.     }
  5263.  
  5264.  
  5265.  
  5266.      // Sub Categoria 2
  5267.  
  5268.     if($opt == 3){
  5269.  
  5270.         $sql3 = "SELECT nome FROM sub_categoria_n_2 WHERE ID=$ID";
  5271.  
  5272.         $sql3 = mysql_query($sql3);
  5273.  
  5274.         @$nome3 = mysql_result($sql3,0,"nome");
  5275.  
  5276.         return $nome3;
  5277.  
  5278.     }
  5279.  
  5280.  
  5281.  
  5282. }
  5283.  
  5284.  
  5285.  
  5286. //---------------------------------------------------------------------------\\
  5287.  
  5288. //  Retorna o nome do usuario                                                \\
  5289.  
  5290. //---------------------------------------------------------------------------\\
  5291.  
  5292. function RetornaNomeUsuario($fk_usuario)
  5293.  
  5294. {
  5295.  
  5296.         $sql1 = "SELECT nome FROM usuarios WHERE ID=$fk_usuario";
  5297.  
  5298.         $sql1 = mysql_query($sql1);
  5299.  
  5300.         $nome1 = mysql_result($sql1,0,"nome");
  5301.  
  5302.         return $nome1;
  5303.  
  5304. }
  5305.  
  5306.  
  5307.  
  5308. //---------------------------------------------------------------------------\\
  5309.  
  5310. //  Checar se o usuario veio do Google                                       \\
  5311.  
  5312. //---------------------------------------------------------------------------\\
  5313.  
  5314.  
  5315.  
  5316.  
  5317.  
  5318. function googleRef($ref)
  5319.  
  5320. {
  5321.  
  5322.     //$ref = $_SERVER['HTTP_REFERER'];
  5323.  
  5324.     $teste = parse_url($ref);
  5325.  
  5326.     //print_r ($teste);
  5327.  
  5328.  
  5329.  
  5330.     $posGoogle = strpos($teste['host'],'google');
  5331.  
  5332.     $posYahoo = strpos($teste['host'],'yahoo');
  5333.  
  5334.     $posMywebsearch = strpos($teste['host'],'mywebsearch');
  5335.  
  5336.  
  5337.  
  5338.     if($posGoogle){
  5339.  
  5340.         //return $teste['query'];
  5341.  
  5342.  
  5343.  
  5344.         parse_str($teste['query']);
  5345.  
  5346.         return utf8_decode($q);
  5347.  
  5348.  
  5349.  
  5350.     }
  5351.  
  5352.  
  5353.  
  5354.     if($posYahoo){
  5355.  
  5356.         //return $teste['query'];
  5357.  
  5358.  
  5359.  
  5360.         parse_str($teste['query']);
  5361.  
  5362.         return utf8_decode($p);
  5363.  
  5364.  
  5365.  
  5366.     }
  5367.  
  5368.  
  5369.  
  5370.     if($posMywebsearch){
  5371.  
  5372.         //return $teste['query'];
  5373.  
  5374.  
  5375.  
  5376.         parse_str($teste['query']);
  5377.  
  5378.         return utf8_decode($searchfor);
  5379.  
  5380.  
  5381.  
  5382.     }
  5383.  
  5384.  
  5385.  
  5386.  
  5387.  
  5388.  
  5389.  
  5390. }
  5391.  
  5392. // Tira Acendo e espaço
  5393.  
  5394.  
  5395.  
  5396. function geraUrlLimpa($texto){
  5397.  
  5398. /* função que gera uma texto limpo pra virar URL:
  5399.  
  5400. - limpa acentos e transforma em letra normal
  5401.  
  5402. - limpa cedilha e transforma em c normal, o mesmo com o ñ
  5403.  
  5404. - transforma espaços em hifen (-)
  5405.  
  5406. - tira caracteres invalidos
  5407.  
  5408. */
  5409.  
  5410. //desconvertendo do padrão entitie (tipo &aacute; para á)
  5411.  
  5412. $texto = html_entity_decode($texto);
  5413.  
  5414. //tirando os acentos
  5415.  
  5416. $texto = eregi_replace('[aáàãâä]','a',$texto);
  5417.  
  5418. $texto = eregi_replace('[eéèêë]','e',$texto);
  5419.  
  5420. $texto = eregi_replace('[iíìîï]','i',$texto);
  5421.  
  5422. $texto = eregi_replace('[oóòõôö]','o',$texto);
  5423.  
  5424. $texto = eregi_replace('[uúùûü]','u',$texto);
  5425.  
  5426. $texto = eregi_replace('[ ]','',$texto);
  5427.  
  5428. $texto = eregi_replace('[!@#$%¨&*())]','',$texto);
  5429.  
  5430.  
  5431.  
  5432.  
  5433.  
  5434.  
  5435.  
  5436. //parte que tira o cedilha e o ñ
  5437.  
  5438. $texto = eregi_replace('[ç]','c',$texto);
  5439.  
  5440. $texto = eregi_replace('[ñ]','n',$texto);
  5441.  
  5442. //trocando espaço em branco por underline
  5443.  
  5444. //$texto = eregi_replace('( )','-',$texto);
  5445.  
  5446. //tirando outros caracteres invalidos
  5447.  
  5448. //$texto = eregi_replace('[^a-z0-9\-]','',$texto);
  5449.  
  5450. //trocando duplo espaço (hifen) por 1 hifen só
  5451.  
  5452. $texto = eregi_replace('--','',$texto);
  5453.  
  5454.  
  5455.  
  5456. return strtolower($texto);
  5457.  
  5458. }
  5459.  
  5460.  
  5461.  
  5462. function convertStringByUrlString($String){
  5463.  
  5464.  
  5465.  
  5466.         $Separador = "";
  5467.  
  5468.  
  5469.  
  5470.         $String = trim($String); //Removendo espaços do inicio e do fim da string
  5471.  
  5472.         $String = strtolower($String); //Convertendo a string para minúsculas
  5473.  
  5474.         $String = strip_tags($String); //Retirando as tags HTML e PHP da string
  5475.  
  5476.         $String = eregi_replace("[[:space:]]", $Separador, $String); //Substituindo todos os espaços por $Separador
  5477.  
  5478.  
  5479.  
  5480.         $String = eregi_replace("[çÇ]", "c", $String); //Substituindo caracteres especiais pela letra respectiva
  5481.  
  5482.         $String = eregi_replace("[áÁäÄàÀãÃâÂ]", "a", $String);
  5483.  
  5484.         $String = eregi_replace("[éÉëËèÈêÊ]", "e", $String);
  5485.  
  5486.         $String = eregi_replace("[íÍïÏìÌîÎ]", "i", $String);
  5487.  
  5488.         $String = eregi_replace("[óÓöÖòÒõÕôÔ]", "o", $String);
  5489.  
  5490.         $String = eregi_replace("[úÚüÜùÙûÛ]", "u", $String);
  5491.  
  5492.  
  5493.  
  5494.         $String = eregi_replace("(\()|(\))", $Separador, $String); //Substituindo outros caracteres por "$Separador"
  5495.  
  5496.         $String = eregi_replace("(\/)|(\\\)", $Separador, $String);
  5497.  
  5498.         $String = eregi_replace("(\[)|(\])", $Separador, $String);
  5499.  
  5500.         $String = eregi_replace("[@#\$%&\*\+=\|º]", $Separador, $String);
  5501.  
  5502.         $String = eregi_replace("[;:'\"<>,\.?!_-]", $Separador, $String);
  5503.  
  5504.         $String = eregi_replace("[“”]", $Separador, $String);
  5505.  
  5506.         $String = eregi_replace("(ª)+", $Separador, $String);
  5507.  
  5508.         $String = eregi_replace("[`´~^°]", $Separador, $String);
  5509.  
  5510.  
  5511.  
  5512.         $String = eregi_replace("($Separador)+", $Separador, $String); //Removendo o excesso de "$Separador" por apenas um
  5513.  
  5514.  
  5515.  
  5516.         $String = eregi_replace("(^($Separador)+)|(($Separador)+$)", "", $String); //Removendo o "$Separador" do inicio e fim da string
  5517.  
  5518.  
  5519.  
  5520.         return $String;
  5521.  
  5522. }
  5523.  
  5524.  
  5525.  
  5526. /*
  5527.  
  5528. * Funcção que verifica se é o googleboot que esta na página
  5529.  
  5530. */
  5531.  
  5532. function VerifyGoogleBoot($botip){
  5533.  
  5534.  
  5535.  
  5536.     //$botip = $_SERVER['REMOTE_ADDR'];
  5537.  
  5538.  
  5539.  
  5540.     $bothost = gethostbyaddr($botip);
  5541.  
  5542.  
  5543.  
  5544.     $verifiedbotip = gethostbyname($bothost);
  5545.  
  5546.  
  5547.  
  5548.     $boots = 0;
  5549.  
  5550.  
  5551.  
  5552.     if ($botip = $verifiedbotip) {
  5553.  
  5554.         if ( substr($bothost, -14) == '.googlebot.com') {
  5555.  
  5556.  
  5557.  
  5558.             $boots = 1;
  5559.  
  5560.  
  5561.  
  5562.         } elseif (substr( $bothost, -18) == '.inktomisearch.com') {
  5563.  
  5564.  
  5565.  
  5566.            $boots = 1;
  5567.  
  5568.  
  5569.  
  5570.         }
  5571.  
  5572.  
  5573.  
  5574.     }
  5575.  
  5576.  
  5577.  
  5578.     return $boots;
  5579.  
  5580. }
  5581.  
  5582.  
  5583.  
  5584. function MaisRelacionados($codcat1,$codcat2,$codcat3){
  5585.  
  5586.  
  5587.  
  5588.  
  5589.  
  5590.  
  5591.  
  5592.     /* Categoria 3 */
  5593.  
  5594.     if(@$codcat3 != ''){
  5595.  
  5596.  
  5597.  
  5598.         @$sqlCat3 = "SELECT nome FROM sub_categoria_n_2 WHERE ID=$codcat3";
  5599.  
  5600.         @$sqlCat3 = mysql_query($sqlCat3);
  5601.  
  5602.         @$nomeCat3 = mysql_result($sqlCat3,0,'nome');
  5603.  
  5604.  
  5605.  
  5606.  
  5607.  
  5608.         @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
  5609.  
  5610.         @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
  5611.  
  5612.         @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
  5613.  
  5614.  
  5615.  
  5616.         $completaURL6 = StringUrlAmigavel("$nomecat1 $nomecat2 $nomecat3");
  5617.  
  5618.         $completaURL6 = str_replace("--", "-", $completaURL6);
  5619.  
  5620.         $link = $completaURL6."__--$codcat1-$codcat2-$codcat3.htm";
  5621.  
  5622.  
  5623.  
  5624.  
  5625.  
  5626.  
  5627.  
  5628.  
  5629.  
  5630.  
  5631.  
  5632.         //$link .= " - <a href=\"$completaURL6\" class=\"link_titulo_classi_2\">$nomeCat3</a>";
  5633.  
  5634.         //$link .= " - <a href=\"lista_anuncio.php?codest=$codest&codcid=$codcid&codcat1=$codcat1&codcat2=$codcat2&codcat3=$codcat3&\" class=\"link_titulo_classi_2\">$nomeCat3</a>";
  5635.  
  5636.  
  5637.  
  5638.     }else{
  5639.  
  5640.  
  5641.  
  5642.  
  5643.  
  5644.         $sqlCat2 = "SELECT nome FROM sub_categoria WHERE ID=$codcat2";
  5645.  
  5646.         $sqlCat2 = mysql_query($sqlCat2);
  5647.  
  5648.         $nomeCat2 = mysql_result($sqlCat2,0,'nome');
  5649.  
  5650.  
  5651.  
  5652.  
  5653.  
  5654.         @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
  5655.  
  5656.         @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
  5657.  
  5658.         @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
  5659.  
  5660.  
  5661.  
  5662.         $completaURL5 = StringUrlAmigavel("$nomecat1 $nomecat2 $nomecat3");
  5663.  
  5664.         $completaURL5 = str_replace("--", "-", $completaURL5);
  5665.  
  5666.         $link = $completaURL5."__--$codcat1-$codcat2-.htm";
  5667.  
  5668.  
  5669.  
  5670.         //$link .= "<a href=\"$completaURL5\" class=\"link_titulo_classi_2\">$nomeCat2</a>";
  5671.  
  5672.  
  5673.  
  5674.  
  5675.  
  5676.     }
  5677.  
  5678.  
  5679.  
  5680.  
  5681.  
  5682. return $link;
  5683.  
  5684.  
  5685.  
  5686. }
  5687.  
  5688.  
  5689.  
  5690.  
  5691.  
  5692.  
  5693.  
  5694. function TestaResultML($valor){
  5695.  
  5696.  
  5697.  
  5698. require_once "class.xmltoarray.php";
  5699.  
  5700. ini_set("allow_url_fopen", 1); //função habilitada
  5701.  
  5702.  
  5703.  
  5704. @$xml_data = file_get_contents("http://www.mercadolivre.com.br/jm/searchXml?&as_word=OVO+DE+PASCOA+CASEIRO");
  5705.  
  5706.  
  5707.  
  5708. //Creating Instance of the Class
  5709.  
  5710. @$xmlObj    = new XmlToArray($xml_data);
  5711.  
  5712. //Creating Array
  5713.  
  5714. @$arrayData = $xmlObj->createArray();
  5715.  
  5716.  
  5717.  
  5718. //Creating Instance of the Class
  5719.  
  5720. @$xmlObj    = new XmlToArray($xml_data);
  5721.  
  5722. //Creating Array
  5723.  
  5724. @$arrayData = $xmlObj->createArray();
  5725.  
  5726.  
  5727.  
  5728. @$totalArray = count($arrayData['response']['listing'][0]['items'][0]['item']);
  5729.  
  5730.  
  5731.  
  5732. return  $totalArray;
  5733.  
  5734.  
  5735.  
  5736.  
  5737.  
  5738. }
  5739.  
  5740. /*
  5741. * Funcção que imprime os produtos do mercado livre
  5742. */
  5743. function GaleriaML($categoria,$tag_ml){
  5744.  
  5745.  
  5746.     require_once "class.xmltoarray.php";
  5747.     ini_set("allow_url_fopen", 1); //função habilitada
  5748.  
  5749.     if($tag_ml){
  5750.         $busca = $tag_ml;  
  5751.     }else{
  5752.         $busca = $categoria;
  5753.     }
  5754.  
  5755. //@$xml_data = file_get_contents("http://www.mercadolivre.com.br/jm/searchXml?&as_word=$valor&as_search_both=y");
  5756. //@$xml_data = file_get_contents("http://www.mercadolivre.com.br/jm/searchXml?as_order_id=$sorteia[$sorteado]&as_categ_id=$valor&gzip=y");
  5757. @$xml_data = file_get_contents("http://www.mercadolivre.com.br/jm/searchXml?as_word=$busca");
  5758.  
  5759.  
  5760. //Creating Instance of the Class
  5761. @$xmlObj    = new XmlToArray($xml_data);
  5762.  
  5763. //Creating Array
  5764. @$arrayData = $xmlObj->createArray();
  5765. @$totalArray = count($arrayData['response']['listing'][0]['items'][0]['item']);
  5766. $myidML = '5272606';
  5767.  
  5768. // produtos 1
  5769. @$titulo_1 = utf8_decode($arrayData['response']['listing'][0]['items'][0]['item'][1]['title']);
  5770. @$imagem_1 = $arrayData['response']['listing'][0]['items'][0]['item'][1]['image_url'];
  5771. @$link_1 = $arrayData['response']['listing'][0]['items'][0]['item'][1]['link'];
  5772. @$link_1 = str_replace("XXX", $myidML, $link_1);
  5773. @$currency_1 = $arrayData['response']['listing'][0]['items'][0]['item'][1]['currency']; //cifrão
  5774. @$price_1 = $arrayData['response']['listing'][0]['items'][0]['item'][1]['price'];
  5775.  
  5776.  
  5777.  
  5778. // produtos 2
  5779. @$titulo_2 = utf8_decode($arrayData['response']['listing'][0]['items'][0]['item'][2]['title']);
  5780. @$imagem_2 = $arrayData['response']['listing'][0]['items'][0]['item'][2]['image_url'];
  5781. @$link_2 = $arrayData['response']['listing'][0]['items'][0]['item'][2]['link'];
  5782. @$link_2 = str_replace("XXX", $myidML, $link_2);
  5783. @$currency_2 = $arrayData['response']['listing'][0]['items'][0]['item'][2]['currency']; //cifrão
  5784. @$price_2 = $arrayData['response']['listing'][0]['items'][0]['item'][2]['price'];
  5785.  
  5786. // produtos 3
  5787. @$titulo_3 = utf8_decode($arrayData['response']['listing'][0]['items'][0]['item'][3]['title']);
  5788. @$imagem_3 = $arrayData['response']['listing'][0]['items'][0]['item'][3]['image_url'];
  5789. @$link_3 = $arrayData['response']['listing'][0]['items'][0]['item'][3]['link'];
  5790. @$link_3 = str_replace("XXX", $myidML, $link_3);
  5791. @$currency_3 = $arrayData['response']['listing'][0]['items'][0]['item'][3]['currency']; //cifrão
  5792. @$price_3 = $arrayData['response']['listing'][0]['items'][0]['item'][3]['price'];
  5793.  
  5794.  
  5795. // produtos 4
  5796. @$titulo_4 = utf8_decode($arrayData['response']['listing'][0]['items'][0]['item'][4]['title']);
  5797. @$imagem_4 = $arrayData['response']['listing'][0]['items'][0]['item'][4]['image_url'];
  5798. @$link_4 = $arrayData['response']['listing'][0]['items'][0]['item'][4]['link'];
  5799. @$link_4 = str_replace("XXX", $myidML, $link_4);
  5800. @$currency_4 = $arrayData['response']['listing'][0]['items'][0]['item'][4]['currency']; //cifrão
  5801. @$price_4 = $arrayData['response']['listing'][0]['items'][0]['item'][4]['price'];
  5802.  
  5803.  
  5804. // produtos 5
  5805. @$titulo_5 = utf8_decode($arrayData['response']['listing'][0]['items'][0]['item'][5]['title']);
  5806. @$imagem_5 = $arrayData['response']['listing'][0]['items'][0]['item'][5]['image_url'];
  5807. @$link_5 = $arrayData['response']['listing'][0]['items'][0]['item'][5]['link'];
  5808. @$link_5 = str_replace("XXX", $myidML, $link_5);
  5809. @$currency_5 = $arrayData['response']['listing'][0]['items'][0]['item'][5]['currency']; //cifrão
  5810. @$price_5 = $arrayData['response']['listing'][0]['items'][0]['item'][5]['price'];
  5811.  
  5812.  
  5813. // produtos 6
  5814. @$titulo_6 = utf8_decode($arrayData['response']['listing'][0]['items'][0]['item'][6]['title']);
  5815. @$imagem_6 = $arrayData['response']['listing'][0]['items'][0]['item'][6]['image_url'];
  5816. @$link_6 = $arrayData['response']['listing'][0]['items'][0]['item'][6]['link'];
  5817. @$link_6 = str_replace("XXX", $myidML, $link_6);
  5818. @$currency_6 = $arrayData['response']['listing'][0]['items'][0]['item'][6]['currency']; //cifrão
  5819. @$price_6 = $arrayData['response']['listing'][0]['items'][0]['item'][6]['price'];
  5820.  
  5821.  
  5822. @$tabela = "<!-- Anuncios relacionados xml  -->
  5823.     <div style=\" margin-top:10px; overflow:auto; \">
  5824.    <div id=\"BotourasInfo\" align=\"center\">Anuncios Relacionados</div>
  5825.        <div id=\"contornoDescricao\">
  5826.        <div id=\"textodescicao_integra\">
  5827.  
  5828. <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  5829.  <tr>
  5830.    <td width=\"34%\" valign=\"top\">
  5831.          <!-- prod 1 -->
  5832.          <div>
  5833. <div style=\"margin-right:5px; float:left\"><div class=\"SlotsFotoShow\" align=\"center\">
  5834. <a rel=\"nofollow\" href=\"$link_1\"><img src=\"$imagem_1\" alt=\"$titulo_1\" width=\"60\" border=\"0\" style=\"margin-top:5px;\" /></a></div>
  5835.             </div>
  5836.             <div style=\"margin-right:8px;\"><a href=\"$link_1;\" class=\"link_titulo_classi_2\">$titulo_1</a></div>
  5837.             <div class=\"PrecoPequeno2\" style=\"margin-top:5px; margin-right:8px;\">$currency_1 $price_1</div>
  5838.      </div>        </td>
  5839.    <td width=\"33%\" valign=\"top\">
  5840.  
  5841.  
  5842.          <!-- prod 2 -->
  5843.  
  5844.          <div>
  5845.  
  5846. <div style=\"margin-right:5px; float:left\"><div class=\"SlotsFotoShow\" align=\"center\">
  5847.  
  5848. <a rel=\"nofollow\" href=\"$link_2\"><img src=\"$imagem_2\" alt=\"$titulo_2\" width=\"60\" border=\"0\" style=\"margin-top:5px;\" /></a></div>
  5849.  
  5850.             </div>
  5851.  
  5852.             <div style=\"margin-right:8px;\"><a rel=\"nofollow\" href=\"$link_2\" class=\"link_titulo_classi_2\">$titulo_2</a></div>
  5853.  
  5854.            <div class=\"PrecoPequeno2\" style=\"margin-top:5px; margin-right:8px;\">$currency_2 $price_2</div>
  5855.  
  5856.      </div>        </td>
  5857.  
  5858.    <td width=\"33%\" valign=\"top\">
  5859.  
  5860.  
  5861.  
  5862.          <!-- prod 3 -->
  5863.  
  5864.          <div>
  5865.  
  5866. <div style=\"margin-right:5px; float:left\"><div class=\"SlotsFotoShow\" align=\"center\"><a rel=\"nofollow\" href=\"$link_3\"><img src=\"$imagem_3;\" alt=\"$titulo_3\" width=\"60\" border=\"0\" style=\"margin-top:5px;\" /></a></div>
  5867.  
  5868.             </div>
  5869.  
  5870.             <div style=\"margin-right:8px;\"><a rel=\"nofollow\" href=\"$link_3\" class=\"link_titulo_classi_2\">$titulo_3</a></div>
  5871.  
  5872.             <div class=\"PrecoPequeno2\" style=\"margin-top:5px; margin-right:8px;\">$currency_3 $price_3</div>
  5873.  
  5874.      </div>        </td>
  5875.  
  5876.  </tr>
  5877.  
  5878.  <tr >
  5879.  
  5880.    <td colspan=\"3\" valign=\"top\">    </td>
  5881.  
  5882. </tr>
  5883.  
  5884.  <tr>
  5885.  
  5886.    <td valign=\"top\"><!-- prod 4 -->
  5887.  
  5888.        <div style=\"margin-top: 10px;\">
  5889.  
  5890.          <div style=\"margin-right:5px; float:left\">
  5891.  
  5892.            <div class=\"SlotsFotoShow\" align=\"center\"> <a rel=\"nofollow\" href=\"$link_4\"><img src=\"$imagem_4\" alt=\"$titulo_4\" width=\"60\" border=\"0\" style=\"margin-top:5px;\" /></a></div>
  5893.  
  5894.          </div>
  5895.  
  5896.          <div style=\"margin-right:8px;\"><a rel=\"nofollow\" href=\"$link_4\" class=\"link_titulo_classi_2\">$titulo_4</a></div>
  5897.  
  5898.          <div class=\"PrecoPequeno2\" style=\"margin-top:5px; margin-right:8px;\">$currency_4 $price_4</div>
  5899.  
  5900.        </div></td>
  5901.  
  5902.    <td valign=\"top\">
  5903.  
  5904.  
  5905.  
  5906.    <!-- prod 5 -->
  5907.  
  5908.         <div style=\"margin-top: 10px;\">
  5909.  
  5910.          <div style=\"margin-right:5px; float:left\">
  5911.  
  5912.            <div class=\"SlotsFotoShow\" align=\"center\"> <a rel=\"nofollow\" href=\"$link_5\"><img src=\"$imagem_5\" alt=\"$titulo_5\" width=\"60\" border=\"0\" style=\"margin-top:5px;\" /></a></div>
  5913.  
  5914.          </div>
  5915.  
  5916.          <div style=\"margin-right:8px;\"><a rel=\"nofollow\" href=\"$link_5\" class=\"link_titulo_classi_2\">$titulo_5</a></div>
  5917.  
  5918.          <div class=\"PrecoPequeno2\" style=\"margin-top:5px; margin-right:8px;\">$currency_5 $price_5</div>
  5919.  
  5920.        </div></td>
  5921.  
  5922.    <td valign=\"top\">
  5923.  
  5924.    <!-- prod 6 -->
  5925.  
  5926.         <div style=\"margin-top: 10px;\">
  5927.  
  5928.          <div style=\"margin-right:5px; float:left\">
  5929.  
  5930.            <div class=\"SlotsFotoShow\" align=\"center\"> <a rel=\"nofollow\" href=\"$link_6\"><img src=\"$imagem_6\" alt=\"$titulo_6\" width=\"60\" border=\"0\" style=\"margin-top:5px;\" /></a></div>
  5931.  
  5932.          </div>
  5933.  
  5934.          <div style=\"margin-right:8px;\"><a rel=\"nofollow\" href=\"$link_6\" class=\"link_titulo_classi_2\">$titulo_6</a></div>
  5935.  
  5936.           <div class=\"PrecoPequeno2\" style=\"margin-top:5px; margin-right:8px;\">$currency_6 $price_6</div>
  5937.  
  5938.        </div></td>
  5939.  
  5940.  </tr>
  5941.  
  5942.  <tr>
  5943.  
  5944.    <td colspan=\"3\" valign=\"top\">&nbsp;</td>
  5945.  
  5946.  </tr>
  5947.  
  5948.  <tr>
  5949.  
  5950.    <td colspan=\"3\" valign=\"top\"><span style=\"margin-top:10px;\">
  5951.  
  5952.  
  5953.  
  5954.      <!--  <a href=\"/\" >Veja mais anuncios relacionados</a> --></span></td>
  5955.  
  5956.  </tr>
  5957.  
  5958. </table>
  5959.  
  5960.  
  5961.  
  5962.        </div>
  5963.  
  5964.        </div>
  5965.  
  5966.        </div>
  5967.  
  5968. <!-- Anuncios relacionados -->";
  5969.  
  5970.  
  5971.  
  5972.  
  5973.  
  5974.  
  5975.  
  5976. return $tabela;
  5977.  
  5978. }
  5979.  
  5980.  
  5981.  
  5982.  
  5983.  
  5984.  
  5985.  
  5986. //-----------------------------------------------------------------------\\
  5987.  
  5988. //  CriaSelectHtml($nomeCampo,$tabela,$valorSelecionado)                 \\
  5989.  
  5990. //  DESC:   Retorna preenchido o campo select do html                    \\
  5991.  
  5992. //                                                                       \\
  5993.  
  5994. //  $nomeCampo - Nome do campo                                           \\
  5995.  
  5996. //  $tabela - Nome da tabela                                             \\
  5997.  
  5998. //  $valorSelecionado - Valor selecionado                                \\
  5999.  
  6000. //                                                                       \\
  6001.  
  6002. //                                                                       \\
  6003.  
  6004. //  OBS: OS campos $campoSelecionado e $valorSelecionado                 \\
  6005.  
  6006. //  não são obrigatório                                                  \\
  6007.  
  6008. //-----------------------------------------------------------------------\\
  6009.  
  6010. function CriaSelectHtml($nomeCampo,$tabela,$valorSelecionado) {
  6011.  
  6012.  
  6013.  
  6014.    $sql = "SELECT ID,$nomeCampo FROM $tabela ORDER BY $nomeCampo ASC";
  6015.  
  6016.    $qry = mysql_query($sql) or die(mysql_error());
  6017.  
  6018.    $row = mysql_fetch_assoc($qry);
  6019.  
  6020.  
  6021.  
  6022.  
  6023.  
  6024.  
  6025.  
  6026.     do {
  6027.  
  6028.         if (!(strcmp($row['ID'], htmlentities($valorSelecionado)))) {$selected = 'selected';}else{$selected = '';}
  6029.  
  6030.             @$option .= "<option value=\"$row[ID]\" $selected > $row[$nomeCampo]</option>";
  6031.  
  6032.     }
  6033.  
  6034.     while ( $row = mysql_fetch_assoc($qry));
  6035.  
  6036.  
  6037.  
  6038.     echo $option;
  6039.  
  6040.  
  6041.  
  6042. } // Fim function
  6043.  
  6044.  
  6045.  
  6046.  
  6047.  
  6048. //-----------------------------------------------------------------------\\
  6049.  
  6050. //  CriaSelectHtml($nomeCampo,$tabela,$valorSelecionado)                 \\
  6051.  
  6052. //  DESC:   Retorna preenchido o campo select do html                    \\
  6053.  
  6054. //                                                                       \\
  6055.  
  6056. //  $nomeCampo - Nome do campo                                           \\
  6057.  
  6058. //  $tabela - Nome da tabela                                             \\
  6059.  
  6060. //  $valorSelecionado - Valor selecionado                                \\
  6061.  
  6062. //                                                                       \\
  6063.  
  6064. //                                                                       \\
  6065.  
  6066. //  OBS: OS campos $campoSelecionado e $valorSelecionado                 \\
  6067.  
  6068. //  não são obrigatório                                                  \\
  6069.  
  6070. //-----------------------------------------------------------------------\\
  6071.  
  6072. function CriaSelectHtmlCidade($nomeCampo,$tabela,$valorSelecionado,$valorSelecionadoEstado) {
  6073.  
  6074.  
  6075.  
  6076.    $sql = "SELECT ID,$nomeCampo FROM $tabela where fk_estado=$valorSelecionadoEstado ORDER BY $nomeCampo ASC";
  6077.  
  6078.    $qry = mysql_query($sql) or die(mysql_error());
  6079.  
  6080.    $row = mysql_fetch_assoc($qry);
  6081.  
  6082.  
  6083.  
  6084.  
  6085.  
  6086.  
  6087.  
  6088.     do {
  6089.  
  6090.         if (!(strcmp($row['ID'], htmlentities($valorSelecionado)))) {$selected = 'selected';}else{$selected = '';}
  6091.  
  6092.             @$option .= "<option value=\"$row[ID]\" $selected > $row[$nomeCampo]</option>";
  6093.  
  6094.     }
  6095.  
  6096.     while ( $row = mysql_fetch_assoc($qry));
  6097.  
  6098.  
  6099.  
  6100.     echo $option;
  6101.  
  6102.  
  6103.  
  6104. } // Fim function
  6105.  
  6106.  
  6107.  
  6108.  
  6109.  
  6110. //---------------------------------------------------------------------------\\
  6111.  
  6112. //                                                                           \\
  6113.  
  6114. //  Retorna o nome do estado                                                 \\
  6115.  
  6116. //                                                                           \\
  6117.  
  6118. //---------------------------------------------------------------------------\\
  6119.  
  6120. function DevolveNomeEstado($codest) {
  6121.  
  6122.  
  6123.  
  6124.     $sql = "SELECT ID FROM estados WHERE ID='$codest'";
  6125.  
  6126.     $sql = mysql_query($sql);
  6127.  
  6128.     $total = mysql_num_rows($sql);
  6129.  
  6130.    
  6131.  
  6132.     if($total == 0){
  6133.  
  6134.         $resposta = 0;
  6135.  
  6136.     }else{
  6137.  
  6138.         $resposta = 1;
  6139.  
  6140.     }
  6141.  
  6142.     return $resposta;
  6143.  
  6144.  
  6145.  
  6146. }
  6147.  
  6148.  
  6149.  
  6150.  
  6151.  
  6152. /*
  6153.  
  6154. * Funcao para marcar o anuncio como noindex
  6155.  
  6156. */
  6157.  
  6158. function MarcaAnuncioNoindex($fk_anuncio){
  6159.  
  6160.  
  6161.  
  6162.     global $db;
  6163.  
  6164.     $up = "UPDATE anuncio SET robotsnoindex='s' WHERE ID='$fk_anuncio'";
  6165.  
  6166.     $up_query = mysql_db_query($db['db'],$up); 
  6167.  
  6168.    
  6169.  
  6170.  
  6171.  
  6172. }
  6173.  
  6174.  
  6175.  
  6176.  
  6177.  
  6178. /*
  6179.  
  6180. * Funcao para verificar url da lista
  6181.  
  6182. */
  6183.  
  6184. //---------------------------------------------------------------------------\\
  6185.  
  6186. //  Função ShowLinkNav($codest,$codcid,$codcat1,$codcat2,$codcat3)           \\
  6187.  
  6188. //  Desc: Mostra os links de navegação:  Brasil - Veículos - venda           \\
  6189.  
  6190. //                                                                           \\
  6191.  
  6192. //---------------------------------------------------------------------------\\
  6193.  
  6194. function ShowLinkNav2($codest,$codcid,$codcat1,$codcat2,$codcat3) {
  6195.  
  6196.  
  6197.  
  6198.     /* Estado */
  6199.  
  6200.     if($codest == ''){
  6201.  
  6202.         $link = "<a href=\"/\" class=\"link_titulo_classi_2\">Brasil</a>";
  6203.  
  6204.     }else{
  6205.  
  6206.         $sqlEstado = "SELECT nome_inteiro FROM estados WHERE ID=$codest";
  6207.  
  6208.         $sqlEstado = mysql_query($sqlEstado);
  6209.  
  6210.         $nomeEstado = mysql_result($sqlEstado,0,'nome_inteiro');
  6211.  
  6212.  
  6213.  
  6214.          @$nomeEstado = NomeEstado($codest);
  6215.  
  6216.         if($nomeEstado){
  6217.  
  6218.             $nomeEstado = $nomeEstado;
  6219.  
  6220.         }else{
  6221.  
  6222.             $nomeEstado = 'Brasil';
  6223.  
  6224.         }
  6225.  
  6226.  
  6227.  
  6228.         $completaURL2 = StringUrlAmigavel("$nomeEstado");
  6229.  
  6230.         $completaURL2 = $completaURL2."-$codest.htm";
  6231.  
  6232.         $completaURL2 = str_replace("--", "-", $completaURL2);
  6233.  
  6234.  
  6235.  
  6236.         $link = "<a href=\"/\" class=\"link_titulo_classi_2\">Brasil</a>";
  6237.  
  6238.  
  6239.  
  6240.  
  6241.  
  6242.  
  6243.  
  6244.  
  6245.  
  6246.         $link = $completaURL2;
  6247.  
  6248.         //$link = "<a href=\"index.php?codest=$codest\" class=\"link_titulo_classi_2\">$nomeEstado</a>";
  6249.  
  6250.     }
  6251.  
  6252.  
  6253.  
  6254.     /* Cidade */
  6255.  
  6256.     if($codcid != ''){
  6257.  
  6258.  
  6259.  
  6260.         $sqlCidade = "SELECT nome FROM cidades WHERE ID=$codcid";
  6261.  
  6262.         $sqlCidade = mysql_query($sqlCidade);
  6263.  
  6264.         $nomeCidade = mysql_result($sqlCidade,0,'nome');
  6265.  
  6266.  
  6267.  
  6268.         @$nomeEstado = NomeEstado($codest);
  6269.  
  6270.         if($nomeEstado){
  6271.  
  6272.             $nomeEstado = $nomeEstado;
  6273.  
  6274.         }else{
  6275.  
  6276.             $nomeEstado = 'Brasil';
  6277.  
  6278.         }
  6279.  
  6280.  
  6281.  
  6282.         @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
  6283.  
  6284.         @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
  6285.  
  6286.         @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
  6287.  
  6288.  
  6289.  
  6290.         $completaURL3 = StringUrlAmigavel("$nomecat1 $nomecat2 $nomecat3 $nomeEstado");
  6291.  
  6292.         $completaURL3 =  $completaURL3."__$codest-$codcid-$codcat1-$codcat2-$codcat3.htm";
  6293.  
  6294.  
  6295.  
  6296.         $link = $completaURL3;
  6297.  
  6298.         //$link .= " - <a href=\"lista_anuncio.php?codest=$codest&codcid=$codcid&codcat=$codcat1&codcat2=$codcat2&codcat3=$codcat3&\" class=\"link_titulo_classi_2\">$nomeCidade</a>";
  6299.  
  6300.  
  6301.  
  6302.     }
  6303.  
  6304.  
  6305.  
  6306.  
  6307.  
  6308.     /* Categoria 1 */
  6309.  
  6310.     if(@$codcat1 != ''){
  6311.  
  6312.  
  6313.  
  6314.         @$sqlCat1 = "SELECT nome FROM categoria_mae WHERE ID=$codcat1";
  6315.  
  6316.         @$sqlCat1 = mysql_query($sqlCat1);
  6317.  
  6318.         @$nomeCat1 = mysql_result($sqlCat1,0,'nome');
  6319.  
  6320.  
  6321.  
  6322.  
  6323.  
  6324.         @$nomeEstado = NomeEstado($codest);
  6325.  
  6326.         if($nomeEstado){
  6327.  
  6328.             $nomeEstado = $nomeEstado;
  6329.  
  6330.         }else{
  6331.  
  6332.             $nomeEstado = 'Brasil';
  6333.  
  6334.         }
  6335.  
  6336.  
  6337.  
  6338.         @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
  6339.  
  6340.         @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
  6341.  
  6342.         @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
  6343.  
  6344.  
  6345.  
  6346.         $completaURL4 = StringUrlAmigavel("$nomecat1 $nomecat2 $nomecat3 $nomeEstado");
  6347.  
  6348.         $completaURL4 = str_replace("--", "-", $completaURL4);
  6349.  
  6350.         $completaURL4 = $completaURL4."__$codest-$codcid-$codcat1--.htm";
  6351.  
  6352.  
  6353.  
  6354.  
  6355.  
  6356.         $link = $completaURL4;
  6357.  
  6358.         //$link .= " - <a href=\"lista_anuncio.php?codest=$codest&codcid=$codcid&codcat1=$codcat1&codcat2=&codcat3=&\" class=\"link_titulo_classi_2\">$nomeCat1</a>";
  6359.  
  6360.  
  6361.  
  6362.     }
  6363.  
  6364.  
  6365.  
  6366.  
  6367.  
  6368.     /* Categoria 2 */
  6369.  
  6370.     if(@$codcat2 != ''){
  6371.  
  6372.  
  6373.  
  6374.         $sqlCat2 = "SELECT nome FROM sub_categoria WHERE ID=$codcat2";
  6375.  
  6376.         $sqlCat2 = mysql_query($sqlCat2);
  6377.  
  6378.         $nomeCat2 = mysql_result($sqlCat2,0,'nome');
  6379.  
  6380.  
  6381.  
  6382.         @$nomeEstado = NomeEstado($codest);
  6383.  
  6384.         if($nomeEstado){
  6385.  
  6386.             $nomeEstado = $nomeEstado;
  6387.  
  6388.         }else{
  6389.  
  6390.             $nomeEstado = 'Brasil';
  6391.  
  6392.         }
  6393.  
  6394.  
  6395.  
  6396.         @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
  6397.  
  6398.         @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
  6399.  
  6400.         @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
  6401.  
  6402.  
  6403.  
  6404.         $completaURL5 = StringUrlAmigavel("$nomecat1 $nomecat2 $nomecat3 $nomeEstado");
  6405.  
  6406.         $completaURL5 = str_replace("--", "-", $completaURL5);
  6407.  
  6408.         $completaURL5 = $completaURL5."__$codest-$codcid-$codcat1-$codcat2-.htm";
  6409.  
  6410.  
  6411.  
  6412.         $link = $completaURL5;
  6413.  
  6414.         //$link .= " - <a href=\"lista_anuncio.php?codest=$codest&codcid=$codcid&codcat1=$codcat1&codcat2=$codcat2&codcat3=&\" class=\"link_titulo_classi_2\">$nomeCat2</a>";
  6415.  
  6416.  
  6417.  
  6418.     }
  6419.  
  6420.  
  6421.  
  6422.  
  6423.  
  6424.     /* Categoria 3 */
  6425.  
  6426.     if(@$codcat3 != ''){
  6427.  
  6428.  
  6429.  
  6430.         @$sqlCat3 = "SELECT nome FROM sub_categoria_n_2 WHERE ID=$codcat3";
  6431.  
  6432.         @$sqlCat3 = mysql_query($sqlCat3);
  6433.  
  6434.         @$nomeCat3 = mysql_result($sqlCat3,0,'nome');
  6435.  
  6436.  
  6437.  
  6438.         @$nomeEstado = NomeEstado($codest);
  6439.  
  6440.         if($nomeEstado){
  6441.  
  6442.             $nomeEstado = $nomeEstado;
  6443.  
  6444.         }else{
  6445.  
  6446.             $nomeEstado = 'Brasil';
  6447.  
  6448.         }
  6449.  
  6450.  
  6451.  
  6452.         @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
  6453.  
  6454.         @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
  6455.  
  6456.         @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
  6457.  
  6458.  
  6459.  
  6460.         $completaURL6 = StringUrlAmigavel("$nomecat1 $nomecat2 $nomecat3 $nomeEstado");
  6461.  
  6462.         $completaURL6 = str_replace("--", "-", $completaURL6);
  6463.  
  6464.         $completaURL6 = $completaURL6."__$codest-$codcid-$codcat1-$codcat2-$codcat3.htm";
  6465.  
  6466.  
  6467.  
  6468.         $link = $completaURL6;
  6469.  
  6470.         //$link .= " - <a href=\"lista_anuncio.php?codest=$codest&codcid=$codcid&codcat1=$codcat1&codcat2=$codcat2&codcat3=$codcat3&\" class=\"link_titulo_classi_2\">$nomeCat3</a>";
  6471.  
  6472.  
  6473.  
  6474.     }
  6475.  
  6476.  
  6477.  
  6478.     return $link;
  6479.  
  6480. }
  6481.  
  6482. //---------------------------------------------------------------------------\\
  6483. //  Função para converter tudo para minusculo                                \\
  6484. //                                                                           \\
  6485. //---------------------------------------------------------------------------\\
  6486. function loCase($string){
  6487.     $string = strtolower($string);
  6488.     $string = str_replace("Â","â",$string);
  6489.     $string = str_replace("Á","á",$string);
  6490.     $string = str_replace("Ã","ã",$string);
  6491.     $string = str_replace("A","à",$string);
  6492.     $string = str_replace("Ê","ê",$string);
  6493.     $string = str_replace("É","é",$string);
  6494.     $string = str_replace("I","Î",$string);
  6495.     $string = str_replace("Í","í",$string);
  6496.     $string = str_replace("Ó","ó",$string);
  6497.     $string = str_replace("Õ","õ",$string);
  6498.     $string = str_replace("Ô","ô",$string);
  6499.     $string = str_replace("Ú","ú",$string);
  6500.     $string = str_replace("U","û",$string);
  6501.     $string = str_replace("Ç","ç",$string);
  6502.     return ($string);
  6503. }
  6504.  
  6505.  
  6506.  
  6507.  
  6508. //---------------------------------------------------------------------------\\
  6509. //  Função para gerar o xml do usuario                                       \\
  6510. //  $Vitrine = g OU p                                                        \\
  6511. //---------------------------------------------------------------------------\\
  6512. function CriaXmlUser($IDuser,$Vitrine){
  6513.        
  6514.         global $Path,$PathAbsoluto,$pasta_img; 
  6515.         $urlsite = $PathAbsoluto;
  6516.        
  6517.         $sqlAnuncio = "SELECT SQL_CACHE ID,titulo,uri,valor FROM anuncio WHERE fk_usuario='$IDuser' AND anuncio.statuss='Ativo' AND liberado='s' order by rand();";
  6518.         $sqlAnuncio = mysql_query($sqlAnuncio);
  6519.         $totalAnuncio = mysql_num_rows($sqlAnuncio);
  6520.        
  6521.  
  6522.         $ponteiro = fopen("$Path/xml_user/".$IDuser."_".$Vitrine.".xml","w");
  6523.        
  6524.         fwrite($ponteiro, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
  6525.         fwrite($ponteiro, "<images>\r\n");
  6526.        
  6527.         while ($rowAnuncio = mysql_fetch_array($sqlAnuncio)) {
  6528.            
  6529.  
  6530.                 /*
  6531.                 * Selecionando a imagem
  6532.                 */
  6533.                 if($Vitrine == 'g'){
  6534.                     $selectImg = 'imagem';
  6535.                 }else{
  6536.                     $selectImg = 'imagem_media';
  6537.                 }          
  6538.                
  6539.                 @$sqlImagem = "select SQL_CACHE $selectImg from imagens where fk_anuncio='$rowAnuncio[ID]' order by ID ASC limit 1";
  6540.                 @$sqlImagem = mysql_query($sqlImagem);
  6541.                 @$totalImagem = mysql_num_rows($sqlImagem);
  6542.                 @$nome_imagem = mysql_result($sqlImagem,0,$selectImg);
  6543.                
  6544.                 if($totalImagem > 0){
  6545.                     $img = $urlsite.'/'.$pasta_img.'/'.$nome_imagem;
  6546.                 }else{
  6547.                     $img = $urlsite.'/img/imagem_n_disponivel_02.gif';
  6548.                 }
  6549.            
  6550.            
  6551.            
  6552.             // Largura da imagem
  6553.             @$size = getimagesize($img);
  6554.             @$width = explode(" ",$size[3]);
  6555.             @$width = explode("width=\"",$width[0]);
  6556.             @$width = explode("\"",$width[1]);
  6557.             @$width_image = $width[0];
  6558.            
  6559.             $titulo = strtolower($rowAnuncio['titulo']);
  6560.             $link = $urlsite.'/'.$rowAnuncio['uri'];
  6561.             $titulo = utf8_encode($titulo);
  6562.             if($rowAnuncio['valor'] != '0.000'){
  6563.                 $valor = "R$ ".number_format ($rowAnuncio['valor'], 2, ',', '.');
  6564.             }else{
  6565.                 $valor = "0";
  6566.             }
  6567.                            
  6568.  
  6569.             $xml = "<pic>\r\n";
  6570.             $xml .= "<image>$img</image>\r\n";
  6571.             $xml .= "<caption>$titulo</caption>\r\n";
  6572.             $xml .= "<url>$link</url>\r\n";
  6573.             $xml .= "<delay>7000</delay>\r\n";
  6574.             $xml .= "<ID_usuario>$IDuser</ID_usuario>\r\n";
  6575.             $xml .= "<ID_anuncio>$rowAnuncio[ID]</ID_anuncio>\r\n";
  6576.             $xml .= "<valor>$valor</valor>\r\n";
  6577.             $xml .= "<width>$width_image</width>\r\n";                             
  6578.             $xml .= "</pic>\r\n";
  6579.            
  6580.             fwrite($ponteiro,$xml);
  6581.        
  6582.    
  6583.         }
  6584.                    
  6585.         fwrite($ponteiro,"</images>\r\n");
  6586.         fclose($ponteiro);
  6587. }
  6588.  
  6589. //---------------------------------------------------------------------------\\
  6590. //  Função para retornar a Longitude e Latitude do CEP                       \\
  6591. //  Retorna uma array [0] - Latitude                                         \\
  6592. //  Retorna uma array [1] - Longitude                                        \\
  6593. //  Retorna uma array [2] - Accuracy                                         \\
  6594. //---------------------------------------------------------------------------\\
  6595. function CepLocation($valor){
  6596.  
  6597.     ini_set("allow_url_fopen", 1);
  6598.     ini_set("allow_url_include", 1);
  6599.  
  6600.     if(!(strstr($valor, '-'))){
  6601.         $cep1 = substr($valor, 0, 5);
  6602.         $cep2 = substr($valor, -3);
  6603.         $valor = $cep1.'-'.$cep2;
  6604.     }
  6605.  
  6606.     $resultado = file_get_contents("http://maps.google.com/maps/geo?output=xml&q=$valor");
  6607.  
  6608.     $explodeAccuracy = explode('Accuracy="',$resultado);
  6609.     $explodeAccuracy1 = explode('"',$explodeAccuracy[1]);
  6610.  
  6611.     $explode = explode('<coordinates>',$resultado);
  6612.     $explode1 = explode('</coordinates>',$explode[1]);
  6613.     $geolocation = explode(',',$explode1[0]);
  6614.  
  6615.     $newcord = "$geolocation[0],$geolocation[1],$explodeAccuracy1[0]";
  6616.     $coordenadas = explode(',',$newcord);
  6617.     return $coordenadas;
  6618. }
  6619.  
  6620. //---------------------------------------------------------------------------\\
  6621. //  Função para remover acwentos                                             \\
  6622. //---------------------------------------------------------------------------\\
  6623.     function tiracento($texto){
  6624.         $trocarIsso = array('à','á','â','ã','ä','å','ç','è','é','ê','ë','ì','í','î','ï','ñ','ò','ó','ô','õ','ö','ù','ü','ú','ÿ','À','Á','Â','Ã','Ä','Å','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ñ','Ò','Ó','Ô','Õ','Ö','O','Ù','Ü','Ú','Ÿ',);
  6625.         $porIsso = array('a','a','a','a','a','a','c','e','e','e','e','i','i','i','i','n','o','o','o','o','o','u','u','u','y','A','A','A','A','A','A','C','E','E','E','E','I','I','I','I','N','O','O','O','O','O','0','U','U','U','Y',);
  6626.         $titletext = str_replace($trocarIsso, $porIsso, $texto);
  6627.         return $titletext;
  6628.     }
  6629.    
  6630.  
  6631. /*
  6632. *  Retorna o número máximo (para os diretórios)
  6633. */
  6634. function Verifica_Pasta_range ($numero){
  6635.     $x = 0;
  6636.     while ($x < $numero){
  6637.     $x = $x + 1000;
  6638.     }
  6639.     return $x;
  6640. }
  6641.  
  6642. //---------------------------------------------------------------------------\\
  6643. //  Função para remover cache                                                \\
  6644. //---------------------------------------------------------------------------\\
  6645.     function RemoveCache($IDads){
  6646.    
  6647.         global $Path;
  6648.        
  6649.         $nomeArq = $IDads.'.cache';
  6650.        
  6651.         $caminhoTotal = $Path.'/cache/ads/'.Verifica_Pasta_range ($IDads).'/'.$nomeArq;
  6652.        
  6653.         @unlink($caminhoTotal);
  6654.     }  
  6655.  
  6656. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement