Home User CP Browse Members Calendar Register Today!  
Get New posts Faq / Help?
   

Not A Member Yet? Register today and become part of the community.

Go Back   Profuse Host Forum > World Wide Web > Programming / Scripting / Coding Forum > PHP

PHP The most widely used server-side programming language for web applications.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-06-2007, 11:53 AM
Ryan56
Status: Offline
Member
 
Join Date: Aug 2006
Posts: 58
Ryan56 is on a distinguished road
Default How To Make A Hit Counter

This simple script creates an image that can be used on any page to display a hit counter. A session variable is used to ensure that the counter only advances once per browser session. In your html, put an <img> tag for the image, such as this one
PHP Code:
<img src="counter.php" alt="" style"border-style:inset; border-width: 3; left: 20; top: 20; position: absolute;"
2) Now make a new file name "counter.php" without the " " in the directory where your site is.

3)edit the counter.php file

4) put the following code in it

PHP Code:
<?php
session_start
();
if (!
session_is_registered(\\\\\\\\\\\'hit_cnt_entry\\\\\\\\\\\')) {
session_register(\\\\\\\\\\\'hit_cnt_entry\\\\\\\\\\\');
 "0";
} else {
 "1";
}

 \\\\\\\\\\\'counter.dat\\\\\\\\\\\';

if (
is_writable()) {

 fopen(,"r");
 fread(filesize ());
fclose();

if (
 == "0") {
 fopen(,"w");
  1;
fwrite(,"");
fclose();
}

 = (strlen() * 8) + 8;

 = @imagecreate (18);
 imagecolorallocate (255255255);
 imagecolorallocate (000);
imagestring (442);
imagepng ();
imagedestroy();

}
?>
the counter value in stored in a different file so

5) open notepad and put a number in it for example "100" this will be the number of hit that will be shown on the counter.

6) name the file counter.dat and upload it to the name directory where you created the counter.php file

and that's it your finished

You can cheat at any time just by changing the number in the counter.dat with notepad. i have also attached the counter.php and the counter.dat file ina zip


here is my finished file http://www.gmgraphics.profusehost.ne...ter/index.html
Attached Files
File Type: zip counter files.zip (968 Bytes, 7 views)

Last edited by Ryan56 : 03-07-2007 at 11:05 AM.
Reply With Quote

  #2 (permalink)  
Old 11-04-2007, 10:26 PM
spoweb
Status: Offline
Member
 
Join Date: Nov 2007
Posts: 51
spoweb is on a distinguished road
Default

I made it in the file manager, but I placed in the "body" tags. There's an x where the image should be. What can I do to make the image appear? Should I take out ALL of the HTML code that was in there to begin with and leave it as a pure PHP file?
Reply With Quote

  #3 (permalink)  
Old 06-08-2008, 02:01 PM
bokepwap
Status: Offline
Junior Member
 
Join Date: Jun 2008
Posts: 14
bokepwap is on a distinguished road
Default

this is simple php counter visitor,
this code make a counter per days
PHP Code:
    <?php
     
"counter.txt";
    
 fopen("a+");
    
 filesize();
    
 date("d/m/y");
    if (
==0)
    {
    
 1;
    
fwrite(."-".);
    }else{
    
 fread();
    
 explode("-");
    
ftruncate(0);
    if(
==[0])
    {
    
 [1]+1;
    
fwrite(."-".);
    }else{
    
 1;
    
fwrite(."-".);
    }
    }
    
fclose();
    
?>
__________________
Make Profusehost The Best Free Webhosting
Reply With Quote

Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
counter strike - condition zero skins? RUSSIAN POWER General/PC Gaming 0 03-26-2008 03:48 PM
need help resizing my html page for motd in counter-strike svsnipa HTML/CSS/DHTML 1 09-12-2007 02:51 PM
How to make your counter-strike server better! vsnfsn General/PC Gaming 1 09-09-2007 03:15 AM
Steam and Counter-Strike cooper General/PC Gaming 4 03-29-2007 12:45 PM
Counter Strike? BOoBOo General/PC Gaming 18 03-15-2007 05:16 AM


All times are GMT -7. The time now is 02:39 AM.

Skin Design By vBSkinworks



Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Sponsored by Web Hosting


Profuse Solutions LLC

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80