Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Bruno Iamada

Count

Recommended Posts

Olá pessoal, bom dia !

 

Pessoal estot com um problema aqui, quero contar quantas vezes a imagen aparece. No meu count existem 5 imagens e quando a imagem1 aparece é somado +1 para a imagem1, porem é somados outros valores para outras imagens, alguem sabe me dizer o que está acontecendo ?

 

segue escript:

 

<?php
if(!is_dir("temp")) { mkdir("temp"); }
if(!is_dir("mydata")) { mkdir("mydata"); }
$hostdir=dirname(__FILE__);
$filesnames = scandir($hostdir."/img");
// print_r ($filesnames);
$count = count($filesnames);
$filesname="";
$cvs="filename,showtimes\r\n";
if($count > 2){
$filesname = $filesnames[rand(2, $count-1)];
for ($x=2; $x< $count; $x++) {
$ff = "temp/$filesnames[$x].txt";
if(!file_exists($ff)){
$ShowTime=0;
if($filesnames[$x]== $filesname){
$ShowTime=1;
}
$myfile = fopen($ff, "w") or die("Unable to open file!");
fwrite($myfile, $ShowTime);
fclose($myfile);
$cvs =$cvs . $filesnames[$x].",".$ShowTime."\r\n";
}else{
$ShowTime=0;
$handle = fopen($ff, 'r');
while(!feof($handle)){
$ShowTime = intval(fgetss($handle, 1024, '<br>'));
}
fclose($handle);
if($filesnames[$x]== $filesname){
$ShowTime++;
$myfile = fopen($ff, "w") or die("Unable to open file!");
fwrite($myfile, $ShowTime);
fclose($myfile);
}
$cvs =$cvs . $filesnames[$x].",".$ShowTime."\r\n";
}
}
$myfilecvs = fopen("mydata/data.csv", "w") or die("Unable to open file!");
fwrite($myfilecvs, $cvs);
fclose($myfilecvs);
}
?>
<html><head><META HTTP-EQUIV='Pragma' CONTENT='no-cache' /><META HTTP-EQUIV='Cache-Control' CONTENT='no-cache' /><META HTTP-EQUIV='Expires' CONTENT='0' /> <meta content='text/html; charset=UTF-8' http-equiv='content-type'/> <title></title> <script type='text/javascript'>
</script> <style type='text/css'> .show{display:block; position:static;} .hide{display:none; position:absolute;} </style></head>
<body onload='L1(0);' style='text-align:center;'><div id='divaa'>
<div id='div0' style=' width:XXXXXXXXXXpx;'>
<img id='img' alt='' style=' width:98%; ' src='img/<?php echo $filesname ?>' />
<div id='divstxt' style='word-break: break-all;font-size:30px;'></div></div>
</div>
<form><div id='div22'></div>
<input type='button' id='right' style="width:100%;font-size:30px" onclick='javascript:location.href="goout.php?url=http://www.google.com";' value=' Internet > ' />
</body>
</html>
desde já agradeço !

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.