#!/usr/bin/perl # ↑あなたが加入しているプロバイダの「perl」言語が使用できる # パスを指定します。一般的に「#!/usr/local/bin/perl」で大丈夫 #======================================================================================= # WhatsNew Version 98.2 #======================================================================================= #日本語コード変換モジュール require 'jcode.pl'; #--------------------------------------- #メッセージを格納するデータベースファイル $datafile = 'whatsnew.txt'; #--------------------------------------- #バックグランドの画像ファイル $bg_gif = ''; #--------------------------------------- #区切り線 画像を使用しない場合は''にする $line_gif = ''; #--------------------------------------- #ワンポイント画像 $point_gif = 'image/bg_02.gif'; #--------------------------------------- #管理者削除モードのパスワード $password = 'g-babyg'; #--------------------------------------- #掲示板の名前 $title = 'Baby-G早耳ニュース'; #--------------------------------------- #バックグランドカラー $bg_color = '#ccffcc'; #テキストの文字色 $text_color = 'green'; #リンク文字色 $link_color = '#66CCFF'; #Vリンク文字色 $vlink_color = '#66CCFF'; #Aリンク文字色 $alink_color = '#66CCFF'; #題名の文字色 $subject_color = '#66CCFF'; #--------------------------------------- #保存する更新履歴(極端に多くするとパフォーマンスが低下します) $max = 100; #--------------------------------------- #1ページに表示する件数 $pagevew = 20; #--------------------------------------- #タグの使用 'yes' / 'no' $tag = 'no'; #--------------------------------------- #管理者登録用ボタンの表示 'yes' / 'no' $mntbutton = 'yes'; #--------------------------------------- #タグは自動で付けられるのでそれ以降のヘッダー部 $title_html = <<"TITLE_HTML_END";
⊂⊂⊂・Baby-G早耳ニュース・⊃⊃⊃
Baby-G探偵団 index
TITLE_HTML_END #======================================================================================= # 初期設定が必要なのはここまでです。 #======================================================================================= #日付と時刻を取得して、すべて2桁に統一する $ENV{'TZ'} = "JST-9"; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $year = sprintf("%02d",$year + 1900); $month = sprintf("%02d",$mon + 1); $mday = sprintf("%02d",$mday); $hour = sprintf("%02d",$hour); $min = sprintf("%02d",$min); $sec = sprintf("%02d",$sec); #日付時刻のフォーマットを整えます $youbi = ('日','月','火','水','木','金','土') [$wday]; $date_now = "$year年$month月$mday日($youbi)"; $agent = $ENV{'HTTP_USER_AGENT'}; $textwidth = 80; if ($agent =~ /MSIE\ 3/i) { $textwidth = $textwidth * 1.5; } if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $formdata, $ENV{'CONTENT_LENGTH'}); } else { $formdata = $ENV{'QUERY_STRING'}; } @pairs = split(/&/,$formdata); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; if ($tag eq 'no') { $value =~ s//>/g; } $value =~ s/\n//g; $value =~ s/\,/,/g; &jcode'convert(*value,'sjis'); $FORM{$name} = $value; } if (!open(NOTE,"$datafile")) { &error(bad_file); } @DATA = ; close(NOTE); #押されたボタンや、呼び出しに対しての分岐 if ($FORM{'action'} eq 'regist') { ®ist; &edit_html; } elsif ($FORM{'action'} eq 'regist' && $FORM{'button'} eq '削除') { &delete; &edit_html; } elsif ($FORM{'action'} eq 'edit' && $FORM{'password'} eq $password) { &edit_html; } else { &html; } #======================================================================================= sub html_head { print "Content-type: text/html\n\n"; print "" . $title . "\n"; print "\n"; print "$title_html\n"; } #======================================================================================= sub comment_form { print "
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print ""; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
日付:
題名:
画像:
URL:
\n"; print "
"; print "\n"; if ($FORM{'code'} > 0) { print "    \n"; } print "
\n"; print "
\n"; } #======================================================================================= sub html { &html_head; print "
\n"; print "

\n"; &listvew; print "

\n"; print "
\n"; if ($mntbutton eq 'yes') { print "
\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; } print "WhatsNew by Terra\n"; print "
\n"; print "\n"; exit; } #======================================================================================= sub edit_html { &html_head; print "
\n"; if ($FORM{'code'} < 1) { $date = $date_now; $msg = ''; $url = ''; $subject = ''; $gif = ''; } else { foreach $line (@DATA) { ($date,$code,$subject,$gif,$url,$msg) = split(/\,/,$line); if ($FORM{'code'} == $code) { last; } } } &comment_form; &listvew; print "
\n"; print "\n"; exit; } #======================================================================================= sub listvew { if ($FORM{'pline'} eq '') { $pline = 0; } else { $pline = $FORM{'pline'}; } $end_data = @DATA - 1; $page_end = $pline + ($pagevew - 1); if ($page_end >= $end_data) { $page_end = $end_data; } if ($line_gif eq '') { print "
"; } else { print ""; } foreach ($pline .. $page_end) { ($date,$code,$subject,$gif,$url,$msg) = split(/\,/,$DATA[$_]); $msg =~ s/([^=^\"]|^)((http|ftp|mailto):[!#-9A-~]+)/$1ここを押して<\/a>/g; $msg =~ s/\r/
/g; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "$date "; if ($gif eq '' && $url ne '') { print "$subject"; } else { print "$subject"; } if ($FORM{'action'} eq 'edit') { print " "; } print "
"; if ($gif ne '') { if ($url ne '') { print ""; } else { print ""; } } else { print " "; } print "\n"; print "

$msg

\n"; print "
\n"; if ($line_gif eq '') { print "
"; } else { print "
"; } } $next_line = $page_end + 1; if ($page_end ne $end_data) { print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; } } #======================================================================================= sub regist { if ($FORM{'msg'} ne '') { if ($FORM{'code'} > 0) { $i = 0; foreach $line (@DATA) { ($date,$code,$subject,$gif,$url,$msg) = split(/\,/,$line); if ($FORM{'code'} == $code) { if ($FORM{'button'} eq '削除') { splice(@DATA,$i,1); } else { $line = "$FORM{'date'}\,$code\,$FORM{'subject'}\,$FORM{'gif'}\,$FORM{'url'}\,$FORM{'msg'}\n"; } last; } $i++; } } else { $count = @DATA; if ($count >= $max) { pop(@DATA); } if ($count < 1) { $new_code = 1; } else { ($date,$code,$subject,$gif,$url,$msg) = split(/\,/,$DATA[0]); $new_code = $code + 1; } $value = "$FORM{'date'}\,$new_code\,$FORM{'subject'}\,$FORM{'gif'}\,$FORM{'url'}\,$FORM{'msg'}\n"; unshift(@DATA,$value); } if (!open(NOTE,">$datafile")) { &error(bad_file); } print NOTE @DATA; close(NOTE); $FORM{'action'} = 'edit'; $FORM{'code'} = 0; } } #======================================================================================= sub delete { $i = 0; foreach $line (@DATA) { ($date,$code,$subject,$gif,$url,$msg) = split(/\,/,$line); if ($FORM{'code'} == $code) { splice(@DATA,$i,1); last; } $i++; } if (!open(DB,">$datafile")) { &error(bad_file); } print DB @DATA; close(DB); print "Location: $reload?\n\n"; } #======================================================================================= sub error { $error = $_[0]; if ($error eq 'bad_file') { $msg = 'ファイルのオープン、入出力に失敗しました。'; } elsif ($error eq 'bad_pass') { $msg = 'パスワードが一致しません。'; } elsif ($error eq 'send_mail') { $msg = 'sendmailをオープンできません。'; } else { $msg = '原因不明のエラーで処理を継続できません。'; } &html_head; print "

 

 

 

ERROR

 

 

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

 

 

\n"; print "$msg

 

 

\n"; print "
\n"; exit; }