Jump to content


Photo

Contador De Visitas


  • Faça o login para participar
2 replies to this topic

#1 lucasmr

lucasmr

    Novato no fórum

  • Usuários
  • 22 posts
  • Sexo:Não informado

Posted 08/01/2005, 15:11

Boa Tarde a todos,
bem, tenho um script de um contador de visitas que funciona perfeitamente,
porem, ele é em modo grafico, e eu gostaria que ele retornasse em texto mesmo, que é mais rapido para carregar!

dai eu escolheria uma fonte, como por exemplo, tahoma, numero 10, e ele retornaria assim mesmo, carregando mais rapidamente para pessoas de acesso discado

Obrigado!


<?
//>---------------------------------------------------------------------------<
//> Simple counter version 1.0                                                <
//>                                                                           <
//> You may use this counter script anywhere you want to, modified in any way <
//> to suit your needs provided this header text is not removed.              <
//>                                                                           <
//> You can register for upgrades by sending your name and e-mail to me at    <
//> ray@rjj.uk.co                                                             <
//>                                                                           <
//> Other scripts will be available from time to time, and you can get them   <
//> Direct from my website at www.webdesigntoolz.co.uk                        <
//>---------------------------------------------------------------------------<
//> Configure script variables                                                <
//>                                                                           <
//> Modify $counterfile to point at the location of your text counter file.   <
//> Modify $image directory to point at your counter image directory. Include <
//> the backslash.                                                            <
//> Modify $digits to specify how many digits you want. There is no limit.    <
//> If you want to use your own images, you need to overwrite the ones        <
//> provided with this script.  They are called '0.jpg' to '9.jpg'.  You can  <
//> use any image type you like, jpeg, png, for example, but you will need to <
//> modify the file extensions in the two loops as indicated below.           <
//>---------------------------------------------------------------------------<

$counterfile = "counter.txt";
$imagedirectory = "files/";
$digits = 7;

$opencount = @fopen($counterfile,"r");
$currentcount = fread($opencount, filesize($counterfile));
fclose($opencount);

$newcount = $currentcount;
++$newcount;
$numdigits = strlen($newcount);
if ($numdigits > $digits) {
        $newcount = "0";
        } else {
        }
$actdigits = strlen($newcount);

//>---------------------------------------------------------------------------<
//> To use images other than jpgs, you will need to modify the file extension <
//> after the 'else' statement in the following loop.                         <
//>---------------------------------------------------------------------------<

for ($a=0;; $a++) {
        if ($a == $digits) {
                break;
                } else {
                $img[$a] = "$imagedirectory";
                $img[$a] .= "0.jpg";
                }
        }

//>---------------------------------------------------------------------------<
//> To use images other than jpgs, you will need to modify the file extension <
//> after the $showdig variable in the following loop.                        <
//>---------------------------------------------------------------------------<

for ($a=0;; $a++) {
        if ($a == $actdigits) {
                break;
                } else {
                $showdig = substr($newcount, $a, 1);
                $img[$digits - $actdigits + $a] = "$imagedirectory";
                $img[$digits - $actdigits + $a] .= "$showdig.jpg";
                }
        }

$displayblock = "";
for ($a=0; $a < $digits; $a++){
        $displayblock .= "<td><img src=$img[$a]></td>";

      }

$opennewcount = @fopen($counterfile,"w");
@fwrite($opennewcount, $newcount);
fclose ($opennewcount);

?>
<html>
<head>
<body topmargin="0" leftmargin="0">
<title>Contador</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

 <body bgcolor="#FFFFFF">

 <table border="0" cellspacing="0" cellpadding="0">
   <tr>
    <? echo $displayblock ?>
  </tr>
 </table>
 </body>
</html>

no mesmo diretorio desse script tem o arquivo "counter.txt" que é onde fica o numero de acessos, e um diretorio "files/" que ficam as figuras, que no caso seria desnessessario!

#2 Felipe Pena

Felipe Pena

    O temor do Senhor é o princípio da sabedoria

  • Ex-Admins
  • 6441 posts
  • Sexo:Masculino

Posted 08/01/2005, 15:39

PHP
<?
$arquivo
= "counter.txt";

$abrir = fopen($arquivo, "r");
$ler = fread($abrir, filesize($arquivo));
fclose($abrir);

$ler++;

$abrir2 = fopen($arquivo, "w");
$escrever = fwrite($abrir2, $ler);
fclose($abrir2);

echo
$ler;
?>

Felipe Pena
[...] ó terra, terra, terra; ouve a palavra do Senhor. — Jeremias 22:29

#3 lucasmr

lucasmr

    Novato no fórum

  • Usuários
  • 22 posts
  • Sexo:Não informado

Posted 09/01/2005, 15:49

obrigado, assim funcionou legal, mas uma coisa
tem como eu de uma outra html puxar as informações desse PHP?
pq atualmente eu uso ele com um quadro entre linhas, mandando a pagina de inicio desse quadro ser o PHP, dai ele abre o contador!!

teria como não precisar fazer o quadro e ja puxar o texto direto?

desculpe o jeito de me expressar, nao sei se deu pra entender...
hehe

valeu!
abraços

Edição feita por: lucasmr, 09/01/2005, 16:12.





1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq