#!/usr/local/bin/perl ##----製作者----############################################ # # Football League Table Type P Version 1.00 # # This is Freeware. # Script written by Masayoshi # Created on: 2003.03.04 # Update: 2003.03.04 # Copyright (C) 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); ##----設定(1)----## # タイトル $title = "Football League Table Type P"; # タイトルフォント $tfont = "Times New Roman"; # グループ名 $gname_a = "Group A"; $gname_b = "Group B"; $gname_c = "Group C"; $gname_d = "Group D"; # グループ数 $n = "4"; # 記録ファイル $table_a = "table_a.dat"; $table_b = "table_b.dat"; $table_c = "table_c.dat"; $table_d = "table_d.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{'hscore'} =~ 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"){ &select; } elsif($in{'pas'} eq "addinput"){ &addinput; } elsif($in{'pas'} eq "addcheck"){ &addcheck; } elsif($in{'pas'} eq "wdladd"){ &wdladd; } else{ print "

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

\n"; print "

戻る

\n"; print "\n"; print "\n"; exit; } ##----表示----## sub table{ print "

$title

\n"; ##----設定(2)----## for($i = 1; $i <= $n; $i++){ if($i == "1"){ $a = "$gname_a"; $tdat = "$table_a"; } elsif($i == "2"){ $a = "$gname_b"; $tdat = "$table_b"; } elsif($i == "3"){ $a = "$gname_c"; $tdat = "$table_c"; } elsif($i == "4"){ $a = "$gname_d"; $tdat = "$table_d"; } ##----設定終了----## print <<"EOM";

$a

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 "
Team PD W D L GF GA GD Pts.
$team $pd $win $draw $lost $gf $ga $gd $pts
\n\n"; } print <<"EOM";

F.L.T.P Ver. 1.00

EOM exit; } ##----選択----## sub select{ print <<"EOM";

[選択]

戻る

EOM exit; } ##----入力欄----## sub addinput{ ##----設定(4)----## if($in{'group'} eq "group_a"){ $tdat = "$table_a"; $gname = "$gname_a"; } elsif($in{'group'} eq "group_b"){ $tdat = "$table_b.dat"; $gname = "$gname_b"; } elsif($in{'group'} eq "group_c"){ $tdat = "$table_c"; $gname = "$gname_c"; } elsif($in{'group'} eq "group_d"){ $tdat = "$table_d"; $gname = "$gname_d"; } ##----設定終了----## print <<"EOM";

[結果入力]

$gname

Home Score Away
-

EOM exit; } ##----入力確認----## sub addcheck{ ##----設定(5)----## if($in{'group'} eq "group_a"){ $gname = "$gname_a"; } elsif($in{'group'} eq "group_b"){ $gname = "$gname_b"; } elsif($in{'group'} eq "group_c"){ $gname = "$gname_c"; } elsif($in{'group'} eq "group_d"){ $gname = "$gname_d"; } ##----設定終了----## print <<"EOM";

[入力確認]

$gname

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

重複しています

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

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

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

スコアが未入力です

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

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

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

スコアが未入力です

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

修正して下さい

戻る

EOM exit; } print <<"EOM";
Home Score Away
$hteam $in{'hscore'} - $in{'ascore'} $ateam

EOM exit; } ##----勝敗処理/入力----## sub wdladd{ ##----設定(6)----## if($in{'group'} eq "group_a"){ $tdat = "$table_a"; } elsif($in{'group'} eq "group_b"){ $tdat = "$table_b"; } elsif($in{'group'} eq "group_c"){ $tdat = "$table_c"; } elsif($in{'group'} eq "group_d"){ $tdat = "$table_d"; } ##----設定終了----## 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); print <<"EOM";

[入力完了]

戻る

EOM exit; }