Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //-----------------------------------------------------------------------\\
- // busca_cep($cep) \\
- // DESC: Busca cep retornando os valores da cidade e estado \\
- // \\
- // $resultado_busca = busca_cep('87040250'); \\
- // print_r($resultado_busca, true); \\
- // \\
- // echo $resultado_busca['cidade']; \\
- // \\
- //-----------------------------------------------------------------------\\
- function busca_cep($cep){
- ini_set("allow_url_fopen", 1);
- ini_set("allow_url_include", 1);
- $cep = $cep.'000';
- $resultado = @file_get_contents('http://republicavirtual.com.br/web_cep.php?cep='.urlencode($cep).'&formato=query_string');
- if(!$resultado){
- $resultado = "&resultado=0&resultado_txt=erro+ao+buscar+cep";
- }
- ini_set("allow_url_fopen", 0);
- ini_set("allow_url_include", 0);
- parse_str($resultado, $retorno);
- return $retorno;
- }
- //-----------------------------------------------------------------------\\
- // busca2_cep($cep) \\
- // Função que busca a cidade e o estado \\
- // http://comercio.locaweb.com.br/correios/calcula_sedex.asp \\
- // \\
- // $resultado_busca = busca_cep('87040250'); \\
- // print_r($resultado_busca, true); \\
- // \\
- // echo $resultado_busca['cidade']; \\
- // \\
- //$resultado = file_get_contents('http://republicavirtual.com.br/web_cep.php?cep='.urlencode($cep).'&formato=query_string');
- //$resultado = file_get_contents('http://viavirtual.com.br/webservicecep.php?cep='.$cep.'');
- //-----------------------------------------------------------------------\\
- function busca_cep2($cep){
- ini_set("allow_url_fopen", 1);
- ini_set("allow_url_include", 1);
- $cepOK = $cep.'000';
- $resultado = file_get_contents("http://comercio.locaweb.com.br/correios/calcula_sedex.asp?cepOrig=$cepOK&cepDest=$cepOK&pesoDeclarado=10&vlrDeclarado=40&metodo=leitura");
- $explode = explode('<br>',$resultado);
- if($explode[0] == 'OK'){
- $cidade = explode('Cidade: ',$explode[3]);
- $cidadeOK = $cidade[1];
- $estado = explode('UF: ',$explode[4]);
- $estadoOK = $estado[1];
- return "$cidadeOK|$estadoOK";
- }else{
- return 0;
- }
- ini_set("allow_url_fopen", 0);
- ini_set("allow_url_include", 0);
- //print_r($retorno);
- }
- function busca_cep3($cep){
- ini_set("allow_url_fopen", 1);
- ini_set("allow_url_include", 1);
- $cepOK = $cep;
- $resultado = file_get_contents("http://comercio.locaweb.com.br/correios/calcula_sedex.asp?cepOrig=$cepOK&cepDest=$cepOK&pesoDeclarado=10&vlrDeclarado=40&metodo=leitura");
- $explode = explode('<br>',$resultado);
- if($explode[0] == 'OK'){
- $cidade = explode('Cidade: ',$explode[3]);
- $cidadeOK = $cidade[1];
- $estado = explode('UF: ',$explode[4]);
- $estadoOK = $estado[1];
- return "$cidadeOK|$estadoOK";
- }else{
- return 0;
- }
- ini_set("allow_url_fopen", 0);
- ini_set("allow_url_include", 0);
- //print_r($retorno);
- }
- /*
- * Funcao para retornar o nome da cidade
- */
- function RetornaNomeCidade($codcid){
- $sqlCidade = "SELECT nome FROM cidades WHERE ID=$codcid";
- $sqlCidade = mysql_query($sqlCidade);
- $nomeCidade = mysql_result($sqlCidade,0,'nome');
- return $nomeCidade;
- }
- /*
- * Funcao para apaga o ultimo título duplicado do usuario
- */
- function ApagaTituloDuplicado($fk_usuario,$titulo){
- $sql = "SELECT ID FROM anuncio WHERE titulo='$titulo' AND fk_usuario='$fk_usuario' order by ID ASC";
- $sql = mysql_query($sql);
- while ($row = mysql_fetch_array($sql)) {
- ExcluiAnuncio($row['ID'],$fk_usuario,'Anúncio com título duplicado');
- }
- }
- /*
- * Funcao que retorna 's' ou 'n' para o campo robotsnoindex
- */
- function ReturnNoIndex($fk_usuario,$descricao){
- $sql = "SELECT ID FROM anuncio WHERE descricao='$descricao'";
- $sql = mysql_query($sql);
- $total = mysql_num_rows($sql);
- if($total > 0){
- $resposta = 's';
- }else{
- $resposta = 'n';
- }
- return $resposta;
- }
- /*
- * Funcao para adcionar a meta tag Noindex nos anúncios com descricao duplicada do mesmo anunciante
- */
- function NoIndex($fk_usuario,$descricao){
- global $db;
- $sql = "SELECT ID FROM anuncio WHERE descricao='$descricao' AND fk_usuario='$fk_usuario'";
- $sql = mysql_query($sql);
- $total = mysql_num_rows($sql);
- if($total > 0){
- $sql2 = "SELECT MIN(ID) FROM anuncio WHERE descricao='$descricao' AND fk_usuario='$fk_usuario'";
- $sql2 = mysql_query($sql2);
- $IDminimo = mysql_result($sql2,0);
- while ($row = mysql_fetch_array($sql)) {
- $up = "UPDATE anuncio SET robotsnoindex='s' WHERE fk_usuario=$fk_usuario AND ID=$row[ID]";
- $up_query = mysql_db_query($db['db'],$up);
- }
- $up = "UPDATE anuncio SET robotsnoindex='n' WHERE fk_usuario=$fk_usuario AND ID=$IDminimo";
- $up_query = mysql_db_query($db['db'],$up);
- }
- }
- /*
- * Funcao para estrair caracteres especiais das meta tags
- */
- function ClearTags($string){
- $filtro = array('/' => '', ' - ' => '', ' ' => '');
- $string = strTr($string, $filtro);
- $string = preg_replace('/\s/',' ',$string);
- $string = ereg_replace(' +', ' ', $string);
- //$string = preg_replace(' +', ' ', $string);
- $string = trim($string);
- $string = strtolower($string);
- return $string;
- }
- /* Funcoes para montar os menus da página inicial */
- function CriaMenu($valor,$estado,$cidade){
- $sql = "SELECT ID, nome, url FROM categoria_mae where ID = $valor";
- $sql = mysql_query($sql);
- //$total = mysql_num_rows($sql);// total de registros
- /* Exemplo 1 */
- $nome = mysql_result($sql,0,"nome");
- $urls = mysql_result($sql,0,"url");
- $IDmenu = mysql_result($sql,0,"ID");
- @$nomeEstado = NomeEstado($estado);
- if($nomeEstado){
- $nomeEstado = $nomeEstado;
- }else{
- $nomeEstado = 'Brasil';
- }
- //$completaURL1 = StringUrlAmigavel("$nome $nomeEstado");
- $nomeEstUrl = StringUrlAmigavel($nomeEstado);
- if($nomeEstUrl != 'brasil'){
- $estadoUrlShow1 = $nomeEstUrl.'-';
- }else{
- $estadoUrlShow1 = 'brasil';
- }
- $completaURL1 = $urls.'-'.$estadoUrlShow1."__$estado-$cidade-$IDmenu--.htm";
- if($valor == 8){
- $linkMenu = "<a href=\"$completaURL1\" class=\"menu_bot_amarelo\" onclick=\"
- Modalbox.show('confirm_age.php?url=$completaURL1', {beforeLoad: function() { Modalbox.deactivate(); },title: 'Info', width: 750, overlayClose:false, inactiveFade:false}); return false;
- \">$nome</a>";
- }else{
- $linkMenu = "<a href=\"$completaURL1\" class=\"menu_bot_amarelo\">$nome</a>";
- }
- echo "
- <div class=\"menu_amarelo\">
- <div style=\" padding-top:5px;\">
- <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"$nome\" /></div>
- <div style=\"margin-left:20px; margin-top:0px\">$linkMenu</div>
- </div>
- </div>";
- }
- /* Funcoes para montar os menus da página inicial */
- function CriaSubMenu($valor,$estado,$cidade){
- $sqlCategoria1 = "SELECT nome,url FROM categoria_mae WHERE ID=$valor";
- $sqlCategoria1 = mysql_query($sqlCategoria1);
- $categoria_mae = mysql_result($sqlCategoria1,0,"nome");
- $categoria_url = mysql_result($sqlCategoria1,0,"url");
- $sql = "SELECT ID, nome,url FROM sub_categoria where fk_categoria = $valor limit 18";
- $sql = mysql_query($sql);
- //$total = mysql_num_rows($sql);// total de registros
- @$nomeEstado = NomeEstado($estado);
- if($nomeEstado){
- $nomeEstado = $nomeEstado;
- }else{
- $nomeEstado = 'Brasil';
- }
- while ($row = mysql_fetch_array($sql)) { //retorna a lista
- $estadoURL1 = StringUrlAmigavel($nomeEstado);
- if($estadoURL1 != 'brasil'){
- $estadoUrlShow2 = $estadoURL1.'-';
- }else{
- $estadoUrlShow2 = 'brasil';
- }
- $completaURL1 = $categoria_url.'-'.$row['url'].'-'.$estadoUrlShow2."__$estado-$cidade-$valor-$row[ID]-.htm";
- if($valor == 8){
- 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=\"
- Modalbox.show('confirm_age.php?url=$completaURL1', {beforeLoad: function() { Modalbox.deactivate(); },title: 'Info', width: 750, overlayClose:false, inactiveFade:false}); return false;
- \">$row[nome]</a></div></div>";
- }else{
- 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>";
- }
- }
- }
- function CropTexto($integra,$n_caracter) {
- //-----------------------------------------------------------------------\\
- // CropTexto(string,number) \\
- // DESC: Esta função vai cortar a string e colocar ... caso o numero \\
- // for menor q o tamanho da string \\
- //-----------------------------------------------------------------------\\
- $corta_integra = substr($integra, 0, $n_caracter);
- $conta_integra = strlen($corta_integra);
- if($conta_integra >= $n_caracter){
- $textoCrop = $corta_integra."...";
- }else{
- $textoCrop = $corta_integra;
- }
- return $textoCrop;
- }
- function GetMidString($str,$iS,$iE) {
- //-----------------------------------------------------------------------\\
- // GetMidString(string $str, int $iS, int $iE) \\
- // DESC: Returns the portion of $str starting at $iS and ending at $iE \\
- //-----------------------------------------------------------------------\\
- return substr($str,$iS,$iE - $iS + 1);
- }
- function RemoveArrayElement($srcArray,$intEIndex) {
- //-----------------------------------------------------------------------\\
- // RemoveArrayElement(array $srcArray, int $intEIndex \\
- // DESC: Removes the item $intEIndex from $srcArray and changes \\
- // all the keys from it in order not to leave any blank items \\
- // and returns the resultant array. \\
- //-----------------------------------------------------------------------\\
- $retArray = array();
- for ($i=0;$i<$intEIndex;$i++) {
- $retArray[$i] = $srcArray[$i];
- }
- for ($i=$intEIndex+1;$i<count($srcArray);$i++) {
- $retArray[$i-1] = $srcArray[$i];
- }
- return $retArray;
- }
- function ClearBlankElements($arr) {
- //-----------------------------------------------------------------------\\
- // ClearBlankElements(array $arr) \\
- // DESC: Searches $arr for blank items (including items containing \\
- // only a white space) and removes them using the \\
- // RemoveArrayElement function. Also trims the item value. \\
- //-----------------------------------------------------------------------\\
- $thearr = array();
- foreach ($arr as $val) {
- if ($val != "" && $val != " ") {
- array_push($thearr,trim($val));
- }
- }
- return $thearr;
- }
- function CreateWordList($strQuery) {
- //-----------------------------------------------------------------------\\
- // CreateWordList(string $strQuery) \\
- // DESC: Returns a array containing the words the user wants to search \\
- // for, including boolean keywords and literal phrases. \\
- // This means, the array returned by this function may contain \\
- // only a keyword (AND,OR,NOT or similars) or contain more than \\
- // one word. This is necessary for proper work of the ParseQuery \\
- // function. \\
- //-----------------------------------------------------------------------\\
- $q = $strQuery;
- $q = stripslashes($q);
- $QueryLength = strlen($strQuery);
- for ($i=0;$i<$QueryLength-1;$i++) {
- if ($i >= strlen($q)) {
- break;
- }
- if ($q{$i} == " ") {
- $q{$i} = chr(0);
- }
- if ($q{$i} == '"') {
- $q{$i} = chr(0);
- $nextQuote = ($i!=$QueryLength) ? strpos($q,'"',$i+1) : $QueryLength;
- if ($nextQuote !== false) {
- $q{$nextQuote} = chr(0);
- }
- if ($nextQuote != $QueryLength - 1) {
- $i = $nextQuote+1;
- }
- }
- }
- if ($q{0} == chr(0)) {
- $q = GetMidString($q,1,strlen($q));
- }
- $theArray = explode(chr(0),$q);
- $theArray = ClearBlankElements($theArray);
- return $theArray;
- }
- function ParseQuery($strDBField,$strQuery) {
- //-----------------------------------------------------------------------\\
- // ParseQuery(string $strDBField, string $strQuery) \\
- // DESC: Main function of the system. Returns a string containing \\
- // a valid mySQL clause to be appendded to a SELECT statement \\
- // using $strDBField as the column name to be searched in and \\
- // $strQuery (parsed) as the search arguments. \\
- //-----------------------------------------------------------------------\\
- $TempQuery = $strQuery;
- $FirstPart = "";
- $ANDPart = "";
- $NOTPart = "";
- $ORPart = "";
- //IF THERE IS NOTHING TO SEARCH, FUNCTION RETURNS FALSE
- if ($TempQuery == "") {
- return false;
- }
- //CONVERTS THE QUERY TO UPPERCASE
- $TempQuery = strtoupper($TempQuery);
- //CREATES THE ACRONYM LIST
- $arrAcronyms = array("-","||","&");
- $arrBase = array("NOT","OR","AND");
- $TempQuery = str_replace($arrAcronyms,$arrBase,$TempQuery);
- //TAKE OUT SQL KEYWORDS IN ORDER TO AVOID SQL INJECTION
- $arrForbiddenWords = array("INSERT","SELECT","UPDATE","DELETE","DROP","--","CREATE","UNION");
- $TempQuery = str_replace($arrForbiddenWords,"",$TempQuery);
- //FORBIDS QUERY TO HAVE TWO OR MORE ADJACENT SPACES
- $strPattern = "/(\s{2,})/";
- $TempQuery = preg_replace($strPattern," ",$TempQuery);
- //FORBIDS QUERY TO HAVE TAGS
- $TempQuery = str_replace(array("<",">"),"",$TempQuery);
- $ArrWords = CreateWordList($TempQuery);
- //CHECK THAT FIRST ITEM IS NOT A OPERATOR
- if ($ArrWords[0] == "AND" || $ArrWords[0] == "OR" || $ArrWords[0] == "NOT") {
- $ArrWords = RemoveArrayElement($ArrWords,0);
- }
- //CHECK FIRST KEYWORD
- if ($ArrWords[0] != "AND") {
- $FirstPart = $strDBField . " LIKE '%" . $ArrWords[0] . "%'";
- }
- //BULID AND PART
- for ($i=1;$i<=count($ArrWords)-1;$i++) {
- if (trim($ArrWords[$i]) == "AND") {
- if ($i != 0) {
- $ANDPart .= " AND " . $strDBField . " LIKE '%" . $ArrWords[$i+1] . "%'";
- $i++;
- }
- }
- else {
- if (trim($ArrWords[$i]) != "NOT" && trim($ArrWords[$i]) != "OR") {
- $ANDPart .= " AND " . $strDBField . " LIKE '%" . $ArrWords[$i] . "%'";
- }
- else {
- $i++;
- }
- }
- }
- //BULID OR PART
- for ($i=1;$i<=count($ArrWords)-1;$i++) {
- if (trim($ArrWords[$i]) == "OR") {
- if ($i != 0) {
- $ANDPart .= " OR " . $strDBField . " LIKE '%" . $ArrWords[$i+1] . "%'";
- $i++;
- }
- }
- }
- //BULID NOT PART
- for ($i=1;$i<=count($ArrWords)-1;$i++) {
- if (trim($ArrWords[$i]) == "NOT") {
- if ($i != 0) {
- $ANDPart .= " AND NOT (" . $strDBField . " LIKE '%" . $ArrWords[$i+1] . "%')";
- $i++;
- }
- }
- }
- $FinalQuery = $FirstPart . $ANDPart . $ORPart . $NOTPart;
- return $FinalQuery;
- }
- //-----------------------------------------------------------------------\\
- // masc_tel($TEL) \\
- // DESC: Esta função retorna o telefone no formato (44) 2222-2222 \\
- // \\
- //-----------------------------------------------------------------------\\
- function masc_tel($TEL) {
- $caract = array(".", "-", "(", ")", "/");
- $TEL = str_replace($caract, "", $TEL);
- $tam = strlen($TEL);
- // COM CÓDIGO DE ÁREA NACIONAL E DO PAIS
- if ($tam > 10) {
- return "+".substr($TEL,0,$tam-10)." (".substr($TEL,$tam-10,2).") ".substr($TEL,$tam-8,4)."-".substr($TEL,-4);
- }
- if ($tam == 10) {
- // COM CÓDIGO DE ÁREA NACIONAL
- return "(".substr($TEL,0,2).") ".substr($TEL,2,4)."-".substr($TEL,6,10);
- }
- if ($tam <= 8) {
- // SEM CÓDIGO DE ÁREA
- return substr($TEL,0,$tam-4)."-".substr($TEL,-4);
- }
- }
- //-----------------------------------------------------------------------\\
- // formataTel($valor) \\
- // DESC: Função para tirar todos os caracter e espaço do telefone \\
- // \\
- //-----------------------------------------------------------------------\\
- function TelOnlyNumber($valor)
- {
- $telefone = str_replace("(","",$valor);
- $telefone = str_replace(")","",$telefone);
- $telefone = str_replace("-","",$telefone);
- $telefone = str_replace(" ","",$telefone);
- return $telefone;
- }
- //-----------------------------------------------------------------------\\
- // formataTel($valor) \\
- // DESC: Função para validar E-mail \\
- // \\
- //-----------------------------------------------------------------------\\
- function verificar_email($email){
- $mail_correcto = 0;
- //verifico umas coisas
- if ((strlen($email) >= 6) && (substr_count($email,"@") == 1) && (substr($email,0,1) != "@") && (substr($email,strlen($email)-1,1) != "@")){
- if ((!strstr($email,"'")) && (!strstr($email,"\"")) && (!strstr($email,"\\")) && (!strstr($email,"\$")) && (!strstr($email," "))) {
- //vejo se tem caracter .
- if (substr_count($email,".")>= 1){
- //obtenho a terminação do dominio
- $term_dom = substr(strrchr ($email, '.'),1);
- //verifico que a terminação do dominio seja correcta
- if (strlen($term_dom)>1 && strlen($term_dom)<5 && (!strstr($term_dom,"@")) ){
- //verifico que o de antes do dominio seja correcto
- $antes_dom = substr($email,0,strlen($email) - strlen($term_dom) - 1);
- $caracter_ult = substr($antes_dom,strlen($antes_dom)-1,1);
- if ($caracter_ult != "@" && $caracter_ult != "."){
- $mail_correcto = 1;
- }
- }
- }
- }
- }
- if ($mail_correcto)
- return 1;
- else
- return 0;
- }
- //-----------------------------------------------------------------------\\
- // Função para deixar a data no formato \\
- // americano aonde o banco de dados usa o tipo date \\
- // \\
- //-----------------------------------------------------------------------\\
- function formataDataNasc($valor)
- {
- $data_nasc = explode("/",$valor);
- $data_nasc = "$data_nasc[2]-$data_nasc[1]-$data_nasc[0]";
- return $data_nasc;
- }
- //-----------------------------------------------------------------------\\
- // Função para formatar o CEP \\
- // 00000-000 \\
- // \\
- //-----------------------------------------------------------------------\\
- function masc_cep($valor)
- {
- $cep1 = substr($valor, 0, 5);
- $cep2 = substr($valor, 5);
- return $cep1."-".$cep2;
- }
- //-----------------------------------------------------------------------\\
- // cepOnlyNumber($valor) \\
- // DESC: Função para tirar todos os caracter e espaço do cep \\
- // \\
- //-----------------------------------------------------------------------\\
- function cepOnlyNumber($valor)
- {
- $cep = str_replace("-","",$valor);
- return $cep;
- }
- //-----------------------------------------------------------------------\\
- // Função para formatar o CPF \\
- // 000.000.000-00 \\
- // \\
- //-----------------------------------------------------------------------\\
- function masc_cpf($var)
- {
- $var = ereg_replace("[^0-9]", "", $var);
- $result = strlen($var);
- if($result == 14){
- $var = preg_replace("/([0-9]{2})[ \.-]?([0-9]{3})[ \.-]?([0-9]{3})[ \.\/-]?([0-9]{4})[ \.-]?([0-9]{2})/", "\\1.\\2.\\3/\\4-\\5", $var);
- }elseif($result == 11){
- $var = preg_replace("/([0-9]{3})[ \.-]?([0-9]{3})[ \.-]?([0-9]{3})[ \.\/-]?([0-9]{2})/", "\\1.\\2.\\3-\\4", $var);
- }
- return $var;
- }
- //-----------------------------------------------------------------------\\
- // formataTel($valor) \\
- // DESC: Função para tirar todos os caracter e espaço do CPD \\
- // \\
- //-----------------------------------------------------------------------\\
- function CpfOnlyNumber($valor)
- {
- $cpf = str_replace(".","",$valor);
- $cpf = str_replace("-","",$cpf);
- $cpf = str_replace(" ","",$cpf);
- return $cpf;
- }
- //-----------------------------------------------------------------------\\
- // getEnumValues($table, $field) \\
- // DESC: Função que retorna os campos ENUM de uma tabela mysql \\
- // \\
- //-----------------------------------------------------------------------\\
- function getEnumValues($table, $field) {
- $enum_array = array();
- $query = 'SHOW COLUMNS FROM `' . $table . '` LIKE "' . $field . '"';
- $result = mysql_query($query);
- $row = mysql_fetch_row($result);
- preg_match_all('/\'(.*?)\'/', $row[1], $enum_array);
- if(!empty($enum_array[1])) {
- // Shift array keys to match original enumerated index in MySQL (allows for use of index values instead of strings)
- foreach($enum_array[1] as $mkey => $mval) $enum_fields[$mkey+1] = $mval;
- return $enum_fields;
- }
- else return array(); // Return an empty array to avoid possible errors/warnings if array is passed to foreach() without first being checked with !empty().
- }
- //---------------------------------------------------------------------------\\
- // Função que coloca os valores de um campo ENUM dentro de um SELECT HTML \\
- // \\
- // \\
- //---------------------------------------------------------------------------\\
- function ShowCampoInSelect($tabela,$campo,$selecionado){
- $ArrayTipos = getEnumValues($tabela,$campo);
- $NumInt = count($ArrayTipos);
- $selected='';
- for ($i = 1; $i <= $NumInt; $i++) {
- if(@$selecionado){
- if($ArrayTipos[$i] == $selecionado){$selected='selected';}else{$selected='';}
- }
- echo "<option value=\"$ArrayTipos[$i]\"$selected>$ArrayTipos[$i]</option>";
- }
- }
- //-----------------------------------------------------------------------\\
- // realParaFloat ($str) \\
- // DESC: Transforma Reais em float \\
- // \\
- // OBS: O campo do banco de dados deveser do tipo float (10,3) \\
- //-----------------------------------------------------------------------\\
- function realParaFloat ($str) {
- if(strstr($str, ",")) {
- $str = str_replace(".", "", $str);
- $str = str_replace(",", ".", $str);
- }
- if (preg_match("#([0-9\.]+)#", $str, $match)) {
- return floatval($match[0]);
- }else{
- return floatval($str);
- }
- } // Fim function
- //-----------------------------------------------------------------------\\
- // SelectHtmlEstado ($str) \\
- // DESC: Retorna preenchido o campo select do html \\
- // \\
- // OBS: \\
- //-----------------------------------------------------------------------\\
- function SelectHtmlEstado($valor) {
- // Selecionando os estados
- $sql = "SELECT ID,sigla FROM estados ORDER BY sigla ASC";
- $qry = mysql_query($sql) or die(mysql_error());
- $row = mysql_fetch_assoc($qry);
- do {
- if (!(strcmp($row['ID'], htmlentities($valor)))) {$selected = 'selected';}else{$selected = "";}
- @$option .= "<option value=\"$row[ID]\" $selected > $row[sigla]</option>";
- }
- while ( $row = mysql_fetch_assoc($qry));
- return $option;
- } // Fim function
- //-----------------------------------------------------------------------\\
- // SelectHtmlTabela($tabela,$valor) \\
- // DESC: Retorna preenchido o campo select do html \\
- // \\
- // OBS: \\
- //-----------------------------------------------------------------------\\
- function SelectHtmlTabela($tabela,$valor) {
- // Selecionando os estados
- $sql = "SELECT ID,nome FROM $tabela ORDER BY nome ASC";
- $qry = mysql_query($sql) or die(mysql_error());
- $row = mysql_fetch_assoc($qry);
- do {
- if (!(strcmp($row['ID'], htmlentities($valor)))) {$selected = 'selected';}else{$selected = "";}
- @$option .= "<option value=\"$row[ID]\" $selected > $row[nome]</option>";
- }
- while ( $row = mysql_fetch_assoc($qry));
- return $option;
- } // Fim function
- //-----------------------------------------------------------------------\\
- // SelectHtmlTabela2($tabela,$valor) \\
- // DESC: Retorna preenchido o campo select do html \\
- // \\
- // OBS: \\
- //-----------------------------------------------------------------------\\
- function SelectHtmlTabela2($tabela,$valor) {
- // Selecionando os estados
- $sql = "SELECT ID,nome,nome_inteiro FROM $tabela ORDER BY nome ASC";
- $qry = mysql_query($sql) or die(mysql_error());
- $row = mysql_fetch_assoc($qry);
- do {
- if (!(strcmp($row['ID'], htmlentities($valor)))) {$selected = 'selected';}else{$selected = "";}
- @$option .= "<option value=\"$row[ID]-$row[nome_inteiro]\" $selected > $row[nome]</option>";
- }
- while ( $row = mysql_fetch_assoc($qry));
- return $option;
- } // Fim function
- //-----------------------------------------------------------------------\\
- // SelectSubCat($tabela,$valor,$valorAnterior) \\
- // DESC: Retorna preenchido o campo select do html \\
- // \\
- // OBS: \\
- //-----------------------------------------------------------------------\\
- function SelectSubCat($tabela,$valor,$valorAnterior) {
- // Selecionando os estados
- $sql = "SELECT ID,nome FROM $tabela WHERE fk_categoria=$valorAnterior ORDER BY nome ASC";
- $qry = mysql_query($sql) or die(mysql_error());
- $row = mysql_fetch_assoc($qry);
- do {
- if (!(strcmp($row['ID'], htmlentities($valor)))) {$selected = 'selected';}else{$selected = "";}
- @$option .= "<option value=\"$row[ID]\" $selected > $row[nome]</option>";
- }
- while ( $row = mysql_fetch_assoc($qry));
- return $option;
- } // Fim function
- //-----------------------------------------------------------------------\\
- // SelectEspc($tabela,$valor,$valorAnterior) \\
- // DESC: Retorna preenchido o campo select do html \\
- // \\
- // OBS: \\
- //-----------------------------------------------------------------------\\
- function SelectEspc($tabela,$valor,$valorAnterior) {
- // Selecionando os estados
- $sql = "SELECT ID,nome FROM $tabela WHERE fK_sub_categoria=$valorAnterior ORDER BY nome ASC";
- $qry = mysql_query($sql) or die(mysql_error());
- $row = mysql_fetch_assoc($qry);
- do {
- if (!(strcmp($row['ID'], htmlentities($valor)))) {$selected = 'selected';}else{$selected = "";}
- @$option .= "<option value=\"$row[ID]\" $selected > $row[nome]</option>";
- }
- while ( $row = mysql_fetch_assoc($qry));
- return $option;
- } // Fim function
- //-----------------------------------------------------------------------\\
- // SelectHtmlTabela($tabela,$valor) \\
- // DESC: Retorna preenchido o campo select do html \\
- // \\
- // OBS: \\
- //-----------------------------------------------------------------------\\
- function SelectHtmlCidades($estado,$valor) {
- // Selecionando as cidades
- $sql = "SELECT ID,nome FROM cidades WHERE fk_estado=$estado ORDER BY nome ASC";
- $qry = mysql_query($sql) or die(mysql_error());
- $row = mysql_fetch_assoc($qry);
- do {
- if (!(strcmp($row['ID'], htmlentities($valor)))) {$selected = 'selected';}else{$selected = "";}
- @$option .= "<option value=\"$row[ID]\" $selected > $row[nome]</option>";
- }
- while ( $row = mysql_fetch_assoc($qry));
- return $option;
- } // Fim function
- //-----------------------------------------------------------------------\\
- // SelectCkeckAcessorio($tabela,$valor) \\
- // DESC: retorna chackbox \\
- // \\
- // OBS: \\
- //-----------------------------------------------------------------------\\
- function SelectCkeckAcessorio($tabela,$valor) {
- $sql = "SELECT ID,nome FROM $tabela ORDER BY nome ASC";
- $sql = mysql_query($sql);
- while ($row = mysql_fetch_array($sql)) {
- if($valor){
- $valorArray = explode(' ',$valor);
- if(in_array($row['ID'],$valorArray)){
- $cheked = 'checked=\"checked\"';
- }else{
- $cheked = '';
- }
- }else{
- $cheked = '';
- }
- echo "<div style=\" width:180px; float:left; margin-right:15px;\">
- <div style=\"float:left\"><input name=\"acessorio[]\" $cheked type=\"checkbox\" value=\"$row[ID]\" /></div>
- <div style=\"margin-top:5px;\">$row[nome]</div>
- </div>";
- }
- } // Fim function
- //-----------------------------------------------------------------------\\
- // SelectCkeckempIdiomas($tabela,$valor) \\
- // DESC: retorna chackbox \\
- // \\
- // OBS: \\
- //-----------------------------------------------------------------------\\
- function SelectCkeckempIdiomas($tabela,$valor) {
- $sql = "SELECT ID,nome FROM $tabela ORDER BY nome ASC";
- $sql = mysql_query($sql);
- while ($row = mysql_fetch_array($sql)) {
- if($valor){
- $valorArray = explode(' ',$valor);
- if(in_array($row['ID'],$valorArray)){
- $cheked = 'checked=\"checked\"';
- }else{
- $cheked = '';
- }
- }else{
- $cheked = '';
- }
- echo "<div style=\" width:180px; float:left; margin-right:15px;\">
- <div style=\"float:left\"><input name=\"idiomas[]\" $cheked type=\"checkbox\" value=\"$row[ID]\" /></div>
- <div style=\"margin-top:5px;\">$row[nome]</div>
- </div>";
- }
- } // Fim function
- //-----------------------------------------------------------------------\\
- // SelectCkeckEspImoves($tabela,$valor) \\
- // DESC: retorna chackbox \\
- // \\
- // OBS: \\
- //-----------------------------------------------------------------------\\
- function SelectCkeckEspImoves($tabela,$valor) {
- $sql = "SELECT ID,nome FROM $tabela ORDER BY nome ASC";
- $sql = mysql_query($sql);
- while ($row = mysql_fetch_array($sql)) {
- if($valor){
- $valorArray = explode(' ',$valor);
- if(in_array($row['ID'],$valorArray)){
- $cheked = 'checked=\"checked\"';
- }else{
- $cheked = '';
- }
- }else{
- $cheked = '';
- }
- echo "<div style=\" width:180px; float:left; margin-right:15px;\">
- <div style=\"float:left\"><input name=\"esp_imoves[]\" $cheked type=\"checkbox\" value=\"$row[ID]\" /></div>
- <div style=\"margin-top:5px;\">$row[nome]</div>
- </div>";
- }
- } // Fim function
- //---------------------------------------------------------------------------\\
- // Função que que envia a imagem para o servidor e \\
- // retorna o nome da imagem \\
- // \\
- // \\
- //---------------------------------------------------------------------------\\
- function criaFoto($file,$pasta,$larguraThumbs,$larguraFull,$larguraMedia){
- global $PathAbsoluto;
- global $Path;
- global $logoClassiaqui;
- $pastaLocal = $Path.'/'.$pasta;
- // O nome da foto é o timestamp do segundo em que o upload foi feito
- $finalNome = rand(0,1000);
- $nomefoto = time().$finalNome;
- // Define a largura ou a altura máxima
- $maxThumbs = $larguraThumbs;
- $maxFull = $larguraFull;
- $maxMedia = $larguraMedia;
- // Pega os dados da imagem
- $dados_imagem = getImageSize ($file['tmp_name']);
- if((($file['type']) != 'image/pjpeg')
- && (($file['type']) != 'image/jpeg')
- && (($file['type']) != 'image/jpg')
- && (($file['type']) != 'image/pjpg')
- && (($file['type']) != 'image/gif')
- && (($file['type']) != 'image/x-png')
- ) {
- echo "<SCRIPT LANGUAGE=\"JavaScript\">alert('Este arquivo não pode ser enviado.');</script>";
- echo "<SCRIPT LANGUAGE=\"JavaScript\"> history.go(-1) </script>;";
- exit;
- }
- // Se for uma imagem válida (gif, jpg, ou png)
- if ((($dados_imagem[2] == 1) || ($dados_imagem[2] == 2) || ($dados_imagem[2] == 3))){
- // Se a largura e a altura forem maiores que a largura máxima do thumbnail
- if ($dados_imagem[0] > $maxThumbs && $dados_imagem[1] > $maxThumbs){
- // Switch no tipo de imagem (gif, jpg ou png)
- switch ($dados_imagem[2]){
- case 1:
- $img_src = imageCreateFromGif ($file['tmp_name']);
- break;
- case 2:
- $img_src = imageCreateFromJpeg ($file['tmp_name']);
- break;
- case 3:
- $img_src = imageCreateFromPng ($file['tmp_name']);
- break;
- }
- //======================================
- // A largura é maior que a altura
- if ($dados_imagem[0] > $dados_imagem[1]){
- /* ######## Thumb ######## */
- // A largura vai ter como valor $maxThumbs. Define a nova altura abaixo
- $nova_altura = round (($maxThumbs * $dados_imagem[1]) / $dados_imagem[0]);
- // Cria a nova imagem do thumbnail
- $img_destino = imageCreateTrueColor ($maxThumbs, $nova_altura);
- // Copia a imagem
- imagecopyresampled ($img_destino, $img_src, 0, 0, 0, 0, $maxThumbs, $nova_altura, $dados_imagem[0], $dados_imagem[1]);
- /* ######## Media ######## */
- // A largura vai ter como valor $maxThumbs. Define a nova altura abaixo
- $nova_altura2 = round (($maxMedia * $dados_imagem[1]) / $dados_imagem[0]);
- // Cria a nova imagem do thumbnail
- $img_destino2 = imageCreateTrueColor ($maxMedia, $nova_altura2);
- // Copia a imagem
- imagecopyresampled ($img_destino, $img_src, 0, 0, 0, 0, $maxThumbs, $nova_altura, $dados_imagem[0], $dados_imagem[1]);
- // Copia a imagem
- imagecopyresampled ($img_destino2, $img_src, 0, 0, 0, 0, $maxMedia, $nova_altura2, $dados_imagem[0], $dados_imagem[1]);
- }
- //======================================
- // A alatura é maior do que a largura
- if ($dados_imagem[0] < $dados_imagem[1]){
- /* ######## Thumb ######## */
- // A altura vai ter como valor $maxThumbs. Define a nova largura abaixo
- $nova_largura = round (($maxThumbs * $dados_imagem[0]) / $dados_imagem[1]);
- // Cria a nova imagem do thumbnail
- $img_destino = imageCreateTrueColor ($nova_largura, $maxThumbs);
- // Copia a imagem
- imagecopyresampled ($img_destino, $img_src, 0, 0, 0, 0, $nova_largura, $maxThumbs, $dados_imagem[0], $dados_imagem[1]);
- /* ######## Media ######## */
- // A altura vai ter como valor $maxThumbs. Define a nova largura abaixo
- $nova_largura2 = round (($maxMedia * $dados_imagem[0]) / $dados_imagem[1]);
- // Cria a nova imagem do thumbnail
- $img_destino2 = imageCreateTrueColor ($nova_largura2, $maxMedia);
- // Copia a imagem
- imagecopyresampled ($img_destino2, $img_src, 0, 0, 0, 0, $nova_largura2, $maxMedia, $dados_imagem[0], $dados_imagem[1]);
- }
- //======================================
- // A alatura é igual a largura
- if ($dados_imagem[0] == $dados_imagem[1]){
- /* ######## Thumb ######## */
- // Cria a nova imagem do thumbnail
- $img_destino = imageCreateTrueColor ($maxThumbs, $maxThumbs);
- // Copia a imagem
- imagecopyresampled ($img_destino, $img_src, 0, 0, 0, 0, $maxThumbs, $maxThumbs, $dados_imagem[0], $dados_imagem[1]);
- /* ######## Media ######## */
- // Cria a nova imagem do thumbnail
- $img_destino2 = imageCreateTrueColor ($maxMedia, $maxMedia);
- // Copia a imagem
- imagecopyresampled ($img_destino2, $img_src, 0, 0, 0, 0, $maxMedia, $maxMedia, $dados_imagem[0], $dados_imagem[1]);
- }
- //======================================
- // A largura maior que o valor máximo difinido
- if($dados_imagem[0] > $larguraFull){
- // Define a altura da nova imagem
- $novaAltura = $dados_imagem[1] / $dados_imagem[0] * $larguraFull;
- // Cria a nova imagem
- $novaImagem = imageCreateTrueColor ($larguraFull, $novaAltura);
- // Copia a danada
- imageCopyResampled ($novaImagem,$img_src, 0, 0, 0, 0, $larguraFull, $novaAltura, $dados_imagem[0], $dados_imagem[1]);
- $larguraOK = $larguraFull;
- $AlturaOk = $novaAltura;
- }else {
- // Cria uma nova imagem maior com o mesmo tamanho da original
- $novaImagem = imageCreateTrueColor ($dados_imagem[0], $dados_imagem[1]);
- // Copia a imagem original
- imagecopyresampled ($novaImagem, $img_src, 0, 0, 0, 0, $dados_imagem[0], $dados_imagem[1], $dados_imagem[0], $dados_imagem[1]);
- $larguraOK = $dados_imagem[0];
- $AlturaOk = $dados_imagem[1];
- }
- //==================================================================
- // Copia a imagem do logotipo e cola na imagem maior, se ele existir
- if (is_file ($Path.'/'.$logoClassiaqui)){
- // Copia o logo
- $logo_src = imageCreateFromPng ($Path.'/'.$logoClassiaqui);
- // Pega os dados do logo (largura e altura)
- $dados_logo = getImageSize ($Path.'/'.$logoClassiaqui);
- // Define o X e Y para aonde o logo deve ser colado
- $x = ($larguraOK - $dados_logo[0]) - 5;
- $y = ($AlturaOk - $dados_logo[1]) - 5;
- // Cola o logo
- imagecopy ($novaImagem, $logo_src, $x, $y, 0, 0, $dados_logo[0], $dados_logo[1]);
- // Solta a imagem full
- imageJpeg ($novaImagem, $pastaLocal.'/'.$nomefoto.'.jpg');
- }
- // Solta o thumb
- imageJpeg ($img_destino, $pastaLocal.'/'.$nomefoto.'_thumb.jpg');
- // Solta a Media
- imageJpeg ($img_destino2, $pastaLocal.'/'.$nomefoto.'_media.jpg');
- }
- }
- return $nomefoto;
- } // Fim function
- //---------------------------------------------------------------------------\\
- // Função que verifica se o usuario é dono do anuncio \\
- // \\
- // \\
- //---------------------------------------------------------------------------\\
- function VerificaPropriedade($fk_anunio,$fk_usuario)
- {
- $sql = "SELECT ID FROM anuncio WHERE ID='$fk_anunio' AND fk_usuario='$fk_usuario'";
- $sql = mysql_query($sql);
- $total = mysql_num_rows($sql);
- return $total;
- }
- //---------------------------------------------------------------------------\\
- // Função que verifica se o usuario é dono da msag \\
- // \\
- // \\
- //---------------------------------------------------------------------------\\
- function VerificaPropriedadeMsg($fk_anunio,$fk_usuario)
- {
- $sql = "SELECT ID FROM anuncio_msg WHERE ID='$fk_anunio' AND fk_usuario='$fk_usuario'";
- $sql = mysql_query($sql);
- $total = mysql_num_rows($sql);
- return $total;
- }
- //---------------------------------------------------------------------------\\
- // Função converter_dataSQL($strData) \\
- // Desc: Cobverte as data para o formato americano 0000-00-00 \\
- // \\
- //---------------------------------------------------------------------------\\
- function converter_dataSQL($strData) {
- // Recebemos a data no formato: dd/mm/aaaa
- // Convertemos a data para o formato: aaaa-mm-dd
- $strDataFinal = implode('-', array_reverse(explode('/',$strData)));
- return $strDataFinal;
- }
- //---------------------------------------------------------------------------\\
- // Função RetornaOutrasInfo($tabela,$valor) \\
- // Desc: Retorna das tabelas as informacoes adcionais \\
- // \\
- //---------------------------------------------------------------------------\\
- function RetornaOutrasInfo($tabela,$valor,$label) {
- $sql = "SELECT nome FROM $tabela where ID='$valor'";
- $sql = mysql_query($sql);
- @$nome = mysql_result($sql,0,"nome");
- echo "<div style=\"margin-bottom:10px;\"><strong>$label:</strong> $nome</div>";
- }
- //---------------------------------------------------------------------------\\
- // Função RetornaOutrasInfo2($tabela,$valor) \\
- // Desc: Retorna varios campos \\
- // \\
- //---------------------------------------------------------------------------\\
- function RetornaOutrasInfo2($tabela,$valor,$label) {
- $exp_IdEmp = explode(" ", $valor);
- $exp_IdEmpPop = array_pop($exp_IdEmp); //retira o ultimo elemento da array
- for ($ilaco=0;$ilaco<count($exp_IdEmp);$ilaco++){
- $sql = "SELECT nome FROM $tabela where ID=$exp_IdEmp[$ilaco]";
- $sql = mysql_query($sql);
- @$nome .= mysql_result($sql,0,'nome').', ';
- }
- // Retira a ultima virgula di final da string
- $tamanho = strlen($nome);
- $nome = substr($nome, 0, $tamanho - 2);
- echo "<div style=\"margin-bottom:10px;\"><strong>$label: </strong>$nome</div>";
- }
- //---------------------------------------------------------------------------\\
- // Função ShowLinkNav($codest,$codcid,$codcat1,$codcat2,$codcat3) \\
- // Desc: Mostra os links de navegação: Brasil - Veículos - venda \\
- // \\
- //---------------------------------------------------------------------------\\
- function ShowLinkNav($codest,$codcid,$codcat1,$codcat2,$codcat3) {
- /* Estado */
- if($codest == ''){
- $link = "<a href=\"/\" class=\"link_titulo_classi_2\">Brasil</a>";
- }else{
- $sqlEstado = "SELECT nome_inteiro FROM estados WHERE ID=$codest";
- $sqlEstado = mysql_query($sqlEstado);
- $nomeEstado = mysql_result($sqlEstado,0,'nome_inteiro');
- @$nomeEstado = NomeEstado($codest);
- if($nomeEstado){
- $nomeEstado = $nomeEstado;
- }else{
- $nomeEstado = 'Brasil';
- }
- $completaURL2 = StringUrlAmigavel($nomeEstado);
- $completaURL2 = $completaURL2."-$codest.htm";
- $completaURL2 = str_replace("--", "-", $completaURL2);
- $link = "<a href=\"/\" class=\"link_titulo_classi_2\">Brasil</a>";
- $link .= " - <a href=\"$completaURL2\" class=\"link_titulo_classi_2\" rel=\"nofollow\">$nomeEstado</a>";
- }
- /* Cidade */
- if($codcid != ''){
- $sqlCidade = "SELECT ID,nome FROM cidades WHERE ID=$codcid";
- $sqlCidade = mysql_query($sqlCidade);
- $nomeCidade = mysql_result($sqlCidade,0,'nome');
- $IDCidade = mysql_result($sqlCidade,0,'ID');
- @$nomeEstado = NomeEstado($codest);
- if($nomeEstado){
- $nomeEstado = $nomeEstado;
- }else{
- $nomeEstado = 'Brasil';
- }
- @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
- @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
- @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
- $completaURL3 = StringUrlAmigavel($nomeCidade);
- $completaURL3 = $completaURL3."__$IDCidade.htm";
- $link .= " - <a href=\"$completaURL3\" rel=\"nofollow\" class=\"link_titulo_classi_2\">$nomeCidade</a>";
- }
- /* Categoria 1 */
- if(@$codcat1 != ''){
- @$sqlCat1 = "SELECT nome FROM categoria_mae WHERE ID=$codcat1";
- @$sqlCat1 = mysql_query($sqlCat1);
- @$nomeCat1 = mysql_result($sqlCat1,0,'nome');
- @$nomeEstado = NomeEstado($codest);
- if($nomeEstado){
- $nomeEstado = $nomeEstado;
- }else{
- $nomeEstado = 'Brasil';
- }
- @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
- @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
- @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
- //$completaURL4 = StringUrlAmigavel("$nomecat1 $nomeEstado");
- $completaURL4 = trim(StringUrlAmigavel($nomecat1));
- $nome_estadoUrl = trim(StringUrlAmigavel($nomeEstado));
- $completaURL4 = str_replace("--", "-", $completaURL4);
- $completaURL4 = $completaURL4.'-'.$nome_estadoUrl.'-'."__$codest-$codcid-$codcat1--.htm";
- $link .= " - <a href=\"$completaURL4\" rel=\"nofollow\" class=\"link_titulo_classi_2\">$nomeCat1</a>";
- }
- /* Categoria 2 */
- if(@$codcat2 != ''){
- $sqlCat2 = "SELECT nome FROM sub_categoria WHERE ID=$codcat2";
- $sqlCat2 = mysql_query($sqlCat2);
- $nomeCat2 = mysql_result($sqlCat2,0,'nome');
- @$nomeEstado = NomeEstado($codest);
- if($nomeEstado){
- $nomeEstado = $nomeEstado;
- }else{
- $nomeEstado = 'Brasil';
- }
- @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
- @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
- @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
- //$completaURL5 = StringUrlAmigavel("$nomecat1 $nomecat2 $nomeEstado");
- $completaURL5 = StringUrlAmigavel($nomecat1);
- $nomecatURL5 = StringUrlAmigavel($nomecat2);
- $nomeEstado2URL5 = StringUrlAmigavel($nomeEstado);
- $completaURL5 = str_replace("--", "-", $completaURL5);
- $completaURL5 = $completaURL5.'-'.$nomecatURL5.'-'.$nomeEstado2URL5.'-'."__$codest-$codcid-$codcat1-$codcat2-.htm";
- $link .= " - <a href=\"$completaURL5\" rel=\"nofollow\" class=\"link_titulo_classi_2\">$nomeCat2</a>";
- }
- /* Categoria 3 */
- if(@$codcat3 != ''){
- @$sqlCat3 = "SELECT nome FROM sub_categoria_n_2 WHERE ID=$codcat3";
- @$sqlCat3 = mysql_query($sqlCat3);
- @$nomeCat3 = mysql_result($sqlCat3,0,'nome');
- @$nomeEstado = NomeEstado($codest);
- if($nomeEstado){
- $nomeEstado = $nomeEstado;
- }else{
- $nomeEstado = 'Brasil';
- }
- @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
- @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
- @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
- //$completaURL6 = StringUrlAmigavel("$nomecat1 $nomecat2 $nomecat3 $nomeEstado");
- $completaURL6 = StringUrlAmigavel($nomecat1);
- $nomecat2URL6 = StringUrlAmigavel($nomecat2);
- $nomecat3URL6 = StringUrlAmigavel($nomecat3);
- $nomeEstado2URL6 = StringUrlAmigavel($nomeEstado);
- $completaURL6 = str_replace("--", "-", $completaURL6);
- $completaURL6 = $completaURL6.'-'.$nomecat2URL6.'-'.$nomecat3URL6.'-'.$nomeEstado2URL6.'-'."__$codest-$codcid-$codcat1-$codcat2-$codcat3.htm";
- $link .= " - <a href=\"$completaURL6\" rel=\"nofollow\" class=\"link_titulo_classi_2\">$nomeCat3</a>";
- }
- echo $link;
- }
- //---------------------------------------------------------------------------\\
- // Função RefinaBusca($codcat2,$codcat3) \\
- // Desc: mostra elementos para refinas a busca \\
- // conforme a subcategoria e a categoria \\
- // \\
- //---------------------------------------------------------------------------\\
- function RefinaBusca($codcat1,$codcat2,$codcat3) {
- // Veiculos - carro caminhoes e onibus novos e seminovos
- if(
- (($codcat2 == 5) AND ($codcat3 == 30)) OR
- (($codcat2 == 6) AND ($codcat3 == 34)) OR
- (($codcat2 == 5) AND ($codcat3 == 31)) OR
- (($codcat2 == 6) AND ($codcat3 == 35)) OR
- (($codcat2 == 5) AND ($codcat3 == 32)) OR
- (($codcat2 == 6) AND ($codcat3 == 36))
- ){
- $sqlAcess = "SELECT ID,nome FROM auto_acessorio";
- $sqlAcess = mysql_query($sqlAcess);
- echo "
- <script>
- function BuscaAvancada(valor){
- if(valor == 'none'){
- document.getElementById('dv_avancada').style.display='block';
- document.getElementById('mostra_inner').innerHTML='Busca Simples';
- document.form_refina_busca.reset();
- }else{
- document.getElementById('dv_avancada').style.display='none';
- document.getElementById('mostra_inner').innerHTML='Busca Avançada';
- document.form_refina_busca.reset();
- }
- }
- </script>
- <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"Busca Simples\"/></div>
- <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>";
- /* Busca avançada */
- echo "<div id=\"dv_avancada\" style=\"display:block\" >";
- /* Faixa de Preço */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Faixa de preço</span></div>
- <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Mínimo R\$</span></div>
- <div style=\"margin-top:0px; margin-left:6px;\">
- <input name=\"preco_minimo\" type=\"text\" class=\"form\" id=\"preco_minimo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
- </div>
- <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Máximo R\$</span></div>
- <div style=\"margin-top:0px; margin-left:6px;\">
- <input name=\"preco_maximo\" type=\"text\" class=\"form\" id=\"preco_maximo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
- </div>
- <hr class=\"estiloHr\">
- ";
- /* Acessórios */
- echo "
- <!-- acessorios -->
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Acessórios</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">";
- while ($rowAcess = mysql_fetch_array($sqlAcess)) {
- $nomeAcessorio = CropTexto($rowAcess['nome'],19);
- echo "
- <div class=\"menu_bot_links\" style=\"margin-top:3px;\">
- <div style=\" padding-left:0px; padding-top:2px;\" >
- <div style=\"float:left; margin-top:3px;\"><input name=\"veiculos_acessorios[]\" type=\"checkbox\" value=\"$rowAcess[ID]\" /></div>
- <div style=\"margin-top:5px;\" class=\"texto_pequeno\">$nomeAcessorio</div>
- </div>
- </div>
- ";
- }
- echo "
- </div>
- <hr class=\"estiloHr\">";
- /* Cor do veículo */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Cor</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"auto_cor\" class=\"form\" id=\"auto_cor\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $cor = SelectHtmlTabela('auto_cor','');
- echo $cor;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* final da placa */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Final da placa</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"auto_final_placa\" class=\"form\" id=\"auto_final_placa\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $finalPlaca = SelectHtmlTabela('auto_final_placa','');
- echo $finalPlaca;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* Número de postas */
- if($codcat3 != 32){
- if($codcat3 != 36){
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Número de portas</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"auto_n_porta\" class=\"form\" id=\"auto_n_porta\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $n_porta = SelectHtmlTabela('auto_n_porta','');
- echo $n_porta;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- }
- }
- /* Fabricante */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Fabricante</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"auto_fabricante\" class=\"form\" id=\"auto_fabricante\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $fabricante = SelectHtmlTabela('auto_fabricante','');
- echo $fabricante;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* Ano */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Ano de fabricação</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"auto_ano_fab\" class=\"form\" id=\"auto_ano_fab\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $anofabri = SelectHtmlTabela('auto_ano_fab','');
- echo $anofabri;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* and busca avançada */
- echo "</div>";
- }
- // Veiculos - motos e seminovos
- if(
- (($codcat2 == 5) AND ($codcat3 == 33)) OR
- (($codcat2 == 6) AND ($codcat3 == 37))
- ){
- echo "
- <script>
- function BuscaAvancada(valor){
- if(valor == 'none'){
- document.getElementById('dv_avancada').style.display='block';
- document.getElementById('mostra_inner').innerHTML='Busca Simples';
- document.form_refina_busca.reset();
- }else{
- document.getElementById('dv_avancada').style.display='none';
- document.getElementById('mostra_inner').innerHTML='Busca Avançada';
- document.form_refina_busca.reset();
- }
- }
- </script>
- <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"Busca Simples\"/></div>
- <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>";
- /* Busca avançada */
- echo "<div id=\"dv_avancada\" style=\"display:block\" >";
- /* Faixa de Preço */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Faixa de preço</span></div>
- <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Mínimo R\$</span></div>
- <div style=\"margin-top:0px; margin-left:6px;\">
- <input name=\"preco_minimo\" type=\"text\" class=\"form\" id=\"preco_minimo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
- </div>
- <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Máximo R\$</span></div>
- <div style=\"margin-top:0px; margin-left:6px;\">
- <input name=\"preco_maximo\" type=\"text\" class=\"form\" id=\"preco_maximo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
- </div>
- <hr class=\"estiloHr\">
- ";
- /* Cor do veículo */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Cor</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"auto_cor\" class=\"form\" id=\"auto_cor\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $cor = SelectHtmlTabela('auto_cor','');
- echo $cor;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* final da placa */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Final da placa</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"auto_final_placa\" class=\"form\" id=\"auto_final_placa\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $finalPlaca = SelectHtmlTabela('auto_final_placa','');
- echo $finalPlaca;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* Ano */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Ano de fabricação</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"auto_ano_fab\" class=\"form\" id=\"auto_ano_fab\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $anofabri = SelectHtmlTabela('auto_ano_fab','');
- echo $anofabri;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* and busca avançada */
- echo "</div>";
- }
- // Imoveis Venda Aluguel Apartamento Casa
- if(
- (($codcat2 == 7) AND ($codcat3 == 96)) OR
- (($codcat2 == 8) AND ($codcat3 == 101)) OR
- (($codcat2 == 7) AND ($codcat3 == 97)) OR
- (($codcat2 == 8) AND ($codcat3 == 102)) OR
- (($codcat2 == 9) AND ($codcat3 == 99)) OR
- (($codcat2 == 8) AND ($codcat3 == 104))
- ){
- echo "
- <script>
- function BuscaAvancada(valor){
- if(valor == 'none'){
- document.getElementById('dv_avancada').style.display='block';
- document.getElementById('mostra_inner').innerHTML='Busca Simples';
- document.form_refina_busca.reset();
- }else{
- document.getElementById('dv_avancada').style.display='none';
- document.getElementById('mostra_inner').innerHTML='Busca Avançada';
- document.form_refina_busca.reset();
- }
- }
- </script>
- <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"Busca Simples\"/></div>
- <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>";
- /* Busca avançada */
- echo "<div id=\"dv_avancada\" style=\"display:block\" >";
- /* Faixa de Preço */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Faixa de preço</span></div>
- <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Mínimo R\$</span></div>
- <div style=\"margin-top:0px; margin-left:6px;\">
- <input name=\"preco_minimo\" type=\"text\" class=\"form\" id=\"preco_minimo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
- </div>
- <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Máximo R\$</span></div>
- <div style=\"margin-top:0px; margin-left:6px;\">
- <input name=\"preco_maximo\" type=\"text\" class=\"form\" id=\"preco_maximo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
- </div>
- <hr class=\"estiloHr\">
- ";
- /* àreea */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Área (m2)</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"imoveis_area\" class=\"form\" id=\"imoveis_area\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $area = SelectHtmlTabela('imoveis_area','');
- echo $area;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* Quartos */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Quartos</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"imoveis_quartos\" class=\"form\" id=\"imoveis_quartos\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $quartos = SelectHtmlTabela('imoveis_quartos','');
- echo $quartos;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* Suites */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Suítes</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"imoveis_suite\" class=\"form\" id=\"imoveis_suite\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $suites = SelectHtmlTabela('imoveis_suite','');
- echo $suites;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* vagas */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Vagas</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"imoveis_vagas\" class=\"form\" id=\"imoveis_vagas\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $vagas = SelectHtmlTabela('imoveis_vagas','');
- echo $vagas;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* and busca avançada */
- echo "</div>";
- }
- // Imoveis Venda Aluguel Salas Comerciais
- if(
- (($codcat2 == 7) AND ($codcat3 == 98)) OR
- (($codcat2 == 8) AND ($codcat3 == 103))
- ){
- echo "
- <script>
- function BuscaAvancada(valor){
- if(valor == 'none'){
- document.getElementById('dv_avancada').style.display='block';
- document.getElementById('mostra_inner').innerHTML='Busca Simples';
- document.form_refina_busca.reset();
- }else{
- document.getElementById('dv_avancada').style.display='none';
- document.getElementById('mostra_inner').innerHTML='Busca Avançada';
- document.form_refina_busca.reset();
- }
- }
- </script>
- <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"Busca Simples\"/></div>
- <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>";
- /* Busca avançada */
- echo "<div id=\"dv_avancada\" style=\"display:block\" >";
- /* Faixa de Preço */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Faixa de preço</span></div>
- <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Mínimo R\$</span></div>
- <div style=\"margin-top:0px; margin-left:6px;\">
- <input name=\"preco_minimo\" type=\"text\" class=\"form\" id=\"preco_minimo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
- </div>
- <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Máximo R\$</span></div>
- <div style=\"margin-top:0px; margin-left:6px;\">
- <input name=\"preco_maximo\" type=\"text\" class=\"form\" id=\"preco_maximo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
- </div>
- <hr class=\"estiloHr\">
- ";
- /* vagas */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Vagas</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"imoveis_vagas\" class=\"form\" id=\"imoveis_vagas\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $vagas = SelectHtmlTabela('imoveis_vagas','');
- echo $vagas;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* and busca avançada */
- echo "</div>";
- }
- // Imoveis Venda Aluguel Terrenos
- if(
- (($codcat2 == 7) AND ($codcat3 == 100)) OR
- (($codcat2 == 8) AND ($codcat3 == 105))
- ){
- echo "
- <script>
- function BuscaAvancada(valor){
- if(valor == 'none'){
- document.getElementById('dv_avancada').style.display='block';
- document.getElementById('mostra_inner').innerHTML='Busca Simples';
- document.form_refina_busca.reset();
- }else{
- document.getElementById('dv_avancada').style.display='none';
- document.getElementById('mostra_inner').innerHTML='Busca Avançada';
- document.form_refina_busca.reset();
- }
- }
- </script>
- <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"Busca Simples\"/></div>
- <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>";
- /* Busca avançada */
- echo "<div id=\"dv_avancada\" style=\"display:block\" >";
- /* Faixa de Preço */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Faixa de preço</span></div>
- <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Mínimo R\$</span></div>
- <div style=\"margin-top:0px; margin-left:6px;\">
- <input name=\"preco_minimo\" type=\"text\" class=\"form\" id=\"preco_minimo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
- </div>
- <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Máximo R\$</span></div>
- <div style=\"margin-top:0px; margin-left:6px;\">
- <input name=\"preco_maximo\" type=\"text\" class=\"form\" id=\"preco_maximo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
- </div>
- <hr class=\"estiloHr\">
- ";
- /* àreea */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Área (m2)</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"imoveis_area\" class=\"form\" id=\"imoveis_area\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $area = SelectHtmlTabela('imoveis_area','');
- echo $area;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* and busca avançada */
- echo "</div>";
- }
- // Produtos A venda
- if(
- (($codcat1 == 1) AND ($codcat2 == 1))
- ){
- echo "
- <script>
- function BuscaAvancada(valor){
- if(valor == 'none'){
- document.getElementById('dv_avancada').style.display='block';
- document.getElementById('mostra_inner').innerHTML='Busca Simples';
- document.form_refina_busca.reset();
- }else{
- document.getElementById('dv_avancada').style.display='none';
- document.getElementById('mostra_inner').innerHTML='Busca Avançada';
- document.form_refina_busca.reset();
- }
- }
- </script>
- <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"Busca Simples\"/></div>
- <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>";
- /* Busca avançada */
- echo "<div id=\"dv_avancada\" style=\"display:block\" >";
- /* Faixa de Preço */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Faixa de preço</span></div>
- <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Mínimo R\$</span></div>
- <div style=\"margin-top:0px; margin-left:6px;\">
- <input name=\"preco_minimo\" type=\"text\" class=\"form\" id=\"preco_minimo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
- </div>
- <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Máximo R\$</span></div>
- <div style=\"margin-top:0px; margin-left:6px;\">
- <input name=\"preco_maximo\" type=\"text\" class=\"form\" id=\"preco_maximo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
- </div>
- <hr class=\"estiloHr\">
- ";
- /* Produtos estado */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Estado do Produto</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"produtos_estado\" class=\"form\" id=\"produtos_estado\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $prod = SelectHtmlTabela('produtos_estado','');
- echo $prod;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* and busca avançada */
- echo "</div>";
- }
- // Produtos oferta de compra
- if(
- (($codcat1 == 1) AND ($codcat2 == 2))
- ){
- echo "
- <script>
- function BuscaAvancada(valor){
- if(valor == 'none'){
- document.getElementById('dv_avancada').style.display='block';
- document.getElementById('mostra_inner').innerHTML='Busca Simples';
- document.form_refina_busca.reset();
- }else{
- document.getElementById('dv_avancada').style.display='none';
- document.getElementById('mostra_inner').innerHTML='Busca Avançada';
- document.form_refina_busca.reset();
- }
- }
- </script>
- <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"Busca Simples\"/></div>
- <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>";
- /* Busca avançada */
- echo "<div id=\"dv_avancada\" style=\"display:block\" >";
- /* Faixa de Preço */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Faixa de preço</span></div>
- <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Mínimo R\$</span></div>
- <div style=\"margin-top:0px; margin-left:6px;\">
- <input name=\"preco_minimo\" type=\"text\" class=\"form\" id=\"preco_minimo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
- </div>
- <div style=\"margin-top:10px; margin-left:6px;\"><span class=\"texto_pequeno\">Preço Máximo R\$</span></div>
- <div style=\"margin-top:0px; margin-left:6px;\">
- <input name=\"preco_maximo\" type=\"text\" class=\"form\" id=\"preco_maximo\" onKeyPress=\"return(FormataReais(this,'.',',',event))\" size=\"18\" />
- </div>
- <hr class=\"estiloHr\">
- ";
- /* and busca avançada */
- echo "</div>";
- }
- // Produtos oferta de compra
- if(
- (($codcat1 == 5) AND ($codcat2 == 24))
- ){
- echo "
- <script>
- function BuscaAvancada(valor){
- if(valor == 'none'){
- document.getElementById('dv_avancada').style.display='block';
- document.getElementById('mostra_inner').innerHTML='Busca Simples';
- document.form_refina_busca.reset();
- }else{
- document.getElementById('dv_avancada').style.display='none';
- document.getElementById('mostra_inner').innerHTML='Busca Avançada';
- document.form_refina_busca.reset();
- }
- }
- </script>
- <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"Busca Simples\"/></div>
- <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>";
- /* Busca avançada */
- echo "<div id=\"dv_avancada\" style=\"display:block\" >";
- /* àreea de atuação */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Área de atuação</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"empregos_area_atuacao\" class=\"form\" style=\"width:145px;\" id=\"empregos_area_atuacao\">
- <option value=\"\">Indiferente</option>
- ";
- $areaAtuacao = SelectHtmlTabela('empregos_area_atuacao','');
- echo $areaAtuacao;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* grau escolaridade */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Grau de escolaridade</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"empregos_escolaridade\" class=\"form\" id=\"empregos_escolaridade\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $grauEscolaridade = SelectHtmlTabela('empregos_escolaridade','');
- echo $grauEscolaridade;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* perfil */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Perfil</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"empregos_perfil\" class=\"form\" id=\"empregos_perfil\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $perfil = SelectHtmlTabela('empregos_perfil','');
- echo $perfil;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* salário */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Salário</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"empregos_salario\" class=\"form\" id=\"empregos_salario\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $salario = SelectHtmlTabela('empregos_salario','');
- echo $salario;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- }
- // Produtos oferta de compra
- if(
- (($codcat1 == 5) AND ($codcat2 == 25)) OR
- (($codcat1 == 5) AND ($codcat2 == 27))
- ){
- echo "
- <script>
- function BuscaAvancada(valor){
- if(valor == 'none'){
- document.getElementById('dv_avancada').style.display='block';
- document.getElementById('mostra_inner').innerHTML='Busca Simples';
- document.form_refina_busca.reset();
- }else{
- document.getElementById('dv_avancada').style.display='none';
- document.getElementById('mostra_inner').innerHTML='Busca Avançada';
- document.form_refina_busca.reset();
- }
- }
- </script>
- <div style=\"float:left\"><img src=\"img/seta_bot_amarelo.gif\" alt=\"Busca Simples\"/></div>
- <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>";
- /* Busca avançada */
- echo "<div id=\"dv_avancada\" style=\"display:block\" >";
- /* àreea de atuação */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Área de atuação</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"empregos_area_atuacao\" class=\"form\" style=\"width:145px;\" id=\"empregos_area_atuacao\">
- <option value=\"\">Indiferente</option>
- ";
- $areaAtuacao = SelectHtmlTabela('empregos_area_atuacao','');
- echo $areaAtuacao;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* perfil */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Perfil</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"empregos_perfil\" class=\"form\" id=\"empregos_perfil\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $perfil = SelectHtmlTabela('empregos_perfil','');
- echo $perfil;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- /* salário */
- echo "
- <div style=\"margin-top:0px; margin-left:6px;\"><span class=\"menu_bot_semlink\">Salário</span></div>
- <div style=\"margin-top:5px; margin-left:6px;\">
- <select name=\"empregos_salario\" class=\"form\" id=\"empregos_salario\" style=\"width:145px;\">
- <option value=\"\">Indiferente</option>
- ";
- $salario = SelectHtmlTabela('empregos_salario','');
- echo $salario;
- echo "
- </select>
- </div>
- <hr class=\"estiloHr\">
- ";
- }
- }
- //---------------------------------------------------------------------------\\
- // Função Função para mostrar o tempo em dias que o anúncio tem para \\
- // expirar \\
- // \\
- //---------------------------------------------------------------------------\\
- function ContDowClassi($timeExpira){
- //$agoraH = (mktime() + 300);
- //echo $agoraH;
- if($timeExpira){
- if($timeExpira >= mktime()){
- $agora = mktime();
- $restante = ($timeExpira - $agora);
- //echo $restante;
- if($restante <= 86400){// se for maior que 1 Dia
- if($restante <= 3600){// se for menor que 1 Hora
- $minutos = round ($restante / 60);
- $dataExpira = "$minutos minutos";
- return $dataExpira;
- }else{
- $minutos = round ($restante / 3600);
- $dataExpira = "$minutos Horas";
- return $dataExpira;
- }
- }
- if($restante >= 86400){// se for maior que 1 Dia
- $minutos = round ($restante / 86400);
- $dataExpira = "$minutos dias";
- return $dataExpira;
- }
- }
- if($timeExpira <= mktime()){
- $dataExpira = "Apagar";
- return $dataExpira;
- }
- }else {
- $dataExpira = "Não expira";
- }
- }
- //---------------------------------------------------------------------------\\
- // Função Apaga anúncio ExcluiAnuncio($fk_anunio,$motivo,$fk_usuario) \\
- // obs: Apaga o anuncio e todas as duas dependecias. \\
- // A váriavel motovo, refere-se ao motivo da exclusão do anúncio \\
- // \\
- //---------------------------------------------------------------------------\\
- function ExcluiAnuncio($fk_anunio,$fk_usuario,$motivo){
- global $Path;
- global $pasta_img;
- $sql = mysql_query("
- SELECT
- anuncio.ID AS ID,
- anuncio.data_cad_timestamp AS data_cad_timestamp,
- anuncio.data_cad AS data_cad,
- anuncio.titulo AS titulo,
- anuncio.uri AS url,
- anuncio.ip_add AS ip_add,
- anuncio.ip_edit AS ip_edit,
- anuncio.site AS site,
- anuncio.telefone1 AS telefone1,
- anuncio.telefone2 AS telefone2,
- anuncio.fax AS fax,
- anuncio.email AS email,
- anuncio.nome AS nome,
- anuncio.fk_usuario AS fk_usuario,
- usuarios.email AS login,
- usuarios.shopping_user AS vitrine,
- usuarios.ip_log AS ip_last_log,
- usuarios.data_log AS data_last_log,
- cidades.nome AS cidade,
- estados.nome_inteiro AS estado
- FROM (anuncio
- LEFT JOIN usuarios ON anuncio.fk_usuario = anuncio.ID
- LEFT JOIN cidades ON anuncio.fk_cidade = cidades.ID
- LEFT JOIN estados ON anuncio.fk_estado = estados.ID
- )
- WHERE anuncio.ID = $fk_anunio");
- $row = mysql_fetch_assoc($sql);
- $tituloAnuncio = $row['titulo'];
- $urlAnuncio = $row['url'];
- $ip_add = $row['ip_add'];
- $ip_edit = $row['ip_edit'];
- $site = $row['site'];
- $telefone = $row['telefone1'].' - '.$row['telefone2'].' '.$row['fax'];
- $email = $row['email'];
- $nome = $row['nome'];
- $login = $row['login'];
- $vitrine = $row['vitrine'];
- $ip_last_log = $row['ip_last_log'];
- $data_last_log = $row['data_last_log'];
- $cidade = $row['cidade'];
- $estado = $row['estado'];
- $data_cad_timestamp = $row['data_cad_timestamp'];
- $data_cad = $row['data_cad'];
- /* Insere no banco de dados os dados do anúncio excluso */
- $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())");
- $total = mysql_num_rows($sql);
- if($total == 0){
- echo "<script language=\"JavaScript\">alert('Operação ilegal! Não existe nenhum anúncio com o código $fk_anunio')</script>";
- }else{
- /* Apaga as imagens */
- @$sqlImg = "SELECT ID,imagem,imagem_thumb,imagem_media FROM imagens WHERE fk_anuncio=$fk_anunio";
- @$sqlImg = mysql_query($sqlImg);
- while ($rowImg = mysql_fetch_array($sqlImg)) {
- @unlink($Path.'/'.$pasta_img.'/'.$rowImg['imagem']);
- @unlink($Path.'/'.$pasta_img.'/'.$rowImg['imagem_thumb']);
- @unlink($Path.'/'.$pasta_img.'/'.$rowImg['imagem_media']);
- }
- mysql_query("DELETE FROM anuncio_classifique WHERE fk_anuncio=$fk_anunio");
- mysql_query("DELETE FROM imagens WHERE fk_anuncio=$fk_anunio");
- //mysql_query("DELETE FROM anuncio_salvo WHERE fk_anuncio='$fk_anunio'");
- //mysql_query("DELETE FROM perguntas WHERE fk_anuncio='$fk_anunio'");
- mysql_query("DELETE FROM anuncio WHERE ID='$fk_anunio'");
- RemoveCache($fk_anunio);
- }
- //return $total;
- }
- //---------------------------------------------------------------------------\\
- // Função para retornar o nome do estado \\
- //---------------------------------------------------------------------------\\
- function NomeEstado($valor){
- $sql = "SELECT nome_inteiro FROM estados where ID=$valor";
- $sql = mysql_query($sql);
- @$nomeEstado = mysql_result($sql,0,"nome_inteiro");
- return $nomeEstado;
- }
- //---------------------------------------------------------------------------\\
- // Função para retornar o ID do estado \\
- //---------------------------------------------------------------------------\\
- function IDEstado($valor){
- $sql = "SELECT ID FROM estados where nome='$valor'";
- $sql = mysql_query($sql);
- @$IDEstado = mysql_result($sql,0,"ID");
- return $IDEstado;
- }
- //---------------------------------------------------------------------------\\
- // Função para remover acento \\
- //---------------------------------------------------------------------------\\
- function strSemAcentos($string="", $mesma=1)
- {
- $string = str_replace(" ", "-", $string);
- $string = strtolower($string);
- if($string != "")
- {
- $com_acento = "à á â ã ä è é ê ë ì í î ï ò ó ô õ ö ù ú û ü À Á Â Ã Ä È É Ê Ë Ì Í Î Ò Ó Ô Õ Ö Ù Ú Û Ü ç Ç ñ Ñ";
- $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";
- $c = explode(' ',$com_acento);
- $s = explode(' ',$sem_acento);
- $i=0;
- foreach($c as $letra)
- {
- if(ereg($letra, $string))
- {
- $pattern[] = $letra;
- $replacement[] = $s[$i];
- }
- $i=$i+1;
- }
- if(isset($pattern))
- {
- $i=0;
- foreach($pattern as $letra)
- {
- $string = eregi_replace($letra, $replacement[$i], $string);
- $i=$i+1;
- }
- return $string; # retorna string alterada
- }
- if ($mesma != 0)
- {
- return $string; # retorna a mesma string se nada mudou
- }
- }
- return ""; # sem mudança retorna nada
- }
- //---------------------------------------------------------------------------\\
- // Cria Meta Tags para o Google \\
- //---------------------------------------------------------------------------\\
- function MetaTagGoogle($codcat1,$codcat2,$codcat3)
- {
- if($codcat2 == ''){
- /* Verifica as subcategoria 1 */
- @$sqlSub1 = "SELECT ID,nome FROM sub_categoria WHERE fk_categoria=$codcat1";
- @$sqlSub1 = mysql_query($sqlSub1);
- @$totalSub1 = mysql_num_rows($sqlSub1);
- if($totalSub1 > 0){
- while (@$rowSub1 = mysql_fetch_array($sqlSub1)) {
- @$rowSub1_OK .= $rowSub1['nome'].' ';
- }
- return @$rowSub1_OK.',';
- }
- }else{
- /* Verifica as subcategoria 2 */
- @$sqlSub2 = "SELECT ID,nome FROM sub_categoria_n_2 WHERE fk_sub_categoria=$codcat2";
- @$sqlSub2 = mysql_query($sqlSub2);
- @$totalSub2 = mysql_num_rows($sqlSub2);
- if($totalSub2 > 0){
- while (@$rowSub2 = mysql_fetch_array($sqlSub2)) {
- @$rowSub2_OK .= $rowSub2['nome'].' ';
- }
- return @$rowSub2_OK.',';
- }
- }
- if($codcat3 == ''){
- /* Verifica as subcategoria 1 */
- @$sqlSub1 = "SELECT ID,nome FROM sub_categoria WHERE fk_categoria=$codcat1";
- @$sqlSub1 = mysql_query($sqlSub1);
- @$totalSub1 = mysql_num_rows($sqlSub1);
- if($totalSub1 > 0){
- while (@$rowSub1 = mysql_fetch_array($sqlSub1)) {
- @$rowSub1_OK .= $rowSub1['nome'].' ';
- }
- return @$rowSub1_OK.',';
- }
- }else{
- /* Verifica as subcategoria 1 */
- @$sqlSub3 = "SELECT ID,nome FROM sub_categoria_n_2 WHERE fk_categoria=$codcat3";
- @$sqlSub3 = mysql_query($sqlSub3);
- @$totalSub3 = mysql_num_rows($sqlSub3);
- if($totalSub3 > 0){
- while (@$rowSub3 = mysql_fetch_array($sqlSub3)) {
- @$rowSub3_OK .= $rowSub1['nome'].' ';
- }
- return @$rowSub3_OK.',';
- }
- }
- }
- //---------------------------------------------------------------------------\\
- // Verifica se o anúncio expirou e encia email ao usuario \\
- //---------------------------------------------------------------------------\\
- function AnuncioExpira()
- {
- $teste='teste';
- }
- /*
- function AnuncioExpira()
- {
- global $db;
- global $PathAbsoluto;
- global $smtp_Servers;
- global $smtp_Username;
- global $smtp_Passworde;
- global $smtp_From_Name;
- global $smtp_From_Mail;
- $mkTime = mktime();
- $sqlapaga = "SELECT ID,data_expira_timestamp,fk_usuario,titulo FROM anuncio WHERE ($mkTime > data_expira_timestamp) AND statuss='Ativo'";
- $sqlapaga = mysql_query($sqlapaga);
- if(mysql_num_rows($sqlapaga) != "0"){
- while($array_apaga = mysql_fetch_array($sqlapaga)) {
- // Pegando as informacoes do Usuario
- $sqlUser = "SELECT email FROM usuarios WHERE ID=$array_apaga[fk_usuario]";
- $sqlUser = mysql_query($sqlUser);
- // E-mail do usuario
- $email_user = mysql_result($sqlUser,0,'email');
- // Função que retorna o tempo de expiracao
- $tempoExpira = ContDowClassi($array_apaga['data_expira_timestamp']);
- if($tempoExpira == 'Apagar'){
- $mkTime24Horas = $mkTime+86400;
- // Setando como Inativo os anúncios expirados
- $up = "UPDATE anuncio SET expirado='s', statuss='Inativo', data_expira_timestamp=$mkTime24Horas WHERE ID=$array_apaga[ID]";
- $up_query = mysql_db_query($db['db'],$up);
- // Enviando email para o usuario
- if (!class_exists("phpmailer")) {
- require_once("include/phpmailer/class.phpmailer.php");
- }
- //require("include/phpmailer/class.phpmailer.php");
- $mail = new PHPMailer();
- $mail->IsSMTP();// send via SMTP
- $mail->Host = $smtp_Servers; // SMTP servers
- $mail->SMTPAuth = true; // turn on SMTP authentication
- $mail->Username = $smtp_Username; // SMTP username
- $mail->Password = $smtp_Passworde; // SMTP password
- $mail->FromName = $smtp_From_Name;
- $mail->From = $smtp_From_Mail;
- $mail->AddAddress($email_user,$email_user);
- //$mail->AddBCC("[email protected]");
- $mail->Subject = "Anúncio expirado";
- $mail->IsHTML(true); // send as HTML
- $mail->Body = "<style type=\"text/css\">
- <!--
- .style1 {
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 11px;
- color: #666666;
- }
- -->
- </style>
- <table width=\"578\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
- <tr>
- <td bgcolor=\"#FFCC00\"><img src=\"$PathAbsoluto/img/logo_email.jpg\" alt=\"ClassiAQUI!\" width=\"127\" height=\"39\" /></td>
- </tr>
- <tr>
- <td bgcolor=\"#666666\" style=\"height:5px;\"> </td>
- </tr>
- </table>
- <table width=\"578\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"border: 1px solid #CCCCCC;\">
- <tr>
- <td><div class=\"style1\" style=\"padding:8px;\">
- <p>Cara(o) Usuária(o),<br />
- <br />
- Gostaríamos de informar que o anúncio de título (<strong>$array_apaga[titulo]</strong>) expirou!<br /><br />
- Para reinserí-lo agora, <a href=\"$PathAbsoluto/expirados_logado.php\">CLIQUE AQUI</a><br /><br />
- Em 24 horas o anúncio será apagado do nosso banco de dados caso você não reinserí-lo.<br /><br />
- Obrigado por utilizar o ClassiAqui!<br>
- Atenciosamente<br />
- Equipe ClassiAqui!<br />
- <a href=\"$PathAbsoluto\">$PathAbsoluto</a></p><br />
- </div></td>
- </tr>
- </table>
- ";
- if(!($mail->Send())){
- echo "<script>alert('Erro ao enviar o e-mail')</script>";
- }
- }
- }//fim while
- }//fim if
- }
- */
- //---------------------------------------------------------------------------\\
- // Apaga os anuncios expirados \\
- //---------------------------------------------------------------------------\\
- function ApagaExpirados(){
- $teste = 'teste';
- }
- /*
- function ApagaExpirados(){
- $mkTime = mktime();
- $sqlapaga = "SELECT ID,data_expira_timestamp,fk_usuario,titulo FROM anuncio WHERE ($mkTime > data_expira_timestamp) AND statuss='Inativo' AND expirado='s'";
- $sqlapaga = mysql_query($sqlapaga);
- if(mysql_num_rows($sqlapaga) != "0"){
- while($array_apaga = mysql_fetch_array($sqlapaga)) {
- ExcluiAnuncio($array_apaga['ID'],$array_apaga['fk_usuario'],'Anúncio expirado');
- }
- }
- }
- */
- //---------------------------------------------------------------------------\\
- // String URL amigavel \\
- //---------------------------------------------------------------------------\\
- function StringUrlAmigavel($string)
- {
- $frase = $string;
- $frase = ereg_replace("[^a-zA-Z0-9_.]", "",
- //$frase = preg_replace("[^a-zA-Z0-9_.]", "",
- strtr($frase, "áàãâéêëíóôõúüçÁÀÃÂÉÊÍÓÔÕÚÜÇ ",
- "aaaaeeeiooouucaaaaeeiooouuc_"));
- $frase = str_replace("_", "-", $frase);
- $frase = strtolower($frase);
- $frase = str_replace(".", "-", $frase);
- $frase = str_replace("--", "-", $frase);
- $frase = str_replace("---", "-", $frase);
- $frase = str_replace("----", "-", $frase);
- $frase = str_replace("-----", "-", $frase);
- $frase = str_replace("------", "-", $frase);
- $frase = str_replace("-------", "-", $frase);
- $frase = str_replace("--------", "-", $frase);
- $frase = str_replace("---------", "-", $frase);
- $frase = str_replace("----------", "-", $frase);
- $frase = str_replace("-----------", "-", $frase);
- //return $frase;
- return $frase;
- }
- //---------------------------------------------------------------------------\\
- // Retorna o nome das Cat Sub \\
- //---------------------------------------------------------------------------\\
- function RetornaNomeCategoria($opt,$ID)
- {
- // Categoria Mãe
- if($opt == 1){
- $sql1 = "SELECT nome FROM categoria_mae WHERE ID=$ID";
- $sql1 = mysql_query($sql1);
- @$nome1 = mysql_result($sql1,0,"nome");
- return $nome1;
- }
- // Sub Categoria 1
- if($opt == 2){
- $sql2 = "SELECT nome FROM sub_categoria WHERE ID=$ID";
- $sql2 = mysql_query($sql2);
- @$nome2 = mysql_result($sql2,0,"nome");
- return $nome2;
- }
- // Sub Categoria 2
- if($opt == 3){
- $sql3 = "SELECT nome FROM sub_categoria_n_2 WHERE ID=$ID";
- $sql3 = mysql_query($sql3);
- @$nome3 = mysql_result($sql3,0,"nome");
- return $nome3;
- }
- }
- //---------------------------------------------------------------------------\\
- // Retorna o nome do usuario \\
- //---------------------------------------------------------------------------\\
- function RetornaNomeUsuario($fk_usuario)
- {
- $sql1 = "SELECT nome FROM usuarios WHERE ID=$fk_usuario";
- $sql1 = mysql_query($sql1);
- $nome1 = mysql_result($sql1,0,"nome");
- return $nome1;
- }
- //---------------------------------------------------------------------------\\
- // Checar se o usuario veio do Google \\
- //---------------------------------------------------------------------------\\
- function googleRef($ref)
- {
- //$ref = $_SERVER['HTTP_REFERER'];
- $teste = parse_url($ref);
- //print_r ($teste);
- $posGoogle = strpos($teste['host'],'google');
- $posYahoo = strpos($teste['host'],'yahoo');
- $posMywebsearch = strpos($teste['host'],'mywebsearch');
- if($posGoogle){
- //return $teste['query'];
- parse_str($teste['query']);
- return utf8_decode($q);
- }
- if($posYahoo){
- //return $teste['query'];
- parse_str($teste['query']);
- return utf8_decode($p);
- }
- if($posMywebsearch){
- //return $teste['query'];
- parse_str($teste['query']);
- return utf8_decode($searchfor);
- }
- }
- // Tira Acendo e espaço
- function geraUrlLimpa($texto){
- /* função que gera uma texto limpo pra virar URL:
- - limpa acentos e transforma em letra normal
- - limpa cedilha e transforma em c normal, o mesmo com o ñ
- - transforma espaços em hifen (-)
- - tira caracteres invalidos
- */
- //desconvertendo do padrão entitie (tipo á para á)
- $texto = html_entity_decode($texto);
- //tirando os acentos
- $texto = eregi_replace('[aáàãâä]','a',$texto);
- $texto = eregi_replace('[eéèêë]','e',$texto);
- $texto = eregi_replace('[iíìîï]','i',$texto);
- $texto = eregi_replace('[oóòõôö]','o',$texto);
- $texto = eregi_replace('[uúùûü]','u',$texto);
- $texto = eregi_replace('[ ]','',$texto);
- $texto = eregi_replace('[!@#$%¨&*())]','',$texto);
- //parte que tira o cedilha e o ñ
- $texto = eregi_replace('[ç]','c',$texto);
- $texto = eregi_replace('[ñ]','n',$texto);
- //trocando espaço em branco por underline
- //$texto = eregi_replace('( )','-',$texto);
- //tirando outros caracteres invalidos
- //$texto = eregi_replace('[^a-z0-9\-]','',$texto);
- //trocando duplo espaço (hifen) por 1 hifen só
- $texto = eregi_replace('--','',$texto);
- return strtolower($texto);
- }
- function convertStringByUrlString($String){
- $Separador = "";
- $String = trim($String); //Removendo espaços do inicio e do fim da string
- $String = strtolower($String); //Convertendo a string para minúsculas
- $String = strip_tags($String); //Retirando as tags HTML e PHP da string
- $String = eregi_replace("[[:space:]]", $Separador, $String); //Substituindo todos os espaços por $Separador
- $String = eregi_replace("[çÇ]", "c", $String); //Substituindo caracteres especiais pela letra respectiva
- $String = eregi_replace("[áÁäÄàÀãÃâÂ]", "a", $String);
- $String = eregi_replace("[éÉëËèÈêÊ]", "e", $String);
- $String = eregi_replace("[íÍïÏìÌîÎ]", "i", $String);
- $String = eregi_replace("[óÓöÖòÒõÕôÔ]", "o", $String);
- $String = eregi_replace("[úÚüÜùÙûÛ]", "u", $String);
- $String = eregi_replace("(\()|(\))", $Separador, $String); //Substituindo outros caracteres por "$Separador"
- $String = eregi_replace("(\/)|(\\\)", $Separador, $String);
- $String = eregi_replace("(\[)|(\])", $Separador, $String);
- $String = eregi_replace("[@#\$%&\*\+=\|º]", $Separador, $String);
- $String = eregi_replace("[;:'\"<>,\.?!_-]", $Separador, $String);
- $String = eregi_replace("[“”]", $Separador, $String);
- $String = eregi_replace("(ª)+", $Separador, $String);
- $String = eregi_replace("[`´~^°]", $Separador, $String);
- $String = eregi_replace("($Separador)+", $Separador, $String); //Removendo o excesso de "$Separador" por apenas um
- $String = eregi_replace("(^($Separador)+)|(($Separador)+$)", "", $String); //Removendo o "$Separador" do inicio e fim da string
- return $String;
- }
- /*
- * Funcção que verifica se é o googleboot que esta na página
- */
- function VerifyGoogleBoot($botip){
- //$botip = $_SERVER['REMOTE_ADDR'];
- $bothost = gethostbyaddr($botip);
- $verifiedbotip = gethostbyname($bothost);
- $boots = 0;
- if ($botip = $verifiedbotip) {
- if ( substr($bothost, -14) == '.googlebot.com') {
- $boots = 1;
- } elseif (substr( $bothost, -18) == '.inktomisearch.com') {
- $boots = 1;
- }
- }
- return $boots;
- }
- function MaisRelacionados($codcat1,$codcat2,$codcat3){
- /* Categoria 3 */
- if(@$codcat3 != ''){
- @$sqlCat3 = "SELECT nome FROM sub_categoria_n_2 WHERE ID=$codcat3";
- @$sqlCat3 = mysql_query($sqlCat3);
- @$nomeCat3 = mysql_result($sqlCat3,0,'nome');
- @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
- @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
- @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
- $completaURL6 = StringUrlAmigavel("$nomecat1 $nomecat2 $nomecat3");
- $completaURL6 = str_replace("--", "-", $completaURL6);
- $link = $completaURL6."__--$codcat1-$codcat2-$codcat3.htm";
- //$link .= " - <a href=\"$completaURL6\" class=\"link_titulo_classi_2\">$nomeCat3</a>";
- //$link .= " - <a href=\"lista_anuncio.php?codest=$codest&codcid=$codcid&codcat1=$codcat1&codcat2=$codcat2&codcat3=$codcat3&\" class=\"link_titulo_classi_2\">$nomeCat3</a>";
- }else{
- $sqlCat2 = "SELECT nome FROM sub_categoria WHERE ID=$codcat2";
- $sqlCat2 = mysql_query($sqlCat2);
- $nomeCat2 = mysql_result($sqlCat2,0,'nome');
- @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
- @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
- @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
- $completaURL5 = StringUrlAmigavel("$nomecat1 $nomecat2 $nomecat3");
- $completaURL5 = str_replace("--", "-", $completaURL5);
- $link = $completaURL5."__--$codcat1-$codcat2-.htm";
- //$link .= "<a href=\"$completaURL5\" class=\"link_titulo_classi_2\">$nomeCat2</a>";
- }
- return $link;
- }
- function TestaResultML($valor){
- require_once "class.xmltoarray.php";
- ini_set("allow_url_fopen", 1); //função habilitada
- @$xml_data = file_get_contents("http://www.mercadolivre.com.br/jm/searchXml?&as_word=OVO+DE+PASCOA+CASEIRO");
- //Creating Instance of the Class
- @$xmlObj = new XmlToArray($xml_data);
- //Creating Array
- @$arrayData = $xmlObj->createArray();
- //Creating Instance of the Class
- @$xmlObj = new XmlToArray($xml_data);
- //Creating Array
- @$arrayData = $xmlObj->createArray();
- @$totalArray = count($arrayData['response']['listing'][0]['items'][0]['item']);
- return $totalArray;
- }
- /*
- * Funcção que imprime os produtos do mercado livre
- */
- function GaleriaML($categoria,$tag_ml){
- require_once "class.xmltoarray.php";
- ini_set("allow_url_fopen", 1); //função habilitada
- if($tag_ml){
- $busca = $tag_ml;
- }else{
- $busca = $categoria;
- }
- //@$xml_data = file_get_contents("http://www.mercadolivre.com.br/jm/searchXml?&as_word=$valor&as_search_both=y");
- //@$xml_data = file_get_contents("http://www.mercadolivre.com.br/jm/searchXml?as_order_id=$sorteia[$sorteado]&as_categ_id=$valor&gzip=y");
- @$xml_data = file_get_contents("http://www.mercadolivre.com.br/jm/searchXml?as_word=$busca");
- //Creating Instance of the Class
- @$xmlObj = new XmlToArray($xml_data);
- //Creating Array
- @$arrayData = $xmlObj->createArray();
- @$totalArray = count($arrayData['response']['listing'][0]['items'][0]['item']);
- $myidML = '5272606';
- // produtos 1
- @$titulo_1 = utf8_decode($arrayData['response']['listing'][0]['items'][0]['item'][1]['title']);
- @$imagem_1 = $arrayData['response']['listing'][0]['items'][0]['item'][1]['image_url'];
- @$link_1 = $arrayData['response']['listing'][0]['items'][0]['item'][1]['link'];
- @$link_1 = str_replace("XXX", $myidML, $link_1);
- @$currency_1 = $arrayData['response']['listing'][0]['items'][0]['item'][1]['currency']; //cifrão
- @$price_1 = $arrayData['response']['listing'][0]['items'][0]['item'][1]['price'];
- // produtos 2
- @$titulo_2 = utf8_decode($arrayData['response']['listing'][0]['items'][0]['item'][2]['title']);
- @$imagem_2 = $arrayData['response']['listing'][0]['items'][0]['item'][2]['image_url'];
- @$link_2 = $arrayData['response']['listing'][0]['items'][0]['item'][2]['link'];
- @$link_2 = str_replace("XXX", $myidML, $link_2);
- @$currency_2 = $arrayData['response']['listing'][0]['items'][0]['item'][2]['currency']; //cifrão
- @$price_2 = $arrayData['response']['listing'][0]['items'][0]['item'][2]['price'];
- // produtos 3
- @$titulo_3 = utf8_decode($arrayData['response']['listing'][0]['items'][0]['item'][3]['title']);
- @$imagem_3 = $arrayData['response']['listing'][0]['items'][0]['item'][3]['image_url'];
- @$link_3 = $arrayData['response']['listing'][0]['items'][0]['item'][3]['link'];
- @$link_3 = str_replace("XXX", $myidML, $link_3);
- @$currency_3 = $arrayData['response']['listing'][0]['items'][0]['item'][3]['currency']; //cifrão
- @$price_3 = $arrayData['response']['listing'][0]['items'][0]['item'][3]['price'];
- // produtos 4
- @$titulo_4 = utf8_decode($arrayData['response']['listing'][0]['items'][0]['item'][4]['title']);
- @$imagem_4 = $arrayData['response']['listing'][0]['items'][0]['item'][4]['image_url'];
- @$link_4 = $arrayData['response']['listing'][0]['items'][0]['item'][4]['link'];
- @$link_4 = str_replace("XXX", $myidML, $link_4);
- @$currency_4 = $arrayData['response']['listing'][0]['items'][0]['item'][4]['currency']; //cifrão
- @$price_4 = $arrayData['response']['listing'][0]['items'][0]['item'][4]['price'];
- // produtos 5
- @$titulo_5 = utf8_decode($arrayData['response']['listing'][0]['items'][0]['item'][5]['title']);
- @$imagem_5 = $arrayData['response']['listing'][0]['items'][0]['item'][5]['image_url'];
- @$link_5 = $arrayData['response']['listing'][0]['items'][0]['item'][5]['link'];
- @$link_5 = str_replace("XXX", $myidML, $link_5);
- @$currency_5 = $arrayData['response']['listing'][0]['items'][0]['item'][5]['currency']; //cifrão
- @$price_5 = $arrayData['response']['listing'][0]['items'][0]['item'][5]['price'];
- // produtos 6
- @$titulo_6 = utf8_decode($arrayData['response']['listing'][0]['items'][0]['item'][6]['title']);
- @$imagem_6 = $arrayData['response']['listing'][0]['items'][0]['item'][6]['image_url'];
- @$link_6 = $arrayData['response']['listing'][0]['items'][0]['item'][6]['link'];
- @$link_6 = str_replace("XXX", $myidML, $link_6);
- @$currency_6 = $arrayData['response']['listing'][0]['items'][0]['item'][6]['currency']; //cifrão
- @$price_6 = $arrayData['response']['listing'][0]['items'][0]['item'][6]['price'];
- @$tabela = "<!-- Anuncios relacionados xml -->
- <div style=\" margin-top:10px; overflow:auto; \">
- <div id=\"BotourasInfo\" align=\"center\">Anuncios Relacionados</div>
- <div id=\"contornoDescricao\">
- <div id=\"textodescicao_integra\">
- <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
- <tr>
- <td width=\"34%\" valign=\"top\">
- <!-- prod 1 -->
- <div>
- <div style=\"margin-right:5px; float:left\"><div class=\"SlotsFotoShow\" align=\"center\">
- <a rel=\"nofollow\" href=\"$link_1\"><img src=\"$imagem_1\" alt=\"$titulo_1\" width=\"60\" border=\"0\" style=\"margin-top:5px;\" /></a></div>
- </div>
- <div style=\"margin-right:8px;\"><a href=\"$link_1;\" class=\"link_titulo_classi_2\">$titulo_1</a></div>
- <div class=\"PrecoPequeno2\" style=\"margin-top:5px; margin-right:8px;\">$currency_1 $price_1</div>
- </div> </td>
- <td width=\"33%\" valign=\"top\">
- <!-- prod 2 -->
- <div>
- <div style=\"margin-right:5px; float:left\"><div class=\"SlotsFotoShow\" align=\"center\">
- <a rel=\"nofollow\" href=\"$link_2\"><img src=\"$imagem_2\" alt=\"$titulo_2\" width=\"60\" border=\"0\" style=\"margin-top:5px;\" /></a></div>
- </div>
- <div style=\"margin-right:8px;\"><a rel=\"nofollow\" href=\"$link_2\" class=\"link_titulo_classi_2\">$titulo_2</a></div>
- <div class=\"PrecoPequeno2\" style=\"margin-top:5px; margin-right:8px;\">$currency_2 $price_2</div>
- </div> </td>
- <td width=\"33%\" valign=\"top\">
- <!-- prod 3 -->
- <div>
- <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>
- </div>
- <div style=\"margin-right:8px;\"><a rel=\"nofollow\" href=\"$link_3\" class=\"link_titulo_classi_2\">$titulo_3</a></div>
- <div class=\"PrecoPequeno2\" style=\"margin-top:5px; margin-right:8px;\">$currency_3 $price_3</div>
- </div> </td>
- </tr>
- <tr >
- <td colspan=\"3\" valign=\"top\"> </td>
- </tr>
- <tr>
- <td valign=\"top\"><!-- prod 4 -->
- <div style=\"margin-top: 10px;\">
- <div style=\"margin-right:5px; float:left\">
- <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>
- </div>
- <div style=\"margin-right:8px;\"><a rel=\"nofollow\" href=\"$link_4\" class=\"link_titulo_classi_2\">$titulo_4</a></div>
- <div class=\"PrecoPequeno2\" style=\"margin-top:5px; margin-right:8px;\">$currency_4 $price_4</div>
- </div></td>
- <td valign=\"top\">
- <!-- prod 5 -->
- <div style=\"margin-top: 10px;\">
- <div style=\"margin-right:5px; float:left\">
- <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>
- </div>
- <div style=\"margin-right:8px;\"><a rel=\"nofollow\" href=\"$link_5\" class=\"link_titulo_classi_2\">$titulo_5</a></div>
- <div class=\"PrecoPequeno2\" style=\"margin-top:5px; margin-right:8px;\">$currency_5 $price_5</div>
- </div></td>
- <td valign=\"top\">
- <!-- prod 6 -->
- <div style=\"margin-top: 10px;\">
- <div style=\"margin-right:5px; float:left\">
- <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>
- </div>
- <div style=\"margin-right:8px;\"><a rel=\"nofollow\" href=\"$link_6\" class=\"link_titulo_classi_2\">$titulo_6</a></div>
- <div class=\"PrecoPequeno2\" style=\"margin-top:5px; margin-right:8px;\">$currency_6 $price_6</div>
- </div></td>
- </tr>
- <tr>
- <td colspan=\"3\" valign=\"top\"> </td>
- </tr>
- <tr>
- <td colspan=\"3\" valign=\"top\"><span style=\"margin-top:10px;\">
- <!-- <a href=\"/\" >Veja mais anuncios relacionados</a> --></span></td>
- </tr>
- </table>
- </div>
- </div>
- </div>
- <!-- Anuncios relacionados -->";
- return $tabela;
- }
- //-----------------------------------------------------------------------\\
- // CriaSelectHtml($nomeCampo,$tabela,$valorSelecionado) \\
- // DESC: Retorna preenchido o campo select do html \\
- // \\
- // $nomeCampo - Nome do campo \\
- // $tabela - Nome da tabela \\
- // $valorSelecionado - Valor selecionado \\
- // \\
- // \\
- // OBS: OS campos $campoSelecionado e $valorSelecionado \\
- // não são obrigatório \\
- //-----------------------------------------------------------------------\\
- function CriaSelectHtml($nomeCampo,$tabela,$valorSelecionado) {
- $sql = "SELECT ID,$nomeCampo FROM $tabela ORDER BY $nomeCampo ASC";
- $qry = mysql_query($sql) or die(mysql_error());
- $row = mysql_fetch_assoc($qry);
- do {
- if (!(strcmp($row['ID'], htmlentities($valorSelecionado)))) {$selected = 'selected';}else{$selected = '';}
- @$option .= "<option value=\"$row[ID]\" $selected > $row[$nomeCampo]</option>";
- }
- while ( $row = mysql_fetch_assoc($qry));
- echo $option;
- } // Fim function
- //-----------------------------------------------------------------------\\
- // CriaSelectHtml($nomeCampo,$tabela,$valorSelecionado) \\
- // DESC: Retorna preenchido o campo select do html \\
- // \\
- // $nomeCampo - Nome do campo \\
- // $tabela - Nome da tabela \\
- // $valorSelecionado - Valor selecionado \\
- // \\
- // \\
- // OBS: OS campos $campoSelecionado e $valorSelecionado \\
- // não são obrigatório \\
- //-----------------------------------------------------------------------\\
- function CriaSelectHtmlCidade($nomeCampo,$tabela,$valorSelecionado,$valorSelecionadoEstado) {
- $sql = "SELECT ID,$nomeCampo FROM $tabela where fk_estado=$valorSelecionadoEstado ORDER BY $nomeCampo ASC";
- $qry = mysql_query($sql) or die(mysql_error());
- $row = mysql_fetch_assoc($qry);
- do {
- if (!(strcmp($row['ID'], htmlentities($valorSelecionado)))) {$selected = 'selected';}else{$selected = '';}
- @$option .= "<option value=\"$row[ID]\" $selected > $row[$nomeCampo]</option>";
- }
- while ( $row = mysql_fetch_assoc($qry));
- echo $option;
- } // Fim function
- //---------------------------------------------------------------------------\\
- // \\
- // Retorna o nome do estado \\
- // \\
- //---------------------------------------------------------------------------\\
- function DevolveNomeEstado($codest) {
- $sql = "SELECT ID FROM estados WHERE ID='$codest'";
- $sql = mysql_query($sql);
- $total = mysql_num_rows($sql);
- if($total == 0){
- $resposta = 0;
- }else{
- $resposta = 1;
- }
- return $resposta;
- }
- /*
- * Funcao para marcar o anuncio como noindex
- */
- function MarcaAnuncioNoindex($fk_anuncio){
- global $db;
- $up = "UPDATE anuncio SET robotsnoindex='s' WHERE ID='$fk_anuncio'";
- $up_query = mysql_db_query($db['db'],$up);
- }
- /*
- * Funcao para verificar url da lista
- */
- //---------------------------------------------------------------------------\\
- // Função ShowLinkNav($codest,$codcid,$codcat1,$codcat2,$codcat3) \\
- // Desc: Mostra os links de navegação: Brasil - Veículos - venda \\
- // \\
- //---------------------------------------------------------------------------\\
- function ShowLinkNav2($codest,$codcid,$codcat1,$codcat2,$codcat3) {
- /* Estado */
- if($codest == ''){
- $link = "<a href=\"/\" class=\"link_titulo_classi_2\">Brasil</a>";
- }else{
- $sqlEstado = "SELECT nome_inteiro FROM estados WHERE ID=$codest";
- $sqlEstado = mysql_query($sqlEstado);
- $nomeEstado = mysql_result($sqlEstado,0,'nome_inteiro');
- @$nomeEstado = NomeEstado($codest);
- if($nomeEstado){
- $nomeEstado = $nomeEstado;
- }else{
- $nomeEstado = 'Brasil';
- }
- $completaURL2 = StringUrlAmigavel("$nomeEstado");
- $completaURL2 = $completaURL2."-$codest.htm";
- $completaURL2 = str_replace("--", "-", $completaURL2);
- $link = "<a href=\"/\" class=\"link_titulo_classi_2\">Brasil</a>";
- $link = $completaURL2;
- //$link = "<a href=\"index.php?codest=$codest\" class=\"link_titulo_classi_2\">$nomeEstado</a>";
- }
- /* Cidade */
- if($codcid != ''){
- $sqlCidade = "SELECT nome FROM cidades WHERE ID=$codcid";
- $sqlCidade = mysql_query($sqlCidade);
- $nomeCidade = mysql_result($sqlCidade,0,'nome');
- @$nomeEstado = NomeEstado($codest);
- if($nomeEstado){
- $nomeEstado = $nomeEstado;
- }else{
- $nomeEstado = 'Brasil';
- }
- @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
- @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
- @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
- $completaURL3 = StringUrlAmigavel("$nomecat1 $nomecat2 $nomecat3 $nomeEstado");
- $completaURL3 = $completaURL3."__$codest-$codcid-$codcat1-$codcat2-$codcat3.htm";
- $link = $completaURL3;
- //$link .= " - <a href=\"lista_anuncio.php?codest=$codest&codcid=$codcid&codcat=$codcat1&codcat2=$codcat2&codcat3=$codcat3&\" class=\"link_titulo_classi_2\">$nomeCidade</a>";
- }
- /* Categoria 1 */
- if(@$codcat1 != ''){
- @$sqlCat1 = "SELECT nome FROM categoria_mae WHERE ID=$codcat1";
- @$sqlCat1 = mysql_query($sqlCat1);
- @$nomeCat1 = mysql_result($sqlCat1,0,'nome');
- @$nomeEstado = NomeEstado($codest);
- if($nomeEstado){
- $nomeEstado = $nomeEstado;
- }else{
- $nomeEstado = 'Brasil';
- }
- @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
- @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
- @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
- $completaURL4 = StringUrlAmigavel("$nomecat1 $nomecat2 $nomecat3 $nomeEstado");
- $completaURL4 = str_replace("--", "-", $completaURL4);
- $completaURL4 = $completaURL4."__$codest-$codcid-$codcat1--.htm";
- $link = $completaURL4;
- //$link .= " - <a href=\"lista_anuncio.php?codest=$codest&codcid=$codcid&codcat1=$codcat1&codcat2=&codcat3=&\" class=\"link_titulo_classi_2\">$nomeCat1</a>";
- }
- /* Categoria 2 */
- if(@$codcat2 != ''){
- $sqlCat2 = "SELECT nome FROM sub_categoria WHERE ID=$codcat2";
- $sqlCat2 = mysql_query($sqlCat2);
- $nomeCat2 = mysql_result($sqlCat2,0,'nome');
- @$nomeEstado = NomeEstado($codest);
- if($nomeEstado){
- $nomeEstado = $nomeEstado;
- }else{
- $nomeEstado = 'Brasil';
- }
- @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
- @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
- @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
- $completaURL5 = StringUrlAmigavel("$nomecat1 $nomecat2 $nomecat3 $nomeEstado");
- $completaURL5 = str_replace("--", "-", $completaURL5);
- $completaURL5 = $completaURL5."__$codest-$codcid-$codcat1-$codcat2-.htm";
- $link = $completaURL5;
- //$link .= " - <a href=\"lista_anuncio.php?codest=$codest&codcid=$codcid&codcat1=$codcat1&codcat2=$codcat2&codcat3=&\" class=\"link_titulo_classi_2\">$nomeCat2</a>";
- }
- /* Categoria 3 */
- if(@$codcat3 != ''){
- @$sqlCat3 = "SELECT nome FROM sub_categoria_n_2 WHERE ID=$codcat3";
- @$sqlCat3 = mysql_query($sqlCat3);
- @$nomeCat3 = mysql_result($sqlCat3,0,'nome');
- @$nomeEstado = NomeEstado($codest);
- if($nomeEstado){
- $nomeEstado = $nomeEstado;
- }else{
- $nomeEstado = 'Brasil';
- }
- @$nomecat1 = RetornaNomeCategoria(1,$codcat1);
- @$nomecat2 = RetornaNomeCategoria(2,$codcat2);
- @$nomecat3 = RetornaNomeCategoria(3,$codcat3);
- $completaURL6 = StringUrlAmigavel("$nomecat1 $nomecat2 $nomecat3 $nomeEstado");
- $completaURL6 = str_replace("--", "-", $completaURL6);
- $completaURL6 = $completaURL6."__$codest-$codcid-$codcat1-$codcat2-$codcat3.htm";
- $link = $completaURL6;
- //$link .= " - <a href=\"lista_anuncio.php?codest=$codest&codcid=$codcid&codcat1=$codcat1&codcat2=$codcat2&codcat3=$codcat3&\" class=\"link_titulo_classi_2\">$nomeCat3</a>";
- }
- return $link;
- }
- //---------------------------------------------------------------------------\\
- // Função para converter tudo para minusculo \\
- // \\
- //---------------------------------------------------------------------------\\
- function loCase($string){
- $string = strtolower($string);
- $string = str_replace("Â","â",$string);
- $string = str_replace("Á","á",$string);
- $string = str_replace("Ã","ã",$string);
- $string = str_replace("A","à",$string);
- $string = str_replace("Ê","ê",$string);
- $string = str_replace("É","é",$string);
- $string = str_replace("I","Î",$string);
- $string = str_replace("Í","í",$string);
- $string = str_replace("Ó","ó",$string);
- $string = str_replace("Õ","õ",$string);
- $string = str_replace("Ô","ô",$string);
- $string = str_replace("Ú","ú",$string);
- $string = str_replace("U","û",$string);
- $string = str_replace("Ç","ç",$string);
- return ($string);
- }
- //---------------------------------------------------------------------------\\
- // Função para gerar o xml do usuario \\
- // $Vitrine = g OU p \\
- //---------------------------------------------------------------------------\\
- function CriaXmlUser($IDuser,$Vitrine){
- global $Path,$PathAbsoluto,$pasta_img;
- $urlsite = $PathAbsoluto;
- $sqlAnuncio = "SELECT SQL_CACHE ID,titulo,uri,valor FROM anuncio WHERE fk_usuario='$IDuser' AND anuncio.statuss='Ativo' AND liberado='s' order by rand();";
- $sqlAnuncio = mysql_query($sqlAnuncio);
- $totalAnuncio = mysql_num_rows($sqlAnuncio);
- $ponteiro = fopen("$Path/xml_user/".$IDuser."_".$Vitrine.".xml","w");
- fwrite($ponteiro, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
- fwrite($ponteiro, "<images>\r\n");
- while ($rowAnuncio = mysql_fetch_array($sqlAnuncio)) {
- /*
- * Selecionando a imagem
- */
- if($Vitrine == 'g'){
- $selectImg = 'imagem';
- }else{
- $selectImg = 'imagem_media';
- }
- @$sqlImagem = "select SQL_CACHE $selectImg from imagens where fk_anuncio='$rowAnuncio[ID]' order by ID ASC limit 1";
- @$sqlImagem = mysql_query($sqlImagem);
- @$totalImagem = mysql_num_rows($sqlImagem);
- @$nome_imagem = mysql_result($sqlImagem,0,$selectImg);
- if($totalImagem > 0){
- $img = $urlsite.'/'.$pasta_img.'/'.$nome_imagem;
- }else{
- $img = $urlsite.'/img/imagem_n_disponivel_02.gif';
- }
- // Largura da imagem
- @$size = getimagesize($img);
- @$width = explode(" ",$size[3]);
- @$width = explode("width=\"",$width[0]);
- @$width = explode("\"",$width[1]);
- @$width_image = $width[0];
- $titulo = strtolower($rowAnuncio['titulo']);
- $link = $urlsite.'/'.$rowAnuncio['uri'];
- $titulo = utf8_encode($titulo);
- if($rowAnuncio['valor'] != '0.000'){
- $valor = "R$ ".number_format ($rowAnuncio['valor'], 2, ',', '.');
- }else{
- $valor = "0";
- }
- $xml = "<pic>\r\n";
- $xml .= "<image>$img</image>\r\n";
- $xml .= "<caption>$titulo</caption>\r\n";
- $xml .= "<url>$link</url>\r\n";
- $xml .= "<delay>7000</delay>\r\n";
- $xml .= "<ID_usuario>$IDuser</ID_usuario>\r\n";
- $xml .= "<ID_anuncio>$rowAnuncio[ID]</ID_anuncio>\r\n";
- $xml .= "<valor>$valor</valor>\r\n";
- $xml .= "<width>$width_image</width>\r\n";
- $xml .= "</pic>\r\n";
- fwrite($ponteiro,$xml);
- }
- fwrite($ponteiro,"</images>\r\n");
- fclose($ponteiro);
- }
- //---------------------------------------------------------------------------\\
- // Função para retornar a Longitude e Latitude do CEP \\
- // Retorna uma array [0] - Latitude \\
- // Retorna uma array [1] - Longitude \\
- // Retorna uma array [2] - Accuracy \\
- //---------------------------------------------------------------------------\\
- function CepLocation($valor){
- ini_set("allow_url_fopen", 1);
- ini_set("allow_url_include", 1);
- if(!(strstr($valor, '-'))){
- $cep1 = substr($valor, 0, 5);
- $cep2 = substr($valor, -3);
- $valor = $cep1.'-'.$cep2;
- }
- $resultado = file_get_contents("http://maps.google.com/maps/geo?output=xml&q=$valor");
- $explodeAccuracy = explode('Accuracy="',$resultado);
- $explodeAccuracy1 = explode('"',$explodeAccuracy[1]);
- $explode = explode('<coordinates>',$resultado);
- $explode1 = explode('</coordinates>',$explode[1]);
- $geolocation = explode(',',$explode1[0]);
- $newcord = "$geolocation[0],$geolocation[1],$explodeAccuracy1[0]";
- $coordenadas = explode(',',$newcord);
- return $coordenadas;
- }
- //---------------------------------------------------------------------------\\
- // Função para remover acwentos \\
- //---------------------------------------------------------------------------\\
- function tiracento($texto){
- $trocarIsso = array('à','á','â','ã','ä','å','ç','è','é','ê','ë','ì','í','î','ï','ñ','ò','ó','ô','õ','ö','ù','ü','ú','ÿ','À','Á','Â','Ã','Ä','Å','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ñ','Ò','Ó','Ô','Õ','Ö','O','Ù','Ü','Ú','Ÿ',);
- $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',);
- $titletext = str_replace($trocarIsso, $porIsso, $texto);
- return $titletext;
- }
- /*
- * Retorna o número máximo (para os diretórios)
- */
- function Verifica_Pasta_range ($numero){
- $x = 0;
- while ($x < $numero){
- $x = $x + 1000;
- }
- return $x;
- }
- //---------------------------------------------------------------------------\\
- // Função para remover cache \\
- //---------------------------------------------------------------------------\\
- function RemoveCache($IDads){
- global $Path;
- $nomeArq = $IDads.'.cache';
- $caminhoTotal = $Path.'/cache/ads/'.Verifica_Pasta_range ($IDads).'/'.$nomeArq;
- @unlink($caminhoTotal);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement