#!/usr/local/bin/perl ##----製作者----############################################ # # Football League Table Version 1.11 # # This is Freeware. # Script written by Masayoshi # Created on: 2002.04.28 # 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"; # タイトルフォント $tfont = "Times New Roman"; # 記録ファイル $tdat = "table.dat"; $tname = "tname.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"){ &addinput; } elsif($in{'pas'} eq "addcheck"){ &addcheck; } elsif($in{'pas'} eq "wdladd"){ &wdladd; } else{ print <<"EOM";

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

戻る

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

$title

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

Football League Table Ver. 1.11

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($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"; } if($flag == "1"){ print <<"EOM";

修正して下さい

戻る

EOM exit; } print <<"EOM";
Home Score Away
$hteam $in{'hscore'} - $in{'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); print <<"EOM";

入力完了

戻る

EOM exit; }