00001 <?php
00002
00027 require_once( dirname(__FILE__) . '/Maintenance.php' );
00028
00029 class InitStats extends Maintenance {
00030 public function __construct() {
00031 parent::__construct();
00032 $this->mDescription = "Re-initialise the site statistics tables";
00033 $this->addOption( 'update', 'Update the existing statistics (preserves the ss_total_views field)' );
00034 $this->addOption( 'noviews', "Don't update the page view counter" );
00035 $this->addOption( 'active', 'Also update active users count' );
00036 $this->addOption( 'use-master', 'Count using the master database' );
00037 }
00038
00039 public function execute() {
00040 $this->output( "Refresh Site Statistics\n\n" );
00041 $counter = new SiteStatsInit( $this->hasOption( 'use-master' ) );
00042
00043 $this->output( "Counting total edits..." );
00044 $edits = $counter->edits();
00045 $this->output( "{$edits}\nCounting number of articles..." );
00046
00047 $good = $counter->articles();
00048 $this->output( "{$good}\nCounting total pages..." );
00049
00050 $pages = $counter->pages();
00051 $this->output( "{$pages}\nCounting number of users..." );
00052
00053 $users = $counter->users();
00054 $this->output( "{$users}\nCounting number of images..." );
00055
00056 $image = $counter->files();
00057 $this->output( "{$image}\n" );
00058
00059 if( !$this->hasOption('noviews') ) {
00060 $this->output( "Counting total page views..." );
00061 $views = $counter->views();
00062 $this->output( "{$views}\n" );
00063 }
00064
00065 if( $this->hasOption( 'active' ) ) {
00066 $this->output( "Counting active users..." );
00067 $active = SiteStatsUpdate::cacheUpdate();
00068 $this->output( "{$active}\n" );
00069 }
00070
00071 $this->output( "\nUpdating site statistics..." );
00072
00073 if( $this->hasOption( 'update' ) ) {
00074 $counter->update();
00075 } else {
00076 $counter->refresh();
00077 }
00078
00079 $this->output( "done.\n" );
00080 }
00081 }
00082
00083 $maintClass = "InitStats";
00084 require_once( DO_MAINTENANCE );