")==1) { $u = strbreak($meio,$tmp,$tmp,$thisid, "="," "); $thisid = substr($thisid,1); echo $antes; if ($thisid>0) include ("mostraimagens.php"); $var=$depois; } echo $var; } function sentencesBreaker($sentence, $len, $str) { $sentence = strip_tags ($sentence, "
"); $stream = ""; $len_stream = 0; $vetor = explode(" ", $sentence); $number_of_words = 0; $number_of_words = count($vetor); $index = 0; while ($len_stream < $len) { $stream .= " " . $vetor[$index]; $len_stream = strlen($stream); $index++; } if ($len_stream > $len) $stream .= $str; return $stream; } function busca_string($string, $str_pesquisada, $classe, $link) { /* A $class que é geralmente utilizada é a found abaixo descrita: .found { FONT-WEIGHT: none; FONT-SIZE: 11px; COLOR: #FFFFFF; BACKGROUND-COLOR: #3366CC; FONT-FAMILY: Arial; TEXT-DECORATION: none } .found:hover { FONT-WEIGHT: none; FONT-SIZE: 11px; COLOR: #FFFFFF; BACKGROUND-COLOR: #3366CC; FONT-FAMILY: Arial; TEXT-DECORATION: none } */ $string_final = ""; $string_aux = ""; $tam_palavra_pesquisada = strlen($str_pesquisada); $nova_string = $string; while (strlen($nova_string) > 0) { $string_aux = strstr($nova_string, $str_pesquisada); $string_final .= substr($nova_string,0,strlen($nova_string) - strlen($string_aux)); if (strlen($string_aux)>0) { if ($link) { if ($classe) $echo_link1 = "" . $str_pesquisada . ""; else $echo_link1 = "" . $str_pesquisada . ""; } else { if ($classe) $echo_link1 = "" . $str_pesquisada . ""; else $echo_link1 = $str_pesquisada; } //$string_final .= strtoupper($str_pesquisada); $string_final .= $echo_link1; } $nova_string = $string_aux; $nova_string = substr($nova_string,$tam_palavra_pesquisada); } return $string_final; } function set_substring($str, $f_chr, $l_chr, $cls, $link) { // ------------------------------------------------------------------------ // // $str - String sobre a qual o algoritmo irá executar // // $f_chr - Caractere de início da substring que queremos encontrar // // $l_chr - Caractere de final da substring que queremos encontrar // // $cls - Class (CSS) // // $link - Caso queiramos que a substring encontrada se transforme em link // // ------------------------------------------------------------------------ // $str_final = ""; $str_aux = ""; $str_aux = $str; $str_nova = $str; $str_antes = ""; $str_meio = ""; $str_depois = ""; $str_final = ""; while (strlen($str_nova) > 0) { // antes - antes - antes - antes // $str_aux = strstr($str_nova, $f_chr); $str_antes = substr($str_nova,0,(strlen($str_nova) - strlen($str_aux))); // string anterior ao caractere buscado $str_final .= $str_antes; // antes - antes - antes - antes // $str_nova = $str_aux; // aqui tratar a informação do meio // $str_aux = strstr($str_nova, $l_chr); $str_meio = substr($str_nova, 0, ((strlen($str_nova))-(strlen($str_aux))+1)); // aqui tratar a informação do meio // if ($link) { if ($cls) $echo_link1 = "" . $str_meio . ""; else $echo_link1 = "" . $str_meio . ""; } else { if ($cls) $echo_link1 = "" . $str_meio . ""; else $echo_link1 = $str_meio; } $str_final .= $echo_link1; $str_nova = substr($str_nova, strlen($str_meio), strlen($str_nova) - strlen($str_meio)); } return $str_final; } function valor($campo, $tbl, $id, $msg) { require("conf.php"); $sql = "select $campo from $tbl where id=$id"; $rs = mysql_query($sql, $connection) or die ("$msg"); $rw = mysql_fetch_array($rs); return $rw[$campo]; } function valorg($campo, $tbl, $vc, $id, $ordem, $msg) { // $vc - variavel condicional // require("conf.php"); $sql = "select $campo from $tbl where $vc=$id order by $ordem"; $rs = mysql_query($sql, $connection) or die ("$msg"); $rw = mysql_fetch_array($rs); return $rw[$campo]; } function fdata($data, $ch) { $data = substr($data,8,2) . $ch . substr($data,5,2) . $ch . substr($data,0,4); return $data; } function mk_data($data, $LG) { $dia = substr($data,8,2); $mes = substr($data,5,2); $ano = substr($data,0,4); switch ($mes) { case "01": if ($LG=="pt") $mes_ext = "Janeiro"; else $mes_ext = "January"; break; case "02": if ($LG=="pt") $mes_ext = "Fevereiro"; else $mes_ext = "February"; break; case "03": if ($LG=="pt") $mes_ext = "Março"; else $mes_ext = "March"; break; case "04": if ($LG=="pt") $mes_ext = "Abril"; else $mes_ext = "April"; break; case "05": if ($LG=="pt") $mes_ext = "Maio"; else $mes_ext = "May"; break; case "06": if ($LG=="pt") $mes_ext = "Junho"; else $mes_ext = "June"; break; case "07": if ($LG=="pt") $mes_ext = "Julho"; else $mes_ext = "July"; break; case "08": if ($LG=="pt") $mes_ext = "Agosto"; else $mes_ext = "August"; break; case "09": if ($LG=="pt") $mes_ext = "Setembro"; else $mes_ext = "September"; break; case "10": if ($LG=="pt") $mes_ext = "Outubro"; else $mes_ext = "October"; break; case "11": if ($LG=="pt") $mes_ext = "Novembro"; else $mes_ext = "November"; break; case "12": if ($LG=="pt") $mes_ext = "Dezembro"; else $mes_ext = "December"; break; } $dia_semana = ""; switch (date("w")) { case "0": $dia_semana = "Domingo"; break; case "1": $dia_semana = "Segunda-feira"; break; case "2": $dia_semana = "Terça-feira"; break; case "3": $dia_semana = "Quarta-feira"; break; case "4": $dia_semana = "Quinta-feira"; break; case "5": $dia_semana = "Sexta-feira"; break; case "6": $dia_semana = "Sábado"; break; } if ($LG=="pt") return $dia_semana . ", " . $dia . " de " . $mes_ext . " de " . $ano; else return $ano . ", " . $dia . " of " . $mes_ext; } function nmUser($id_user) { require("conf.php"); $sql = "select nome from _tusers where id=$id_user"; $rs = mysql_query($sql, $connection) or die ("Error - nmUser"); $rw = mysql_fetch_array($rs); return $rw[nome]; } function upperFisrtLetter ($str) { $str_invalid_chars = array("as", "e", "ao", "and", "os", "da", "de", "ou", "para", "com", "que", "qual", "qualquer", "quaisquer", "das", "dos", "em", "in", "on", "at", "that", "do", "of", "the", "with", "a", "an", "to"); $str = strtolower($str); // converte os caracteres da string para characteres minusculos $words = explode(" ", $str); // separa a string quebrando-a nos espaços em branco $str_final = ""; // variavel final que conterá a string devolvida $strAux = ""; // variavel auxiliar que guarda um valor (string) temporário $strAux = strtoupper(substr($words[0],0,1)) . strtolower(substr($words[0],1,strlen($words[0])-1)); // a primeira palavra será alterada sempre $str_final .= $strAux; for ($i=1;$i < count($words);$i++) { $strAux = ""; if (!in_array($words[$i], $str_invalid_chars)) { // verifica se a palavra a ser alterada está presente no array $str_invalid_chars $strAux = " " . strtoupper(substr($words[$i],0,1)) . strtolower(substr($words[$i],1,strlen($words[$i])-1)); $str_final .= $strAux; } else { $str_final .= " " . $words[$i]; } } return $str_final; } function formataNumero($str,$casas,$ch) { // inclui zero no final $v_temp = explode($ch,$str); if (count($v_temp) < 2) { $valor = $str . "."; for ($i=strlen($str);$i < $casas; $i++) { $valor .= "0"; } } else { if (strlen($str) < $casas) { $valor = $str; for ($i=strlen($str);$i < $casas; $i++) { $valor .= "0"; } } else { $valor = $str; } } return $valor; } function limpaAspas($str) { $nova_str = str_replace('"','\"',$str); $nova_str = str_replace("'","\'",$nova_str); return $nova_str; } function firstLastName($str) { $nomes_completos = trim($str); $nomes = explode(" ", $nomes_completos); if (count($nomes) > 1) { return $nomes[0] . " " . $nomes[(count($nomes)-1)]; } else { return $nomes[0]; } } function montaCaminho($subpagina, $id_parar=0, $class1 = "caminho", $class2 = "caminho_atual") { require("conf.php"); if ($subpagina==$id_parar) { $sql_caminho = "select * from _trubricas where id=" . $subpagina; $rs_caminho = mysql_query($sql_caminho,$connection) or die ("Error - montaCaminho - funcs.php - IV"); $rw_caminho = mysql_fetch_array($rs_caminho); echo $rw_caminho[descpt]; } else { $i=0; while (($subpagina!=$id_parar) && ($subpagina!=$id_home)) { $sql_caminho = "select * from _trubricas where id=" . $subpagina; $rs_caminho = mysql_query($sql_caminho,$connection) or die ("Error - montaCaminho - funcs.php - I"); $rw_caminho = mysql_fetch_array($rs_caminho); $subpagina = $rw_caminho[subpagina]; $vetor_caminho[$i] = $rw_caminho[descpt]; $vetor_id_caminho[$i] = $rw_caminho[id]; $i++; } $x = 0; for ($j=(count($vetor_caminho)-1);$j>=0;$j--) { if ($j>0) { $barras = ">"; $class = "class='$class1'"; } else { $barras = ""; $class = "class='$class2'"; } if ($vetor_id_caminho[$j]!=1) { $id_novo = $vetor_id_caminho[$j]; } else { $id_novo = 291; } echo "" . $vetor_caminho[$j] . "" . " " . $barras . " "; //echo "" . $vetor_caminho[$j] . "" . " " . $barras . " "; $x++; } } } function NumeroVisitas($id) { require("conf.php"); $sql_id = "select sum(valor) as total from stats where id=$id"; $rs_id = mysql_query($sql_id, $connection) or die ("error - funcs.php - NumeroVisitas"); $rw_id = mysql_fetch_array($rs_id); return $rw_id[total]; } function ehpar($valor, $cor_par, $cor_impar) { if (($valor % 2)==0) { return $cor_par; } else { return $cor_impar; } } function color_formt($COLOR,$tipo){ /* / echo color_formt(array("93","142","176"),2); */ for ($i=0; $i<=9; $i++) { $codigo_part[$i]=$i; $fac_mult[$i]=$i; } for ($is='a'; $is<='f'; $is++) { $codigo_part[$i]=$is; $fac_mult[$is]=$i; $i++; } if($tipo==1) { $COLOR=strtolower($COLOR); /* de código a valores FORMATO VALIDO : #RRVVAA */ $COLOR= ereg_replace ('#','',$COLOR); $col[rojo][1]= substr($COLOR,0,1); $col[rojo][2]= substr($COLOR,1,1); $col[verde][1]= substr($COLOR,2,1); $col[verde][2]= substr($COLOR,3,1); $col[azul][1] = substr($COLOR,4,1); $col[azul][2] = substr($COLOR,5,1); $color_[rojo]=($fac_mult[$col[rojo][1]]*16)+$fac_mult[$col[rojo][2]]; $color_[verde]=($fac_mult[$col[verde][1]]*16)+$fac_mult[$col[verde][2]]; $color_[azul]=($fac_mult[$col[azul][1]]*16)+$fac_mult[$col[azul][2]]; } elseif($tipo==2) { /* de valores a código FORMATO VALIDO : RRR|VVV|AAA */ $rojo=$COLOR[0]; $verde=$COLOR[1]; $azul=$COLOR[2]; $color_=strtoupper('#'.$codigo_part[floor($rojo/16)].$codigo_part[$rojo%16]. /*rojo */ $codigo_part[floor($verde/16)].$codigo_part[$verde%16]. /*verde*/ $codigo_part[floor($azul/16)].$codigo_part[$azul%16]); /*azul*/ } else { $color_='N/a'; } return $color_; } function getPaises() { require("conf.php"); $sql_paises = "select * from _tpaises order by nomept"; $rs_paises = mysql_query ($sql_paises, $connection) or die ("Error - funcs.php - getPaises"); $html = ""; return $html; } function toupper ($str) { $nova_string = strtoupper(strtr($str, 'àáâãäåæçèéêëìíîïðñòóôõö÷øùüúþÿ', 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÜÚÞß')); return $nova_string; } function tolower ($str) { $nova_string = strtolower(strtr($str, 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÜÚÞß', 'àáâãäåæçèéêëìíîïðñòóôõö÷øùüúþÿ')); return $nova_string; } function subpaginas ($id) { require ("conf.php"); $ids = ""; $i = 1; $sql = "select * from _trubricas where subpagina=$id"; $rs = mysql_query ($sql, $connection) or die ("Error - funcs.php - subpaginas"); while ($rw = mysql_fetch_array($rs)) { if ($i==1) { $ids = $rw[id]; } else { $ids .= "," . $rw[id]; } $i++; } return $ids; } function montaMapaArray($vetor_id, $lan = "pt") { require ("conf.php"); $html = ""; $count = count($vetor_id); $html .= "\n"; $html .= " "; $html .= " "; $html .= " "; $html .= " "; $html .= " "; $html .= " "; $html .= " "; for ($i=0;$i < $count; $i++) { $j = 1; $sql = "select * from _trubricas where subpagina=$vetor_id[$i] and hidden=0 and hidemenu=0 order by ordem"; $rs = mysql_query ($sql, $connection) or die ("Error - funcs.php - montaMapaArray"); $total = 0; $total = mysql_num_rows($rs); while ($rw = mysql_fetch_array($rs)) { if ($j < $total) { $imagem = ""; $imagem2 = ""; } elseif ($i==($count-1)) { $imagem = ""; $imagem2 = ""; } else { $imagem = ""; $imagem2 = ""; } $html .= " "; $html .= " "; $html .= " "; $html .= " "; $j++; } } $html .= "
HOME
"; $html .= " "; $html .= " "; $html .= " "; $html .= " "; $html .= " "; $html .= " "; $sql2 = "select * from _trubricas where subpagina=$rw[id] and hidden=0 and hidemenu=0 order by ordem"; $rs2 = mysql_query ($sql2, $connection) or die ("Error - funcs - montaMapaArray2"); $x = 1; $total2 = mysql_num_rows($rs2); while ($rw2 = mysql_fetch_array($rs2)) { if ($x < $total2) { $imagem3 = ""; } else { $imagem3 = ""; } $html .= " "; $html .= " "; $html .= " "; $html .= " "; $html .= " "; $x++; } $html .= "
" . $imagem . "" . $rw['nome' . $lan] . "
" . $imagem2 . ""; $html .= " "; $html .= " "; $html .= " "; $html .= " "; $html .= " "; $html .= " "; $html .= "
" . $imagem3 . "" . $rw2['nome' . $lan] . "
"; $html .= "
"; $html .= "
\n"; return $html; } function getAllSubIds ($id_principal, $indice, &$lista_ids) { // id_principal - pagina que será visitada // indice - elemento no array que será visitado // array - array contendo todos os ids require("conf.php"); $sql_sids = "select * from _trubricas where subpagina = $id_principal"; $rs_sids = mysql_query ($sql_sids, $connection) or die ("Error - getAllSubIds"); $i = count($lista_ids); while ($rw_sids = mysql_fetch_array($rs_sids)) { $lista_ids[$i] = $rw_sids[id]; $i++; } $proximo_id = $lista_ids[$indice]; $proximo_indice = ++$indice; if ($proximo_id) { $nova_lista = getAllSubIds($proximo_id, $proximo_indice, $lista_ids); } for ($j=0;$j < count($lista_ids);$j++) { if ($j==0) { $ids = $lista_ids[$j]; } else { $ids .= "," . $lista_ids[$j]; } } return $ids; } // divide um ttf em várias linhas // recebe como parâmetros a string toda, o número de caracteres por linha, o tamanho da fonte, a fonte, // a cor de fundo e a cor do texto function divide_ttf ($string, $caracteres, $size, $font, $bgcolor, $fccolor) { $s = explode(" ",$string); $str = ""; $j = 0; for ($i=0; $i < count($s); $i++){ if (strlen($str) > 0) $str .= " ".$s[$i]; else $str = $s[$i]; if (strlen($str) > $caracteres){ $resultado[$j]=$str; $str = ""; $j++; } } if (count($resultado)>0){ for ($i=0; $i < count($resultado); $i++){ echo "

"; } if (strlen($str) > 0) echo ""; } else { echo ""; } } // $hora1 = "hh:mm:ss"; // $hora2 = "hh:mm:ss"; // total de segundos entre duas horas (horas2 - horas1) // conversão do total de segundos para x hs y min function subtraiHoras($hora1, $hora2) { $vetor_hora1 = explode(":",$hora1); $vetor_hora2 = explode(":",$hora2); $hora_numero1 = mktime($vetor_hora1[0],$vetor_hora1[1]); $hora_numero2 = mktime($vetor_hora2[0],$vetor_hora2[1]); $diferenca = $hora_numero2 - $hora_numero1; $res_horas = $diferenca / 3600; $vetor_horas_minutos = explode(".", $res_horas); if ($vetor_horas_minutos[0] > 0) { if ($vetor_horas_minutos[0] > 1) { $h = " hs"; } else { $h = " h"; } $horas = $vetor_horas_minutos[0] . $h . " "; } if ($vetor_horas_minutos[1] > 0) { $segundos = $diferenca % 3600; $minu = $segundos / 60; $minu .= " min"; } return $horas . $minu; } // total de segundos entre duas horas (horas2 - horas1) function totalSegundos($hora1, $hora2) { $vetor_hora1 = explode(":",$hora1); $vetor_hora2 = explode(":",$hora2); $hora_numero1 = mktime($vetor_hora1[0],$vetor_hora1[1]); $hora_numero2 = mktime($vetor_hora2[0],$vetor_hora2[1]); $diferenca = $hora_numero2 - $hora_numero1; return $diferenca; } // conversão de segundos para x hs y min function segundosParaHorasMinutos ($segundos) { $res_horas = $segundos / 3600; $vetor_horas_minutos = explode(".", $res_horas); if ($vetor_horas_minutos[0] > 0) { if ($vetor_horas_minutos[0] > 1) { $h = " hs"; } else { $h = " h"; } $horas = $vetor_horas_minutos[0] . $h . " "; } if ($vetor_horas_minutos[1] > 0) { $segundos = $segundos % 3600; $minu = $segundos / 60; $minu .= " min"; } return $horas . $minu; } function GetSubPaginasReversa ($id_stop, $id_pa) { require("conf.php"); $vetor = $id_pa; do { $sql_gspr = "select * from _trubricas where id='$id_pa' "; $rs_gspr = mysql_query ($sql_gspr, $connection) or die ("Error - novidades_home.php - Ia"); $rw_gspr = mysql_fetch_array($rs_gspr); if ($rw_gspr[subpagina]!=$id_stop) { $vetor .= "," . $rw_gspr[subpagina]; $id_pa = $rw_gspr[subpagina]; } } while ($rw_gspr[subpagina]!=$id_stop); return $vetor; } function existeSP ($id) { require("conf.php"); $sql = "select * from _trubricas where subpagina=$id and hidden=0 and hidemenu=0 "; $rs = mysql_query ($sql, $connection) or die ("Error - funcs.php - existeSP"); return mysql_num_rows($rs); } function getPaginaPai ($id) { require ("conf.php"); $sql_pp = "select subpagina from _trubricas where id=$id"; $rs_pp = mysql_query ($sql_pp, $connection) or ("Error - funcs.php - getPaginaPai"); $rw_pp = mysql_fetch_array($rs_pp); return $rw_pp[subpagina]; } function escolheImagePHP($src, $width, $height, $class='') { $sizes = @GetImageSize($src); $w = $sizes[0]; $h = $sizes[1]; if ($w > $h) { $img = ""; } else { $img = ""; } return $img; } function round_flash($largurax, $alturax, $raio, $corLinha, $espessura, $src, $preload) { $nome = "flash/rounded_flash.swf"; $largura = $largurax + ($espessura * 2); $altura = $alturax + ($espessura * 2); $vars = "&largura=" . $largura . "&altura=" . $altura ."&raio=" . $raio ."&corL=" . $corLinha . "&tL=" . $espessura ."&src=" .$src . "&preload=" .$preload; $html = ""; $html .= ""; $html .= ""; $html .= ""; $html .= ""; $html .= ""; $html .= ""; $html .= ""; $html .= ""; $html .= ""; $html .= ""; return $html; } function flash($largura, $altura, $nome, $vars) { $html = ""; $html .= ""; $html .= ""; $html .= ""; $html .= ""; $html .= ""; $html .= ""; $html .= ""; $html .= ""; $html .= ""; $html .= ""; return $html; } ?>0) { //***************************** CONTAGEM DOS CLICKS ****************************************************** if (mysql_num_rows(mysql_query("SELECT * FROM stats where mes='$MES' and ano='$ANO' and tbl='$utbl' and id='$id'",$connection))>0) mysql_query("UPDATE stats SET valor=valor+1 WHERE mes='$MES' and ano='$ANO' and tbl='$utbl' and id='$id'"); else mysql_query("INSERT into stats (mes, ano, tbl, id, valor) VALUES ('$MES','$ANO','$utbl','$id','1')"); //***************************** CONTAGEM PAÍS ****************************************************** if (mysql_num_rows(mysql_query("SELECT * FROM stats3 where mes='$MES' and ano='$ANO' and pais='$PAIS'",$connection))>0) mysql_query("UPDATE stats3 SET valor=valor+1 WHERE mes='$MES' and ano='$ANO' and pais='$PAIS'"); else mysql_query("INSERT into stats3 (mes, ano, pais, valor) VALUES ('$MES','$ANO','$PAIS','1')"); //***************************** CONTAGEM HORA ****************************************************** if (mysql_num_rows(mysql_query("SELECT * FROM stats2 where mes='$MES' and ano='$ANO' and hora='$HORA'",$connection))>0) mysql_query("UPDATE stats2 SET valor=valor+1 WHERE mes='$MES' and ano='$ANO' and hora='$HORA'"); else mysql_query("INSERT into stats2 (mes, ano, hora, valor) VALUES ('$MES','$ANO','$HORA','1')"); } ?>