J'ai testé ce code sur mon localhost (wamp) et il marche au poil! Problème c'est qu'il ne marche pas en ligne avec free-h. Donc la je donne ma langue au chat

Lorsque un internaute telecharge un logiciel, le code php envoi un url de la forme "index.php?lang=fr&file=lelogiciel" qui est capté par le code php defini au début de mon index.php que voici:
- Code: Tout sélectionner
$folder_stat = 'trial/stats/' ;
$folder_archive = 'trial/' ;
if ( isset( $_GET['lang'] ) )
{
$lang = htmlentities($_GET['lang'], ENT_QUOTES);
if (strcmp($lang,"fr")!=0)
{
$lang="en";
}
}
else
{
$lang="en";
}
if ( isset( $_GET['file'] ) )
{
$name = htmlentities($_GET['file'], ENT_QUOTES);
if ( file_exists( $folder_stat . $name . '.txt' ) )
{
$FileContent = fopen( $folder_stat . $name . '.txt', 'r+' );
$hit = fgets( $FileContent );
$hit = intval( $hit );
$hit++;
fseek( $FileContent, 0 );
fputs( $FileContent, $hit );
fclose( $FileContent );
header( "Location: $folder_archive$name$lang.7z" );
}
}
function NumberOfHit( $name )
{
$folder_stat = 'trial/stats/' ;
$file = $folder_stat . $name . '.txt' ;
if ( file_exists( $file ) )
{
$FileContent = fopen( $file , 'r' );
$hit = fgets( $FileContent );
fclose( $FileContent );
return $hit;
}
else
{
return -1;
}
}
?>
voici le code pour un lien de telechargement :
- Code: Tout sélectionner
<a href="index.php?lang=<?php echo $lang ?>&file=lelogiciel">LELOGICIEL<?php echo $lang ?></a>
enfin le code pour afficher le compteur dans la page html:
- Code: Tout sélectionner
<?php $name = 'lelogiciel' ; $result = NumberOfHit( $name ) ; echo $result; ?>
J'ai adapté un code php libre de droit que j'ai trouvé sur le web afin de gérer la langue du logiciel tout en ayant un compteur unique par logiciel. N'importe qui peu reprendre ce code à son compte.
Si quelqu'un veut bien m'expliquer pourquoi ca marche sur mon localhost et pas sur free-h, merci d'avance!