* */ ini_set("include_path", dirname(__FILE__) . "/.."); require_once 'commandLine.inc'; $bDebugMode = isset($options['d']) || isset($options['debug']) ? true : false; $aUserNames = isset($options['users']) ? explode(',', $options['users']) : array(); $aUseDB = isset($options['usedb']) ? explode(',', $options['usedb']) : array(); $bDbExistsCheck = isset($options['checkdb']) ? true : false; $bClearMode = isset($options['clear']) ? true : false; $bRegenMode = isset($options['regen']) ? true : false; $sDebugMailTo = isset($options['mailto']) ? $options['mailto'] : ''; if (class_exists('GlobalWatchlistBot')) { $oWatchlistBot = new GlobalWatchlistBot($bDebugMode, $aUserNames, $aUseDB); //$oWatchlistBot->setDbExistsCheck($bDbExistsCheck); $oWatchlistBot->setDebugMailTo($sDebugMailTo); if ($bClearMode) { $oWatchlistBot->clear(); } elseif ($bRegenMode) { $oWatchlistBot->regenerate(); } else { $oWatchlistBot->run(); // $oUser = User::newFromId(115748); //Moli.wikia $oUser->load(); $oUser->sendMail('Global watchlist is finished', 'Global watchlist is finished', 'Wikia <*****@*****.**>', null, 'GlobalWatchlist'); } } else { print "GlobalWatchlist extension is not installed.\n"; exit(1); }
public function execute() { if ( class_exists('GlobalWatchlistBot') ) { // defaults $bDebugMode = $bClearMode = $bUpdateMode = $bSendMode = $bRegenMode = false; $aUserNames = $aUseDB = array(); $sDebugMailTo = $sPage = ''; $sNamespace = null; // options if( $this->hasOption( 'debug' ) ) { $bDebugMode = true; } if ( $this->hasOption( 'clear' ) ) { $bClearMode = true; } elseif ( $this->hasOption( 'update' ) ) { $bUpdateMode = true; } elseif ( $this->hasOption( 'send' ) ) { $bSendMode = true; } elseif ( $this->hasOption( 'regen' ) ) { $bRegenMode = true; } if ( $this->hasOption( 'users' ) ) { $aUserNames = explode( ',', $this->getOption( 'users' ) ); } if ( $this->hasOption( 'usedb' ) ) { $aUseDB = explode( ',', $this->getOption( 'usedb' ) ); } if ( $this->hasOption( 'mailto' ) ) { $sDebugMailTo = $this->getOption( 'mailto' ); } if ( $this->hasOption( 'page' ) ) { $sPage = $this->getOption( 'page' ); } if ( $this->hasOption( 'namespace' ) ) { $sNamespace = $this->getOption( 'namespace' ); } $oWatchlistBot = new GlobalWatchlistBot( $bDebugMode, $aUserNames, $aUseDB ); $oWatchlistBot->setDebugMailTo( $sDebugMailTo ); if ( $bClearMode ) { $this->output( "Run weekly digest with --clear option ... \n" ); $oWatchlistBot->clear(); } elseif ( $bRegenMode ) { $this->output( "Run weekly digest with --regen option ... \n" ); $oWatchlistBot->regenerate(); } elseif ( $bUpdateMode ) { $this->output( "Run weekly digest with --update option for page {$sPage} and namespace {$sNamespace} ... \n" ); if ( !empty( $sPage ) && !is_null( $sNamespace ) ) { if ( ! $oWatchlistBot->updateLocalWatchlist( $sPage, $sNamespace ) ) { print "Update error \n"; exit(1); } } else { print "Invalid title \n"; exit(1); } } elseif ( $bSendMode ) { $this->output( "Run weekly digest with --send option for user {$this->getOption( 'users' )} ... \n" ); if ( ! $oWatchlistBot->send() ) { print "Send failed \n"; exit(1); } } else { $this->output( "Run weekly digest ...\n" ); $oWatchlistBot->updateLog( ); $emailsSent = $oWatchlistBot->run(); // $oUser = User::newFromId(115748); //Moli.wikia $oUser->load(); $oUser->sendMail( 'Global watchlist has finished', 'Global watchlist has finished', 'Wikia <*****@*****.**>', null, 'GlobalWatchlist' ); $oWatchlistBot->updateLog( ); $this->output( "Done!\n" ); } } else { $this->output( "GlobalWatchlist extension is not installed.\n" ); exit(1); } }