iNET Interactive - Online Advertising Agency
          
   Home    Authors    About    Login    Contact Us
   Search:   
Advanced Search     
  Articles

  ASP (26)
  ASP.NET (19)
  C and C++ (4)
  CFML (2)
  CGI and Perl (16)
  Flash (2)
  Java (7)
  JavaScript (28)
  PHP (92)
  MySQL (13)
  MSSQL (3)
  HTML (35)
  SEO (9)
  Visual Basic (12)
  CSS (13)
  SSI (5)
  XML (12)
  C# (14)

  Developer News

July 3, 2008
Poll: Which Web editor do you use?
About
 
July 3, 2008
Book Review: Head First JavaScript
WebReference.com
 
July 3, 2008
10 Things You Can Do With a Wiki
About
 
July 2, 2008
Web Host Reviews - 10 New Reviews
About
 
July 2, 2008
14 Reasons You Should Join a Social Network
About
 
July 1, 2008
Mark Boulton's Freelance Design Secrets
SitePoint
 
Courtesy of moreover.com
 
Want to receive new articles via e-mail? Click here!
/Home /PHP

IP Retrival & hit counter with PHP/GD Library image editing 

  Views:    11157
  Votes:    4
by Sreejith Rk 3/07/05 Rating: 

Synopsis:

This tutorial shows how to make a PHP image which generates IP Address of the PC viewing it and act as a HIT counter .
Pages: firstback2 forwardlast
The Article

This is a really simple free php hit counter script that uses the GD library to generate a picture that displays the users IP address and the amount of views the picture / page has had.This can be used as a hit counter for your siteor as a cool forum signature.Your host will need php and the GD library installed to use this Free Hit Counter.

1. First save a blank .txt file named counter.txt
2. then open notepad (or any PHP-editor u use) and paste this code :
<?php


$TextFile
=
"counter.txt"
;
$Count = trim(file_get_contents($TextFile
));
$FP = fopen($TextFile, "r"
);
$Count=fgets($FP, 4096
);
fclose ($FP
);
settype($Count, "integer"
);
$Count
++;
if (
$FP = fopen ($TextFile, "w"
)){
fwrite ($FP, $Count
);
fclose ($FP
);

}

$image = "counterpic.png"
;
$im = imagecreatefrompng($image
);
$red = ImageColorAllocate ($im, 255, 0, 0
);
$blue = ImageColorAllocate ($im, 0, 0, 255
);
$hit = "$Count"
;
$ip = $_SERVER["REMOTE_ADDR"
];

ImageString($im, 2, 18, 1, "www.sr-ultimate.com", $blue
);
ImageString($im, 2, 1, 19, " Your ip: $ip", $red
);
ImageString($im, 2, 1, 30, " Page visited $hit times ", $red
);
header("Content-Type: image/png"
);
Imagepng($im,'',100
);
ImageDestroy ($im
);

?>

3. Save it as index.php or anything u like just with .php extention
4. Now save the 3 files index.php , counter.txt &amp; this image in a folder and upload it through 
FTP to any server supporting php


 
Pages: firstback2 forwardlast

Similar/related articles:


 
  Sponsors