⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 5cht.cgi

📁 自己原创的五子棋沙龙游戏
💻 CGI
📖 第 1 页 / 共 2 页
字号:
if (($cHost[0] eq "") || ($dHost[0] eq "")){
 if (($cHost[0] ne $cgi{'name'}) && ($dHost[0] ne $cgi{'name'})){
if ($cHost[0] ne $cgi{'room'}){$joiner[0]="$cgi{'name'}&&$cHost[1]"} else {$joiner[1]="$cgi{'name'}&&$cHost[1]"}
open(file,">$user_file")||die"不能打开文件\n";
foreach $line(@joiner){print file"$line";}
close file;
foreach $line(@lists){@each_er=split(/&&/,$line);
if ($each_er[0] eq $cgi{'room'}){$each_er[1]=$cgi{'name'};$each_er[2]="ing";$each_er[3]="$mon&&$day&&$hour&&$min"};
push (@re_each_er,"$each_er[0]&&$each_er[1]&&$each_er[2]&&$each_er[3]&&\n");
}
open(file,">$user_list_file")||die"不能打开文件\n";
foreach $line(@re_each_er){print file"$line";}
close file;
}}
&print_frame;
}
##目的:返回$entries[1](最复杂的逻辑运算)
sub ru_{
$tt="zABCDEFGHIJKLMNO";$three=0;$four=0;$five=0;
 foreach $st ('A'..'O'){ foreach $i (1..15){$uu=$st.$i;$ps{$uu}="e";}}
$old_tmp=$old_player;
chop($old_tmp);
@pois_tmp=split(/&&/,$old_tmp);
@po_tmp=split(/;/,$pois_tmp[1]);
foreach $line(@po_tmp){@po_ru_tmp=split(/!/,$line);$ps{$po_ru_tmp[0]}="others";}

@pois=split(/&&/,$entries[1]);
@po=split(/;/,$pois[1]);
foreach $line(@po){@po_ru=split(/!/,$line);$ps{$po_ru[0]}=$po_ru[0];push (@pr,"$po_ru[0]");}
%turn=(1,"1,0,-1,0",2,"0,1,0,-1",3,"1,1,-1,-1",4,"1,-1,-1,1");
     ####对于每一个点
foreach $line(@pr){
     ###检测在周边4条线上有没有连接的点
 foreach $i (1..4){
$thl=$line.$i;
next if ($mmm{$thl} eq "checked");
@fd=();@fdfour=();@find=();
$mar[$i]=1;
@l=split(/,/,$turn{$i});
$nx=substr($line,0,1);$county=substr($line,1);
$countx=index($tt,$nx);
$xx=substr($tt,$countx,1);
$yy=$county;
$count="$xx$yy";
$fin="";$iis=0;$ppp=0;

while($fin ne "out"){$ppp++;
$countx+=$l[0];
$yy+=$l[1];
$xx=substr($tt,$countx,1);
$count="$xx$yy";$tl=$count.$i;
if (($ps{$count} eq "others") || ($ps{$count} eq "")){$fin="out";$find[0]=($find[0] eq "empty")?"empty":"";}
 else {if ($ps{$count} eq "e"){$find[0]="empty";$fin=($iis>0)?"out":"";$iis++;}
 else {$mar[$i]++;$mmm{$tl}="checked";$find[0]="";$iis=0;}}
}
$nx=substr($line,0,1);$county=substr($line,1);
$countx=index($tt,$nx);
$xx=substr($tt,$countx,1);
$yy=$county;
$count="$xx$yy";
$fin="";$iiq=0;

while($fin ne "out"){$ppp++;
$countx+=$l[2];
$yy+=$l[3];
$xx=substr($tt,$countx,1);
$count="$xx$yy";$tl=$count.$i;
if (($ps{$count} eq "others") || ($ps{$count} eq "") ){$fin="out";$find[1]=($find[1] eq "empty")?"empty":"";}
 else {if ($ps{$count} eq "e"){$find[1]="empty";$fin=($iiq>0)?"out":"";$iiq++;}
 else {$mar[$i]++;$mmm{$tl}="checked";$find[1]="";$iiq=0;}}
}
$ppp++ if ($find[0] ne "empty");$ppp++ if ($find[1] ne "empty");
$fd[$i]="empty" if (($find[0] eq "empty") && ($find[1] eq "empty"));
$fdfour[$i]="empty" if (($find[0] eq "empty") || ($find[1] eq "empty"));
$ppp-=$mar[$i]+3;
$three++ if (($mar[$i] == 3) && ($ppp < 2) && ($fd[$i] eq "empty"));
$four++ if (($mar[$i] == 4) && ($fdfour[$i] eq "empty"));
$four++ if (($mar[$i] == 4) && ($fdfour[$i] ne "empty") && ($ppp == 1));
$four++ if (($mar[$i] == 4) && ($fd[$i] ne "empty") && ($ppp == 1));
$five++ if (($mar[$i] == 5) && ($ppp == 0));
                   }
}
$ru="";
$ru="三三" if ($three >= 2);
$ru="四" if ($four >= 1);
$ru="三四" if (($three >= 1) && ($four >= 1));
$ru="胜利" if ($five >= 1);
$entries[1]="$entries[1]!$ru;\n";
}
sub put{
if ($timer < 1){&play;exit;};
@check_v=split(/:/,$entries[2]);
if ($check_v[1] eq "胜利"){&play;exit;};
@new_player=split(/&&/,$entries[0]);
@p_one=@new_player;@p_two=split(/&&/,$entries[1]);
chop($p_one[1]);chop($p_two[1]);
$u_data=$p_one[1].$p_two[1];
@player_dat=split(/;/,$u_data);
foreach $line(@player_dat){@line_po=split(/!/,$line);if ($line_po[0] eq $cgi{'puthere'}){$mark="find"}}
if (($cgi{'name'} eq $new_player[0]) && ($mark ne "find")){
$old_player=$entries[1];
chop($entries[0]);
$entries[1]="$entries[0]$cgi{'puthere'}";
&ru_;
$entries[0]=$old_player;$entries[2]="$cgi{'name'}:$ru:\n";
open(file,">$user_file")||die"不能打开文件\n";
foreach $line(@entries){print file"$line";}
close file;
}
&play;
}

sub joinhis{
print <<eof;
<html><head><title>$title</title></head>
<FRAMESET COLS="310,*">
  <FRAME SRC="$thisfile?mu=wmaps&name=$cgi{'name'}&room=$cgi{'room'}&hismu=hisplay&hisroom=$cgi{'hisroom'}" NAME="map_frm" FRAMEBORDER="0" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="no">
  <FRAME SRC="$thisfile?mu=hisplay&name=$cgi{'name'}&room=$cgi{'room'}&hisroom=$cgi{'hisroom'}" NAME="5msg_frm" FRAMEBORDER="0" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="auto">
</FRAMESET>
</html>
eof
exit;}
sub hisplay{
$hisf="$his_path/$cgi{'hisroom'}.log";
if (-e "$hisf"){
open(file,"$hisf")||die"不能打开文件\n";
@entries=<file>;
close file;
$timer= (-M "$hisf")*60*24;
$timer=15-int($timer);
}else{$timer=0;}
$playmode="hisplay";
@hisdate=split(/$cgi{'room'}/,$cgi{'hisroom'});
@daters=split(/-/,$hisdate[1]);
$timer="($daters[0].$daters[1]) $daters[2]时$daters[3]";
&play;}
sub play{
if ($playmode ne "hisplay"){$playmode = "play";$le_mark="<";$hisroom="";$time_over_msg="由于对手已经退出或已经超时,本局比赛结束."}else {$hisroom="$cgi{'hisroom'}";$timeover="ture";$time_over_msg="历史纪录察看模式";$le_mark="于";}
$timeover="ture" if ($timer < 1);
@player_one=split(/&&/,$entries[0]);
@player_one_dat=split(/;/,$player_one[1]);
pop(@player_one_dat);
@player_two=split(/&&/,$entries[1]);
@player_two_dat=split(/;/,$player_two[1]);
pop(@player_two_dat);
@vvv=split(/:/,$entries[2]);

if ($cgi{'room'} eq $player_one[0]){
@guest_dat=@player_two_dat;
@host_dat=@player_one_dat;
$guest_name=@player_two[0];
}else{
@guest_dat=@player_one_dat;
@host_dat=@player_two_dat;
$guest_name=@player_one[0];
}

$i=0;
foreach $line(@host_dat){
($pl,$result)=split(/!/,$line);
push (@points,"$cgi{'room'}:$pl:$result");
($pl,$result)=split(/!/,$guest_dat[$i]);
push (@points,"$guest_name:$pl:$result");
$i++;
}
if ($cgi{'room'} eq $player_two[0]){
 pop(@points);
 if($guest_name eq ""){$msg="等待挑战者."}else{$msg="该$guest_name了."}}
else{$msg="该$cgi{'room'}了.";}
if ($vvv[1] eq "胜利"){$vhead="";$msg="<font color='red'>$vvv[0]胜利!</font>";}
 else{
 if ($timeover eq "ture"){$vhead="";$msg="<font color='red'>$time_over_msg</font>";}else{
$vhead="<META HTTP-EQUIV='Refresh' Content='5; URL=$thisfile?mu=$playmode&name=$cgi{'name'}&room=$cgi{'room'}&hisroom=$hisroom'>";
}}
@points=reverse(@points);
print <<eof;
<html><head>
$vhead
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<script language='JavaScript'>
Ix = eval("parent.map_frm.document");
eof
foreach $line(@points){
@sl=split(/:/,$line);
$img=($sl[0] eq $cgi{'room'})?"$img_path/xx.gif":"$img_path/yy.gif";
print <<eof;
Ix.images["$sl[1]"].src="$img";
eof
}
$new_point=shift(@points);@sl=split(/:/,$new_point);
$tc=($sl[0] eq $cgi{'room'})?"$img_path/xx.gif":"$img_path/yy.gif";
print <<eof;
Ix.maps.tc.value="$tc";
Ix.maps.nn.value="$sl[1]";
</script></head><body bgcolor='#eee8aa'>
<table border=0  bgcolor='#FFFFFF'cellspacing=0 cellpadding=0 width="100%">
<tr><td colspan=2>●= $cgi{'room'}</td></tr>
<tr><td colspan=2>○= $guest_name</td></tr>
<TR><TD><form action="$thisfile" method="POST">
<input type=hidden name=mu value=$playmode>
<input type=hidden name=name value=$cgi{'name'}>
<input type=hidden name=room value=$cgi{'room'}>
<input type=hidden name=hisroom value=$hisroom>
<input type=submit value=刷新></form></TD>
<TD><form action="$thisfile" target="_top" method="POST">
<input type=hidden name=mu value=hall>
<input type=hidden name=name value=$cgi{'name'}>
<input type=submit value=退出></form></TD>
</TR></TABLE>
<table border=0 bgcolor='#eee8aa' cellspacing=0 cellpadding=0 width="100%">
<tr bgcolor='#1e90ff'><td colspan=3 align=left>$msg</td></tr>
<tr bgcolor='#b0c4de'><td colspan=3 align=right>$le_mark $timer分</td></tr>
<tr><td align=right><font color="red">$sl[0]:</font></td><td align=left><font color="red">$sl[1]</font></td><td>$sl[2]</td></tr>
eof
foreach $line(@points){@sl=split(/:/,$line);print "<tr><td align=right>$sl[0]:</td><td align=left>$sl[1]</td><td>$sl[2]</td></tr>\n";}
print "</table></body></html>";
exit;}

sub time_over {
print <<eof;
<html><head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
</head><body>
<table border="0" width="100%"><tr bgcolor="#b0c4de"><th>错误!</th></tr><tr><td>对手已经退出或已经超时,请退出,重新再来.</td></tr>
<TR><TD><form action="$thisfile" target="_top" method="POST">
<input type=hidden name=mu value=hall>
<input type=hidden name=name value=$cgi{'name'}>
<input type=submit value=退出></form></TD></TR></table>
</body></html>
eof
exit;}

sub readparse {
read(STDIN,$user_string,$ENV{'CONTENT_LENGTH'});
if (length($ENV{'QUERY_STRING'})>0) {$user_string=$ENV{'QUERY_STRING'}};
$user_string =~ s/\+/ /g;
@name_value_pairs = split(/&/,$user_string);
foreach $name_value_pair (@name_value_pairs) {
        ($keyword,$value) = split(/=/,$name_value_pair);
#print "$keyword=$value<br>";
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/ge;
        push(@value, "$value");
	  $cgi{$keyword} = $value;
	  if ($value=~/<!--\#exec/) {
		print "Content-type: text/html\n\nNo SSI permitted";
		exit;
	  }

}
}
exit;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -