00001 <?php 00011 $options = array( 'update', 'help' ); 00012 require_once( 'commandLine.inc' ); 00013 require_once( 'updateArticleCount.inc.php' ); 00014 echo( "Update Article Count\n\n" ); 00015 00016 if( isset( $options['help'] ) && $options['help'] ) { 00017 echo( "Usage: php updateArticleCount.php [--update]\n\n" ); 00018 echo( "--update : Update site statistics table\n" ); 00019 exit( 0 ); 00020 } 00021 00022 echo( "Counting articles..." ); 00023 $counter = new ArticleCounter(); 00024 $result = $counter->count(); 00025 00026 if( $result !== false ) { 00027 echo( "found {$result}.\n" ); 00028 if( isset( $options['update'] ) && $options['update'] ) { 00029 echo( "Updating site statistics table... " ); 00030 $dbw = wfGetDB( DB_MASTER ); 00031 $dbw->update( 'site_stats', array( 'ss_good_articles' => $result ), array( 'ss_row_id' => 1 ), __METHOD__ ); 00032 echo( "done.\n" ); 00033 } else { 00034 echo( "To update the site statistics table, run the script with the --update option.\n" ); 00035 } 00036 } else { 00037 echo( "failed.\n" ); 00038 } 00039 echo( "\n" ); 00040