[PerlWikiBot] SF.net SVN: perlwikibot: [21] trunk
Status: Pre-Alpha
Brought to you by:
rotemliss
From: <rot...@us...> - 2006-09-16 12:48:19
|
Revision: 21 http://svn.sourceforge.net/perlwikibot/?rev=21&view=rev Author: rotemliss Date: 2006-09-16 05:48:10 -0700 (Sat, 16 Sep 2006) Log Message: ----------- Several fixes. Modified Paths: -------------- trunk/bot.pl trunk/includes/actions.pm trunk/includes/functions.pm trunk/includes/http.pm Modified: trunk/bot.pl =================================================================== --- trunk/bot.pl 2006-09-16 12:30:18 UTC (rev 20) +++ trunk/bot.pl 2006-09-16 12:48:10 UTC (rev 21) @@ -5,13 +5,14 @@ use strict; # Libraries +use LWP::UserAgent; +use includes::actions; +use includes::dump; use includes::functions; +use includes::http; use config::configure; use config::runtime; -# Counters -my ( $i, $j, $k, $l, $m ); - # Do nothing if no server specified if ( !$ARGV[0] ) { die "No server name set - please set server name!\n"; @@ -33,7 +34,7 @@ my @pages = functions::getMatchingPages(); # Execute actions of all the pages -for ( $i = 0; $i <= $#pages; $i += 2 ) { +for ( my $i = 0; $i <= $#pages; $i += 2 ) { # Get title and action my $title = $pages[$i]; my $action = $configure::actions{ $pages[$i + 1] }; Modified: trunk/includes/actions.pm =================================================================== --- trunk/includes/actions.pm 2006-09-16 12:30:18 UTC (rev 20) +++ trunk/includes/actions.pm 2006-09-16 12:48:10 UTC (rev 21) @@ -5,55 +5,6 @@ use warnings; use strict; -# Libraries -use includes::http; -use config::configure; -use config::runtime; - -# Counters -my ( $i, $j, $k, $l, $m ); - -# Log in -sub login { - # Is sysop finally required? - my $sysop = 0; - - # Go through the array, and check if sysop permission is needed. - for ( $i = 0; $i <= $#configure::executedActions; $i++ ) { - my $action = $configure::actions{ $configure::executedActions[$i] }; - if ( $action eq "replace" ) { - # Continue - } elsif ($action eq "refresh") { - # Continue - } elsif ($action eq "delete") { - $sysop = 1; - } elsif ($action eq "move") { - # Continue - } - } - - # Get user name and password - my ( $username, $password ); - if ( $sysop == 1 ) { - $username = $configure::sysopUserNames{ $ARGV[0] }; - $password = $configure::sysopPasswords{ $ARGV[0] }; - } else { - $username = $configure::userNames{ $ARGV[0] }; - $password = $configure::passwords{ $ARGV[0] }; - } - - # Log in - print "Logging in...\n"; - http::postPage( "Special:Userlogin", "submitlogin", - [ - wpName => $username, - wpPassword => $password, - wpRemember => 0, - ], - , "type=login" ); - print "\tDone!\n"; -} - # Get the contents of a page sub getPageContents { # Get parameters Modified: trunk/includes/functions.pm =================================================================== --- trunk/includes/functions.pm 2006-09-16 12:30:18 UTC (rev 20) +++ trunk/includes/functions.pm 2006-09-16 12:48:10 UTC (rev 21) @@ -5,15 +5,6 @@ use warnings; use strict; -# Libraries -use includes::actions; -use includes::dump; -use config::configure; -use config::runtime; - -# Counters -my ( $i, $j, $k, $l, $m ); - # Get all the pages matching specific restrictions sub getMatchingPages { # Get the pages @@ -47,7 +38,7 @@ my $title = $page->title; utf8::encode( $title ); $tempCounter = 0; - for ( $i = 0; $i <= $#pagePossibleActions; $i++ ) { + for ( my $i = 0; $i <= $#pagePossibleActions; $i++ ) { my $wantedTitle = $configure::titles{ $pagePossibleActions[$i] }; if ( $title =~ /$wantedTitle/ ) { $tempTitleArray[$tempCounter++] = $pagePossibleActions[$i]; @@ -65,7 +56,7 @@ my $text = $page->text; utf8::encode( $$text ); $tempCounter = 0; - for ( $i = 0; $i <= $#pagePossibleActions; $i++ ) { + for ( my $i = 0; $i <= $#pagePossibleActions; $i++ ) { my $wantedText = $configure::texts{ $pagePossibleActions[$i] }; if ($$text =~ /$wantedText/) { $tempTextArray[$tempCounter++] = $pagePossibleActions[$i]; @@ -117,6 +108,47 @@ return timegm( $6, $5, $4, $3, $2 - 1, $1 - 1900 ); } +# Log in +sub login { + # Is sysop finally required? + my $sysop = 0; + + # Go through the array, and check if sysop permission is needed. + for ( my $i = 0; $i <= $#configure::executedActions; $i++ ) { + my $action = $configure::actions{ $configure::executedActions[$i] }; + if ( $action eq "replace" ) { + # Continue + } elsif ($action eq "refresh") { + # Continue + } elsif ($action eq "delete") { + $sysop = 1; + } elsif ($action eq "move") { + # Continue + } + } + + # Get user name and password + my ( $username, $password ); + if ( $sysop == 1 ) { + $username = $configure::sysopUserNames{ $ARGV[0] }; + $password = $configure::sysopPasswords{ $ARGV[0] }; + } else { + $username = $configure::userNames{ $ARGV[0] }; + $password = $configure::passwords{ $ARGV[0] }; + } + + # Log in + print "Logging in...\n"; + http::postPage( "Special:Userlogin", "submitlogin", + [ + wpName => $username, + wpPassword => $password, + wpRemember => 0, + ], + , "type=login" ); + print "\tDone!\n"; +} + # Replace regular expressions in the page sub replaceInPage { # Get parameters @@ -124,7 +156,7 @@ if ( $configure::sendPages == 1 || $configure::sendPages == 2 ) { # Get the edited page contents - my $editedPage = getPageContents( $title ); + my $editedPage = actions::getPageContents( $title ); # Set initial edit summary my $editSummary = $configure::initialEditSummaries{ $ARGV[0] }; @@ -136,7 +168,7 @@ my $replaced = 0; # Replace regular expressions - for ( $i = 0; $i <= $#actions; $i++ ) { + for ( my $i = 0; $i <= $#actions; $i++ ) { my $action = $actions[$i]; my $search = $configure::texts{ $action }; if ( $editedPage =~ /$search/ ) { Modified: trunk/includes/http.pm =================================================================== --- trunk/includes/http.pm 2006-09-16 12:30:18 UTC (rev 20) +++ trunk/includes/http.pm 2006-09-16 12:48:10 UTC (rev 21) @@ -5,10 +5,6 @@ use warnings; use strict; -# Libraries -use LWP; -use config::configure; - # The browser we use to surf; enable cookies, and use a specific user agent my $browser = LWP::UserAgent->new(); $browser->cookie_jar( {} ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |