diff options
| -rw-r--r-- | admin/schema_inc.php | 2 | ||||
| -rw-r--r-- | stats_lib.php | 16 | ||||
| -rw-r--r-- | templates/stats.tpl | 6 | ||||
| -rw-r--r-- | templates/user_stats.tpl | 32 | ||||
| -rw-r--r-- | users.php | 47 |
5 files changed, 97 insertions, 6 deletions
diff --git a/admin/schema_inc.php b/admin/schema_inc.php index 4d72142..0905f2b 100644 --- a/admin/schema_inc.php +++ b/admin/schema_inc.php @@ -13,7 +13,7 @@ $tables = array( global $gBitInstaller; foreach( array_keys( $tables ) AS $tableName ) { - $gBitInstaller->registerSchemaTable( STATS_PKG_DIR, $tableName, $tables[$tableName] ); + $gBitInstaller->registerSchemaTable( STATS_PKG_NAME, $tableName, $tables[$tableName] ); } $gBitInstaller->registerPackageInfo( STATS_PKG_NAME, array( diff --git a/stats_lib.php b/stats_lib.php index 7605e15..f09f615 100644 --- a/stats_lib.php +++ b/stats_lib.php @@ -1,6 +1,6 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_stats/Attic/stats_lib.php,v 1.2 2005/06/28 07:45:58 spiderr Exp $ + * $Header: /cvsroot/bitweaver/_bit_stats/Attic/stats_lib.php,v 1.3 2005/07/17 17:36:17 squareing Exp $ * * Copyright (c) 2004 bitweaver.org * Copyright (c) 2003 tikwiki.org @@ -8,7 +8,7 @@ * All Rights Reserved. See copyright.txt for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details * - * $Id: stats_lib.php,v 1.2 2005/06/28 07:45:58 spiderr Exp $ + * $Id: stats_lib.php,v 1.3 2005/07/17 17:36:17 squareing Exp $ * @package stats */ @@ -327,6 +327,18 @@ class StatsLib extends BitBase { return $stats; } + function registrationStats( $pPeriod ) { + if( !is_numeric( $pPeriod ) || empty( $pPeriod ) ) { + $pPeriod = 86400; + } + $query = "SELECT ((`registration_date` / ?) * ?) AS day, COUNT(`user_id`) FROM `".BIT_DB_PREFIX."users_users` + GROUP BY( `registration_date` / ? ) ORDER BY COUNT(`user_id`) DESC"; + $stats['per_period'] = $this->GetAssoc( $query, array( $pPeriod, $pPeriod, $pPeriod ) ); + $stats['max'] = !empty( $stats['per_period'] ) ? current( $stats['per_period'] ) : 0; + krsort( $stats['per_period'] ); + return $stats; + } + function user_stats() { $stats = array(); $stats["users"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."users_users`",array()); diff --git a/templates/stats.tpl b/templates/stats.tpl index cc7d60b..4b04d34 100644 --- a/templates/stats.tpl +++ b/templates/stats.tpl @@ -1,4 +1,4 @@ -{* $Header: /cvsroot/bitweaver/_bit_stats/templates/stats.tpl,v 1.2 2005/06/28 07:45:59 spiderr Exp $ *} +{* $Header: /cvsroot/bitweaver/_bit_stats/templates/stats.tpl,v 1.3 2005/07/17 17:36:17 squareing Exp $ *} <div class="display statistics"> <div class="header"> <h1>{tr}Stats{/tr}</h1> @@ -146,7 +146,7 @@ <!-- Users stats --> {if $user_stats} <tr><th colspan="2"><a name="user_stats"></a>{tr}User Stats{/tr}</th></tr> - <tr><td>{tr}Users{/tr}</td><td style="text-align:right;">{$user_stats.users}</td></tr> + <tr><td>{tr}<a href="{$gBitLoc.STATS_PKG_URL}users.php">Users</a>{/tr}</td><td style="text-align:right;">{$user_stats.users}</td></tr> <tr><td>{tr}User bookmarks{/tr}</td><td style="text-align:right;">{$user_stats.bookmarks}</td></tr> <tr><td>{tr}Average bookmarks per user{/tr}</td><td style="text-align:right;">{$user_stats.bpu|string_format:"%.2f"}</td></tr> <tr><td colspan="2"> </td></tr> @@ -181,7 +181,7 @@ <input type="submit" name="pv_chart" value="{tr}display{/tr}" /> {/form} - {if $pv_chart eq 'y'} + {if $pv_chart eq 'y'} <div align="center"> <img src="{$gBitLoc.STATS_PKG_URL}pv_chart.php?days={$days}" alt="" /> </div> diff --git a/templates/user_stats.tpl b/templates/user_stats.tpl new file mode 100644 index 0000000..79bbe68 --- /dev/null +++ b/templates/user_stats.tpl @@ -0,0 +1,32 @@ +{* $Header: /cvsroot/bitweaver/_bit_stats/templates/user_stats.tpl,v 1.2 2005/07/17 17:36:17 squareing Exp $ *}
+<div class="display statistics">
+ <div class="header">
+ <h1>{tr}Site Registrations{/tr}</h1>
+ </div>
+
+ <div class="navbar">
+ <ul>
+ <li><a href="{$gTikiLoc.STATS_PKG_URL}users.php?period=86400">{tr}Daily{/tr}</a></li>
+ <li><a href="{$gTikiLoc.STATS_PKG_URL}users.php?period=604800">{tr}Weekly{/tr}</a></li>
+ <li><a href="{$gTikiLoc.STATS_PKG_URL}users.php?period=2592000">{tr}30 Days{/tr}</a></li>
+ </ul>
+ </div>
+
+ <div class="clear"></div>
+
+ <div class="body">
+ <ul class="data">
+ {foreach item=reg key=period from=$userStats.per_period}
+ <li class="item {cycle values="even,odd"}">
+ {$period|bit_long_date}
+ {tr}{$reg} registrations{/tr}
+ <div style="width:{math equation="round( (r / m) * 100 )" r=$reg m=$userStats.max}%; background:#f80;height:20px;"></div>
+ </li>
+ {foreachelse}
+ <li class="norecords">
+ No results for {$periodName}
+ </li>
+ {/foreach}
+ </ul>
+ </div> <!-- end .body -->
+</div> <!-- end .statistics -->
diff --git a/users.php b/users.php new file mode 100644 index 0000000..7c9c587 --- /dev/null +++ b/users.php @@ -0,0 +1,47 @@ +<?php
+/**
+ * $Header: /cvsroot/bitweaver/_bit_stats/users.php,v 1.2 2005/07/17 17:36:17 squareing Exp $
+ *
+ * Copyright (c) 2005 bitweaver.org
+ * All Rights Reserved. See copyright.txt for details and a complete list of authors.
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
+ *
+ * $Id: users.php,v 1.2 2005/07/17 17:36:17 squareing Exp $
+ * @package stats
+ * @subpackage functions
+ */
+
+require_once( '../bit_setup_inc.php' );
+
+include_once( STATS_PKG_PATH.'stats_lib.php' );
+global $statslib, $gBitSystem;
+
+$gBitSystem->verifyPackage( 'stats' );
+
+$gBitSystem->verifyPermission( 'bit_p_view_stats' );
+
+if (!isset($_REQUEST["period"])) {
+ $_REQUEST["period"] = 86400;
+}
+
+switch( $_REQUEST["period"] ) {
+ case 2592000:
+ $periodName = '30 Days';
+ break;
+ case 604800:
+ $periodName = 'Weekly';
+ break;
+ case 86400:
+ $periodName = 'Daily';
+ break;
+}
+$smarty->assign( 'periodName', $periodName );
+
+$stats = $statslib->registrationStats( $_REQUEST["period"] );
+
+$smarty->assign_by_ref( 'userStats', $stats );
+
+// Display the template
+$gBitSystem->display( 'bitpackage:stats/user_stats.tpl');
+
+?>
\ No newline at end of file |
