Contents
Wiki Help |
There are two ways to add the activation code to your web pages.
Manually Adding the Activation Code To Every PHP PageNow that we've tested BBClone and found it working, we can go on to register visits. Simply add the manual activation code like you used for the test.php file to the end of the php files you want to be counted, and change the title (if you're including this line) and change the path to the BBClone installation directory to be correct. The "traditional" method requires *.php pages. You also need to have permissions to run PHP (of course). If you want to put your code somewhere else the file needs to be included into a *.php file eventually, so the server recognises it and is able to run the PHP interpreter. If BBClone's activation code is placed in a *.html or *.htm file, it will simply be sent to the browser and appear on the web page. The page won't get counted. For BBClone to work with these files, we must say to the server something which amounts to "look through html and htm files for php code and execute any code you find, before sending the web page". This may be done with a command in .htaccess on an Apache webserver (described later on this page). If you don't have access to .htaccess files or are running BBClone on a Windows server, you must use *.php files. (This is as easy as renaming your htm or html files, and then adding the manual activation code to the end of the file.) Not all code in a PHP file is necessarily PHP code. Sometimes passages of code will be pure html. Each PHP code block is started with "<?php" and ended with "?>". If you want to add the actiavtion code within PHP code, you simply use: define("_BBC_PAGE_NAME", "Test");
define("_BBCLONE_DIR", "bbclone/");
define("COUNTER", _BBCLONE_DIR."mark_page.php");
if (is_readable(COUNTER)) include_once(COUNTER);
test activation code within a php block (or without the page title line, see Testing BBClone for details.) Remember that the relative path in green (bbclone/) has to be from the page you're putting the code into, to the bbclone installation directory. If you're outside of such a block (and find nothing but html tags) then you need to use the php enclosings so the server knows it has to parse this passage as PHP code. Automatically Adding the Activation Code To Every PHP Page (Apache webservers only)If you run an Apache server and are allowed to use .htaccess you can add code to existing .htaccess files, or create new .htaccess files. The commands in .htaccess files affect files in the same directory as the .htaccess and all subdirectories. Using the following commands, your webserver will add the BBClone activation code to *.php before parsing and sending them. (See next section for counting .htm or .html files.) Create a file "count.php" to contain the BBClone activation code. Create this file and add the following: <?php count.php Highlighted in blue is the absolute server path to the BBClone directory. Relative paths are not allowed here. The absolute server path is how the server "sees itself", and does not refer to how someone might browse to the directory in the internet. Notice that the path uses the forward slash Go to your bbclone directory, open index.php in your favorite editor and add these lines: echo "<?php\n"
."define("_BBCLONE_DIR", ""
.dirname(__FILE__)."/");\n"
."define("COUNTER", _BBCLONE_DIR.""
."mark_page.php");\n"
."if (is_readable(COUNTER)) include_once(COUNTER);\n"
."?>\n";
determine your absolute path Upload it to your webserver, point your browser to it, copy and paste the output and save it into a file as "count.php" (to stick with our example). Don't forget to remove the line from index.php afterwards else it will be displayed each time you call your stats. Now add the following to your chosen .htaccess (to count all pages on your site, add to the .htaccess file above or in your www-root directory): <FilesMatch "\.(php)$">
php_value short_open_tag "Off"
php_value auto_append_file "/the/path/that/leads/to/count.php"
</FilesMatch>
automatic .php counting Note that if your BBClone directory is below this .htaccess file in the document tree, visits to the BBClone stats display pages will also be counted, since they are PHP files. Automatically Adding the Activation Code To Every HTML Page (Apache webservers only)BBClone is a PHP application, and your server needs to parse the activation code snippet as PHP code. Usually it knows to look through a file for PHP code because a file has a .php extension as part of the filename. But on an Apache webserver, you can tell the server to look through .htm and .html files for PHP code as well, with an extra command in .htaccess. First create the count.php file as described above. Then add the following lines to your .htaccess (in addition to the ones above, if you like): AddHandler php-script .htm .html automatic .htm(l) counting The NOTES: Now the following will happen: Each time someone calls one of the ".htm" or ".html" pages the code snippet with the counter code will be automatically appended. BBClone will automatically create a page title derived from the file's path which will be used in the page stats. Next: Configure BBClone using config.php << Testing BBClone | Help Index | Configuration Introduction >> |