#!/usr/local/bin/perl # # # # # # # # # # # # # # # # # # # # # # # # # # # # << 楽 書・呟 >> RGN-11-3 # presented by 楽 # raku@f204.net # http://f204.net/ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 設定項目 # #### 全id共通設定 #### #このスクリプトの名前 $this = "rgn.cgi"; #このスクリプトの設置ファイルパス(最後スラッシュ必須) $base = "http://www.resttime.co.jp/cgi/"; #文字コード #本体・ログファイル統一のこと $charset = "Shift_JIS"; #複数設置用設定ファイル #使用する場合 下行頭の"#"を消す # require "rgn_ini.cgi"; #折り畳み用jsファイルの場所 $hide_js = "rg_hide.js"; #### 各id設定 #### #{'id名'}=「1」 #ログファイル名 $logfile{'1'} = "1.pl"; $logfile{'rest'} = "rest.pl"; #最大ログ保存数 $data_max{'1'} = "200"; $data_max{'rest'} = "200"; #管理用パスワード $adpass{'1'} = "1234"; $adpass{'rest'} = "1234"; #外部表示ファイル名(この名で自動作成されます) $temp_html{'1'} = "rgn.html"; $temp_html{'rest'} = "../index.html"; #↑のテンプレート $template{'1'} = "rgn_temp.html"; $template{'rest'} = "../index_temp.html"; #↑の表示コメント数 $temp_comsize{'1'} = "3"; $temp_comsize{'rest'} = "4"; #アップ画像ファイルサイズ制限値(KB) $img_max{'1'} = "100"; $img_max{'rest'} = "2048"; #画像を保存するフォルダ #cgi本体からの「相対パス」で(最後スラッシュ必須) #同フォルダの場合は空に $img_f{'1'} = "rgn_img/"; $img_f{'rest'} = "../pdf/"; #折り畳み部分展開メッセージ #(折り畳み部分は「--続--」と「--/続--」で挟む) $hide_mes{'1'} = "→続きを読む"; $hide_mes{'rest'} = "→続きを読む"; ## 本体表示設定 ## #タイトル (ブラウザタイトルバー表示) $thisname{'1'} = "ツブヤキテスト"; $thisname{'rest'} = "株式会社レスト|過去のNEWS"; #head内記述1 meta・ロボット対策等 (「"」は「\」でエスケープ) $head1{'1'} = ""; $head1{'rest'} = ""; #head内記述2 スクリプトタグ等 (「"」は「\」でエスケープ) $head2{'1'} = ""; $head2{'rest'} = ""; #外部スタイルシートアドレス $css1{'1'} =""; $css1{'rest'} ="../css/style.css"; #内部スタイルシート #ネタバレカラーは「.hidden_c」で指定 #(隠したい部分を「--隠--」と「--/隠--」で挟む) $css2{'1'} ="body { width:80%; margin:auto; } .data { text-align:right; } .no {} .day {} .time {} .comment { padding:0.5em; } .hidden_c { color:#ffffff; }"; $css2{'rest'} ="body { width:80%; margin:auto; } .data { text-align:right; } .no {} .day {} .time {} .comment { padding:0.5em; } .hidden_c { color:#ffffff; }"; #bodyタグ (「"」は「\」でエスケープ) #このタグ自体は消さないように $body{'1'} = "
"; $body{'rest'} = ""; #見出し (タグ可 「"」は「\」でエスケープ) $main_title{'1'} = "
NEWS 管理フォーム |
記事修正・削除 |
[back] |
\n/g; $comment =~ s/--\/続--/<\/blockquote>/g; print "\n"; print "$no] $today $time\n"; print "
\n"; print "
\n\n"; } #ログリンク $new_p = $p - $comsize{$id}; $old_p = $p + $comsize{$id}; print "\n"; if ($new_p >= 0){ print "← "; } print "[back]"; if ($old_p < $i){ print " →\n"; } print "
\n"; } #フッター表示 sub footer{ print <<"HTML"; HTML } #デコード処理 sub decode{ use CGI; $query = new CGI(); $id = $query->param('id'); $mode = $query->param('mode'); $no = $query->param('no'); $today = $query->param('today'); $time = $query->param('time'); $name = $query->param('name'); $mail = $query->param('mail'); $site = $query->param('site'); $comment = $query->param('comment'); $title = $query->param('title'); $read = $query->param('read'); $pass = $query->param('pass'); $pass2 = $query->param('pass2'); $p = $query->param('p'); $upfile = $query->param('upfile'); $comment =~ s/\x0D\x0A/
/g; $comment =~ s/\x0D/
/g; $comment =~ s/\x0A/
/g; $comment =~ s/\t/ /g; $comment =~ s/--隠--//g; $comment =~ s/--\/隠--/<\/span>/g; } #ログファイルに書き込み sub regist{ $ENV{'TZ'} = "JST-9"; ($sec,$min,$hour,$day,$mon,$year,$wday) = localtime(time); $week = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat')[$wday]; $month = ('Jau','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')[$mon]; $year += 1900; $today = sprintf("%4d/%2d/%2d",$year,$mon+1,$day); $time = " "; if ($ENV{'HTTP_REFERER'} !~ /$base/i) { &error('エラー','不正なアクセスです'); } unless ($pass eq $adpass{$id}) { &error('エラー','マスターパスワードが違います'); } open(IN,"$logfile{$id}"); @log =; close(IN); $no = $log[0] + 1 ; $salt = pack("CC",int( rand(26) + 65 ),int(rand(26) + 97 )); $pass = crypt($pass,$salt); $read = "$read<\/span>"; if ($upfile ne '') { ℑ } elsif ($comment eq '') { &error('エラー','コメントを記入してください'); } else {$comment = "$read
$comment"; } $newdata = "$no\t$today\t$time\t$name\t$mail\t$site\t$comment\t$pass\t$title\t$last_date\t\n"; open(OUT,">$logfile{$id}"); unshift (@log,"$newdata"); if ($#log > ($data_max{$id} -1)){ $#log = $data_max{$id} -1; } print OUT @log; close(OUT); &temp; if ($check{$id} eq 'on'){ ✓ } else { print "location:$temp_html{$id}\n\n"; } exit; } #アップ画像処理 sub image{ $type = $query->uploadInfo($upfile)->{'content-type'}; if ($type =~ /jpeg/i) { $ext = '.jpg'; } elsif ($type =~ /gif/i ) { $ext = '.gif'; } elsif ($type =~ /png/i ) { $ext = '.png'; } elsif ($type =~ /pdf/i ) { $ext = '.pdf'; } elsif ($upfile =~ /.jpeg$|.jpg$/i) { $ext = '.jpg'; } elsif ($upfile =~ /.gif$/i ) { $ext = '.gif'; } elsif ($upfile =~ /.png$/i ) { $ext = '.png'; } elsif ($upfile =~ /.pdf$/i ) { $ext = '.pdf'; } else { &error('エラー','その形式の画像ファイルは保存できません'); } while(read($upfile, $buffer, 2048)) { $file .= $buffer; $file_size ++; if($file_size > $img_max{$id}) { &error('エラー','画像ファイルが設定サイズをオーバーしています'); } } $upimg = "$id"."_$no"."$ext"; if ($comment !~ /--画/) { $comment = "$read<\/a>
$comment"; } else { $comment =~ s/--画左--//g; $comment =~ s/--画中--/<\/p>/g; $comment =~ s/--画右--//g; } unless (-d $img_f{$id}){ mkdir "$img_f{$id}"; } open(OUT, "> $img_f{$id}$upimg"); binmode(OUT); print(OUT $file); close(OUT); } #書き込み確認 sub check{ print "Content-type: text/html; charset=$charset\n\n"; print <<"HTML";
処理完了 実行されました。
[back]
-- --
HTML } #修正フォーム sub edit_f { if ($no eq '' || $pass2 eq ''){ &error('エラー','削除番号・パスワードを記入してください'); } open(IN,"$logfile{$id}"); @log =; close(IN); @edit_no = grep (/^$no\t/,@log); foreach $line(@edit_no) { chomp($line); ($e_no,$e_today,$e_time,$e_name,$e_mail,$e_site,$e_comment,$e_pass,$e_title)= split(/\t/,$line); $e_comment =~ s/
/\n/g; if ($e_no eq $no){ if ($e_pass eq crypt($pass2,$e_pass) || $pass2 eq $adpass{$id}) { print "Content-type: text/html; charset=$charset\n\n"; print <<"HTML";修正・削除 HTML exit; } else { &error('エラー','パスワードが違います'); } } } } #修正 sub modify { if ($ENV{'HTTP_REFERER'} !~ /$base/i) { &error('エラー','不正なアクセスです'); } if ($comment eq ''){ &error('エラー','コメントを記入してください'); } open(IN,"$logfile{$id}"); @log =
NEWS 修正・削除フォーム
[back]
; close(IN); $e_line = "$no\t$today\t$time\t$name\t$mail\t$site\t$comment\t$pass\t$title\t\n"; foreach $line (@log) { ($e_no,$e_today,$e_time,$e_name,$e_mail,$e_site,$e_comment,$e_pass,$e_title)= split(/\t/,$line); if( $e_no == $no ){ $line = $e_line; } } open(OUT,">$logfile{$id}"); print OUT @log; close(OUT); &temp; if ($check{$id} eq 'on'){ ✓ } else { print "location:$temp_html{$id}\n\n"; } exit; } #ログファイルから削除 sub delete{ if ($ENV{'HTTP_REFERER'} !~ /$base/i) { &error('エラー','不正なアクセスです'); } open(IN,"$logfile{$id}"); @log = ; close(IN); for ($i = 0; $i <= $#log; $i++) { ($d_no,$d_today,$d_time,$d_name,$d_mail,$d_site,$d_comment,$d_pass,$d_title) = split(/\t/, $log[$i]); if ($d_no == $no) { splice (@log, $i, 1); last; } } open(OUT,">$logfile{$id}"); print OUT @log; close(OUT); &temp; if ($check{$id} eq 'on'){ ✓ } else { print "location:$temp_html{$id}\n\n"; } exit; } #エラーメッセージ表示 sub error { print "Content-type: text/html; charset=$charset\n\n"; print <<"HTML"; エラー $_[0]
$_[1]
[back]
-- --
HTML exit; } #テンプレート sub temp { $flag = ''; open(TEMP,"$template{$id}"); while () { if (/--rgn_$id--/) {$flag = 'start';} elsif (/--rgn_end_$id--/) {$flag = 'end';} elsif ($flag eq 'start') {$temp_start .= $_;} elsif ($flag eq 'end') {$temp_end .= $_;} else {$temps .= $_;} } close(TEMP); open(IN,"$logfile{$id}"); @log = ; my $log = @log; close(IN); @log = @log[0 .. $temp_comsize{$id} -1]; foreach $line(@log) { chomp($line); ($no,$today,$time,$name,$mail,$site,$comment,$pass,$title)= split(/\t/,$line); $comment =~ s/--続--/\n$hide_mes{$id}<\/span> \n/g; $comment =~ s/--\/続--/<\/blockquote>/g; $comment =~ s/
/
\n/g; $temp = $temp_start; $temp =~ s/--no--/$no/g; $temp =~ s/--day--/$today/g; $temp =~ s/--time--/$time/g; $temp =~ s/--name--/$name/g; $temp =~ s/--mail--/$mail/g; $temp =~ s/--site--/$site/g; $temp =~ s/--comment--/$comment/g; $temp =~ s/--title--/$title/g; $temps .= $temp; } open(TOP, ">$temp_html{$id}"); print TOP $temps; print TOP $temp_end; close(TOP); } __END__
\n"; print "