Files
ore/park.cgi

304 lines
8.8 KiB
Perl
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/perl
# サーバーの環境に合わせて変更して下さい。
#-----------------------------------------------------------#
# 罪と罰++ 二律背反 #
# Copyright(C) 2001-2002 by Vivid Studio. BLANK BOARD #
# Vivid Studio.[ http://www17.big.or.jp/~obochan/vivid/ ] #
# BLANK BOARD [ http://pom.to/ ] #
#-----------------------------------------------------------#
$ver = '교류광장 v1.1'; # 버전 정보(변경 불가)
#--- [注意事項] --------------------------------------------#
# 1.このスクリプトは以下の利用規程に従って配布しています。 #
# http://www24.big.or.jp/~obo/game/ore_/gild/ #
#-----------------------------------------------------------#
#===============================================================================
# 設定項目
#-------------------------------------------------------------------------------
# 各種ファイル
require './inc/ore_sub-bbs.cgi'; # 各種掲示板共通な設定項目読み込み
$script = "./park.cgi"; # 이 스크립트의 경로
$logfile = "./logdata/park_log.cgi"; # 로그 파일
$memfile = "./logdata/park_mem.cgi"; # 참가자 파일
$lockkey = 0; # 파일 잠금(0=no 1=yes)
$lockfile = "./camp.lock"; # 잠금 파일명
#-------------------------------------------------------------------------------
# 環境設定
$title = "국제교류광장"; # 타이틀명
$max = 100; # 최대 보유 게시글 수
$reload_mn = 5; # 최단 리로드 간격(이 초 수 이내에 발언 시 에러[부하 대책])
$reload_limit= 120; # 이 시간(초) 동안 발언이 없으면 퇴실 처리
$com_limit = 240; # 코멘트 최대 글자수(반각 환산)
$tagkey = 0; # 태그 허용 (0=no 1=yes)
$nolink = 1; # URL 광고 배제 (0=no 1=yes)
# 機種別設定
if($mv_mode eq 'mv'){
# 모바일용 설정
$log_last= 15; # 표시 행 수(모바일)
# BODY 태그 디자인
$body = 'bgcolor="black" text="white" link="pink" vlink="pink" alink="pink"';
$hr_color= 'white'; # 구분선 색상(모바일)
}else{
# PC용 설정
@reload_time= (90,120,180); # 리로드 시간
$log_last= 50; # 표시 행 수(PC)
# BODY 태그 디자인
$body = 'bgcolor="#111122" text="#ddddee" link="#ffddee" vlink="#ffddee" alink="#ffddee"';
}
#===============================================================================
# 以下処理 基本的にこれ以下はいいじらないように。
#-------------------------------------------------------------------------------
# メイン処理
&axs_check; # アクセス制御
&decode; # フォームデコード
&mandata_open; # 参加者ログ読み込み
&get_time; # 日時取得
&member;
if($mode eq "regist" && $com){ &regist; } # 書き込み処理
&html; # ページ表示
#-------------------------------------------------------------------------------
# 記事表示部
sub html {
# 表示開始
&header;
if($mv_mode eq 'mv'){
print <<"EOM";
$camp_info[$DAT{'camp'}][0] 전용<br>$title
<form name="park" method="$method" action="$script">
<input type=hidden name=mode value="regist">
<input type=hidden name=id value="$id">
<input type=hidden name=pw value="$pw">
<input type=text name=comment size=8>
<input type=submit value="말하기"><input type=reset value="지우기">
</form>
<form name="ore_" method="$method" action="$ore_game">
<input type=hidden name=id value="$id">
<input type=hidden name=pw value="$pw">
<input type=hidden name=cmd value="-1">
<input type=submit value="돌아가기">
</form>
EOM
}
else{
print <<"EOM";
<table>
<tr>
<td width="220"><img src="./imgs/title_game.png" width="220" height="52"></td>
<td valign="bottom" align="left">
<b>$title</b><br>
<small>~ 참가자들의 쉼터 ~</small>
</td>
</tr>
<tr>
<form name="park" method="$method" action="$script">
<td colspan="2" nowrap>
<input type="hidden" name="mode" value="regist">
<input type="hidden" name="id" value="$id">
<input type="hidden" name="pw" value="$pw">
<input type="hidden" name="rd" value="$rd">
<input type="text" name="comment" class="button1" style="width:300px">
<input type="submit" value="말하기/새로고침" class="button1" style="width:80px">
<input type="reset" value="지우기" class="button1" style="width:60px">
</td>
</form>
</tr>
<tr>
<form method="$method" action="$script">
<input type="hidden" name="mode" value="regist">
<input type="hidden" name="id" value="$id">
<input type="hidden" name="pw" value="$pw">
<td align="left">
<tt>새로고침:<select name="rd" size="1" class="button1" style="width:60px">
EOM
print qq|<option value="$rd">$reload_time[$rd]초</option>|;
foreach(0 .. $#reload_time){
print qq|<option value="$_">$reload_time[$_]초</option>| if($rd!=$_);
}
print <<EOM;
</select> <input type="submit" value="변경" class="button1" style="width:60px">
</td>
</form>
<form name="ore_" method="$method" action="$ore_game">
<td align="right">
<input type=hidden name=id value="$id">
<input type=hidden name=pw value="$pw">
<input type=hidden name=cmd value="-1">
<input type=submit value="돌아가기" class="button1" style="width:80px">
</td>
</form>
</tr>
</table>
EOM
}
# 参加者表示:$member
($mv_mode eq 'mv') ?
print qq|참가자($num)<hr color=\"$hr_color\">\n|:
print qq|<hr size="8" color="#666699"><span class=\"mem\"><br>참가자($num)$member</span><hr color="#c0c0c0" size="4">\n|;
# ログを展開
open(IN,"$logfile") || &error("Open Error : $logfile");
local $log_last_flag=0;
while (<IN>) {
$log_last_flag++;
local($date,$nm,$camp,$com,$sogo,$addr,$host) = split(/<>/);
$nm = qq|$nm <small>[$sogo_p[$sogo]]</small>| if($sogo);
($mv_mode eq 'mv') ? $com =~ s/하트/<font color="pink">\&\#63726<\/font>/g : $com =~ s/하트/<span class="f1">ゥ<\/span>/g ;
($mv_mode eq 'mv') ?
print qq|$nm:$com [$camp_info[$camp][0] $date]<br>\n|:
print qq|<span style="color:$camp_info[$camp][1]">$nm $com </span><span class="date">[ $camp_info[$camp][0] $date ]</span><hr>\n|;
last if $log_last_flag > $log_last;
}
close(IN);
# 著作権表示(削除禁止)
print "<hr>\n";
&copyright;
exit;
}
#-------------------------------------------------------------------------------
# ログ書き込み処理
sub regist {
# ファイルロック
if ($lockkey) { &lock; }
# ログを読み込み
open(IN,"$logfile") || &error("Open Error : $logfile");
@lines = <IN>;
close(IN);
# 最大記事数処理
while ($max <= @lines) { pop(@lines); }
# ログ更新処理
unshift (@lines,"$date<>$DAT{'nm'}<>$DAT{'camp'}<>$com<>$DAT{'sogo'}<>$addr<>$host<>$agent<>\n");
open(OUT,">$logfile") || &error("Write Error : $logfile");
print OUT @lines;
close(OUT);
# ロック解除
if (-e $lockfile) { unlink($lockfile); }
}
#-------------------------------------------------------------------------------
# 在室者処理
sub member {
open(IN,"$memfile") || &error("Open Error : $memfile");
@data = <IN>;
close(IN);
$member="";
@new=();
$flag=0;
$flag2=0;
foreach (@data) {
($time2,$name2,$host2) = split(/<>/);
# 発言のない者は削除
if ($time-$reload_limit > $time2) { next; }
elsif ($host2 eq "$addr") {
# 발언/갱신 간격
# &error("$reload_mn秒以上間隔を空けて発言してください。") if($reload_mn+$time2>$time);
if($reload_mn+$time2>$time){
print "Status: 204\n\n";
exit;
}
# 退室者は削除
if ($_[0] eq 'bye') { next; }
# ホスト名が同一であれば時間と名前を更新
$_ = "$time<>$DAT{'nm'}<>$addr<>\n";
$name2 = $DAT{'nm'};
$flag=1;
}
# 更新用配列 @new に追加
if ($name2 ne "$host2") {
push(@new,$_);
# 参加者表示用文字列を作成
if(!$flag2){$member .="$name2◇";$flag2=1;}
else{$member .="$name2◆";$flag2=0;}
}
}
# 新規参加者を追加
if (!$flag && $mv_mode eq 'pc') {
if ($DAT{'nm'} ne "$host") {
push(@new,"$time<>$DAT{'nm'}<>$addr<>\n");
$member .= (!$flag2) ? "$DAT{'nm'} [IN]◇" : "$DAT{'nm'} [IN]◆";
}
}
# 参加者数を認識
$num = @new;
# ファイル更新
open(OUT,">$memfile") || &error("Write Error : $memfile");
eval "flock(OUT,2);";
truncate(OUT,0);
seek(OUT,0,0);
print OUT @new;
close(OUT);
}
#-------------------------------------------------------------------------------
# HTMLのヘッダー
sub header {
print "Content-type: text/html; charset=UTF-8\n\n";
print <<"EOM";
<html>
<head>
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
<title>$title</title>
EOM
if($mv_mode eq 'pc'){
print <<"EOM";
<META HTTP-EQUIV="refresh" CONTENT="$reload_time[$rd];URL=$script?id=$id&pw=$pw&rd=$rd">
$css
<script language="JavaScript">
<!--
function textfocus(){
document.park.comment.focus();
return true;
}
//-->
</script>
EOM
}
(!$_[0] && $mv_mode eq 'pc') ? print qq|</head>\n<body $body onLoad="return textfocus()">| : print "</head>\n<body $body>" ;
}