(file) Return to statistics.cgi CVS log (file) (dir) Up to [RizwankCVS] / geekymedia_web / twiki / bin

 1 rizwank 1.1 #!/usr/bin/perl -wT
 2             #
 3             # TWiki Collaboration Platform, http://TWiki.org/
 4             #
 5             # Copyright (C) 2000-2004 Peter Thoeny, peter@thoeny.com
 6             # Copyright (C) 2002 Richard Donkin, rdonkin@bigfoot.com
 7             #
 8             # For licensing info read license.txt file in the TWiki root.
 9             # This program is free software; you can redistribute it and/or
10             # modify it under the terms of the GNU General Public License
11             # as published by the Free Software Foundation; either version 2
12             # of the License, or (at your option) any later version.
13             #
14             # This program is distributed in the hope that it will be useful,
15             # but WITHOUT ANY WARRANTY; without even the implied warranty of
16             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17             # GNU General Public License for more details, published at 
18             # http://www.gnu.org/copyleft/gpl.html
19             #
20             # DESCRIPTION
21             # This script updates the usage statistics of each TWiki web.
22 rizwank 1.1 # It reads the current month's log file and updates the table
23             # in the WebStatistics topic of each web.
24             # The script should be called by a cron job, it is recommended to
25             # call it once a day.
26             BEGIN {
27                 # Set default current working directory
28                 if( $ENV{"SCRIPT_FILENAME"} && $ENV{"SCRIPT_FILENAME"} =~ /^(.+)\/[^\/]+$/ ) {
29                     chdir $1;
30                 }
31                 # Set library paths in @INC at compile time
32                 unshift @INC, '.';
33                 require 'setlib.cfg';
34             
35                 # 'Use locale' for internationalisation of Perl regexes -
36                 # main locale settings are done in TWiki::setupLocale
37                 # Do a dynamic 'use locale' for this module
38                 require TWiki;
39                 if( $TWiki::useLocale ) {
40                     require locale;
41             	import locale ();
42                 }
43 rizwank 1.1 }
44             
45             use CGI::Carp qw(fatalsToBrowser);
46             use CGI;
47             use TWiki;
48             use TWiki::UI::Statistics;
49             
50             #open(STDERR,'>&STDOUT');   # redirect error to browser
51             # FIXME: Beware global $| in mod_perl!  Should use 'local'
52             $| = 1;                    # no buffering
53             
54             my $query = undef;
55             my $pathInfo = "";
56             my $remoteUser = "";
57             my $topic = "";
58             my $logDate = "";
59             
60             # determine at runtime if script is called by browser or cron job
61             if( $ENV{'DOCUMENT_ROOT'} ) {
62               # script is called by browser
63               $query = new CGI;
64 rizwank 1.1   $pathInfo = $query->path_info() || ""; 
65               $remoteUser = $query->remote_user() || "";
66               $topic = $query->param( 'topic' ) || "";
67               $logDate = $query->param( 'logdate' ) || "";
68             
69             } else {
70               # script is called by cron job or user
71               foreach my $arg ( @ARGV ) {
72                 if ( $arg =~ /^-web=(.*)$/o ) {
73                   $pathInfo = "/$1";
74                 } elsif ( $arg =~ /^-logdate=(.*)$/o ) {
75                   $logDate = $1;
76                 }
77               }
78             }
79             
80             TWiki::UI::Statistics::statistics( $query, $pathInfo, $remoteUser, $topic, $logDate );
81             
82             # =========================
83             # EOF

Rizwan Kassim
Powered by
ViewCVS 0.9.2