######################################################################### # #

本日のリンク元を表示します。

#
# {{todayslink}}
# 
#

オプションで表示件数を指定することもできます。

#
# {{todayslink 10}}
# 
#

また、vオプションをつけるとリンク元のURLを表示することもできます。

#
# {{todayslink 10,v}}
# 
# ######################################################################### package plugin::info::TodaysLink; use strict; #======================================================================== # コンストラクタ #======================================================================== sub new { my $class = shift; my $self = {}; return bless $self,$class; } #======================================================================== # 本日のリンク元を表示します #======================================================================== sub paragraph { my $self = shift; my $wiki = shift; my $rank = shift;# 上位 $rank 位まで表示 my $way = shift; my $buf = ""; if($way eq ""){ $way = "H"; } if($rank eq "v" ||$rank eq "V"){ $way = "V"; $rank = ""; } elsif($rank eq "H" || $rank eq "h") { $way = "H"; $rank = ""; } # 今日の日付をログと同じフォーマットで my $time = time(); my ($sec,$min,$hour,$mday,$month,$year,$wday) = localtime($time); $year += 1900; $month += 1; my $today =sprintf("%04d/%02d/%02d",$year,$month,$mday); my $count={}; #logを走査 open(LOG,$wiki->config('log_dir')."/".$wiki->config('access_log_file')) or return ""; while(my $line=){ chomp $line; my ($page,$date,$time,$ip,$ref,$ua) = split(/ /,$line); if($date =~ /$today/){ $count->{$ref}++; } } close(LOG); my @keys = sort { my $count1 = $count->{$a}; my $count2 = $count->{$b}; return $count2<=>$count1; } keys(%{$count}); if ($way ne "H" && $way ne "h"){ $buf .= "\n" ; }else{ $buf .="]"; } return $buf; } 1;