#!/usr/bin/perl # 設定ファイル $setfile = "./bbs.ini"; $logfile="./bbs.log"; { #$ENV{'REQUEST_METHOD'}='GET'; #$ENV{'QUERY_STRING'}='mode=17'; if(!$form{"mode"}){$postData=&get_PostData();} $hashref=&get_FormData($postData);%form=%$hashref; $ono=$form{"mode"}; if($ono) {&getcomment($ono);} print "main:$ono\n"; &set_file(); &html(); } # 設定処理 # sub set_file { # 設定ファイル読み込み # open(IN,"$setfile") || &error("Open Error : $setfile"); $data = ; close(IN); ($title,$t_color,$t_size,$ImgT,$bg,$bc,$tx,$lk,$vl,$al,$face,$b_size, $sub_color,$max,$home,$p_log,$deny,$mailto) = split(/<>/, $data); # ポイント数 $t_size .= 'pt'; $s_size = ($b_size - 1) . 'pt'; $b_size .= 'pt'; #文字数の設定 $f_name = 20; $f_sub = 25; $f_url = 45; $f_cols = 46; } # HTMLヘッダ # #--------------# sub header { $head_flag = 1; print "Content-type: text/html\n\n"; print <<"EOM"; $title EOM } sub html { &header; # クッキー情報を取得 &get_cookie; $action="regist"; if($ono){$action="update";} print <
おなまえ
Eメール
URL
タイトル

メッセージ
パスワード  
EOM print "\n\n"; } # クッキーを取得 # sub get_cookie { local($key, $val, @pairs); $cookies = $ENV{'HTTP_COOKIE'}; @pairs = split(/;/, $cookies); foreach (@pairs) { ($key, $val) = split(/=/); $key =~ s/\s//g; $tmp{$key} = $val; } @pairs = split(/,/, $tmp{'nBBS'}); foreach (@pairs) { ($key, $val) = split(/:/); $ck{$key} = $val; } $c_name = $ck{'name'}; $c_email = $ck{'email'}; $c_url = $ck{'url'}; $c_pwd = $ck{'pwd'}; if ($in{'name'}) { $c_name = $in{'name'}; } if ($in{'email'}) { $c_email = $in{'email'}; } if ($in{'url'}) { $c_url = $in{'url'}; } if ($in{'pwd'}) { $c_pwd = $in{'pwd'}; } } sub get_PostData{ my $data; if( $ENV{'REQUEST_METHOD'} eq 'GET' ) { $data = $ENV{'QUERY_STRING'}; } else { read( STDIN, $data, $ENV{'CONTENT_LENGTH'}); } return $data; } sub get_FormData{ my $data=shift; my @pair=split(/&/,$data); my %hash; my $key; foreach(@pair){ my($key,$value)=split(/=/); $hash{$key}=$value; #print "form:$key val:$value\n"; }; return \%hash; } sub getcomment{ open(IN,"$logfile") || &error("Open Error : $logfile"); $eline=shift; #print "getcomment:$eline\n"; @lines = ; close(IN); for($i=0;$i<@lines ;$i++){ ($tno,$tdate,$tname,$tmail,$c_sub,$c_comment) = split(/<>/, $lines[$i]); #print "getcomment:$tno\n"; if($tno eq $eline) { $c_comment =~ s/
/\n/g; #print "getcomment:$c_comment\n"; last; } } }