Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
#!/usr/mesh/bin/perl5
# 降順に出力するスコア管理スクリプトの例
# 渡されるデータ
# Score=得点
# Name =名前
# 自ら取得するデータ
# 時刻
# 得点を調べて適切な位置に出力
# 得点の高いもの順
# 同得点なら日付(年月日)の古い順
# 同得点同日なら名前順
# 入力スコアファイル test.dat
# 出力スコアファイル test.tmp
if($ENV{'REQUEST_METHOD'} eq "POST")
{
read(STDIN,$str,$ENV{'CONTENT_LENGTH'});
}
else
{
$str=$ENV{'QUERY_STRING'};
}
@part=split('&',$str);
foreach $i (@part)
{
($variable,$value)=split('=',$i);
$cgi{$variable}=$value;
}
($sec,$min,$hour,$mday,$mon,$year,$wday,$ydat,$isdat)=localtime();
$mon++;
if($year>=70)
{
$date=sprintf("19%.2d %.2d %.2d",$year,$mon,$mday);
$str=sprintf("%.10d: 19%d %.2d %.2d : %s\n",$cgi{'Score'},$year,$mon,$mday,$cgi{'Name'});
}
else
{
$date=sprintf("20%.2d %.2d %.2d",$year,$mon,$mday);
$str=sprintf("%.10d: 20%.2d %.2d %.2d : %s\n",$cgi{'Score'},$year,$mon,$mday,$cgi{'Name'});
}
@list=(); # データ格納用リストの初期化
$i=0; # リストアクセスのための添え字用
open(IN,"test.dat"); # データファイルオープン
while() # 読み込み
{
@list[$i]=$_; #リストへの格納
$i++;
}
print @list[0];
print @list[$i-1];
$c=0;
open(OUT,">test.tmp");
do
{
$tmp=substr(@list[$c],0,10);
if($tmp<$cgi{'Score'})
{
print OUT $str;
print OUT @list[$c];
goto rest;
}
elsif($tmp==$cgi{'Score'})
{
$scoredate=substr(@list[$c],13,10);
if($scoredate gt $date)
{
print OUT $str;
print OUT @list[$c];
goto rest;
}
elsif($scoredate eq $date)
{
$scorename=substr(@list[$c],25);
chop($scorename);
if($scorename gt $cgi{'Name'})
{
print OUT @list[$c];
print OUT $str;
goto rest;
}
}
}
print OUT @list[$c];
}while(++$c<$i);
rest:
while(++$c<$i)
{
print OUT @list[$c];
}