How to prevent BBClone from logging your own visits

Introduction

BBClone is essentially a counter written in PHP that logs information about the users who visit your site. It generates useful data like referrers, browser info and the like. You can read more about its features at the BBClone website.

My problem

In its current incarnation, BBClone can prevent logging of visitors with a specific IP address, or with an IP mask. It can also prevent logging of visitors who come from certain locations/URLs. The IP mask feature didn't work for me as my IP address changes everytime I reboot my cable modem. And being one of those interactive designer types, I use many different machines and browsers, both at home and at work, to check, modify and test my site(s).

A crude fix

To prevent my browsers from logging my own hits, I created a small PHP page which I visit once in all my browsers. This page creates a cookie specific to my own website. Now, for the pages on my website which invoke BBClone to log visits, I put a small ‘wrapper code’ around the BBClone code in each page. This ‘wrapper code’ checks for the existence of the above-mentioned cookie in my browser and only logs visitors who don't have this cookie installed.

It's a very simple and trivial piece of modification which suits my purposes. And it is a very common technique too. If you want to use it for yourself, please follow the instructions that follow.

Instructions to fix up for yourself a cookie that BBClone won't bite

For simplicity and clarity, let's assume your website resides at example.com, the page you are tracking is named index.php and that your BBClone directory is at /bbclone (i.e you access your BBClone via http://www.example.com/bbclone/). And of course, I am assuming you have followed the installation procedures for BBClone and have it working already.

  1. First, we need to a utility that can create delicious cookies for us.

    Download this PHP script and rename it to cookie-box.php (or any name you so please, as long as it ends in PHP). This is a simple script I wrote that can create, delete and view cookies in your browser.

  2. Open cookie-box.php in your favourite text editor. You will see the following lines at the top of the file

    	define("__MY_COOKIE_NAME__", "DNC-Block-BBClone-Log");
    	define("__MY_COOKIE_VALUE__", "TRUE");
    	define("__MY_EXPIRE_DATE__", mktime(0, 0, 0, 3, 14, 2026));
    	define("__MY_PATH__", "/");
    	define("__MY_DOMAIN__", ".example.com");
    				

    These are the things you have to change for your own usage:

    Change the name of the cookie: DNC-Block-BBClone-Log
    I used DNC-Block-BBClone-Log to identify the cookie from my site. You could change the DNC- part to some prefix that relates better to your site, or give it a new name altogether, like Who-Is-Your-Daddy, or whatever. (Please keep it simple; i don't know how the script will react if you put and '&' in there.)
    Please take note of this name which you gave your cookie — we'll need it later.
    Modify the path: / (slash)
    This is the part where you fill in the 'sub folder' where your site resides. If your website URL is, for example, http://www.website.com/~joe/, then the appropriate value you should use is /~joe/.
    Modify the domain name: .example.com
    This is the part where you fill in your domain name detail. Note the '.' (dot) in front. If your website URL is, for example, http://www.website.com/~joe/, you should modify yours to show .website.com.
  3. Upload cookie-box.php to your server. It can go into any directory that can be accessed via your browser. I just put mine in the /bbclone directory.

  4. Fire up your browser and point it to cookie-box.php on your server, e.g http://www.example.com/bbclone/cookie-box.php.

  5. Click on "Set the cookie" and you will get a confirmation of the name of the cookie, which you had set earlier.

  6. Click on "View cookie details" to double check the name. If it is the same name as how you had customised it earlier, then you have a working cookie.

  7. Now, open up index.php on your website which contains your BBClone code fragment. Let's assume your BBClone code is like so :

    	<?php
    	define("_BBC_PAGE_NAME", "Test_Page");
    	define("_BBCLONE_DIR", "bbclone/");
    	define("COUNTER", _BBCLONE_DIR."mark_page.php");
    	if (is_readable(COUNTER)) include_once(COUNTER);
    	?>
    				
  8. Here's where it all ties together: We're going to use the cookie that we installed earlier and check if it exists in the browser that is requesting the page. If the cookie isn't available (or set), we'll let BBClone log the visitor. That means, that if the cookie is available (or is set), you are probably the one viewing the site from your own browser amd so nothing will be logged.

    We modify the above code just slightly to look like this:

    	<?php
    	if (!isset($_COOKIE['DNC-Block-BBClone-Log'])) {
    		define("_BBC_PAGE_NAME", "newsreader");
    		define("_BBCLONE_DIR", "../governer/bbclone/");
    		define("COUNTER", _BBCLONE_DIR."mark_page.php");
    		if (is_readable(COUNTER)) include_once(COUNTER);
    	}
    	?>
    				

    Just replace DNC-Block-BBClone-Log in the code fragment above with the name you gave your cookie earlier (please make sure there single quotes ' ' are intact) and you are done!

Now, that was really long winded

I hope this helps someone, as much as it helped me. This is my first time writing a pseudo-instruction manual, so please let me know if its over the top or if there are any errors. All feedback is most welcome; please email me at .

And yeah, BBClone rocks.