bbclone - htaccess

Intro

    A couple of years ago, late 2004, I decided it would be nice to know how many people were accessing my Web Pages. I was just looking for a counter and came across this piece of work. bbclone

    BBclone is a web counter written in PHP and gives a detailed view of the visitors of your web site by displaying the nth last users (and the data they provided, like their IP, browser and so on) that visited the web site, not just showing a number of visitors. For each visitor, BBClone can display IP address, hostname, operating system, robots, browser, referring URL, country, search engine keywords, hostname resolution, time statistics, proxy workaround and display, referrer and ip address filtering. Live domo available on the website.
Ref: Big WebMaster

    Now here it is, early to mid 2008, and my counter has ceased to work. Upon approaching my fabulous, and very helpful ISP, I was informed that they had moved to PHP5 and if I had been reading the e-mails they sent I would have known that. Even though this sounds harsh in print, they were very cordial and kind about it. Matter of fact, Don and Joshua both helped me get things straightened out and working again. Suffice it to say that I put the PHP5 version of bbclone out on my site, on my ISP, and still had a problem.

1. suPHP Set Up

    Turns out that in addition to PHP5, my ISP, HostRocket.com, implemented suPHP for better control and security. This "security" caused problems in bbclone operation. This led to a search of the Net and the bbclone forum. Through this search I found Olliver Wichmann who had worked on bbclone in the beginning and had some insights. He helped me to finalize the info on this page so that, hopefully, it will be useful to someone else.

The .htaccess file:

suPHP_ConfigPath /home/username/
RemoveHandler .html .htm
AddHandler php5-script .htm .html
AddType application/x-httpd-php5 .htm .html
<FilesMatch "\.(html?)$">
php_value short_open_tag "Off"
php_value auto_append_file "/home/username/public_html/count.php"
</FilesMatch>
Note, that suPHP_ConfigPath is specific to suPHP and not available in general. Also please note that you will have to put your own paths in. Check with your ISP.

    When running suPHP, PHP is running as a CGI binary and not an Apache module. Therefore, an AddHandler and AddType are both needed.

suPHP options
It seems, that suPHP is used as an Apache module (whilst php is running as cgi-binary). Therefore it might be useful to point out that suPHP_ConfigPath is an option used by mod_suphp:
   http://www.suphp.org/Documentation-Module-Configuration.en.html

RemoveHandler is only necessary in case a handler for htm(l) files has been defined in httpd.conf or in another .htaccess of a higher directory level. As not everyone is Apache savvy, it might be useful to link to the Apache documentation explaining that directive, so those interested in more details can study the source of your statement:
   http://httpd.apache.org/docs/2.2/mod/mod_mime.html#removehandler

2. Code Added to index.php

    This code is to be placed at the beginning of your main, or top, index file. Usually index.php.

<!-- Visitor counter code. Created by the Good Guys at http://www.bbclone.de -->
<?php
define("_BBC_PAGE_NAME", "XXMain");
define("_BBCLONE_DIR", "bbclone/");
define("COUNTER", _bbclone_dir."mark_page.php");
if (is_readable(COUNTER)) include_once(COUNTER);
?>

3. The count file

    The following code is placed in a file called count.php.

<?php
define("_BBCLONE_DIR", "/home/username/public_html/bbclone/");
define("COUNTER", _BBCLONE_DIR."mark_page.php");
if (is_readable(COUNTER)) include_once(COUNTER);
?>

    There is also a Wiki Help Page at: http://help.bbclone.de/ that answers a lot of questions.

4. My Conclusion

    Through all this, embarrassment on my part, it seems that in the beginning, when I was trying to be nice and helpful, I caused these problems later. The key fix, which was added by Joshua, was the line:
   AddType application/x-httpd-php5 .htm .html
I had removed this line way back when I first implemented bbclone with the thought that it would cut down on server processing and speed up operations. As it turns out, I was wrong.

   The other key line in the fix was from Don:
  suPHP_ConfigPath /home/username/

    




Copyright © 2008-2008 All rights reserved.