#!/usr/local/bin/perl5 $datafile="./omikuji.dat"; ( $sec, $min, $hour, $day, $mon, $year ) = localtime(time); $mon++; $num1=$day*$mon; &get_host; $_=$addr; if (/(\d+)\.(\d+)\.(\d+)\.(\d+)/){ $first=$1; $second =$2; $third=$3; $forth=$4%10; } $num=($num1*$forth+$first+$second+$third)%101; $num2=($num1*$forth+$first+$second+$third)%101; open IN, "<$datafile"; while(){ chop; if( $m == $num){ @box=split(/#/,$_); ( $kiti , $coment ) = @box[0,1]; } $m++; } close IN; $text = <<"end_msg"; URANAI
今日の運勢

$kiti

$coment


運勢は人それぞれ違います。
これはランダムではありません。
同じ日なら何度やっても同じ運勢が出ます
end_msg print "Content-type: text/html\n"; print "\n"; @bb=split(/./,$addr); ( $num2 , $num3 ,$num4 ,$num5) = @bb[0,1,2,3]; print $text; ## ホスト名を取得 sub get_host { $host = $ENV{'REMOTE_HOST'}; $addr = $ENV{'REMOTE_ADDR'}; if ($host eq "" || $host eq "$addr") { ($p1,$p2,$p3,$p4) = split(/\./,$addr); $temp = pack("C4",$p1,$p2,$p3,$p4); $host = gethostbyaddr("$temp", 2); if ($host eq "") { $host = $addr; } } }