Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvipsoft <vipsoft@59fd770c-687e-43c8-a1e3-f5a4ff64c105>2010-02-24 01:47:29 +0300
committervipsoft <vipsoft@59fd770c-687e-43c8-a1e3-f5a4ff64c105>2010-02-24 01:47:29 +0300
commit2db2b3f36a99bb73f6839c0d6eb77ef9273d1735 (patch)
treefa3593fbfa9a18a99f45e8f5c3bbfc83d237b081 /plugins/Live
parent380690233971786fc7fd0091962e92a051bd30ba (diff)
refs #1120 - merged from Live.zip as there were too many conflicts with piwik.patch against the svn trunk
Diffstat (limited to 'plugins/Live')
-rw-r--r--plugins/Live/API.php329
-rw-r--r--plugins/Live/Controller.php82
-rw-r--r--plugins/Live/Live.php16
-rw-r--r--plugins/Live/Visitor.php121
-rw-r--r--plugins/Live/templates/images/download.pngbin0 -> 734 bytes
-rw-r--r--plugins/Live/templates/images/goal.pngbin0 -> 672 bytes
-rw-r--r--plugins/Live/templates/images/outboundlink.pngbin0 -> 799 bytes
-rw-r--r--plugins/Live/templates/index.tpl43
-rw-r--r--plugins/Live/templates/lastVisits.tpl22
-rw-r--r--plugins/Live/templates/scripts/spy.js20
-rw-r--r--plugins/Live/templates/totalVisits.tpl2
11 files changed, 310 insertions, 325 deletions
diff --git a/plugins/Live/API.php b/plugins/Live/API.php
index 15e2f09889..4e9318f22b 100644
--- a/plugins/Live/API.php
+++ b/plugins/Live/API.php
@@ -18,17 +18,17 @@ defined('PIWIK_INCLUDE_PATH') or die;
*/
require_once PIWIK_INCLUDE_PATH . '/plugins/Live/Visitor.php';
-class Piwik_Live_API
+class Piwik_Live_API
{
static private $instance = null;
-
+
/*
* @return Piwik_Live_API
*/
static public function getInstance()
{
if (self::$instance == null)
- {
+ {
$c = __CLASS__;
self::$instance = new $c();
}
@@ -42,7 +42,7 @@ class Piwik_Live_API
{
return $this->getLastVisitsForVisitor($visitorId, $idSite, 1);
}
-
+
/*
* @return Piwik_DataTable
*/
@@ -58,6 +58,7 @@ class Piwik_Live_API
}
$visitorDetails = $this->loadLastVisitorDetailsFromDatabase($visitorId, $idSite, $limit);
$table = $this->getCleanedVisitorsFromDetails($visitorDetails);
+
return $table;
}
@@ -78,7 +79,7 @@ class Piwik_Live_API
}
$visitorDetails = $this->loadLastVisitorDetailsFromDatabase(null, $idSite, $limit, $minIdVisit);
$table = $this->getCleanedVisitorsFromDetails($visitorDetails);
-// var_dump($table);
+
return $table;
}
@@ -88,7 +89,6 @@ class Piwik_Live_API
public function getLastVisitsDetails( $idSite = false, $limit = 1000, $minIdVisit = false )
{
// for checking given vars
- // echo $idSite.'|'.$limit.'|'.$minIdVisit.'<br>';
if(is_null($idSite))
{
Piwik::checkUserIsSuperUser();
@@ -99,89 +99,100 @@ class Piwik_Live_API
}
$visitorDetails = $this->loadLastVisitorDetailsFromDatabase(null, $idSite, $limit, $minIdVisit);
$dataTable = $this->getCleanedVisitorsFromDetails($visitorDetails);
-//echo "hallo";
-//
// $dataTable->queueFilter('ColumnCallbackAddMetadata', array('operatingSystem', 'icon', 'Piwik_Live_Visitor::getVisitLength()'));
-
-// echo "<pre>";
-// var_dump($dataTable[0]);
-// echo "</pre>";
-
+
return $dataTable;
}
-
+
/*
* @return Piwik_DataTable
*/
private function getCleanedVisitorsFromDetails($visitorDetails)
{
$table = new Piwik_DataTable();
+
foreach($visitorDetails as $visitorDetail)
{
$this->cleanVisitorDetails($visitorDetail);
$visitor = new Piwik_Live_Visitor($visitorDetail);
+
+ // $visitorDetail must contain the match_atribute
$visitorDetailsArray = $visitor->getAllVisitorDetails();
+
+// $visitorDetailsArray['goalIcon'] = "themes/default/images/goal.png";
+
$dateTimeVisit = Piwik_Date::factory($visitorDetailsArray['firstActionTimestamp']);
//TODO TO FIX
$visitorDetailsArray['serverDatePretty'] = $dateTimeVisit->getLocalized('%shortDay% %day% %shortMonth%');
$visitorDetailsArray['serverTimePretty'] = $dateTimeVisit->getLocalized('%time%');
-
- // get Detail
+
+ // get Detail - 100 single SQL Statements - Performance Issue
$idvisit = $visitorDetailsArray['idVisit'];
- $sql = "SELECT DISTINCT`" .Piwik::prefixTable('log_action')."`.`name` AS pageUrl
- FROM `" .Piwik::prefixTable('log_visit')."`
- INNER JOIN `" .Piwik::prefixTable('log_link_visit_action')."` ON `" .Piwik::prefixTable('log_visit')."`.`idvisit` = `" .Piwik::prefixTable('log_link_visit_action')."`.`idvisit`
+
+ $sql = "SELECT DISTINCT `" .Piwik::prefixTable('log_action')."`.`name` AS pageUrl
+ FROM `" .Piwik::prefixTable('log_link_visit_action')."`
INNER JOIN `" .Piwik::prefixTable('log_action')."` ON `" .Piwik::prefixTable('log_link_visit_action')."`.`idaction_url` = `" .Piwik::prefixTable('log_action')."`.`idaction`
- WHERE `" .Piwik::prefixTable('log_visit')."`.`idvisit` = $idvisit;
+ WHERE `" .Piwik::prefixTable('log_link_visit_action')."`.`idvisit` = $idvisit;
";
-
+
$visitorDetailsArray['actionDetails'] = Piwik_FetchAll($sql);
-
+
+ $sql = "SELECT DISTINCT `" .Piwik::prefixTable('log_action')."`.`name` AS pageUrl
+ FROM `" .Piwik::prefixTable('log_link_visit_action')."`
+ INNER JOIN `" .Piwik::prefixTable('log_action')."` ON `" .Piwik::prefixTable('log_link_visit_action')."`.`idaction_name` = `" .Piwik::prefixTable('log_action')."`.`idaction`
+ WHERE `" .Piwik::prefixTable('log_link_visit_action')."`.`idvisit` = $idvisit;
+ ";
+
+ $visitorDetailsArray['actionDetailsTitle'] = Piwik_FetchAll($sql);
+
$table->addRowFromArray( array(Piwik_DataTable_Row::COLUMNS => $visitorDetailsArray));
}
+
return $table;
}
-
+
/*
* @return array
*/
private function loadLastVisitorDetailsFromDatabase($visitorId = null, $idSite = null, $limit = null, $minIdVisit = false )
{
// for checking given vars
- // echo $visitorId.'|'.$idSite.'|'.$limit.'|'.$minIdVisit.'<br>';
+ // echo $visitorId.'|'.$idSite.'|'.$limit.'|'.$minIdVisit.'<br>';
$where = $whereBind = array();
-
+
if(!is_null($idSite))
{
- $where[] = " idsite = ? ";
+ $where[] = Piwik::prefixTable('log_visit') . ".idsite = ? ";
$whereBind[] = $idSite;
}
-
+
if(!is_null($visitorId))
{
- $where[] = " visitor_idcookie = ? ";
+ $where[] = Piwik::prefixTable('log_visit') . ".visitor_idcookie = ? ";
$whereBind[] = $visitorId;
}
-
+
if(!is_null($minIdVisit))
{
- $where[] = " idvisit > ? ";
+ $where[] = Piwik::prefixTable('log_visit') . ".idvisit > ? ";
$whereBind[] = $minIdVisit;
}
-
+
$sqlWhere = "";
if(count($where) > 0)
{
$sqlWhere = " WHERE " . join(' AND ', $where);
}
-
- $sql = "SELECT *
+
+ $sql = "SELECT " . Piwik::prefixTable('log_visit') . ".* , " . Piwik::prefixTable ( 'goal' ) . ".`match_attribute`
FROM " . Piwik::prefixTable('log_visit') . "
- $sqlWhere
+ LEFT JOIN ".Piwik::prefixTable('log_conversion')." ON " . Piwik::prefixTable('log_visit') . ".`idvisit` = " . Piwik::prefixTable('log_conversion') . ".`idvisit`
+ LEFT JOIN ".Piwik::prefixTable('goal')." ON " . Piwik::prefixTable('goal') . ".`idgoal` = " . Piwik::prefixTable('log_conversion') . ".`idgoal` AND " . Piwik::prefixTable('goal') . ".`deleted` = 0
+ $sqlWhere
ORDER BY idvisit DESC
LIMIT $limit";
-
+
return Piwik_FetchAll($sql, $whereBind);
}
@@ -190,7 +201,7 @@ class Piwik_Live_API
*/
private function cleanVisitorDetails( &$visitorDetails )
{
- $toUnset = array('config_md5config');
+ $toUnset = array('config_md5config');
if(!Piwik::isUserIsSuperUser())
{
$toUnset[] = 'visitor_idcookie';
@@ -204,9 +215,9 @@ class Piwik_Live_API
}
}
}
-
-
-
+
+
+
/*
* @return Piwik_DataTable
*/
@@ -220,9 +231,11 @@ class Piwik_Live_API
{
Piwik::checkUserHasViewAccess($idSite);
}
- $visitorDetails = $this->loadLastVisitorDetailsInLastXMinFromDatabase(null, $idSite, $limit, $minIdVisit, $minutes);
-
+// $visitorDetails = $this->loadLastVisitorDetailsInLastXMinFromDatabase(null, $idSite, $limit, $minIdVisit, $minutes);
+ $visitorDetails = $this->loadLastVisitorInLastXTimeFromDatabase(null, $idSite, $limit, $minIdVisit, $minutes, 0, 1);
+
$table = $this->getCleanedVisitorsFromDetails($visitorDetails);
+
return $table;
}
@@ -231,7 +244,7 @@ class Piwik_Live_API
*/
public function getUsersInLastXDays( $idSite = false, $limit = 10, $minIdVisit = false, $days = 10 )
{
-
+
if(is_null($idSite))
{
Piwik::checkUserIsSuperUser();
@@ -240,20 +253,21 @@ class Piwik_Live_API
{
Piwik::checkUserHasViewAccess($idSite);
}
- $visitorDetails = $this->loadLastVisitorDetailsInLastXDaysFromDatabase(null, $idSite, $limit, $minIdVisit, $days);
-
+// $visitorDetails = $this->loadLastVisitorDetailsInLastXDaysFromDatabase(null, $idSite, $limit, $minIdVisit, $days);
+ $visitorDetails = $this->loadLastVisitorInLastXTimeFromDatabase(null, $idSite, $limit, $minIdVisit, 0, $days, 1);
+
$table = $this->getCleanedVisitorsFromDetails($visitorDetails);
return $table;
}
-
+
/*
* @return array
- */
+ */
public function getPageImpressionsInLastXDays($idSite = false, $limit = 10, $minIdVisit = false, $days = 10){
// for checking given vars
#echo $idSite.'|'.$limit.'|'.$minIdVisit.'|'.$days.'<br>';
-
+
if(is_null($idSite))
{
Piwik::checkUserIsSuperUser();
@@ -262,8 +276,9 @@ class Piwik_Live_API
{
Piwik::checkUserHasViewAccess($idSite);
}
- $pageDetails = $this->loadLastVisitedPagesInLastXDaysFromDatabase(null, $idSite, $limit, $minIdVisit, $days);
-
+// $pageDetails = $this->loadLastVisitedPagesInLastXDaysFromDatabase(null, $idSite, $limit, $minIdVisit, $days);
+ $pageDetails = $this->loadLastVisitorInLastXTimeFromDatabase(null, $idSite, $limit, $minIdVisit, 0, $days, 2);
+
$i = -1;
foreach ($pageDetails as $detail) {
$i++;
@@ -272,12 +287,12 @@ class Piwik_Live_API
}
}
- return $pageDetails;
+ return $pageDetails;
}
/*
* @return array
- */
+ */
public function getPageImpressionsInLastXMin($idSite = false, $limit = 10, $minIdVisit = false, $minutes = 30){
if(is_null($idSite))
@@ -288,8 +303,9 @@ class Piwik_Live_API
{
Piwik::checkUserHasViewAccess($idSite);
}
- $pageDetails = $this->loadLastVisitedPagesInLastXMinFromDatabase(null, $idSite, $limit, $minIdVisit, $minutes);
-
+// $pageDetails = $this->loadLastVisitedPagesInLastXMinFromDatabase(null, $idSite, $limit, $minIdVisit, $minutes);
+ $pageDetails = $this->loadLastVisitorInLastXTimeFromDatabase(null, $idSite, $limit, $minIdVisit, $minutes, 0, 2);
+
$i = -1;
foreach ($pageDetails as $detail) {
$i++;
@@ -297,192 +313,103 @@ class Piwik_Live_API
$pageDetails[$i]['name'] = substr($pageDetails[$i]['name'] , 0, 30 - 3).'...';
}
}
- return $pageDetails;
+ return $pageDetails;
}
-
-
- /*
- * TODO should be refactored with function below
- * @return array
+ /**
+ * Load last Visitors PAGES or DETAILS in MINUTES or DAYS from database
+ *
+ * @param boolen $visitorId
+ * @param boolen $idSite
+ * @param int $limit int
+ * @param int $minIdVisit
+ * @param int $minutes
+ * @param int $days
+ * @param int $type 1 = DETAILS; 2 = PAGES
+ *
+ * @return mixed
*/
- private function loadLastVisitorDetailsInLastXMinFromDatabase($visitorId = null, $idSite = null, $limit = 1000, $minIdVisit = false, $minutes = 0 )
+ private function loadLastVisitorInLastXTimeFromDatabase($visitorId = null, $idSite = null, $limit = 1000, $minIdVisit = false, $minutes = 0, $days = 0, $type = 0 )
{
$where = $whereBind = array();
-
+
if(!is_null($idSite))
{
- $where[] = " idsite = ? ";
+ $where[] = " " . Piwik::prefixTable('log_visit') . ".`idsite` = ? ";
$whereBind[] = $idSite;
}
-
+
if(!is_null($visitorId))
{
- $where[] = " visitor_idcookie = ? ";
+ $where[] = " `visitor_idcookie` = ? ";
$whereBind[] = $visitorId;
}
-
+
if(!is_null($minIdVisit))
{
- $where[] = " idvisit > ? ";
+ $where[] = " " . Piwik::prefixTable('log_visit') . ".`idvisit` > ? ";
$whereBind[] = $minIdVisit;
}
-
+
if($minutes != 0)
{
$timeLimit = mktime(date("H"), date("i") - $minutes, 0, date("m"), date("d"), date("Y"));
-
- $where[] = " visit_last_action_time > '".date('Y-m-d H:i:s',$timeLimit)."'";
- }
-
- $sqlWhere = "";
- if(count($where) > 0)
- {
- $sqlWhere = " WHERE " . join(' AND ', $where);
- }
-
- $sql = "SELECT *
- FROM " . Piwik::prefixTable('log_visit') . "
- $sqlWhere
- ORDER BY idvisit DESC
- LIMIT " . (int)$limit;
- return Piwik_FetchAll($sql, $whereBind);
- }
-
- /*
- * TODO should be refactored with function above
- * @return array
- */
- private function loadLastVisitorDetailsInLastXDaysFromDatabase($visitorId = null, $idSite = null, $limit = 1000, $minIdVisit = false, $days = 0 )
- {
- $where = $whereBind = array();
-
- if(!is_null($idSite))
- {
- $where[] = " idsite = ? ";
- $whereBind[] = $idSite;
- }
-
- if(!is_null($visitorId))
- {
- $where[] = " visitor_idcookie = ? ";
- $whereBind[] = $visitorId;
- }
-
- if(!is_null($minIdVisit))
- {
- $where[] = " idvisit > ? ";
- $whereBind[] = $minIdVisit;
+ $where[] = " `visit_last_action_time` > '".date('Y-m-d H:i:s',$timeLimit)."'";
}
-
+
if($days != 0)
{
$timeLimit = mktime(0, 0, 0, date("m"), date("d") - $days + 1, date("Y"));
-
- $where[] = " visit_last_action_time > '".date('Y-m-d H:i:s',$timeLimit)."'";
+ $where[] = " `visit_last_action_time` > '".date('Y-m-d H:i:s',$timeLimit)."'";
}
-
+
$sqlWhere = "";
if(count($where) > 0)
{
$sqlWhere = " WHERE " . join(' AND ', $where);
}
-
- $sql = "SELECT *
+
+ // Details
+ if($type == 1)
+ {
+ $sql = "SELECT " . Piwik::prefixTable('log_visit') . ".*
FROM " . Piwik::prefixTable('log_visit') . "
- $sqlWhere
+ $sqlWhere
ORDER BY idvisit DESC
LIMIT " . (int)$limit;
- return Piwik_FetchAll($sql, $whereBind);
- }
-
- /*
- * TODO should be refactored with function above
- * @return array
- */
- private function loadLastVisitedPagesInLastXMinFromDatabase($visitorId = null, $idSite = null, $limit = null, $minIdVisit = false, $minutes = 0 )
- {
- $where = $whereBind = array();
-
- if(!is_null($idSite))
- {
- $where[] = " idsite = ? ";
- $whereBind[] = $idSite;
- }
-
- if(!is_null($visitorId))
- {
- $where[] = " visitor_idcookie = ? ";
- $whereBind[] = $visitorId;
- }
-
- if(!is_null($minIdVisit))
- {
- $where[] = Piwik::prefixTable('log_visit') .".idvisit > ? ";
- $whereBind[] = $minIdVisit;
- }
-
- if($minutes != 0)
- {
- $timeLimit = mktime(date("H"), date("i") - $minutes, 0, date("m"), date("d"), date("Y"));
+ }
+ // Pages
+ elseif($type == 2)
+ {
+ // different SELECT between $minutes & $days
+ if($minutes != 0)
+ {
+ $sql_select = "SELECT " . Piwik::prefixTable('log_link_visit_action') . ".`idaction_url`, " . Piwik::prefixTable('log_action') . ".`idaction`, " . Piwik::prefixTable('log_action') . ".`name` , " . Piwik::prefixTable('log_visit') . ".*";
+ }
+ elseif($days != 0)
+ {
+ $sql_select = "SELECT " . Piwik::prefixTable('log_link_visit_action') . ".`idaction_url`, " . Piwik::prefixTable('log_action') . ".`idaction`, " . Piwik::prefixTable('log_action') . ".`name` , " . Piwik::prefixTable('log_link_visit_action') . ".*";
+ }
+ else
+ {
+ // neither $minutes nor $days --> ERROR
+ return false;
+ }
- $where[] = " visit_last_action_time > '".date('Y-m-d H:i:s',$timeLimit)."'";
- }
-
- $sqlWhere = "";
- if(count($where) > 0)
- {
- $sqlWhere = " WHERE " . join(' AND ', $where);
- }
-
- $sql = "SELECT " . Piwik::prefixTable('log_link_visit_action') . ".`idaction_url`," . Piwik::prefixTable('log_action') . ".`idaction`, " . Piwik::prefixTable('log_action') . ".`name` , " . Piwik::prefixTable('log_visit') . ".*
+ $sql = $sql_select."
FROM " . Piwik::prefixTable('log_link_visit_action') . "
- INNER JOIN " . Piwik::prefixTable('log_action') . " ON " . Piwik::prefixTable('log_link_visit_action') . ".`idaction_url`= " . Piwik::prefixTable('log_action') . ".`idaction`
+ INNER JOIN " . Piwik::prefixTable('log_action') . " ON " . Piwik::prefixTable('log_link_visit_action') . ".`idaction_url`= " . Piwik::prefixTable('log_action') . ".`idaction`
INNER JOIN " . Piwik::prefixTable('log_visit') . " ON " . Piwik::prefixTable('log_visit') . ".`idvisit` = " . Piwik::prefixTable('log_link_visit_action') . ".`idvisit`
$sqlWhere";
- return Piwik_FetchAll($sql, $whereBind);
- }
-
- /*
- * TODO should be refactored with function above
- * @return array
- */
- private function loadLastVisitedPagesInLastXDaysFromDatabase($visitorId = null, $idSite = null, $limit = null, $minIdVisit = false, $days = 0 )
- {
- $where = $whereBind = array();
-
- if(!is_null($idSite))
- {
- $where[] = " idsite = ? ";
- $whereBind[] = $idSite;
- }
-
- if(!is_null($visitorId))
- {
- $where[] = " visitor_idcookie = ? ";
- $whereBind[] = $visitorId;
- }
-
- if($days != 0)
- {
- $timeLimit = mktime(0, 0, 0, date("m"), date("d") - $days + 1, date("Y"));
-
- $where[] = " visit_last_action_time > '".date('Y-m-d H:i:s',$timeLimit)."'";
- }
-
- $sqlWhere = "";
- if(count($where) > 0)
- {
- $sqlWhere = " WHERE " . join(' AND ', $where);
- }
-
- $sql = "SELECT " . Piwik::prefixTable('log_link_visit_action') . ".`idaction_url`, " . Piwik::prefixTable('log_action') . ".`idaction`, " . Piwik::prefixTable('log_action') . ".`name` , " . Piwik::prefixTable('log_link_visit_action') . ".*
- FROM " . Piwik::prefixTable('log_link_visit_action') . "
- INNER JOIN " . Piwik::prefixTable('log_action') . " ON " . Piwik::prefixTable('log_link_visit_action') . ".`idaction_url`= " . Piwik::prefixTable('log_action') . ".`idaction`
- INNER JOIN " . Piwik::prefixTable('log_visit') . " ON " . Piwik::prefixTable('log_visit') . ".idvisit=" . Piwik::prefixTable('log_link_visit_action') . ".idvisit
- $sqlWhere";
+ }
+ else
+ {
+ // no $type is set --> ERROR
+ return false;
+ }
+ // return $sql by fetching
return Piwik_FetchAll($sql, $whereBind);
- }
+ }
}
diff --git a/plugins/Live/Controller.php b/plugins/Live/Controller.php
index 6f2ab426da..5fe8508a60 100644
--- a/plugins/Live/Controller.php
+++ b/plugins/Live/Controller.php
@@ -1,11 +1,11 @@
<?php
/**
* Piwik - Open source web analytics
- *
+ *
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
* @version $Id$
- *
+ *
* @category Piwik_Plugins
* @package Piwik_Live
*/
@@ -16,22 +16,22 @@
*/
class Piwik_Live_Controller extends Piwik_Controller
{
-
+
function __construct()
{
parent::__construct();
$this->idSite = Piwik_Common::getRequestVar('idSite');
$this->minIdVisit = Piwik_Common::getRequestVar('minIdVisit', 0, 'int');
}
-
+
function index()
{
$this->widget(true);
- }
-
+ }
+
public function widget($fetch = false)
{
- $view = Piwik_View::factory('index');
+ $view = Piwik_View::factory('index');
$this->setGeneralVariablesView($view);
$view->visitorsCountHalfHour = $this->getUsersInLastXMin(30);
$view->visitorsCountToday = $this->getUsersInLastXDays(1);
@@ -39,23 +39,23 @@ class Piwik_Live_Controller extends Piwik_Controller
$view->pisToday = $this->getPageImpressionsInLastXDays(1);
$view->visitors = $this->getLastVisitsStart($fetch = true);
- echo $view->render();
+ echo $view->render();
}
-
+
public function getLastVisitsDetails($fetch = false)
{
$view = Piwik_ViewDataTable::factory('');
$view->init( $this->pluginName,
- __FUNCTION__,
+ __FUNCTION__,
'Live.getLastVisitsDetails',
- 'getPagesFromVisitId');
+ 'getPagesFromVisitId');
// All colomns in DB which could be shown
-//'ip', 'idVisit', 'countActions', 'isVisitorReturning', 'country', 'countryFlag', 'continent', 'provider', 'providerUrl', 'idSite',
-//'serverDate', 'visitLength', 'visitLengthPretty', 'firstActionTimestamp', 'lastActionTimestamp', 'refererType', 'refererName',
+//'ip', 'idVisit', 'countActions', 'isVisitorReturning', 'country', 'countryFlag', 'continent', 'provider', 'providerUrl', 'idSite',
+//'serverDate', 'visitLength', 'visitLengthPretty', 'firstActionTimestamp', 'lastActionTimestamp', 'refererType', 'refererName',
//'keywords', 'refererUrl', 'searchEngineUrl', 'searchEngineIcon', 'operatingSystem', 'operatingSystemShortName', 'operatingSystemIcon',
//'browserFamily', 'browserFamilyDescription', 'browser', 'browserIcon', 'screen', 'resolution', 'screenIcon', 'plugins', 'lastActionDateTime',
//'serverDatePretty', 'serverTimePretty', 'actionDetails'
-
+
$view->setColumnsToDisplay(array(
// 'label',
'idVisit',
@@ -78,7 +78,7 @@ class Piwik_Live_Controller extends Piwik_Controller
'idVisit' => Piwik_Translate(''),
'serverDatePretty' => Piwik_Translate('Live_Date'),
'serverTimePretty' => Piwik_Translate('Live_Time'),
- 'ip' => 'IP',
+ 'ip' => 'IP',
'countActions' => Piwik_Translate('VisitorInterest_ColumnPagesPerVisit'),
'visitLengthPretty' => Piwik_Translate('VisitorInterest_ColumnVisitDuration'),
'keywords' => Piwik_Translate('Referers_ColumnKeyword'),
@@ -92,9 +92,16 @@ class Piwik_Live_Controller extends Piwik_Controller
$view->disableSort();
$view->setLimit(10);
- $view->disableExcludeLowPopulation();
+ $view->disableExcludeLowPopulation();
$view->setSortedColumn('idVisit', 'ASC');
-
+ $view->disableSearchBox();
+ // "Include low population" link won't be displayed under this table
+ $view->disableExcludeLowPopulation();
+ // disable the tag cloud, pie charts, bar chart icons
+ $view->disableShowAllViewsIcons();
+ // disable the button "show more datas"
+ $view->disableShowAllColumns();
+
return $this->renderView($view, $fetch);
}
@@ -102,9 +109,9 @@ class Piwik_Live_Controller extends Piwik_Controller
{
$view = Piwik_ViewDataTable::factory('');
$view->init( $this->pluginName,
- __FUNCTION__,
+ __FUNCTION__,
'Live.getLastVisitsForVisitor',
- 'getPagesFromVisitId');
+ 'getPagesFromVisitId');
#$view->disableSearchBox();
#$view->disableExcludeLowPopulation();
@@ -112,22 +119,23 @@ class Piwik_Live_Controller extends Piwik_Controller
#$view->setColumnTranslation('label', Piwik_Translate('Referers_ColumnKeyword'));
return $this->renderView($view, $fetch);
- }
+ }
- public function getLastVisitsStart($fetch = false)
+ public function getLastVisitsStart($fetch = false)
{
$view = Piwik_View::factory('lastVisits');
$this->setGeneralVariablesView($view);
$view->visitors = $this->getLastVisits(10);
+
$rendered = $view->render($fetch);
-
+
if($fetch)
{
return $rendered;
}
- echo $rendered;
+ echo $rendered;
}
-
+
public function getLastVisits($limit = 10)
{
$api = new Piwik_API_Request("method=Live.getLastVisits&idSite=$this->idSite&limit=$limit&minIdVisit=$this->minIdVisit&format=php&serialize=0&disable_generic_filters=1");
@@ -135,44 +143,44 @@ class Piwik_Live_Controller extends Piwik_Controller
return $visitors;
}
-
+
public function getUsersInLastXMin($minutes = 30) {
$api = new Piwik_API_Request("method=Live.getUsersInLastXMin&idSite=".$this->idSite."&limit=10000&minIdVisit=".$this->minIdVisit."&minutes=".$minutes."&format=php&serialize=0&disable_generic_filters=1");
$visitors_halfhour = $api->process();
-
+
return count($visitors_halfhour);
}
-
+
public function getUsersInLastXDays($days = 1) {
$api = new Piwik_API_Request("method=Live.getUsersInLastXDays&idSite=$this->idSite&limit=50000&minIdVisit=$this->minIdVisit&days=$days&format=php&serialize=0&disable_generic_filters=1");
$visitors_today = $api->process();
-
+
return count($visitors_today);
}
-
+
public function getPageImpressionsInLastXMin($minutes = 30) {
$api = new Piwik_API_Request("method=Live.getPageImpressionsInLastXMin&idSite=$this->idSite&limit=10000&minIdVisit=$this->minIdVisit&minutes=$minutes&format=php&serialize=0&disable_generic_filters=1");
$pis_halfhour = $api->process();
-
+
return count($pis_halfhour);
}
-
+
public function getPageImpressionsInLastXDays($days = 1) {
$api = new Piwik_API_Request("method=Live.getPageImpressionsInLastXDays&idSite=$this->idSite&limit=50000&minIdVisit=$this->minIdVisit&days=$days&format=php&serialize=0&disable_generic_filters=1");
$pis_today = $api->process();
-
+
return count($pis_today);
}
-
+
public function ajaxTotalVisitors($fetch = false)
{
- $view = Piwik_View::factory('totalVisits');
+ $view = Piwik_View::factory('totalVisits');
$this->setGeneralVariablesView($view);
$view->visitorsCountHalfHour = $this->getUsersInLastXMin(30);
$view->visitorsCountToday = $this->getUsersInLastXDays(1);
$view->pisHalfhour = $this->getPageImpressionsInLastXMin(30);
$view->pisToday = $this->getPageImpressionsInLastXDays(1);
-
- echo $view->render();
- }
+
+ echo $view->render();
+ }
}
diff --git a/plugins/Live/Live.php b/plugins/Live/Live.php
index 9c1b82a8d2..9a1788cb05 100644
--- a/plugins/Live/Live.php
+++ b/plugins/Live/Live.php
@@ -1,11 +1,11 @@
<?php
/**
* Piwik - Open source web analytics
- *
+ *
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
* @version $Id$
- *
+ *
* @category Piwik_Plugins
* @package Piwik_Live
*/
@@ -20,7 +20,7 @@
- simple stats above in TEXT
- Security review
- blog post, push version
-
+
//TODO add api to get actions name/count/first/last/etc
*/
@@ -40,7 +40,7 @@ class Piwik_Live extends Piwik_Plugin
'version' => Piwik_Version::VERSION,
);
}
-
+
function getListHooksRegistered()
{
return array(
@@ -49,19 +49,19 @@ class Piwik_Live extends Piwik_Plugin
'Menu.add' => 'addMenu',
);
}
-
+
function css()
{
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"themes/default/styles.css\" />\n";
}
-
+
function addMenu()
{
Piwik_AddMenu('General_Visitors', 'Live_VisitorLog', array('module' => 'Live', 'action' => 'getLastVisitsDetails'));
}
-
+
public function addWidget() {
Piwik_AddWidget('Live!', 'Live Visitors!', 'Live', 'widget');
}
-
+
}
diff --git a/plugins/Live/Visitor.php b/plugins/Live/Visitor.php
index 6afce54ddb..a90ba8f94a 100644
--- a/plugins/Live/Visitor.php
+++ b/plugins/Live/Visitor.php
@@ -1,11 +1,11 @@
<?php
/**
* Piwik - Open source web analytics
- *
+ *
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
* @version $Id$
- *
+ *
* @category Piwik_Plugins
* @package Piwik_Live
*/
@@ -35,7 +35,7 @@ class Piwik_Live_Visitor
{
$this->details = $visitorRawData;
}
-
+
function getAllVisitorDetails()
{
return array(
@@ -54,7 +54,7 @@ class Piwik_Live_Visitor
'visitLengthPretty' => $this->getVisitLengthPretty(),
'firstActionTimestamp' => $this->getTimestampFirstAction(),
'lastActionTimestamp' => $this->getTimestampLastAction(),
-
+
'refererType' => $this->getRefererType(),
'refererName' => $this->getRefererTypeName(),
'keywords' => $this->getKeywords(),
@@ -62,7 +62,7 @@ class Piwik_Live_Visitor
'refererName' => $this->getRefererName(),
'searchEngineUrl' => $this->getSearchEngineUrl(),
'searchEngineIcon' => $this->getSearchEngineIcon(),
-
+
'operatingSystem' => $this->getOperatingSystem(),
'operatingSystemShortName' => $this->getOperatingSystemShortName(),
'operatingSystemIcon' => $this->getOperatingSystemIcon(),
@@ -75,14 +75,17 @@ class Piwik_Live_Visitor
'screenIcon' => $this->getScreenTypeIcon(),
'plugins' => $this->getPlugins(),
'lastActionDateTime' => $this->getDateTimeLastAction(),
+ 'isVisitorGoalConverted' => $this->isVisitorGoalConverted(),
+ 'goalIcon' => $this->getGoalIcon(),
+ 'goalType' => $this->getGoalType(),
);
}
-
+
function getServerDate()
{
return $this->details['visit_server_date'];
}
-
+
function getIp()
{
if(isset($this->details['location_ip']))
@@ -91,17 +94,17 @@ class Piwik_Live_Visitor
}
return false;
}
-
+
function getIdVisit()
{
return $this->details['idvisit'];
}
-
+
function getIdSite()
{
return $this->details['idsite'];
}
-
+
function getNumberOfActions()
{
return $this->details['visit_total_actions'];
@@ -111,42 +114,42 @@ class Piwik_Live_Visitor
{
return $this->details['visit_total_time'];
}
-
+
function getVisitLengthPretty()
{
return Piwik::getPrettyTimeFromSeconds($this->details['visit_total_time']);
}
-
+
function isVisitorReturning()
{
return $this->details['visitor_returning'];
}
-
+
function getTimestampFirstAction()
{
return strtotime($this->details['visit_first_action_time']);
}
-
+
function getTimestampLastAction()
{
return strtotime($this->details['visit_last_action_time']);
}
-
+
function getCountryName()
{
return Piwik_CountryTranslate($this->details['location_country']);
}
-
+
function getCountryFlag()
{
return Piwik_getFlagFromCode($this->details['location_country']);
}
-
+
function getContinent()
{
return Piwik_ContinentTranslate($this->details['location_continent']);
}
-
+
function getRefererType()
{
$map = array(
@@ -161,27 +164,27 @@ class Piwik_Live_Visitor
}
return $map[Piwik_Common::REFERER_TYPE_DIRECT_ENTRY];
}
-
+
function getRefererTypeName()
{
return Piwik_getRefererTypeLabel($this->details['referer_type']);
}
-
+
function getKeywords()
{
return $this->details['referer_keyword'];
}
-
+
function getRefererUrl()
{
- return $this->details['referer_url'];
+ return $this->details['referer_url'];
}
-
+
function getRefererName()
{
- return $this->details['referer_name'];
+ return $this->details['referer_name'];
}
-
+
function getSearchEngineUrl()
{
if($this->getRefererType() == 'searchEngine'
@@ -191,7 +194,7 @@ class Piwik_Live_Visitor
}
return null;
}
-
+
function getSearchEngineIcon()
{
$searchEngineUrl = $this->getSearchEngineUrl();
@@ -204,7 +207,7 @@ class Piwik_Live_Visitor
function getPlugins()
{
- $plugins = array(
+ $plugins = array(
'config_pdf',
'config_flash',
'config_java',
@@ -218,10 +221,10 @@ class Piwik_Live_Visitor
$return = array();
foreach($plugins as $plugin)
{
- if($this->details[$plugin] == 1)
+ if($this->details[$plugin] == 1)
{
$pluginShortName = substr($plugin, 7);
- $return[] = $pluginShortName;
+ $return[] = $pluginShortName;
}
}
return implode(", ", $return);
@@ -231,12 +234,12 @@ class Piwik_Live_Visitor
{
return Piwik_getOSLabel($this->details['config_os']);
}
-
+
function getOperatingSystemShortName()
{
return Piwik_getOSShortLabel($this->details['config_os']);
}
-
+
function getOperatingSystemIcon()
{
return Piwik_getOSLogo($this->details['config_os']);
@@ -246,49 +249,87 @@ class Piwik_Live_Visitor
{
return Piwik_getBrowserTypeLabel($this->getBrowserFamily());
}
-
+
function getBrowserFamily()
{
return Piwik_getBrowserFamily($this->details['config_browser_name']);
}
-
+
function getBrowser()
{
return Piwik_getBrowserLabel($this->details['config_browser_name'] . ";" . $this->details['config_browser_version']);
}
-
+
function getBrowserIcon()
{
return Piwik_getBrowsersLogo($this->details['config_browser_name'] . ";" . $this->details['config_browser_version']);
}
-
+
function getScreenType()
{
return Piwik_getScreenTypeFromResolution($this->details['config_resolution']);
}
-
+
function getResolution()
{
return $this->details['config_resolution'];
}
-
+
function getScreenTypeIcon()
{
return Piwik_getScreensLogo($this->getScreenType());
}
-
+
function getProvider()
{
return Piwik_getHostnameName($this->details['location_provider']);
}
-
+
function getProviderUrl()
{
return Piwik_getHostnameUrl($this->details['location_provider']);
}
-
+
function getDateTimeLastAction()
{
return date('Y-m-d H:i:s', strtotime($this->details['visit_last_action_time']));
}
+
+ function isVisitorGoalConverted()
+ {
+ return $this->details['visit_goal_converted'];
+ }
+
+ function getGoalType()
+ {
+ if(isset($this->details['match_attribute'])){
+ return $this->details['match_attribute'];
+ }
+ else {
+ return false;
+ }
+ }
+
+ function getGoalIcon()
+ {
+ $goalicon = "";
+ if(isset($this->details['match_attribute'])){
+ switch ($this->details['match_attribute']) {
+ case "url":
+ $goalicon = "plugins/Live/templates/images/goal.png";
+ break;
+ case "file":
+ $goalicon = "plugins/Live/templates/images/download.png";
+ break;
+ case "external_website":
+ $goalicon = "plugins/Live/templates/images/outboundlink.png";
+ break;
+ }
+ return $goalicon;
+ }
+ else {
+ return false;
+ }
+ }
+
}
diff --git a/plugins/Live/templates/images/download.png b/plugins/Live/templates/images/download.png
new file mode 100644
index 0000000000..1920b1bb22
--- /dev/null
+++ b/plugins/Live/templates/images/download.png
Binary files differ
diff --git a/plugins/Live/templates/images/goal.png b/plugins/Live/templates/images/goal.png
new file mode 100644
index 0000000000..e4bc611f87
--- /dev/null
+++ b/plugins/Live/templates/images/goal.png
Binary files differ
diff --git a/plugins/Live/templates/images/outboundlink.png b/plugins/Live/templates/images/outboundlink.png
new file mode 100644
index 0000000000..0010931e2c
--- /dev/null
+++ b/plugins/Live/templates/images/outboundlink.png
Binary files differ
diff --git a/plugins/Live/templates/index.tpl b/plugins/Live/templates/index.tpl
index d5ac305395..46bf5cacfb 100644
--- a/plugins/Live/templates/index.tpl
+++ b/plugins/Live/templates/index.tpl
@@ -3,36 +3,36 @@
<script type="text/javascript" charset="utf-8">
-
- $(document).ready(function() {
+
+ $(document).ready(function() {
if($('#_spyTmp').size() == 0) {
$('#visitsLive > div:gt(2)').fadeEachDown(); // initial fade
- $('#visitsLive').spy({
- limit: 10,
- ajax: 'index.php?module=Live&idSite={/literal}{$idSite}{literal}&action=getLastVisitsStart',
- fadeLast: 2,
+ $('#visitsLive').spy({
+ limit: 10,
+ ajax: 'index.php?module=Live&idSite={/literal}{$idSite}{literal}&action=getLastVisitsStart',
+ fadeLast: 2,
isDupes : check_for_dupe,
timeout: 20000,
- customParameterName: 'minIdVisit',
+ customParameterName: 'minIdVisit',
customParameterValueCallback: lastIdVisit,
fadeInSpeed: 1400
});
}
});
-
+
// first I'm ensuring that 'last' has been initialised (with last.constructor == Object),
// then prev.html() == last.html() will return true if the HTML is the same, or false,
// if I have a different entry.
function check_for_dupe(prev, last)
{
-
+
if (last.constructor == Object) {
return (prev.html() == last.html());
- }
+ }
else {
return 0;
-
- }
+
+ }
}
function lastIdVisit()
@@ -46,7 +46,7 @@
var pauseDisabledImage = "plugins/Live/templates/images/pause_disabled.gif";
var playImage = "plugins/Live/templates/images/play.gif";
var playDisabledImage = "plugins/Live/templates/images/play_disabled.gif";
-
+
function onClickPause()
{
$('#pauseImage').attr('src', pauseImage);
@@ -59,19 +59,28 @@
$('#pauseImage').attr('src', pauseDisabledImage);
return playSpy();
}
-
+
// updates the numbers of total visits in startbox
function updateTotalVisits()
{
$("#visitsTotal").load("index.php?module=Live&idSite={/literal}{$idSite}{literal}&action=ajaxTotalVisitors");
}
-
+
// updates the visit table, to refresh the already presented visotors pages
function updateVisitBox()
{
$("#visitsLive").load("index.php?module=Live&idSite={/literal}{$idSite}{literal}&action=getLastVisitsStart");
}
+ /* TOOLTIP */
+ $('#visitsLive label').tooltip({
+ track: true,
+ delay: 0,
+ showURL: false,
+ showBody: " - ",
+ fade: 250
+ });
+
</script>
<style>
@@ -82,7 +91,7 @@
#visitsLive .datetime, #visitsLive .country, #visitsLive .referer, #visitsLive .settings, #visitsLive .returning , #visitsLive .countActions{
border-bottom:1px solid #C1DAD7;
border-right:1px solid #C1DAD7;
- padding:5px 5px 5px 12px;
+ padding:5px 5px 5px 12px;
}
#visitsLive .datetime {
@@ -169,6 +178,6 @@
</div>
<div>
- <a href="javascript:void(0);" onclick="onClickPause();"><img id="pauseImage" border="0" src="plugins/Live/templates/images/pause_disabled.gif"></a>
+ <a href="javascript:void(0);" onclick="onClickPause();"><img id="pauseImage" border="0" src="plugins/Live/templates/images/pause_disabled.gif"></a>
<a href="javascript:void(0);" onclick="onClickPlay();"><img id="playImage" border="0" src="plugins/Live/templates/images/play.gif"></a>
</div>
diff --git a/plugins/Live/templates/lastVisits.tpl b/plugins/Live/templates/lastVisits.tpl
index ccc48967a7..db19258752 100644
--- a/plugins/Live/templates/lastVisits.tpl
+++ b/plugins/Live/templates/lastVisits.tpl
@@ -2,34 +2,34 @@
<div class="visit{if $visitor.idVisit % 2} alt{/if}">
<!--<div class="idvisit">{$visitor.idVisit}</div>-->
<div style="display:none" class="idvisit">{$visitor.idVisit}</div>
-
+
<div class="datetime">
{$visitor.serverDatePretty} - {$visitor.serverTimePretty}
&nbsp;<img src="{$visitor.countryFlag}" title="{$visitor.country}, Provider {$visitor.provider}">
&nbsp;<img src="{$visitor.browserIcon}" title="{$visitor.browser} with plugins {$visitor.plugins} enabled">
- &nbsp;<img src="{$visitor.operatingSystemIcon}" title="{$visitor.operatingSystem}, {$visitor.resolution}">
- </div>
- <div class="settings">
- {$visitor.ip}
- {if $visitor.isVisitorReturning}<img src="plugins/Live/templates/images/returningVisitor.gif" title="Returning Visitor">{/if}
+ &nbsp;<img src="{$visitor.operatingSystemIcon}" title="{$visitor.operatingSystem}, {$visitor.resolution}">
+ &nbsp;{if $visitor.isVisitorGoalConverted}<img src="{$visitor.goalIcon}" title="{$visitor.goalType}">{/if}
+ {if $visitor.isVisitorReturning}&nbsp;<img src="plugins/Live/templates/images/returningVisitor.gif" title="Returning Visitor">{/if}
+ &nbsp;<label id="" title="IP: {$visitor.ip} - Duration: {$visitor.visitLengthPretty}">more...</label>
</div>
+ <!--<div class="settings"></div>-->
<div class="referer">
- {if $visitor.refererType != 'directEntry'}from <a href="{$visitor.refererUrl}">{if !empty($visitor.searchEngineIcon)}<img src="{$visitor.searchEngineIcon}"> {/if}{$visitor.refererName}</a>
+ {if $visitor.refererType != 'directEntry'}from <a href="{$visitor.refererUrl}">{if !empty($visitor.searchEngineIcon)}<img src="{$visitor.searchEngineIcon}"> {/if}{$visitor.refererName}</a>
{if !empty($visitor.keywords)}"{$visitor.keywords}"{/if}
{/if}
{if $visitor.refererType == 'directEntry'}Direct entry{/if}
</div>
- <div id="{$visitor.idVisit}_actions" class="actions">
+ <div id="{$visitor.idVisit}_actions" class="settings">
<span class="pagesTitle">Pages:</span>&nbsp;
{php} $col = 0; {/php}
{foreach from=$visitor.actionDetails item=action}
- {php}
- $col++;
+ {php}
+ $col++;
if ($col>=9)
{
$col=0;
}
- {/php}
+ {/php}
<a href="{$action.pageUrl}" target="_blank"><img align="middle" src="plugins/Live/templates/images/file{php} echo $col; {/php}.png" title="{$action.pageUrl}"></a>
{/foreach}
</div>
diff --git a/plugins/Live/templates/scripts/spy.js b/plugins/Live/templates/scripts/spy.js
index 75d0665881..27454fe029 100644
--- a/plugins/Live/templates/scripts/spy.js
+++ b/plugins/Live/templates/scripts/spy.js
@@ -12,12 +12,12 @@ $.fn.spy = function(settings) {
spy.parsing = 0;
spy.waitTimer = 0;
spy.json = null;
-
+
if (!settings.ajax) {
alert("An AJAX/AJAH URL must be set for the spy to work.");
return;
}
-
+
spy.attachHolder = function() {
// not mad on this, but the only way to parse HTML collections
if (o.method == 'html')
@@ -37,7 +37,7 @@ $.fn.spy = function(settings) {
else
return 0;
}
-
+
spy.parse = function(e, r) {
spy.parsing = 1; // flag to stop pull via ajax
if (o.method == 'html') {
@@ -45,7 +45,7 @@ $.fn.spy = function(settings) {
} else if (o.method == 'json') {
eval('spy.json = ' + r); // convert text to json
}
-
+
if ((o.method == 'json' && spy.json.constructor == Array) || o.method == 'html') {
if (spy.parseItem(e)) {
spy.waitTimer = window.setInterval(function() {
@@ -65,7 +65,7 @@ $.fn.spy = function(settings) {
spy.parsing = 0;
}
}
-
+
// returns true if there's more to parse
spy.parseItem = function(e) {
if (o.method == 'html') {
@@ -74,7 +74,7 @@ $.fn.spy = function(settings) {
if (i.size() > 0) {
i.hide();
spy.addItem(e, i);
- }
+ }
return ($('div#_spyTmp').find('div').size() != 0);
} else {
if (spy.json.length) {
@@ -85,7 +85,7 @@ $.fn.spy = function(settings) {
return (spy.json.length != 0);
}
}
-
+
spy.addItem = function(e, i) {
if (! o.isDupe.call(this, i, spy.last)) {
spy.last = i; // note i is a pointer - so when it gets modified, so does spy.last
@@ -95,11 +95,11 @@ $.fn.spy = function(settings) {
$('#' + e.id + ' > div:first').fadeIn(o.fadeInSpeed);
}
}
-
+
spy.push = function(r) {
$('#' + this.id).prepend(r);
}
-
+
var o = {
limit: (settings.limit || 10),
ajax: settings.ajax,
@@ -126,7 +126,7 @@ $.fn.spy = function(settings) {
$.get(o.ajax, parameters, function(r) {
spy.parse(e, r);
});
- }
+ }
}, o.timeout);
});
};
diff --git a/plugins/Live/templates/totalVisits.tpl b/plugins/Live/templates/totalVisits.tpl
index 574d223c31..8164501561 100644
--- a/plugins/Live/templates/totalVisits.tpl
+++ b/plugins/Live/templates/totalVisits.tpl
@@ -21,4 +21,4 @@
<td class="columnodd">{$pisHalfhour}</td>
</tr>
</table>
-</div> \ No newline at end of file
+</div>