){
chop;
($num,$date,$name,$mail,$host,$today,@line)=split(/,/);
if ($in{perso} eq "nokeep"){$name=&checkname($name);}
$count{$name}++;
$total++;
}
close(FILE);
$i=0;
foreach (keys(%count)){
$content{"${count{$_}}_${i}"}="$_";
$i++;
}
@tmp=keys(%content);
@sortdata=reverse(sort({$a<=>$b}@tmp));
print "\n";
foreach $data (@sortdata){
print "";
print "| $content{$data} | \n";
$data =~ s/^(\d\d*)_\d\d*/$1/;
print "";
$linemax=$sortdata[0];
if ($linemax == 0){last;}
$width=($data/$linemax)*$rightend;
if ($width != 0){
print " \n";
}
# for($j=0;$j<$data;$j=$j+$inc){
# print "*";
# }
if ($total == 0){last;}
$pars=($data/$total)*100;
print " $data";
printf(" (%3.2f%%)",$pars);
print " |
";
print "";
}
print "
";
$people=$#sortdata+1;
print "
";
print "トータル=$total件、 延べ人数=";
print "$people";
print "人、一人平均=";
if ($people == 0){$people=1;}
$mean=$total/$people;
printf("%3.2f",$mean);
print "件
";
}
if ($in{choise} eq data6a){
$inc=2;
print "$titleprint\n";
&subtitle;
print "\n";
$realy=$in{y2}+1900;
print "$realy年$in{m2}月のデータ";
open(FILE,"< $filename");
while (){
chop;
($num,$date,$name,$mail,$host,$today,@line)=split(/,/);
if ($date =~ /^$in{y2}_$in{m2}_\d\d?$/){
if ($in{perso} eq "nokeep"){$name=&checkname($name);}
$count{$name}++;
$total++;
}
}
close(FILE);
$i=0;
foreach (keys(%count)){
$content{"${count{$_}}_${i}"}="$_";
$i++;
}
@tmp=keys(%content);
@sortdata=reverse(sort({$a<=>$b}@tmp));
$linemax=$sortdata[0];
print "\n";
foreach $data (@sortdata){
print "";
print "| $content{$data} | \n";
$data =~ s/^(\d\d*)_\d\d*/$1/;
print "";
if ($linemax == 0){last;}
$width=($data/$linemax)*400;
if ($width != 0){
print " \n";
}
# for($j=0;$j<$data;$j=$j+$inc){
# print "*";
# }
if ($total == 0){last;}
$pars=($data/$total)*100;
print " $data";
printf(" (%3.2f%%)",$pars);
print " |
";
print "";
}
print "
";
$people=$#sortdata+1;
print "
";
print "トータル=$total件、 延べ人数=";
print "$people";
print "人、一人平均=";
if ($people == 0){$people=1;}
$mean=$total/$people;
printf("%3.2f",$mean);
print "件
";
}
if ($in{choise} eq data6b){
$inc=20;
print "$titleprint\n";
&subtitle;
print "\n";
$realy=$in{y3}+1900;
print "$realy年のデータ";
open(FILE,"< $filename");
while (){
chop;
($num,$date,$name,$mail,$host,$today,@line)=split(/,/);
if ($date =~ /^$in{y3}_\d\d?_\d\d?$/){
$name1=$name;
if ($in{perso} eq "nokeep"){$name=&checkname($name);}
$count{$name}++;
$total++;
}
}
close(FILE);
$i=0;
foreach (keys(%count)){
$content{"${count{$_}}_${i}"}="$_";
$i++;
}
@tmp=keys(%content);
@sortdata=reverse(sort({$a<=>$b}@tmp));
$linemax=$sortdata[0];
print "\n";
foreach $data (@sortdata){
print "";
print "| $content{$data} | \n";
$data =~ s/^(\d\d*)_\d\d*/$1/;
print "";
if ($linemax == 0){last;}
$width=($data/$linemax)*$rightend;
if ($width != 0){
print " \n";
}
# for($j=0;$j<$data;$j=$j+$inc){
# print "*";
# }
if ($total == 0){last;}
$pars=($data/$total)*100;
print " $data";
printf(" (%3.2f%%)",$pars);
print " |
";
print "";
}
print "
";
$people=$#sortdata+1;
print "
";
print "トータル=$total件、 延べ人数=";
print "$people";
print "人、一人平均=";
if ($people == 0){$people=1;}
$mean=$total/$people;
printf("%3.2f",$mean);
print "件
";
}
if ($in{choise} eq data6c){
$inc=2;
print "$titleprint\n";
&subtitle;
print "\n";
print "";
print "| 月 | ";
print "1位 | ";
print "2位 | ";
print "3位 | ";
print "
";
open(FILE,"< $filename");
$j=0;
while () {
chop;
($num,$date,$name,$mail,$host,$today,@line)=split(/,/);
if ($in{perso} eq "nokeep"){$name=&checkname($name);}
$date =~ s/^(\d?\d\d_\d\d?)_\d\d?$/$1/;
if ($lastmon ne '' && $lastmon ne $date){
&mktbl;
$j=$j+1;
undef %count;
undef %content;
}
$count{"$name"}++;
$total++;
$lastmon=$date;
}
close(FILE);
&mktbl;
for($i=$j;$i>=0;$i=$i-1){
($ym,$a1,$a2,$b1,$b2,$c1,$c2)=split(/\,/,$tbl[$i]);
($yyy,$mmm)=split(/_/,$ym);
$yyy=$yyy+1900;
print "| $yyy年$mmm月 | ";
print "$a1 $a2件 | ";
print "$b1 $b2件 | ";
print "$c1 $c2件 | ";
print "
";
}
print "
";
}
sub mktbl {
$i=0;
foreach (keys(%count)){
$content{"${count{$_}}_$i"}="$_";
$i++;
}
@tmp = keys(%content);
@tmp1 = reverse(sort {$a<=>$b} @tmp);
$top=$tmp1[0];
$top =~ s/^(\d\d*)_\d\d*$/$1/;
$second=$tmp1[1];
$second =~ s/^(\d\d*)_\d\d*$/$1/;
$third=$tmp1[2];
$third =~ s/^(\d\d*)_\d\d*$/$1/;
$tbl[$j]="$lastmon,$content{$tmp1[0]},$top,$content{$tmp1[1]},$second,$content{$tmp1[2]},$third";
}
if ($in{choise} eq data7){
print "$titleprint\n";
&subtitle;
print "\n";
open(FILE,"< $filename");
while (){
chop;
($num,$date,$name,$mail,$host,$today,@line)=split(/,/);
$date =~ s/_(\d_\d?\d)$/_0${1}/;
$date =~ s/_(\d\d_)(\d)$/_${1}0${2}/;
$date =~ s/^(9\d_\d\d_\d\d)$/0${1}/;
$date2=$date;
$date =~ s/^(\d?\d\d)_\d?\d_\d?\d$/$1/;
$today2=$today;
$today2 =~ s/^(\d\d?\d?)..*/$1/;
if ($in{perso} eq "nokeep"){$name=&checkname($name);}
if ($today2 != $date){
$count{$name}=sprintf("%s_%s年%s_%s",$date2,$date,$today,$num);
} else {
$count{$name}="${date2}_${today}_${num}";
}
}
close(FILE);
foreach (keys(%count)){
$content{"$count{$_}"}="$_";
}
@tmp=keys(%content);
@sortdata=reverse(sort(@tmp));
print "";
foreach $today (@sortdata){
$today2 = $today;
$today2 =~ s/^\d?\d\d_\d\d_\d\d_(..*)_(\d\d*)$/$1/;
@darray = split(/[^\d]/,$today2);
@tmpaaa = split(/日[^\)]/,$today2);
$datex=$darray[0];
$tx=sprintf("%s月%s日(%s",$darray[2],$darray[4],$tmpaaa[1]);
$today2=sprintf("%s年%s",$datex+1900,$tx);
$mesnum=$2;
print "| $content{$today} | $today2 | #$mesnum |
\n";
}
print "
";
}
if ($in{choise} eq data10){
print "$titleprint\n";
&subtitle;
print "\n";
print "「$in{hname}」での集計\n";
open(FILE,"< $filename");
while (){
chop;
($num,$date,$name,@line)=split(/,/);
if ($in{perso} eq "nokeep"){
$name=&checkname($name);
$hname=&checkname($in{hname});
} else {
$hname=$in{hname};
}
if ($name eq $hname){
if ($date =~ /^${in{y1}}_${in{m1}}_/){
$count{$date}++;
$total++;
}
}
}
close(FILE);
for ($i=1;$i<=$finday;$i++){
$date="${in{y1}}_${in{m1}}_${i}";
printf("%04d/%02d/%02d | ",$in{y1}+1900,$in{m1},$i);
$linemax=40;
$width=($count{$date}/$linemax)*$rightend;
if ($width != 0){
print "
\n";
}
# for($j=0;$j<$count{$date};$j++){
# print "*";
# }
if ($count{$date} eq ""){$count{$date}=0;}
print " $count{$date}
";
}
$mean=$total/$finday;
print "---------------------
";
print "トータル=$total件、 一日平均=";
printf("%3.2f",$mean);
print "件
";
}
if ($in{choise} eq data11){
print "$titleprint\n";
&subtitle;
print "\n";
print "「$in{hname}」での集計\n";
open(FILE,"< $filename");
while (){
chop;
($num,$date,$name,@line)=split(/,/);
if ($in{perso} eq "nokeep"){
$name=&checkname($name);
$hname=&checkname($in{hname});
} else {
$hname=$in{hname};
}
if ($name eq $hname){
$count{$date}++;
$total++;
}
}
close(FILE);
$i=0;
foreach (keys(%count)){
$content{"${count{$_}}_${i}"}="$_";
$i++;
}
@tmp=keys(%content);
@tmp1=reverse(sort({$a<=>$b}@tmp));
@sortdata=splice(@tmp1,0,30);
foreach $number (@sortdata){
$date=$content{$number};
($yy,$mm,$dd,$dummy)=split(/_/,$date);
printf("%04d/%02d/%02d | ",$yy+1900,$mm,$dd);
$linemax=20;
$width=($number/$linemax)*$rightend;
if ($width != 0){
print "
\n";
}
# for($j=0;$j<$number;$j++){
# print "*";
# }
if ($number eq ""){$number=0;}
print " $count{$date}
";
}
$mean=$total/$finday;
print "---------------------
";
print "トータル=$total件、 一日平均=";
printf("%3.2f",$mean);
print "件
";
}
if ($in{choise} eq data12){
print "$titleprint\n";
&subtitle;
print "\n";
print "「$in{hname}」での集計\n";
open(FILE,"< $filename");
$i=0;
while (){
chop;
($num,$date,$name,@line)=split(/,/);
if ($in{perso} eq "nokeep"){
$name=&checkname($name);
$hname=&checkname($in{hname});
} else {
$hname=$in{hname};
}
if ($name eq $hname){
if ($i==0){$date1=$date;$num0=$num;}
$count{$date}++;
$i++;
}
}
close(FILE);
($yyy,$mmm,$ddd)=split(/_/,$date1);
($yyy2,$mmm2,$ddd2)=split(/_/,$date);
@timetmp=gmtime($time_offset);
$firstline=timelocal(0,0,0,$ddd,$mmm-1,$yyy,$timetmp[6],$timetmp[7],$timetmp[8]);
$endline=timelocal(0,0,0,$ddd2,$mmm2-1,$yyy2,$timetmp[6],$timetmp[7],$timetmp[8]);
@tmp=sort {$a<=>$b} values(%count);
$max=$tmp[$#tmp];
$total=$#tmp+1;
$yyy = $yyy + 1900;
$yyy2 = $yyy2 + 1900;
print "$yyy年$mmm月$ddd日から$yyy2年$mmm2月$ddd2日まで";
for ($i=0;$i<=$max;$i++){
@dnum=grep(/^$i$/,@tmp);
$value=$#dnum+1;
if ($i==0){
for($y=$yyy-1900;$y<=$yyy2-1900;$y++){
for($m=1;$m<=12;$m++){
if (($m =~ /^[13578]$/) || ($m =~ /^1[02]$/)){
$finday = 31;
} elsif (($m =~ /^[469]$/) || ($m == 11)){
$finday = 30;
} elsif ($m == 2){
$finday = 28;
}
for($d=1;$d<=$finday;$d++){
$curline=timelocal(0,0,0,$d,$m-1,$y,$timetmp[6],$timetmp[7],$timetmp[8]);
if (($curline < $firstline)||($curline > $endline)){next;}
if ($count{"${y}_${m}_${d}"} eq ""){
$value++;
}
if ($date eq "${y}_${m}_${d}"){last;}
}
if ($date eq "${y}_${m}_${d}"){last;}
}
if ($date eq "${y}_${m}_${d}"){last;}
}
$gtotal=$value;
}
$linemax=2000;
printf("%02d件 | ",$i);
$width=($value/$linemax)*$rightend;
if ($width != 0){
print "
\n";
}
# for($j=0;$j<$value;$j=$j+5){
# print "*";
# }
$num2 = $num2+$value*$i;
$mean1=($value/($total+$gtotal))*100;
print " $value日";
printf(" (%3.2f%%)
",$mean1);
}
$total=$total+$gtotal;
$mean=($total/($num2))*24;
print "---------------------
";
print "トータル=$total日、$num2件、 投稿平均間隔=";
printf("%3.2f",$mean);
print "時間
";
}
if ($in{choise} eq data13){
if (($in{new} eq on)&&($in{past} eq on)){
$inc=5;
} elsif ($in{new} eq on){
$inc=1;
} elsif ($in{past} eq on){
$inc=5;
}
print "$titleprint\n";
&subtitle;
print "
\n";
print "「$in{hname}」での集計\n";
open(FILE,"< $filename");
while (){
chop;
($num,$date,$name,$mail,$host,$today,@line)=split(/,/);
if ($in{perso} eq "nokeep"){
$name=&checkname($name);
$hname=&checkname($in{hname});
} else {
$hname=$in{hname};
}
if ($name eq $hname){
if ($today =~ /(\d\d)時\d\d分$/){
$count[$1]++;
$total++;
}
}
}
close(FILE);
@tmp = sort {$a <=> $b} @count;
$linemax=$tmp[$#tmp];
for($i=0;$i<=23;$i++){
printf("%02d時〜%02d時 | ",$i,$i+1);
if ($linemax == 0){last;}
$width=($count[$i]/$linemax)*$rightend;
if ($width != 0){
print "
\n";
}
# for($j=0;$j<$count[$i];$j=$j+$inc){
# print "*";
# }
if ($total == 0){last;}
$pars=($count[$i]/$total)*100;
if ($count[$i] eq ""){$count[$i] = 0;}
print " $count[$i]";
printf(" (%2.2f%%)
\n",$pars);
}
print "---------------------
";
print "トータル=$total件
";
}
if ($in{choise} eq data14){
if (($in{new} eq on)&&($in{past} eq on)){
$inc=5;
} elsif ($in{new} eq on){
$inc=1;
} elsif ($in{past} eq on){
$inc=5;
}
print "$titleprint\n";
&subtitle;
print "\n";
print "「$in{hname}」での集計\n";
open(FILE,"< $filename");
while (){
chop;
($num,$date,$name,$mail,$host,$today,@line)=split(/,/);
if ($in{perso} eq "nokeep"){
$name=&checkname($name);
$hname=&checkname($in{hname});
} else {
$hname=$in{hname};
}
if ($name eq $hname){
if ($today =~ /\((.*)\)\d\d時\d\d分$/){
$count{$1}++;
$total++;
}
}
}
close(FILE);
@tmp = sort {$a <=> $b} values(%count);
$linemax=$tmp[$#tmp];
foreach $week ('日','月','火','水','木','金','土'){
printf("%s | ",$week);
if ($linemax == 0){last;}
$width=($count{$week}/$linemax)*$rightend;
if ($width != 0){
print "
\n";
}
# for($j=0;$j<$count{$week};$j=$j+$inc){
# print "*";
# }
if ($count{$week} eq ""){$count{$week}=0;}
if ($total == 0){last;}
$pars=($count{$week}/$total)*100;
print " $count{$week}\n";
printf(" (%2.2f%%)
\n",$pars);
}
print "---------------------
";
print "トータル = $total件
\n";
}
if ($in{choise} eq data15){
$inc=2;
print "$titleprint\n";
&subtitle;
print "\n";
print "「$in{hname}」での集計\n";
open(FILE,"< $filename");
while (){
chop;
($num,$date,$name,@line)=split(/,/);
if ($in{perso} eq "nokeep"){
$name=&checkname($name);
$hname=&checkname($in{hname});
} else {
$hname=$in{hname};
}
$date =~ s/^(\d?\d\d_\d?\d)_\d?\d$/$1/;
$count{$date}++;
$total++;
if ($name eq $hname){
$personal{$date}++;
$ptotal++;
}
}
close(FILE);
@item=keys(%count);
@item1=();
foreach (@item){
s/^(\d?\d\d)_(\d)$/${1}0$2/;
s/^(\d?\d\d)_(\d\d)$/$1$2/;
push(@item1,$_);
}
@item1=sort {$a <=> $b} @item1;
$flag = 0;
@tmp = sort {$a <=> $b} values(%personal);
$linemax=$tmp[$#tmp];
foreach $date (@item1){
$date =~ s/^(\d?\d\d)([1-9]\d)$/${1}_$2/;
$date =~ s/^(\d?\d\d)0(\d)$/${1}_$2/;
($yy,$mm)=($1,$2);
if ($personal{$date} == 0 && $flag == 0){next;}
printf("%04d年%02d月 | ",$yy+1900,$mm);
if ($linemax == 0){last;}
$width=($personal{$date}/$linemax)*$rightend;
if ($width != 0){
print "
\n";
}
# for($j=0;$j<$personal{$date};$j=$j+$inc){
# print "*";
# }
if ($count{$date} != 0){
$pers=($personal{$date}/$count{$date})*100;
} else {
$pers=0;
}
if ($personal{$date} eq ""){$personal{$date}=0;}
print " $personal{$date}";
printf(" (%3.2f%%)
\n",$pers);
# if ($personal{$date} == 0 && $flag == 0){next;}
$flag = 1;
$item3++;
$p2total = $p2total + $count{$date};
}
# $mean1=$total/($#item+1);
if ($total != 0){$pers2=($ptotal/$total)*100;}
if ($p2total != 0){$pers1=($ptotal/$p2total)*100;}
if ($item3 != 0){$mean2=$ptotal/$item3;}
print "---------------------
";
print "トータル=$ptotal件、 初書き込み以来月平均=";
printf("%3.2f",$mean2);
print "件、
";
print "初書き込み以来全体の";
printf("%3.2f%%、",$pers1);
print "全書き込みの";
printf("%3.2f%%",$pers2);
print "\n";
}
if ($in{choise} eq data15a){
$inc=2;
print "$titleprint\n";
&subtitle;
print "\n";
print "「$in{hname}」での集計\n";
open(FILE,"< $filename");
while (){
chop;
($num,$date,$name,@line)=split(/,/);
if ($in{perso} eq "nokeep"){
$name=&checkname($name);
$hname=&checkname($in{hname});
} else {
$hname=$in{hname};
}
$date =~ s/^(\d?\d\d)_\d?\d_\d?\d$/$1/;
$count{$date}++;
$total++;
if ($name eq $hname){
$personal{$date}++;
$ptotal++;
}
}
close(FILE);
@item=keys(%count);
@item1=@item;
# @item1=();
# foreach (@item){
# s/^(\d?\d\d)_(\d)$/${1}0$2/;
# s/^(\d?\d\d)_(\d\d)$/$1$2/;
# push(@item1,$_);
# }
@item1=sort {$a <=> $b} @item1;
$flag = 0;
@tmp = sort {$a <=> $b} values(%personal);
$linemax=$tmp[$#tmp];
foreach $date (@item1){
# $date =~ s/(\d?\d\d)([1-9]\d)/${1}_$2/;
# $date =~ s/(\d?\d\d)0(\d)/${1}_$2/;
$yy=$date;
if ($personal{$date} == 0 && $flag == 0){next;}
printf("%04d年 | ",$yy+1900);
if ($linemax == 0){last;}
$width=($personal{$date}/$linemax)*$rightend;
if ($width != 0){
print "
\n";
}
$pers=($personal{$date}/$count{$date})*100;
if ($personal{$date} eq ""){$personal{$date}=0;}
print " $personal{$date}";
printf(" (%3.2f%%)
\n",$pers);
# if ($personal{$date} == 0 && $flag == 0){next;}
$flag = 1;
$item3++;
$p2total = $p2total + $count{$date};
}
# $mean1=$total/($#item+1);
if ($item3 != 0){$mean2=$ptotal/$item3;}
if ($p2total != 0){$pers1=($ptotal/$p2total)*100;}
if ($total != 0){$pers2=($ptotal/$total)*100;}
print "---------------------
";
print "トータル=$ptotal件、 初書き込み以来年平均=";
printf("%3.2f",$mean2);
print "件、
";
print "初書き込み以来全体の";
printf("%3.2f%%、",$pers1);
print "全書き込みの";
printf("%3.2f%%",$pers2);
print "\n";
}
print "\n";
print "";
if ($in{ref} eq 'part' || $in{ref} eq 'timeframe' || $compatible == 1){
unlink("$tmpdata");
}
exit;
sub subtitle {
if ($in{ref} eq 'part'){
print "Message#$in{startnum}から$in{endnum}まで\n";
} elsif ($in{ref} eq 'timeframe'){
$fullsty=$in{styear}+1900;
$fulledy=$in{endyear}+1900;
print "$fullsty年$in{stmon}月$in{stday}日から$fulledy年$in{endmon}月$in{endday}日まで
\n";
}
}
}
sub gentmpdata {
local($filename,$tmpdata);
$tmpdata = "$mbdir/tmp.$$";
if ($compatible == 1) {
`$cat $mbarchdata $mbpastdata $mbdata > $alldata`;
chmod(0666,"$alldata");
$filename="$alldata";
} else {
$filename = $mbdata;
}
if (($in{m1} =~ /^[13578]$/) || ($in{m1} =~ /^1[02]$/)){
$finday = 31;
} elsif (($in{m1} =~ /^[469]$/) || ($in{m1} == 11)){
$finday = 30;
} elsif ($in{m1} == 2){
$finday = 28;
}
if ($in{ref} eq 'part'){
open(ALLFILE,"< $filename");
open(TMPFILE,"> $tmpdata");
while(){
($num,@dum)=split(/,/);
if ($num >= $in{startnum} && $num <= $in{endnum}){
print TMPFILE;
}
if ($num > $in{endnum}){last;}
}
close(ALLFILE);
close(TMPFILE);
$filename=$tmpdata;
} elsif ($in{ref} eq 'timeframe'){
open(ALLFILE,"< $filename");
open(TMPFILE,"> $tmpdata");
@timetmp=gmtime($time_offset);
$firstline=timelocal(0,0,0,$in{stday},$in{stmon}-1,$in{styear},$timetmp[6],$timetmp[7],$timetmp[8]);
$endline=timelocal(0,0,0,$in{endday},$in{endmon}-1,$in{endyear},$timetmp[6],$timetmp[7],$timetmp[8]);
while(){
($num,$datecode,@dum)=split(/,/);
($cury,$curm,$curd)=split(/_/,$datecode);
$curline=timelocal(0,0,0,$curd,$curm-1,$cury,$timetmp[6],$timetmp[7],$timetmp[8]);
if (($curline >= $firstline)&&($curline <= $endline)){
print TMPFILE;
}
if ($curline > $endline){last;}
}
close(ALLFILE);
close(TMPFILE);
$filename=$tmpdata;
}
return ($filename,$tmpdata);
}
# 統計の個人名方式で「人物」を選んだ場合に違う名前を同一人物と
# 判断させることができます。
# namedef.datにそれらの名前を人物ごとに1行に登録されていると
# 一番左の名前が代表として表示されます。
# 例:以下はnamedef.datの内容の例です。
# ----------------------------------------
# 管理人,作成者,かんりにん
# ホークス,hawks
# ----------------------------------------
# この例では、「作成者」「かんりにん」共に「管理人」と同一人物として
# まとめて集計されます。
# 「ホークス」は改行されているので管理人と別人として判断されますが、
# 「hawks」とは同一人物となります。
# namedef.datがない場合は、書き込みの名前そのままで集計されます。
sub checkname {
local($name)=@_;
open(NAMES,"< $namedef") || return($name);
while(){
s/[\r\n]*$//; # instead of chop;
(@nicknames)=split(/,/);
foreach $nick (@nicknames){
if ("$name" eq "$nick"){
close(NAMES);
return($nicknames[0]);
}
}
}
close(NAMES);
return($name);
}
#############################################################################
# Search Form mode ##########################################################
#############################################################################
sub mbschform {
&getmbdata;
($num,$datecode,@dum)=split(/,/,$alldata[$#alldata]);
$datecode =~ /^(\d\d+)_\d+_\d+/;
$finyear = $1;
if ($compatible == 0){
open(FILE,"< $mbdata");
$firstdata = ;
close(FILE);
} else {
open(FILE,"< $mbarchdata") || open(FILE,"< $mbpastdata") || open(FILE,"< $mbdata");
$firstdata = ;
close(FILE);
}
($num,$datecode,@dum)=split(/,/,$firstdata);
$datecode =~ /^(\d\d+)_/;
$firstyear = $1;
print "Content-Type:text/html\n\n";
print <
$mbsrctitle
END
if ($head_insert_en == 1){
print "$head_insert\n";
}
if ($style_sheet_en == 1){
print "\n";
}
$titleprint=&titleprint("$mbsrctitle","$mbsrc_logo","$mbsrc_style","$mbsrc_color","$mbsrc_size","$mbsrc_face","$mbsrc_sel","$mbsrc_loc");
print <
\n";
open(FILE,"< $filename") || "die Cannot open file\n";
print "\n";
while (){
s/[\r\n]*$//;
$nameres = "false";
$titleres = "false";
$main1res = "false";
$main2res = "false";
$main3res = "false";
($lnum,$ldcode,$lname,$lmadd,$lip,$ldate,$ltitle,$lmain,$lencpwd,$limagefile)=split(/,/);
$lmain =~ s/(http..*)<\/a>/$1/;
$lmain =~ s/\>\;[^<]*
//g;
# $lmain =~ s/
/ /g;
($name ne '') && ("$lname" =~ /$name/) && ($nameres = 'true');
($in{title} ne '') && ("$ltitle" =~ /$in{title}/) && ($titleres = 'true');
($in{main1} ne '') && ("$lmain" =~ /$in{main1}/) && ($main1res = 'true');
($in{main2} ne '') && ("$lmain" =~ /$in{main2}/) && ($main2res = 'true');
($in{main3} ne '') && ("$lmain" =~ /$in{main3}/) && ($main3res = 'true');
if (($nameres eq false) && ($titleres eq false) && ($main1res eq false) && ($main2res eq false) && ($main3res eq false)) {next;}
if (($nameres eq false || $titleres eq false) && $in{name_plus} eq 'and' && $name ne '' && $in{title} ne ''){next;}
if (($nameres eq false || $main1res eq false) && $in{name_plus} eq 'and' && $name ne '' && $in{main1} ne ''){next;}
if (($nameres eq false || $main2res eq false) && $in{name_plus} eq 'and' && $name ne '' && $in{main2} ne ''){next;}
if (($nameres eq false || $main3res eq false) && $in{name_plus} eq 'and' && $name ne '' && $in{main3} ne ''){next;}
if (($titleres eq false || $main1res eq false) && $in{title_plus} eq 'and' && $in{title} ne '' && $in{main1} ne ''){next;}
if (($titleres eq false || $main2res eq false) && $in{title_plus} eq 'and' && $in{title} ne '' && $in{main2} ne ''){next;}
if (($titleres eq false || $main3res eq false) && $in{title_plus} eq 'and' && $in{title} ne '' && $in{main3} ne ''){next;}
if (($main1res eq false || $main2res eq false) && $in{main1_plus} eq 'and' && $in{main1} ne '' && $in{main2} ne ''){next;}
if (($main1res eq false || $main3res eq false) && $in{main1_plus} eq 'and' && $in{main1} ne '' && $in{main3} ne ''){next;}
if (($main2res eq false || $main3res eq false) && $in{main2_plus} eq 'and' && $in{main2} ne '' && $in{main3} ne ''){next;}
# print "$nameres/$in{name_plus}:$titleres/$in{title_plus}:$main1res/$in{main1_plus}:$main2res/$in{main2_plus}:$main3res/$in{main3_plus}
";
print "- ";
if ($name ne ''){$lname =~ s/($name)/$1<\/b>/g;}
print "#$lnum";
print ", $lname, ";
if ($in{title} ne ''){$ltitle =~ s/($in{title})/$1<\/b>/g;}
# $ltitle =~ s/,(\d)/,$1/g;
@sub2=split(/Re:/,$ltitle);
if ($#sub2 > 1){
print "Re$#sub2:$sub2[$#sub2]";
} else {
print "$ltitle";
}
@ldlist = split(/_/,$ldcode);
printf(" ,%d年%d月%d日
\n",$ldlist[0]+1900,$ldlist[1],$ldlist[2]);
$lmain =~ s/
/ /g;
if ($in{main1} ne '' && $lmain =~ $in{main1}){
$lmain =~ m/($in{main1})/g;
} elsif ($in{main2} ne '' && $lmain =~ $in{main2}){
$lmain =~ m/($in{main2})/g;
} elsif ($in{main3} ne '' && $lmain =~ $in{main3}){
$lmain =~ m/($in{main3})/g;
}
$position = pos($lmain);
if ($position < 100) {$position = 100;}
$lmain = substr($lmain,$position-100,200);
# $tail1 = substr($lmain,199,200);
# $head1 = substr($lmain,0,1);
# print "$head1
$tail1
\n";
# $lmain =~ s/,(\d)/,$1/g;
$lmain1 = $lmain;
$taillmain = chop($lmain1);
$taillmain2 = substr($lmain1,-1);
$tailhex = unpack("C",$taillmain);
$tailhex2 = unpack("C",$taillmain2);
$lastchar = $tailhex2 * 0x100 + $tailhex;
# printf("上%x
",$tailhex);
# printf("上%x
",$tailhex2);
# printf("%x
",$lastchar);
# printf("%x
",$tailhex);
# @tmp = ($tailhex2 , $tailhex);
# printf("%s
",pack("C2",@tmp));
# $a = ($tailhex >= 0x21 && $tailhex <= 0x7e);
# $b = ($tailhex >= 0xa1 && $tailhex <= 0xdf);
# $c = ($lastchar >= 0x8140 && $lastchar <= 0x84be);
# $d = ($lastchar >= 0x889f && $lastchar <= 0x9872);
# $e = ($lastchar >= 0x989f && $lastchar <= 0x9ffc);
# print "$a,$b,$c,$d,$e
";
if (!(
# $tailhex >= 0x21 && $tailhex <= 0x7e ||
# $tailhex >= 0xa1 && $tailhex <= 0xdf ||
$lastchar >= 0x8140 && $lastchar <= 0x84be ||
$lastchar >= 0x889f && $lastchar <= 0x9872 ||
$lastchar >= 0x989f && $lastchar <= 0x9ffc)){
$lmain = $lmain1;
}
$headlmain = substr($lmain,0,1);
$headlmain2 = substr($lmain,1,1);
$lmain2 = substr($lmain,1);
$headhex = unpack("C",$headlmain);
$headhex2 = unpack("C",$headlmain2);
$headchar = $headhex * 0x100 + $headhex2;
# printf("下%x
",$headhex);
# printf("下%x
",$headhex2);
# printf("%x
",$headchar);
# printf("%x
",$headhex);
# @tmp = ($headhex , $headhex2);
# printf("%s
",pack("C2",@tmp));
# $a = ($headhex >= 0x21 && $headhex <= 0x7e);
# $b = ($headhex >= 0xa1 && $headhex <= 0xdf);
# $c = ($headchar >= 0x8140 && $headchar <= 0x84be);
# $d = ($headchar >= 0x889f && $headchar <= 0x9872);
# $e = ($headchar >= 0x989f && $headchar <= 0x9ffc);
# print "$a,$b,$c,$d,$e
";
if (!($headchar >= 0x8140 && $headchar <= 0x84be ||
$headchar >= 0x889f && $headchar <= 0x9872 ||
$headchar >= 0x989f && $headchar <= 0x9ffc)){
# print "下hit
";
$lmain = $lmain2;
}
if ($in{main1} ne ''){$lmain =~ s/($in{main1})/$1<\/b>/g;}
if ($in{main2} ne ''){$lmain =~ s/($in{main2})/$1<\/b>/g;}
if ($in{main3} ne ''){$lmain =~ s/($in{main3})/$1<\/b>/g;}
print "$lmain \n";
}
print "
\n";
close(FILE);
print "\n";
print "";
if ($in{ref} eq 'part' || $in{ref} eq 'timeframe' || $compatible == 1){
unlink("$tmpdata");
}
exit;
}
#############################################################################
# Archive Form mode #########################################################
#############################################################################
sub mbarchform {
print "Content-Type:text/html\n\n";
print <
$mbarctitle
END
if ($head_insert_en == 1){
print "$head_insert\n";
}
if ($style_sheet_en == 1){
print "\n";
}
$titleprint=&titleprint("$mbarctitle","$mbarc_logo","$mbarc_style","$mbarc_color","$mbarc_size","$mbarc_face","$mbarc_sel","$mbarc_loc");
print <
$titleprint
このページでメッセージボードのアーカイブを作成できます。
下の項目から一つを選び、条件を入力して「作成」をクリックしてください。HTML,圧縮ファイル名は変更できます。ダウンロード後、WinZip等で解凍してブラウザでご覧ください(圧縮は$compmsgで行われています)。作成されたメッセージは、古い順になっています。圧縮ファイルは200件で約30KB、1000件で約150KBになります。画像は表\\示されません。
メッセージボードへ
|
END2
}
#############################################################################
# Archive mode ##############################################################
#############################################################################
sub mbarch {
$outfile="$mbdir/$in{htmlname}";
$zipfile="$mbdir/$in{archname}";
if ($in{choice} eq "unread"){
$to=&newnum;
$from=&getcookie+1;
} elsif ($in{choice} eq "new200") {
$to=&newnum;
$from=$to-199;
if ($from < 1) {$from = 1;}
} elsif ($in{choice} eq "tillnew") {
$to=&newnum;
$from=$in{start1};
} elsif ($in{choice} eq "fromto") {
$to=$in{end2};
$from=$in{start2};
} else {
print "Content-type: text/html\n\n";
print "\n";
print "\n";
if ($head_insert_en == 1){
print "$head_insert\n";
}
if ($style_sheet_en == 1){
print "\n";
}
print "\n";
print "\n";
print "
どれか選択した後「作成」をクリックしてください。\n";
print "\n";
exit;
}
if ($compatible == 1){
$infile="$alldata";
`$cat $mbarchdata $mbpastdata $mbdata > $alldata`;
} else {
$infile = $mbdata;
}
&printmb($from,$to,$infile,$outfile);
chmod(0666,"$outfile");
if (-e $zipfile){unlink($zipfile);}
`$compress $outfile`;
if (-e "$outfile.gz"){
if ("$outfile.gz" ne "$zipfile"){rename("$outfile.gz","$zipfile");}
chmod(0666,"$zipfile");
print "Location: $zipfile\n\n";
} else {
print "Content-type: text/html\n\n";
print "\n";
print "
ファイルが作成されませんでした。圧縮コマンドの設定が正しくないと思われます。管理人へ連絡してください。\n";
print "\n";
}
exit;
sub getcookie {
$cookies = $ENV{'HTTP_COOKIE'};
@pairs = split(/;/,$cookies);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ s/ //g;
$DUMMY{$name} = $value;
}
@pairs = split(/,/,$DUMMY{$cookiename});
foreach $pair (@pairs) {
($name, $value) = split(/:/, $pair);
$COOKIE{$name} = $value;
}
return($COOKIE{done});
}
sub newnum {
open(FILE,"< $mbdata");
while (){
($fin,@dummy)=split(/,/);
}
close(FILE);
return($fin);
}
sub printmb {
local($from,$to,$infile,$outfile)=@_;
$titleprint=&titleprint("$mbtitle","$mblogo","$logo_style","$logo_color","$logo_size","$logo_face","$logo_sel","$logo_loc");
open(OUTMB,">$outfile");
print OUTMB "\n";
print OUTMB "\n";
print OUTMB "\n";
print OUTMB "\n";
print OUTMB "\n";
print OUTMB "$mbtitle\n";
if ($head_insert_en == 1){
print OUTMB "$head_insert\n";
}
if ($style_sheet_en == 1){
print OUTMB "\n";
}
print OUTMB "\n";
print OUTMB"\n";
print OUTMB "$titleprint\n";
if ($in{choice} eq "unread"){
print OUTMB "未読分
\n";
} elsif ($in{choice} eq "new200") {
print OUTMB "$from - $to(最新200件)
\n";
} elsif ($in{choice} eq "tillnew") {
print OUTMB "$from - $to(最新まで)
\n";
} elsif ($in{choice} eq "fromto") {
print OUTMB "$from - $to
\n";
}
print OUTMB "\n";
print OUTMB " ";
open(INMB,"< $infile");
while(){
chop;
($number,$datecode,$name,$mail,$host,$date,$subject,$main,$encpwd,$imagefile,$user_name_color,$user_title_color,$user_text_color)=split(/,/);
&replace_color($user_name_color,$user_title_color,$user_text_color);
if ($number >= $from && $number <= $to){
print OUTMB "";
# print OUTMB "Message#${number} $date ";
@darray = split(/[^\d]/,$date);
@darray2 = split(/_/,$datecode);
print OUTMB " | Message#${number} ";
$dy = $darray2[0]+1900;
if ($darray2[0] == 97 || ($darray2[0] == 98 && $darray2[1] < 7) || ($darray2[0] == 98 && $darray2[1] == 7 && $darray2[2] < 25)){
$date = "${dy}年" . $date;
} else {
$date =~ s/^\d?\d\d([^\d]..*)$/$dy$1/;
}
print OUTMB "$date ";
print OUTMB "From: ";
if ($mail ne ""){
print OUTMB "${name}"
} else {
print OUTMB "$name";
}
if ($namesan_en == 1){
print OUTMB "$namesan";
}
if ($mail ne "" && $maildisp_en == 1){
print OUTMB " ($mail)"
}
print OUTMB " | ";
print OUTMB " | ";
@sub2=split(/Re:/,$subject);
print OUTMB "";
if ($#sub2 > 1){
print OUTMB "Re$#sub2:$sub2[$#sub2]";
} else {
print OUTMB "$subject";
}
# print OUTMB "$subject";
print OUTMB " | ";
if ($link_samewin_en == 1){
$link_target = '_top';
} else {
$link_target = '_blank';
}
@mainarry=split(/<[bB][rR]>/,$main);
print OUTMB "";
print OUTMB "| ";
print OUTMB " | ";
print OUTMB "";
print OUTMB "";
foreach (@mainarry){
$_ = &replace_link($_,$number);
$_ = &replace_tag($_);
if(/^(\>)(.*)$/){
print OUTMB "$1$2";
} else {
print OUTMB;
}
print OUTMB " ";
}
print OUTMB "";
print OUTMB " | ";
print OUTMB " \n";
}
}
print OUTMB " |
\n";
print OUTMB "\n";
print OUTMB "\n";
close(INMB);
close(OUTMB);
}
}
#############################################################################
# Past mode #################################################################
#############################################################################
sub mbpast {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($time_offset);
if ($compatible == 1){
open(ALL,"< $mbpastdata");
while(){$fin=$_};
close(ALL);
chop($fin);
} else {
open(FILE,"< $mbdata");
while(){
push(@alldata,$_);
if ($#alldata >= 201){
shift(@alldata);
}
};
close(FILE);
$fin = $alldata[0];
shift(@alldata);
}
($endline,$findate,@dummy)=split(/,/,$fin);
($finyy,$finmm,$findd)=split(/_/,$findate);
$how = 1;
$endline2=$endline;
if ($ENV{"REQUEST_METHOD"} eq "GET"){
$ago=$in{number};
$lin = 99;
if ($in{number} ne ""){
$endline = $in{number};
$lin=$in{lin};
# if ($in{title} eq on){$t='title';}
}
$start = $endline - $lin;
if ($in{title} eq on){$t='title';}
if ($in{imlist} eq on){$t='imlist';}
} elsif ($ENV{"REQUEST_METHOD"} eq "POST"){
if ($in{title} eq on){$t = 'title'};
if ($in{imlist} eq on){$t='imlist';}
if ($in{see1} ne ""){
$ago=$in{endline};
$tmpline = $endline;
# if ($ago > $tmpline){$ago=$tmpline;}
$endline=$ago;
$lin = $in{start} - 1;
$start=$ago - $lin;
}
if ($in{see2} ne ""){
$yy=$in{yy};
$mm=$in{mm};
$dd=$in{dd};
$how=$in{how};
$finyy = $yy;
$finmm = $mm;
$findd = $dd;
$in{start}="";
$in{endline}="";
$lin = 99;
$fromtime=timelocal($sec,$min,$hour,$dd,$mm-1,$yy,$wday,$yday,$isdst);
}
}
if ($start < 1){
$start = 1;
}
@pastdata=();
@numlist=();
if ($in{mode} eq 'print'){
@numlist=split(/\,/,$in{message});
@continiouslist = grep(/-/,@numlist);
@numlist = grep(!/-/,@numlist);
foreach (@continiouslist){
($aa,$bb) = split(/-/);
($aa,$bb) = sort {$a <=> $b} ($aa,$bb);
foreach $cc ($aa .. $bb){push(@numlist,$cc);}
}
@numlist = sort {$a <=> $b} @numlist;
}
if ($in{mode} eq 'print' && ($compatible == 0 || $endline2 < $numlist[0])){
$pastfile = "$mbdata";
} elsif ($in{mode} eq 'print' && $compatible == 1){
`$cat $mbarchdata $mbpastdata $mbdata > $alldata`;
chmod(0666,"$alldata");
$pastfile = "$alldata";
} elsif ($endline2 < $ago && $endline2 < $ago - $lin){
$pastfile = "$mbdata";
} elsif ($endline2 >= $ago - $lin && $compatible == 1) {
`$cat $mbarchdata $mbpastdata $mbdata > $alldata`;
chmod(0666,"$alldata");
$pastfile = "$alldata";
} else {
if ($compatible == 1){
($a_dev,$a_ino,$a_mode,$a_nlink,$a_uid,$a_gid,$a_rdev,$a_size,$a_atime,$a_mtime,$a_ctime,$a_blksize,$a_blocks)=stat("$mbpastdata");
($p_dev,$p_ino,$p_mode,$p_nlink,$p_uid,$p_gid,$p_rdev,$p_size,$p_atime,$p_mtime,$p_ctime,$p_blksize,$p_blocks)=stat("$pastall");
if ($a_mtime > $p_mtime){
`$cat $mbarchdata $mbpastdata > $pastall`;
chmod(0666,"$pastall");
}
$pastfile = "$pastall";
} else {
$pastfile = $mbdata;
}
}
open(ALL,"<$pastfile");
while(){
chop;
($number,$dates,@dummy)=split(/,/);
if ($in{mode} eq 'print'){
if (grep(/^$number$/,@numlist)){
push(@pastdata,$_);
}
} else {
if (($in{see1} ne "") || ($ENV{"REQUEST_METHOD"} eq "GET")){
if ($number >= $start && $number <= $endline){
push(@pastdata,$_);
}
} elsif ($in{see2} ne ""){
for($ld=0;$ld<$how;$ld++){
$thattime = $fromtime - $ld*86400;
($sec,$min,$hour,$dd,$mm,$yy,$wday,$yday,$isdst)=gmtime($thattime);
$mm2=$mm+1;
if ("${yy}_${mm2}_${dd}" eq $dates){
push(@pastdata,$_);
}
}
}
}
}
close(ALL);
@pastdata = reverse(@pastdata);
print "Content-Type: text/html\n\n";
print "";
print <
$mbtitle
HEADPRINT
if ($head_insert_en == 1){
print "$head_insert\n";
}
if ($style_sheet_en == 1){
print "\n";
}
print "\n";
print "";
#print "
";
print "$body_insert1" if ($body_insert1_en == 1);
print "";
&getmbdata;
&disphead(1);
print "\n";
if ($start != 1 && $in{mode} ne 'print'){
$start2=$start-1;
if ($endline2 >= $ago){
if ($t eq 'title') {
print "更に前100件 ";
} else {
print "更に前100件 ";
}
}
}
print " ";
if (($t eq 'title' or $t eq 'imlist') && $lin != 0) {print "\n";};
foreach $count (0 .. $#pastdata){
($number,$datecode,$name,$mail,$host,$date,$subject,$main,$encpwd,$imagefile,$user_name_color,$user_title_color,$user_text_color)=split(/,/,$pastdata[$count]);
&replace_color($user_name_color,$user_title_color,$user_text_color);
if ($t eq 'imlist' && $lin != 0) {
chomp($imagefile);
next if ($imagefile eq '' or ! -e "$imagedir/$imagefile");
print "- #${number}、";
@sub2=split(/Re:/,$subject);
if ($#sub2 > 1){
print "Re$#sub2:$sub2[$#sub2]";
} else {
print "$subject";
}
@darray = split(/[^\d]/,$date);
@darray2 = split(/_/,$datecode);
$dy = $darray2[0]+1900;
if ($darray2[0] == 97 || ($darray2[0] == 98 && $darray2[1] < 7) || ($darray2[0] == 98 && $darray2[1] == 7 && $darray2[2] < 25)){
$date = "${dy}年" . $date;
} else {
$date =~ s/^\d?\d\d([^\d]..*)$/$dy$1/;
}
print " ........ $date
\n";
($imagefile,$w,$h)=&get_image_size($imagefile,$ssiimage_w,$ssiimage_h);
print "";
print &image_tag($imagefile,$w,$h);
print "";
print " \n";
} elsif ($t eq 'title' && $lin != 0) {
print "- #${number}、";
@sub2=split(/Re:/,$subject);
if ($#sub2 > 1){
print "Re$#sub2:$sub2[$#sub2]";
} else {
print "$subject";
}
@darray = split(/[^\d]/,$date);
@darray2 = split(/_/,$datecode);
$dy = $darray2[0]+1900;
if ($darray2[0] == 97 || ($darray2[0] == 98 && $darray2[1] < 7) || ($darray2[0] == 98 && $darray2[1] == 7 && $darray2[2] < 25)){
$date = "${dy}年" . $date;
} else {
$date =~ s/^\d?\d\d([^\d]..*)$/$dy$1/;
}
print " ........ $date
\n";
} else {
print "";
# print "Message#${number} $date ";
@darray = split(/[^\d]/,$date);
@darray2 = split(/_/,$datecode);
print " | Message#${number} ";
$dy = $darray2[0]+1900;
if ($darray2[0] == 97 || ($darray2[0] == 98 && $darray2[1] < 7) || ($darray2[0] == 98 && $darray2[1] == 7 && $darray2[2] < 25)){
$date = "${dy}年" . $date;
} else {
$date =~ s/^\d?\d\d([^\d]..*)$/$dy$1/;
}
print "$date ";
print "From: ";
if ($mail ne ""){
print "${name}"
} else {
print "$name";
}
if ($namesan_en == 1){
print "$namesan";
}
if ($mail ne "" && $maildisp_en == 1){
print " ($mail)"
}
print " | ";
print " | ";
@sub2=split(/Re:/,$subject);
print "| ";
if ($#sub2 > 1){
print "Re$#sub2:$sub2[$#sub2]";
} else {
print "$subject";
}
print " | ";
print "";
if ($link_samewin_en == 1){
$link_target = '_top';
} else {
$link_target = '_blank';
}
$main =~ s/\(#(\d+)\)/\(#$1<\/a>\)/g;
$main =~ s/(message)#(\d+)/$1#$2<\/a>/gi;
@mainarry=split(/<[bB][rR]>/,$main);
print "";
print "| ";
$imagefile =~ s/[\r\n]*$//;
if ($image_en == 1 && $imagefile ne '' && -e "$imagedir/$imagefile"){
($imagefile,$width,$height)=&get_image_size($imagefile,$max_w,$max_h);
if ($image_samewin_en == 1){
$newwin = '';
} else {
$newwin = 'target="_blank"';
}
print "";
print &image_tag($imagefile,$width,$height);
print "";
}
print " | ";
print "";
print "";
foreach (@mainarry){
$_ = &replace_link($_,$number);
$_ = &replace_tag($_);
if(/^(\>)(.*)$/){
print "$1$2";
} else {
print;
}
print " ";
}
print "";
print " | ";
print " \n";
}
}
if (($t eq 'title' or $t eq 'imlist') && $lin != 0) {print " \n";};
if ($start != 1 && $in{mode} ne 'print'){
$start2=$start-1;
if ($endline2 >= $ago){
if ($t eq 'title') {
print "更に前100件 ";
} else {
print "更に前100件 ";
}
}
}
print " \n";
&disptail;
©right;
print "";
print " |