Compteur php

Fermé
jérémy1664 Messages postés 165 Date d'inscription lundi 4 juin 2007 Statut Membre Dernière intervention 3 juillet 2008 - 28 févr. 2008 à 15:15
jérémy1664 Messages postés 165 Date d'inscription lundi 4 juin 2007 Statut Membre Dernière intervention 3 juillet 2008 - 29 févr. 2008 à 08:39
Bonjour,

J'ai un problème avec mon compteur php

Il marche avec les adresses ip,

il y a un fichier ip.txt qui s'incrémente que quand il est vide alors qu'il devrait le faire à chaque fois qu'une nouvelle ip entre sur mon site

Conclusion le compteur est faux et reste bloqué

Il fonctionne aussi avec un fichier compteur.txt


<?
$numip = "10"; 
$anzdir="modules\compteur.txt" ;
$ipdir ="modules\ip.txt" ;
//$anzdir="D:\vhosts\gs-computer.eu\httpdocs\compteur.txt" ;
//$ipdir ="D:\vhosts\gs-computer.eu\httpdocs\ip.txt" ;
if (file_exists($anzdir) AND file_exists($ipdir))
{ 
	global $REMOTE_ADDR, $ipdata, $userip1;	
	$userip = $_SERVER["REMOTE_ADDR"]; 
	$ipfile = fopen($ipdir,"r+");
	$ipfile1 = fgets($ipfile,200);
	$ipdata = explode(":",$ipfile1);
	fclose($ipfile);
	if (in_array($userip, $ipdata))
	{
		global $nummer,$anzahl; 
		$anzahl = fopen("$anzdir", "r+") ;	
	   	$nummer = fgets($anzahl,9);
	   	fclose($anzahl);
	  }
	else	
	{	
		global $num, $userip;
		$num = count($ipdata);
		if ($num <= $numip)
		{
			$ipfile1 = substr($ipfile1,0,strlen($ipfile1)-1);	
			$ipfile1 = $ipfile1.$userip.":";
			$ipfile = fopen($ipdir,"w+");
   			fwrite($ipfile, 	$ipfile1);
			fclose($ipfile);
			$anzahl = fopen("$anzdir", "r+");	
 	  		$nummer = fgets( $anzahl, 9 );  
 	  		$nummer++; 
 	  		fseek($anzahl, 0); 
 	 		fputs( $anzahl, $nummer );
			fclose($anzahl);
		}
		else
		{
			global $ipdata9, $push;
			$pop = array_pop($ipdata);
			$ipdata = array_reverse($ipdata);
			array_push($ipdata,$userip);
			$ipdata = array_reverse($ipdata);
			$userip2 = implode(":",$ipdata);
			$ipfile = fopen($ipdir,"w+");
			fputs($ipfile,$userip2);
			fclose($ipfile);
			
			$anzahl = fopen("$anzdir", "r+");	
 	  		$nummer = fgets( $anzahl, 9 );  
 	  		$nummer++; 
 	  		fseek($anzahl, 0); 
 	 		fputs( $anzahl, $nummer );
			fclose($anzahl);
		}
	}
}
else
{
	if (file_exists($ipdir))
	{
		global $nummer;
		$fo = fopen($anzdir,"w+");
		fputs($fo, 1);
		$nummer = 1;
	}
	else
	{
		global $nummer;
		$foip = fopen($ipdir, "w+");
		fputs($foip, $REMOTE_ADDR.":");
		fclose($foip);
		$foan = fopen($anzdir,"w+");
		fputs($foan, 1);
		$nummer = 1;
	}
}
//echo <span class="compteur"><b>.$nummer.</b></span>;
echo $nummer;
?>

 


Si quelqu'un a un solution ?
A voir également:

1 réponse

jérémy1664 Messages postés 165 Date d'inscription lundi 4 juin 2007 Statut Membre Dernière intervention 3 juillet 2008 4
28 févr. 2008 à 18:02
En fait les ip étrangère a mon réseau ne sont pas comptabilisées comment c'est possible
0
jérémy1664 Messages postés 165 Date d'inscription lundi 4 juin 2007 Statut Membre Dernière intervention 3 juillet 2008 4
29 févr. 2008 à 08:39
Personne ne peux m'aider ?
0