■
昨日に引き続き
axscheck,error,headderと
頑張りました。
しかし、KENTさんの掲示板って、もっとシンプルで分かりやすかったと思ってたけど
結構、複雑です。
#!/usr/local/bin/ruby $host = '' $addr = '' $deny_addr = '' $deny_host = '' $headflag = nil $title = '掲示板のテスト' $body = '<body>' def axscheck # IP&ホスト取得 $host = ENV['REMOTE_HOST'] $addr = ENV['REMOTE_ADDR'] # if $gethostbyaddr && ($host == "" || $host == $addr) # a = Socket.gethostbyname($addr) # $host = Socket.gethostbyaddr(a[3], a[2]) # end ちょっとエラーがでますワラ # IPチェック flg = nil $deny_addr.split(/\s+/).each {|l| l = l.gsub(/\./,"\\\.") l = l.gsub(/\*/,"\.\*") if /^#{l}/i =~ $addr flg = 1 end } if flg error("アクセスを許可されていません") end # ホストチェック $deny_host.split(/\s+/).each {|l| l = l.gsub(/\./,"\\\.") l = l.gsub(/\*/,"\.\*") if /^#{l}/i =~ $host flg = 1 end } if flg error("アクセスを許可されていません") end $host = $addr if $host == '' end def error(msg) header print <<EOM; <div align="center"> <hr width="400"> <h3>ERROR !</h3> <font color="#dd0000">#{msg}</font> <br> <form> <input type="button" value="前画面に戻る" onclick="history.back()"> </form> <hr width="400"> </div> </body> </html> EOM exit end def header return if $headflag print "Content-type: text/html\n\n" print <<"EOM" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html lang="ja"> <head> <meta http-equiv="content-type" content="text/html; charset=shift_jis"> <meta http-equiv="content-style-type" content="text/css"> <style type="text/css"> <!-- body,td,th { font-size:$bSize; font-family:$bFace } .tbl { background-color:#ffffff; color:#000000; } --> </style> <title>#{$title}</title> </head> #{$body} EOM $headflag = 1 end axscheck header print <<END_HTML <H1>BBS test</H1> <P>REMOTE_HOST= #{$host}</P> <P>REMOTE_ADDR= #{$addr}</P> </BODY> </HTML> END_HTML