• All Elements
Packages
  • [Backend]
  • [Implementation]
  • [Implementation]-[Backend]
  • [Plugins]
[Implementation]-[Backend]


  • Package Elements
  • Class Hierarchy
Classes
  • DebugTools
  • GeneralFunctions
  • StatisticFunctions
  • XssFilter
Files
  • DebugTools.class.php
  • GeneralFunctions.class.php
  • StatisticFunctions.class.php
  • XssFilter.class.php

feindura - Docs

  • Back to feindura.org
  • Startpage
  • Feindura Class
Welcome
Documentation
CHANGELOG | LICENSE

Quick Menu
  • Class Overview
  • Properties | Descriptions
  • Methods | Descriptions

Properties
  • $adminConfig
  • $categoryConfig
  • $websiteConfig
  • $websiteStatistic
  • $statisticConfig
  • $pagesMetaData
  • $browser

Methods
  • __construct()
  • init()
  • urlEncode()
  • getCurrentPageId()
  • getCurrentCategoryId()
  • isPageStatisticsArray()
  • readPageStatistics()
  • savePageStatistics()
  • saveRefererLog()
  • getBrowser()
  • addDataToDataString()
  • isRobot()
  • visitorCache()
  • getCurrentVisitor()
  • getCurrentVisitors()
  • saveWebsiteStats()
  • refreshPageStatistics()

Class StatisticFunctions File source: /library/classes/StatisticFunctions.class.php

Class Overview


		    
            
        
		

Description

Classname StatisticFunctions

Provides public static functions for the website statistics.

Note: this class will be used by the implementation classes AND the backend of the feindura-CMS.


Version
  • 0.7
    ChangeLog
    • 0.7 moved a lot of functions to and from GeneralFunctions and backend.functions.php; add $pagesMetaData array
    • 0.6.4 moved createBrowserChart() and createTagCloud() to backend.functions.php
    • 0.6.3 check if add searchwords and add data to dataString is not empty
    • 0.62 change to static class
    • 0.61 doesnt extend GeneralFunctions anymore, no creates an instance of it
    • 0.60 add hasVistiCache()
    • 0.59 refreshPageStatistics(): prevent save searchwords to be counted miltuple times
    • 0.58 fixed isRobot() and saveWebsiteStatistic()
    • 0.57 add new browsers to createBrowserChart()
    • 0.56 started documentation

Class located in /library/classes/StatisticFunctions.class.php [in line 49]
Property Summary
static array   $adminConfig   Contains the administrator-settings config array
static array   $categoryConfig   Contains the category-settings config array
static array   $websiteConfig   Contains the website-config array
static array   $websiteStatistic   Contains the website-statistic array
static array   $statisticConfig   Contains the backend-statistic config array
static array   $pagesMetaData   Contains the pagesMetaData array
static string|false   $browser   The current Browser name
Method Summary
static void   init()  

The real constructor of the static class, gets the settings.

Used Global Variables

static string   urlEncode()  

Encodes a string to url, but before it removes all tags and htmlentitites.

static int|false   getCurrentPageId()  

Returns the current page ID from the $_GET variable.

Gets the current page ID from the

static bool   isPageStatisticsArray()  

Checks the given $page parameter is a valid $pageStatistics array.

static array|FALSE|NULL   readPageStatistics()  

Loads the $pageStatistics array of a page.

Includes the page statistics.

Example of the returned

static bool   savePageStatistics()  

Save a page statistics to it's flatfile.

Example of the saved $pageStatistics array:

static bool   saveRefererLog()  

Adds a entry to the referer log-file. This log file saves the referer URLS of the users visiting the website.

static string|false   getBrowser()  

Returns the right browser name.

static string   addDataToDataString()  

Adds a new string to a data-string and counts the string up if its already existing.

Example dataString:

static bool   isRobot()  

Check if the user-agent is a spider/bot/webcrawler. This method uses the

static bool   visitorCache()  

Creates a visitor.statistic.cache file and store the md5 sum of the user agent + ip with a timestamp. If

static array   getCurrentVisitor()  

Gets the current visitor (only the CURRENT) from the visitCache file

static array   getCurrentVisitors()  

Gets the current visitors (ALL) from the visitCache file (statistic/visitor.statistic.cache)

static bool   saveWebsiteStats()  

Saves the following values of the website-statistic:

  • number of user visits
  • number of bot
static bool   refreshPageStatistics()  

Saves the following values of the page-statistic:

  • number of visitors
  • first visit date
void   __construct()   Constructor is not callable, StatisticFunctions::init() is used instead.
int|false   getCurrentCategoryId()   Returns the current category ID from the $_GET variable. Gets the current category ID from the $_GET variable....
Properties
static array $adminConfig

Default value

Description

Contains the administrator-settings config array


Additional
  • see: StatisticFunctions::init()
  • access: public
Used By
  • StatisticFunctions::getCurrentPageId() - to look if set startpage is allowed
  • StatisticFunctions::getCurrentCategoryId() - to look if set startpage is allowed
  • StatisticFunctions::savePageStatistics() - for the save path of the flatfiles
  • StatisticFunctions::saveRefererLog() - to prevent storing the own website URL in the referer log
  • StatisticFunctions::refreshPageStatistics() - for the save path of the pages

static array $categoryConfig

Default value

Description

Contains the category-settings config array


Additional
  • see: StatisticFunctions::init()
  • access: public
Used By
  • StatisticFunctions::getCurrentCategoryId() - for the right category name, if the $_GET variable is not a ID but a category name

static array $websiteConfig = array()

Default value

array()

Description

Contains the website-config array

Example array:
Show Example

  1. <?php
  2.  
  3. $websiteConfig['startPage']      = 1;
  4.  
  5. $websiteConfig['localized']['de']['title']          = 'Beispiel Website';
  6. $websiteConfig['localized']['de']['publisher']      = 'Max Musterman';
  7. $websiteConfig['localized']['de']['copyright']      = 'Max Musterman';
  8. $websiteConfig['localized']['de']['keywords']       = 'schlüsselwort1,schlüsselwort2,schlüsselwort3';
  9. $websiteConfig['localized']['de']['description']    = 'Diese Beispielseite ist dazu da um zu zeigen wie einfach feindura CMS ist.';
  10.  
  11. $websiteConfig['localized']['en']['title']          = 'Example Website';
  12. $websiteConfig['localized']['en']['publisher']      = 'Max Musterman';
  13. $websiteConfig['localized']['en']['copyright']      = 'Max Musterman';
  14. $websiteConfig['localized']['en']['keywords']       = 'keyword1,keyword2,keyword3,keyword4';
  15. $websiteConfig['localized']['en']['description']    = 'This example website is intended to show how easy it is to use feindura CMS.';
  16.  
  17. return $websiteConfig;
  18. ?>


Additional
  • see: StatisticFunctions::init()
  • access: public

static array $websiteStatistic = array()

Default value

array()

Description

Contains the website-statistic array

Example array:
Show Example

  1. <?php
  2.  
  3. $websiteStatistic['userVisitCount'] =    4;
  4. $websiteStatistic['robotVisitCount'] =   0;
  5.  
  6. $websiteStatistic['firstVisit'] =        1333306675;
  7. $websiteStatistic['lastVisit'] =         1333484292;
  8.  
  9. $websiteStatistic['browser'] =           'a:3:{i:0;a:2:{s:4:"data";s:6:"safari";s:6:"number";i:2;}i:1;a:2:{s:4:"data";s:7:"firefox";s:6:"number";i:1;}i:2;a:2:{s:4:"data";s:6:"chrome";s:6:"number";s:1:"1";}}';
  10.  
  11. return $websiteStatistic;
  12. ?>


Additional
  • see: StatisticFunctions::init()
  • access: public
Used By
  • StatisticFunctions::saveWebsiteStats() - for the old website-statistics

static array $statisticConfig = array()

Default value

array()

Description

Contains the backend-statistic config array

This array contains the number of task logs and referrer logs saved until the last line is droped.

Example array:
Show Example

  1. <?php
  2.  
  3. $statisticConfig['number']['mostVisitedPages']        = 15;
  4. $statisticConfig['number']['longestVisitedPages']     = 10;
  5. $statisticConfig['number']['lastVisitedPages']        = 15;
  6. $statisticConfig['number']['lastEditedPages']         = 10;
  7.  
  8. $statisticConfig['number']['refererLog']    = 100;
  9. $statisticConfig['number']['taskLog']       = 50;
  10.  
  11. return $statisticConfig;
  12. ?>


Additional
  • see: StatisticFunctions::init()
  • access: public
Used By
  • StatisticFunctions::saveRefererLog() - to get the number of maxmial referer log entries

static array $pagesMetaData = array()

Default value

array()

Description

Contains the pagesMetaData array

This array contains all pages IDs and their category ID, as well as the localized titles

Example array:
Show Example

  1. <?php
  2. $pagesMetaData[3]['id']       = 3;
  3. $pagesMetaData[3]['category'] = 0;
  4. $pagesMetaData[3]['localized']['en']['title'] = 'Page One';
  5. $pagesMetaData[3]['localized']['de']['title'] = 'Seite eins';
  6.  
  7. $pagesMetaData[16]['id']       = 16;
  8. $pagesMetaData[16]['category'] = 1;
  9. $pagesMetaData[16]['localized']['en']['title'] = 'Another Page';
  10.  
  11. $pagesMetaData[2]['id']       = 2;
  12. $pagesMetaData[2]['category'] = 1;
  13. $pagesMetaData[2]['localized']['en']['title'] = 'Last Page';
  14. $pagesMetaData[2]['localized']['de']['title'] = 'Letzte Seite';
  15.  
  16. return $pagesMetaData;
  17. ?>


Additional
  • see: StatisticFunctions::init()
  • see: StatisticFunctions::getCurrentPageId()
  • access: public

static string|false $browser = false

Default value

false

Description

The current Browser name


Additional
  • see: StatisticFunctions::getBrowser()
  • access: public
Used By
  • StatisticFunctions::getBrowser()

Methods
File source:
line 188
static void init ( )

Description

Type init

The real constructor of the static class, gets the settings.

Used Global Variables

  • $adminConfig the administrator-settings config (included in the general.include.php)
  • $websiteConfig the website-settings config (included in the general.include.php)
  • $websiteStatistic the website-statistic (included in the general.include.php)
  • $statisticConfig the statistic-settings config (included in the general.include.php)


Additional
  • access: public
Version
  • 1.3
    ChangeLog
    • 1.3 add $categoryConfig back again
    • 1.2 add $pagesMetaData
    • 1.1 removed $categoryConfig
    • 1.02 removed instatiating of GeneralFunctions class, because GeneralFunctions is now static
    • 1.01 add $adminConfig and $categoryConfig and creates an instance of the GeneralFunctions class
    • 1.0 initial release

File source:
line 224
static string urlEncode ( string|false )

Parameters

string|false $string the string to urlencode

Description

Name urlEncode()

Encodes a string to url, but before it removes all tags and htmlentitites.


Return Value
  • string - the url encoded string
Additional
  • see: Feindura::createHref()
  • access: public
Version
  • 2.1
    ChangeLog
    • moved to StatisticFunctions
    • 2.0 add transliteration from http://php.vrana.cz/vytvoreni-pratelskeho-url.php
    • 1.0 initial release

File source:
line 268
static int|false getCurrentPageId ( [int  = null],
[  = null])

Parameters

int $startPage the startPage, given when it comes from the Feindura class
Default null
$category
Default null

Description

Name getCurrentPageId()

Returns the current page ID from the $_GET variable.

Gets the current page ID from the $_GET variable. If $_GET is not a ID but a page name, it loads all pages in an array and look for the right page name and returns the ID. If no $_GET variable exists try to return the $startPage parameter.

Used Global Variables

  • $_GET to fetch the page ID
  • $varNames the varNames generated in the general.include.php)


Return Value
  • int|false - the current page ID or FALSE
Additional
  • access: public
Used By
  • FeinduraBase::getCurrentPageId() - to get the current page id
  • StatisticFunctions::saveWebsiteStats() - to get the current page
Uses
  • StatisticFunctions::$adminConfig - to look if set startpage is allowed
  • GeneralFunctions::$pagesMetaData - to get all page titles, to get the right page ID, if the $_GET variable is not a ID but a page name
Version
  • 1.3
    ChangeLog
    • 1.3 pretty url page name looks now only in the current category for a match
    • 1.2 moved to StatisticsFunctions; use now $pagesMetaData
    • 1.1 add localization
    • 1.0 initial release

File source:
line 440
static bool isPageStatisticsArray ( int|array )

Parameters

int|array $page the variable to check

Description

Name isPageStatisticsArray()

Checks the given $page parameter is a valid $pageStatistics array.


Additional
  • access: public
Version
  • 1.1
    ChangeLog
    • 1.1 moved to StatisticFunctions
    • 1.0 initial release

File source:
line 470
static array|FALSE|NULL readPageStatistics ( int )

Parameters

int $pageId a page ID or a $pageStatistics array (will then returned immediately)

Description

Name readPageStatistics()

Loads the $pageStatistics array of a page.

Includes the page statistics.

Example of the returned $pageStatistics array:
Show Example

  1. <?php
  2.  
  3. array(
  4.       "id" => 1,
  5.       "visitorCount"   => 125,
  6.       "firstVisit"     => 1282348800, // UNIX-Timestamp
  7.       "lastVisit"      => 1282349800,
  8.       "visitTimeMin"   =>  'a:2:{i:0;i:23;i:1;i:0;}', // serialized array
  9.       "visitTimeMax"   =>  'a:1:{i:0;i:149;}',
  10.       "searchWords"    =>    'a:3:{i:0;a:2:{s:4:"data";s:21:"keyword1";s:6:"number";i:2;}i:1;a:2:{s:4:"data";s:14:"keyword2";s:6:"number";i:1;}}'
  11.     )
  12.  
  13. ?>


Return Value
  • array|FALSE|NULL - the $pageStatistics array of the requested page or FALSE, if it couldn't open the file, or NULL when the file exists but couldnt be loaded properly
Additional
  • access: public
Used By
  • StatisticFunctions::saveWebsiteStats() - to read the last page again, to save the time spend on the page
  • StatisticFunctions::refreshPageStatistics() - to read the last page again, to save the time spend on the page
Version
  • 1.1
    ChangeLog
    • 1.1 moved to StatisticFunctions
    • 1.0 initial release

File source:
line 528
static bool savePageStatistics ( array )

Parameters

array $pageStatistics the $pageStatistics array of the page to save

Description

Name savePageStatistics()

Save a page statistics to it's flatfile.

Example of the saved $pageStatistics array:
Show Example

  1. <?php
  2.  
  3. array(
  4.       "id" => 1,
  5.       "visitorCount"   => 125,
  6.       "firstVisit"     => 1282348800, // UNIX-Timestamp
  7.       "lastVisit"      => 1282349800,
  8.       "visitTimeMin"   =>  'a:2:{i:0;i:23;i:1;i:0;}', // serialized array
  9.       "visitTimeMax"   =>  'a:1:{i:0;i:149;}',
  10.       "searchWords"    =>    'a:3:{i:0;a:2:{s:4:"data";s:21:"keyword1";s:6:"number";i:2;}i:1;a:2:{s:4:"data";s:14:"keyword2";s:6:"number";i:1;}}'
  11.     )
  12.  
  13. ?>


Return Value
  • bool - TRUE if the page was succesfull saved, otherwise FALSE
Additional
  • access: public
Used By
  • StatisticFunctions::saveWebsiteStats() - to save the current page statictics
  • StatisticFunctions::refreshPageStatistics() - to save the current page statictics
Uses
  • StatisticFunctions::$adminConfig - for the save path of the flatfiles
Version
  • 1.1
    ChangeLog
    • 1.1 moved to StatisticFunctions
    • 1.0 initial release

File source:
line 581
static bool saveRefererLog ( )

Description

Name saveRefererLog()

Adds a entry to the referer log-file. This log file saves the referer URLS of the users visiting the website.


Additional
  • access: public
Used By
  • StatisticFunctions::saveWebsiteStats() - to save the referer log-file
Uses
  • StatisticFunctions::$statisticConfig - to get the number of maxmial referer log entries
  • StatisticFunctions::$adminConfig - to prevent storing the own website URL in the referer log
Version
  • 1.0
    ChangeLog
    • 1.0 initial release

File source:
line 650
static string|false getBrowser ( )

Description

Name getBrowser()

Returns the right browser name.


Return Value
  • string|false - the right browser name or FALSE if no useragent is available
Additional
  • access: public
Uses
  • Browser::getBrowser - to get the right browser
  • StatisticFunctions::$browser
Version
  • 1.01
    ChangeLog
    • 1.01 add the browser detection class from http://chrisschuld.com/projects/browser-php-detecting-a-users-browser-from-php
    • 1.0 initial release

File source:
line 695
static string addDataToDataString ( string ,
string|array )

Parameters

string $dataString the data-string which the $dataToAdd parameter will be add to
string|array $dataToAdd a string or an array with data to add, OR a unserialized data-string

Description

Name addDataToDataString()

Adds a new string to a data-string and counts the string up if its already existing.

Example dataString:
Show Example

  1. <?php
  2.  
  3. $dataString[0]['data']   = 'Searchword1';
  4. $dataString[0]['number'] = 2;
  5.  
  6. $dataString[1]['data']   = 'OtherWord';
  7. $dataString[1]['number'] = 25;
  8.  
  9. $dataString[2]['data']   = 'FooBar';
  10. $dataString[2]['number'] = 54;
  11.  
  12. ...
  13.   
  14. ?>


Return Value
  • string - the modified data-string
Additional
  • access: public
Used By
  • StatisticFunctions::saveWebsiteStats() - to add a browser to the browser data-string
  • StatisticFunctions::refreshPageStatistics() - to add the searchwords to the searchword data-string
Version
  • 1.1.1
    ChangeLog
    • 1.1.1 check if add data is not empty
    • 1.1 changed to searialize data
    • 1.0 initial release

File source:
line 792
static bool isRobot ( )

Description

Name isRobot()

Check if the user-agent is a spider/bot/webcrawler. This method uses the "library/thirdparty/spider.xml".

The list of spiders it uses is from: http://www.wolfshead-solutions.com/spiders-list


Return Value
  • bool - TRUE if its a spider/bot/webcrawler, FALSE if not
Additional
  • access: public
Used By
  • StatisticFunctions::saveWebsiteStats() - to check whether the user-agent is a robot or a human
  • StatisticFunctions::refreshPageStatistics() - to check whether the user-agent is a robot or a human
Version
  • 1.0.1
    ChangeLog
    • 1.0.1 store the isRobot value directly in the session and return it
    • 1.0 initial release

File source:
line 862
static bool visitorCache ( [bool  = true])

Parameters

bool $add if this is FALSE, it only check if the agents in the cache are still up to date, without adding a user agent
Default true

Description

Name visitorCache()

Creates a visitor.statistic.cache file and store the md5 sum of the user agent + ip with a timestamp. If the agent load again the website, it check if the agent is already in the cache and the timelimit of 10 min is not passed.

This public static function is used when the session ID cannot be transfered, because of deactivated cookies or no session ID in the link was transfered.

An example of the saved cache lines 1306733465|#|visitor|#|c5b5533c8475801044fb7680059d5846|#|192.168.0.1


Return Value
  • bool - TRUE the user agent is in the cache, FALSE if not
Additional
  • access: public
Version
  • 1.01
    ChangeLog
    • 1.01 add type, which can be "robot" or "visitor"
    • 1.0 initial release

File source:
line 938
static array getCurrentVisitor ( )

Description

Name getCurrentVisitor()

Gets the current visitor (only the CURRENT) from the visitCache file (statistic/visitor.statistic.cache)


Return Value
  • array - the current visitor with $returnVisitors['ip'], $returnVisitors['time'] and $returnVisitors['type']
Additional
  • access: public
Version
  • 1.0
    ChangeLog
    • 1.0 initial release

File source:
line 975
static array getCurrentVisitors ( )

Description

Name getCurrentVisitors()

Gets the current visitors (ALL) from the visitCache file (statistic/visitor.statistic.cache)


Return Value
  • array - the current visitors with $returnVisitors['ip'], $returnVisitors['time'] and $returnVisitors['type']
Additional
  • access: public
Version
  • 1.0
    ChangeLog
    • 1.0 initial release

File source:
line 1039
static bool saveWebsiteStats ( [false|int  = false])

Parameters

false|int $page a page ID, of the current page, where the page statistic should be saved
Default false

Description

Name saveWebsiteStats()

Saves the following values of the website-statistic:

  • number of user visits
  • number of bot visits
  • first visit date time
  • last visit date time
  • which browser and how often visited this website
Saves the time spend on the last Pages
  • minimal time spend on the page
  • maxmimal time spend on the page
Used Global Variables
  • $_SESSION to store whether the user visited the website already, to prevent double counting


Return Value
  • bool - TRUE if the website-statistics were saved, otherwise FALSE
Additional
  • access: public
Used By
  • FeinduraBase::__construct() - save the website statistic like user visit count, first and last visit AND the visit time of the last visited pages
Uses
  • StatisticFunctions::$websiteStatistic - for the old website-statistics
  • StatisticFunctions::saveRefererLog() - to save the referer log-file
  • StatisticFunctions::isRobot() - to check whether the user-agent is a robot or a human
  • StatisticFunctions::addDataToDataString() - to add a browser to the browser data-string
  • StatisticFunctions::readPageStatistics() - to read the last page again, to save the time spend on the page
  • StatisticFunctions::savePageStatistics() - to save the current page statictics
  • StatisticFunctions::refreshPageStatistics() - to save the current page statistics
  • StatisticFunctions::getCurrentPageId() - to get the current page
Version
  • 1.0.3
    ChangeLog
    • 1.0.3 moved the visitorCache inside the if condition
    • 1.0.2 fixed save visit Time with unix timestamps
    • 1.0.1 if Robot it will only be counted nothing else
    • 1.0 initial release

File source:
line 1288
static bool refreshPageStatistics ( $pageContent )

Parameters

$pageContent $pageId the $pageContent array of the page

Description

Name refreshPageStatistics()

Saves the following values of the page-statistic:

  • number of visitors
  • first visit date time
  • last visit date time
  • which searchwords and how often they occured
Used Global Variables
  • $_SESSION to store whether the user is a robots and save the time and ID of the last page to calculate the time viewed the pages


Return Value
  • bool - TRUE if the page-statistic was saved succesfully or FALSE if the user agent is a robot, or the $pageContent parameter is not a valid $pageContent array
Additional
  • access: public
Used By
  • StatisticFunctions::saveWebsiteStats() - to save the current page statistics
Uses
  • StatisticFunctions::$adminConfig - for the save path of the pages
  • StatisticFunctions::isRobot() - to check whether the user-agent is a robot or a human
  • StatisticFunctions::addDataToDataString() - to add the searchwords to the searchword data-string
  • StatisticFunctions::readPageStatistics() - to read the last page again, to save the time spend on the page
  • StatisticFunctions::savePageStatistics() - to save the current page statictics
Version
  • 1.0.3
    ChangeLog
    • 1.0.3 check if searchwords are not empty
    • 1.0.2 fixed scalar value returned from readPageStatistics()
    • 1.0.1 prevent save searchwords to be counted miltuple times
    • 1.0 initial release

File source:
line 159
void Constructor __construct ( )

Description

Type constructor

Constructor is not callable, StatisticFunctions::init() is used instead.


Additional
  • access: private
Version
  • 1.0
    ChangeLog
    • 1.0 initial release

File source:
line 380
int|false getCurrentCategoryId ( [ $startCategory = null])

Parameters

$startCategory
Default null

Description

Name getCurrentCategoryId()

Returns the current category ID from the $_GET variable.

Gets the current category ID from the $_GET variable. If $_GET is not a ID but a category name, it look in the FeinduraBase::$categoryConfig for the right category ID. If no $_GET variable exists it try to return the Feindura::$startPage property.

Used Global Variables

  • $_GET to fetch the category ID


Return Value
  • int|false - the current category ID or FALSE
Additional
  • access: public
Uses
  • StatisticFunctions::$adminConfig - to look if set startpage is allowed
  • StatisticFunctions::$categoryConfig - for the right category name, if the $_GET variable is not a ID but a category name
Version
  • 1.2
    ChangeLog
    • 1.2 moved to StatisticFunctions class
    • 1.1 add localization
    • 1.0 initial release



The feindura API reference was generated from the comments in the feindura source code on Sat, 01 Dec 2012 21:56:16 +0000 by phpDocumentor 1.4.3
feindura - Flat File Content Management System, Copyright © Fabian Vogelsteller [frozeman.de]