#!/usr/local/bin/perl # ↑あなたが加入しているプロバイダの「perl」言語が使用できる # パスを指定します。一般的に「#!/usr/local/bin/perl」で大丈夫 #*************************************************************************************** # △シンプルBBS Var 2.0▽ # ○Yuppies CGI # http://http://www.geocities.co.jp/Milano/1567/ # ○フリープログラム # 使用条件:[Yuppies]へのリンクは消さないで下さい。 # ○質問、コメントはYumiまで。 # Yuppi(Yumi Tanaka) # YUPPI@chat.club.or.jp # # ※パスワードの変更を行ってください。 #*************************************************************************************** #日本語コード変換モジュール #require 'jcode.pl'; if (-f "jcode.pl") { $jflag = true; require "jcode.pl"; $code = ord(substr("漢", 0, 1)); if ($code == 0xb4) { $ccode = "euc"; $hcode = "x-euc-jp"; } elsif ($code == 0x1b) { $ccode = "jis"; $hcode = "iso-2022-jp"; } else { $ccode = "sjis"; $hcode = "x-sjis"; } } #**************************************************************************************** #* 初期設定 --- ファイルから読み込みます * #**************************************************************************************** $reload = 'sbbs2.cgi'; if (!open(NOTE,"$setteifile")) { &error(bad_file); } @settei = ; close(NOTE); ($max,$pagevew,$pass,$bbstitle,$mail,$home) = split(/,/,$settei[0]); ($bgcolor,$textcolor,$linkcolor,$vlinkcolor,$titlecolor,$titlesize,$bak) = split(/,/,$settei[1]); ($tp1b,$tcl1,$tcl2) = split(/,/,$settei[2]); ($nmcl,$nmtp,$nms,$tycl,$tys,$dtcl,$dts,$cmcl,$cms) = split(/,/,$settei[3]); ($re,$me,$de,$formtype,$write,$reset) = split(/,/,$settei[4]); ($fname,$fmail,$ftitle,$fcom,$fhp) = split(/,/,$settei[5]); ($TOP) = split(/,/,$settei[6]); #**************************************************************************************** #* その他設定 * #**************************************************************************************** $setteifile = "sbbs2_settei.txt"; $datafile = "sbbs2.txt"; $CookieName = 'sbbs2'; &cookie_read; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $date_now = sprintf("%02d/%02d/%02d %02d:%02d", $year, $mon + 1, $mday, $hour, $min); if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $formdata, $ENV{'CONTENT_LENGTH'}); } else { $formdata = $ENV{'QUERY_STRING'}; } $ENV{'TZ'} = "GMT"; ($c_sec,$c_min,$c_hour,$c_mday,$c_mon,$c_year,$c_wday,$c_yday,$c_isdst) = localtime(time + 30 * 86400); @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; $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); #**************************************************************************************** #* クッキー読み込み * #**************************************************************************************** sub cookie_read { $cookies = $ENV{'HTTP_COOKIE'}; @pairs = split(/;/,$cookies); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $name =~ s/ //g; $DUMMY{$name} = $value; } @pairs = split(/,/,$DUMMY{$CookieName}); foreach $pair (@pairs) { ($name, $value) = split(/\!/, $pair); $COOKIE{$name} = $value; } } #**************************************************************************************** #* 動作分類 * #**************************************************************************************** if ($FORM{'action'} eq "regist") { ®ist; } if ($FORM{'action'} eq "new") { &new; } if ($FORM{'action'} eq "setteiregist") { &setteiregist; } elsif ($FORM{'button'} eq "$de" && $FORM{'pass'} eq "$pass" ) { &settei_html; } elsif ($FORM{'button'} eq "$me" && $FORM{'pass'} eq "$pass" ) { &delmode; } elsif ($FORM{'action'} eq "delete") { &delete; } else{ &html; } #**************************************************************************************** #* 初期画面 * #**************************************************************************************** sub html{ print "Content-type: text/html\n\n"; print "$bbstitle\n"; print "
\n"; print "
\n"; print "$bbstitle\n"; print "

\n"; chop($TOP); $TOP =~ s/\r/
/g; $TOP =~ s/<//g; print "$TOP\n"; if( $formtype == 0){ &form; } else{ &button_form; } $counter = @data-1; $view = $pagevew - 1; if ($FORM{'viewdata'} eq '') { $viewdata = 0; } else { $viewdata = $FORM{'viewdata'}; } $endview = $viewdata + ($pagevew - 1); if ($endview >= $counter) { $endview = $counter; } foreach($viewdata .. $endview){ ($date,$num,$name,$email,$homepage,$comment,$title) = split(/,/,$data[$_]); $comment =~ s/\r/
/g; print "\n"; print "\n"; if( $tcl1 eq ""){ print"\n"; print "\n"; print "\n"; if( $tcl2 eq ""){ print"\n"; print "\n"; print"
\n"; } else{ print"\n"; } &title; &name; if( $nmtp == 1 ){ if( $email ne "" ){ print "  Email:\n"; print "$email\n"; } } if( $homepage ne ""){ print "  HP:\n"; $dammy = $homepage; ($check,$site) = split(/:/,$dammy); if( $check ne http or $check ne ftp ){ print "\n"; } else{ print "\n"; } print "$homepage\n"; } print "
\n"; } else{ print"\n"; } print "

\n"; print "\n"; print "$comment\n"; print "\n"; print "
\n"; print "

\n"; } print "
\n"; $nextview = $view + 1; if ($endview < $counter) { print "
\n"; print "\n"; print "\n"; print "
\n"; } if( $formtype == 0){ print "
\n"; print "\n"; print " \n"; print " \n"; print "
\n"; } print "

\n"; print "$mail\n"; print "
\n"; print "△Yuppies CGI▽\n";#この部分は消さないで print "\n"; exit; } #**************************************************************************************** #* 新規書き込み * #**************************************************************************************** sub new { print "Content-type: text/html\n\n"; print "$bbstitle\n"; print "\n"; print "

\n"; print "$bbstitle\n"; print "

\n"; print "$TOP\n"; print "

\n"; &form; print "

\n"; print "$mail\n"; print "
\n"; print "△Yuppies CGI▽\n";#この部分は消さないで print "\n"; exit; } #**************************************************************************************** #* タイトル表示 * #**************************************************************************************** sub title { print "\n"; print "$title\n"; print "\n"; } #**************************************************************************************** #* 掲示板の書き込み者の名前表示 * #**************************************************************************************** sub name { if($nmtp == 1){ print "\n"; print "$name\n"; print "\n"; print "\n"; print "  $date\n"; print "\n"; } elsif($nmtp == 0){ if( $email eq ""){ print "\n"; print "$name\n"; print "\n"; } else{ print "\n"; print "$name"; print "\n"; } print "\n"; print "  $date\n"; print "\n"; } } #**************************************************************************************** #* ボタン作成 * #**************************************************************************************** sub button_form { print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
Home Page

\n"; } #**************************************************************************************** #* フォーム作成 * #**************************************************************************************** sub form { print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
$fname
$fmail
$fhp
$ftitle
$fcom
  

\n"; } #**************************************************************************************** #* カスタマイズ * #**************************************************************************************** sub settei_html { print "Content-type: text/html\n\n"; print "カスタマイズフォーム\n"; print "\n"; print "

\n"; print "カスタマイズフォーム\n"; $dammy = "$bgcolor$textcolor$linkcolor$vlinkcolor$titlecolor$tcl1$tycl$nmcl$dtcl$cmcl$tcl2"; ($dd,$bgcolor,$textcolor,$linkcolor,$vlinkcolor,$titlecolor,$tcl1,$tycl,$nmcl,$dtcl,$cmcl,$tcl2)=split(/#/,$dammy); print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; print "全体の設定です\n"; print "
\n"; print "色の指定は16進数で\n"; print "
\n"; print "
\n"; print "掲示板タイトル\n"; print "
\n"; print "掲示板タイトルカラー\n"; print "#\n"; print "掲示板タイトルサイズ\n"; print "
\n"; print "TOP、タイトルの下にコメントを入れられます[タグOK]
\n"; print "

\n"; print "
\n"; print "背景使う画像のURL\n"; print "http://
\n"; print "背景色\n"; print "#\n"; print "テキスト色\n"; print "#
\n"; print "リンク色\n"; print "#\n"; print "訪れたリンク色\n"; print "#

\n"; print "最大記憶記事数\n"; print "\n"; print "1ページの記事数\n"; print "
\n"; print "パスワード[最初は必ず変更してください]\n"; print "
\n"; print "あなたのメールアドレス\n"; print "
\n"; print "Homeとして戻るURL\n"; print "http://
\n"; print "
\n"; print "
\n"; print "
ボタン&フォームの設定です
\n"; print "
\n"; print "初期画面に書き込みフォームを出すかボタンフォームを出すかを選択
\n"; if( $formtype == 0 ){ print "\n";} else{ print "\n";} print "書き込みフォーム\n"; if( $formtype == 1 ){ print "\n";} else{ print "\n";} print "ボタンフォーム

\n"; print "ボタンの文字です

\n"; print "ボタンフォーム
\n"; print "新規書き込みボタン:\n"; print "メンテナンスボタン:
\n"; print "デザイン変更ボタン:\n"; print "

書き込みフォーム
\n"; print "書き込みボタン:\n"; print "リセットボタン:
\n"; print "

書き込みフォームの横の文字
\n"; print "名前:\n"; print "メール:
\n"; print "HP:\n"; print "タイトル:
\n"; print "コメント:
\n"; print "
\n"; print "
\n"; print "
記事の設定です
\n"; print "
\n"; print "テーブルの枠の設定\n"; print "\n"; print ":「0」で枠を消せます\n"; print "\n"; print "\n"; if( $tcl1 eq ""){ print"\n"; print "\n"; print "\n"; if( $tcl2 eq ""){ print"\n"; print "\n"; print"
\n"; } else{ print"\n"; } print "上段の色\n"; print "#
\n"; print "タイトルの色\n"; print "#\n"; print "タイトルの大きさ\n"; print "
\n"; print "名前の色\n"; print "#\n"; print "名前の大きさ\n"; print "
\n"; print "日付の色\n"; print "#\n"; print "日付の大きさ\n"; print "\n"; print "
\n"; print "□タイプを選択してください\n"; print "
\n"; if( $nmtp == 1 ){ print "\n";} else{ print "\n";} print "\n"; print "name\n"; print "\n"; print "\n"; print "  $date_now\n"; print "\n"; print "  EMail:\n"; print "○○\@××.△△\n"; print "  HP:\n"; print "\n"; print "http://××.△△

\n"; if( $nmtp == 0 ){ print "\n";} else{ print "\n";} print "\n"; print "name"; print "\n"; print "\n"; print "  $date_now\n"; print "\n"; print "  HP:\n"; print "\n"; print "http://××.△△\n"; print "
\n"; } else{ print"\n"; } print "下段の色\n"; print "#\n"; print "コメントの色\n"; print "#\n"; print "コメントの大きさ\n"; print "\n"; print "

\n"; print "\n"; print "\n"; print "カスタマイズに関して、意見・希望があればお知らせください\n"; print "
\n"; print "

\n"; print "$mail\n"; print "
\n"; print "△Yuppies CGI▽\n";#この部分は消さないで print "\n"; exit; } #**************************************************************************************** #* 掲示板のカスタマイズデータを保存 * #**************************************************************************************** sub setteiregist { chop($FORM{'TOP'}); $sdata[0] = "$FORM{'max'}\,$FORM{'pagevew'}\,$FORM{'pass'}\,$FORM{'bbstitle'}\,$FORM{'mail'}\,$FORM{'hp'}\n"; $sdata[1] = "#$FORM{'bgcolor'}\,#$FORM{'textcolor'}\,#$FORM{'linkcolor'}\,#$FORM{'vlinkcolor'}\,#$FORM{'titlecolor'}\,$FORM{'titlesize'}\,$FORM{'back'}\n"; $sdata[2] = "$FORM{'tp1b'}\,#$FORM{'tcl1'}\,#$FORM{'tcl2'}\n"; $sdata[3] = "#$FORM{'nmcl'}\,$FORM{'nmtp'}\,$FORM{'nms'}\,#$FORM{'tycl'}\,$FORM{'tys'}\,#$FORM{'dtcl'}\,$FORM{'dts'}\,#$FORM{'cmcl'}\,$FORM{'cms'}\n"; $sdata[4] = "$FORM{'re'}\,$FORM{'me'}\,$FORM{'de'}\,$FORM{'formtype'}\,$FORM{'write'}\,$FORM{'reset'}\n"; $sdata[5] = "$FORM{'fname'}\,$FORM{'fmail'}\,$FORM{'ftitle'}\,$FORM{'fcom'}\,$FORM{'fhp'}\n"; $sdata[6] = "$FORM{'TOP'}\n"; if (!open(NOTE,">$setteifile")) { &error(bad_file); } print NOTE @sdata; close(NOTE); print "Location: $reload" . '?' . "\n\n"; } #**************************************************************************************** #* 掲示板の書き込みデータを保存 * #**************************************************************************************** sub regist { if ($FORM{'name'} eq "") { &error(bad_name); } if ($FORM{'comment'} eq "") { &error(bad_comment); } if ($c_year < 10) { $c_year = "0$c_year"; } if ($c_sec < 10) { $c_sec = "0$c_sec"; } if ($c_min < 10) { $c_min = "0$c_min"; } if ($c_hour < 10) { $c_hour = "0$c_hour"; } if ($c_mday < 10) { $c_mday = "0$c_mday"; } $y0="Sunday"; $y1="Monday"; $y2="Tuesday"; $y3="Wednesday"; $y4="Thursday"; $y5="Friday"; $y6="Saturday"; $youbi = ($y0,$y1,$y2,$y3,$y4,$y5,$y6) [$c_wday]; $m0="Jan"; $m1="Feb"; $m2="Mar"; $m3="Apr"; $m4="May"; $m5="Jun"; $m6="Jul"; $m7="Aug"; $m8="Sep"; $m9="Oct"; $m10="Nov"; $m11="Dec"; $month = ($m0,$m1,$m2,$m3,$m4,$m5,$m6,$m7,$m8,$m9,$m10,$m11) [$c_mon]; $date_gmt = "$youbi, $c_mday\-$month\-$c_year $c_hour:$c_min:$c_sec GMT"; $cook="name\!$FORM{'name'}\,email\!$FORM{'email'}\,hp\!$FORM{'homepage'}"; print "Set-Cookie: $CookieName=$cook; expires=$date_gmt\n"; $i = 1; foreach $dammy (@data){ if( $i <= $max ){ push(@new,$dammy); } $i++; } $count = @data; if ($count < 1) { #記事がない場合は、コードを1に $new_num = 1; } else { #記事ある場合は、最後に投稿された記事のコードに1プラスする ($date,$num,$name,$email,$homepage,$comment) = split(/\,/,$data[0]); $new_num = $num + 1; } $value = "$date_now\,$new_num\,$FORM{'name'}\,$FORM{'email'}\,$FORM{'homepage'}\,$FORM{'comment'}\,$FORM{'title'}\n"; unshift(@new,$value); if (!open(NOTE,">$datafile")) { &error(bad_file); } print NOTE @new; close(NOTE); print "Location: $reload" . '?' . "\n\n"; } #**************************************************************************************** #* 削除モード * #**************************************************************************************** sub delmode { $count = @data; if ($count < 1) { &html; } print "Content-type: text/html\n\n"; print "メンテナンス\n"; print "\n"; print "

\n"; print "メンテナンス\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "削除番号:\n"; print "
\n"; print "スペースで区切って番号を入力すれば同時に削除できます[半角]

\n"; print "全ての記事を消します
\n"; print "
\n"; foreach $line (@data) { ($date,$num,$name,$email,$homepage,$comment) = split(/\,/,$line); print "\n"; print "\n"; print "\n"; print "\n"; print "
[$num]\n"; #メールアドレスが記入されていればリンクをつける if ($email ne '') { print "" . $name . "\n"; } else { print "" . $name . "\n"; } print "$date
\n"; print "$comment\n"; print "
\n"; print "
\n"; } print "
\n"; print "\n"; print "削除番号:\n"; print "
\n"; print "スペースで区切って番号を入力すれば同時に削除できます\n"; print "
\n"; exit; } #**************************************************************************************** #* 記事の削除 * #**************************************************************************************** sub delete { if ($FORM{'del'} eq "all"){ @new = ""; } else{ @delcode = split(/ /,$FORM{'delnum'}); $count = @delcode; if ($count eq 0) { &html; } foreach $line (@data) { ($date,$num,$name,$email,$homepage,$comment) = split(/\,/,$line); $check = "false"; foreach $delchecker (@delcode) { if ($num eq $delchecker) { $check = "true"; } } if ($check eq "false") { push (@new,$line); } } } if (!open(NOTE,">$datafile")) { &error(bad_file); } print NOTE @new; close(NOTE); &html; } #**************************************************************************************** #* エラールーチン * #**************************************************************************************** sub error{ $error = $_[0]; if( $error eq "bad_file"){ $em = "ファイルのオープンに失敗しました"; } elsif ($error eq "bad_name") { $em = 'おなまえが記入されていません。'; } elsif ($error eq "bad_comment") { $em = 'コメントが記入されていません。'; } print "Content-type: text/html\n\n"; print "エラー\n"; print "\n"; print "



\n"; print "

ERROR
\n"; print "$em\n"; print "

「戻る」ボタンで戻ってください
\n"; print "\n"; exit; }