Xona.com Hit Counter Stopped at 7,000,000 Page Views

Tuesday, December 21, 2010
By: Matthew Doucette

We stopped our xona.com hit counter a few days ago. It was over 7,000,000 page views, started on July 27th, 2004. This makes for over 3,000 page views everyday on average, since day one, not including all our domain hack views.

If you scroll to the bottom of our articles, you will see that xona.com use to be a non-profite technology article website, as well as offering Windows freeware and web utilities, all free. Now, of course, we are all about games, and have quite a story in gaming behind us building up.

The reason we stopped our counter was because, due to increased traffic, it continually would lose it's data, despite us locking the counter file. You can look at our code and let us know if you see what we coded wrong:

newcount.cgi:

#!/usr/bin/perl
print "Content-type:text/html\n\n";
open FH, "<newcount.dat";
flock FH, 2;
seek FH, 0, 0;
$count = <FH>;
$count = $count + 1;
close FH;

if ($count <= 2)
{
 # count did NOT work

 open FH2, ">>newcounterror.txt";
 flock FH2, 2;
 seek FH2, 0, 2;
 print FH2 "$count\n";
 close FH2;
 print "Indeterminable\n";
}
else
{
 # count worked

 open FH, ">newcount.dat";
 flock FH, 2;
 seek FH, 0, 0;
 print FH "$count\n";
 close FH;
 $ones = $count % 1000;
 $count = ($count - $ones) / 1000;
 $thousands = $count % 1000;
 $count = ($count - $thousands) / 1000;
 $millions = $count % 1000;
 $count = ($count - $millions) / 1000;
 $billions = $count % 1000;
 if ($billions > 0) { printf("%d,%03d,%03d,%03d",$billions,$millions,$thousands,$ones); }
 elsif ($millions > 0) { printf("%d,%03d,%03d",$millions,$thousands,$ones); }
 elsif ($thousands > 0) { printf("%d,%03d",$thousands,$ones); }
 elsif ($ones > 0) { printf("%d",$ones); }
}

exit;

The newcount.dat file would continually lose its data, the script would print out "Indeterminable" (see the code above), and newcounterror.txt would fill with "1"s (the value of the counter) each on their own line, when our traffic would go up.

For now, we have too much on our plate to worry about hit counters messing up, so we decided to pull it!

Feel free to contact us if you see the problem in our code above.

 

 

About the Author: I am Matthew Doucette of Xona Games, an award-winning indie game studio that I founded with my twin brother. We make intensified arcade-style retro games. Our business, our games, our technology, and we as competitive gamers have won prestigious awards and received worldwide press. Our business has won $180,000 in contests. Our games have ranked from #1 in Canada to #1 in Japan, have become #1 best sellers in multiple countries, have won game contests, and have held 3 of the top 5 rated spots in Japan of all Xbox LIVE indie games. Our game engines have been awarded for technical excellence. And we, the developers, have placed #1 in competitive gaming competitions -- relating to the games we make. Read about our story, our awards, our games, and view our blog.