Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  agyat : (24 May 2013 - 05:15 PM) O Dear, Where Are You? Without Your Words This Sb Is ..
@  agyat : (23 May 2013 - 01:23 AM) Wow! Mr. Sb Back Home.
@  OpaQue : (23 May 2013 - 12:44 AM) Ting
@  OpaQue : (24 April 2013 - 02:44 PM) I guess, Time to run Mycent script.
@  OpaQue : (24 April 2013 - 02:43 PM) wow.. not much spam. except habatt posting lot of links.. :P
@  yordan : (23 April 2013 - 01:04 PM) You're welcome, agyat. Nice to have been helpful. Second lesson: try full words, "you" instead of "EW".
@  agyat : (23 April 2013 - 05:03 AM) @YORDAN: tHANK EW FOR YOUR FIRST LESSON.   :D
@  yordan : (22 April 2013 - 09:43 PM) @agyat : "why don't you help me", or "please help me", or "please teach us"
@  yordan : (22 April 2013 - 09:42 PM) welcome back, velma
@  velma : (22 April 2013 - 07:51 AM) **yawns** Good to be back, wonder what is going on here :)
@  agyat : (22 April 2013 - 03:50 AM) Oh! so, why don't help me learn english..
@  yordan : (21 April 2013 - 08:38 PM) The goal mentioned by shiu : "learning english, learning computer"
@  agyat : (21 April 2013 - 06:31 PM) WHAT GOAL?
@  yordan : (20 April 2013 - 10:39 AM) yes, that's our goal. simultaneouly learning English and teaching/learning computer using.
@  shiyu : (20 April 2013 - 07:30 AM) learning english,learning computer
@  yordan : (19 April 2013 - 01:11 PM) Oh, I see, it's just a trick in order to force people looking at your texte. Somehow smart, maybe.
@  agyat : (19 April 2013 - 02:54 AM) And of course I know it is not SEO friendly.
@  agyat : (19 April 2013 - 02:52 AM) There may be two possible answers for that ....


1) Shout was posted using mobile keypad.

2) To force people read content carefully and/or with more concentration.
@  agyat : (19 April 2013 - 02:49 AM) There may be two possible answers for that ....
@  yordan : (18 April 2013 - 09:35 PM) however, why this mixing of capital letters in the middle of your text?

Replying to Easy Visitor Counter


Post Options

    • Can't make it out? Click here to generate a new image

  or Cancel


Topic Summary

Posted 16 May 2011 - 12:08 PM

to VandanaEasy Visitor CounterUse $_SERVER['REMOTE_ADDR'] to check and compare the ip address. If you know the ip address of the so called your enemy (bloked ip ) if he traced then use header to redirect some other site-reply by Manoj Updhyay

 


Posted 19 February 2010 - 06:31 AM

How to block the internal ip address in hit count of the website?Easy Visitor CounterHow to block the internal ip address in hit count of the website?-question by vandana

magiccode9

Posted 01 June 2008 - 04:52 PM

But sometime that only a value then it need to be read from a db may waste it space.
If the code was used on small sites would be fine.

Writing to file just as to database.
But instead I am thinking about the code changed a bit may be better by first initial the variables.

$count = 0;
$file = null;

if ( ... )
....

FirefoxRocks

Posted 25 May 2008 - 03:55 PM

Yes I think that a database would be a better idea as it requires a password to access and is less work to use than by writing to a file each time. This is because unless you have specific permissions set, anyone can read that file and that may not be a good thing.

With a database you can do so much more though, such as IP logging, browser (user-agent) identification, etc. This may or may not be useful but to most people it should be because it helps efficiently target their audience in some cases.

sparkx

Posted 25 May 2008 - 03:43 PM

That seems like a lot of work to count the number of visitors. Also how safe is it? I get a little worried when you try to edit actual files rather then using a database. This is how I would count visitors using a database:
<?php 
//Update
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$row = mysql_fetch_array(mysql_query("SELECT * FROM info WHERE ID='1'") or die(mysql_error()));  
$count = $row['count']+1;
$result = mysql_query("UPDATE info SET count='$count' WHERE ID='1'") or die(mysql_error());  

//Display
echo 'Visitors: <font color="#FF6600">'.$count.'</font>.';
?>
This method is great and very secure unless you don't have MySQL access. Otherwise your script would be the only option and would work good as long as you made sure your server only allowed editing of that file only and only from the server itself (not an external server/hacker).

Your script is still good to know though because when you get into more advanced things you might need to actually save a file to the server (for example when someone is installing your open source code on their server).

Sparkx

jsuthers

Posted 24 May 2008 - 08:58 PM

Add this to the page you want to count the visitors on:

<?php
$logfile="counter.txt";
$returnpage = htmlentities($_GET['count']);
if (! @$file = fopen($logfile,"r+"))
{
$count="1";
}
else
{
$count = @fread($file, filesize($logfile)) or $count=0;
fclose($file);
$count++;
}
$file = fopen($logfile,"w+");
fputs($file, $count);
fclose($file);
?>

The link to the page you want to count the visitors should be www.yoursite.com/yourpage.php?count
The visitors numbers will be saved in counter.txt

Add this to the page where you want to show how many visitors the page have had:
<?php
$logfile="counter.txt";
if (! @$file = fopen($logfile,"r+"))
{
$count="0";
}
else
{
$count = @fread($file, filesize($logfile)) or $count=0;
fclose($file);
}
echo 'Visitors: <font color="#FF6600">'.$count.'</font>.';
?>

Review the complete topic (launches new window)