#!/usr/local/bin/perl # WeB dorama Editor version 1.11 # # Script written by Shigeto Nakazawa.(1996/11/27) # This script is free. # Arranged by Ninjinju-su CGI require './jcode.pl'; # --------------------------------- # 各種設定 # --------------------------------- $pass = 'password'; # 必ず半角英数8文字以内で書き換えて下さい。 $mojicode = 'sjis'; # Windows なら 'sjis' UNIX なら 'euc' を推奨。 $logfile = 'dorama.log'; # 記録用ファイル $lockfile = 'dorama.lock'; # 鍵ファイル $lockcheck = 1; # 鍵ファイルの使用(通常は 1 にしてください) $pluscheck = 1; # 登場人物設定(1:自由登録モード 0:管理者限定登録モード) $kyaralogfile = 'kyara.log'; # 登場人物記録用ファイル @plus_colors = ('#000000=くろ', '#FF0000=あか', '#008000=みどり', '#0000FF=あお', '#00FFFF=みずいろ', '#FF8000=みかん', '#804000=ちゃ', '#00C0C0=まりんぶるー', '#FF8080=もも', '#808080=ねずみ'); # 登場人物につける色 $type = '<>'; #ログ形式設定 # --------------------------------- # フォームからデータをもらう # --------------------------------- if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { $buffer = $ENV{'QUERY_STRING'}; } $typec = $type; $typec =~ s/\\//; @pairs = split(/&/,$buffer); foreach $pair (@pairs) { ($name,$value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; &jcode'convert(*value,$mojicode); $value =~ s/\n//; if ($type ne '<>') { $value =~ s/$typec//; } if ($value ne 'on') { $FORM{$name} = $value; } else { $FORM{$name} = 1; } } $rq_dorama = &change0($FORM{'dorama'}); $rq_actor = &change0($FORM{'actor'}); $pw = $FORM{'pass'}; $typec = $type; $typec =~ s/\\//; # --------------------------------- # HTML出力 # --------------------------------- print <<"_HTML_header_"; Content-type: text/html\n\n WeB DoRaMa Editor Plus _HTML_header_ # --------------------------------- # 記録ファイルを読み込む # --------------------------------- if ($lockcheck) { local($wt) = 0; while (-f $lockfile) { if (++$wt > 5) { &error('強制終了されました。処理は中断されました。'); } sleep 4; } open (LOCK,">$lockfile"); } if (!open(IN,$logfile)) { unlink ($lockfile); &error("記録ファイルの読み込みに失敗しました。"); } @lines = ; close(IN); if (!open(IN,$kyaralogfile)) { unlink ($lockfile); &error("登場人物記録ファイルの読み込みに失敗しました。"); } @tomatos = ; close(IN); unlink ($lockfile); @ptomatos = @tomatos; foreach $tomato (@tomatos) { chop($tomato); ($kyara,$color) = split(/$type/, $tomato); $kyara = &change1($kyara); push(@actors,$kyara); push(@colors,$color); } if ($pw eq $pass) { $back = "doraedit.cgi?pass=$pw"; } else { $back = "dorama.cgi"; } # --------------------------------- # plusのみ分岐 # --------------------------------- if ($FORM{'plus'} eq '0' && $pluscheck || $pass eq $pw && $FORM{'plus'} eq '0') { + } elsif ($FORM{'plus'} eq '1' && $pluscheck || $pass eq $pw && $FORM{'plus'} eq '1') { &pluss; } elsif ($pass eq $pw && $FORM{'plus'} eq '2') { &plusedit; } elsif ($pass eq $pw && $FORM{'plus'} eq '3') { &plusregist; } # --------------------------------- # パスワードのチェック # --------------------------------- if ($pass ne $pw) { print <<"_HTML_password_";
パスワード

_HTML_password_ exit; } # --------------------------------- # 編集処理 # --------------------------------- ($new_no) = split(/$type/,$lines[0]); $new_no = ($new_no + 1) % 9999; foreach $line (@lines) { ($no,$date) = split(/$type/,$line); if ($FORM{$no} == 1) { $check = 1; if ($rq_dorama ne '') { $line = "$no$typec$date$typec$rq_dorama$typec$rq_actor\n"; push (@new,$line); } } else { push (@new,$line); } } # --------------------------------- # 記録ファイルに書き込む # --------------------------------- if ($check) { ($no,$date,$dorama,$actor) = split(/$type/,$new[0]); $new[0] = "$new_no$typec$date$typec$dorama$typec$actor"; if ($lockcheck) { local($wt) = 0; while (-f $lockfile) { if (++$wt > 5) { &error('強制終了されました。処理は中断されました。'); } sleep 4; } open (LOCK,">$lockfile"); } if (!open(OUT,">$logfile")) { unlink ($lockfile); &error("記録ファイルの書き込みに失敗しました。"); } print OUT @new; close(OUT); unlink ($lockfile); } # --------------------------------- # リストを表示 # --------------------------------- print <<"_EOF_";

WeB dorama Editor Plus

★使い方★

  1. 編集する項目をチェックします
  2. 編集内容を書きます(このとき、何も書かなかった場合、削除されます)
  3. [編集開始]で書き換えられます。

_EOF_ print "\n"; print <<"_EOF_";
[登場人物追加編集] [ドラマ]
_EOF_ foreach $line (@new) { ($no,$date,$dorama,$actor) = split(/$type/,$line); $dorama = &change1($dorama); print "\n"; print "$date : "; print "$actors[$actor] "; print "『$dorama
\n"; } # *************************** # 登場人物編集 # *************************** # --------------------------------- # 登場人物追加フォーム # --------------------------------- sub plus { print <<"_EOF_";

WeB DoRaMa Plus


あなたも小説に登場人物を追加したいはず!ということで・・・


_EOF_ print "色: \n"; print <<"_HTML_"; 人物名:
  • 変な登場人物名は入れないでください
  • タグを使用したり、全角20字を超えると登録されません。

    [もどる] _HTML_ exit; } # --------------------------------- # 登場人物名登録 # --------------------------------- sub pluss { $color = $FORM{'color'}; $name = $FORM{'name'}; $name_c = &change0($name); if ($name eq '') { &error("何も書かれていないか、または使用禁止の文字が使われているようです。<は使用しないでください。"); } if (length($name) >= 40) { &error("名前が長すぎます。文字数は全角20字を超えてはいけません。"); } # --------------------------------- # 登場人物専用記録ファイルに登録する # --------------------------------- if ($lockcheck) { $wt = 0; while (-f $lockfile) { $wt++; if ($wt > 19) { &error('強制終了されました。処理は中断されました。'); } sleep 1; } open (LOCK,">$lockfile"); } if (!open(OUT,">>$kyaralogfile")) { unlink ($lockfile); &error("管理者が登場人物記録用ファイルの書き込みを許可していません。現在は使えません。"); } print OUT "$name_c$typec$color\n"; close(OUT); unlink ($lockfile); print <<"_EOF_";

    WeB DoRaMa
    Plus


    あなたが登場させたい人物の名前が追加されました


    『$name』が追加されました

    [もどる] _EOF_ exit; } # --------------------------------- # 登場人物編集フォーム # --------------------------------- sub plusedit { print <<"_EOF_";

    WeB DoRaMa Plus Editor


    ★使い方★

    1. 編集したいを登場人物名を選びます
    2. 登場人物の色や名前を書き換えたりします
      (このとき、色の中の削除を選んだ場合、削除されます)
      (削除したものも編集可能です)
    3. [編集開始]で書き換えられます。

    _EOF_ print "編集人物:\n"; print "色: \n"; print <<"_HTML_"; 人物名:
  • タグを使用したり、全角20字を超えると登録されません。

    [もどる] _HTML_ exit; } sub plusregist { $color = $FORM{'color_p'}; $actor = $FORM{'actor_p'}; $name = $FORM{'name'}; $name_c = &change0($name); if ($color eq 'del') { $name = $mes = "削除"; } else { $mes = "『$name』に変更"; } if ($actor eq '' || $color eq '') { &error("編集人物名または色が選ばれていません"); } if ($name eq '' && $color ne 'no') { &error("何も書かれていないか、または使用禁止の文字が使われているようです。<は使用しないでください。"); } if (length($name) >= 40) { &error("名前が長すぎます。文字数は全角20字を超えてはいけません。"); } $sio = 0; foreach $line (@ptomatos) { if ($sio eq $actor) { $line = "$name_c$typec$color\n"; push (@ptomato,$line); } else { push (@ptomato,$line); } $sio++; } # --------------------------------- # 登場人物記録ファイルに登録する # --------------------------------- if ($lockcheck) { $wt = 0; while (-f $lockfile) { $wt++; if ($wt > 19) { &error('強制終了されました。処理は中断されました。'); } sleep 1; } open (LOCK,">$lockfile"); } if (!open(OUT,">$kyaralogfile")) { unlink ($lockfile); &error("登場人物記録ファイルの書き込みに失敗しました。"); } print OUT @ptomato; close(OUT); unlink ($lockfile); print <<"_EOF_";

    WeB DoRaMa
    Plus Editor


    みごと編集が完了されましたわよ。


    『$actors[$actor]』が$mesされましたわよ

    [もどる] _EOF_ exit; } # *************************** # 禁止文字コードの変換処理 # *************************** sub change0 { local($text) = $_[0]; $text =~ s/\(/(/g; $text =~ s/\)/)/g; $text =~ s/\*/*/g; $text =~ s/\+/+/g; $text =~ s/\././g; $text =~ s/\?/?/g; $text =~ s/\[/[/g; $text =~ s/\\/\/g; $text =~ s/\]/]/g; $text =~ s/\{/{/g; $text =~ s/\|/|/g; $text =~ s/\}/}/g; return $text; } sub change1 { local($text) = $_[0]; $text =~ s/(/\(/g; $text =~ s/)/\)/g; $text =~ s/*/\*/g; $text =~ s/+/\+/g; $text =~ s/./\./g; $text =~ s/?/\?/g; $text =~ s/[/\[/g; $text =~ s/\/\\/g; $text =~ s/]/\]/g; $text =~ s/{/\{/g; $text =~ s/|/\|/g; $text =~ s/}/\}/g; return $text; } # *************************** # エラー処理 # *************************** sub error { print <<"_HTML_error_";

    エラーが発生しました。

    $_[0] _HTML_error_ exit; }