#!/usr/local/bin/perl # ↑あなたが加入しているプロバイダの「perl」言語が使用できる # パスを指定します。一般的に「#!/usr/local/bin/perl」で大丈夫 #*************************************************************************************** # △SlotBBS Var 1.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"; } } #**************************************************************************************** #* 初期設定 #**************************************************************************************** #掲示板を設置するURLを設定 $reload = 'slbbs2.cgi'; #記事の記憶数・1ページの表示数 $max="100"; $pagevew="3"; #パスワード $pass="abc777";#必ず変更 #キー保存ファイルの**の部分(slbbs**.txt) $pasfile="aa";#必ず変更(この場合、slbbsaa.txtという空のファイルを作成) #掲示板タイトル $bbstitle="SlotBBS"; #メールアドレス・戻るURL $mail=''; $home=''; #背景の色指定 $bgcolor="#111111"; #背景の画像URL $back=""; #文字の色指定 $textcolor="#cccccc"; #リンク・訪れたリンクの色指定 $linkcolor="#6699CC"; $vlinkcolor="#cc9966"; #タイトルの色・大きさ指定 $titlecolor="#cccccc"; $titlesize="6"; #掲示板のTOPにコメントを入力できます。 $TOP=""; #記事のテーブルの設定です。 #テーブルの枠の太さ $tpb="0"; #上段の背景色 $tcl1="#777777";#名前の部分の色 $tcl3="#333333";#タイトルの部分の色 #下段の背景色 $tcl2="#777777";#コメントの部分の色 #名前の色・大きさ $nmcl="#cccccc"; $nms="4"; #タイトルの色・大きさ $tycl="#ffffff"; $tys="3"; #日付の色・大きさ $dtcl="#fffff0"; $dts="1"; #コメントの色・大きさ $cmcl="#dddddd"; $cms="2"; #フォームのタイプ # 0---書き込みフォームが初期画面に表示されます # 1---ボタンフォームが初期画面に表示されます $formtype="0"; #ボタンに表示する文字 $re="書き込み"; $me="メンテ"; $write="φ(。。)カキカキ"; $reset="ロ(。。)ケシケシ"; #フォームのタイトル $fname="Your Name"; $fmail="E-mail"; $ftitle="Title"; $fcom="Comment"; $fhp="Home Page"; @c_type = ("+5P(^^v♪","BIGo(^^o)(o^^)o","REGo(^^o)","+20P小役(^^v♪","チャンスっ(^◇^)ノ","(--)"); #**************************************************************************************** #* その他設定 #**************************************************************************************** $datafile = "slbbs.txt"; $pointfile = "slbbs$pasfile.txt"; $CookieName = 'slbbs'; &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 + 365 * 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; $value =~ s/\*!\+/\r/g; &jcode'convert(*value,'sjis'); $FORM{$name} = $value; } if (!open(NOTE,"$datafile")) { &error(bad_file); } @data = ; close(NOTE); if (!open(NOTE,"$pointfile")) { &error(bad_file); } @pointdata = ; 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; } elsif ($FORM{'action'} eq "check") { ✓ } elsif ($FORM{'action'} eq "new") { &new; } 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 "SlotBBS\n"; print "
\n"; print "
\n"; print "$bbstitle\n"; print "

\n"; print "\n"; if($COOKIE{'name'} ne "" && $COOKIE{'p'} ne ""){ foreach $numcheck ( @pointdata ){ ($id,$name,$pass1,$pass2,$point,$rt) = split(/\,/,$numcheck); if( $COOKIE{'id'} eq $id){ print "現在$COOKIE{'name'}さん$pointPです(^^)\n"; print "---ありがとう\n"; last;} } } else{ print "書き込みよろしく\n";} print "
\n"; if( $formtype == 1){ &button_form; } else{ &form; } $counter = @data-1; $view = $pagevew - 1; if ($FORM{'viewdata'} eq '') { $viewdata = 0; } else { $viewdata = $FORM{'viewdata'}; } $endview = $viewdata + $view; if ($endview >= $counter) { $endview = $counter; } foreach($viewdata .. $endview){ ($date,$num,$name,$email,$homepage,$comment,$title,$sn,$po,$sp,$rt,$inum) = split(/,/,$data[$_]); $comment =~ s/\r/
/g; $comment =~ s/<//g; ($sn1,$sn2,$sn3,$s_type) = split(/\+/,$sn); print "\n"; print "\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; if( $tcl1 eq ""){ print"\n"; print "\n"; print "\n"; if( $tcl2 eq ""){ print"\n"; print"
\n"; print "\n"; print " $name\n"; print "\n"; if( $email ne "" ){ print " \n"; print "[Email]\n"; } if( $homepage ne ""){ print " \n"; $dammy = $homepage; ($check,$site) = split(/:/,$dammy); if( $check eq "http" or $check eq "ftp" ){ print "\n"; } else{ print "\n"; } print "[Home]\n"; } print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print " +" . $po . "P\n"; print "\n"; print "\n"; print "" .$c_type[$s_type]. "\n"; print "\n"; print "\n"; print "\n"; print "". $sp . "P\n"; print "\n"; print "\n"; print "
\n"; } else{ print"\n"; } print"   \n"; print "\n"; &title; print "\n"; print "\n"; print " $date\n"; print "
\n"; } else{ print"\n"; } print "
\n"; print "\n"; if($cmcl2 == 1){ print "$comment\n";} elsif($cmcl2 == 0){print "$comment\n";} print "\n"; print "
\n"; print "
\n"; print "

\n"; } print "
\n"; $nextview = $endview + 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 "$mail\n"; print "Go To Home\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 "Go To Home\n"; print "
\n"; print "△Yuppies CGI▽\n";#この部分は消さないで print "\n"; exit; } #**************************************************************************************** #* タイトル表示 #**************************************************************************************** sub title { print "\n"; print "  $title\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 "
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 "\n"; print "\n"; print "\n"; print "
$fname\n"; print "\n"; print "
スロットタイプBBSです(^^)
\n"; print "
チャンス目を引くと、
\n"; print "次回の貴方の書き込みは
チャンス♪♪
\n"; print "
ボーナス柄の並びでチャンス目です♪♪\n"; print "
$fmail
$fhp
$ftitle
$fcom
  
\n"; print "キー1  キー2\n"; print "
\n"; print "
\n"; print "\n"; print "↑2つのキーで書き込み者を認識します↑\n"; print "
◆どこから繋いでも、この2つのキーだけ同じなら同一人物とみなします
\n"; print " もし以前のキーがフォーム内に出ていなかったら自分で同じ物を入れてください・・・
\n"; print "◇キーは4文字以上の数字・文字でお願いしますm(_ _)m
\n"; print "◆キーを忘れた場合は連絡ください。保管してありますのでお教えいたします♪♪
\n"; print "
\n"; print "

\n"; } #**************************************************************************************** #* ユーザー確認 #**************************************************************************************** sub check { if ($FORM{'name'} eq "") { &error(bad_name); } if ($FORM{'comment'} eq "") { &error(bad_comment); } if ($FORM{'pass1'} eq "") { &error(bad_pass); } if ($FORM{'pass2'} eq "") { &error(bad_pass); } $check = 0; if(@pointdata != ""){ $i = 0; foreach $data (@pointdata){ ($id,$name,$pass1,$pass2,$point,$rt) = split(/\,/,$data); $key[$i] = "『$pass1, $pass2 』
"; if( $FORM{'pass1'} eq $pass1 && $FORM{'pass2'} eq $pass2){ $who=$name; $user = $id; if($COOKIE{'id'} ne "" && $COOKIE{'id'} eq $id){ $check = 1; ®ist; last; } elsif($COOKIE{'id'} ne "" && $COOKIE{'id'} ne $id){$type = 1; $check = 2; last;} elsif($COOKIE{'id'} eq ""){ $type = 2; $check = 2; last;} } $i++; } } else{ $check = 3; ®ist; last;} if( $check == 0){ ®ist; last;} print "Content-type: text/html\n\n"; print "エラー\n"; print "\n"; print "

\n"; print "

WHO ARE YOU?
\n"; print "同じキー『$FORM{'pass1'} , $FORM{'pass2'}』が検出されました

\n"; print "
\n"; print "\n"; print "
\n"; print "
\n"; $c_dammy =$FORM{'comment'}; $c_dammy =~ s/\r/\*!\+/g; print "あなたが以前に『$who』さんで書き込みをしていればOKをおして下さい

\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( $type == 1){ print "
\n"; print "

\n"; print "『$COOKIE{'name'}』さんのキーは『$COOKIE{'pass1'},$COOKIE{'pass2'}』です。

\n"; print "変更される場合&違うユーザーの場合は、
もう一度違うキーを入力して下さい
\n"; print "「戻る」ボタンで戻ってください

\n"; print "
\n"; } if( $type == 2){ 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 "記事の書き込みにはなんの影響もありません。
"; print "
キーの変更は新しいキーを入力して「変更」と掲示板に書き込んでくれれば
\n"; print "ポイントの変更など処理します

\n"; print "
\n"; } #**************************************************************************************** #* 掲示板の書き込みデータを保存 #**************************************************************************************** sub regist { 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"; $i = 0; foreach $data (@pointdata){ $newdata[$i] = $data; $i++; } if($FORM{'check'} == 1){ $user = $FORM{'user'}; ($id,$name,$pass1,$pass2,$point,$rt) = split(/\,/,$pointdata[$user]); &point; $newdata[$user]="$user\,$name\,$FORM{'pass1'}\,$FORM{'pass2'}\,$pp\,$r\n"; $iid = $user; } elsif($check == 1){ ($id,$name,$pass1,$pass2,$point,$rt) = split(/\,/,$pointdata[$user]); &point; $newdata[$user]="$user\,$name\,$FORM{'pass1'}\,$FORM{'pass2'}\,$pp\,$r\n"; $iid = $user; } elsif($check == 0){ $rt = 0; $point = 0; &point; $j = @pointdata; $iid = $j; $newdata[$j]="$j\,$FORM{'name'}\,$FORM{'pass1'}\,$FORM{'pass2'}\,$pp\,$r\n"; } elsif($check == 3){ $rt = 0; $point = 0; &point; $jj = 0; $iid = $jj; $newdata[0]="$jj\,$FORM{'name'}\,$FORM{'pass1'}\,$FORM{'pass2'}\,$pp\,$r\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,$title,$sn,$po,$sp,$rt) = split(/\,/,$data[0]); $new_num = $num + 1; } $value = "$date_now\,$new_num\,$FORM{'name'}\,$FORM{'email'}\,$FORM{'homepage'}\,$FORM{'comment'}\,$FORM{'title'}\,$snum\,$p\,$pp\,$r\,$iid\n"; unshift(@new,$value); if (!open(NOTE,">$datafile")) { &error(bad_file); } print NOTE @new; close(NOTE); if (!open(NOTE,">$pointfile")) { &error(bad_file); } print NOTE @newdata; close(NOTE); $cook="name\!$FORM{'name'}\,email\!$FORM{'email'}\,hp\!$FORM{'homepage'},pass1\!$FORM{'pass1'}\,pass2\!$FORM{'pass2'}\,p\!$pp\,id\!$iid"; print "Set-Cookie: $CookieName=$cook; expires=$date_gmt\n"; print "Location: $reload" . '?' . "\n\n"; } #**************************************************************************************** #* ポイント計算 #**************************************************************************************** sub point{ @number = (0,1,2,3,4,5); srand; $r[1] = $number[rand(@number)]; $r[2] = $number[rand(@number)]; $r[3] = $number[rand(@number)]; $r = 0; $p = 10; $s_type = 5; if($rt == 0){ if($r[1] == $r[2] && $r[1] == $r[3]){ if($r[1] == 0 or $r[1] == 1){ $p = 100 ; $s_type = 1; } if($r[1] == 3){ $p = 50 ; $s_type = 2; } if($r[1] == 2 or $r[1] == 4){ $p = 30 ; $s_type = 3; } if($r[1] == 5){ $p = 15 ; $s_type = 0; } } elsif($r[1] == 0 or $r[1] == 1 or $r[1] == 3){ if($r[2] == 0 or $r[2] == 1 or $r[2] == 3){ if($r[3] == 0 or $r[3] == 1 or $r[3] == 3){ $s_type = 4; $r = 1; }} } elsif($r[1] == 5){ $p = 15 ; $s_type = 0; } } else{ @number = (0,1,3); srand; $r[1] = $number[rand(@number)]; $r[2] = $r[1]; $r[3] = $r[1]; if($r[1] == 0 or $r[1] == 1){ $p = 100 ; $s_type = 1;} if($r[1] == 3){ $p = 50 ; $s_type = 2;} } $snum = "$r[1]+$r[2]+$r[3]+$s_type"; $pp = $p + $point; } #**************************************************************************************** #* 削除モード #**************************************************************************************** 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,$title,$sn,$po,$sp,$rt) = 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,$title,$sn,$po,$sp,$rt) = 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 = 'コメントが記入されていません。'; } elsif ($error eq "bad_pass") { $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; }