# ******************************************************************************
#   PHPnuke Tracking v1.0
#
#   for PHPnuke 5.5
#
#   Version 1.0	   17-03-2002
#
#
#   Download at: http://www.wstyle.org
#   
#   This is a hack to log all pageviews of your PHPnuke website. It
#   includes a program to analyse the tracking log data and display
#   it with the common object titles from your PHPnuke database.
#
#   Copyright (C) 2002 by WebStyle http://www.wstyle.org
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
# ******************************************************************************


FUNCTIONS PHPnuke TRACKING v1.0

- easy analyse tool for your nuke website traffic as an module in the
  administration area
- identify users by user-id and tracking id cookie
- store every singe page view in your nuke website in a new database table
- analyse pageviews and group it by time, visit, user, pages, ip, trackid
- select different periods to analyse like defines hours, days, free periods
- delete old tracking data
- track external links by using TRACKLINK.PHP also (see documentation below)
- track your Ebay auction
- configurable exclude rules for tracking by IP, username or URL
- configurable default menu
- dutch, english, french, german, italian, spanish language file
- CSS classes for design changes


INSTALLATION

There are only four easy steps to install PHPnuke tracking:

1.  Copy the files of the tracking installation to your PHPnuke website:

    /trackhack.php                    ===>   /trackhack.php
    /tracklink.php                    ===>   /tracklink.php
    /tracktest.php                    ===>   /tracktest.php
    /admin/case/case.tracking.php     ===>   /admin/case/case.tracking.php
    /admin/links/links.tracking.php   ===>   /admin/links/links.tracking.php
    /admin/modules/tracking.php       ===>   /admin/modules/tracking.php
    /images/admin/tracking.gif        ===>   /images/admin/tracking.gif

    The file "trackhack" have to be placed in the root folder of your PHPnuke
    website. You find the quoted subdirectories as subdirectories in your root
    folder.


2.  Copy the content of the files:
    /admin/language/lang-english-track.php  into the file  /language/lang-english.php
    /admin/language/lang-dutch-track.php   into the file  /language/lang-german.php
    ... same for other languages

    Add the content of that files after the big comment block at the beginning
    of the languages files.


3.  Install the database table "nuke_tracking" from the file

    /sql/tracking.sql

    You can use MYSQL to import that file (example):

    C:\mysql\bin>MYSQL %dbname% < tracking.sql

    (you must use your path and enter your databasename instead of %dbname%)

    OR    

    use phpMyAdmin and execute the content as SQL command with phpMyAdmin. That
    will create the database table into witch the tracking information is stored.

    In phpMyAdmin click on the database name at the right side navigation. Then 
    you see a list of your tables in the database installation. At the end of 
    that list is an text box "SQL command...". You can insert the commands via
    cut and past and push the button "OK" or you can push at the button "..."
    next to the field "or file" and insert the filename "tracking.sql" to
    transfer the commands via the file directly.


4.  Modify the original file mainfile.php with the following change.
    I'm sorry but at this time there is no way to include such a function
    like tracking without any modification. We would need configurable
    events to add event triggerd functions. 

    
    IT IS ONLY ONE LINE YOU HAVE TO ADD TO AN ORIGINAL NUKE FILE. IF YOU
    DONT WANT THE ADDON MODULE ANY MORE YOU CAN EASILY DELETE THAT ONE LINE.


    You must insert in "mainfile.php" at the end of the file the line
    'include("trackhack.php");      # Tracking'. After that it looks like:

    ...
    CloseTable2();
    include("footer.php");
    die("");
    }

    include("trackhack.php");               # Tracking  <=== ONE NEW LINE !!!
    ?>
    

5.  You have finished the installation. Now call some pages of your nuke
    website. The TRACKHACK.PHP is included in every page how use the
    mainfile.php. Thats normaly every PHPnuke page. TRACKHACK will now collect
    the pageview data and store it in the table nuke_tracking.

    Change to the administration menu. There is a new function Tracking Show to
    analyse the stored tracking data.



OPTIONAL INSTALLATION STEPS / CONFIGURATION / FUNCTIONS

1. Modify your default period menu

   You can edit your default period menu in the file TRACKING.PHP
   Edit the following array to change your periods or to add new ones.

   ...
       1 => array(
        "text"   => _TRACK_LAST." 1 "._TRACK_HOURS,
        "timef"  => date("Y-m-d H:i:s", time()-3600*1)      # today - 1 hours
    ),
       2 => array(
        "text"   => _TRACK_LAST." 4 "._TRACK_HOURS,
        "timef"  => date("Y-m-d H:i:s", time()-3600*4)      # today - 4 hours
   ...


2. Exclude tracking for IP, users or URLS

   You exclude tracking if you modify the file TRACKHACK.PHP
   Insert IP, username or urls in that file
   
   ...
  # Exclude that IPs
  $exclude_ip  = array(
    "127.0.0.1",
    "192.168.0.0",
    "255.255.255.0");

  # Exclude that nuke usernames
  $exclude_user  = array(
    "????????",
    "antarcon");

  # Exclude url containing that strings
  $exclude_url  = array(
    "/admin.php?op=trackingshow",
    "/dummy.php");
   ...

   You can temporarily deactivate the tracking if you set the variable
   $hf_exclude = '1';     # the default is '0'.

   You can deactivate the use of cookies to identify annonymus users
   if you set the variable
   $track_cookie = '0';   # default 1 / use cookies to identify users?   

3. Tracking of external links. It is possible to track external links
   like headlines, ... also. For that case please use the redirection
   file TRACKLINK.PHP. Then you will find that pages in the analyse too.
   
   The optional query parameter to give over the url is "url="

   If you want a link to the page www.phpnuke.org, then use the
   following as an example:

   href="/tracklink.php?url=www.phpnuke.org"                      or
   href="/tracklink.php?url=http://www.phpnuke.org"               or
   href="/tracklink.php?url=www.phpnuke.org?op=download&lid=26"   or  
   href="/tracklink.php?www.phpnuke.org?op=download&lid=26"       
   
   It is not nessecary to translate "&" or to urlencode the string. 
   Thats the work from tracklink.php

   Here are some modification examples for tracking different links
   in PHPnuke:


   Tracking EXTERNAL HEADLINES:
   ===========================
   If you want to track your external headlines look at that modification
   example for the file MAINFILE.PHP

   search for function 'function headlines($bid)'

   Insert the following new line in that function as shown below:

   ...
         $items = explode("</item>",$string);
         $content = "<font size=\"2\">";
         for ($i=0;$i<10;$i++) {
       $items[$i] = ereg_replace("http://","/tracklink.php?url=http://",$items[$i]);  # <=== NEW LINE
       $link = ereg_replace(".*<link>","",$items[$i]);
       $link = ereg_replace("</link>.*","",$link);
       $title2 = ereg_replace(".*<title>","",$items[$i]);
   ...

   
   Tracking YOUR EBAY AUCTION :-)
   ==========================  
   And as special gift. Track the views at your ebay auctions. I doesnt know
   for what that is good. But it is possible.

   Example:
   <a href="http://www.antarcon.de/tracklink.php?url=http://www.antarcon.de/div/cullmann1.jpg">
   <img src="http://www.antarcon.de/tracklink.php?url=http://www.antarcon.de/div/cullmann1_s.jpg" border="2">

   Use that code to insert a picture in your ebay article text. The href Link to 
   your big picture will track clicks on your picture. The IMG Tag will link 
   your small picture into your article detail text and will track every 
   view at your article details. After doing that you can analyse the 
   ebay traffic at your article in PHPnuke tracking. Even with the 
   IP and cookie (trackid) of single visitors.


4. You can use the following CSS classes to match your design

   <p class="pn-decidelink">          Questionslink YES / NO
   <p class="pn-tabheader">       table header line
   <p class="pn-tabcontent">        table content
   <p class="pn-addinfo-small">       additional info small (date period)
   <p class="pn-linkmenu-content">    period menu upper content area

   It is not nessesary to create that CSS-classes. They are only a
   help for you for the case you have special design requirements.
   

PROBLEMS

   If you have problems working with Tracking please try one of the following:

   1. Check the installation step nr 4. Have you inserted the right line
      at the right place?

   2. Set the variable $hf_debug = 1 in trackhack.php to get some more
      information about the work from Tracking

   3. Call tracktest.php to see if the Tracking database table is filled
      with entries

   4. Look at http://www.antarcon.com/forumtracking for a solution of
      your problem or to post questions   


