#!/usr/local/bin/perl ##----製作者----############################################ # # Football League Table Type R Version 1.00 # # This is Freeware. # Script written by Masayoshi # Created on: 2003.03.05 # Update: 2003.03.05 # Copyright (C) 2002-2003 Masayoshi. All Rights Reserved. # I can be reached at: masayosi@mahoroba.ne.jp # Scripts Found at: http://www3.mahoroba.ne.jp/~masayosi/jfl/top.shtml # ############################################################ require 'cgi-lib.pl'; &ReadParse(in); ##----設定----## # タイトル $title = "Football League Table Type R"; # タイトルフォント $tfont = "Times New Roman"; # 記録ファイル $tdat = "table.dat"; $rdat = "result.dat"; $rd = "rd.dat"; # Home Page URL $home = "../jfl/index.html"; # 色設定 $bgcolor = "#FFCC00"; $text = "#000000"; $tabgc = "#FFA042"; $link = "#CC6600"; $vlink = "#990000"; $alink = "#FF3300"; $hlink = "#FF0000"; ## パスワード # 入力キー $addpas = "1234"; ##----設定終了----## $in{'pas'} =~ s//>/g; $in{'setu'} =~ s//>/g; $in{'date'} =~ s//>/g; $in{'stad'} =~ s//>/g; $in{'hscore'} =~ s//>/g; $in{'ascore'} =~ s//>/g; $hteam = "$in{'hteam'}"; $ateam = "$in{'ateam'}"; $hscore = "$in{'hscore'}"; $ascore = "$in{'ascore'}"; print "Content-type: text/html\n\n"; print <<"EOM"; $title EOM ##----分岐----## if($in{'pas'} eq ""){ &table; } elsif($in{'pas'} eq "$addpas"){ &addinput; } elsif($in{'pas'} eq "addcheck"){ &addcheck; } elsif($in{'pas'} eq "wdladd"){ &wdladd; } else{ print <<"EOM";

パスワードが一致しません

戻る

EOM exit; } ##----表示----## sub table{ print <<"EOM";

$title

EOM ## 順位表 print <<"EOM"; EOM open (FILE, "$tdat"); @allbody = ; close(FILE); foreach $line (@allbody){ chomp $line; ($no, $team, $pd, $win, $draw, $lost, $gf, $ga, $gd, $pts) = split(/:/,$line); print <<"EOM"; EOM } print <<"EOM";
Team PD W D L GF GA GD Pts.
$team $pd $win $draw $lost $gf $ga $gd $pts

EOM ##----試合結果表示----## if($in{'method'} == ""){ open (FILE, "$rd"); $n = ; close(FILE); $n2 = $n; } else{ open (FILE, "rd.dat"); $n = ; close(FILE); $n2 = $in{'method'}; } print <<"EOM";
EOM open (FILE, "$rdat"); @allbody = ; close(FILE); foreach $line (@allbody){ chomp $line; ($no, $da, $st, $hno, $ht, $hs, $as, $ano, $at) = split(/:/,$line); if($no == "$n2"){ print <<"EOM"; EOM } } print <<"EOM";
第 $n2 節 Stadium Home Score Away
$da $st $ht $hs - $as $at

F.L.T.R Ver. 1.00

EOM exit; } ##----入力欄----## sub addinput{ print <<"EOM";

[結果入力]

年月日 開催節 開催地
Home Score Away
-

EOM exit; } ##----入力確認----## sub addcheck{ print "

[最終確認]

\n"; ($hno, $hteam) = split(/:/,$in{'hteam'}); ($ano, $ateam) = split(/:/,$in{'ateam'}); if($in{'date'} eq ""){ $flag = "1"; print "

開催年月日が未入力です

\n"; } if($in{'stad'} eq ""){ $flag = "1"; print "

開催地が未入力です

\n"; } if($in{'setu'} =~ /[^0-9]/){ $flag = "1"; print "

開催節数を半角英数字で入力してください

\n"; } elsif($in{'setu'} eq ""){ $flag = "1"; print "

開催節数が未入力です

\n"; } if($hno eq $ano){ $flag = "1"; print "

重複しています

\n"; } if($hscore =~ /[^0-9]/){ $flag = "1"; print "

スコアを半角英数字で入力してください

\n"; } elsif($hscore eq ""){ $flag = "1"; print "

スコアが未入力です

\n"; } if($ascore =~ /[^0-9]/){ $flag = "1"; print "

スコアを半角英数字で入力してください

\n"; } elsif($ascore eq ""){ $flag = "1"; print "

スコアが未入力です

\n"; } if($flag == "1"){ print <<"EOM";

修正して下さい

戻る

EOM exit; } print <<"EOM";
年月日 開催節 開催地
$in{'date'} 第 $in{'setu'} 節 $in{'stad'}
Home Score Away
$hteam $hscore - $ascore $ateam

EOM exit; } ##----勝敗処理/入力----## sub wdladd{ open (FILE, "$tdat"); @allbody = ; close(FILE); foreach $line (@allbody){ chomp $line; ($no, $team, $pd, $win, $draw, $lost, $gf, $ga, $gd, $pts) = split(/:/,$line); if($no =~ /^$in{'hno'}$/){ if($hscore > $ascore){ $win += 1; $pts += 3; } elsif($hscore < $ascore){ $lost += 1; } else{ $draw += 1; $pts += 1; } $pd += 1; $gf += $hscore; $ga += $ascore; $gd = ($gf - $ga); $line = "$no:$team:$pd:$win:$draw:$lost:$gf:$ga:$gd:$pts"; } if($no =~ /^$in{'ano'}$/){ if($ascore > $hscore){ $win += 1; $pts += 3; } elsif($ascore < $hscore){ $lost += 1; } else{ $draw += 1; $pts += 1; } $pd += 1; $gf += $ascore; $ga += $hscore; $gd = ($gf - $ga); $line = "$no:$team:$pd:$win:$draw:$lost:$gf:$ga:$gd:$pts"; } $line = "$line\n"; } @allbody = map {$_->[0]} sort {$b->[10] <=> $a->[10] or $b->[9] <=> $a->[9] or $b->[7] <=> $a->[7] or $b->[8] <=> $a->[8]} map {[$_, split /:/]} @allbody; open (FILE, ">$tdat"); print FILE @allbody; close (FILE); @line = ("$in{'setu'}", "$in{'date'}", "$in{'stad'}", "$in{'hno'}", "$in{'hteam'}", "$in{'hscore'}", "$in{'ascore'}", "$in{'ano'}", "$in{'ateam'}"); $result = join(":", @line); open (FILE, ">>$rdat"); print FILE "$result\n"; close(FILE); open (FILE, ">$rd"); print FILE "$in{'setu'}"; close (FILE); print <<"EOM";

入力完了

戻る

EOM exit; }