"Fossies" - the Fresh Open Source Software Archive

Member "betterawstats/bawstats.module" (16 Mar 2008, 7554 Bytes) of package /linux/www/old/betterawstats-1.0.zip:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 <?php
    2  // $Id: bawstats.module,v 1.4 2008/03/16 14:45:35 tokyoahead Exp $
    3 
    4 /**
    5  * BAWstats drupal module
    6  *
    7  * BAWstats is a drupal module written in php for integration of
    8  * the BetterAWstats presentation and processing of AWstats data into drupal.
    9  * Copyright (C) 2008  Andrew Gillies (anaru@equivocation.org)
   10  *
   11  * For more information about BetterAWstats see:
   12  * http://betterawstats.com/
   13  *
   14  * This program is free software; you can redistribute it and/or modify
   15  * it under the terms of the GNU General Public License as published by
   16  * the Free Software Foundation; either version 2 of the License, or, at
   17  * your option, any later version.
   18  *
   19  * This program is distributed in the hope that it will be useful, but
   20  * WITHOUT ANY WARRANTY; without even the implied warranty of
   21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   22  * General Public License for more details.
   23  *
   24  * You should have received a copy of the GNU General Public License
   25  * along with this program; if not, write to the Free Software
   26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   27  *
   28  */
   29 
   30 /**
   31  * Implementation of hook_help
   32  */
   33 
   34 function bawstats_help($section) {
   35   $output = '';
   36   switch ($section) {
   37     case 'admin/help#bawstats':
   38       $output .= '<p>'. t('BAWstats is a drupal interface to "BetterAWstats" by Oliver Spiesshofer.  If you run AWstats or have AWstats data, BAWstats can provide a drupal view of the statistics data.  The data itself does not need to be in web accessible space, although it must be readable by php (i.e. within the <em>openbasedir</em> setting).') .'</p>';
   39       $output .= '<p>'. t('By default this module only shows statistics for a single site.  Which site this is, is <strong>not</strong> configurable within the module.  This is done to prevent administrative users on one site viewing another sites data (the AWstats data directory can hold multiple site data).  BAWstats tries to guess the AWstats site name from the drupal site name, but if the guess is wrong it can be set within the settings.php file using the <em>$conf[\'bawstats_defsite\']</em> variable.  For example, <em>$conf[\'bawstats_defsite\'] = \'equivocation.org\';</em> will generate site statistics from the AWStats data files for the site equivocation.org.') .'</p>';
   40       $output .= '<p>'. t('It is possible to view all the site statistics found in the AWstats data directory.  By setting <em>$conf[\'bawstats_admin_access\'] = 1;</em> in the settings.php file, access to the statistics for <strong>all</strong> the sites available is given.') .'</p>';
   41       $output .= '<p>'. t('As this module only provides a drupal interface into the non-drupal "Better AWstats" code, limited configuration is available through drupal.  Fine configuration of the statistics views may be achieved by editing the Better AWstats <em>config.php</em> file.') .'</p>';
   42       break;
   43     case 'admin/settings/bawstats':
   44       $output .= '<p>'. t('BAWstats is based on "BetterAWstats" by Oliver Spiesshofer.  This module displays AWstats data within drupal. The location of the AWstats data and the location of auxiliary AWstats libraries can be configured below.') .'</p>';
   45       $output .= '<p>'. t('Note, it may be considered important that the AWstats data and library locations reside outside of web file space.  This would remove direct access to the data with the only access through AWstats itself (if it is running as a CGI) and/or through this drupal module.') .'</p>';
   46       $output .= '<p>'. t('Once the AWstats locations are correctly configured, site statistics can be viewed under the admin reports') . ' (<a href="/admin/reports/bawstats">/admin/reports/bawstats</a>).</p>';
   47 
   48   }
   49   return $output;
   50 }
   51 
   52 /**
   53  * Implementation of hook_perm().
   54  */
   55 function bawstats_perm() {
   56   return array('view site statistics','statistics admin');
   57 }
   58 
   59 /**
   60  * Implementation of hook_init()
   61  *   This hook is run at the beginning of the page request. When this hook
   62  *   is called, all modules are already loaded in memory.  Here used to
   63  *   setup CSS
   64  */
   65 
   66 function bawstats_init() {
   67   drupal_add_css(drupal_get_path('module', 'bawstats') .'/includes/bawstats.css');
   68 }
   69 
   70 /**
   71  * Implementation of hook_menu().
   72  */
   73 
   74 function bawstats_menu() {
   75   $items = array();
   76   $includes_path = drupal_get_path('module', 'bawstats') . '/includes';
   77 
   78   $items['admin/settings/bawstats'] = array(
   79     'title' => 'BAW Statistics',
   80     'description' => 'Configure site statistics.',
   81     'page callback' => 'drupal_get_form',
   82     'page arguments' => array('bawstats_admin_settings'),
   83     'file' => 'bawstats.admin.inc',
   84     'file path' => $includes_path,
   85     'access arguments' => array('statistics admin'),
   86   );
   87 
   88   $items['admin/reports/bawstats'] = array(
   89     'title' => 'View Site Statistics',
   90     'description' => t('View AWStats web statistics.'),
   91     'page callback' => 'bawstats_view_theform',
   92     'page arguments' => array(),
   93     'file' => 'bawstats.stats.inc',
   94     'file path' => $includes_path,
   95     'weight' => 1,
   96     'access arguments' => array('view site statistics'),
   97   );
   98 
   99   $items['admin/reports/bawstats/all/%/%'] = array(
  100     'title' => 'View Site Statistics',
  101     'type' => MENU_CALLBACK,
  102     'page callback' => 'bawstats_view_theform',
  103     'page arguments' => array(4,5),
  104     'file' => 'bawstats.stats.inc',
  105     'file path' => $includes_path,
  106     'weight' => 1,
  107     'access arguments' => array('view site statistics'),
  108   );
  109 
  110   // create the sub group menues if requested
  111   if (variable_get('bawstats_page_view',0)>0) {
  112     $statgroups = variable_get('bawstats_groups',array());
  113     if (count($statgroups)>0) {
  114       $pri = 1;
  115       foreach ($statgroups as $group => $group_details) {
  116         if ($pri==1) {
  117           $items['admin/reports/bawstats/'.$group.'/%/%'] = array(
  118             'title' => 'View Site Statistics',
  119             'type' => MENU_CALLBACK,
  120             'page callback' => 'bawstats_view_theform',
  121             'page arguments' => array(4,5,$group),
  122             'file' => 'bawstats.stats.inc',
  123             'file path' => $includes_path,
  124             'weight' => $pri,
  125             'access arguments' => array('view site statistics')
  126           );
  127         } else {
  128           $items['admin/reports/bawstats/'.$group] = array(
  129             'title' => $group_details,
  130             'type' => MENU_NORMAL_ITEM,
  131   	    'page callback' => 'bawstats_set_section',
  132             'page arguments' => array($group),
  133             'file' => 'bawstats.stats.inc',
  134             'file path' => $includes_path,
  135             'weight' => $pri,
  136             'access arguments' => array('view site statistics')
  137           );
  138           $items['admin/reports/bawstats/'.$group.'/%/%'] = array(
  139             'title' => $group_details,
  140             'type' => MENU_CALLBACK,
  141             'page callback' => 'bawstats_view_theform',
  142             'page arguments' => array(4,5,$group),
  143             'file' => 'bawstats.stats.inc',
  144             'file path' => $includes_path,
  145             'weight' => $pri,
  146             'access arguments' => array('view site statistics')
  147           );
  148         }
  149         $pri += 1;
  150       }
  151     }
  152   }
  153 
  154   // the "other" more specific things we don't have menus for!
  155   $items['admin/reports/bawstats/details/%/%/%'] = array(
  156     'title' => $group_details,
  157     'type' => MENU_CALLBACK,
  158     'page callback' => 'bawstats_view_theform',
  159     'page arguments' => array(5,6,4),
  160     'file' => 'bawstats.stats.inc',
  161     'file path' => $includes_path,
  162     'weight' => $pri,
  163     'access arguments' => array('view site statistics')
  164   );
  165 
  166   return $items;
  167 }