Home Page Services Solutions Articles History Contacts Links Versione Italiana
Software
2D Creations
3D Creations
Images
Open Source
Projects
Web Utilities
Graphic Tools
Downloads
Documents

Semplice Contatore in Php


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 "<img src="$imgdir"."$cifra.gif" width=$dx height=$dy>";
  }
 }

 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;
 }



Giovanni Ceglia
giovanniceglia@xungame.com


Home Page Services Solutions Articles History Contacts Links Italian Version

Personal sites and projects: E-Mercanti Services, Programmers Community, E-Merchants Community, Game Developing Community, Programming & Videogames, Programming Portal, Graphic Portal, Services for people looking for a job, Search Engine for Accommodations, Hosting Services, Internet Services for Identity Verification, Cheap Hosting Services and Domain Registration, Hardware and Software E-Shop, The Whole Giovanni Ceglia's Network. Real Estate Listings in English, Real Estate Listings in Italian, Real Estate Listings in German, Malmignatta Search Engine, Malmignatta Search Engine in English.


All material on this site is © CopyRight Giovanni Ceglia since 2003, all the right are reserved, the copy and redistribution of the material on this site is forbidden without permission. If there are words about trade marks they are of respective owners. Giovanni Ceglia - Computer Science Services & Programmer, Internet and Hosting Services, Business Number(Italian IVA) N. 03972320653, Based in Via Trento N.74 84016, Pagani (Salerno) Italy, E-Mail: giovanniceglia@xungame.com, Mobile Photne for contacts: 339-4403189.