summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--admin/schema_inc.php39
-rw-r--r--bit_setup_inc.php29
-rw-r--r--icons/pkg_stats.pngbin0 -> 1957 bytes
-rw-r--r--index.php112
-rw-r--r--pv_chart.php38
-rw-r--r--referer_stats.php80
-rw-r--r--stats_lib.php397
-rw-r--r--templates/index.php6
-rw-r--r--templates/menu_stats.tpl9
-rw-r--r--templates/referer_stats.tpl48
-rw-r--r--templates/search_stats.tpl46
-rw-r--r--templates/stats.tpl189
-rw-r--r--usage_chart.php33
13 files changed, 1026 insertions, 0 deletions
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
new file mode 100644
index 0000000..f22a81c
--- /dev/null
+++ b/admin/schema_inc.php
@@ -0,0 +1,39 @@
+<?php
+
+$tables = array(
+
+'tiki_referer_stats' => "
+ referer C(50) NOTNULL,
+ hits I8,
+ last I8
+"
+
+);
+
+global $gBitInstaller;
+
+foreach( array_keys( $tables ) AS $tableName ) {
+ $gBitInstaller->registerSchemaTable( STATS_PKG_DIR, $tableName, $tables[$tableName] );
+}
+
+$gBitInstaller->registerPackageInfo( STATS_PKG_NAME, array(
+ 'description' => "Stats collects and display information about your site.",
+ 'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>',
+ 'version' => '0.1',
+ 'state' => 'stable',
+ 'dependencies' => '',
+) );
+
+// ### Default Preferences
+$gBitInstaller->registerPreferences( SHOUTBOX_PKG_NAME, array(
+ array('', 'feature_referer_stats','y')
+) );
+
+// ### Default UserPermissions
+$gBitInstaller->registerUserPermissions( SHOUTBOX_PKG_NAME, array(
+ array('bit_p_view_referer_stats', 'Can view referer stats', 'editors', 'shoutbox'),
+ array('bit_p_view_stats', 'Can view site stats', 'basic', 'shoutbox'),
+) );
+
+
+?>
diff --git a/bit_setup_inc.php b/bit_setup_inc.php
new file mode 100644
index 0000000..2fa83b1
--- /dev/null
+++ b/bit_setup_inc.php
@@ -0,0 +1,29 @@
+<?php
+global $gBitSystem;
+
+$gBitSystem->registerPackage( 'stats', dirname( __FILE__ ).'/' );
+
+if( $gBitSystem->isPackageActive( STATS_PKG_NAME ) ) {
+ if( $gBitUser->hasPermission( 'bit_p_view_site_stats' ) || $gBitUser->hasPermission( 'bit_p_view_ref_stats' ) ) {
+ $gBitSystem->registerAppMenu( 'stats', 'Stats', STATS_PKG_URL.'index.php', 'bitpackage:stats/menu_stats.tpl', 'stats');
+ }
+ global $statslib;
+ require_once( STATS_PKG_PATH.'stats_lib.php' );
+ // ********** STATS ************
+ if ($gBitSystem->isFeatureActive( 'feature_referer_stats' ) ) {
+ // Referer tracking
+ if (isset($_SERVER['HTTP_REFERER'])) {
+ $pref = parse_url($_SERVER['HTTP_REFERER']);
+ if (!strstr($_SERVER["HTTP_HOST"], $pref["host"])) {
+ $statslib->register_referer($pref["host"]);
+ }
+ }
+ }
+ if( $gBitSystem->isFeatureActive( "count_admin_pvs" ) || $gBitUser->isAdmin() ) {
+ if ( isset($_SERVER["REQUEST_URI"]) && !strstr($_SERVER["REQUEST_URI"], 'chat')) {
+ $statslib->add_pageview();
+ }
+ }
+}
+
+?>
diff --git a/icons/pkg_stats.png b/icons/pkg_stats.png
new file mode 100644
index 0000000..a089d65
--- /dev/null
+++ b/icons/pkg_stats.png
Binary files differ
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..456f273
--- /dev/null
+++ b/index.php
@@ -0,0 +1,112 @@
+<?php
+
+// $Header: /cvsroot/bitweaver/_bit_stats/index.php,v 1.1 2005/06/19 05:05:49 bitweaver Exp $
+
+// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
+// 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.
+
+// Initialization
+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["days"])) {
+ $_REQUEST["days"] = 7;
+}
+
+$smarty->assign('pv_chart', 'n');
+
+if (isset($_REQUEST["pv_chart"])) {
+ $smarty->assign('pv_chart', 'y');
+}
+
+$smarty->assign('days', $_REQUEST["days"]);
+
+$smarty->assign('usage_chart', 'n');
+
+if (isset($_REQUEST["chart"])) {
+ $smarty->assign($_REQUEST["chart"] . "_chart", 'y');
+}
+
+if ($gBitSystem->isPackageActive( 'wiki' ) ) {
+ $wiki_stats = $statslib->wiki_stats();
+} else {
+ $wiki_stats = false;
+}
+$smarty->assign_by_ref('wiki_stats', $wiki_stats);
+
+if ($gBitSystem->isPackageActive( 'imagegals' ) ) {
+ $igal_stats = $statslib->image_gal_stats();
+} else {
+ $igal_stats = false;
+}
+$smarty->assign_by_ref('igal_stats', $igal_stats);
+
+if ($gBitSystem->isPackageActive( 'filegals' ) ) {
+ $fgal_stats = $statslib->file_gal_stats();
+} else {
+ $fgal_stats = false;
+}
+$smarty->assign_by_ref('fgal_stats', $fgal_stats);
+
+if ($gBitSystem->isPackageActive( 'articles' ) ) {
+ $cms_stats = $statslib->cms_stats();
+} else {
+ $cms_stats = false;
+}
+$smarty->assign_by_ref('cms_stats', $cms_stats);
+
+if ($gBitSystem->isPackageActive( 'forums' ) ) {
+ $forum_stats = $statslib->forum_stats();
+} else {
+ $forum_stats = false;
+}
+$smarty->assign_by_ref('forum_stats', $forum_stats);
+
+if ($gBitSystem->isPackageActive( 'blogs' ) ) {
+ $blog_stats = $statslib->blog_stats();
+} else {
+ $blog_stats = false;
+}
+$smarty->assign_by_ref('blog_stats', $blog_stats);
+
+if ($gBitSystem->isPackageActive( 'polls' ) ) {
+ $poll_stats = $statslib->poll_stats();
+} else {
+ $poll_stats = false;
+}
+$smarty->assign_by_ref('poll_stats', $poll_stats);
+
+if ($gBitSystem->isPackageActive( 'faqs' ) ) {
+ $faq_stats = $statslib->faq_stats();
+} else {
+ $faq_stats = false;
+}
+$smarty->assign_by_ref('faq_stats', $faq_stats);
+
+if ($gBitSystem->isPackageActive( 'quizzes' ) ) {
+ $quiz_stats = $statslib->quiz_stats();
+} else {
+ $quiz_stats = false;
+}
+$smarty->assign_by_ref('quiz_stats', $quiz_stats);
+
+
+$user_stats = $statslib->user_stats();
+$smarty->assign_by_ref('user_stats', $user_stats);
+
+$site_stats = $statslib->site_stats();
+$smarty->assign_by_ref('site_stats', $site_stats);
+
+
+
+// Display the template
+$gBitSystem->display( 'bitpackage:stats/stats.tpl');
+
+?>
diff --git a/pv_chart.php b/pv_chart.php
new file mode 100644
index 0000000..6eafe46
--- /dev/null
+++ b/pv_chart.php
@@ -0,0 +1,38 @@
+<?php
+
+// $Header: /cvsroot/bitweaver/_bit_stats/pv_chart.php,v 1.1 2005/06/19 05:05:49 bitweaver Exp $
+
+// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
+// 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.
+
+require_once( '../bit_setup_inc.php' );
+//Include the code
+include (UTIL_PKG_PATH."phplot.php");
+global $gBitSystem, $gBitSystem;
+
+if ($gBitSystem->mPrefs['feature_stats'] != 'y') {
+ die;
+}
+
+if ($bit_p_view_stats != 'y') {
+ die;
+}
+
+//Define the object
+$graph = new PHPlot;
+
+//Set some data
+if (!isset($_REQUEST["days"]))
+ $_REQUEST["days"] = 7;
+
+$example_data = $gBitSystem->get_pv_chart_data($_REQUEST["days"]);
+$graph->SetDataValues($example_data);
+//$graph->SetPlotType('bars');
+$graph->SetPlotType('lines');
+$graph->SetYLabel(tra('pageviews'));
+$graph->SetXLabel(tra('day'));
+//Draw it
+$graph->DrawGraph();
+
+?>
diff --git a/referer_stats.php b/referer_stats.php
new file mode 100644
index 0000000..6741506
--- /dev/null
+++ b/referer_stats.php
@@ -0,0 +1,80 @@
+<?php
+
+// $Header: /cvsroot/bitweaver/_bit_stats/referer_stats.php,v 1.1 2005/06/19 05:05:49 bitweaver Exp $
+
+// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
+// 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.
+
+// Initialization
+require_once( '../bit_setup_inc.php' );
+
+include_once ( STATS_PKG_PATH.'stats_lib.php');
+
+$gBitSystem->verifyPackage( 'stats' );
+$gBitSystem->verifyFeature( 'feature_referer_stats' );
+$gBitSystem->verifyPermission( 'bit_p_view_referer_stats' );
+
+
+if (isset($_REQUEST["clear"])) {
+
+ $statslib->clear_referer_stats();
+}
+
+/*
+if($bit_p_take_quiz != 'y') {
+ $smarty->assign('msg',tra("You dont have permission to use this feature"));
+ $gBitSystem->display( 'error.tpl' );
+ die;
+}
+*/
+if ( empty( $_REQUEST["sort_mode"] ) ) {
+ $sort_mode = 'hits_desc';
+} else {
+ $sort_mode = $_REQUEST["sort_mode"];
+}
+
+if (!isset($_REQUEST["offset"])) {
+ $offset = 0;
+} else {
+ $offset = $_REQUEST["offset"];
+}
+
+$smarty->assign_by_ref('offset', $offset);
+
+if (isset($_REQUEST["find"])) {
+ $find = $_REQUEST["find"];
+} else {
+ $find = '';
+}
+
+$smarty->assign('find', $find);
+
+$smarty->assign_by_ref('sort_mode', $sort_mode);
+$channels = $statslib->list_referer_stats($offset, $maxRecords, $sort_mode, $find);
+
+$cant_pages = ceil($channels["cant"] / $maxRecords);
+$smarty->assign_by_ref('cant_pages', $cant_pages);
+$smarty->assign('actual_page', 1 + ($offset / $maxRecords));
+
+if ($channels["cant"] > ($offset + $maxRecords)) {
+ $smarty->assign('next_offset', $offset + $maxRecords);
+} else {
+ $smarty->assign('next_offset', -1);
+}
+
+// If offset is > 0 then prev_offset
+if ($offset > 0) {
+ $smarty->assign('prev_offset', $offset - $maxRecords);
+} else {
+ $smarty->assign('prev_offset', -1);
+}
+
+$smarty->assign_by_ref('channels', $channels["data"]);
+
+
+
+// Display the template
+$gBitSystem->display( 'bitpackage:stats/referer_stats.tpl');
+
+?>
diff --git a/stats_lib.php b/stats_lib.php
new file mode 100644
index 0000000..d047487
--- /dev/null
+++ b/stats_lib.php
@@ -0,0 +1,397 @@
+<?php
+
+class StatsLib extends BitBase {
+ function StatsLib() { BitBase::BitBase();
+ }
+
+
+ /* referer methods */
+ function clear_referer_stats() {
+ $query = "delete from tiki_referer_stats";
+
+ $result = $this->query($query);
+ }
+
+ function list_referer_stats($offset, $maxRecords, $sort_mode, $find) {
+ $bindvars = array();
+ if ($find) {
+ $findesc = $this->qstr('%' . strtoupper( $find ) . '%');
+ $mid = " where (UPPER(`referer`) like ?)";
+ $bindvars = array($findesc);
+ } else {
+ $mid = "";
+ }
+
+ $query = "select * from `".BIT_DB_PREFIX."tiki_referer_stats` $mid order by ".$this->convert_sortmode($sort_mode);;
+ $query_cant = "select count(*) from `".BIT_DB_PREFIX."tiki_referer_stats` $mid";
+ $result = $this->query($query,$bindvars,$maxRecords,$offset);
+ $cant = $this->getOne($query_cant,$bindvars);
+ $ret = array();
+
+ while ($res = $result->fetchRow()) {
+ $ret[] = $res;
+ }
+
+ $retval = array();
+ $retval["data"] = $ret;
+ $retval["cant"] = $cant;
+ return $retval;
+ }
+
+ function register_referer($referer) {
+ if( !empty( $referer ) ) {
+ $now = date("U");
+ $cant = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_referer_stats` where `referer`=?",array($referer));
+
+ $query = "update `".BIT_DB_PREFIX."tiki_referer_stats` set `hits`=`hits`+1,`last`=? where `referer`=?";
+ $rs = $this->query($query,array((int)$now,$referer));
+ if( !$this->mDb->mDb->Affected_Rows() ) {
+ $query = "insert into `".BIT_DB_PREFIX."tiki_referer_stats`(`last`,`referer`,`hits`) values(?,?,1)";
+ $result = $this->query($query,array((int)$now,$referer));
+ }
+ }
+ }
+
+
+ /* content methods */
+ function list_orphan_pages($offset = 0, $maxRecords = -1, $sort_mode = 'title_desc', $find = '') {
+
+ if ($sort_mode == 'size_desc') {
+ $sort_mode = 'page_size_desc';
+ }
+
+ if ($sort_mode == 'size_asc') {
+ $sort_mode = 'page_size_asc';
+ }
+
+ $old_sort_mode = '';
+
+ if (in_array($sort_mode, array(
+ 'versions_desc',
+ 'versions_asc',
+ 'links_asc',
+ 'links_desc',
+ 'backlinks_asc',
+ 'backlinks_desc'
+ ))) {
+ $old_offset = $offset;
+
+ $old_maxRecords = $maxRecords;
+ $old_sort_mode = $sort_mode;
+ $sort_mode = 'user_desc';
+ $offset = 0;
+ $maxRecords = -1;
+ }
+ $bindvars = array();
+ if ($find) {
+ $mid = " where UPPER(`page_name`) like ? ";
+ $bindvars[] = '%'.strtoupper( $find ).'%';
+ } else {
+ $mid = "";
+ }
+
+ // If sort mode is versions then offset is 0, maxRecords is -1 (again) and sort_mode is nil
+ // If sort mode is links then offset is 0, maxRecords is -1 (again) and sort_mode is nil
+ // If sort mode is backlinks then offset is 0, maxRecords is -1 (again) and sort_mode is nil
+ $query = "select * from `".BIT_DB_PREFIX."tiki_pages` tp INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc ON( tc.`content_id`=tp.`content_id` ) $mid order by ".$this->convert_sortmode($sort_mode);
+ $query_cant = "select count(*) from `".BIT_DB_PREFIX."tiki_pages` $mid";
+ $result = $this->query($query,$bindvars,-1,0);
+ $cant = $this->getOne($query_cant,$bindvars);
+ $ret = array();
+ $num_or = 0;
+
+ while ($res = $result->fetchRow()) {
+ $title = $res["title"];
+ $queryc = "select count(*) from `".BIT_DB_PREFIX."tiki_links` where `to_content_id`=?";
+ $cant = $this->getOne( $queryc,array($res['content_id'] ) );
+ $queryc = "select count(*) from `".BIT_DB_PREFIX."tiki_structures` ts WHERE ts.`content_id`=?";
+ $cant += $this->getOne( $queryc, array( $res['content_id'] ) );
+
+ if ($cant == 0) {
+ $num_or++;
+ $aux = array();
+ $aux["title"] = $title;
+ $page = $aux["title"];
+ $page_as = addslashes($page);
+ $aux["hits"] = $res["hits"];
+ $aux["last_modified"] = $res["last_modified"];
+ $aux["user_id"] = $res["user_id"];
+ $aux["ip"] = $res["ip"];
+// $aux["len"] = $res["len"];
+ $aux["comment"] = $res["comment"];
+ $aux["version"] = $res["version"];
+ $aux["flag"] = $res["flag"] == 'y' ? tra('locked') : tra('unlocked');
+ $aux["versions"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_history` WHERE `page_id`=?",array($res['page_id']));
+ $aux["links"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_links` WHERE `from_content_id`=?",array( $res['content_id']) );
+ $aux["backlinks"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_links` where `to_content_id`=?",array( $res['content_id'] ) );
+ $ret[] = $aux;
+ }
+ }
+
+ // If sortmode is versions, links or backlinks sort using the ad-hoc function and reduce using old_offse and old_maxRecords
+ if ($old_sort_mode == 'versions_asc') {
+ usort($ret, 'compare_versions');
+ }
+
+ if ($old_sort_mode == 'versions_desc') {
+ usort($ret, 'r_compare_versions');
+ }
+
+ if ($old_sort_mode == 'links_desc') {
+ usort($ret, 'compare_links');
+ }
+
+ if ($old_sort_mode == 'links_asc') {
+ usort($ret, 'r_compare_links');
+ }
+
+ if ($old_sort_mode == 'backlinks_desc') {
+ usort($ret, 'compare_backlinks');
+ }
+
+ if ($old_sort_mode == 'backlinks_asc') {
+ usort($ret, 'r_compare_backlinks');
+ }
+
+ if (in_array($old_sort_mode, array(
+ 'versions_desc',
+ 'versions_asc',
+ 'links_asc',
+ 'links_desc',
+ 'backlinks_asc',
+ 'backlinks_desc'
+ ))) {
+ $ret = array_slice($ret, $old_offset, $old_maxRecords);
+ }
+
+ $retval = array();
+ $retval["data"] = $ret;
+ $retval["cant"] = $num_or;
+ return $retval;
+ }
+
+ function wiki_stats() {
+ global $gBitSystem;
+ $stats = array();
+ if( $gBitSystem->isPackageActive( 'wiki' ) ) {
+ require_once( WIKI_PKG_PATH.'BitPage.php' );
+
+ $stats["pages"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_pages`",array());
+ $stats["versions"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_history`",array());
+
+ if ($stats["pages"]) {
+ $stats["vpp"] = $stats["versions"] / $stats["pages"];
+ } else {
+ $stats["vpp"] = 0;
+ }
+ $stats["visits"] = $this->getOne("select sum(`hits`) from `".BIT_DB_PREFIX."tiki_content` WHERE `content_type_guid`=?",array( BITPAGE_CONTENT_TYPE_GUID ));
+ $or = $this->list_orphan_pages(0, -1, 'title_desc', '');
+ $stats["orphan"] = $or["cant"];
+ $links = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_links`",array());
+
+ if ($stats["pages"]) {
+ $stats["lpp"] = $links / $stats["pages"];
+ } else {
+ $stats["lpp"] = 0;
+ }
+ $stats["size"] = $this->getOne("select sum(`page_size`) from `".BIT_DB_PREFIX."tiki_pages`",array());
+
+ if ($stats["pages"]) {
+ $stats["bpp"] = $stats["size"] / $stats["pages"];
+ } else {
+ $stats["bpp"] = 0;
+ }
+ $stats["size"] = $stats["size"] / 1000000;
+ }
+ return $stats;
+ }
+
+ function quiz_stats() {
+ global $gBitSystem;
+ $stats = array();
+ if( $gBitSystem->isPackageActive( 'quizzes' ) ) {
+ global $quizlib;
+ require_once( QUIZZES_PKG_PATH.'quiz_lib.php' );
+ $quizlib->compute_quiz_stats();
+ $stats = array();
+ $stats["quizzes"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_quizzes`",array());
+ $stats["questions"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_quiz_questions`",array());
+ if ($stats["quizzes"]) {
+ $stats["qpq"] = $stats["questions"] / $stats["quizzes"];
+ } else {
+ $stats["qpq"] = 0;
+ }
+ $stats["visits"] = $this->getOne("select sum(`times_taken`) from `".BIT_DB_PREFIX."tiki_quiz_stats_sum`",array());
+ $stats["avg"] = $this->getOne("select avg(`avgavg`) from `".BIT_DB_PREFIX."tiki_quiz_stats_sum`",array());
+ $stats["avgtime"] = $this->getOne("select avg(`avgtime`) from `".BIT_DB_PREFIX."tiki_quiz_stats_sum`",array());
+ }
+ return $stats;
+ }
+
+ function image_gal_stats() {
+ $stats = array();
+ $stats["galleries"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_galleries`",array());
+ $stats["images"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_images`",array());
+ $stats["ipg"] = ($stats["galleries"] ? $stats["images"] / $stats["galleries"] : 0);
+ $stats["size"] = $this->getOne("select sum(`filesize`) from `".BIT_DB_PREFIX."tiki_images_data` where `type`=?",array('o'));
+ $stats["bpi"] = ($stats["images"] ? $stats["size"] / $stats["images"] : 0);
+ $stats["size"] = $stats["size"] / 1000000;
+ $stats["visits"] = $this->getOne("select sum(`hits`) from `".BIT_DB_PREFIX."tiki_galleries`",array());
+ return $stats;
+ }
+
+ function file_gal_stats() {
+ $stats = array();
+ $stats["galleries"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_file_galleries`",array());
+ $stats["files"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_files`",array());
+ $stats["fpg"] = ($stats["galleries"] ? $stats["files"] / $stats["galleries"] : 0);
+ $stats["size"] = $this->getOne("select sum(`filesize`) from `".BIT_DB_PREFIX."tiki_files`",array());
+ $stats["size"] = $stats["size"] / 1000000;
+ $stats["bpf"] = ($stats["galleries"] ? $stats["size"] / $stats["galleries"] : 0);
+ $stats["visits"] = $this->getOne("select sum(`hits`) from `".BIT_DB_PREFIX."tiki_file_galleries`",array());
+ $stats["downloads"] = $this->getOne("select sum(`downloads`) from `".BIT_DB_PREFIX."tiki_files`",array());
+ return $stats;
+ }
+
+ function cms_stats() {
+ global $gBitSystem;
+ $stats = array();
+ if( $gBitSystem->isPackageActive( 'articles' ) ) {
+ require_once( ARTICLES_PKG_PATH.'BitArticle.php' );
+
+ $stats["articles"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_articles`",array());
+ $stats["reads"] = $this->getOne("select sum(`hits`) from `".BIT_DB_PREFIX."tiki_content` WHERE `content_type_guid`=?",array( BITARTICLE_CONTENT_TYPE_GUID ));
+ $stats["rpa"] = ($stats["articles"] ? $stats["reads"] / $stats["articles"] : 0);
+// $stats["size"] = $this->getOne("select sum(`size`) from `".BIT_DB_PREFIX."tiki_articles`",array());
+ $stats["bpa"] = ($stats["articles"] ? $stats["size"] / $stats["articles"] : 0);
+ $stats["topics"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_article_topics` where `active`=?",array('y'));
+ }
+ return $stats;
+ }
+
+ function forum_stats() {
+ $stats = array();
+ $stats["forums"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_forums`",array());
+ $stats["topics"] = $this->getOne( "select count(*) from `".BIT_DB_PREFIX."tiki_comments`,`".BIT_DB_PREFIX."tiki_forums` where `object`=".$this->sql_cast('`forum_id`','string')." and `object_type`=? and `parent_id`=?",array('forum',0));
+ $stats["threads"] = $this->getOne( "select count(*) from `".BIT_DB_PREFIX."tiki_comments`,`".BIT_DB_PREFIX."tiki_forums` where `object`=".$this->sql_cast('`forum_id`','string')." and `object_type`=? and `parent_id`<>?",array('forum',0));
+ $stats["tpf"] = ($stats["forums"] ? $stats["topics"] / $stats["forums"] : 0);
+ $stats["tpt"] = ($stats["topics"] ? $stats["threads"] / $stats["topics"] : 0);
+ $stats["visits"] = $this->getOne("select sum(`hits`) from `".BIT_DB_PREFIX."tiki_forums`",array());
+ return $stats;
+ }
+
+ function blog_stats() {
+ global $gBitSystem;
+ $stats = array();
+ if( $gBitSystem->isPackageActive( 'blogs' ) ) {
+ require_once( BLOGS_PKG_PATH.'BitBlogPost.php' );
+ $stats["blogs"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_blogs`",array());
+ $stats["posts"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_blog_posts`",array());
+ $stats["ppb"] = ($stats["blogs"] ? $stats["posts"] / $stats["blogs"] : 0);
+ // $stats["size"] = $this->getOne("select sum(`data_size`) from `".BIT_DB_PREFIX."tiki_blog_posts`",array());
+ // $stats["bpp"] = ($stats["posts"] ? $stats["size"] / $stats["posts"] : 0);
+ $stats["visits"] = $this->getOne("select sum(`hits`) from `".BIT_DB_PREFIX."tiki_content` WHERE `content_type_guid`=?",array( BITBLOGPOST_CONTENT_TYPE_GUID ));
+ }
+ return $stats;
+ }
+
+ function poll_stats() {
+ $stats = array();
+ $stats["polls"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_polls`",array());
+ $stats["votes"] = $this->getOne("select sum(`votes`) from `".BIT_DB_PREFIX."tiki_poll_options`",array());
+ $stats["vpp"] = ($stats["polls"] ? $stats["votes"] / $stats["polls"] : 0);
+ return $stats;
+ }
+
+ function faq_stats() {
+ $stats = array();
+ $stats["faqs"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_faqs`",array());
+ $stats["questions"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_faq_questions`",array());
+ $stats["qpf"] = ($stats["faqs"] ? $stats["questions"] / $stats["faqs"] : 0);
+ return $stats;
+ }
+
+ function user_stats() {
+ $stats = array();
+ $stats["users"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."users_users`",array());
+ $stats["bookmarks"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_user_bookmarks_urls`",array());
+ $stats["bpu"] = ($stats["users"] ? $stats["bookmarks"] / $stats["users"] : 0);
+ return $stats;
+ }
+
+ function site_stats() {
+ $stats = array();
+ $stats["started"] = $this->getOne("select min(`day`) from `".BIT_DB_PREFIX."tiki_pageviews`",array());
+ $stats["days"] = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_pageviews`",array());
+ $stats["pageviews"] = $this->getOne("select sum(`pageviews`) from `".BIT_DB_PREFIX."tiki_pageviews`");
+ $stats["ppd"] = ($stats["days"] ? $stats["pageviews"] / $stats["days"] : 0);
+ $stats["bestpvs"] = $this->getOne("select max(`pageviews`) from `".BIT_DB_PREFIX."tiki_pageviews`",array());
+ $stats["bestday"] = $this->getOne("select `day` from `".BIT_DB_PREFIX."tiki_pageviews` where `pageviews`=?",array((int)$stats["bestpvs"]));
+ $stats["worstpvs"] = $this->getOne("select min(`pageviews`) from `".BIT_DB_PREFIX."tiki_pageviews`",array());
+ $stats["worstday"] = $this->getOne("select `day` from `".BIT_DB_PREFIX."tiki_pageviews` where `pageviews`=?",array((int)$stats["worstpvs"]));
+ return $stats;
+ }
+
+ // Stats ////
+ /*shared*/
+ function add_pageview() {
+ $dayzero = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
+ $cant = $this->getOne("select count(*) from `".BIT_DB_PREFIX."tiki_pageviews` where `day`=?",array((int)$dayzero));
+
+ if ($cant) {
+ $query = "update `".BIT_DB_PREFIX."tiki_pageviews` set `pageviews`=`pageviews`+1 where `day`=?";
+ } else {
+ $query = "insert into `".BIT_DB_PREFIX."tiki_pageviews`(`day`,`pageviews`) values(?,1)";
+ }
+ $result = $this->query($query,array((int)$dayzero));
+ }
+
+
+ function get_usage_chart_data() {
+ global $gBitSystem;
+ if( $gBitSystem->isPackageActive( 'wiki' ) ) {
+ $data[] = array( WIKI_PKG_NAME, $this->getOne("select sum(`hits`) from `".BIT_DB_PREFIX."tiki_content` WHERE content_type_guid=?",array( BITPAGE_CONTENT_TYPE_GUID )));
+ }
+ if( $gBitSystem->isPackageActive( 'blogs' ) ) {
+ require_once( BLOGS_PKG_PATH.'BitBlogPost.php' );
+ $postHits = $this->getOne("select sum(`hits`) from `".BIT_DB_PREFIX."tiki_content` WHERE content_type_guid=?",array( BITBLOGPOST_CONTENT_TYPE_GUID ) );
+ $blogHits = $this->getOne("select sum(`hits`) from `".BIT_DB_PREFIX."tiki_blogs`" );
+ $data[] = array( "blogs", $blogHits + $postHits );
+ }
+/*
+not liberated
+ if( $gBitSystem->isPackageActive( 'imagegals' ) ) {
+ $data[] = array( IMAGEGALS_PKG_NAME, $this->getOne("select sum(`hits`) from `".BIT_DB_PREFIX."tiki_galleries`",array()));
+ }
+ if( $gBitSystem->isPackageActive( 'filegals' ) ) {
+ $data[] = array( FILEGALS_PKG_NAME, $this->getOne("select sum(`hits`) from `".BIT_DB_PREFIX."tiki_file_galleries`",array()));
+ }
+ if( $gBitSystem->isPackageActive( 'fags' ) ) {
+ $data[] = array( FAQS_PACKAGE_NAME, $this->getOne("select sum(`hits`) from `".BIT_DB_PREFIX."tiki_faqs`",array()));
+ }
+ if( $gBitSystem->isPackageActive( 'quizzes' ) ) {
+ global $quizlib;
+ $quizlib->compute_quiz_stats();
+ $data[] = array( QUIZZES_PKG_NAME,$this->getOne("select sum(`times_taken`) from `".BIT_DB_PREFIX."tiki_quiz_stats_sum`",array()));
+ }
+ if( $gBitSystem->isPackageActive( 'articles' ) ) {
+ $data[] = array( ARTICLES_PKG_NAME, $this->getOne("select sum(`reads`) from `".BIT_DB_PREFIX."tiki_articles`",array()));
+ }
+ if( $gBitSystem->isPackageActive( 'bitforums' ) ) {
+ $data[] = array( BITFORUMS_PKG_NAME, $this->getOne("select sum(`hits`) from `".BIT_DB_PREFIX."tiki_forums`",array()));
+ }
+ if( $gBitSystem->isPackageActive( 'games' ) ) {
+ $data[] = array( "games", $this->getOne("select sum(`hits`) from `".BIT_DB_PREFIX."tiki_games`",array()));
+ }
+*/
+ return $data;
+ }
+
+
+
+}
+
+global $statslib;
+$statslib = new StatsLib();
+
+?>
diff --git a/templates/index.php b/templates/index.php
new file mode 100644
index 0000000..3e305fe
--- /dev/null
+++ b/templates/index.php
@@ -0,0 +1,6 @@
+<?php
+
+ // This is not a package.
+ header ("location: ../index.php");
+
+?> \ No newline at end of file
diff --git a/templates/menu_stats.tpl b/templates/menu_stats.tpl
new file mode 100644
index 0000000..517c9d6
--- /dev/null
+++ b/templates/menu_stats.tpl
@@ -0,0 +1,9 @@
+{strip}
+<ul>
+ {if $gBitUser->hasPermission( 'bit_p_view_site_stats' )}
+ <li><a class="item" href="{$gBitLoc.STATS_PKG_URL}index.php">{tr}Site Stats{/tr}</a></li>
+ {/if}{if $gBitUser->hasPermission( 'bit_p_view_ref_stats' )}
+ <li><a class="item" href="{$gBitLoc.STATS_PKG_URL}referer_stats.php">{tr}Referrer Stats{/tr}</a></li>
+ {/if}
+</ul>
+{/strip}
diff --git a/templates/referer_stats.tpl b/templates/referer_stats.tpl
new file mode 100644
index 0000000..c15e0ed
--- /dev/null
+++ b/templates/referer_stats.tpl
@@ -0,0 +1,48 @@
+<div class="floaticon">{bithelp}</div>
+
+<div class="display statistics">
+<div class="header">
+<h1><a href="{$gBitLoc.STATS_PKG_URL}referer_stats.php">{tr}Referer stats{/tr}</a></h1>
+</div>
+
+<div class="body">
+
+<table class="find">
+<tr><td>{tr}Find{/tr}</td>
+ <td>
+ <form method="get" action="{$gBitLoc.STATS_PKG_URL}referer_stats.php">
+ <input type="text" name="find" value="{$find|escape}" />
+ <input type="submit" value="{tr}find{/tr}" name="referer" />
+ <input type="hidden" name="sort_mode" value="{$sort_mode|escape}" />
+ </form>
+ </td>
+</tr>
+</table>
+
+<table class="data">
+<tr>
+<th><a href="{$gBitLoc.STATS_PKG_URL}referer_stats.php?offset={$offset}&amp;sort_mode={if $sort_mode eq 'referer_desc'}referer_asc{else}referer_desc{/if}">{tr}Term{/tr}</a></th>
+<th><a href="{$gBitLoc.STATS_PKG_URL}referer_stats.php?offset={$offset}&amp;sort_mode={if $sort_mode eq 'hits_desc'}hits_asc{else}hits_desc{/if}">{tr}Hits{/tr}</a></th>
+<th><a href="{$gBitLoc.STATS_PKG_URL}referer_stats.php?offset={$offset}&amp;sort_mode={if $sort_mode eq 'last_desc'}last_asc{else}last_desc{/if}">{tr}Last{/tr}</a></th>
+</tr>
+{cycle values="even,odd" print=false}
+{section name=user loop=$channels}
+<tr class="{cycle}">
+<td>{$channels[user].referer}</td>
+<td>{$channels[user].hits}</td>
+<td>{$channels[user].last|bit_short_datetime}</td>
+</tr>
+{sectionelse}
+<tr class="norecords"><td colspan="2">{tr}No records found{/tr}</td></tr>
+{/section}
+</table>
+
+</div> <!-- end .body -->
+
+<div class="navbar">
+ <a href="{$gBitLoc.STATS_PKG_URL}referer_stats.php?clear=1">{tr}clear stats{/tr}</a>
+</div>
+
+{include file="bitpackage:kernel/pagination.tpl"}
+
+</div> <!-- end .statistics -->
diff --git a/templates/search_stats.tpl b/templates/search_stats.tpl
new file mode 100644
index 0000000..994796b
--- /dev/null
+++ b/templates/search_stats.tpl
@@ -0,0 +1,46 @@
+<div class="floaticon">{bithelp}</div>
+
+<div class="display statistics">
+<div class="header">
+<h1><a href="{$gBitLoc.SEARCH_PKG_URL}stats.php">{tr}Search stats{/tr}</a></h1>
+</div>
+
+<div class="body">
+
+<table class="find">
+<tr><td>{tr}Find{/tr}</td>
+ <td>
+ <form method="get" action="{$gBitLoc.SEARCH_PKG_URL}stats.php">
+ <input type="text" name="find" value="{$find|escape}" />
+ <input type="submit" value="{tr}find{/tr}" name="search" />
+ <input type="hidden" name="sort_mode" value="{$sort_mode|escape}" />
+ </form>
+ </td>
+</tr>
+</table>
+
+<table class="data">
+<tr>
+<th><a href="{$gBitLoc.SEARCH_PKG_URL}stats.php?offset={$offset}&amp;sort_mode={if $sort_mode eq 'term_desc'}term_asc{else}term_desc{/if}">{tr}Term{/tr}</a></th>
+<th><a href="{$gBitLoc.SEARCH_PKG_URL}stats.php?offset={$offset}&amp;sort_mode={if $sort_mode eq 'hits_desc'}hits_asc{else}hits_desc{/if}">{tr}Searched{/tr}</a></th>
+</tr>
+{cycle values="even,odd" print=false}
+{section name=user loop=$channels}
+<tr class="{cycle}">
+<td>{$channels[user].term}</td>
+<td>{$channels[user].hits}</td>
+</tr>
+{sectionelse}
+<tr class="norecords"><td colspan="2">{tr}No records found{/tr}</td></tr>
+{/section}
+</table>
+
+</div> <!-- end .body -->
+
+<div class="navbar">
+ <a div href="{$gBitLoc.SEARCH_PKG_URL}stats.php?clear=1">{tr}clear stats{/tr}</a>
+</div>
+
+{include file="bitpackage:kernel/pagination.tpl"}
+
+</div> <!-- end .statistics -->
diff --git a/templates/stats.tpl b/templates/stats.tpl
new file mode 100644
index 0000000..7f64e73
--- /dev/null
+++ b/templates/stats.tpl
@@ -0,0 +1,189 @@
+{* $Header: /cvsroot/bitweaver/_bit_stats/templates/stats.tpl,v 1.1 2005/06/19 05:05:49 bitweaver Exp $ *}
+<div class="display statistics">
+ <div class="header">
+ <h1>{tr}Stats{/tr}</h1>
+ </div>
+
+ <div class="navbar">
+ <a href="#site_stats">{tr}Site{/tr}</a>
+ {if $wiki_stats}
+ <a href="#wiki_stats">{tr}Wiki{/tr}</a>{/if}
+ {if $igal_stats}
+ <a href="#igal_stats">{tr}Image galleries{/tr}</a>{/if}
+ {if $fgal_stats}
+ <a href="#fgal_stats">{tr}File galleries{/tr}</a>{/if}
+ {if $cms_stats}
+ <a href="#cms_stats">{tr}Articles{/tr}</a>{/if}
+ {if $forum_stats}
+ <a href="#forum_stats">{tr}Forums{/tr}</a>{/if}
+ {if $blog_stats}
+ <a href="#blog_stats">{tr}Weblogs{/tr}</a>{/if}
+ {if $poll_stats}
+ <a href="#poll_stats">{tr}Polls{/tr}</a>{/if}
+ {if $faq_stats}
+ <a href="#faq_stats">{tr}FAQs{/tr}</a>{/if}
+ {if $user_stats}
+ <a href="#user_stats">{tr}Users{/tr}</a>{/if}
+ {if $quiz_stats}
+ <a href="#quiz_stats">{tr}Quizzes{/tr}</a>{/if}
+ </div>
+
+ <div class="body">
+
+ <a name="site_stats"></a>
+ <table class="panel">
+ <caption>{tr}Site Statistics{/tr}</caption>
+ <tr><th colspan="2">{tr}Global Stats{/tr}</th></tr>
+ <tr><td>{tr}Started{/tr}</td><td style="text-align:right;">{$site_stats.started|bit_short_date}</td></tr>
+ <tr><td>{tr}Days online{/tr}</td><td style="text-align:right;">{$site_stats.days}</td></tr>
+ <tr><td>{tr}Total pageviews{/tr}</td><td style="text-align:right;">{$site_stats.pageviews}</td></tr>
+ <tr><td>{tr}Average pageviews per day{/tr}</td><td style="text-align:right;">{$site_stats.ppd|string_format:"%.2f"}</td></tr>
+ <tr><td>{tr}Best day{/tr}</td><td style="text-align:right;">{$site_stats.bestday|bit_short_date} ({$site_stats.bestpvs} {tr}pvs{/tr})</td></tr>
+ <tr><td>{tr}Worst day{/tr}</td><td style="text-align:right;">{$site_stats.worstday|bit_short_date} ({$site_stats.worstpvs} {tr}pvs{/tr})</td></tr>
+ <tr><td colspan="2">&nbsp;</td></tr>
+ <!-- Site stats -->
+
+ <!-- Wiki Stats -->
+ {if $wiki_stats}
+ <tr><th colspan="2"><a name="wiki_stats"></a>{tr}Wiki Stats{/tr}</th></tr>
+ <tr><td>{tr}Wiki Pages{/tr}</td><td style="text-align:right;">{$wiki_stats.pages}</td></tr>
+ <tr><td>{tr}Size of Wiki Pages{/tr}</td><td style="text-align:right;">{$wiki_stats.size} {tr}Mb{/tr}</td></tr>
+ <tr><td>{tr}Average page length{/tr}</td><td style="text-align:right;">{$wiki_stats.bpp|string_format:"%.2f"} {tr}bytes{/tr}</td></tr>
+ <tr><td>{tr}Versions{/tr}</td><td style="text-align:right;">{$wiki_stats.versions}</td></tr>
+ <tr><td>{tr}Average versions per page{/tr}</td><td style="text-align:right;">{$wiki_stats.vpp|string_format:"%.2f"}</td></tr>
+ <tr><td>{tr}Visits to wiki pages{/tr}</td><td style="text-align:right;">{$wiki_stats.visits}</td></tr>
+ <tr><td>{tr}Orphan pages{/tr}</td><td style="text-align:right;">{$wiki_stats.orphan}</td></tr>
+ <tr><td>{tr}Average links per page{/tr}</td><td style="text-align:right;">{$wiki_stats.lpp|string_format:"%.2f"}</td></tr>
+ <tr><td colspan="2">&nbsp;</td></tr>
+ {/if}
+ <!-- Wiki Stats -->
+
+ <!-- Image gallleries stats -->
+ {if $igal_stats}
+ <tr><th colspan="2"><a name="igal_stats"></a>{tr}Image galleries Stats{/tr}</th></tr>
+ <tr><td>{tr}Galleries{/tr}</td><td style="text-align:right;">{$igal_stats.galleries}</td></tr>
+ <tr><td>{tr}Images{/tr}</td><td style="text-align:right;">{$igal_stats.images}</td></tr>
+ <tr><td>{tr}Average images per gallery{/tr}</td><td style="text-align:right;">{$igal_stats.ipg|string_format:"%.2f"}</td></tr>
+ <tr><td>{tr}Total size of images{/tr}</td><td style="text-align:right;">{$igal_stats.size} {tr}Mb{/tr}</td></tr>
+ <tr><td>{tr}Average image size{/tr}</td><td style="text-align:right;">{$igal_stats.bpi|string_format:"%.2f"} {tr}bytes{/tr}</td></tr>
+ <tr><td>{tr}Visits to image galleries{/tr}</td><td style="text-align:right;">{$igal_stats.visits}</td></tr>
+ <tr><td colspan="2">&nbsp;</td></tr>
+ {/if}
+ <!-- Image gallleries stats -->
+
+ <!-- File gallleries stats -->
+ {if $fgal_stats}
+ <tr><th colspan="2"><a name="fgal_stats"></a>{tr}File galleries Stats{/tr}</th></tr>
+ <tr><td>{tr}Galleries{/tr}</td><td style="text-align:right;">{$fgal_stats.galleries}</td></tr>
+ <tr><td>{tr}Files{/tr}</td><td style="text-align:right;">{$fgal_stats.files}</td></tr>
+ <tr><td>{tr}Average files per gallery{/tr}</td><td style="text-align:right;">{$fgal_stats.fpg|string_format:"%.2f"}</td></tr>
+ <tr><td>{tr}Total size of files{/tr}</td><td style="text-align:right;">{$fgal_stats.size} {tr}Mb{/tr}</td></tr>
+ <tr><td>{tr}Average file size{/tr}</td><td style="text-align:right;">{$fgal_stats.bpf|string_format:"%.2f"} {tr}Mb{/tr}</td></tr>
+ <tr><td>{tr}Visits to file galleries{/tr}</td><td style="text-align:right;">{$fgal_stats.visits}</td></tr>
+ <tr><td>{tr}Downloads{/tr}</td><td style="text-align:right;">{$fgal_stats.downloads}</td></tr>
+ <tr><td colspan="2">&nbsp;</td></tr>
+ {/if}
+ <!-- File gallleries stats -->
+
+ <!-- CMS stats -->
+ {if $cms_stats}
+ <tr><th colspan="2"><a name="cms_stats"></a>{tr}CMS Stats{/tr}</th></tr>
+ <tr><td>{tr}Articles{/tr}</td><td style="text-align:right;">{$cms_stats.articles}</td></tr>
+ <tr><td>{tr}Total reads{/tr}</td><td style="text-align:right;">{$cms_stats.reads}</td></tr>
+ <tr><td>{tr}Average reads per article{/tr}</td><td style="text-align:right;">{$cms_stats.rpa|string_format:"%.2f"}</td></tr>
+ <tr><td>{tr}Total articles size{/tr}</td><td style="text-align:right;">{$cms_stats.size} {tr}bytes{/tr}</td></tr>
+ <tr><td>{tr}Average article size{/tr}</td><td style="text-align:right;">{$cms_stats.bpa|string_format:"%.2f"} {tr}bytes{/tr}</td></tr>
+ <tr><td>{tr}Topics{/tr}</td><td style="text-align:right;">{$cms_stats.topics}</td></tr>
+ <tr><td colspan="2">&nbsp;</td></tr>
+ {/if}
+ <!-- CMS stats -->
+
+ <!-- Forum stats -->
+ {if $forum_stats}
+ <tr><th colspan="2"><a name="forum_stats"></a>{tr}Forum Stats{/tr}</th></tr>
+ <tr><td>{tr}Forums{/tr}</td><td style="text-align:right;">{$forum_stats.forums}</td></tr>
+ <tr><td>{tr}Total topics{/tr}</td><td style="text-align:right;">{$forum_stats.topics}</td></tr>
+ <tr><td>{tr}Average topics per forums{/tr}</td><td style="text-align:right;">{$forum_stats.tpf|string_format:"%.2f"}</td></tr>
+ <tr><td>{tr}Total threads{/tr}</td><td style="text-align:right;">{$forum_stats.threads}</td></tr>
+ <tr><td>{tr}Average threads per topic{/tr}</td><td style="text-align:right;">{$forum_stats.tpt|string_format:"%.2f"}</td></tr>
+ <tr><td>{tr}Visits to forums{/tr}</td><td style="text-align:right;">{$forum_stats.visits}</td></tr>
+ <tr><td colspan="2">&nbsp;</td></tr>
+ {/if}
+ <!-- Forum stats -->
+
+ <!-- Blogs stats -->
+ {if $blog_stats}
+ <tr><th colspan="2"><a name="blog_stats"></a>{tr}Blog Stats{/tr}</th></tr>
+ <tr><td>{tr}Weblogs{/tr}</td><td style="text-align:right;">{$blog_stats.blogs}</td></tr>
+ <tr><td>{tr}Total posts{/tr}</td><td style="text-align:right;">{$blog_stats.posts}</td></tr>
+ <tr><td>{tr}Average posts per weblog{/tr}</td><td style="text-align:right;">{$blog_stats.ppb|string_format:"%.2f"}</td></tr>
+ <tr><td>{tr}Visits to weblogs{/tr}</td><td style="text-align:right;">{$blog_stats.visits}</td></tr>
+ <tr><td colspan="2">&nbsp;</td></tr>
+ {/if}
+ <!-- Blogs stats -->
+
+ <!-- Poll stats -->
+ {if $poll_stats}
+ <tr><th colspan="2"><a name="poll_stats"></a>{tr}Poll Stats{/tr}</th></tr>
+ <tr><td>{tr}Polls{/tr}</td><td style="text-align:right;">{$poll_stats.polls}</td></tr>
+ <tr><td>{tr}Total votes{/tr}</td><td style="text-align:right;">{$poll_stats.votes}</td></tr>
+ <tr><td>{tr}Average votes per poll{/tr}</td><td style="text-align:right;">{$poll_stats.vpp|string_format:"%.2f"}</td></tr>
+ <tr><td colspan="2">&nbsp;</td></tr>
+ {/if}
+ <!-- Poll stats -->
+
+ <!-- FAQ stats -->
+ {if $faq_stats}
+ <tr><th colspan="2"><a name="faq_stats"></a>{tr}Faq Stats{/tr}</th></tr>
+ <tr><td>{tr}FAQs{/tr}</td><td style="text-align:right;">{$faq_stats.faqs}</td></tr>
+ <tr><td>{tr}Total questions{/tr}</td><td style="text-align:right;">{$faq_stats.questions}</td></tr>
+ <tr><td>{tr}Average questions per FAQ{/tr}</td><td style="text-align:right;">{$faq_stats.qpf|string_format:"%.2f"}</td></tr>
+ <tr><td colspan="2">&nbsp;</td></tr>
+ {/if}
+ <!-- FAQ stats -->
+
+ <!-- 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}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">&nbsp;</td></tr>
+ {/if}
+ <!-- Usersstats -->
+
+ <!-- Quiz stats -->
+ {if $quiz_stats}
+ <tr><th colspan="2"><a name="quiz_stats"></a>{tr}Quiz Stats{/tr}</th></tr>
+ <tr><td>{tr}Quizzes{/tr}</td><td style="text-align:right;">{$quiz_stats.quizzes}</td></tr>
+ <tr><td>{tr}Questions{/tr}</td><td style="text-align:right;">{$quiz_stats.questions}</td></tr>
+ <tr><td>{tr}Average questions per quiz{/tr}</td><td style="text-align:right;">{$quiz_stats.qpq|string_format:"%.2f"}</td></tr>
+ <tr><td>{tr}Quizzes taken{/tr}</td><td style="text-align:right;">{$quiz_stats.visits}</td></tr>
+ <tr><td>{tr}Average quiz score{/tr}</td><td style="text-align:right;">{$quiz_stats.avg|string_format:"%.2f"}</td></tr>
+ <tr><td>{tr}Average time per quiz{/tr}</td><td style="text-align:right;">{$quiz_stats.avgtime|string_format:"%.2f"} {tr}seconds{/tr}</td></tr>
+ <tr><td colspan="2">&nbsp;</td></tr>
+ {/if}
+ <!-- Quiz stats -->
+ </table>
+
+ <h2>{tr}Usage chart{/tr}</h2>
+
+ {if $usage_chart eq 'y'}
+ <div align="center">
+ <img src="{$gBitLoc.STATS_PKG_URL}usage_chart.php" alt="{tr}Usage chart image{/tr}" />
+ </div>
+ {/if}
+
+ {form}
+ {tr}Show chart for the last {/tr}
+ <input type="text" name="days" size="10" value="{$days|escape}" /> {tr}days (0=all){/tr}
+ <input type="submit" name="pv_chart" value="{tr}display{/tr}" />
+ {/form}
+
+ {if $pv_chart eq 'y'}
+ <div align="center">
+ <img src="{$gBitLoc.STATS_PKG_URL}pv_chart.php?days={$days}" alt="" />
+ </div>
+ {/if}
+ </div> <!-- end .body -->
+</div> <!-- end .statistics -->
diff --git a/usage_chart.php b/usage_chart.php
new file mode 100644
index 0000000..1a665c7
--- /dev/null
+++ b/usage_chart.php
@@ -0,0 +1,33 @@
+<?php
+
+// $Header: /cvsroot/bitweaver/_bit_stats/usage_chart.php,v 1.1 2005/06/19 05:05:49 bitweaver Exp $
+
+// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
+// 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.
+
+require_once( '../bit_setup_inc.php' );
+require_once (STATS_PKG_PATH."stats_lib.php");
+//Include the code
+require (UTIL_PKG_PATH."phplot.php");
+
+
+if ($feature_stats != 'y') {
+ die;
+}
+
+if ($bit_p_view_stats != 'y') {
+ die;
+}
+
+//Define the object
+$graph = new PHPlot;
+//Set some data
+$example_data = $statslib->get_usage_chart_data();
+$graph->SetDataValues($example_data);
+$graph->SetPlotType('bars');
+//$graph->SetPlotType('lines');
+//Draw it
+$graph->DrawGraph();
+
+?>