Sfoglia il codice sorgente

Added "Most referenced URLs"

doomshammer 25 anni fa
parent
commit
996d7dcbb7
2 ha cambiato i file con 49 aggiunte e 2 eliminazioni
  1. 1 0
      Changelog
  2. 48 2
      pisg.pl

+ 1 - 0
Changelog

@@ -1,5 +1,6 @@
 pisg (0.21)
 pisg (0.21)
    * Fix stupid legend bug; 0-6 should be 0-5, and 7-11 should be 6-11.
    * Fix stupid legend bug; 0-6 should be 0-5, and 7-11 should be 6-11.
+   * Added "Most referenced URLs".
 
 
 pisg (0.20) - Tue, Aug 14th 2001
 pisg (0.20) - Tue, Aug 14th 2001
    * Add 'bgpic' config setting for the possibility to add a userdefined
    * Add 'bgpic' config setting for the possibility to add a userdefined

+ 48 - 2
pisg.pl

@@ -110,7 +110,7 @@ $thirdline, @ignore, $processtime, @topics, %monologue, %kicked, %gotkick,
 %loud, $totallength, %gaveop, %tookop, %joins, %actions, %sayings, %wordcount,
 %loud, $totallength, %gaveop, %tookop, %joins, %actions, %sayings, %wordcount,
 %lastused, %gotban, %setban, %foul, $days, $oldtime, $lastline, $actions,
 %lastused, %gotban, %setban, %foul, $days, $oldtime, $lastline, $actions,
 $normals, %T, $repeated, $lastnormal, %shout, %slap, %slapped, %words,
 $normals, %T, $repeated, $lastnormal, %shout, %slap, %slapped, %words,
-%line_time);
+%line_time, @urls, %urlnick);
 
 
 
 
 sub main
 sub main
@@ -409,6 +409,7 @@ sub parse_file
 {
 {
     my $file = shift;
     my $file = shift;
     my $foulwords = $conf->{foul};
     my $foulwords = $conf->{foul};
+	my $urlcount = 0;
 
 
     # This parses the file..
     # This parses the file..
     print "Analyzing log($file) in '$conf->{format}' format...\n";
     print "Analyzing log($file) in '$conf->{format}' format...\n";
@@ -420,7 +421,6 @@ sub parse_file
     } else {
     } else {
         open (LOGFILE, $file) or die("$0: Unable to open logfile($file): $!\n");
         open (LOGFILE, $file) or die("$0: Unable to open logfile($file): $!\n");
     }
     }
-
     while(my $line = <LOGFILE>) {
     while(my $line = <LOGFILE>) {
         $lines++; # Increment number of lines.
         $lines++; # Increment number of lines.
 
 
@@ -499,6 +499,12 @@ sub parse_file
                     $sadface{$nick}--
                     $sadface{$nick}--
                         if ($saying =~ /\w+:\/\//);
                         if ($saying =~ /\w+:\/\//);
 
 
+					if ($saying =~ /(\w+):+\/\/(\S+).*/) {
+						$urls[$urlcount] = $1 . "://" . $2;
+						$urlnick{$urls[$urlcount]} = $nick;
+						$urlcount++;
+					}
+
                     foreach my $word (split(/[\s,!?.:;)(]+/, $saying)) {
                     foreach my $word (split(/[\s,!?.:;)(]+/, $saying)) {
                         $words{$nick}++;
                         $words{$nick}++;
                         # remove uninteresting words
                         # remove uninteresting words
@@ -1065,6 +1071,8 @@ sub create_html
 
 
     mostreferenced();
     mostreferenced();
 
 
+	mosturls();
+
     headline(template_text('othernumtopic'));
     headline(template_text('othernumtopic'));
     html("<table width=\"$conf->{tablewidth}\">\n"); # Needed for sections
     html("<table width=\"$conf->{tablewidth}\">\n"); # Needed for sections
     gotkicks();
     gotkicks();
@@ -1444,6 +1452,44 @@ sub mostreferenced
 
 
 }
 }
 
 
+sub mosturls
+{
+	my %toll;
+	my $k = 0;
+	foreach(@urls) {
+		if($_ eq $urls[$k]) {
+			$toll{$_}++;
+		}
+		$k++;
+	}
+	my @sorturls = sort { $toll{$b} <=> $toll{$a} } keys %toll;
+
+    if (@sorturls) {
+
+        &headline(template_text('urlstopic'));
+
+        html("<table border=\"0\" width=\"$conf->{tablewidth}\"><tr>");
+        html("<td>&nbsp;</td><td bgcolor=\"$conf->{tdtop}\"><b>" . template_text('url') . "</b></td>");
+        html("<td bgcolor=\"$conf->{tdtop}\"><b>" . template_text('numberuses') . "</b></td>");
+        html("<td bgcolor=\"$conf->{tdtop}\"><b>" . template_text('lastused') . "</b></td>");
+
+       for(my $i = 0; $i < 5; $i++) {
+           last unless $i < $#sorturls;
+           my $a = $i + 1;
+           my $sorturl = $sorturls[$i];
+           my $urlcount = $toll{$sorturls[$i]};
+		   my $lastused = $urlnick{$sorturls[$i]};
+           html("<tr><td bgcolor=\"$conf->{rankc}\"><b>$a</b>");
+           html("<td bgcolor=\"$conf->{hicell}\"><a href=\"$sorturl\">$sorturl</a></td>");
+           html("<td bgcolor=\"$conf->{hicell}\">$urlcount</td>");
+		   html("<td bgcolor=\"$conf->{hicell}\">$lastused</td>");
+           html("</tr>");
+       }
+   html("</table>");
+   }
+
+}
+
 sub questions
 sub questions
 {
 {
     # Persons who asked the most questions
     # Persons who asked the most questions