An alternative method to use BBclone counter

Discussion corner for Developers of Serendipity.
Post Reply
Andyman77
Regular
Posts: 92
Joined: Mon Oct 17, 2005 2:50 pm
Location: London
Contact:

An alternative method to use BBclone counter

Post by Andyman77 »

Hiya,
Ok, I have tried quite a few methods to get BBclone to track users, I am at the moment using the .htaccess method which well only tracks the main page but not which page they went to, so lots of the stats is missing.
I found a bit of code from the Gallery2 application that allows you to use BBclone with mod-rewrite enabled and works well.
here's the code:

Code: Select all

<?php
require_once(dirname(__FILE__) . "/main.php");

if (!defined('GALLERY_CONFIG_DIR')){
	define('GALLERY_CONFIG_DIR', dirname(__FILE__));
}

if (!defined("_BBCLONE_DIR")){
	define("_BBCLONE_DIR", GALLERY_CONFIG_DIR . "/bbclone/");
}

$Title = "";
$Title = pathway($_GET['g2_itemId']);
if (strlen($Title) > 0){
	define("_BBC_PAGE_NAME", $Title);
	define("COUNTER", _BBCLONE_DIR."mark_page.php");
	if (is_readable(COUNTER)) require (COUNTER);
}

function pathway($g2_itemId){
	//first get parent albums
	if (empty($g2_itemId)){
		//return "Gallery Root";
		$g2_itemId = 7;
	}
	if (!class_exists('GalleryCoreApi')){
		return "";
	}
	list ($ret, $parents) = GalleryCoreApi::fetchParentSequence($g2_itemId);
	if ($ret) { $parents = array(); }
	$parents[count($parents)+1]=$g2_itemId;
 	$g2_s=0;
	//gogogo
	$path = "";
	$extend = "";
	$seperator = " -> ";
	foreach($parents as $items){
		list ($ret,	$item) = GalleryCoreApi::loadEntitiesById($items);
		if (GalleryUtilities::isA($item, 'GalleryItem')){
			$title = "";		
			if (!$ret && $item){
				if ($item->getTitle()){
					$title = $item->getTitle();
				}else{
					$title = $item->getPathComponent();
				}
			}
			$titles[$item->getId()] = preg_replace('/\r\n/', ' ', $title);
	 
			//let's switch again
			if($g2_s == 0 AND count($parents) ==1){ //first and last		
				$path .= $extend.$title;
				$extend = $seperator;
			} elseif($g2_s == 0 AND count($parents) !=1) {// first but not last
				$path .= $extend.$title;
				$extend = $seperator;
			} elseif($g2_s == count($parents)-1 AND $g2_s == 1){// second and last	
				$path .=$extend.$title;
				$extend = $seperator;
			} elseif($g2_s == count($parents)-1){ // not second but it is last
				$path .=$extend.$title;
				$extend = $seperator;
			} elseif($g2_s == 1) {// everything in between			
				$path .=$extend.$title;
				$extend = $seperator;
			} else {
				$path .=$extend.$title;
				$extend = $seperator;
			}
		}
		$g2_s++;
	}
	if (!empty($_GET['g2_view']))
		if ($_GET['g2_view'] == "imageframe.CSS" ||
			$_GET['g2_view'] == "core.DownloadItem" ||
			$_GET['g2_view'] == "rewrite.FileNotFound")
			return "";
		else
 		    if ($_GET['g2_view'] != "core.ShowItem")
			$path .= " * " . $_GET['g2_view'];
	if (!empty($_GET['g2_subView']))
		$path .= " ~ " . $_GET['g2_subView'];
	return $path;		
}//end pathway function
?>
Obviously, there is a lot of Gallery2 references and a lot of code that will not be needed, but would it be possible to translate this for serendipity ?

More info on code from here : clicky
Serendipity - Site, finished ;)
Mine that is ... so lots of nonsensical Stuff
Post Reply