diff -Nur websec-snapshot-2003.06.28/url.list websec-snapshot-2003.06.28.webhtmldiff/url.list --- websec-snapshot-2003.06.28/url.list 2003-06-28 20:20:51.000000000 +0000 +++ websec-snapshot-2003.06.28.webhtmldiff/url.list 2003-11-22 09:17:29.000000000 +0000 @@ -7,6 +7,7 @@ # Auth = "none"; or "username:password" # Diff = "webdiff" to detect and highlight differences, # "htmldiff" to use HTML::Diff from cpan +# "webdiff_htmldiff" to enable ignoring of changes and still use htmldiff # "none" to mail page as is. # HiColor = "blue"; "yellow"; "pink"; or "grey". # Ignore = list of comma-delimited section names containing ignore keywords. diff -Nur websec-snapshot-2003.06.28/webdiff websec-snapshot-2003.06.28.webhtmldiff/webdiff --- websec-snapshot-2003.06.28/webdiff 2003-06-28 20:20:51.000000000 +0000 +++ websec-snapshot-2003.06.28.webhtmldiff/webdiff 2003-11-22 09:17:30.000000000 +0000 @@ -40,8 +40,20 @@ $tmax = 99999; $debug = 0; $ignoreFile = "ignore.list"; -$basedir = $ENV{HOME} . "/.websec/"; +if ( -e "url.list" ) { + $basedir = "."; +} +else { + if ( ($^O eq "Windows_NT") or ($^O eq "MSWin32")) + { + $basedir = $ENV{HOME} . "\\.websec\\"; + } + else + { + $basedir = $ENV{HOME} . "/.websec/"; + } +} # Parse options $help = 0; $man = 0; diff -Nur websec-snapshot-2003.06.28/websec websec-snapshot-2003.06.28.webhtmldiff/websec --- websec-snapshot-2003.06.28/websec 2003-06-28 20:20:51.000000000 +0000 +++ websec-snapshot-2003.06.28.webhtmldiff/websec 2003-11-22 09:17:32.000000000 +0000 @@ -45,7 +45,14 @@ $base = "."; } else { - $base = $ENV{HOME} . "/.websec"; + if ( ($^O eq "Windows_NT") or ($^O eq "MSWin32")) + { + $base = $ENV{HOME} . "\\.websec"; + } + else + { + $base = $ENV{HOME} . "/.websec"; + } } $help = 0; $man = 0; @@ -70,12 +77,25 @@ # Location of webdiff, if it's in the same directory as websec, use it, # this enables simply opening the archive and using the program inplace. +$webdiffbin = ".\\webdiff"; +if ( -e $webdiffbin ) { + $webdiffbin = "perl .\\webdiff"; +} +else +{ use FindBin; $webdiffbin = "$FindBin::Bin/webdiff"; if ( !-e $webdiffbin ) { $webdiffbin = "webdiff"; } +} +$htmldiffbin = ".\\htmldiff"; +if ( -e $htmldiffbin ) { + $htmldiffbin = "perl .\\htmldiff"; +} +else +{ $htmldiffbin = "$FindBin::Bin/htmldiff"; if ( !-e $htmldiffbin ) { $htmldiffbin = "./htmldiff"; @@ -83,6 +103,7 @@ $htmldiffbin = "htmldiff"; } } +} # prepare digest @digest = (); @@ -165,9 +186,13 @@ if (@htmldigest) { open( OUTPAGE, "> $base/index.html" ) or die "Cannot open $base/index.html: $!\n"; - print OUTPAGE "<HTML><BODY>The contents of the following URLs has changed:<P><P>"; - foreach (@htmldigest) { print OUTPAGE "$_<P>\n"; } - print OUTPAGE "<P></BODY></HTML>"; + print OUTPAGE "<HTML><BODY>The contents of the following URLs has changed:<P>"; + print OUTPAGE "<TABLE CELLSPACING=\"2\" CELLPADDING=\"2\" WIDTH=\"100%\" BORDER=\"1\">"; + print OUTPAGE "<TBODY>"; + foreach (@htmldigest) { print OUTPAGE "$_\n"; } + print OUTPAGE "</TBODY>"; + print OUTPAGE "</TABLE>"; + print OUTPAGE "</BODY></HTML>"; close(OUTPAGE); &ShowDocument( $program, $base."/index.html"); @@ -367,10 +392,12 @@ ShowDocument( $program, $outgoing ); } else { - push @htmldigest, "<A HREF=\"".$outgoing."\">Changes for ".$name."</A>". - "&nbsp;<A HREF=\"".$page_archive."\">previous page</A>". - "&nbsp;<A HREF=\"".$page_previous."\">current page</A>". - "&nbsp;<A HREF=\"".$url."\">current page on the net</A><P><P>"; + push @htmldigest, + "<TR><TD><A HREF=\"file://".$outgoing."\">Changes for ".$name."</A></TD>". + "&nbsp;<TD><A HREF=\"file://".$page_archive."\">previous page</A></TD>". + "&nbsp;<TD><A HREF=\"file://".$page_previous."\">current page</A></TD>". + "&nbsp;<TD><A HREF=\"".$url."\">current page on the net</A></TD>". + "</TR>"; } } } @@ -405,6 +432,58 @@ } else { my $filepath = File::Spec->rel2abs($page_previous); + $linkmsg = "The contents of the following URL has changed:\n$url\n\nIt can also be found at:\nfile://$filepath\n"; + MailMessage( $linkmsg, $subj, $emailLink ); + } + } + if ( $program ne "" ) { + if ( $programdigest ne "true" ) { + ShowDocument( $program, $outgoing ); + } + else { + push @htmldigest, + "<TR><TD><A HREF=\"file://".$outgoing."\">Changes for ".$name."</A></TD>". + "&nbsp;<TD><A HREF=\"file://".$page_archive."\">previous page</A></TD>". + "&nbsp;<TD><A HREF=\"file://".$page_previous."\">current page</A></TD>". + "&nbsp;<TD><A HREF=\"".$url."\">current page on the net</A></TD>". + "</TR>"; + } + } + } + else { + print "No changes were detected.\n"; + } + rename $page_previous, $page_archive; + rename $page_current, $page_previous; + } + else { + print + "No previous version for this page. Storing in archive ...\n"; + rename $page_current, $page_previous; + } + } + elsif ( $diff eq "webdiff_htmldiff" ) + { + if ( $page_previousExists == 1 ) { + print "First testing differences from previous version of webpage with webdiff...\n"; + $rc = system($webdiff); + if ( $rc != 0 ) { + print "webdiff found differences, now Highlighting differences from previous version of webpage using htmldiff...\n"; + $rc = system($htmldiff); + } + if ( $rc != 0 ) { + if ( $email ne "" ) { + print "Sending highlighted page to $email ...\n"; + MailDocument( $outgoing, $subj, $email ); + } + if ( $emailLink ne "" ) { + print "Sending link to $emailLink ...\n"; + if ( ( $digest ne "no" ) && ( $digest ne "false" ) ) { + push @digest, $url; + ($digestEmail) or ( $digestEmail = $emailLink ); + } + else { + my $filepath = File::Spec->rel2abs($page_previous); $linkmsg = "The contents of the following URL has changed:\n$url\n\nIt can also be found at:\nfile://$filepath\n"; MailMessage( $linkmsg, $subj, $emailLink ); @@ -415,10 +494,12 @@ ShowDocument( $program, $outgoing ); } else { - push @htmldigest, "<A HREF=\"".$outgoing."\">Changes for ".$name."</A>". - "&nbsp;<A HREF=\"".$page_archive."\">previous page</A>". - "&nbsp;<A HREF=\"".$page_previous."\">current page</A>". - "&nbsp;<A HREF=\"".$url."\">current page on the net</A><P><P>"; + push @htmldigest, + "<TR><TD><A HREF=\"file://".$outgoing."\">Changes for ".$name."</A></TD>". + "&nbsp;<TD><A HREF=\"file://".$page_archive."\">previous page</A></TD>". + "&nbsp;<TD><A HREF=\"file://".$page_previous."\">current page</A></TD>". + "&nbsp;<TD><A HREF=\"".$url."\">current page on the net</A></TD>". + "</TR>"; } } } @@ -535,25 +616,36 @@ # special handling for mozilla, try to use remoting... if ( $program eq "mozilla" ) { - $status = system("mozilla -remote \"ping()\""); - - # print "Status after ping: ".$status."\n"; - -# if ping() returns ne 0, mozilla is not running, we cannot use openurl() - if ( $status ne 0 ) { - $status = system( "mozilla", $outgoing ); + # on Windows, remoting is not available + if ( ($^O eq "Windows_NT") or ($^O eq "MSWin32")) + { + $status = system( "mozilla", "file://".$outgoing ); if ( $status ne 0 ) { print "Running mozilla returned status: " . $status . "\n"; } - } - else { - $status = - system( - "mozilla -remote \"openurl(" . $outgoing . ",new-tab)\"" ); - if ( $status ne 0 ) { - print "Running mozilla returned status: " . $status . "\n"; - } - } + } + else + { + $status = system("mozilla -remote \"ping()\""); + + # print "Status after ping: ".$status."\n"; + + # if ping() returns ne 0, mozilla is not running, we cannot use openurl() + if ( $status ne 0 ) { + $status = system( "mozilla", $outgoing ); + if ( $status ne 0 ) { + print "Running mozilla returned status: " . $status . "\n"; + } + } + else { + $status = + system( + "mozilla -remote \"openurl(" . $outgoing . ",new-tab)\"" ); + if ( $status ne 0 ) { + print "Running mozilla returned status: " . $status . "\n"; + } + } + } } elsif ($program eq "konqueror") { # konqueror from KDE has a small client application that helps with opening urls