summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspiderr <spider@viovio.com>2011-02-14 22:45:03 -0500
committerspiderr <spider@viovio.com>2011-02-14 22:45:03 -0500
commite31159c25bc789281405b15c90d70d4090b46550 (patch)
treeae80dd4f9a828d7334d895f1b552bf919d4cfab9
parentcb5b143027cd418f942d89d1bda363e8aea938bd (diff)
downloadstats-e31159c25bc789281405b15c90d70d4090b46550.tar.gz
stats-e31159c25bc789281405b15c90d70d4090b46550.tar.bz2
stats-e31159c25bc789281405b15c90d70d4090b46550.zip
add timeframe view
-rw-r--r--Statistics.php33
-rw-r--r--templates/referer_stats.tpl4
-rw-r--r--templates/user_stats.tpl6
3 files changed, 28 insertions, 15 deletions
diff --git a/Statistics.php b/Statistics.php
index 2e58ea5..9f547ba 100644
--- a/Statistics.php
+++ b/Statistics.php
@@ -58,43 +58,56 @@ class Statistics extends BitBase {
$ret = $bindVars = array();
$selectSql = $joinSql = $whereSql = $groupSql = "";
+ $hashSql = "uu.`user_id` AS `hash_key`, ";
+
if( empty( $pListHash['sort_mode'] )) {
$pListHash['sort_mode'] = 'uu.`registration_date_desc`';
}
self::prepGetList( $pListHash );
- if( !empty( $pListHash['period_format'] ) ) {
+ if( !empty( $pListHash['period_format'] ) && !empty( $pListHash['timeframe'] ) ) {
$whereSql .= empty( $whereSql ) ? ' WHERE ' : ' AND ';
$whereSql .= $this->mDb->SQLDate( $pListHash['period_format'], $this->mDb->SQLIntToTimestamp( 'registration_date' )).'=?';
- $bindVars[] = $pListHash['itemize'];
+ $bindVars[] = $pListHash['timeframe'];
+ $hashKey = 'host';
}
if( !empty( $pListHash['find'] ) && is_string( $pListHash['find'] )) {
$whereSql .= empty( $whereSql ) ? ' WHERE ' : ' AND ';
- $whereSql .= " UPPER( `referer` ) LIKE ?";
+ $whereSql .= " UPPER( `referer_url` ) LIKE ?";
$bindVars[] = '%'.strtoupper( $pListHash['find'] ).'%';
+ if( !empty( $pListHash['period_format'] ) ) {
+ $hashSql = $this->mDb->SQLDate( $pListHash['period_format'], $this->mDb->SQLIntToTimestamp( 'registration_date' )).' AS `hash_key`,';
+ $hashKey = 'period';
+ }
}
- $query = "SELECT uu.`user_id` AS `hash_key`, uu.*, sru.`referer_url`
+ $query = "SELECT $hashSql uu.*, sru.`referer_url`
FROM `".BIT_DB_PREFIX."users_users` uu
LEFT JOIN `".BIT_DB_PREFIX."stats_referer_users_map` srum ON(uu.`user_id`=srum.`user_id`)
LEFT JOIN `".BIT_DB_PREFIX."stats_referer_urls` sru ON (sru.`referer_url_id`=srum.`referer_url_id`)
$whereSql ORDER BY ".$this->mDb->convertSortmode( $pListHash['sort_mode'] );
if( $rs = $this->mDb->query( $query, $bindVars, -1, $pListHash['offset'] ) ) {
+
while( $row = $rs->fetchRow() ) {
- $host = 'none';
- if( !empty( $row['referer_url'] ) ) {
- $parseUrl = parse_url( $row['referer_url'] );
- $host = $parseUrl['host'];
+ $key = $row['hash_key'];
+ if( $hashKey == 'host' ) {
+ $key = 'none';
+ if( !empty( $row['referer_url'] ) ) {
+ $parseUrl = parse_url( $row['referer_url'] );
+ $key = $parseUrl['host'];
+ }
}
- $ret[$host][$row['user_id']] = $row;
+ $ret[$key][$row['user_id']] = $row;
}
}
LibertyContent::postGetList( $pListHash );
- uasort( $ret, array( $this, 'sortRefererHash' ) );
+ if( $hashKey == 'host' ) {
+ uasort( $ret, array( $this, 'sortRefererHash' ) );
+ }
return $ret;
}
diff --git a/templates/referer_stats.tpl b/templates/referer_stats.tpl
index a7e4b09..80475bc 100644
--- a/templates/referer_stats.tpl
+++ b/templates/referer_stats.tpl
@@ -13,8 +13,8 @@
{foreach from=$referers key=host item=reg}
{assign var=hostHash value=$host|md5}
<tr>
- <th style="width:5%;">{$reg|@count} ({math equation="round((x / y) * 100)" x=$reg|@count y=$totalRegistrations}%)</th>
- <th>{biticon iname='folder-saved-search' onclick="BitBase.toggleElementDisplay('`$hostHash`','table-row-group');" class="floaticon"} <div style="width:{math equation="round( ( r / m ) * 100 )" r=$reg|@count m=$maxRegistrations}%; background:#f80;padding:0 0 0 5px;">{$host|escape}</div></th>
+ <th style="width:5%;">{$reg|@count}</th>
+ <th><div class="floaticon"> [{math equation="round((x / y) * 100)" x=$reg|@count y=$totalRegistrations}% ] <a href="{$smarty.server.PHP_SELF}?period={$smarty.request.period}&amp;find={$host|escape}">{biticon iname='appointment-new'}</a>{biticon iname='folder-saved-search' onclick="BitBase.toggleElementDisplay('`$hostHash`','table-row-group');"}</div> <div style="width:{math equation="round( ( r / m ) * 100 )" r=$reg|@count m=$maxRegistrations}%; background:#f80;padding:0 0 0 5px;">{$host|escape}</div></th>
</tr>
<tbody id="{$hostHash}" style="display:none">
diff --git a/templates/user_stats.tpl b/templates/user_stats.tpl
index ed49f89..18d6681 100644
--- a/templates/user_stats.tpl
+++ b/templates/user_stats.tpl
@@ -21,10 +21,10 @@
<th style="width:20%;" colspan="2">{tr}Period{/tr}</td>
<th style="width:80%;">{tr}Number of Registrations{/tr}</td>
</tr>
- {foreach item=reg key=period from=$userStats.per_period}
+ {foreach item=reg key=timeframe from=$userStats.per_period}
<tr class="{cycle values="even,odd"}">
- <td><a href="{$smarty.const.STATS_PKG_URL}users.php?period={$smarty.request.period}&amp;itemize={$period|urlencode}">{$period}</td>
- <td>[<a href="{$smarty.const.STATS_PKG_URL}referer_stats.php?period={$smarty.request.period}&amp;itemize={$period|urlencode}">Referrers</a>]</td>
+ <td><a href="{$smarty.const.STATS_PKG_URL}users.php?period={$smarty.request.period}&amp;timeframe={$timeframe|urlencode}">{$timeframe}</td>
+ <td>[<a href="{$smarty.const.STATS_PKG_URL}referer_stats.php?period={$smarty.request.period}&amp;timeframe={$timeframe|urlencode}">Referrers</a>]</td>
<td><div style="width:{math equation="round( ( r / m ) * 100 )" r=$reg m=$userStats.max}%; background:#f80;padding:0 0 0 5px;">{$reg}</div></td>
</tr>
{foreachelse}