+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2010
    Posts
    11

    Default Google Analytics MOD (

    I've posted a copy of this tutorial in my blog with syntax highlight for better reading. You can find it here http://www.davidgouveia.net/2010/04/...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:

    Code:
    <!-- Setting Template Variables -->
    shit scriptshit scriptshit scriptshit scriptshit script}
        if(!$_COOKIE['current_style'])
            $_COOKIE['current_style'] = 'grid_view';
    {/php}
    Add below:

    Code:
    <!-- Google Analytics -->
    {show_analytics|html_entity_decode}
    2nd – includes/common.php. Find:

    Code:
    $Smarty->register_function('cbtitle','cbtitle');
    Add below:

    Code:
    $Smarty->register_function('show_analytics', 'show_analytics');
    3rd – Open includes/functions.php. Find:

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

    Code:
        /**
        * Function used to load Google Analytics - me( at )davidgouveia.net
        */
        function show_analytics()
        {
            global $Cbucket;
            // code to convert html entities back usefull code.
            echo base64_decode($Cbucket->configs['google_analytics']);
     
        }
    4th – Open admin_area/main.php. Find:

    Code:
        'gravatars',
    Add above:

    Code:
        'google_analytics',
    Find:

    Code:
        $value = mysql_clean($_POST[$field]);
        if(in_array($field,$num_array))
    Add above:

    Code:
        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:

    Code:
                <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:

    Code:
             <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 ).

  2. #2
    Join Date
    Jan 2010
    Location
    Denmark
    Posts
    860

    Default Re: Google Analytics MOD (

    Hey there, thanks for sharing!

    It looks like something went pretty haywire, think it was the forum going crazy about the first section, people should check with the blog-post for the correct code to be sure it's correct.

  3. #3
    Join Date
    Aug 2008
    Posts
    106

    Default Re: Google Analytics MOD (

    My question on my admin I just have a test area box named google analytics what i supposed to add inside because. there is noting on my site where i can see the data i opened an account on google analytics and paste the code that supposed to be after body there. there is nothing more in admin just that .. can you explain with more details thanks

  4. #4
    Join Date
    Aug 2008
    Posts
    106

    Default Re: Google Analytics MOD (

    never mind but explain me how supposed to work

  5. #5
    Join Date
    Aug 2008
    Posts
    106

    Default Re: Google Analytics MOD (

    may be the base 64 is my problem

  6. #6
    Join Date
    Mar 2010
    Posts
    4

    Default Re: Google Analytics MOD (

    you have to add the record 'google_analytics' to your database as well (in the xx_config table)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts