Chiamaci oggi! Richiedi informazioni!

Orario ufficio:

Lunedě-Sabato: 9am-8pm
Sull'Articolo -
Semplice Contatore in Php di Giovanni Ceglia - giovanniceglia@xungame.com (é stato visto 9657 volte)

Sapendo di fare cosa gradita a qualcuno, posto questo semplice codice per realizzare un semplicissimo contatore in Php, anche con funzioni per contatore grafico.

 function potenza($val,$exp){
  if (($val==0) && ($exp==0)) return "ERROR"; else {
   if ($exp==0) return 1; else return ($val*potenza($val,$exp-1));
  }
 }

 function nzeros($n){
  $s="";
  for ($i=1;$i<=$n;$i++) $s=$s."0";
  return $s;
 }
  
 function graphic_counter($value,$cifre,$imgdir,$dx,$dy){
  $cnt=(string)nzeros($cifre-strlen($value)).(string)$value;
  for ($j=0;$j<$cifre;$j++) {
   $cifra=substr($cnt,$j,1);
   echo "";
  }
 }

 function inc_counter($path){
  if (!file_exists($path)) {
   $f=fopen($path,"w");
   $val=0;
  } else {
   $f=fopen($path,"r+");
   $num=fgets($f,12);
   fclose($f);
   $f=fopen($path,"w");
  }
  $val++;
  fputs($f,$val);
  fclose($f);
  return $val;
 }

 function get_counter($path){
  if (!file_exists($path)) {
   $val=0;
  } else {
   $f=fopen($path,"r+");
   $val=fgets($f,12);
   fclose($f);
  }
  return $val;
 }





4609

Clienti e Utenti
1057

Domini Gestiti
145

Hosting Gestiti
6511

Database
454

EMail
41

Server Virtuali
17310

Backorder .IT riusciti
20

Anni sul Mercato