#!/usr/bin/perl ##### YADChat版豪華絢爛チャット ##### ### $Id: kenranchat.cgi,v 1.5 2007/07/14 14:00:19 jyugoya Exp $ ### YADChat / 2007 © 結城由羅@世界忍者国 / BSD Lisence ### Kent-Webのcomchatの(ほぼ)互換品、をさらに書き換えたもの # バージョン番号 $ver = 'KENRANCHAT 1.2'; # 設定項目読み込み require './config.cgi'; # CGI関連処理ライブラリ読み込み require './cgilib.pl'; # KENRANCHAT ライブラリ require './kenranlib.pl'; ######################## ##### メイン処理部 ##### ######################## ##### CGIパッケージ ##### use CGI qw/:standard/; ##### グローバル変数 ##### # CGI オブジェクト $query = new CGI; # 入力データ解析 (グローバル変数) &checkInput(); # クッキーを取得 (グローバル変数) %CK = &getCookie($CONF{'cookiekey'}); # ダイスONならばダイス文字列置き換え if ( $CONF{'dicemode'} ) { if ($IN{'comment'} =~ /([1-9][0-9]*)[dD]([1-9][0-9]*)/) { local($dstr) = &dice($1, $2); $IN{'comment'} =~ s/[1-9][0-9]*[dD][1-9][0-9]*/$dstr/; } } # RP機能がONならば文字列にlogclearがあったらRPログ消去 if ( $CONF{'rplog'} ) { if ($IN{'comment'} =~ /^logclear$/) { &clearRPLog(); } } # 顔文字があれば、入力文字列に付記 if ( $IN{'face'} ne "" ) { $IN{'comment'} = "$IN{'comment'} $IN{'face'}"; } # クライアントのIPアドレスの取得 (グローバル変数) $client = $ENV{'REMOTE_ADDR'}; # 無名の場合はクライアントIPアドレスを名前とする if ($IN{'name'} eq "") { $IN{'name'} = $client; } # 時間を取得 $date = &getDate(); # トリップ変換 if ($CONF{'usetrip'} && $IN{'name'} =~ /(.*)(#|#)(.*)/){ $trip = &genTrip($1, $3); $tripped = "" . $name . "◆" . $trip; } else { $tripped = $IN{'name'}; $tripped =~ s/◆/◇/g; } # アクセス拒否チェック &checkDeny($client); # インデックスファイルから部屋タイトルを取得して上書き $CONF{'title'} = &getRoomTitle($IN{'room'}); # 部屋チェック if ($IN{'room'} ne "") { $datfile = $CONF{'datdir'}.'/'.$IN{'room'}.'.dat'; if (! -e $datfile) { $logfile = $CONF{'logdir'}.'/'.$IN{'room'}.'.html'; if (-e $logfile) { &printGoToLog(); } else { &printError("指定されたチャットルームはログも存在していません"); } } } else { &printError("部屋番号が指定されていません"); } # 軽量化ONによる動作分岐 if ($IN{'weight'} eq 'light') { if ($IN{'mode'} eq '' || $IN{'mode'} eq 'view' || $IN{'mode'} eq 'form') { &printEntryFormAndDat(); } elsif ($IN{'mode'} eq 'login' || $IN{'mode'} eq 'chat') { &printChatFormAndDat(); } elsif ($IN{'mode'} eq 'logout') { &printLogout($tripped); } else { &printError("そのようなモードは存在しません"); } } # mode による動作分岐 if ($IN{'mode'} eq '') { &printFrame(); } elsif ($IN{'mode'} eq 'view') { &viewDat(); } elsif ($IN{'mode'} eq 'form') { &printEntryForm(); } elsif ($IN{'mode'} eq 'login') { &printChatForm(); } elsif ($IN{'mode'} eq 'chat') { if ($IN{'comment'}) { &writeDat($IN{'mode'}); } &viewDat(); } elsif ($IN{'mode'} eq 'logout') { &printLogout($tripped); } else { &printError("そのようなモードは存在しません"); } ### Main処理終了 __END__