Google analytics MOD to ClipBucket.

Summary: with this mod you will be able to insert any script into your clipbucket. I’m using it to manage google analytics.

1st – Open styles/cbv2new/layout/global_header.html. Find:

<!-- Setting Template Variables -->
{php}
	if(!$_COOKIE['current_style'])
    	$_COOKIE['current_style'] = 'grid_view';
{/php}

Add below:

<!-- Google Analytics -->;
{show_analytics|html_entity_decode}

2nd – includes/common.php. Find:

$Smarty-&gt;register_function('cbtitle','cbtitle');

Add below:

$Smarty-&gt;register_function('show_analytics', 'show_analytics');

3rd – Open includes/functions.php. Find:

	/**
	 * Function used to load clipbucket title
	 */
	function cbtitle($params=false)
	{

Add above:

	/**
	* Function used to load Google Analytics - me( at )davidgouveia.net
	*/
	function show_analytics()
	{
		global $Cbucket;
		// code to convert html entities back useful code.
		echo base64_decode($Cbucket-&gt;configs['google_analytics']);
 
	}

4th – Open admin_area/main.php. Find:

	'gravatars',

Add above:

	'google_analytics',

Find:

	$value = mysql_clean($_POST[$field]);
	if(in_array($field,$num_array))

Add above:

	if($field == 'google_analytics')
		$value = base64_encode($_POST['google_analytics']);
	else

(the “else” MUST be in the line immediately above “$value = mysql_clean($_POST[$field]);”).

Finally, open /admin_area/styles/cbv2/layout/main.html. Find:

            <tr>
              <td valign="top">Meta Description</td>
              <td valign="top"><textarea name="description" id="description" cols="45" rows="5">{$row.description}</textarea></td>
            </tr>

Add below:

       	    <tr>
              <td valign="top">Google Analytics</td>
              <td valign="top"><textarea name="google_analytics" id="google_analytics" cols="45" rows="5">{$row.google_analytics|base64_decode|html_entity_decode}</textarea></td>
            </tr>

Done! You shoud see another option under Web Settings.

Tested under ClipBucket 2.0.6.

PS: I’m using base64_encode/decode because I want to save the script as its original values and I need to avoid using functions like mysql_clean() to sanitize the code. By saving it as a base64 string I avoid potential malicious SQL injection problems. I’m sure there are other ways of doing it but this works OK (I think :p).

3 comments

  1. Is working fine. Just I have to change

    $Smarty->register_function(‘show_analytics’, ‘show_analytics’);

    to

    $Smarty->register_function(‘show_analytics’, ‘show_analytics’);

  2. All users, If you are installed clipbucket verstion 2.6 , in your site, dont try for this methods. I dont know about clipbucket verstion 2.0.6 version . it will destroy your code, site shows completes errors with particular folder and line errors. strong advice dont try for 2.6 version.

    1. Hello Aravin,

      As you probably know, 2.0.6 is a very old version of clipbucket so it is normal that this mod won’t work. It has been a while since the last time I used clipbucket but if I manage to have some spare time I will reinstall it and write another snippet to newer versions of clip bucket. 😉

Leave a Reply

Your email address will not be published. Required fields are marked *