Skip to content

Instantly share code, notes, and snippets.

@nurse
Created January 7, 2012 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nurse/1575633 to your computer and use it in GitHub Desktop.
Save nurse/1575633 to your computer and use it in GitHub Desktop.
TeaChat with flock(2)
#!/usr/local/bin/perl
# ---------------------------------------------------
#
# TeaChat
$version = '1.8.4b'; # 04/01/19 00:29
# (c) 1998-2004 Toshikazu.S All rights reserved.
#
# URL : http://www.teachat.org/
# E-Mail : webmaster@teachat.org
#
# アイコン化改造
# 姫宮夏芽
#
# URL : http://blog.tirno.net/
# E-Mail: natume@tirno.net
#
# ---------------------------------------------------
##################
#.ユーザー設定ここから
# 【必須】chat,cgiのURL(動作しない場合は、http://からのフルパスを記述すること)
$script = './chat.cgi';
# 【必須】管理パスワード(半角英数字)
$password = 'abc1234';
# 電報の暗号化鍵(半角英数字6~8文字)
# 電報の暗号化を行う場合は必ず適当なものに変えてください
$key = 'tane9seed';
# 公開プロクシを照会するデータベース(bbx.2ch.net、http.dnsbl.sorbs.net、niku.2ch.netなど)
$dnsbl = 'niku.2ch.net';
# chat.cgiから他のファイルへの相対パス。最後に「/」をつけないこと。
# 意味がわからない人は触らないでください。
$dir = '.';
#--登録アイコン保存URL(必ず相対パスまたは、httpから指定してください。)
$icon_url = "./icn";
#--登録アイコン保存場所(必ずPathで指定してください。httpからは指定できません。)
$IconPath = "./icn";
#--登録アイコン1個当たり保存OKの容量(単位KB, 0:無制限)
$MaxPicSize = 35;
# --------データファイル--------
# ファイル名は変更を推奨。変更する場合は下記記述の変更だけでなく、サーバー上のファイル名の変更も忘れずに。
$chat_file = "$dir/chat.dat";
$ctz_file = "$dir/ctz.dat";
$decorate_file = "$dir/decorate.dat";
$status_file = "$dir/status.dat";
$mem_file = "$dir/mem.dat";
$count_file = "$dir/count.dat";
$punish_file = "$dir/punish.dat";
$SaveFile = "$dir/iconfile.dat";
###############################
# ユーザー設定ここまで
&file_open;
# -------------------------------------------------------------
#.基本設定
$method = 'POST';
$html_pl = "$dir/html.pl";
$html2_pl = "$dir/html2.pl";
$tool_pl = "$dir/tool.pl";
$ctz_pl = "$dir/customize.pl";
$decorate_pl = "$dir/decorate.pl";
#$chatdb_pl = "$dir/chatdb.pl";
$pup_pl = "$dir/pup.pl";
$color_dat = "$dir/color.dat";
$lockdir = "$dir/lock/";
#$jcode = "$dir/jcode_se.pl";
$retry = 4;
$background = " background=\"$background\"" if($background);
$body = "<body$background bgcolor=\"$bgcolor\" text=\"$text\" link=\"$link\" vlink=\"$vlink\" alink=\"$alink\"";
$background2 = " background=\"$background2\"" if($background2);
$body2 = "<body$background2 bgcolor=\"$bgcolor2\" text=\"$text2\" link=\"$link2\" vlink=\"$vlink2\" alink=\"$alink2\"";
$endhtml = '<noembed><noscript><noscript><noscript><noscript>';
$time = time+$stdtime*60*60;
$k_splitchar = "''";
$icon_url =~ s/\/$//g;
$IconPath =~ s/\/$//g;
# -------------------------------------------------------------
#.分岐処理
BEGIN{
$| = 1;
# print"Content-type: text/html\n\n";open(STDERR, ">&STDOUT");
eval("use Encode qw(:fallbacks from_to)");
$use_encode = ($@ ? 0 : 1);
}
$Eflag = 0;
$Jflag = 0;
if ($use_encode) {
$Eflag = 1;
my $text = "\xE6\xBC\xA2";
my $xtext = $text;
&ktai_enc($xtext);
$Eflag = 2 if($text eq $xtext);
}
if (!$Eflag) {
eval "use Jcode";
$Jflag = 1 if(!$@);
}
&usercheck;
if($ENV{'CONTENT_TYPE'} =~ /multipart\/form-data; boundary=[^\0]*$/i){
require "$pup_pl";
&InitFormMultiPart;
}else{
&xdecode;
}
$ktai_id = &ktai_sr if(!$ktai_id && $ktai_rid && ($enter || ($k_tairom && ($pass ne $password))));
&punish if($punish_check);
if($ktai_ua){
&xdecode2;
$high = on;
if($view){
if($rank){
require "$html_pl";
&rank_read;
exit;
}
if($sphone && $enter) { require "$html_pl"; &setcookie; }
&write if($chat ne "");
if($xrom && (!$orgname && !($k_tairom && ($pass eq $password)))){ require "$html_pl"; &i_first; exit; }
&read;
}
elsif($administer){
require "$tool_pl";
if(($pass eq $password) && $adexe eq "on"){ &ad_exe; }
&ad_html;
}
else{
require "$html_pl";
&i_first;
}
}
elsif($first eq "on" || $nofent eq "on"){ require "$html_pl"; &first; }
elsif($hidden eq "on"){ require "$html_pl"; &hidden; }
elsif($nof eq "on"){
if(($chat ne "") || $enter eq "on"){ &xdecode2; &iconchk if($enter eq "on"); &write if($change ne "on"); }
&read;
}
elsif($enter){ require "$html_pl"; &xdecode2; &iconchk; &setcookie; &operation; }
elsif($FORM{'kick_list'} || $FORM{'kldel'}){
require "$html2_pl";
if(!$FORM{'back'} && $cs_use_kill_list){
&kick_list;
}
else{
require "$html_pl";
&operation;
}
}
elsif($view){
&xdecode2;
if($xrom && !$orgname && !$rank){ require "$html_pl"; &hidden; exit; };
&write if($chat ne "");
if($rank || $exit){ &member; require "$html_pl"; &rank_read; exit; }
elsif($secret){ require "$html_pl"; &secret; exit; }
elsif($secret2){ require "$html_pl"; &secret2; exit; }
else{
&read;
}
}
elsif($cc eq "on"){
require "$html_pl";
&color_chart;
}
elsif($FORM {'image'} eq "on"){
require "$html_pl";
&image;
}
elsif($url){
&getreferer;
print "Content-type: text/html\n";
print "Refresh: 0; URL=$url\n\n\n";
}
elsif($FORM {'pup'} eq "on"){
if(!$usricon) { &error(0); }
&rbl_check($addr) if($rbl && !$p_flag);
require "$pup_pl";
&MainX;
}
elsif($administer eq "on"){
require "$tool_pl";
if(($pass eq $password) && $adexe eq "on"){ &ad_exe; }
&ad_html;
}
elsif($customize eq "on"){
require "$ctz_pl";
if(($pass eq $password) && $ctz_exe eq "on"){ &ctz_exe; }
&ctz_html;
}
elsif($FORM{'decorate'} eq "on"){
require "$decorate_pl";
if(($pass eq $password) && $FORM{'decorate_exe'} eq "on"){ &decorate_exe; }
&decorate;
}
#elsif($FORM{'cdb'} eq "on"){
# require "$chatdb_pl";
# &cdb_body;
#}
#elsif($FORM{'cdb_active'} eq "on" && ($pass eq $password)){
# require "$chatdb_pl";
# &activation_exe;
#}
else{
require "$html_pl";
&index;
}
exit;
# -------------------------------------------------------------
#.ユーザチェック
sub usercheck{
$host = &getip;
$hua = $ENV{'HTTP_USER_AGENT'};
$hua =~ s/</&lt;/g;
$hua =~ s/>/&gt;/g;
$jxn = $ENV{'HTTP_X_JPHONE_MSNAME'} || $ENV{'X_JPHONE_MSNAME'};
$sphone = 1 if($hua =~ /iPhone|Android/i);
$jphone = 1 if($jxn || ($hua =~ /J-PHONE\/|Vodafone\/|SoftBank\//i));
$jphone_old = 1 if(($hua =~ /J-PHONE\/1/i) || ($hua =~ /J-PHONE\/2/i));
$jphone_nop = 1 if(($hua =~ /J-PHONE\/1/i) || ($hua =~ /J-PHONE\/2/i) || ($hua =~ /J-PHONE\/3/i));
$hua = $jxn if($jxn && !$hua);
$method = 'GET' if($jphone_old);
$ktai_ua = 1 if(($hua =~ /DoCoMo|ASTEL|KDDI|UP\.Browser|PDXGW|Palmscape|Xiino|pda browser|L-mode/i) || $jphone || $sphone);
$nonrefer_ua = 1 if(($ktai_ua || ($hua =~ /Lynx|Windows CE/i)) && !$sphone);
$ktai_sj = 1 if(($ktai_ua && !$sphone) && (($hua =~ /DoCoMo|ASTEL|PDXGW|Palmscape|Xiino|pda browser|L-mode/i) || $jphone));
$charset = 'Shift_JIS';
$charset = 'x-sjis' if($hua =~ /MSIE 3|Mozilla\/1|Mozilla\/2|Mozilla\/3/i);
$charset = 'UTF-8' if(!$ktai_sj || (!$Eflag && !$Jflag));
$firewall = 0 if($nonrefer_ua);
$accesskey = 'accesskey';
$accesskey = 'directkey' if($jphone);
$utn = ' utn' if($ktai_seigen && $hua =~ /DoCoMo/i);
$ktai_rid = 1 if($ktai_seigen && (($hua =~ /DoCoMo|KDDI|^UP\.Browser/i) || ($jphone && !$jphone_nop)));
}
# -------------------------------------------------------------
#.REFERER判定
sub getreferer{
$refer = $ENV{'HTTP_REFERER'};
$ident = $script;
$ident =~ s/\~/.*/g;
# if(!$nonrefer_ua && ($refer !~ /$ident/i)){ &error(0); }
if(!$nonrefer_ua && $refer && ($refer !~ /$ident/i)){ &error(0); }
}
# -------------------------------------------------------------
#.ヘッダ
sub http_header{
$doctype = $doctype2;
$doctype = 'Transitional' unless($doctype2);
$dtd = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 $doctype//EN\">\n" unless($ktai_ua);
my $ctype = qq{<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=${charset}">\n} unless($ktai_ua);
my $scale = qq{<meta name="viewport" content="width=320, initial-scale=1.0, user-scalable=yes, maximum-scale=1.0, minimum-scale=1.0, ">\n} if($sphone);
&ktai_enc($title) if($ktai_sj);
print <<"EOF";
Pragma: no-cache
Expires: -1
P3P: CP="NOI ADMa"
Cache-Control: no-cache
robots: noindex,nofollow
Content-Style-Type: text/css
Content-Script-Type: text/javascript
Content-Language: ja
Content-Type: text/html; charset=$charset
$dtd<html><head>$ctype$scale<title>$title</title>
EOF
}
# -------------------------------------------------------------
#.元IP取得 ホスト変換
sub getip{
local $ip = $ENV{'REMOTE_HOST'};
$addr = $ENV{'REMOTE_ADDR'};
$ip = $addr if(!$ip);
if($trueip){
if($ENV{'HTTP_X_FORWARDED_FOR'} =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)(\D*).*/){
$ip = "$1.$2.$3.$4";
}
elsif($ENV{'HTTP_CACHE_INFO'} =~ m/(\d+)\.(\d+)\.(\d+)\.(\d+)/){
$ip = "$1.$2.$3.$4";
}
elsif($ENV{'HTTP_FROM'} =~ m/(\d+)\.(\d+)\.(\d+)\.(\d+)/){
$ip = "$1.$2.$3.$4";
}
elsif($ENV{'HTTP_SP_HOST'} =~ m/(\d+)\.(\d+)\.(\d+)\.(\d+)/){
$ip = "$1.$2.$3.$4";
}
elsif($ENV{'HTTP_VIA'} =~ m/.*\s(\d+)\.(\d+)\.(\d+)\.(\d+)/){
$ip = "$1.$2.$3.$4";
}
elsif($ENV{'HTTP_FORWARDED'} =~ m/.*\s(\d+)\.(\d+)\.(\d+)\.(\d+)/){
$ip = "$1.$2.$3.$4";
}
elsif($ENV{'HTTP_CLIENT_IP'} =~ m/.*\s(\d+)\.(\d+)\.(\d+)\.(\d+)/){
$ip = "$1.$2.$3.$4";
}
}
if($ip =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/){
($i1,$i2,$i3,$i4) = split(/\./,$ip);
$p_name = pack("CCCC",$i1,$i2,$i3,$i4);
($iname, @addr) = gethostbyaddr($p_name, 2);
}
$iname = $ip if(!$iname);
return $iname;
}
# -------------------------------------------------------------
#.アクセス制限
sub punish{
open(DB,"$punish_file") || &error(8);
@p_line = <DB>;
close(DB);
$p_mode_ch = shift(@p_line);
chop($p_mode_ch);
$p_flag = 0;
foreach (@p_line) {
($pmv, $phv) = split(/\t/, $_);
chop($phv) if($phv =~ /\n/);
if(($p_mode_ch eq "1") && ($pmv eq "1")){
if((($host =~ /$phv/) || ($xfor =~ /$phv/)) || (($ktai_id =~ /$phv/) && $ktai_seigen)){ &error(0); }
}
elsif($pmv eq "2"){
if(($host =~ /$phv/) || (($ktai_id =~ /$phv/) && ktai_seigen)){ $p_flag = 1; }
}
}
if(($p_mode_ch eq "2") && !$p_flag){ &error(12); }
if($hua =~ /Iria/i){ &error(0); }
}
# -------------------------------------------------------------
#.表示処理
sub read{
&rbl_check($addr) if($rbl && !$p_flag);
&member if(!($ktai_ua && $FORM{'peephole'} && ($pass eq $password)));
&read_header;
print qq(</head>$body2$reljs>\n);
print qq($title) if(!$ktai_ua);
print qq($rb);
if(!$filesize_flag && $ktai_ua && $FORM{'filecheck'} && !$chat){
$_ = "新規の発言はありません。新規の発言がある場合のみログを表\示します。";
&ktai_enc($_) if($ktai_sj);
print "<center>$_<br>[<a href=\"$relper&ktaireload=on\" $accesskey=\"1\">1.Reload</a>]</center>\n";
exit;
}
print qq(<SCRIPT LANGUAGE="JavaScript"><!--\nalert\("参加人数が変化しました。"\);\n// --></SCRIPT>\n) if($alert_flag && $FORM{'addalert'});
&member_print;
$window = $cs_log_max if($cs_log_max < $window);
open(CHAT, "$chat_file") || &error(1);
flock(CHAT, 1);
$i = 0;
while(<CHAT>){
my $chatline = $_;
if($chatline){
$i = $i + log_print($chatline);
}
last if($window <= $i);
}
close(CHAT);
&html_hooter;
}
#..ログ表示
sub log_print{
my $chatline = shift;
my ($time_v, $host3_v, $hua2, $name, $email, $chat, $n_color, $s_color, $greet, $icon, $fcolor_value, $fcolor_file, $s_host_v, $s_host_n, $ktai_id_v, $realhost) = split(/\t/, $chatline);
$realhost =~ tr/\x0D\x0A//d;
#携帯の時、前回リロード時より60秒以上古い発言は表示させない
#(10行表示以上ではこの機能は働かない。
# by G_Prog.さん
last if($window < 10 && $ktai_ua && $time_v < $lastreload-60);
#...無視リスト参照
$kick_flag = 0;
foreach (@my_kick_list){
local ($k_host, $k_name) = split(/:/, $_);
$k_name =~ tr/\x0D\x0A//d;
$kick_flag = 1 if(($k_host eq $realhost) || ($k_name eq $name));
}
next if($kick_flag);
&time($time_v);
$secflag = '';
if($email && ($email =~ /(.*)\@(.*)\.(.*)/)){
$mb = "<a href=\"mailto:$email\"><b>&gt;</b></a>";
}
elsif($email && ($email =~ /http:\/\//)){
$mb = "<a href=\"$email\" target=\"_blank\"><b>&gt;</b></a>";
}
else{
$mb = "&gt;";
}
$flag_e = '';
if($s_host_v eq "enter" || $s_host_v eq "exit"){
$name = $notice;
$n_color_ch = $notice_color;
$mb = '';
if($greet){
$greet = "<font color=\"$n_color\"><b>『$greet』</b></font> ";
}
if($secret3){ return 0; }
$flag_e = 1;
}
elsif($s_host_v eq 'omikuji'){
$mb = '';
$n_color_ch = $n_color;
$flag_e = 1;
# 電報ウィンドウにおみくじは表示しない
return 0 if $secret3;
}
#...電報種別判定
elsif($s_host_v){
$teleg_flag = 0;
@teleg_name = ''; # ☆
$teleg_name_list = '';
if($s_host_v eq "ALL"){
local @teleg_list2 = split(/<>/, $s_host_n);
for (@teleg_list2){
local ($teleg_host, $teleg_name) = split(/<s>/, $_);
push(@teleg_name, $teleg_name);
$teleg_name_list = join ', ', @teleg_name;
$teleg_name_list =~ s/^, //;
$teleg_flag = 1 if(($teleg_host eq $host) && ($teleg_name eq $realname));
}
}
if($sechide){ return 0; }
if(($s_host_v eq $host) && ($s_host_n eq $realname)){
$secflag = "さんから$s_host_nさんへの電報";
}
elsif(($realhost eq $host) && ($s_host_v eq "ALL") && ($realname eq $name)){
$secflag = ":($teleg_name_list)さんへの電報";
}
elsif(($realhost eq $host) && ($realname eq $name)){
# 発言が発言者のもので、ALL宛の場合
$secflag = ":$s_host_nさんへの電報";
}
elsif(($realname ne $host) && ($s_host_v eq "ALL") && $teleg_flag){
# 発言が発言者のものでなく、ALL宛で、$teleg_hostが自分のと一致した場合
$secflag = "さんから($teleg_name_list)さんへの電報";
}
else{ return 0; }
$chat = &StringDecode($chat) if($key);
# $chat =~ tr/a-fA-F0-9/fedcbaFEDCBA9876543210/;
# $chat = &xdecode3($chat);
# $chat =~ tr/+/ /;
}
elsif($secret3){ return 0; }
else{
$greet = '';
}
if(!$flag_e){
$n_color_ch = $n_color;
$chat = "<font color=\"$s_color\">$chat</font>" if($saycolor_check);
}
#...ログのホストアドレス表示
if($ipcomout eq "1"){ # 入室・退室時のみ表示する
if($hua2){
$host3_v = " $host3_v";
}else{
$host3_v = '';
}
}
elsif($ipcomout eq "2"){ # 常に表示する
$host3_v = " $host3_v";
}
elsif($ipcomout eq "3"){ # コメントアウトしてソースに表示
$host3_v = "<!-- $host3_v -->";
}
else{
$host3_v = ''; # 条件にマッチしない場合は表示しない
}
$hua2 = " $hua2" if($hua2);
$hua2 = '' if(!$cs_showua);
$user = "$date_v$hua2$host3_v";
$chat = "<b>$chat</b>" if($cs_markbold);
if(!$high){
$br = "<br>" if($defa_space);
print qq(<table cellspacing="1"><tr><td align="center" valign="middle"><img src="$icon" align=middle></td><td><table cellspacing="0" cellpadding="0"><tbody><td><img src="$fkidir/$fcolor_file\_l.gif"></td><td bgcolor="$fcolor_value"><font color="$n_color_ch"><b>$name</b></font>$secflag $mb $chat $greet<span class="fface">[$user]</span></td><td><img src="$fkidir/$fcolor_file\_r.gif"></td></tr></tbody></table></td></tr></table>$br);
print "\n";
}
else{
$chat=~s/<[^>]*>//ig;
$greet=~s/<[^>]*>//ig;
if ($sphone) {
$chat =~ s/((http[s]?:\/\/|ftp:\/\/)[\w\$\#\~\.\/\-\?\=\&\:\;\%\+\,]+)/<a href\=\"$1\" target\=\"\_blank\">$1<\/a>/g;
$_ = "<img src=\"$icon\" width=\"20\" height=\"20\" align=\"left\"><font color=\"$n_color_ch\">$name</font>$secflag &gt; $chat $greet\[$date_i\]";
} else {
$_ = "<font color=\"$n_color_ch\">$name</font>$secflag &gt; $chat $greet\[$date_i\]";
}
&ktai_enc($_) if($ktai_sj);
print $_;
# print qq($name$secflag &gt; $chat $greet\[$date_i\]);
if(!$ktai_ua) {
print qq(<hr class="line">);
} else {
print qq(<hr>);
}
print "\n";
return 1;
}
}
#..ヘッダHTML読み込み
sub read_header{
my $n_color = $main::n_color;
my $s_color = $main::s_color;
# $n_color =~ s/#//g;
# $s_color =~ s/#//g;
$xn_color = $n_color;
$xs_color = $s_color;
&xencode($xn_color);
&xencode($xs_color);
$script =~ s/~/%7E/g;
$realname = $name;
$rom_name = $name;
&xencode($rom_name);
$rom_name = '' if(!$romer && ($name eq $host));
my $f_color2 = $f_color;
$f_color2 =~ s/#/\%h/g;
my $reload2 = $reload;
$reload2 = $reload + 10 if(($reload > 0) && ($reload < 60));
$relsum = $relsum + $reload;
$relsum = 3600 if($relsum > 3600);
$relper = "$script?name=$rom_name&reload=$reload2&window=$window&view=on&high=$high&sechide=$sechide&secret3=$secret3&n_color=$xn_color&addalert=$FORM{'addalert'}&filecheck=$FORM{'filecheck'}&relsum=$relsum";
&http_header;
$relper_nof = "&email=$email&s_color=$xs_color&icon=$icon&f_color=$f_color2&nof=on" if($nof);
print qq(<META HTTP-EQUIV="Refresh" CONTENT="$reload;URL=$relper$relper_nof">\n) if($reload && !$ktai_ua);
&css if(!$high || !$ktai_ua);
$rb = " <span class=\"fface\">[<a href=\"$relper&relb=on\">Reload</a>]</span><br>\n" if($relb && !$nof);
if ($nof || ($inlog_sec_send eq "on")) {
print qq(<SCRIPT Language="JavaScript">\n<!--\n);
print qq(function chaImgIenn5\(foName,elName,imgName\) {\n);
print qq(\tif \(document.images\) {\n\t\tvar p=document.forms[foName].elements[elName];\n);
print qq(\t\tvar v=p.options[p.selectedIndex].value;\n\t\tif \(v!="defult"\) {\n);
print qq(\t\t\tvar img=new Image\(\);\n\t\t\timg.src=v;\n);
print qq(\t\t\tdocument.images[imgName].src=img.src;\n\t\t}\n }\n}\n);
print qq(// -->\n</SCRIPT>);
}
if($reloadcnt && !$high && $reload){
print qq(<SCRIPT Language="JavaScript">\n<!--\nfunction timer\(\) {\n cnt--;\n var bar = cnt / 2;\n block = "";\n);
print qq( while \(bar > 0\) { block += "◇"; bar--; }\n status = "リロードまで約" + cnt + "秒 " + block;\n);
print qq( if \(cnt > 4\) { Timecount = setTimeout\("timer\(\)",900\); }\n else { clearTimeout\(Timecount\); status = "間もなくリロードします"; }\n}\n// -->\n</SCRIPT>);
$reljs = " onLoad=\"cnt=$reload\;timer\(\)\"";
}
}
#..参加者表示print
sub member_print{
my $manrel = "$script?name=$rom_name&reload=$reload&window=$window&view=on&high=$high&sechide=$sechide&secret3=$secret3&n_color=$xn_color&addalert=$FORM{'addalert'}&filecheck=$FORM{'filecheck'}";
print qq( <span class=\"fface\">[<a href="$manrel">Reload</a>]</span>) if(!$ktai_ua && !$nof && !$relb);
if(!$high){
$mem_num = @mem_num;
if($mem_num eq "0"){ $mem_num = 'なし'; }
else{ $mem_num = "$mem_num人 : @mem_num"; }
if(!$romer){ $memt = '参加者'; }
else{ $memt = 'Access'; }
if($romcount && !$romer){
$rom_num = @rom_num;
if($rom_num eq "0"){ $rom_num = ' ROM なし'; }
else{ $rom_num = " ROM $rom_num人"; }
}
else{ $rom_num = ''; }
print qq( <font size="2">$memt $mem_num$rom_num</font>);
}
print qq(<hr size="1" class="line">) if(!$ktai_ua);
if($nof eq "on"){
require "$html_pl";
&operation;
print qq(<hr size="1" class="line">\n);
}
elsif($inlog_sec_send eq "on"){
require "$html_pl";
&inlog_sec_send;
print qq(<hr size="1" class="line">\n);
}
if($ktai_ua && ($k_tairom ne "on")){
if(!$exit){
require "$html_pl";
&i_operation;
print qq(<hr size="1">\n);
}
else{
$_ = "1.再入室";
&ktai_enc($_) if($ktai_sj);
print qq(<a href="$script?" $accesskey="1">$_</a>);
print qq(/<a href="$home_k" $accesskey="2">2.HOME</a>) if($home_k);
print qq(<br>\n);
}
}
}
#..フッタ
sub html_hooter{
if(!$high){
print qq(<span class="fface">);
if($reload){ print qq(Reload : $reload ); }
else{ print qq(Reload : off ) }
print qq(Line : $window</span>\n);
}
# 下記の改変は禁止されています。
if(!$high){
print qq(<div align="right"><a href="http://www.teachat.org/" target="_blank"><span class="fface">TeaChat $version</span></a></div>);
print qq(<div align="right"><span class="fface">Edit:</span><a href="http://blog.tirno.net/" target="_blank"><span class="fface">姫宮夏芽</span></a></div>);
}
else{
print qq(TeaChat $version\n);
}
print qq(</body></html>);
print qq($endhtml) if(!$ktai_ua);
}
# -------------------------------------------------------------
#.記録処理
sub write{
my ($omikuji_chat, $omikuji_name, $omikuji_n_color, $omikuji_flag, $omikuji_line);
$omikuji_flag = 0;
&getreferer if($firewall);
$failure = 0;
srand($time) if $enter or $exit or $omikuji_enable;
#..発言/入退室判別
$chat2 = $chat;
$host3 = $host;
$host4 = $host3;
$viewname = $name;
&lieip if($lieip_check);
if($enter eq "on" or $exit eq "on"){
# 同一名入室禁止
if($cs_no_imitation and $enter){
open(MEM,"$mem_file") or error(5);
flock(MEM, 1);
my @mem_array = <MEM>;
close(MEM);
for (@mem_array) {
my @line = split /\t/;
error("参加者と同名の入室は禁止されています。") if $line[1] eq $name and $line[2] ne $host;
}
}
&error(20) if(!$ktai_ua && $enter && $chktext && ($chkspam ne $chktext));
# メール通知処理
mail_send() if $cs_sendmail_enable and $enter eq "on";
if($cs_notice_style eq "off"){
if($greet){
$chat = $greet;
$time_v = $time;
&time;
rank_write() if $cs_use_ranking;
&tag;
}
else{
$failure = 1;
}
}
else{
if($kosr && ($enter eq 'on') && $kossori) {
$rand = int(rand(100)) + 1;
if ($rand <= $kossori) {
$failure = 1;
} else {
$greet = "<font color=\"$err_color\">こっそり入室失敗!!</font>";
}
}
if($name eq $host4){
if($cs_nameconfirm){ &error(13); }
else{ $name = "\[$host4\]"; }
}
$viewname = $name;
&haijo;
&rbl_check($addr) if($rbl && !$p_flag);
@enter_mes2 = @enter_mes;
@leave_mes2 = @leave_mes;
$em_num = @enter_mes2;
$lm_num = @leave_mes2;
$em_num2 = int(rand $em_num);
$lm_num2 = int(rand $lm_num);
if($enter eq "on"){
$e1 = $enter_mes[$em_num2];
}
elsif($exit eq "on"){
$e1 = $leave_mes[$lm_num2];
}
$e1 =~ s/&quot;/"/g;
$e1 =~ s/&gt;/>/g;
$e1 =~ s/&lt;/</g;
$e1 =~ s/\[NAME\]/$name/g;
$e1 =~ s/\[NAME_COLOR\]/$n_color/g;
chop($e1) if($e1 =~ /\n/);
$chat = $e1;
$s_host_v = 'exit';
$hua2 = $hua;
}
$icon2 = $icondir . "\/" .$adicon;
}
else{
$time_v = $time;
&time;
if($name eq $host4){
if($cs_nameconfirm){ &error(13); }
else{ $name = "\[$host4\]"; }
}
&error(13) if(!$namae);
&haijo;
&rbl_check($addr) if($rbl && !$p_flag);
&error(21) if($ktai_rid && !$ktai_id);
rank_write() if $cs_use_ranking;
&tag;
# if($face){ $chat = "$chat $face"; }
if($s_host){
($s_host_v, $s_host_n) = split(/:/, $s_host);
}
$xkeyflag = xwords_match() if $cs_xwords;
$chat = "<font color=\"$err_color\">[発言の中に不正なキーワードが含まれています。削除されました。]</font>" if($xkeyflag);
if($s_host){
# $chat = &xencode($chat);
# $chat =~ tr/a-fA-F0-9/fedcbaFEDCBA9876543210/;
$chat = &StringEncode($chat) if($key);
}
#...おみくじの実行
if($cs_omikuji_enable){
my $match = $chat;
# jcode::convert(\$match, 'euc');
# jcode::convert(\$cs_omikuji_word, 'euc');
if($match eq $cs_omikuji_word){
$omikuji_flag = 1;
open(IN, $decorate_file) or error(11);
my @deco = <IN>;
close(IN);
my $omikuji_msg = pop(@deco);
my @omikuji_msg = split(/\t/, $omikuji_msg);
map { chomp; } @omikuji_msg;
my $num = @omikuji_msg;
my $num_random = int(rand $num);
$omikuji_chat = $omikuji_msg[$num_random];
$omikuji_chat =~ s/&quot;/"/g;
$omikuji_chat =~ s/&gt;/>/g;
$omikuji_chat =~ s/&lt;/</g;
$omikuji_chat =~ s/\[NAME\]/$name/g;
$omikuji_chat =~ s/\[NAME_COLOR\]/$n_color/g;
$omikuji_name = $cs_omikuji_name;
$omikuji_n_color = $cs_omikuji_namecolor;
$omi_fcolor_value = $fki_col;
$omi_fcolor_file = $dfki;
}
}
if ($icon !~ /^($icondir|$icon_url)/) { &error(0); }
$icon2 = $icon;
}
open(CHAT, "+<$chat_file") || &error(1);
flock(CHAT, 2);
@lines = <CHAT>;
#..同一発言連続防止 or clearコマンドがある場合のみ読み出し
if($cs_chatconfirm || ($clear_on && ($chat2 eq "clear")) || ($cut_on && ($chat2 eq "cut"))){
if($cs_chatconfirm){
@continuity_confirm = @lines;
$lastline = shift(@continuity_confirm);
($d1, $d2, $d3, $last_name, $d5, $last_comment, $d7, $d8, $d9, $d10, $d11, $d12, $d13, $d14, $d15, $last_realhost) = split(/\t/, $lastline);
chop($last_realhost) if($last_realhost =~ /\n/);
if(($last_name eq $name) && ($last_comment eq $chat) && ($last_realhost eq $host)){
$failure = 1;
}
}
if($clear_on && ($chat2 eq "clear")){
foreach $line (@lines){
($d1, $d2, $d3, $last_name2, $d5, $d6, $d7, $d8, $d9, $d10, $d11, $d12, $shv, $d14, $d15, $realhost) = split(/\t/, $line);
chop($realhost) if($realhost =~ /\n/);
if(($host eq $realhost) && ($shv ne 'exit') && ($last_name2 eq $name)){
$line = '';
}
}
$chat = "<font color=\"$err_color\">[発言者によって$nameさんの発言ログは消去されました。]</font>";
}
#..直前の発言を消去する機能
if($cut_on && ($chat2 eq "cut")){
$chat=~s/^cut//;
foreach $line (@lines) {
($d1, $d2, $d3, $last_name2, $d5, $d6, $d7, $d8, $d9, $d10, $d11, $d12, $shv, $d14, $d15, $realhost) = split(/\t/, $line);
chop($realhost) if($realhost =~ /\n/);
if (($host eq $realhost) && ($shv ne 'exit') && ($last_name2 eq $name) && ($line=~/$chat/i)){
$line = '';
last;
}
}
$chat = "<font color=\"$err_color\">[発言者によって$nameさんの直前の発言は消去されました。]</font>";
}
}
#..管理用消去コマンド実行
if ($chat2 =~ /$cs_allclear(.*)/){
$chat=~s/^$cs_allclear//;
foreach $line (@lines) {
$line = '' if ($line=~/$chat/i);
}
$chat = "<font color=\"$err_color\">[管理人による削除が実行されました。]</font>";
}
$allclear_flag = 0;
$allclear_flag = 1 if($chat2 eq $cs_allclear);
#..$chatの装飾
$chatstyle = "";
if($FORM{'fontsize'} && ($FORM{'fontsize'} ne "3")){
$chatstyle = " size=\"$FORM{'fontsize'}\"";
}
if($FORM{'fontfamily'} && ($FORM{'fontfamily'} ne "-")){
$chatstyle .= " style=\"font-family: \'$FORM{'fontfamily'}\';\"";
}
if($FORM{'fontstyle'} && ($FORM{'fontstyle'} ne "-")){
if($FORM{'fontstyle'} eq "iv"){
$chatstyle .= " color=\"$fcolor_value\"";
}
elsif($FORM{'fontstyle'} eq "b"){
$chat = "<b>$chat</b>";
}
elsif($FORM{'fontstyle'} eq "i"){
$chat = "<i>$chat</i>";
}
elsif($FORM{'fontstyle'} eq "s"){
$chat = "<strike>$chat</strike>";
}
elsif($FORM{'fontstyle'} eq "u"){
$chat = "<u>$chat</u>";
}
}
$chat = "<font$chatstyle>$chat</font>" if($chatstyle);
$w_val = "$time\t$host3\t$hua2\t$name\t$email\t$chat\t$n_color\t$s_color\t$greet\t$icon2\t$fcolor_value\t$fcolor_file\t$s_host_v\t$s_host_n\t$ktai_id\t$host\n";
#..file書き込み
if(!$failure){
$i = 0;
foreach $line (@lines){
if(++$i > $log_max){ last; }
push(@array, $line);
}
unshift(@array, $w_val);
if($omikuji_flag){
my $tmp = 'omikuji';
$omikuji_line = "$time\t$host3\t$hua2\t$omikuji_name\t$email\t$omikuji_chat\t$omikuji_n_color\t$s_color\t$greet\t$omi_icon\t$omi_fcolor_value\t$omi_fcolor_file\t$tmp\t$s_host_n\t$ktai_id\t$host\n";
unshift(@array, $omikuji_line);
}
truncate(CHAT,0);
seek(CHAT,0,0);
if(!$allclear_flag){
print CHAT @array;
}
}
close(CHAT);
}
# -------------------------------------------------------------
#.タグチェック
sub tag{
&tag_error if($chat =~ /<($x_tag)|($x_tag)>|<.*style=|<.*mailbox:|<.*width|<.*height/i);
$chat =~ s/<a href=/<a target="_blank" class="userlink" href=/ig;
unless($chat =~ /</i){
$chat =~ s/((http[s]?:\/\/|ftp:\/\/)[\w\$\#\~\.\/\-\?\=\&\:\;\%\+\,]+)/<a href\=\"$1\" target\=\"\_blank\" class=\"userlink\">$1<\/a>/g;
# if ($chat =~ /((http[s]?:\/\/|ftp:\/\/)[\w\$\#\~\.\/\-\?\=\&\:\;\%\+\,]+)/i) {
# my $rurl = $1;
# &xencode($rurl);
# $chat =~ s/((http[s]?:\/\/|ftp:\/\/)[\w\$\#\~\.\/\-\?\=\&\:\;\%\+\,]+)/<a href\=\"$script?url=$rurl\" target\=\"\_blank\" class=\"userlink\">$1<\/a>/g;
# }
$chat =~ s/([\w\.\-\_]+\@[\w\.\-\_]+\.[\w\.\-\_]+)/<a href\=\"mailto:$1\" class=\"userlink\">$1<\/a>/g;
}
@tags = split( /</ , $chat ); $dmy = shift(@tags);
foreach $tag (@tags){
$tag =~s/([^>]*)>(.*)/$1/;
$tag =~s/^\/(.*)//;
$tag =~s/^([^\s]*).*/$1/;
}
$chat.='>' if($chat=~/<\/$/);
@tags = reverse(@tags);
foreach $tag (@tags){
next if($tag =~/(img|^hr$|^br$)/i);
$chat.="</$tag>" if($tag);
}
}
sub tag_error{
$chat =~ s/</&lt;/g;
$chat =~ s/>/&gt;/g;
$chat = $chat . "<font color=\"$err_color\">[注意:そのタグは使用を禁止しております。ご了承下さい]</font>";
}
# -------------------------------------------------------------
#.不正ワードチェック
#sub xwords_match{
# my $match = 0;
# my $chat_euc = $chat;
# $xwords =~ s/\|$//g;
# $xwords =~ s/^\|//g;
# my @xwords = split(/\|/, $xwords);
# jcode::convert(\$chat_euc, 'euc');
# foreach $xword (@xwords){
# jcode::convert(\$xword, 'euc');
#
# # $chat_euc に $xword を正しくマッチさせる
#
# my $ascii = '[\x00-\x7F]';
# my $twoBytes = '[\x8E\xA1-\xFE][\xA1-\xFE]';
# my $threeBytes = '\x8F[\xA1-\xFE][\xA1-\xFE]';
#
# if($xword && ($chat_euc =~ /$xword/)){
# if($chat_euc =~ /^(?:$ascii|$twoBytes|$threeBytes)*?(?:$xword)/){
# $match = 1;
# }
# }
# }
# return $match;
#}
# 2004/1/19 のりさんの指摘により修正。
sub xwords_match{
my $match = 0;
my $chat_mes = $chat;
my @xwords = split(/\|/, $xwords);
foreach $xword (@xwords){
if($xword && ($chat_mes =~ /\Q${xword}\E/)){
$match = 1;
last;
}
}
return $match;
}
# -------------------------------------------------------------
#.時刻変換
sub time{
my $convert_time = shift;
$convert_time ||= $time_v;
($sec, $min, $hour, $mday, $mon, $year, $wday) = localtime($convert_time);
$mon2 = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec') [$mon];
$wday2 = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat') [$wday];
$wday3 = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday') [$wday];
$youbi = ('日','月','火','水','木','金','土') [$wday];
$year2 = $year;
$year2 = $year2 - 100;
$year2 = sprintf("%.2d",$year2);
if($year < 90){ $year = $year+2000; }
else{ $year = $year+1900; }
++$mon;
$hour = sprintf("%.2d",$hour);
if($hour > 11){
$hour2 = $hour - 12;
$ampm = "PM";
}
else{
$hour2 = $hour;
$ampm = "AM";
}
$min = sprintf("%.2d",$min);
$sec = sprintf("%.2d",$sec);
if($cs_timestyle eq "1"){
$date_v = "$wday2 $mday $mon2 $year $hour:$min:$sec";
}
elsif($cs_timestyle eq "2"){
$date_v = "$wday3, $mday-$mon2-$year $hour:$min:$sec";
}
elsif($cs_timestyle eq "3"){
$date_v = "$year/$mon/$mday $hour:$min";
}
elsif($cs_timestyle eq "4"){
$date_v = "$year/$mon/$mday $hour:$min:$sec";
}
elsif($cs_timestyle eq "5"){
$date_v = "$year/$mon/$mday $hour2:$min:$sec $ampm";
}
elsif($cs_timestyle eq "6"){
$date_v = "$year/$mon/$mday($youbi) $hour:$min";
}
elsif($cs_timestyle eq "7"){
$date_v = "$year/$mon/$mday($youbi) $hour:$min:$sec";
}
elsif($cs_timestyle eq "8"){
$date_v = "$year/$mon/$mday($youbi) $hour2:$min:$sec $ampm";
}
elsif($cs_timestyle eq "9"){
$date_v = "$year年$mon月$mday日($youbi) $hour:$min";
}
elsif($cs_timestyle eq "10"){
$date_v = "$year年$mon月$mday日($youbi) $hour:$min:$sec";
}
elsif($cs_timestyle eq "11"){
$date_v = "$year年$mon月$mday日($youbi) $hour2:$min:$sec $ampm";
}
elsif($cs_timestyle eq "12"){
$date_v = "$year2/$mon/$mday($wday2) $hour:$min:$sec";
}
$date_i = "$mon/$mday $hour:$min";
}
# -------------------------------------------------------------
#.ホスト名置換
sub lieip{
my $dmy = shift(@ctzline2);
$dmy = shift(@ctzline2);
$dmy = shift(@ctzline2);
$dmy = shift(@ctzline2);
$dmy = shift(@ctzline2);
$dmy = shift(@ctzline2);
$dmy = shift(@ctzline2);
foreach $l_line (@ctzline2){
($ip_email, $ip_host, $ip_new) = split(/\t/, $l_line);
chop($ip_new) if($ip_new =~ /\n|\cM/);
if($email =~ /$ip_email/ && $host3 =~ /$ip_host/){ $host3 = $ip_new; }
chop($host3) if($host3 =~ /\n|\cM/);
}
}
# -------------------------------------------------------------
#.設定ファイルオープン
sub file_open{
open(IN, "$ctz_file") || &error(7);
@ctzline = <IN>;
close(IN);
@ctzline2 = @ctzline;
$line_base = shift(@ctzline);
$line_frame1 = shift(@ctzline);
$line_frame2 = shift(@ctzline);
$line_function = shift(@ctzline);
$line_xwords = shift(@ctzline);
$enter_mes = shift(@ctzline);
$leave_mes = shift(@ctzline);
chop($line_base) if($line_base =~ /\n/);
chop($line_frame1) if($line_frame1 =~ /\n/);
chop($line_frame2) if($line_frame2 =~ /\n/);
chop($line_function) if($line_function =~ /\n/);
chop($line_xwords) if($line_xwords =~ /\n/);
chop($enter_mes) if($enter_mes =~ /\n/);
chop($leave_mes) if($leave_mes =~ /\n/);
($cs_title, $cs_home, $cs_bbs, $cs_log_max, $cs_rank_max, $cs_rank_mini, $cs_stdtime, $cs_home_k, $cs_allclear, $cs_chatmaxlength ,$cs_iconw_max ,$cs_iconh_max ,$cs_iconv_max, $cs_kossori, $cs_kprof,$cs_name_max) = split(/\t/, $line_base);
$cs_kprof =~ tr/\x0D\x0A//d;
($cs_bgcolor, $cs_text, $cs_link, $cs_vlink, $cs_alink, $cs_hlink, $cs_background, $cs_logo, $cs_b_text, $cs_b_bgcolor, $cs_b_border, $cs_form_bg, $cs_form_tx, $cs_form_bd, $cs_icq_uin, $cs_icq_img, $cs_f_size, $cs_font, $cs_use_scrollbar, $cs_srl1_face, $cs_srl1_base, $cs_srl1_highlight, $cs_srl1_shadow, $cs_srl1_arrow, $cs_y_id, $cs_y_mark) = split(/\t/, $line_frame1);
$cs_y_mark =~ tr/\x0D\x0A//d;
($cs_notice, $cs_notice_color, $cs_bgcolor2, $cs_text2, $cs_link2, $cs_vlink2, $cs_alink2, $cs_background2, $cs_hlink2, $cs_ipcolor, $cs_defa_space, $cs_err_color, $cs_markbold, $cs_ipsize, $cs_ipfont, $cs_ipcomout, $cs_timestyle, $cs_notice_style, $cs_hr_b_style, $cs_hr_b_color, $cs_showua, $cs_srl2_face, $cs_srl2_base, $cs_srl2_highlight, $cs_srl2_shadow, $cs_srl2_arrow, $cs_icondir, $cs_adicon, $cs_pri_icon, $cs_fkidir, $cs_dfki, $cs_fki_col) = split(/\t/, $line_frame2);
$cs_fki_col =~ tr/\x0D\x0A//d;
($cs_ctch, $cs_saycolor_check, $cs_secret_check, $cs_lieip_check, $cs_punish_check, $cs_clear_on, $cs_lock_check, $cs_reloadcnt, $cs_romer, $cs_romcount, $cs_xrom, $cs_firewall, $cs_kickrom, $cs_nameconfirm, $cs_chatconfirm, $cs_trueip, $cs_use_kill_list, $cs_fontbox, $cs_sendmail_enable, $cs_mailto, $cs_sendmailpath, $cs_omikuji_enable, $cs_omikuji_word, $cs_omikuji_name, $cs_omikuji_namecolor, $cs_no_imitation, $cs_use_ranking, $cs_cut_on, $cs_user_icn, $cs_fukidasi, $cs_rbl, $cs_senyou, $cs_ktai_seigen, $cs_omi_icon, $cs_chktext) = split(/\t/, $line_function);
$cs_omi_icon =~ tr/\x0D\x0A//d;
($cs_xwords, $cs_x_tag, $cs_x_namez) = split(/\t/, $line_xwords);
$cs_x_namez =~ tr/\x0D\x0A//d;
$title = $cs_title; $background2 = $cs_background2;
$home = $cs_home; $hlink2 = $cs_hlink2;
$bbs = $cs_bbs; $log_max = $cs_log_max;
$rank_max = $cs_rank_max; $ipcolor = $cs_ipcolor;
$rank_mini = $cs_rank_mini; $defa_space = $cs_defa_space;
$name_max = $cs_name_max;
$MaxPicWidth = $cs_iconw_max; $MaxPicHeight = $cs_iconh_max;
$MaxTbWidth = $MaxPicWidth + 6; $MaxTbHeight = $MaxPicHeight + 6;
$MaxSaveCount = $cs_iconv_max; $kprof = $cs_kprof;
$stdtime = $cs_stdtime; $err_color = $cs_err_color;
$bgcolor = $cs_bgcolor; $ctch = $cs_ctch;
$text = $cs_text; $saycolor_check = $cs_saycolor_check;
$link = $cs_link; $secret_check = $cs_secret_check;
$vlink = $cs_vlink; $lieip_check = $cs_lieip_check;
$alink = $cs_alink; $punish_check = $cs_punish_check;
$hlink = $cs_hlink; $clear_on = $cs_clear_on;
$cut_on = $cs_cut_on; $usricon = $cs_user_icn;
$fukidasi = $cs_fukidasi; $rbl = $cs_rbl;
$kossori = $cs_kossori; $senyou = $cs_senyou;
$background = $cs_background; $lock_check = $cs_lock_check;
$logo = $cs_logo; $reloadcnt = $cs_reloadcnt;
$b_text = $cs_b_text; $ipcomout = $cs_ipcomout;
$b_bgcolor = $cs_b_bgcolor; $romer = $cs_romer;
$b_border = $cs_b_border; $romcount = $cs_romcount;
$form_bg = $cs_form_bg; $xrom = $cs_xrom;
$form_tx = $cs_form_tx; $firewall = $cs_firewall;
$home_k = $cs_home_k; $kickrom = $cs_kickrom;
$form_bd = $cs_form_bd; $trueip = $cs_trueip;
$notice = $cs_notice; $icq_uin = $cs_icq_uin;
$notice_color = $cs_notice_color; $icq_img = $cs_icq_img;
$bgcolor2 = $cs_bgcolor2; $xwords = $cs_xwords;
$text2 = $cs_text2; $x_tag = $cs_x_tag;
$x_namez = $cs_x_namez; $omi_icon = $cs_omi_icon;
$chktext = $cs_chktext;
$icondir = $cs_icondir; $adicon = $cs_adicon;
$pri_icon = $cs_pri_icon; $fkidir = $cs_fkidir;
$fki_col = $cs_fki_col; $dfki = $cs_dfki;
$link2 = $cs_link2; $logo =~ s/&quot;/"/g;
$vlink2 = $cs_vlink2; $logo =~ s/&gt;/>/g;
$alink2 = $cs_alink2; $logo =~ s/&lt;/</g;
$icq_uin =~ s/ //g; $icq_img =~ s/ //g;
$omi_icon = $icondir . "\/" . $omi_icon;
$ktai_seigen = $cs_ktai_seigen;
$senyou = '' if(!$usricon);
$title ||= 'TeaChat'; $vlink2 ||= '#663333';
$log_max ||= '1000'; $alink2 ||= '#660066';
$rank_max ||= '1000'; $hlink2 ||= '#660066';
$rank_mini ||= '5'; $stdtime ||= '0';
$bgcolor ||= '#663333'; $cs_notice_style ||= 'on';
$text ||= '#fce9c3'; $link ||= '#deb887';
$vlink ||= '#deb887';
$alink ||= '#deb887'; $defa_space = 0 if($defa_space eq "");
$hlink ||= '#deb887'; $ipcomout = 2 if($ipcomout eq "");
$ipcolor ||= '#663333'; $secret_check = 1 if($secret_check eq "");
$err_color ||= '#dc143c'; $cs_chatmaxlength ||= 1000;
$notice ||= 'お知らせ'; $b_text ||= '#fce9c3';
$notice_color ||= '#804040'; $b_bgcolor ||= '#663333';
$bgcolor2 ||= '#fce9c3'; $b_border ||= '#fce9c3';
$text2 ||= '#003366'; $form_bg ||= '#ffffff';
$link2 ||= '#663333'; $form_tx ||= '#663333';
$cs_timestyle ||= 1; $form_bd ||= '#fce9c3';
$cs_hr_b_color ||= '#808080'; $cs_hr_b_style ||= 'solid';
$cs_allclear ||= 'allclear'; $cs_use_ranking = 1 if $cs_use_ranking eq "";
$cs_showua = 1 if(!$cs_showua eq "");
$cs_ipsize = '80' if(!$cs_ipsize || $cs_ipsize < 2);
$cs_f_size = '100' if(!$cs_f_size || $cs_f_size < 2);
$cs_ipfont ||= 'Osaka,Verdana';
$cs_font ||= 'MS UI Gothic,Osaka';
$logo ||= '<font face="arial, helvetica"><b>TeaChat</b></font>';
$x_tag ||= 'img|--|!--|applet|basefont|bgsound|body|em|embed|form|frame|head|html|iframe|input|isindex|listing|meta|nobr|noscript|object|plaintext|pre|script|span|table|xmp';
$enter_mes ||= '<b><font size="4" color="[NAME_COLOR]">[NAME]</font><font color="#804040">さんが入室されました。</font></b>';
$leave_mes ||= '<b><font size="4" color="[NAME_COLOR]">[NAME]</font><font color="#804040">さんが退室されました。</font></b>';
# @x_namez = split(/\|/, $x_namez);
@enter_mes = split(/\t/, $enter_mes);
@leave_mes = split(/\t/, $leave_mes);
$cs_use_scrollbar ||= 0;
$cs_srl1_face ||= $b_bgcolor;
$cs_srl1_base ||= $b_border;
$cs_srl1_highlight ||= $b_border;
$cs_srl1_shadow ||= $b_border;
$cs_srl1_arrow ||= $b_border;
$cs_srl2_face ||= $b_border;
$cs_srl2_base ||= $b_border;
$cs_srl2_highlight ||= $b_bgcolor;
$cs_srl2_shadow ||= $b_bgcolor;
$cs_srl2_arrow ||= $b_bgcolor;
$cs_y_mark ||= 0;
# for TPJ
if($script =~ /tripod.co.jp/){
$lock_check = 0;
$firewall = 0;
}
$kossori = 0 if($kossori < 0);
$kossori = 100 if($kossori > 100);
}
# -------------------------------------------------------------
#.デコード処理
sub xdecode{
if($ENV{'REQUEST_METHOD'} eq "POST"){ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); }
else{ $buffer = $ENV{'QUERY_STRING'}; }
@pairs = split(/&/,$buffer);
foreach (@pairs) {
local ($vn, $value) = split(/=/, $_);
$vn =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/\t/ /g;
# $value =~ s/\n//g;
# $value =~ tr/\x0D\x0A//d;
$value =~ s/\cM//g;
$value =~ s/</&lt;/g;
$value =~ s/>/&gt;/g;
$value =~ s/"/&quot;/g;
from_to($value, 'cp932', 'utf8') if($ktai_sj && $Eflag);
from_to($vn, 'cp932', 'utf8') if($ktai_sj && $Eflag);
Jcode::convert(\$value, 'utf8', 'sjis') if($ktai_sj && $Jflag);
Jcode::convert(\$vn, 'utf8', 'sjis') if($ktai_sj && $Jflag);
if($vn eq "ID"){
$DELETE_ID{$value} = 1;
}else{
$FORM{$vn} = $value;
}
if(($vn =~ m/^kl_delete/) && ($FORM{$vn} eq "on")){
$vn =~ tr/+/ /;
$vn =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$vn =~ s/kl_delete\:\://;
push(@kl_delete, $vn);
$kl_del_flag = 1;
}
}
$cookie = $FORM{'cookie'}; $name = $FORM{'name'};
$first = $FORM{'first'}; $name =~ s/ /_/g;
$name =~ s/:/:/g; $orgname = $name;
$name =~ s/退席中//g; $url = $FORM{'url'};
$namae = $FORM{'namae'}; $kosr = $FORM{'kosr'};
$enter = $FORM{'enter'}; $name = $host if(!$name);
$email = $FORM{'email'}; $exit = $FORM{'exit'};
$email = '' if(!(($email =~ /(.*)\@(.*)\.(.*)/) || ($email =~ /http:\/\//)));
$email =~ s/ /_/g; $rank = $FORM{'rank'};
$view = $FORM{'view'}; $cc = $FORM{'cc'};
$f_color = $FORM{'f_color'}; $iconpass = $FORM{'iconpass'};
$relb = $FORM{'relb'}; $window = $FORM{'window'};
$change = $FORM{'change'}; $window = 20 if(!$window);
$nof = $FORM{'nof'}; $reload = $FORM{'reload'};
$nofent = $FORM{'nofent'}; $reload = 0 if(!$reload);
$administer = $FORM{'administer'}; $n_color = $FORM{'n_color'};
$pass = $FORM{'pass'}; $n_color2 = $FORM{'n_color2'};
$adexe = $FORM{'adexe'}; $s_color = $FORM{'s_color'};
$n_color =~ s/ //g; $n_color2 =~ s/ //g;
$s_color =~ s/ //g; $s_color =~ s/\n//g;
$n_color = $text2 if($n_color =~ /[^\w#]/);
$n_color2 = $text2 if($n_color2 =~ /[^\w#]/);
$s_color = $text2 if($s_color =~ /[^\w#]/);
$unlock = $FORM{'unlock'}; $greet = $FORM{'greet'};
$chkspam = $FORM{'chkspam'}; $chat = $FORM{'chat'};
$chat =~ s/\n//g; $greet =~ s/\n//g;
$email =~ s/\n//g; $n_color2 =~ s/\n//g;
$name =~ s/\n//g; $n_color_code = $n_color2;
$f_color =~ s/\n//g; $relsum = $FORM{'relsum'};
$f_color =~ s/\%h/#/g; $s_host = $FORM{'s_host'};
if($FORM{'usetag'} eq "on"){
$chat =~ s/&lt;/</g;
$chat =~ s/&gt;/>/g;
$chat =~ s/&quot;/"/g;
}
if($fukidasi){
($fcolor_value, $fcolor_file) = split(/!/, $f_color);
}
if (!$fcolor_value) {
$fcolor_value = $fki_col;
$fcolor_file = $dfki;
}
$icon = $FORM{'icon'}; $auto = $FORM{'auto'};
$secret = $FORM{'secret'}; $e_host = $FORM{'e_host'};
$secret2 = $FORM{'secret2'}; $ncsame = $FORM{'ncsame'};
$hidden = $FORM{'hidden'}; $high = $FORM{'high'};
$secret3 = $FORM{'secret3'}; $sechide = $FORM{'sechide'};
$customize = $FORM{'customize'}; $ctz_exe = $FORM{'ctz_exe'};
$k_tairom = $FORM{'k_tairom'}; $ktairank = $FORM{'ktairank'};
$xrom_flag = $FORM{'xrom_flag'}; $inlog_sec_send = $FORM{'inlog_sec_send'};
$s_host =~ s/&lt;/</g; $s_host =~ s/&gt;/>/g;
# 携帯の時のパケ代対策
# 区切り文字$k_splitcharで区切られている各変数を分割
# 退室時は「0.退室」が変数exitにセットされて来るのでそれを判別
# by Gprog.さん
if($ktai_ua && $FORM{'imode'}){
$imode = $FORM{'imode'};
($name,$namae,$view,$window,$n_color,$icon,$filecheck,$lastreload,$ktai_id) = split(/$k_splitchar/,$imode);
if($FORM{'exit'} =~ m/^0\./){
$chat = "exit";
$exit = "on";
}
$orgname = $name;
}
if (($icon eq "i") && !$sphone) { $icon = $icondir . "\/" . $pri_icon; }
}
sub xdecode2{
$n_color = $n_color2 if($n_color2);
$n_color = "$text2" if(!$n_color);
if(!$s_color){
if($ncsame){ $s_color = $n_color; }
else{ $s_color = $text2; }
}
elsif($s_color && $ncsame){ $s_color = $n_color; }
}
sub xdecode3{
$_[0] =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$_[0];
}
sub xencode{
$_[0] =~ s/([^0-9A-Za-z_ ])/'%'.unpack('H2',$1)/ge;
$_[0] =~ s/\s/+/g;
$_[0];
}
# -------------------------------------------------------------
#.参加者表示
sub member{
open(MEM,"+<$mem_file") || &error(5);
flock(MEM,2);
@lastmember = <MEM>;
$filesize = -s $chat_file;
$flag = 1;
$alert_flag = 0;
$now_mem = 0;
#..mem.datのフラッシュ
foreach (@lastmember){
my ($mtime, $name2, $host2, $n_color3, $last_mem, $lastsize, $k_list, $invisible, $ktai, $ktai_id2, $relsum2) = split(/\t/, $_);
$ktai_id2 =~ tr/\x0D\x0A//d;
if($exit && ($name2 eq $name)){
$flag = 0;
next;
# 退室する場合は自分のデータを削除。
}
if($time-300 > $mtime){
next;
# 5分以上前の参加者は削除
}
elsif(($host2 eq $host) || ($name2 eq $name)){
if($FORM{'admin_alert'} && ($pass eq $password)){
$invisible = 'invisible'
}
else{
$invisible = '';
}
push(@member,"$mtime\t$name2\t$host2\t$n_color3\t$last_mem\t$lastsize\t$k_list\t$invisible\t$ktai\t$ktai_id2\t$relsum\n") if($flag);
$flag = 0;
# 5分以内の参加者で本人なら追加。ホスト、又は名前で本人判定
}
else{
push(@member,$_);
}
}
$invisible = 'invisible' if($FORM{'admin_alert'} && ($pass eq $password));
push(@member,"$time\t$name\t$host\t$n_color\t$now_mem\t$filesize\t\t$invisible\t$ktai_ua\t$ktai_id\t$relsum\n") if($flag);
# 参加者ファイルの中に自分がいない場合は追加
#..各配列に格納
foreach (@member){
my ($mtime, $name2, $host2, $n_color3, $last_mem, $lastsize, $k_list, $invisible, $ktai, $ktai_id2, $relsum2) = split(/\t/, $_);
$ktai_id2 =~ tr/\x0D\x0A//d;
my $ktai_mark = '*' if $ktai;
my $taiseki = '(退席中)' if($relsum2 > 600);
if($invisible ne 'invisible'){ # 管理モードからのアクセス監視の場合は配列格納しない。
if(!$romer){ # 通常参加者表示時
if($name2 ne $host2){
if($kprof && $orgname && !$ktai_ua){
$xname2 = $name2;
$xname2 =~ s/(@(.+)|\@(.+))// if ($xname2=~ /@|\@/);
$xname2 = $name2 if(!$xname2);
from_to($xname2, 'utf8', 'euc-jp') if($Eflag);
Jcode::convert(\$xname2, 'euc', 'utf8') if($Jflag);
&xencode($xname2);
push(@mem_num,"<a href=\"$kprof?mode=view\;name=$xname2\" target=\"_blank\"><font color=\"$n_color3\">$name2$taiseki$ktai_mark</font></a> ");
} else {
push(@mem_num,"<font color=\"$n_color3\">$name2$taiseki$ktai_mark</font> ");
}
}
# ホスト名と名前が異なる場合参加者配列にいれる
push(@rom_num, "<font color=\"$n_color3\">$name2$ktai_mark</font> ") if($name2 eq $host2);
# ROMはROM表示用配列にいれる
}
else{ # Access表示時
push(@mem_num,"<font color=\"$n_color3\">$name2$ktai_mark</font> ");
# $name2がホスト名(ROM)でも参加者配列にいれる(ROM表示モード)
}
}
if($secret || $inlog_sec_send){
if(($name2 ne $host2) && ($name2 ne $name)){
push(@sec_mem,"<option value=\"$host2:$name2\">$name2$ktai_mark\n");
push(@teleg_list, "$host2<s>$name2");
$teleg_list = join("<>", @teleg_list);
}
# 自分を除く参加者を電報用参加者配列に加える
}
$now_mem++ if($name2 ne $host2);
# 参加人数変化アラート用、人数カウント
}
#..現在人数とファイルサイズをフラッシュ
foreach (@member){
my ($mtime, $name2, $host2, $n_color3, $last_mem, $lastsize, $k_list, $invisible, $ktai, $ktai_id2, $relsum2) = split(/\t/, $_);
$ktai_id2 =~ tr/\x0D\x0A//d;
if(($host2 eq $host) || ($name2 eq $name)){
$alert_flag = 1 if($now_mem > $last_mem);
# 人数の増加が確認できればアラート
$filesize_flag = 1 if($filesize ne $lastsize);
#ファイルサイズが異なっていたらフラグを立てる
if($kl_del_flag){
%seen2 = ();
@my_kick_list_true = ();
@now_kick_list = split(/<>/, $k_list);
foreach (@kl_delete) {
$seen2{$_} = 1;
}
foreach (@now_kick_list) {
if(!$seen2{$_}){
push(@my_kick_list_true, $_);
$seen2{$_} = 1;
}
}
$k_list = join("<>", @my_kick_list_true);
# 無視リスト削除処理
}
else{
if($FORM{'add_kick_list'}){
if($k_list){ $k_list = $k_list . "<>$FORM{'add_kick_list'}"; }
else{ $k_list = $FORM{'add_kick_list'}; }
}
# 無視リスト追加。
}
@my_kick_list = split(/<>/, $k_list);
# 自分の無視リストを配列に格納
$_ = "$time\t$name\t$host\t$n_color\t$now_mem\t$filesize\t$k_list\t$invisible\t$ktai\t$ktai_id\t$relsum\n";
# 現在人数を記録
}
else{
push(@kicklist_array, "$host2:$name2") if($host2 ne $name2);
# 自分を除く参加者を無視リスト候補配列に加える
}
}
unless($FORM{'nocount'} && ($pass eq $password)){
truncate(MEM,0);
seek(MEM,0,0);
print MEM @member;
}
close(MEM);
}
# -------------------------------------------------------------
#.発言ランキング書き込み
sub rank_write{
open(RANK,"+<$status_file") || &error(2);
flock(RANK, 2);
@rank = <RANK>;
$point = shift(@rank);
my ($sec, $min, $hour, $mday, $mon, $year, $wday) = localtime(time);
my ($daily, $weekly, $monthly, $l_daily, $l_weekly, $l_monthly, $hizuke, $week, $tsuki, $w_member, $active) = split(/\t/, $point);
$w_member =~ tr/\x0D\x0A//d;
$active =~ tr/\x0D\x0A//d;
if($hizuke != $mday){
$l_daily = $daily;
$daily = 0;
$w_member = 0;
foreach (@rank){
my ($r_icon, $r_name, $r_point, $r_time) = split(/\t/, $_);
my $Oneweekbefore = $time - 7*24*60*60;
$w_member++ if($r_time > $Oneweekbefore);
}
}
else { $daily++; }
if($week > $wday){
$l_weekly = $weekly;
$weekly = 0;
}
else { $weekly++; }
if($tsuki != $mon){
$l_monthly = $monthly;
$monthly = 0;
}
else { $monthly++; }
$hizuke = $mday;
$week = $wday;
$tsuki = $mon;
$active = "$hour:$min" if($FORM{'cdb_active'} eq "on" && ($pass eq $password));
$point2 = "$daily\t$weekly\t$monthly\t$l_daily\t$l_weekly\t$l_monthly\t$hizuke\t$week\t$tsuki\t$w_member\t$active\n";
$rank2 = @rank;
my @sorted_array = undef;
if($rank2 > $rank_max){
@sorted_array = my_sort(\@rank, 3);
# 現在の最大発言数を調べる。。。
# my @high = my_sort(\@rank, 1);
# my $highpoint = shift(@high);
# my @tmp = split /\t/, $highpoint;
# $tmp[1] に現在の発言数の第一位の値が入るはず
pop(@sorted_array); # 最終発言時刻の古いものから削除する
}
@sorted_array = @rank unless $#sorted_array;
$flag = 1;
foreach (@sorted_array){
my ($ricon,$handle,$rvalue,$rtime) = split /\t/;
chomp($rtime);
next if($handle ne $namae);
$rvalue++;
$flag = 0;
$_ = "$icon\t$namae\t$rvalue\t$time\n";
last;
}
push(@sorted_array, "$icon\t$namae\t1\t$time\n") if $flag;
unshift(@sorted_array,$point2);
truncate(RANK,0);
seek(RANK,0,0);
print RANK @sorted_array;
close(RANK);
}
# -------------------------------------------------------------
#.n番目のフィールドで配列をソートする
# ※0番目から数えた順番
#
# Schwartzian Transform
sub my_sort{
my ($array, $n) = @_;
my (@array);
my @sorted_list =
map { $_->[0] }
sort { $b->[1] <=> $a->[1] } # ASCIIではなく数値ソート
map { [$_, (split /\t/)[$n]] } # $n番目のフィールドでソート
@{$array};
return @sorted_list;
}
# -------------------------------------------------------------
#.メール送信
# この機能はまうさん、通りすがりさんの処理を参考にさせていただきました。m(_ _)m
sub mail_send{
&time($time);
my $body = <<EOF;
\[$date_i\]
$titleに入室者がありました。
入室者:$nameさん
EOF
from_to($body, 'utf8', 'iso-2022-jp') if($Eflag);
Jcode::convert(\$body, 'jis', 'utf8') if($Jflag);
open (MAIL,"| $cs_sendmailpath -t") or error("sendmailのオープンに失敗しました。パスを確認してください。");
print MAIL "To: $cs_mailto\n";
print MAIL "From: $cs_mailto\n";
print MAIL "Subject: TeaChat Mail Alert\n";
print MAIL "MIME-Version: 1.0\n";
print MAIL "Content-type: text/plain; charset=ISO-2022-JP\n";
print MAIL "Content-Transfer-Encoding: 7bit\n";
print MAIL "X-Mailer: TeaChat Mail Alert\n\n";
print MAIL $body;
close (MAIL);
}
# -------------------------------------------------------------
#.名前のチェック
sub haijo{
@x_namez = split(/\|/, $x_namez);
$x_namez_cnt = @x_namez;
if($x_namez_cnt){
my $namae_euc = $namae;
foreach (@x_namez){
&error(14) if($namae_euc eq $_);
}
}
if($name_max) {
my $xnamae = $namae;
if ($Eflag) {
utf8::decode($xnamae);
$xname_max = $name_max;
} else {
$xname_max = $name_max * 3;
}
my $lenamae = length($xnamae);
&error(22) if($lenamae > $xname_max);
}
}
# -------------------------------------------------------------
#.公開プロクシ禁止モード
sub rbl_check{
my $remote_ip = $_[0];
my $dsbl_ip = join(".", reverse split /\./, $remote_ip) . "." . $dnsbl;
my $rip = gethostbyname($dsbl_ip);
if ($rip) {
&error(17);
}
}
# -------------------------------------------------------------
#.専用アイコンチェック
sub iconchk{
if ($senyou && ($iconpass ne $password)) {
require "$pup_pl";
&MakeIconSet;
if(@iconu2){
foreach (0 .. $#iconu2){
my $icon_value = $icon_url . "\/" . $iconu2[$_];
if ($icon eq $icon_value) {
my $match = &DeCodeKey($iconpass,$ico_pass[$_]);
if ($match ne 'yes') { &error(18); }
}
}
}
}
}
# -------------------------------------------------------------
#.携帯のシリアル取得
sub ktai_sr{
my($ser, @user);
if ($hua =~ /DoCoMo/i) {
@user = split '/' , $hua;
$user[-1] =~ /(?:^|;)ser([a-zA-Z0-9]+)/;
if (length($1) == 11) {
# $ser = $1;
$ser = $user[-1];
$hua =~ s/\/$ser//g;
}elsif (length($1) == 15) {
for(split(/[\(\)\s;]+/ , $user[-1])){
if(/^ser.{15}$/){
$ser = $_;
}
}
$hua =~ s/;$ser(.+)\)/\)/g;
}
} elsif ($hua =~ /^KDDI|^UP\.Browser/i) {
$ser = $ENV{HTTP_X_UP_SUBNO};
$ser =~ s/\.ezweb\.ne\.jp//g;
} elsif ($jphone) {
if($hua =~ /\/SN([A-Za-z0-9]+)\ /){
$ser = $1;
}
$hua =~ s/$ser\s//g;
}
if (!$ser) { &error(21); }
return $ser;
}
# -------------------------------------------------------------
#.電報の暗号化
sub StringEncode{
my($comment, $i, $j, @key, %pcp_table);
$comment = $_[0];
$comment .= "\0" if (length($comment) % 2);
@key = split(//, $key);
$i = 0;
$j = MakeTable($key, \%pcp_table);
$comment =~ s/./sprintf("%03o",ord($&)^(ord($key[$i++ % @key])+($j++ % 383)))/ges;
$comment =~ s/../$pcp_table{$&}/g;
return $comment;
}
# -------------------------------------------------------------
#.電報の復号化
sub StringDecode{
my($comment, $i, $j, @key, %pcp_table);
$comment = $_[0];
@key = split(//, $key);
$i = 0;
$j = MakeTable($key, \%pcp_table);
$comment =~ s/./$pcp_table{$&}/g;
$comment =~ s/.../sprintf("%c",oct($&)^(ord($key[$i++ % @key]) +($j++ % 383)))/ges;
$comment =~ s/\0$//;
return $comment;
}
# -------------------------------------------------------------
#.暗号テーブルの作成
sub MakeTable{
my(@list, $i, $j, $k, $init_j, @key, @seed, %pcp_table, $pcp_table);
@seed = split(//, 'Hw9WihKQ1Y8NbzuE4mXraM2.snF7ZpIq6xv5goRBecP!jVO3DkCU0ldLGftTASJy');
@key = split(//, $_[0]);
$pcp_table = $_[1];
$k = @key;
$init_j = 0;
for($i = 0; $i < 64; $i++){
$j = ord($key[$i % $k]);
$init_j += $j;
$list[$i] = splice(@seed,(($j+$k) % (64-$i)),1);
}
$k = 0;
for($i = 0; $i < 8; $i++){
for($j = 0; $j < 8; $j++, $k++){
$$pcp_table{"$i$j"} = $list[$k];
$$pcp_table{$list[$k]} = "$i$j";
}
}
return ($init_j % 383);
}
# -------------------------------------------------------------
#.携帯の日本語コード変換
sub ktai_enc{
if ($Eflag == 1) {
from_to($_[0], 'utf8', 'cp932', FB_XMLCREF);
} elsif($Eflag == 2) {
from_to($_[0], 'utf8', 'cp932');
}
elsif ($Jflag) {
Jcode::convert(\$_[0], 'sjis', 'utf8');
}
$_[0];
}
# -------------------------------------------------------------
#.スタイルシート
sub css{
if($view eq "on" && !$exit && !$rank && !$secret){
$link = $link2;
$vlink = $vlink2;
$alink = $alink2;
$hlink = $hlink2;
$cs_srl1_face = $cs_srl2_face;
$cs_srl1_base = $cs_srl2_base;
$cs_srl1_highlight = $cs_srl2_highlight;
$cs_srl1_shadow = $cs_srl2_shadow;
$cs_srl1_arrow = $cs_srl2_arrow;
if($hua !~ /MSIE 3/i){
$mbstyle = "a\:hover \{ color\: $hlink\; text-decoration\: underline\; \}\na\:hover \.mb \{ color\: $hlink\; text\-decoration\: underline\; \}";
}
}
else{
$mbstyle = "a\:hover \{ color\: $hlink\; text-decoration\: underline\; \}" if($hua !~ /MSIE 3/i);
}
$css_ie = "\n.i_text \{ color\: $form_tx\; background-color\: $form_bg\; border\: 1px solid $form_bd\; \}\n\.bttn \{ color: $b_text\; background\-color\:$b_bgcolor\; border\: 1px solid $b_border\; cursor: hand; \}";
$css_ie = '' if($hua !~ /MSIE|Cuam|Opera|Gecko/i);
$cs_ipsize2 = $cs_ipsize."%";
$cs_f_size2 = $cs_f_size."%";
if($hua =~ /Opera/i){
$linecss = "\n.line { border: 0px $cs_hr_b_style $cs_hr_b_color; margin: 7px; height: 1px; width: 100%; }";
}
elsif($hua =~ /MSIE/i){
$linecss = "\n.line { border: 1px $cs_hr_b_style $cs_hr_b_color; margin: 1px; height: 0px; width: 100%; }";
}
elsif($hua =~ /Mac_PowerPC/i){
$linecss = "";
}
if($cs_use_scrollbar){
$scrl =<<"_SCRL_";
scrollbar-arrow-color: $cs_srl1_arrow;
scrollbar-face-color: $cs_srl1_face;
scrollbar-base-color: $cs_srl1_base;
scrollbar-track-color: $cs_srl1_base;
scrollbar-highlight-color: $cs_srl1_base;
scrollbar-dark-shadow-color: $cs_srl1_base;
scrollbar-shadow-color: $cs_srl1_shadow;
scrollbar-3dlight-color: $cs_srl1_highlight;
_SCRL_
}
print <<"EOF";
<style type="text/css"><!--
body {
font-family: $cs_font; font-size: $cs_f_size2;
$scrl
}$linecss
.fface { color: $ipcolor; font-family: $cs_ipfont; font-size: $cs_ipsize2; }
a:link { color: $link; text-decoration: none; }
a:visited { color: $vlink; text-decoration: none; }
a:active { color: $alink; text-decoration: underline; }
$mbstyle
a.userlink:link { color: $link; text-decoration: underline; }
a.userlink:visited { color: $vlink; text-decoration: none; }
a.userlink:active { color: $alink; text-decoration: underline; }
a.userlink:hover { color: $hlink; text-decoration: none; }$css_ie
--></style>
EOF
}
# -------------------------------------------------------------
#.エラー処理
sub error{
my $num = shift;
if($num =~ /[^\d]/){
$msg = $num;
}
else{
$msg = (
'0', # 0
'チャットファイルが開けません', # 1
'ランキングファイルが開けません', # 2
'名前が入力されていません', # 3
'他ページからの書き込みは出来ません', # 4
'参加者ファイルが開けません', # 5
'カウンタファイルが開けません', # 6
'初期設定・ホスト置換ファイルが開けません', # 7
'アクセス制限ファイルが開けません', # 8
'参加者ファイルが開けません', # 9
'色データファイルが開けません', # 10
'顔文字・文字色ファイルが開けません', # 11
'現在、指定されたホスト以外のアクセスは許可されておりません', # 12
'名前が未入力です', # 13
'名前が不正です。入力された名前は現在禁止されています', # 14
'メールアドレス、またはパスワードが不正です', # 15
'名前に半角@が含まれています', # 16
'現在、公開PROXYからのアクセスを制限しています', # 17
'専用アイコンパスが違います', #18
'必須項目が指定されていません', #19
'SPAM防止用合言葉が間違っています', #20
'端末シリアル番号が未送信または不正です', #21
'名前は' .$name_max. '文字以内にしてください', #22
)[$num];
}
if($msg eq "0"){ # アクセス制限の時
print "Content-type: text/html\n\n";
print qq(<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<HTML><HEAD>\n<TITLE>403 Forbidden</TITLE>\n);
print qq(</HEAD><BODY>\n<H1>Forbidden</H1>\nYou don't have permission to access /chat.cgi\n);
print qq(on this server.<P>\n<HR>\n<ADDRESS>Apache/1.3.14 Server Port 80</ADDRESS>\n</BODY></HTML>);
exit;
}
&ktai_enc($msg) if($ktai_sj);
&http_header;
&css;
print qq(</head>\n);
print qq($body>\n);
print qq(<center><font size="4"><b>ERROR!</b></font><br><br>$msg</center>\n);
print qq(</body></html>\n);
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment