#!/usr/bin/perl ################################################################## # Program : gate.cgi(Perl) # Permission : 705 # Date_written : 2000/02/23 # Author : 良寛 # E-mail : ryokan@po.minc.ne.jp # HomePage : http://www.minc.ne.jp/~ryokan/ ################################################################## # -----注意事項--------------------------------------------------- # (1)このスクリプトはフリーソフトです。このスクリプトを使用した # いかなる損害に対して作者は一切の責任を負いません。 # (2)設置に関する質問は質問コーナーにお願いいたします。 # ---------------------------------------------------------------- $ver = 'GATE v1.0'; # バージョン require './jcode.pl'; #=== 設定(ここから)============================================= # $title = 'Gate'; # タイトル $password = "spaper"; # パスワード $gatecgi = "gate.cgi"; # このスクリプト名(フルパス可) $locate = "http://kuroppe.tagen.tohoku.ac.jp/~ecd/ecd.htm"; # 秘密のファイル $bgcolor = "FFFFFF"; # 背景色 $homepage =""; # トップページのURL # #=== 設定終了(ここまで)========================================= # クッキー取得 &get_cookie; # データ受信 if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { $buffer = $ENV{'QUERY_STRING'}; } # 受信データの編集 @buffer = split(/&/, $buffer); foreach $pair (@buffer) { local($name, $value) = split(/=/, $pair); $name =~ tr/+/ /; $name =~ 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//>/ig; $value =~ s/\r\n/
/g; $value =~ s/\n/
/g; $value =~ s/\r/
/g; $value =~ s/\,/,/g; &jcode'convert(*name,'sjis'); &jcode'convert(*value,'sjis'); &jcode'h2z_sjis(*value); $FORM{$name} = $value; } $pass = $FORM{'myName'}; $check = $FORM{'myCheck'}; if ($check eq ""){ $check="off";} # パスワードチェック if ($pass ne "" || $FORM{'submit'} eq "Enter"){ &set_cookie; if ($pass eq $password){ print "Location:$locate\n\n"; exit; }else{ &error_disp; } } &disp; exit; # 終了 #******************** SUBROUTINE ******************************* # # # パスワード間違い表示 sub error_disp { print "Content-type: text/html\n\n"; print <<"HTML"; もどる

Wrong password!


$pass


HTML exit; } # パスワード入力画面 sub disp { print "Content-type: text/html\n\n"; print "\n"; print "$title\n"; print "\n"; print "\n"; print "

\n"; print "

\n"; print "

\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; print "

Password?\n"; print "

\n"; if ($c_check eq "on" || $c_check eq "ON") { print "

\n"; print "

\n"; print "\n"; }else{ print "

\n"; print "

\n"; print "\n"; } print "Keep password

\n"; print "

\n"; print "\n"; print "

\n"; print "
\n"; print "\n"; print "
\n"; print "
\n"; ## 著作権を表示(削除禁止) print "
\n"; print "
\n"; print "\n"; } ## クッキーを発行 sub set_cookie { # クッキーは90日間有効 ($secg,$ming,$hourg,$mdayg,$mong,$yearg, $wdayg,$ydayg,$isdstg) = gmtime(time + 90*24*60*60); if ($yearg >= 100) { $yearg = $yearg - 100; } if ($yearg < 10) { $yearg = "0$yearg"; } if ($secg < 10) { $secg = "0$secg"; } if ($ming < 10) { $ming = "0$ming"; } if ($hourg < 10) { $hourg = "0$hourg"; } if ($mdayg < 10) { $mdayg = "0$mdayg"; } $month = ('Jan','Feb','Mar','Apr','May', 'Jun','Jul','Aug','Sep','Oct','Nov','Dec') [$mong]; $youbi = ('Sunday','Monday','Tuesday', 'Wednesday','Thursday','Friday','Saturday') [$wdayg]; $date_gmt = "$youbi, $mdayg\-$month\-$yearg $hourg:$ming:$secg GMT"; $cook="pass\:$pass\,check\:$check"; print "Set-Cookie: GATE=$cook; expires=$date_gmt\n"; } ## クッキーを取得 sub get_cookie { @pairs = split(/;/, $ENV{'HTTP_COOKIE'}); foreach $pair (@pairs) { local($name, $value) = split(/=/, $pair); $name =~ s/ //g; $DUMMY{$name} = $value; } @pairs = split(/,/, $DUMMY{'GATE'}); foreach $pair (@pairs) { local($name, $value) = split(/:/, $pair); $COOKIE{$name} = $value; } $c_pass = $COOKIE{'pass'}; $c_check = $COOKIE{'check'}; if ($pass) { $c_pass = $pass; } if ($check) { $c_check = $check; } }