List of bbs-ex0/bbs-w.cgi

Mon Dec 10 10:44:51 2018

戻る

TEXTAREA で表示(カット&ペーストむき)

#!/usr/local/bin/perl5

# bbs-w.cgi
# 1997/09/01 Ver.0.00
# 1997/09/06 Ver.0.01
# 1997/09/08 Ver.0.02
# 1997/09/09 Ver.0.03
# 1997/11/10 Ver.0.04  error の location の飛び先を修正 他
# 2000/01/06 Ver.0.05 Y2K 対応
#
# (C) 1997 がま 
# e-mail addr : gama@mvg.biglobe.ne.jp

# --------------------------------------------------------

$file   ="bbs.dat";
$fctr   ="bbs-ctr.dat";
$bbswhtm="/~gama/cgi/bbs-ex0/bbs-w.htm";
$bbsname="掲示板のための習作";

# --------------------------------------------------------
$ct = $ENV{"CONTENT_TYPE"};
$cl = $ENV{"CONTENT_LENGTH"};

# --------------------------------------------------------
if ( $ct ne "application/x-www-form-urlencoded")  {
        print "Location: $bbswhtm\n\n";
        exit;
}

# YY/MM/DD hh:mm------------------------------------------
($sec,$min,$hour,$mday,$mon,$year)=localtime;
$time = sprintf "%2.2d\/%2.2d\/%2.2d  %2.2d:%2.2d",
        $year%100,$mon+1,$mday,$hour,$min;

# --------------------------------------------------------
read(STDIN, $in, $cl);

($name,$email,$hp,$title,$comment) = split("&",$in);

$name   = &str_decode($name);
$email  = &str_decode($email);
$hp     = &str_decode($hp);
$title  = &str_decode($title);
$comment= &str_decode($comment);
$comment=~ s/\n/<BR>\n/g;

# 発言 # のカウント --------------------------------------
open(FCTR,"+<$fctr");
$no=<FCTR> + 1;
seek(FCTR, 0, 0);
printf(FCTR "%d", $no);
close(FCTR);

# --------------------------------------------------------
# #801/900 掲示板のための習作
# ★タイトル (ABC12345)  97/09/06  22:58  ( 16)
# PC−VAN風の体裁であります・・・・・     がま
# ★内容

$head1  = sprintf("#%s %s\n<BR>\n",    $no,$bbsname);

$head2  = sprintf("★タイトル (<A HREF=\"mailto:%s\">%s</A>) %s<BR>\n",
                        $email,$name,$time);

$body   = sprintf("%s<BR>\n★内容<BR>\n%s<BR>\n",
                        $title,$comment);

$tail   = sprintf("<BR><A HREF=\"%s\">%s</A><BR>\n",
                        $hp,$hp);

# BBS ---------------------------------------------------

open(BBS,">>$file");

print(BBS $head1);                 # 内容
print(BBS $head2);                 # 内容
print(BBS $body);                  # 内容
print(BBS $tail);                  # 内容

print(BBS "\n<HR>\n");

close(BBS);

# HTML ---------------------------------------------------
print "Content-type: text/html\n\n";
print "<HTML>";
print "<HEAD><TITLE>書き込みが完了しました</TITLE></HEAD>";
print "<BODY BGCOLOR=\"#FFFFFF\">\n";
print "<H2>書き込みが完了しました</H2>";
print "<BLOCKQUOTE>\n";
print "<HR>\n";

print $head1;                  # 内容
print $head2;                  # 内容
print $body;                   # 内容
print $tail;                   # 内容

print "</BLOCKQUOTE>\n";
print "<HR>\n";
print "<CENTER>\n";
print "<A HREF=\"bbs-r.cgi\">読む</A>";
print "|<A HREF=\"index.htm\">戻る</A>";
print "</CENTER>\n";
print "<HR>\n";
print "</BODY>\n";
print "</HTML>\n";

# --------------------------------------------------------
sub str_decode {

        local($str)=$_[0];                      # サブルーチンの引数を

        $str=~ /=/;                             # = をさがして・・・
        $str=  $';				# その後ろ
        $str=~ s/\+/ /g;                        # + を space へ
        $str=~ s/%(..)/pack("c",hex($1))/ge;    # decode
        $str=~ s/&/&amp;/g;                     # &
        $str=~ s/</&lt;/g;                      # <
        $str=~ s/>/&gt;/g;                      # >
        $str=~ s/\r//g;                         #LF を削除

        return($str);
}

戻る