#!/usr/local/bin/perl #Web Diary Professional (2005/05/04) $ver = '3.08'; # #Copyright(C) Knight 2002-2005 #Mail ... support@web-liberty.net #Home ... http://www.web-liberty.net/ #――――― 設定項目 ―――――――――――――――――――――――― #管理者用パスワード $admin_pwd = '2480mike'; #初期設定ファイル require './diary.ini'; #――――― 設定項目終了 ―――――――――――――――――――――― ### メイン処理 &mobile(); &decode(); if ($in{'mode'} eq 'res' && $res_mode == 1) { &res(); } elsif ($in{'mode'} eq 'rss' && $rss_mode == 1) { &rss(); } elsif ($in{'mode'} eq 'trackback' && $trackback_mode == 1) { &trackback(); } elsif ($in{'mode'} eq 'icon' && $icon_mode == 1) { &icon(); } elsif ($in{'mode'} eq 'img' && $img_show_way == 2) { &img(); } elsif ($in{'mode'} eq 'loglist') { &loglist(); } elsif ($in{'mode'} eq 'view') { &view(); } elsif ($in{'mode'} eq 'search') { &search(); } elsif ($in{'mode'} eq 'userdel' && $res_mode == 1) { &userdel(); } elsif ($in{'mode'} eq 'past' && $make_past == 1) { &past(); } elsif ($in{'mode'} eq 'admin') { &admin(); } elsif ($in{'mode'} eq 'regist' && $res_mode == 1) { ®ist(); } &html(); ### HTML出力 sub html { if ($mini_counter != 0) { if ($ENV{'REQUEST_METHOD'} ne 'POST' && $ENV{'QUERY_STRING'} eq '') { &count_up(); } open(COUNT, "$count_log") || &error("カウントログファイルを読み出せません。"); $data = ; close(COUNT); ($sum, $c_today, $c_yesterday, $key) = split(/\t/, $data); } open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); &header(); print qq|\n
\n|; if ($in{'date'} ne '') { if ($in{'date'} =~ /^(\d\d\d\d)(\d\d)(\d\d)$/) { $year = $1; $month = $2; $day = $3; } $diary_info = "$year年$month月$day日のエントリ"; } elsif ($in{'year'} ne '' || $in{'month'} ne '') { $diary_info = "$in{'year'}年$in{'month'}月のエントリ"; } elsif ($in{'no'} ne '') { $diary_info = 'エントリ'; } elsif ($in{'field'} ne '') { $diary_info = $fields[$in{'field'}]; } elsif ($in{'profile'} ne '') { $diary_info = '投稿者情報'; } else { $diary_info = '最近のエントリ'; } print qq|\t

$diary_info

\n|; if ($show_index == 0 || $in{'date'} ne '' || $in{'year'} ne '' || $in{'month'} ne '' || $in{'no'} ne '' || $in{'field'} ne '' || $in{'author'} ne '' || $in{'profile'} ne '') { if ($in{'profile'} ne '') { open(PROFILE, "$profile_file") || &error("プロフィール保存ファイルを読み出せません。"); @profile = ; close(PROFILE); $flag = 0; foreach (@profile) { chop($_); ($author, $text) = split(/\t/); if ($author[$in{'profile'}] eq $author) { $flag = 1; last; } } if ($flag == 0) { $author = $author[$in{'profile'}]; $text = 'プロフィールは登録されていません。'; } &showlog("0\t0\t1\t\t\t$author\t\t\tプロフィール\t$author

$text\t\t\t\t\t"); } else { &showlog(&extract(@logs)); } } else { &index_mesg(); } print qq|
\n|; &footer(); } ### インデックス sub index_mesg { print <<"_HTML_";

$title

$index_message _HTML_ if ($index_record_size != 0) { print "\t\t

最近の$index_record_size件

\n\t\t
"; $i = 0; foreach (@logs) { ($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($reno != 0) { next; } $i++; if ($i > $index_record_size) { last; } if ($display == 0) { next; } if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $date = "$1$2$3"; ($sec, $min, $hour, $day, $mon, $year, $week) = localtime(time()); $today = sprintf("%04d%02d%02d", $year + 1900, $mon + 1, $day); if ($new_date != 0 && $today - $date < $new_date) { $new = ' ' . $new_mark; } else { $new = ''; } $year = sprintf("%04d", $1); $month = sprintf("%02d", $2); $day = sprintf("%02d", $3); $week = $week[&getweek($day, $year, $month)]; $date = qq|$year年$month月$day日($week)|; } print qq|\t\t\t
$date$new
\n\t\t
$subj
\n|; } } print <<"_HTML_";
_HTML_ return; } ### カレンダー sub calendar { local(@logs) = @_; %date = (); foreach (@logs) { ($date, $icon) = (split(/\t/))[3, 11]; if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $date = "$1$2$3"; } if ($icon eq '') { $icon = '-'; } $date{"$date"} .= "$icon<>"; } ($d, $m, $y) = (localtime(time()))[3, 4, 5]; $y = sprintf("%04d", $y + 1900); $m = sprintf("%01d", $m + 1); $d = sprintf("%01d", $d); if ($in{'date'} ne '') { if ($in{'date'} =~ /^(\d\d\d\d)(\d\d)(\d\d)$/) { $year = sprintf("%04d", $1); $month = sprintf("%01d", $2); } if ($y == $year && $m == $month) { $today = $d; } } elsif ($in{'year'} eq '') { $year = $y; $month = $m; $today = $d; } else { if ($in{'year'} == $y && $in{'month'} == $m) { $today = $d; } $year = $in{'year'}; $month = $in{'month'}; } $head = qq|$year年 $month月|; $prev_month = $month - 1; $prev_year = $year; if ($prev_month < 1) { $prev_month = 12; $prev_year--; } $prev = qq|<<|; $next_month = $month + 1; $next_year = $year; if ($next_month > 12) { $next_month = 1; $next_year++; } $next = qq|>>|; print <<"_HTML_";

カレンダー

_HTML_ foreach (0 .. 6) { $week = $week[$_]; print qq|\t\t\t\n|; } print qq|\t\t\n|; $wkey = &getweek('1', $year, $month); $lastday = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)[$month - 1] + ($month == 2 && (($year % 4 == 0 && $year % 100 != 0) || $year % 400 == 0)); $i = 0; $day = 1; $flag = 0; $week_num = 0; $spend = 0; foreach (1 .. 42) { if ($wkey == $i) { $flag = 1; } if ($lastday < $day) { $flag = 0; } if ($show_voidrow == 0 && $flag == 0 && $day > 1 && $i == 0) { last; } if ($i == 0) { print qq|\t\t\n|; } if ($flag == 0) { print qq|\t\t\t\n|; } else { $month = sprintf("%02d", $month); $code = sprintf("%02d", $day); if ($day == $today) { print qq|\t\t\t\n|; } $i++; if ($i == 1 && $flag == 1) { $week_num++; } if ($i == 7) { print qq|\t\t\n|; $i = 0; } if ($flag == 1) { $day++; } } print <<"_HTML_";
$prev $head $next
|; if ($_ == 0) { print qq|$week|; } elsif ($_ == 6) { print qq|$week|; } else { print qq|$week|; } print qq|
$void_cel|; } else { print qq|\t\t\t|; } if ($i == 0) { $day_style = 'sunday'; } elsif ($i == 6) { $day_style = 'satday'; } else { $day_style = 'day'; } if ($spend == 1) { $spend = 0; $day_style = 'sunday'; } else { foreach $spend_day (@spend_day) { if ("$month$code" eq "$spend_day") { if ($i == 0) { $spend = 1; } $day_style = 'sunday'; last; } } while (($m, $n) = each(%spend_day)) { if ($i == 1 && "$month" eq "$m" && "$week_num" eq "$n") { $day_style = 'sunday'; last; } } } if ($written_mark eq '' && $date{"$year$month$code"} ne '') { print qq||; } print qq|$day|; if ($written_mark eq '' && $date{"$year$month$code"} ne '') { print qq||; } if ($date{"$year$month$code"} ne '') { $j = 1; foreach $diary_info (split(/<>/, $date{"$year$month$code"})) { if ($icon_display != 0) { if ($diary_info eq '-') { $written_icon = $written_mark } else { $written_icon = qq|エントリを表\示|; } } else { $written_icon = $written_mark; } if ($j != 1) { $diary_no = "#diary$j"; } else { $diary_no = ''; } print qq|
$written_icon|; if ($written_mark_multi == 1) { $j++; } else { last; } } } print qq|
_HTML_ $prev = qq|前の月|; $next = qq|次の月|; print qq|\t
    \n\t\t
  • $prev
  • \n\t\t
  • $next
  • \n\t
\n|; print <<"_HTML_";
表\示エントリ選択フォーム
表\示年
表\示月

_HTML_ return; } ### 最近のエントリ表示 sub record { local(@logs) = @_; if ($res_mode == 1) { $parent = 0; foreach (@logs) { if ((split(/\t/, $_))[1] == 0) { $parent++; } } } else { $parent = $#logs + 1; } if ($in{'record'} > 0) { $n = $in{'record'} - 1; $prev = qq|
  • 新しいエントリ
  • |; } else { $prev = ''; } if (int(($parent - 1) / $record_size) > $in{'record'}) { $n = $in{'record'} + 1; $next = qq|
  • 以前のエントリ
  • |; } else { $next = ''; } print <<"_HTML_";

    最近のエントリ

    _HTML_ local $start = $in{'record'} * $record_size; local $end = $start + $record_size; local $i = 0; foreach (@logs) { local($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($reno != 0) { next; } $i++; if ($i <= $start) { next; } if ($i > $end) { last; } if ($display == 0) { next; } if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $date = "$1$2$3"; ($sec, $min, $hour, $day, $mon, $year, $week) = localtime(time()); $today = sprintf("%04d%02d%02d", $year + 1900, $mon + 1, $day); if ($new_date != 0 && $today - $date < $new_date) { $new = ' ' . $new_mark; } else { $new = ''; } $date = "$1/$2/$3"; } print qq|\t\t
    $date$new
    \n\t\t\t
    $subj
    \n|; } print <<"_HTML_";
      $prev $next
    _HTML_ return; } ### 分類一覧 sub field { local(@logs) = @_; local %fields = (); foreach (@logs) { local($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ((split(/\t/, $_))[2] == 1) { $fields{(split(/\t/, $_))[4]}++; } } print <<"_HTML_";

    分類一覧

      _HTML_ local $i = 0; foreach (@fields) { if ($_ eq '') { next; } if ($fields{$_} eq '') { $fields{$_} = 0; } print qq|\t\t
    • $_($fields{$_})
    • \n|; $i++; } print <<"_HTML_";
    _HTML_ return; } ### 投稿者名一覧 sub author { local(@logs) = @_; local %author = (); foreach (@logs) { local($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ((split(/\t/, $_))[2] == 1) { $author{(split(/\t/, $_))[5]}++; } } print <<"_HTML_";

    プロフィール

      _HTML_ local $i = 0; foreach (@author) { if ($_ eq '') { next; } if ($author{$_} eq '') { $author{$_} = 0; } if ($profile_mode == 1) { if ($author[1] ne '') { $author_count = qq|($author{$_})| } else { $author_count = ''; } print qq|\t\t
    • $_$author_count
    • \n|; } else { if ($author[1] ne '') { $author_count = qq|($author{$_})| } else { $author_count = ''; } print qq|\t\t
    • $_$author_count
    • \n|; } $i++; } print <<"_HTML_";
    _HTML_ return; } ### 最近の受信トラックバック一覧 sub trackback_list { if (-e "${reserved_trackback_dir}new$reserved_trackback_ext") { open(TB, "${reserved_trackback_dir}new$reserved_trackback_ext") || &error_trackback("Read error"); @trackback = ; close(TB); } print <<"_HTML_";

    最近のトラックバック

    _HTML_ $i = 0; foreach (@trackback) { if ($i >= $show_trackback_list) { last; } local($no, $time, $blog_name, $title, $url, $excerpt) = split(/\t/); ($sec, $min, $hour, $day, $mon, $year, $week) = localtime($time); $time = sprintf("%02d/%02d-%02d:%02d", $mon + 1, $day, $hour, $min); print qq|\t\t
    $title
    \n\t\t\t
    $time $blog_name
    \n|; $i++; } print <<"_HTML_";
    _HTML_ return; } ### 最近のコメント一覧 sub res_list { local(@logs) = @_; local %comment_list = (); foreach (@logs) { local($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($reno != 0) { $comment_list{$date} = "$reno\t$date\t$name\t$subj"; } } print <<"_HTML_";

    最近のコメント

    _HTML_ local $i = 0; foreach (sort { $b <=> $a } keys %comment_list) { local($reno, $date, $name, $subj) = split(/\t/, $comment_list{$_}); $i++; if ($i > $show_res_list) { last; } ($sec, $min, $hour, $day, $mon, $year, $week) = localtime($date); $date = sprintf("%02d/%02d-%02d:%02d", $mon + 1, $day, $hour, $min); print qq|\t\t
    $subj
    \n\t\t\t
    $date $name
    \n|; } print <<"_HTML_";
    _HTML_ return; } ### ミニリンク集 sub link_list { open(LINK, "$link_file") || &error("ミニリンク集保存ファイルを読み出せません。"); @link = ; close(LINK); print <<"_HTML_"; _HTML_ return; } ### 投稿記事表示 sub showlog { local(@logs) = @_; if ($res_mode == 1) { $parent = 0; foreach (@logs) { if ((split(/\t/, $_))[1] == 0) { $parent++; } } } else { $parent = $#logs + 1; } if ($in{'mode'} ne 'past' && $in{'date'} eq '' && $in{'year'} eq '' && $in{'month'} eq '' && $in{'no'} eq '') { $start = $in{'page'} * $default_show; $end = $start + $default_show; } else { $start = 0; $end = $#logs + 1; } if ($in{'page'} > 0) { if ($in{'field'} ne '') { $field = "field=$in{'field'}&"; } else { $field = ''; } if ($in{'author'} ne '') { $author = "author=$in{'author'}&"; } else { $author = ''; } $n = $in{'page'} - 1; $prev = qq|
  • 新しいエントリ
  • |; } else { $prev = ''; } if (int(($parent - 1) / $default_show) > $in{'page'}) { if ($in{'field'} ne '') { $field = "field=$in{'field'}&"; } else { $field = ''; } if ($in{'author'} ne '') { $author = "author=$in{'author'}&"; } else { $author = ''; } $n = $in{'page'} + 1; $next = qq|
  • 以前のエントリ
  • |; } else { $next = ''; } print qq|
    \n|; $i = 0; $flag = 0; foreach (@logs) { ($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($in{'mode'} eq 'regist' || $in{'mode'} eq 'search' || $reno == 0) { $i++; } if ($i <= $start) { next; } if ($i > $end) { last; } if ($showres_mode == 0 && $in{'mode'} eq '' && $reno != 0) { next; } if ($display == 0) { next; } if ($date ne '') { if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $date = "$1$2$3"; ($sec, $min, $hour, $day, $mon, $year, $week) = localtime(time()); $today = sprintf("%04d%02d%02d", $year + 1900, $mon + 1, $day); if ($in{'preview'} ne 'on' && $new_date != 0 && $today - $date < $new_date) { $new = $new_mark; } else { $new = ''; } $year = sprintf("%04d", $1); $month = sprintf("%02d", $2); $day = sprintf("%02d", $3); if ($time_mode == 1) { $hour = sprintf("%02d", $4); $minute = sprintf("%02d", $5); } $week = $week[&getweek($day, $year, $month)]; $date = qq|$year年$month月$day日($week)|; } else { if ($in{'preview'} ne 'on' && $new_date != 0 && time() - $date < $new_date * 24 * 60 * 60) { $new = ' ' . $new_mark; } else { $new = ''; } $new = ''; ($sec, $min, $hour, $day, $mon, $year, $week) = localtime($date); $date = sprintf("%04d年%02d月%02d日(%s)%02d:%02d", $year + 1900, $mon + 1, $day, $week[$week], $hour, $min); } } else { $new = ''; } $field_no = 0; foreach $field_name (@fields) { if ($field eq $field_name) { last; } $field_no++; } if ($author_mode == 1 && $reno == 0) { $author_no = 0; foreach $author_name (@author) { if ($name eq $author_name) { last; } $author_no++; } } if ($mail ne '') { $mail = qq| Eメール|; } if ($url ne '') { $url = qq| URL|; } foreach $html (@no_paragrath_html_a) { if ($html eq '') { next; } $text =~ s/(<$html>)/<\/p>$1/gi; $text =~ s/(<\/$html>)/$1

    /gi; } foreach $html (@no_paragrath_html_b) { if ($html eq '') { next; } $text =~ s/(<${html}[^>]*>)/<\/p>$1

    /gi; } if ($paragraph_mode == 1) { $text =~ s/

    /<\/p>

    /g; } if ($auto_link == 1) { $text = &auto_link($text); } if ($upload_mode == 1 && $file ne '') { @file_info = (); @file = split(/<>/, $file); $j = 0; foreach $file_name (@file) { if (! -e "$upfile_dir$file_name") { next; } $j++; $file_info = ''; $file_name =~ /[^\/\\]*\.([^.\/\\]*)$/; $ext = ".$1"; $file_size = &comma(int((stat("$upfile_dir$file_name"))[7] / 1024)); if ($file_size == 0) { $file_size = 1; } if ($ext eq '.gif' || $ext eq '.jpeg' || $ext eq '.jpg' || $ext eq '.jpe' || $ext eq '.png') { if ($thumbnail_mode == 1 && -e "$thumbnail_url$file_name" && ($img_single_max_width == 0 || ($file[1] ne '' || $file[2] ne ''))) { open(IMG, "$thumbnail_url$file_name"); binmode(IMG); if ($ext eq '.gif') { ($img_width, $img_height) = &gifsize(*IMG); } elsif ($ext eq '.jpeg' || $ext eq '.jpg' || $ext eq '.jpe') { ($img_width, $img_height) = &jpegsize(*IMG); } elsif ($ext eq '.png') { ($img_width, $img_height) = &pngsize(*IMG); } close(IMG); $file_info = qq|アップロードファイル ${file_size}KB|; $file_insert_l = qq|アップロードファイル ${file_size}KB|; $file_insert_r = qq|アップロードファイル ${file_size}KB|; $file_insert = qq|アップロードファイル ${file_size}KB|; if ($img_show_way == 2) { open(IMG, "$upfile_dir$file_name"); binmode(IMG); if ($ext eq '.gif') { ($img_width, $img_height) = &gifsize(*IMG); } elsif ($ext eq '.jpeg' || $ext eq '.jpg' || $ext eq '.jpe') { ($img_width, $img_height) = &jpegsize(*IMG); } elsif ($ext eq '.png') { ($img_width, $img_height) = &pngsize(*IMG); } close(IMG); $org_img_width = $img_width; $org_img_height = $img_height; } $thumbnail_flag = 1; } else { open(IMG, "$upfile_dir$file_name"); binmode(IMG); if ($ext eq '.gif') { ($img_width, $img_height) = &gifsize(*IMG); } elsif ($ext eq '.jpeg' || $ext eq '.jpg' || $ext eq '.jpe') { ($img_width, $img_height) = &jpegsize(*IMG); } elsif ($ext eq '.png') { ($img_width, $img_height) = &pngsize(*IMG); } close(IMG); if ($img_show_way == 2) { $org_img_width = $img_width; $org_img_height = $img_height; } if ($img_single_max_width != 0 && $file[1] eq '' && $file[2] eq '') { if ($img_width > $img_single_max_width) { $img_height = int($img_height / ($img_width / $img_single_max_width)); $img_width = $img_single_max_width; $thumbnail_flag = 1; } else { $thumbnail_flag = 0; } } else { if ($img_width > $img_max_width) { $img_height = int($img_height / ($img_width / $img_max_width)); $img_width = $img_max_width; $thumbnail_flag = 1; } else { $thumbnail_flag = 0; } } $file_info = qq|アップロードファイル ${file_size}KB|; $file_insert_l = qq|アップロードファイル ${file_size}KB|; $file_insert_r = qq|アップロードファイル ${file_size}KB|; $file_insert = qq|アップロードファイル ${file_size}KB|; } if ($thumbnail_flag == 1) { if ($img_show_way == 0) { $link_start = qq||; $link_end = ''; } elsif ($img_show_way == 1) { $link_start = qq||; $link_end = ''; } elsif ($img_show_way == 2) { $link_start = qq||; $link_end = ''; } $file_info = "$link_start$file_info$link_end"; $file_insert_l = "$link_start$file_insert_l$link_end"; $file_insert_r = "$link_start$file_insert_r$link_end"; $file_insert = "$link_start$file_insert$link_end"; } $file_insert_l[$j] = $file_insert_l; $file_insert_r[$j] = $file_insert_r; $file_insert[$j] = $file_insert; } else { $file_info = qq|

    $file_name(${file_size}KB)

    |; $file_insert[$j] = qq|$file_name(${file_size}KB)|; } if ($text !~ /\$FILE$j/) { push(@file_info, $file_info); } } $file_info = ''; foreach $file (@file_info) { $file_info .= $file; } } else { $file_info = ''; $j = 0; } if ($icon_mode == 1 && $icon_display != 1 && $icon ne '') { $icon = qq|$icon|; } else { $icon = ''; } foreach $k (1 .. 3) { if ($k > $j) { last; } $text =~ s/\$FILE${k}_l/$file_insert_l[$k]/g; $text =~ s/\$FILE${k}_r/$file_insert_r[$k]/g; $text =~ s/\$FILE${k}/$file_insert[$k]/g; } if ($pause_string ne '' && $reno == 0 && $text =~ /$pause_string/) { if ($in{'no'} eq '') { $text = (split(/$pause_string/, $text, 2))[0]; $text .= qq|... 続きを読む|; } else { $text =~ s/$pause_string//; } } if ($color_mode == 1) { if ($color eq '') { $color = $color[0]; } $text = qq|$text|; } chop($host); if ($res_mode == 1 && $logs[0] + 0 != 0 && ($in{'mode'} eq '' || $in{'mode'} eq 'view')) { if ($comment{$no} eq '') { $comment = 0; } else { $comment = $comment{$no}; } $res = qq|
  • コメント($comment)
  • |; } if ($trackback_mode == 1 && $subj ne '') { if (-e "$reserved_trackback_dir$no$reserved_trackback_ext") { open(TB, "$reserved_trackback_dir$no$reserved_trackback_ext") || &error("受信トラックバック一覧ファイルを読み出せません。"); @trackback = ; close(TB); $trackback = $#trackback + 1; } else { $trackback = 0; } $trackback = qq|
  • トラックバック($trackback)
  • |; } else { $trackback = ''; } if (($in{'mode'} eq 'search' && $in{'no'} eq '' && $flag == 1) || ($flag == 1 && $reno == 0)) { print "\t
    \n"; } if ($subj eq '') { $subj = 'No Data'; } if (($in{'mode'} eq 'regist' && $in{'back'} eq '') || ($in{'mode'} eq 'search' && $in{'no'} eq '') || $reno == 0) { $flag = 1; if ($in{'date'} ne '') { $date_id = qq| id="diary$i"|; } else { $date_id = ''; } print <<"_HTML_";
    _HTML_ } if (($in{'mode'} eq 'search' && $in{'no'} eq '') || $reno == 0) { if ($res_mode == 1 && $in{'mode'} eq 'search' && $in{'no'} eq '') { if ($reno == 0) { $show = $no; } else { $show = $reno; } $all_show_info = qq|
  • 関連記事を表\示
  • |; } else { $all_show_info = ''; } $date_info = "$date"; if ($time_mode == 1) { $date_info .= "$hour:$minute"; } if ($in{'mode'} eq 'past') { $date_info = qq|
  • $date_info
  • |; } else { $date_info = qq|
  • $date_info
  • |; } print <<"_HTML_";

    $subj

    $file_info$icon

    $text

    _HTML_ if ($subj ne 'No Data') { if ($file_name{'file1'} ne '' || $file_name{'file2'} ne '' || $file_name{'file3'} ne '') { print "\t\t
    \n"; if ($file_name{'file1'} ne '') { $file_name{'file1'} =~ /([^\/\\]*)\.([^.\/\\]*)$/; $filename1 = "$1\.$2"; print <<"_HTML_";
    アップロードファイル1
    $filename1
    _HTML_ } if ($file_name{'file2'} ne '') { $file_name{'file2'} =~ /([^\/\\]*)\.([^.\/\\]*)$/; $filename2 = "$1\.$2"; print <<"_HTML_";
    アップロードファイル2
    $filename2
    _HTML_ } if ($file_name{'file3'} ne '') { $file_name{'file3'} =~ /([^\/\\]*)\.([^.\/\\]*)$/; $filename3 = "$1\.$2"; print <<"_HTML_";
    アップロードファイル3
    $filename3
    _HTML_ } print "\t\t
    \n"; } if ($new ne '') { $new = "
  • $new_mark
  • "; } else { $new = ''; } if ($fields[1] ne '') { $field = qq|
  • $field
  • |; } else { $field = ''; } if ($author_mode == 1 && $name ne '') { if ($in{'profile'} ne '') { $name = qq|
  • $nameの投稿記事一覧
  • |; $new = ''; $date_info = ''; $field = ''; $all_show_info = ''; $res = ''; $trackback = ''; } elsif ($profile_mode == 1) { $name = qq|
  • $name
  • |; } else { $name = qq|
  • $name
  • |; } } else { $name = ''; } print <<"_HTML_";
      $new$date_info$field$all_show_info$res$trackback$name
    _HTML_ } } else { print <<"_HTML_";
    $name$mail$url $date$new
    $icon$file_info

    $text

    _HTML_ } } if ($flag == 1) { print <<"_HTML_";
    _HTML_ } print <<"_HTML_"; _HTML_ if ($in{'mode'} ne 'search' && $in{'mode'} ne 'past' && $in{'date'} eq '' && $in{'year'} eq '' && $in{'month'} eq '' && $in{'no'} eq '') { print <<"_HTML_"; _HTML_ } return; } ### 表示ログ抽出 sub extract { local(@logs) = @_; $i = 0; @show = (); %comment = (); foreach (@logs) { ($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($display == 0) { next; } if ($reno != 0) { $comment{$reno}++; } if ($in{'date'} ne '') { if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $year = $1; $month = $2; $day = $3; if($in{'date'} =~ /^(\d\d\d\d)(\d\d)(\d\d)$/ && $year == $1 && $month == $2 && $day == $3) { push(@show, $_); $show_no = $no; } } elsif ($show_no ne '' && $show_no == $reno) { push(@show, $_); } } elsif ($in{'year'} ne '' || $in{'month'} ne '') { if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/ && $in{'year'} == $1 && $in{'month'} == $2) { push(@show, $_); $show_no = $no; } elsif ($show_no ne '' && $show_no == $reno) { push(@show, $_); } } elsif ($in{'no'} ne '') { if ($in{'no'} == $no || $in{'no'} == $reno) { push(@show, $_); } } elsif ($in{'field'} ne '') { if ($fields[$in{'field'}] eq $field) { push(@show, $_); } } elsif ($in{'author'} ne '') { if ($author[$in{'author'}] eq $name) { push(@show, $_); } } else { push(@show, $_); } } if (($in{'date'} ne '' || $in{'year'} ne '' || $in{'month'} ne '' || $in{'no'} ne '') && $show[0] eq '') { opendir(DIR, "$past_dir") || &error("過去ログディレクトリを読み出せません。"); @dir = readdir(DIR); closedir(DIR); @dir = sort {$b <=> $a} (@dir); @past = (); foreach (@dir) { if ($_ =~ /^\d+(\.\w+)$/ && $1 eq $past_ext) { open(FILE, "$past_dir$_") || &error("過去ログファイルを読み出せません。"); @file = ; close(FILE); push(@past, @file); } } foreach (@past) { ($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($display == 0) { next; } if ($reno != 0) { $comment{$reno}++; } if ($in{'date'} ne '') { if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $year = $1; $month = $2; $day = $3; if($in{'date'} =~ /^(\d\d\d\d)(\d\d)(\d\d)$/ && $year == $1 && $month == $2 && $day == $3) { push(@show, $_); $show_no = $no; } } elsif ($show_no ne '' && $show_no == $reno) { push(@show, $_); } } elsif ($in{'year'} ne '' || $in{'month'} ne '') { if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/ && $in{'year'} == $1 && $in{'month'} == $2) { push(@show, $_); $show_no = $no; } elsif ($show_no ne '' && $show_no == $reno) { push(@show, $_); } } elsif ($in{'no'} ne '') { if ($in{'no'} == $no || $in{'no'} == $reno) { push(@show, $_); } } } } @logs = (); if ($show[0] ne '') { @logs = @show; } else { $logs[0] = "0\t0\t1\t\t\t\t\t\t\t該当するエントリはありません。\t\t\t\t\t"; } return @logs; } ### 投稿フォーム表示 sub form { if ($in{'mode'} eq 'res' && $in{'back'} eq '') { %cookie = &get_cookie($cookie_id); if ($cookie{'url'} eq '') { $cookie{'url'} = 'http://'; } if ($cookie{'color'} eq '') { $cookie{'color'} = $color[0]; } $form_name = $cookie{'name'}; $form_mail = $cookie{'mail'}; $form_url = $cookie{'url'}; $form_text = ''; $form_icon = $cookie{'icon'}; $form_color = $cookie{'color'}; $form_pwd = $cookie{'pwd'}; $form_preview = $cookie{'preview'}; $form_mode = 'regist'; $form_submit = 'コメントを書く'; $form_no = ''; $form_reno = $in{'no'}; $form_date = ''; $form_subj = 'Re:' . (split(/\t/, $logs[0]))[8]; $form_user_pwd = ''; } elsif ($in{'back'} ne '') { if ($in{'url'} eq '') { $in{'url'} = 'http://'; } $in{'text'} =~ s/
    /\n/g; $form_name = $in{'name'}; $form_mail = $in{'mail'}; $form_url = $in{'url'}; $form_text = $in{'text'}; $form_icon = $in{'icon'}; $form_color = $in{'color'}; $form_pwd = $in{'pwd'}; $form_preview = $in{'c_preview'}; $form_mode = 'regist'; $form_submit = 'コメントを書く'; $form_no = $in{'no'}; $form_reno = $in{'reno'}; $form_date = ''; $form_subj = $in{'subj'}; $form_user_pwd = $in{'user_pwd'}; } else { $text =~ s/
    /\n/g; $form_name = $name; $form_mail = $mail; $form_url = $url; $form_text = $text; $form_icon = $icon; $form_color = $color; $form_pwd = $in{'user_pwd'}; $form_preview = ''; $form_mode = 'userdel'; $form_submit = '修正する'; $form_no = $no; $form_reno = $reno; $form_date = $date; $form_subj = $subj; $form_user_pwd = $in{'user_pwd'}; } print <<"_HTML_";
    投稿フォーム
    名前
    Eメール
    URL
    本文
    _HTML_ if ($icon_mode == 1) { print <<"_HTML_";
    アイコン
    アイコン一覧
    _HTML_ } if ($color_mode == 1) { print <<"_HTML_";
    本文の色
    _HTML_ foreach (@color) { if ($_ eq '') { next; } $color_label = $_; $color_label =~ s/#//g; if ($form_color eq $_) { print qq|\t\t\t\t\t\t\n|; } else { print qq|\t\t\t\t\t\t\n|; } } print <<"_HTML_";
    _HTML_ } print <<"_HTML_";
    削除キー
    _HTML_ if ($show_preview == 0 || $in{'mode'} eq 'userdel') { print qq|\t\t\t\n|; } elsif ($show_preview == 1) { if ($form_preview eq 'on') { print qq|\t\t\t
      \n\t\t\t\t
    • |; } else { print qq|\t\t\t
        \n\t\t\t\t
      • |; } print qq|
      • \n\t\t\t
      \n|; } else { print qq|\t\t\t\n|; } print <<"_HTML_";

    _HTML_ return; } ### 返信フォーム表示 sub res { open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); $past_flag = 0; @res = (); foreach (@logs) { ($no, $reno) = split(/\t/); if ($in{'no'} == $no || $in{'no'} == $reno) { push(@res, $_); } } if ($res[0] eq '') { opendir(DIR, "$past_dir") || &error("過去ログディレクトリを読み出せません。"); @dir = readdir(DIR); closedir(DIR); @dir = sort {$b <=> $a} (@dir); @past = (); foreach (@dir) { if ($_ =~ /^\d+(\.\w+)$/ && $1 eq $past_ext) { open(FILE, "$past_dir$_") || &error("過去ログファイルを読み出せません。"); @file = ; close(FILE); push(@past, @file); } } foreach (@past) { ($no, $reno) = split(/\t/); if ($in{'no'} == $no || $in{'no'} == $reno) { push(@res, $_); } } $past_flag = 1; } @logs = @res; &header(); print <<"_HTML_";

    コメント一覧

    _HTML_ &showlog(@logs); if ($past_flag == 1) { print <<"_HTML_";
    • この記事は過去ログに移行されているので、コメントを書くことはできません。
    _HTML_ } else { &form(); } print <<"_HTML_"; _HTML_ &footer(); } ### RSS配信 sub rss { open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); local @logs = ; close(FILE); local(@items, @text, $code, $rss); local $i = 0; foreach (@logs) { local($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($reno == 0) { $i++; } if ($i > $rss_size) { last; } if ($display == 0) { next; } if ($reno == 0) { if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $code = "$1$2$3"; } local @text = split(/

    /, $text); $text[0] =~ s/<[^>]*>//g; push(@items, "$subj\t$original_file?date=$code\t$text[0]\t$field\t$date"); } } local $rss = &make_rss("$original_file?mode=rss", $site_title, $site_url, $site_description, $original_file, @items); print "Content-Type: text/xml\n\n"; print $rss; exit(); } ### 受信トラックバック一覧表示 sub trackback { if ($in{'no'} =~ /[^\w\-\_]/) { &error("トラックバックIDは半角英数字で指定してください。"); } if (-e "$reserved_trackback_dir$in{'no'}$reserved_trackback_ext") { open(TB, "$reserved_trackback_dir$in{'no'}$reserved_trackback_ext") || &error("受信トラックバック一覧ファイルを読み出せません。"); @trackback = ; close(TB); } @trackback = reverse(@trackback); &header(); print <<"_HTML_";

    トラックバック一覧

    この記事のトラックバックURL
    $trackback_script/$in{'no'}
    _HTML_ foreach (@trackback) { chop($_); ($tb_no, $tb_time, $tb_blog_name, $tb_title, $tb_url, $tb_excerpt) = split(/\t/); ($sec, $min, $hour, $day, $mon, $year, $week) = localtime($tb_time); $tb_time = sprintf("%04d年%02d月%02d日(%s)%02d:%02d", $year + 1900, $mon + 1, $day, $week[$week], $hour, $min); print <<"_HTML_";
    $tb_title from $tb_blog_name
    $tb_excerpt 続きを読む
    $tb_time 受信
    _HTML_ } print <<"_HTML_";
    _HTML_ &footer(); } ### 投稿画像表示 sub img { print <<"_HTML_"; Content-Type: text/html IMAGE WINDOW クリックするとウインドウを閉じます _HTML_ exit; } ### アイコン一覧 sub icon { &header(); print <<"_HTML_";

    アイコン一覧

    • 選択できるアイコンは以下のとおりです。
    _HTML_ @new = (); foreach (@icon) { if ($_ ne '') { push(@new, $_); } } @icon = @new; $icon_no = ($#icon + 1) / 2; foreach (1 .. $icon_no) { if (($_ % 5) == 1) { print "\t\t\n"; } $icon_file = shift(@icon); $icon_name = shift(@icon); print qq|\t\t\t\n|; if (($_ % 5) == 0) { print "\t\t\n"; } if ($_ == $icon_no && ($_ % 5) != 0) { foreach (1 .. (5 - ($_ % 5))) { print qq|\t\t\t\n|; } print "\t\t\n"; } } print <<"_HTML_";

    $icon_name

    $icon_name

    _HTML_ &footer(); } ### タイトル一覧 sub loglist { open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); $parent = 0; foreach (@logs) { if ((split(/\t/))[1] == 0) { $parent++; } } &header(); print <<"_HTML_";

    タイトル一覧

      _HTML_ $start = $in{'page'} * $list_size; $end = $start + $list_size; $i = 0; foreach (@logs) { ($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($reno == 0) { $i++; } if ($reno != 0 || $i <= $start) { next; } if ($i > $end) { last; } if ($display == 0) { next; } if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $date = "$1$2$3"; ($sec, $min, $hour, $day, $mon, $year, $week) = localtime(time()); $today = sprintf("%04d%02d%02d", $year + 1900, $mon + 1, $day); if ($new_date != 0 && $today - $date < $new_date) { $new = ' ' . $new_mark; } else { $new = ''; } $year = sprintf("%04d", $1); $month = sprintf("%02d", $2); $day = sprintf("%02d", $3); $week = $week[&getweek($day, $year, $month)]; $date = qq|$year年$month月$day日($week)|; } if ($icon_mode == 1 && $icon_display != 0 && $icon ne '') { $icon = qq|$icon|; } else { $icon = ''; } print qq|\t\t
    • $date   $icon$subj$new
    • \n|; } print <<"_HTML_";
    _HTML_ &footer(); } ### 個別表示 sub view { open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); &header(); %comment = (); @show = (); $i = 1; $pno = 0; foreach (@logs) { ($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($in{'no'} == $i || ($reno != 0 && $reno == $pno)) { push(@show, $_); if ($in{'no'} == $i) { $pno = $no; } $comment{$reno}++; } if ($reno == 0) { $i++; } } if ($in{'mode'} eq '') { $view = qq|
  • 以前のエントリを表\示
  • |; } else { $prev_view = '前のエントリ'; $next_view = '次のエントリ'; if ($in{'no'} != $i - 1) { $prev_no = $in{'no'} + 1; $prev_view = qq|
  • $prev_view
  • |; } else { $prev_view = qq|
  • $prev_view
  • |; } if ($in{'no'} != 1) { $next_no = $in{'no'} - 1; $next_view = qq|
  • $next_view
  • |; } else { $next_view = qq|
  • $next_view
  • |; } } print <<"_HTML_";

    個別表\示

    _HTML_ &showlog(@show); print <<"_HTML_"; _HTML_ &footer(); } ### ログ検索 sub search { &header(); print <<"_HTML_";

    ログ検索

    • 検索したいキーワードを入力し、検索ボタンを押してください。
    • キーワードは半角スペースで区切って複数指定することができます。
    検索フォーム
    キーワード
    検索条件
    _HTML_ if ($make_past == 1) { print <<"_HTML_";
    検索対象
    _HTML_ } print <<"_HTML_";
    • _HTML_ if ($in{'string'} eq 'dis') { print qq|\t\t\t\t\t\n|; } else { print qq|\t\t\t\t\t\n|; } print <<"_HTML_";

    _HTML_ if ($in{'word'} ne '' || $in{'no'} ne '') { if ($make_past == 0 || $in{'obje'} ne 'past') { open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @search = ; close(FILE); } if ($make_past == 1 && $in{'obje'} ne 'now') { opendir(DIR, "$past_dir") || &error("過去ログディレクトリを読み出せません。"); @dir = readdir(DIR); closedir(DIR); @dir = sort {$b <=> $a} (@dir); @past = (); foreach (@dir) { if ($_ =~ /^\d+(\.\w+)$/ && $1 eq $past_ext) { open(FILE, "$past_dir$_") || &error("過去ログファイルを読み出せません。"); @file = ; close(FILE); push(@past, @file); } } if ($in{'obje'} eq 'all') { push(@search, @past); } elsif($in{'obje'} eq 'past') { @search = @past; } } if ($in{'word'} ne '') { $in{'word'} =~ s/ / /g; @pairs = split(/\s+/, $in{'word'}); @logs = (); foreach (@search) { $string = $_; $flag = 0; foreach $pair (@pairs) { if ($in{'string'} eq 'dis') { $string =~ tr/A-Z/a-z/; $pair =~ tr/A-Z/a-z/; } if (index($string, $pair) >= 0) { $flag = 1; if ($in{'cond'} eq 'or') { last; } } else { if ($in{'cond'} eq 'and') { $flag = 0; last; } } } if ($flag != 0) { push(@logs, $_); } } print <<"_HTML_"; _HTML_ } elsif ($in{'no'} ne '') { @logs = (); foreach (@search) { ($no, $reno) = split(/\t/); if (($reno == 0 && $in{'no'} == $no) || ($reno != 0 && $in{'no'} == $reno)) { push(@logs, $_); } } } $default_show = $page_size; &showlog(@logs); } print <<"_HTML_"; _HTML_ &footer(); } ### ユーザー記事削除 sub userdel { if ($in{'prev'} ne '') { $in{'page'}--; } if ($in{'next'} ne '') { $in{'page'}++; } if ($in{'delete'} ne '') { if ($ENV{'REQUEST_METHOD'} ne 'POST') { &error("不正なアクセスです。"); } if ($ENV{'HTTP_REFERER'} ne '' && $base_url ne '' && $ENV{'HTTP_REFERER'} !~ /^$base_url/i) { &error("不正なアクセスです。"); } if ($in{'user_pwd'} eq '') { &error("削除キーを入力してください。"); } if ($in{'del'} eq '') { &error("削除したい記事を選択してください。"); } &lock($lock_file); open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); @new = (); $flag = 0; $del_list = ''; foreach (@logs) { ($no, $reno, $pwd) = (split(/\t/))[0, 1, 13]; if ($flag == 0 && $in{'del'} == $no) { &decrypt($in{'user_pwd'}, $pwd); $flag = 1; } elsif ($flag == 1 && $in{'del'} == $reno) { $flag = 1; } else { $flag = 0; } if ($flag == 0) { push(@new, $_); } else { $del_list .= "$no "; } } $work_mesg = "$del_list番の記事を削除しました。"; open(FILE, ">$log_file") || &error("ログファイルに書き込めません。"); print FILE @new; close(FILE); if ($html_mode == 1) { &output_htmlfile(); } if ($js_mode != 0) { &output_jsfile(@new); } &unlock($lock_file); } if ($edit_mode == 1 && $in{'modify'} ne '') { if ($ENV{'REQUEST_METHOD'} ne 'POST') { &error("不正なアクセスです。"); } if ($ENV{'HTTP_REFERER'} ne '' && $base_url ne '' && $ENV{'HTTP_REFERER'} !~ /^$base_url/i) { &error("不正なアクセスです。"); } if ($in{'user_pwd'} eq '') { &error("削除キーを入力してください。"); } if ($in{'modi'} eq '') { &error("修正したい記事を選択してください。"); } open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); $flag = 0; foreach (@logs) { chop($_); ($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($in{'modi'} == $no) { &decrypt($in{'user_pwd'}, $pwd); $flag = 1; last; } } if ($flag != 1) { &error("該当する記事が見つかりません。"); } &header(); print <<"_HTML_";

    記事修正

    • 記事を修正して、修正ボタンを押してください。
    _HTML_ &form(); print <<"_HTML_"; _HTML_ &footer(); } if ($edit_mode == 1 && $in{'no'} ne '') { ®ist_check(); &lock($lock_file); open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); if ($in{'subj'} eq '') { $in{'subj'} = '無題'; } if ($in{'url'} eq 'http://') { $in{'url'} = ''; } if ($in{'pwd'} ne '') { $in{'pwd'} = &encrypt($in{'pwd'}); } $line = "$in{'no'}\t$in{'reno'}\t1\t$in{'date'}\t\t$in{'name'}\t$in{'mail'}\t$in{'url'}\t$in{'subj'}\t$in{'text'}\t$in{'color'}\t$in{'icon'}\t$in{'file'}\t$in{'pwd'}\t$host\n"; @new = (); foreach (@logs) { if ($in{'no'} == ($_ + 0)) { push(@new, $line); } else { push(@new, $_); } } $work_mesg = "$in{'no'}番の記事を修正しました。"; open(FILE, ">$log_file") || &error("ログファイルに書き込めません。"); print FILE @new; close(FILE); if ($html_mode == 1) { &output_htmlfile(); } if ($js_mode != 0) { &output_jsfile(@new); } &unlock($lock_file); } open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); $parent = 0; foreach (@logs) { if ((split(/\t/))[1] == 0) { $parent++; } } &header(); print <<"_HTML_";

    記事編集

    • 削除キーを入力して削除したい記事にチェックを入れ、削除ボタンを押してください。
    • _HTML_ if ($edit_mode == 1) { print qq|\t\t
    • 削除キーを入力して修正したい記事にチェックを入れ、修正ボタンを押してください。
    • \n|; } print <<"_HTML_";
    • 投稿時に削除キーを設定していなければ記事を削除することはできません。
    記事編集フォーム
    削除キー

    _HTML_ if ($edit_mode == 1) { print qq|\t\t\t\t\n|; } print <<"_HTML_";

    スレッド数
    $parent

    $work_mesg

    _HTML_ if ($edit_mode == 1) { print qq|\t\t\t\t\t\n|; } print <<"_HTML_"; _HTML_ $start = $in{'page'} * $page_size; $end = $start + $page_size; $i = 0; foreach (@logs) { ($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($reno == 0) { $i++; } if ($i <= $start) { next; } if ($i > $end) { last; } if ($display == 0) { next; } if ($reno == 0) { if ($name eq '') { $name = '管理者'; } $subj = "$subj"; } $text =~ s/<[^>]*>//g; if (length($text) > 60) { $text = substr($text, 0, 60) . ' …'; } if ($reno == 0) { print <<"_HTML_"; _HTML_ } else { print <<"_HTML_"; _HTML_ } if ($edit_mode == 1) { if ($reno == 0) { print <<"_HTML_"; _HTML_ } else { print <<"_HTML_"; _HTML_ } } print <<"_HTML_"; _HTML_ } print <<"_HTML_";
    削除修正No 投稿者 題名 本文
    $no $name $subj $text

    _HTML_ if ($in{'page'} > 0) { print qq|\t\t\t\t\n|; } if (int(($parent - 1) / $page_size) > $in{'page'}) { print qq|\t\t\t\t\n|; } print <<"_HTML_";

    _HTML_ &footer(); } ### 過去ログ表示 sub past { opendir(DIR, "$past_dir") || &error("過去ログディレクトリを読み出せません。"); @dir = readdir(DIR); closedir(DIR); @dir = sort {$a <=> $b} (@dir); $past_byte = 0; foreach (@dir) { if ($_ =~ /^\d+(\.\w+)$/ && $1 eq $past_ext) { $past_byte += (stat("$past_dir$_"))[7]; } } &header(); print <<"_HTML_";

    過去ログ

    • 表\示したい過去ログを選択し、表\示ボタンを押してください。
    • ログ検索によって過去ログを検索することができます。
    過去ログ選択フォーム
    表\示ログ

    _HTML_ if ($in{'view'} ne '' && $in{'view'} =~ /^\d+\.\w+$/ && -e "$past_dir$in{'view'}") { open(FILE, "$past_dir$in{'view'}") || &error("過去ログファイルを読み出せません。"); @logs = ; close(FILE); if ($past_show == 1) { if ($in{'no'} ne '') { @show = (); foreach (@logs) { ($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($display == 0) { next; } if ($in{'no'} == $no || $in{'no'} == $reno) { push(@show, $_); } } &showlog(@show); } else { print <<"_HTML_";
      _HTML_ foreach (@logs) { ($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($reno != 0) { next; } if ($display == 0) { next; } if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $year = sprintf("%04d", $1); $month = sprintf("%02d", $2); $day = sprintf("%02d", $3); $week = $week[&getweek($day, $year, $month)]; $date = qq|$year年$month月$day日($week)|; } print qq|\t\t
    • $date   $subj
    • \n|; } print <<"_HTML_";
    _HTML_ } } else { &showlog(@logs); } } print <<"_HTML_"; _HTML_ &footer(); } ### 管理者用 sub admin { if ($in{'admin_pwd'} eq '') { &admin_login(); } else { if ($ENV{'REQUEST_METHOD'} ne 'POST') { &error("不正なアクセスです。"); } if ($ENV{'HTTP_REFERER'} ne '' && $base_url ne '' && $ENV{'HTTP_REFERER'} !~ /^$base_url/i) { &error("不正なアクセスです。"); } if ($in{'admin_pwd'} ne $admin_pwd) { &error("パスワードが違います。"); } if ($in{'prev'} ne '') { $in{'page'}--; } if ($in{'next'} ne '') { $in{'page'}++; } #過去ログ作成・読み戻し if ($make_past == 1 && ($in{'create_log'} ne '' || $in{'read_log'} ne '')) { &lock($lock_file); opendir(DIR, "$past_dir") || &error("過去ログディレクトリを読み出せません。"); @dir = readdir(DIR); closedir(DIR); @dir = sort {$a <=> $b} (@dir); open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); if ($in{'create_log'} ne '') { &admin_createlog(); } if ($in{'read_log'} ne '') { &admin_readlog(); } open(FILE, ">$log_file") || &error("ログファイルに書き込めません。"); print FILE @logs; close(FILE); if ($html_mode == 1) { &output_htmlfile(); } if ($js_mode != 0) { &output_jsfile(@logs); } &unlock($lock_file); } #ログ削除 if ($in{'delete'} ne '') { if ($in{'del'} eq '') { &error("削除したいエントリを選択してください。"); } &lock($lock_file); &admin_delete(); if ($html_mode == 1) { &output_htmlfile(); } if ($js_mode != 0) { &output_jsfile(@new); } &unlock($lock_file); } #ログ登録・修正フォーム if ($in{'exec'} eq 'new' || $in{'back'} ne '' || $in{'modify'} ne '') { &admin_form(); } #ログ登録・修正 if ($in{'regist'} ne '' || $in{'modi'} ne '') { &admin_inputcheck(); &lock($lock_file); open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); if ($in{'regist'} ne '') { $no = &admin_regist(); } else { $no = &admin_modi(); } open(FILE, ">$log_file") || &error("ログファイルに書き込めません。"); print FILE @logs; close(FILE); if ($thumbnail_mode == 1) { $make_flag = &make_thumbnail($upfile_dir, $thumbnail_dir, $img_max_width); if ($make_flag == 0) { &error("エントリを新規に書き込みましたが、サムネイル画像の作成に失敗しました。"); } } if ($trackback_mode == 1 && $in{'trackback_url'} ne '') { ($send_flag, $error_message) = &send_trackback($in{'trackback_url'}, $in{'subj'}, "$trackback_self_url?no=$no", $in{'text'}, $title); if ($send_flag == 0) { &error("エントリを新規に書き込みましたが、トラックバックの送信に失敗しました。
    Error message : $error_message"); } open(TB, "$sended_trackback_file") || &error("送信トラックバック一覧ファイルを読み出せません。"); @trackback = ; close(TB); $date = time(); $trackback_no = $trackback[0] + 1; unshift(@trackback, "$trackback_no\t$date\t$in{'trackback_url'}\t$in{'subj'}\t$trackback_self_url?date=$in{'date'}\t$in{'text'}\t$title\n"); splice(@trackback, $max_trackback); open(TB, ">$sended_trackback_file") || &error("送信トラックバック一覧ファイルに書き込めません。"); print TB @trackback; close(TB); } if ($ping_mode == 1) { ($send_flag, @error_message) = &send_ping($title, $ping_self_url, @ping_server); if ($send_flag == 0) { $error_message = ''; foreach (@error_message) { $error_message .= "$_
    "; } &error("エントリを新規に書き込みましたが、更新PINGの送信に失敗しました。
    Error message : $error_message"); } } if ($html_mode == 1) { &output_htmlfile(); } if ($js_mode != 0) { &output_jsfile(@logs); } &unlock($lock_file); } #プロフィール設定 if ($profile_mode == 1 && $in{'exec'} eq 'profile') { if ($in{'profile_regist'} ne '') { &admin_profile_regist(); } if ($in{'profile_form'} ne '' || $author[1] eq '') { if ($author[1] eq '') { $in{'author'} = $author[0]; } &admin_profile_form(); } &admin_profile_list(); } #受信トラックバック削除 if ($trackback_mode == 1 && $in{'exec'} eq 'trackback') { if ($in{'tb_list'} ne '') { &admin_tb_list(); } elsif ($in{'tb_delete'} ne '') { &admin_tb_delete(); } elsif ($in{'tb_clear'} ne '') { &admin_tb_clear(); } &admin_tb_all(); } #送信トラックバック if ($trackback_mode == 1 && $in{'exec'} eq 'tbsended') { &admin_tb_sended(); } #ミニリンク集設定 if ($link_mode == 1 && $in{'exec'} eq 'link') { if ($in{'link_update'} ne '') { &admin_link_update(); } &admin_link_list(); } #ログダウンロード if ($in{'download'} ne '') { &admin_download(); } #削除修正用ログ一覧 &admin_list(); } } ### 管理モード - ログイン sub admin_login { &header(); print <<"_HTML_";

    管理者用

    • 管理者パスワードを入力してください。
    管理者認証フォーム
    パスワード
    作業内容

    _HTML_ &footer(); } ### 管理モード - 過去ログ作成 sub admin_createlog { $dir[$#dir] =~ /([^\/\\]*)\.([^.\/\\]*)$/; $past_file = ($1 + 1) . $past_ext; @past = (); (*logs, *past) = &move_log(*logs, *past, $past_size); open(FILE, ">$past_dir$past_file") || &error("過去ログファイルを作成できません。"); print FILE @past; close(FILE); chmod(0606, "$past_dir$past_file"); $work_mesg = "スレッド$past_size件を過去ログに移動しました。"; return; } ### 管理モード - 過去読み戻し sub admin_readlog { $past_file = $dir[$#dir]; open(FILE, "$past_dir$past_file") || &error("過去ログファイルを読み出せません。"); @past = ; close(FILE); (*logs, *past) = &move_log(*logs, *past, 're'); unlink("$past_dir$past_file"); $work_mesg = "スレッド$past_size件を過去ログから読み戻しました。"; return; } ### 管理モード - ログ削除 sub admin_delete { open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); @new = (); $del_list = ''; foreach (@logs) { ($no, $reno, $file) = (split(/\t/))[0, 1, 12]; $flag = 0; foreach $del (split(/\n/, $in{'del'})) { if ($no == $del || $reno == $del) { $flag = 1; last; } } if ($flag == 0) { push(@new, $_); } else { $del_list .= "$no "; foreach $file_name (split(/<>/, $file)) { if (-e "$upfile_dir$file_name") { unlink("$upfile_dir$file_name"); } if ($thumbnail_mode == 1 && -e "$thumbnail_dir$file_name") { unlink("$thumbnail_dir$file_name"); } } if (-e "$reserved_trackback_dir$no$reserved_trackback_ext") { unlink("$reserved_trackback_dir$no$reserved_trackback_ext"); } } } $work_mesg = "$del_list番のエントリを削除しました。"; open(FILE, ">$log_file") || &error("ログファイルに書き込めません。"); print FILE @new; close(FILE); return; } ### 管理モード - ログ登録・修正フォーム sub admin_form { if ($in{'exec'} eq 'new') { %cookie = &get_cookie($admin_cookie_id); if ($cookie{'color'} eq '') { $cookie{'color'} = $color[0]; } $form_subj = ''; ($sec, $min, $hour, $day, $mon, $year, $week) = localtime(time()); $form_year = sprintf("%04d", $year + 1900); $form_month = sprintf("%02d", $mon + 1); $form_day = sprintf("%02d", $day); if ($time_mode == 1) { $form_hour = sprintf("%02d", $hour); $form_minute = sprintf("%02d", $min); } $form_field = ''; $form_name = ''; $form_icon = $cookie{'icon'}; $form_color = $cookie{'color'}; $form_text = ''; $form_display = 1; $form_trackback_url = ''; $form_preview = $cookie{'preview'}; $form_mode = 'regist'; $form_info = '書き込む'; $form_no = ''; $form_file1 = ''; $form_file2 = ''; $form_file3 = ''; $form_ext1 = ''; $form_ext2 = ''; $form_ext3 = ''; $form_host = ''; } elsif ($in{'back'} ne '') { $in{'text'} =~ s/
    /\n/g; $form_subj = $in{'subj'}; if ($in{'date'} =~ /^(\d\d\d\d)(\d\d)(\d\d)$/) { $form_year = $1; $form_month = $2; $form_day = $3; } if ($time_mode == 1) { $form_hour = $in{'hour'}; $form_minute = $in{'minute'}; } $form_field = $in{'field'}; $form_name = $in{'name'}; $form_icon = $in{'icon'}; $form_color = $in{'color'}; $form_text = $in{'text'}; $form_display = $in{'display'}; $form_trackback_url = $in{'trackback_url'}; $form_preview = $in{'c_preview'}; if ($in{'no'} ne '' && $in{'no'} != 0) { $form_mode = 'modi'; $form_info = '修正する'; $form_no = $in{'no'}; $form_file1 = $in{'orgfile1'}; $form_file2 = $in{'orgfile2'}; $form_file3 = $in{'orgfile3'}; $form_ext1 = $in{'ext1'}; $form_ext2 = $in{'ext2'}; $form_ext3 = $in{'ext3'}; $form_host = $in{'host'}; } else { $form_mode = 'regist'; $form_info = '書き込む'; $form_no = ''; $form_file1 = ''; $form_file2 = ''; $form_file3 = ''; $form_ext1 = ''; $form_ext2 = ''; $form_ext3 = ''; $form_host = ''; } } else { if ($in{'modi'} eq '') { &error("修正したいエントリを選択してください。"); } open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); $flag = 0; foreach (@logs) { chop($_); ($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($in{'modi'} == $no) { $flag = 1; last; } } if ($flag != 1) { &error("該当するエントリが見つかりません。"); } $text =~ s/
    /\n/g; ($file1, $file2, $file3) = split(/<>/, $file); if ($file1 ne '') { $file1 =~ /([^\/\\]*)\.([^.\/\\]*)$/; $file1_ext = $2; $file1_ext =~ tr/A-Z/a-z/; } if ($file2 ne '') { $file2 =~ /([^\/\\]*)\.([^.\/\\]*)$/; $file2_ext = $2; $file2_ext =~ tr/A-Z/a-z/; } if ($file3 ne '') { $file3 =~ /([^\/\\]*)\.([^.\/\\]*)$/; $file3_ext = $2; $file3_ext =~ tr/A-Z/a-z/; } $form_subj = $subj; if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $form_year = sprintf("%04d", $1); $form_month = sprintf("%02d", $2); $form_day = sprintf("%02d", $3); if ($time_mode == 1) { $form_hour = sprintf("%02d", $4); $form_minute = sprintf("%02d", $5); } } else { ($sec, $min, $hour, $day, $mon, $year, $week) = localtime(time()); $form_year = sprintf("%04d", $year + 1900); $form_month = sprintf("%02d", $mon + 1); $form_day = sprintf("%02d", $day); if ($time_mode == 1) { $form_hour = sprintf("%02d", $hour); $form_minute = sprintf("%02d", $min); } } $form_field = $field; $form_name = $name; $form_icon = $icon; $form_color = $color; $form_text = $text; $form_display = $display; $form_trackback_url = ''; $form_preview = ''; $form_mode = 'modi'; $form_info = '修正する'; $form_no = $no; $form_file1 = $file1; $form_file2 = $file2; $form_file3 = $file3; $form_ext1 = $file1_ext; $form_ext2 = $file2_ext; $form_ext3 = $file3_ext; $form_host = $host; } &header(); print <<"_HTML_";

    管理者用

    _HTML_ &admin_modelist($in{'exec'}); print <<"_HTML_";
    • 各項目を入力して$form_infoボタンを押してください。
    • _HTML_ if ($time_mode == 1) { $date_label = '日時'; } else { $date_label = '日付'; } if ($form_file1 ne '' || $form_file2 ne '' || $form_file3 ne '') { print <<"_HTML_";
    • ファイルの項目を入力しなければ、以前の内容が引き続いて使用されます。
    • _HTML_ } print <<"_HTML_";
    投稿フォーム
    題名
    $date_label
    _HTML_ if ($year_mode == 1) { print qq|\t\t\t\t\t\t\n|; } else { print qq|\t\t\t\t\t\t\n|; } print qq|\t\t\t\t\t\t\n|; print qq|\t\t\t\t\t\t\n|; if ($time_mode == 1) { print qq|\t\t\t\t\t\t\n|; print qq|\t\t\t\t\t\t\n|; } print <<"_HTML_";
    _HTML_ if ($fields[1] ne '') { print <<"_HTML_";
    分類
    _HTML_ } if ($author_mode == 1 && $author[1] ne '') { print <<"_HTML_";
    投稿者
    _HTML_ } if ($icon_mode == 1) { print <<"_HTML_";
    アイコン
    アイコン一覧
    _HTML_ } if ($color_mode == 1) { print <<"_HTML_";
    本文の色
    _HTML_ foreach (@color) { if ($_ eq '') { next; } $color_label = $_; $color_label =~ s/#//g; if ($form_color eq $_) { print qq|\t\t\t\t\t\t\n|; } else { print qq|\t\t\t\t\t\t\n|; } } print <<"_HTML_";
    _HTML_ } if ($insert_mode == 1) { print <<"_HTML_";
    装飾機能\
    _HTML_ while (scalar(@insert_a) != 0) { $insert_html = shift(@insert_a); $insert_name = shift(@insert_a); if ($insert_html eq '' || $insert_name eq '') { next; } print qq|\t\t\t\t\t\t\n|; } while (scalar(@insert_b) != 0) { $insert_html = shift(@insert_b); $insert_name = shift(@insert_b); if ($insert_html eq '' || $insert_name eq '') { next; } print qq|\t\t\t\t\t\t\n|; } print <<"_HTML_";
    _HTML_ } print <<"_HTML_";
    本文
    _HTML_ if ($upload_mode == 1) { if ($form_file1 ne '') { $file_link1 = qq| このファイルを表\示 ($form_file1)|; } if ($form_file2 ne '') { $file_link2 = qq| このファイルを表\示 ($form_file2)|; } if ($form_file3 ne '') { $file_link3 = qq| このファイルを表\示 ($form_file3)|; } print <<"_HTML_";
    ファイル1
    $file_link1
    ファイル2
    $file_link2
    ファイル3
    $file_link3
    _HTML_ } print <<"_HTML_";
    エントリの状態
    _HTML_ if ($form_display == 0) { print <<"_HTML_"; _HTML_ } else { print <<"_HTML_"; _HTML_ } print <<"_HTML_";
    _HTML_ if ($trackback_mode == 1) { print <<"_HTML_";
    Trackback URL
    _HTML_ } print <<"_HTML_";
    _HTML_ $flag = 0; if ($show_preview == 0 || $in{'modify'} ne '' || ($in{'back'} ne '' && $in{'no'} ne '' && $in{'no'} != 0)) { print qq|\t\t\t\n|; } elsif ($show_preview == 1) { if ($form_preview eq 'on') { print qq|\t\t\t
      \n\t\t\t\t
    • |; } else { print qq|\t\t\t
        \n\t\t\t\t
      • |; } print qq|
      • \n|; $flag = 1; } else { print qq|\t\t\t\n|; } if ($form_file1 ne '') { if ($flag == 0) { print "\t\t\t
          \n"; } print qq|\t\t\t\t
        • \n|; $flag = 1; } if ($form_file2 ne '') { if ($flag == 0) { print "\t\t\t
            \n"; } print qq|\t\t\t\t
          • \n|; $flag = 1; } if ($form_file3 ne '') { if ($flag == 0) { print "\t\t\t
              \n"; } print qq|\t\t\t\t
            • \n|; $flag = 1; } if ($form_mode eq 'modi') { if ($flag == 0) { print "\t\t\t
                \n"; } print qq|\t\t\t\t
              • \n|; $flag = 1; } if ($flag == 1) { print "\t\t\t
              \n"; } print <<"_HTML_";

              _HTML_ if ($fields[1] eq '') { print <<"_HTML_"; _HTML_ } print <<"_HTML_";

    _HTML_ &footer(); } ### 管理モード - 入力内容チェック sub admin_inputcheck { $in{'subj'} = &create_line($in{'subj'}); $in{'text'} = &create_text($in{'text'}); $in{'text'} =~ s/&/&/g; $in{'text'} =~ s/<//g; $in{'text'} =~ s/"/"/g; if ($in{'date'} eq '') { $in{'date'} = "$in{'year'}$in{'month'}$in{'day'}"; } if ($in{'subj'} eq '') { &error("題名が入力されていません。"); } if ($in{'date'} !~ /^\d\d\d\d\d\d\d\d$/) { &error("日付が不正です。"); } if ($time_mode == 1) { if ($in{'hour'} !~ /^\d\d$/) { &error("時間が不正です。"); } if ($in{'minute'} !~ /^\d\d$/) { &error("分が不正です。"); } } else { $in{'hour'} = '00'; $in{'minute'} = '00'; } if ($fields[1] ne '' && $in{'field'} eq '') { &error("分類が選択されていません。"); } if ($author_mode == 1 && $in{'name'} eq '') { if ($author[1] eq '') { $in{'name'} = $author[0]; } else { &error("投稿者が選択されていません。"); } } if ($in{'text'} eq '') { &error("本文が入力されていません。"); } if ($in{'preview'} eq 'on') { &preview(); } $cookie{'color'} = $in{'color'}; $cookie{'icon'} = $in{'icon'}; $cookie{'preview'} = $in{'c_preview'}; &set_cookie(*cookie, $admin_cookie_id, $hold_days); return; } ### 管理モード - ログ登録 sub admin_regist { $host = $ENV{'REMOTE_HOST'}; $addr = $ENV{'REMOTE_ADDR'}; if ($host eq "" || $host eq $addr) { if ($gethostbyaddr == 1) { $host = gethostbyaddr(pack("C4", split(/\./, $addr)), 2) || $addr; } } $no = 0; $parent = 0; $subj = ''; $text = ''; foreach (@logs) { if ($_ + 0 > $no) { ($no, $date, $subj, $text) = (split(/\t/))[0, 2, 8, 9]; } if ((split(/\t/))[1] == 0) { $parent++; } } $no++; if ($in{'subj'} eq $subj && $in{'text'} eq $text) { &error("すでに書き込まれています。"); } if ($upload_mode == 1) { @file_name = (); foreach (1 .. 3) { if ($file_name{'file' . $_} eq '' && ($in{'ext' . $_} eq '' || ! -e "$upfile_dir$temporary_file$_")) { next; } if ($file_name{'file' . $_} ne '') { $file_name{'file' . $_} = &upfile($file{'file' . $_}, $file_name{'file' . $_}, "$no-$_"); } elsif ($in{'ext' . $_} ne '' && -e "$upfile_dir$temporary_file$_") { $file_name{'file' . $_} = "$no-$_.$in{'ext' . $_}"; rename("$upfile_dir$temporary_file$_", "$upfile_dir$file_name{'file' . $_}"); } push(@file_name, $file_name{'file' . $_}); } $file_name = join('<>', @file_name); } $line = "$no\t0\t$in{'display'}\t$in{'date'}$in{'hour'}$in{'minute'}\t$in{'field'}\t$in{'name'}\t\t\t$in{'subj'}\t$in{'text'}\t$in{'color'}\t$in{'icon'}\t$file_name\t\t$host\n"; $log_no = $no; if ($make_past == 0) { foreach (0 .. ($parent - $max_log)) { ($no, $reno) = split(/\t/, $logs[$#logs]); if ($reno == 0) { ($file) = (split(/\t/, pop(@logs)))[12]; foreach $file_name (split(/<>/, $file)) { if (-e "$upfile_dir$file_name") { unlink("$upfile_dir$file_name"); } if ($thumbnail_mode == 1 && -e "$thumbnail_dir$file_name") { unlink("$thumbnail_dir$file_name"); } } if (-e "$reserved_trackback_dir$no$reserved_trackback_ext") { unlink("$reserved_trackback_dir$no$reserved_trackback_ext"); } } else { while ((split(/\t/, $logs[$#logs]))[1] != 0) { ($file) = (split(/\t/, pop(@logs)))[12]; foreach $file_name (split(/<>/, $file)) { if (-e "$upfile_dir$file_name") { unlink("$upfile_dir$file_name"); } if ($thumbnail_mode == 1 && -e "$thumbnail_dir$file_name") { unlink("$thumbnail_dir$file_name"); } } if (-e "$reserved_trackback_dir$no$reserved_trackback_ext") { unlink("$reserved_trackback_dir$no$reserved_trackback_ext"); } } ($file) = (split(/\t/, pop(@logs)))[12]; foreach $file_name (split(/<>/, $file)) { if (-e "$upfile_dir$file_name") { unlink("$upfile_dir$file_name"); } if ($thumbnail_mode == 1 && -e "$thumbnail_dir$file_name") { unlink("$thumbnail_dir$file_name"); } } if (-e "$reserved_trackback_dir$no$reserved_trackback_ext") { unlink("$reserved_trackback_dir$no$reserved_trackback_ext"); } } } } @new = (); $flag = 0; foreach (@logs) { ($no, $reno, $display, $date) = split(/\t/); if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $date = "$1$2$3"; } if ($flag == 0 && $reno == 0 && $in{'date'} + 0 >= $date) { $flag = 1; push(@new, $line); } push(@new, $_); } if ($flag == 0) { push(@new, $line); } @logs = @new; $work_mesg = "エントリを新規に書き込みました。"; return $log_no; } ### 管理モード - ログ修正 sub admin_modi { if ($upload_mode == 1) { @file_name = (); foreach (1 .. 3) { if ($file_name{'file' . $_} eq '' && $in{'delfile' . $_} eq '' && $in{'orgfile' . $_} eq '') { next; } if ($file_name{'file' . $_} ne '') { if (-e "$upfile_dir" . $in{'orgfile' . $_}) { unlink("$upfile_dir" . $in{'orgfile' . $_}); } if ($thumbnail_mode == 1 && -e "$thumbnail_dir" . $in{'orgfile' . $_}) { unlink("$thumbnail_dir" . $in{'orgfile' . $_}); } $file_name{'file' . $_} = &upfile($file{'file' . $_}, $file_name{'file' . $_}, "$in{'no'}-$_"); } elsif ($in{'orgfile' . $_} ne '' && $in{'delfile' . $_} eq 'on') { if (-e "$upfile_dir" . $in{'orgfile' . $_}) { unlink("$upfile_dir" . $in{'orgfile' . $_}); } if ($thumbnail_mode == 1 && -e "$thumbnail_dir" . $in{'orgfile' . $_}) { unlink("$thumbnail_dir" . $in{'orgfile' . $_}); } $file_name{'file' . $_} = ''; } elsif ($in{'orgfile' . $_} ne '') { $file_name{'file' . $_} = $in{'orgfile' . $_}; } push(@file_name, $file_name{'file' . $_}); } $file_name = join('<>', @file_name); } $line = "$in{'no'}\t0\t$in{'display'}\t$in{'date'}$in{'hour'}$in{'minute'}\t$in{'field'}\t$in{'name'}\t\t\t$in{'subj'}\t$in{'text'}\t$in{'color'}\t$in{'icon'}\t$file_name\t\t$in{'host'}\n"; if ($in{'sort'} eq 'on') { @new = (); @tmp = (); foreach (@logs) { ($no, $reno) = split(/\t/); if ($in{'no'} == $no) { push(@tmp, $line); } elsif ($in{'no'} == $reno) { push(@tmp, $_); } else { push(@new, $_); } } @logs = (); $flag = 0; foreach (@new) { ($no, $reno, $display, $date) = split(/\t/); if ($flag == 0 && $reno == 0 && "$in{'date'}$in{'hour'}$in{'minute'}" + 0 >= $date) { $flag = 1; push(@logs, @tmp); } push(@logs, $_); } if ($flag == 0) { push(@logs, @tmp); } } else { @new = (); foreach (@logs) { ($no, $reno) = split(/\t/); if ($in{'no'} == $no) { push(@new, $line); } else { push(@new, $_); } } @logs = @new; } $work_mesg = "$in{'no'}のエントリを修正しました。"; return $in{'no'}; } ### プロフィール編集 sub admin_profile_regist { if ($in{'author'} eq '') { &error("編集したいプロフィールを選択してください。"); } $flag = 0; foreach (@author) { if ($_ eq $in{'author'}) { $flag = 1; last; } } if ($flag == 0) { &error("指定された投稿者名は存在しません。"); } $in{'author'} = &create_line($in{'author'}); $in{'text'} = &create_text($in{'text'}); $in{'text'} =~ s/&/&/g; $in{'text'} =~ s/<//g; $in{'text'} =~ s/"/"/g; $line = "$in{'author'}\t$in{'text'}\n"; open(PROFILE, "$profile_file") || &error("プロフィール保存ファイルを読み出せません。"); @profile = ; close(PROFILE); @new = (); $flag = 0; foreach (@profile) { ($author, $text) = split(/\t/); if ($in{'author'} eq $author) { push(@new , $line); $flag = 1; } else { push(@new, $_); } } if ($flag == 0) { push(@new, $line); } open(PROFILE, ">$profile_file") || &error("プロフィール保存ファイルに書き込めません。"); print PROFILE @new; close(PROFILE); $work_mesg = "$in{'author'}のプロフィールを編集しました。"; } ### プロフィール編集フォーム sub admin_profile_form { if ($in{'author'} eq '') { &error("編集したいプロフィールを選択してください。"); } open(PROFILE, "$profile_file") || &error("プロフィール保存ファイルを読み出せません。"); @profile = ; close(PROFILE); $flag = 0; foreach (@profile) { chop($_); ($author, $text) = split(/\t/); if ($in{'author'} eq $author) { $flag = 1; last; } } if ($flag == 0) { $author = $in{'author'}; $text = ''; } $text =~ s/
    /\n/g; &header(); print <<"_HTML_";

    管理者用

    _HTML_ &admin_modelist($in{'exec'}); print <<"_HTML_";
    • $authorのプロフィール内容です。
    • プロフィールを入力して、登録ボタンを押してください。
    • _HTML_ if ($work_mesg ne '') { print <<"_HTML_";
    • $work_mesg
    • _HTML_ } print <<"_HTML_";
    プロフィール設定フォーム
    プロフィール

    _HTML_ &footer(); } ### プロフィール一覧 sub admin_profile_list { open(PROFILE, "$profile_file") || &error("プロフィール保存ファイルを読み出せません。"); @profile = ; close(PROFILE); %profile = (); foreach (@profile) { chop($_); ($author, $text) = split(/\t/); $profile{"$author"} = $text; } &header(); print <<"_HTML_";

    管理者用

    _HTML_ &admin_modelist($in{'exec'}); print <<"_HTML_";
    • エントリ投稿者のプロフィール一覧です。
    • 設定したいプロフィールにチェックを入れ、編集ボタンを押すと、プロフィールの設定ができます。
    プロフィール設定フォーム

    $work_mesg

    _HTML_ foreach (@author) { if ($_ eq '') { next; } if ($profile{"$_"} ne '') { $text = $profile{"$_"}; if ($text ne '') { $text =~ s/<[^>]*>//g; if (length($text) > 80) { $text = substr($text, 0, 80) . ' …'; } } } else { $text = ''; } print <<"_HTML_"; _HTML_ } print <<"_HTML_";
    編集 名前 登録内容
    $_ $text
    _HTML_ &footer(); } ### 受信トラックバック削除 sub admin_tb_delete { open(TB, "$reserved_trackback_dir$in{'no'}$reserved_trackback_ext") || &error("受信トラックバック保存ファイルを読み出せません。"); @trackback = ; close(TB); @new_trackback = (); $del_list = ''; foreach (@trackback) { ($tb_no) = (split(/\t/))[0]; $flag = 0; foreach $del (split(/\n/, $in{'del'})) { if ($tb_no == $del) { $flag = 1; last; } } if ($flag == 0) { push(@new_trackback, $_); } else { $del_list .= "$tb_no "; } } $work_mesg = "$del_list番のトラックバックを削除しました。"; open(TB, ">$reserved_trackback_dir$in{'no'}$reserved_trackback_ext") || &error("受信トラックバック保存ファイルに書き込めません。"); print TB @new_trackback; close(TB); if ($new_trackback[0] eq '') { unlink("$reserved_trackback_dir$in{'no'}$reserved_trackback_ext"); $work_mesg = "$in{'no'}番へのトラックバックをすべて削除しました。"; &admin_tb_all(); } else { $in{'show'} = $in{'no'}; &admin_tb_list(); } return; } ### 受信トラックバックすべて削除 sub admin_tb_clear { $del_list = ''; foreach $del (split(/\n/, $in{'del'})) { if (-e "$reserved_trackback_dir$del$reserved_trackback_ext") { unlink("$reserved_trackback_dir$del$reserved_trackback_ext"); $del_list .= "$del "; } } $work_mesg = "$del_list番へのトラックバックをすべて削除しました。"; return; } ### 受信トラックバック表示 sub admin_tb_list { open(TB, "$reserved_trackback_dir$in{'show'}$reserved_trackback_ext") || &error("受信トラックバック保存ファイルを読み出せません。"); @trackback = ; close(TB); &header(); print <<"_HTML_";

    管理者用

    _HTML_ &admin_modelist($in{'exec'}); print <<"_HTML_";
    • No.$in{'show'}へのトラックバック一覧です。
    • 削除したいトラックバックにチェックを入れ、削除ボタンを押してください。
    トラックバック削除フォーム

    $work_mesg

    _HTML_ foreach (@trackback) { ($tb_no, $tb_time, $tb_blog_name, $tb_title, $tb_url, $tb_excerpt) = split(/\t/); ($sec, $min, $hour, $day, $mon, $year, $week) = localtime($tb_time); $tb_time = sprintf("%04d/%02d/%02d-%02d:%02d", $year + 1900, $mon + 1, $day, $week[$week], $hour, $min); chop($tb_excerpt); print <<"_HTML_"; _HTML_ } print <<"_HTML_";
    削除 No 受信日時 ブログ名 題名 本文
    $tb_no $tb_time $tb_blog_name $tb_title $tb_excerpt
    _HTML_ &footer(); } ### 受信トラックバック一覧 sub admin_tb_all { open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); opendir(DIR, "$reserved_trackback_dir") || &error("受信トラックバック保存ディレクトリを読み出せません。"); @dir = readdir(DIR); closedir(DIR); $parent = 0; foreach (@dir) { if ($_ =~ /^\d+(\.\w+)$/ && $1 eq $reserved_trackback_ext) { $parent++; } } &header(); print <<"_HTML_";

    管理者用

    _HTML_ &admin_modelist($in{'exec'}); print <<"_HTML_";
    • これまでに受信したトラックバック一覧です。
    • 削除したいトラックバックにチェックを入れ、削除ボタンを押すと、そのエントリへのトラックバックを一括削除します。
    • 表\示したいトラックバックにチェックを入れ、トラックバックを表\示ボタンを押すと、受信したトラックバックを個別に削除することができます。
    トラックバック削除フォーム

    $work_mesg

    _HTML_ $start = $in{'page'} * $page_size; $end = $start + $page_size; $i = 0; foreach (@logs) { ($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($reno != 0) { next; } if (! -e "$reserved_trackback_dir$no$reserved_trackback_ext") { next; } $i++; if ($i <= $start) { next; } if ($i > $end) { last; } if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $year = sprintf("%04d", $1); $month = sprintf("%02d", $2); $day = sprintf("%02d", $3); $date = "$year/$month/$day"; } print <<"_HTML_"; _HTML_ } print <<"_HTML_";
    削除 表\示 No エントリの日付 内容
    $no $date $subjへのトラックバック

    _HTML_ if ($in{'page'} > 0) { print qq|\t\t\t\t\n|; } if (int(($parent - 1) / $page_size) > $in{'page'}) { print qq|\t\t\t\t\n|; } print <<"_HTML_";

    _HTML_ &footer(); } ### 送信トラックバック sub admin_tb_sended { open(TB, "$sended_trackback_file") || &error("送信トラックバック一覧ファイルを読み出せません。"); @trackback = ; close(TB); &header(); print <<"_HTML_";

    管理者用

    _HTML_ &admin_modelist($in{'exec'}); print <<"_HTML_";
    • 過去に送信したトラックバックの一覧です。
    _HTML_ foreach (@trackback) { chop($_); local($tb_no, $tb_date, $tb_url, $tb_subj, $tb_self) = split(/\t/); local($sec, $min, $hour, $day, $mon, $year, $week) = localtime($tb_date); $tb_date = sprintf("%02d月%02d日%02d:%02d", $mon + 1, $day, $hour, $min); print <<"_HTML_"; _HTML_ } print <<"_HTML_";
    送信日時 送信先URL 投稿エントリの題名 投稿エントリのURL
    $tb_date $tb_url $tb_subj $tb_self
    _HTML_ &footer(); } ### 管理モード - リンク集更新 sub admin_link_update { @link = (); foreach (0 .. ($link_size - 1)) { if ($in{"name$_"} eq '') { next; } if ($in{"url$_"} eq '' || $in{"url$_"} eq 'http://') { next; } push(@link, "$in{\"name$_\"}\t$in{\"url$_\"}\n"); } open(LINK, ">$link_file") || &error("ミニリンク集保存ファイルに書き込めません。"); print LINK @link; close(LINK); return; } ### 管理モード - リンク集一覧 sub admin_link_list { open(LINK, "$link_file") || &error("ミニリンク集保存ファイルを読み出せません。"); @link = ; close(LINK); &header(); print <<"_HTML_";

    管理者用

    _HTML_ &admin_modelist($in{'exec'}); print <<"_HTML_";
    • トップに表\示されるリンク集の設定を行います。
    トラックバック削除フォーム

    $work_mesg

    _HTML_ foreach (0 .. ($link_size - 1)) { chop($link[$_]); local($name, $url) = split(/\t/, $link[$_]); if ($url eq '') { $url = 'http://'; } print <<"_HTML_"; _HTML_ } print <<"_HTML_";
    サイト名 URL
    _HTML_ &footer(); } ### 管理モード - ログダウンロード sub admin_download { open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); if ($download_mode == 1) { $log_file =~ /([^\/\\]*)\.([^.\/\\]*)$/; $filename = "$1\.$2"; print "Content-type: application/x-csv\n"; print "Content-Disposition: inline; filename=$filename\n\n"; print @logs; } else { print "Content-type: text/download\n\n"; print @logs; } exit; } ### 管理モード - 削除修正用ログ一覧 sub admin_list { open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); $log_byte = &comma(int((stat($log_file))[7] / 1024)); if ($logs[0] ne '' && $log_byte == 0) { $log_byte = 1; } if ($make_past == 1) { opendir(DIR, "$past_dir") || &error("過去ログディレクトリを読み出せません。"); @dir = readdir(DIR); closedir(DIR); $past_byte = 0; foreach (@dir) { if ($_ =~ /^\d+(\.\w+)$/ && $1 eq $past_ext) { $past_byte += (stat("$past_dir$_"))[7]; } } $past_byte = &comma(int($past_byte / 1024)); } $parent = 0; foreach (@logs) { if ((split(/\t/))[1] == 0) { $parent++; } } if ($mini_counter != 0) { open(COUNT, "$count_log") || &error("カウントログファイルを読み出せません。"); $data = ; close(COUNT); ($sum, $today, $yesterday, $key) = split(/\t/, $data); } &header(); print <<"_HTML_";

    管理者用

    _HTML_ &admin_modelist($in{'exec'}); print <<"_HTML_";
    • 削除したいエントリにチェックを入れ、削除ボタンを押してください。
    • 修正したいエントリにチェックを入れ、修正ボタンを押してください。
    • ダウンロードボタンを押すと、現在のログをダウンロードします。
    • _HTML_ if ($make_past == 1) { print qq|\t\t
    • エントリが$past_size件以上になると過去ログを作成することができます。
    • \n|; } else { print qq|\t\t
    • エントリが$max_log件以上になると古いエントリから削除されます。
    • \n|; } print <<"_HTML_";
    記事編集フォーム

    _HTML_ if ($make_past == 1 && $parent > $past_size) { print qq|\t\t\t\t\n|; } if ($make_past == 1 && $past_byte > 0) { print qq|\t\t\t\t\n|; } print <<"_HTML_";

    ログサイズ
    $log_byteKB
    _HTML_ if ($make_past == 1) { print qq|\t\t\t\t
    過去ログ
    \n\t\t\t\t\t
    $past_byteKB
    \n|; } print <<"_HTML_";
    エントリ数
    $parent
    _HTML_ if ($mini_counter != 0) { printf("\t\t\t\t
    総アクセス
    \n\t\t\t\t
    %0${count_figure}d
    \n\t\t\t
    今日
    \n\t\t\t\t
    %0${count_figure}d
    \n\t\t\t
    昨日
    \n\t\t\t\t
    %0${count_figure}d
    \n", $sum, $today, $yesterday); } print <<"_HTML_";

    $work_mesg

    _HTML_ if ($res_mode == 1 || $author_mode == 1) { print qq|\t\t\t\t\t\n|; } print <<"_HTML_"; _HTML_ if ($upload_mode == 1) { print qq|\t\t\t\t\t\n|; } print qq|\t\t\t\t\t\n|; if ($res_mode == 1) { print qq|\t\t\t\t\t\n|; } print <<"_HTML_"; _HTML_ $start = $in{'page'} * $page_size; $end = $start + $page_size; $i = 0; foreach (@logs) { ($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($reno == 0) { $i++; } if ($i <= $start) { next; } if ($i > $end) { last; } if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $year = sprintf("%04d", $1); $month = sprintf("%02d", $2); $day = sprintf("%02d", $3); $week = $week[&getweek($day, $year, $month)]; $date = "$year/$month/$day"; } else { ($sec, $min, $hour, $day, $mon, $year, $week) = localtime($date); $date = sprintf("%04d/%02d/%02d", $year + 1900, $mon + 1, $day); } if ($reno == 0) { if ($name eq '') { $name = '管理者'; } $modi = qq||; } else { $modi = ''; } $text =~ s/<[^>]*>//g; if (length($text) > 60) { $text = substr($text, 0, 60) . ' …'; } if ($file eq '') { $file_list = ''; } else { @file = split(/<>/, $file); $file_list = ''; foreach $file (@file) { $file_list .= qq||; } } if ($display == 1) { $display = '公開'; } else { $display = '下書き'; } chop($host); print <<"_HTML_"; _HTML_ if ($res_mode == 1 || $author_mode == 1) { print qq|\t\t\t\t\t\n|; } print <<"_HTML_"; _HTML_ if ($upload_mode == 1) { print qq|\t\t\t\t\t\n|; } print qq|\t\t\t\t\t\n|; if ($res_mode == 1) { print qq|\t\t\t\t\t\n|; } print <<"_HTML_"; _HTML_ } print <<"_HTML_";
    削除 修正 No 日付投稿者題名 本文ファイル状態ホスト
    $modi $no $date$name$subj $text$file_list$display$host

    _HTML_ if ($in{'page'} > 0) { print qq|\t\t\t\t\n|; } if (int(($parent - 1) / $page_size) > $in{'page'}) { print qq|\t\t\t\t\n|; } print <<"_HTML_";

    _HTML_ &footer(); } ### 管理モード - 実行モードリスト sub admin_modelist { local($_) = @_; if ($_ eq 'new') { $new_selected = ' selected'; } elsif ($_ eq 'profile') { $profile_selected = ' selected'; } elsif ($_ eq 'trackback') { $trackback_selected = ' selected'; } elsif ($_ eq 'tbsended') { $tbsended_selected = ' selected'; } elsif ($_ eq 'link') { $link_selected = ' selected'; } else { $edit_selected = ' selected'; } print <<"_HTML_";
    表\示設定フォーム

    _HTML_ return; } ### 記事登録 sub regist { ®ist_check(); if ($in{'preview'} eq 'on') { &preview(); } if ($in{'back'} ne '') { &res(); } if ($mobile == 0) { $cookie{'name'} = $in{'name'}; $cookie{'mail'} = $in{'mail'}; $cookie{'url'} = $in{'url'}; $cookie{'icon'} = $in{'icon'}; $cookie{'color'} = $in{'color'}; $cookie{'pwd'} = $in{'pwd'}; $cookie{'preview'} = $in{'c_preview'}; &set_cookie(*cookie, $cookie_id, $hold_days); } &lock($lock_file); open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); $no = 0; $re = 0; $parent = 0; $name = ''; $text = ''; foreach (@logs) { if ($_ + 0 > $no) { ($no) = (split(/\t/))[0]; } if ($_ + 0 > $re && (split(/\t/))[1] != 0) { ($re, $date, $name, $text, $ip) = (split(/\t/))[0, 3, 5, 9, 14]; } if ((split(/\t/))[1] == 0) { $parent++; } } $no++; if ($in{'name'} eq $name && $in{'text'} eq $text) { &unlock($lock_file); &error("二重投稿は禁止です。"); } chop($ip); if (time() - $date < $wait_time && $host eq $ip) { &unlock($lock_file); &error("連続投稿は$wait_time秒以上時間をあけてください。"); } $date = time(); if ($in{'subj'} eq '') { $in{'subj'} = '無題'; } if ($in{'url'} eq 'http://') { $in{'url'} = ''; } if ($in{'pwd'} ne '') { $in{'pwd'} = &encrypt($in{'pwd'}); } if ($file_name{'file'} ne '') { $file_name{'file'} = &upfile($file_name{'file'}, $file{'file'}, $no); } $line = "$no\t$in{'reno'}\t1\t$date\t\t$in{'name'}\t$in{'mail'}\t$in{'url'}\t$in{'subj'}\t$in{'text'}\t$in{'color'}\t$in{'icon'}\t\t$in{'pwd'}\t$host\n"; @new = (); $flag = 0; foreach (@logs) { ($no, $reno) = split(/\t/); if ($flag == 0 && $in{'reno'} == $no) { $flag = 1; } elsif ($flag == 1 && $in{'reno'} != $reno) { $flag = 2; push(@new, $line); } push(@new, $_); } if ($flag == 1) { push(@new, $line); } @logs = @new; open(FILE, ">$log_file") || &error("ログファイルに書き込めません。"); print FILE @logs; close(FILE); if ($html_mode == 1) { &output_htmlfile(); } if ($js_mode != 0) { &output_jsfile(@logs); } &unlock($lock_file); $in{'mode'} = ''; $in{'no'} = ''; $in{'date'} = ''; return; } ### 投稿内容のチェック sub regist_check { if ($ENV{'REQUEST_METHOD'} ne 'POST' && $mobile == 0) { &error("不正なアクセスです。"); } if ($ENV{'HTTP_REFERER'} ne '' && $base_url ne '' && $ENV{'HTTP_REFERER'} !~ /^$base_url/i) { &error("不正なアクセスです。"); } $host = $ENV{'REMOTE_HOST'}; $addr = $ENV{'REMOTE_ADDR'}; if ($host eq "" || $host eq $addr) { if ($gethostbyaddr == 1) { $host = gethostbyaddr(pack("C4",split(/\./,$addr)),2) || $addr; } } $flag = 0; foreach $list (@blacklist) { if ($list ne '' && $host =~ /$list/i) { $flag = 1; last; } } if ($proxy_check == 1) { if ($ENV{'HTTP_VIA'} ne '' || $ENV{'HTTP_FORWARDED'} ne '' || $ENV{'HTTP_X_FORWARDED_FOR'} ne '') { $flag = 1; } } if ($flag == 1) { &error("アクセスを許可されていません。"); } $in{'name'} = &create_line($in{'name'}); $in{'mail'} = &create_line($in{'mail'}); $in{'url'} = &create_line($in{'url'}); $in{'subj'} = &create_line($in{'subj'}); $in{'pwd'} = &create_line($in{'pwd'}); $in{'text'} = &create_text($in{'text'}); if ($in{'name'} eq '') { &error("名前が入力されていません。"); } if (length($in{'name'}) > $name_length * 2) { &error("名前の長さは全角$name_length文字までにしてください。"); } if ($in{'mail'} ne '' && ($in{'mail'} =~ /[^\w\.\@\d\-\_]/ || $in{'mail'} !~ /(.+)\@(.+)\.(.+)/ || length($in{'mail'}) > 50)) { &error("Eメールの入力内容が正しくありません。"); } if (length($in{'url'}) > 70) { &error("URLの入力内容が正しくありません。"); } if ($in{'text'} eq '') { &error("本文が入力されていません。"); } if (length($in{'text'}) > $text_length * 2) { &error("本文の長さは全角$text_length文字までにしてください。"); } if (($in{'text'} =~ s/
    /
    /g) + 1 > $text_line) { &error("本文は$text_line行までにしてください。"); } if ($admin_icon_mode == 1 && $in{'icon'} eq $admin_icon[0]) { &error("管理者専用のアイコンは使用できません。"); } if ($need_pwd == 1 && $in{'pwd'} eq '') { &error("削除キーが設定されていません。"); } if (length($in{'pwd'}) > 10) { &error("削除キーの長さは半角10文字までにしてください。"); } return; } ### プレビュー表示 sub preview { if ($in{'mode'} eq 'admin') { $date = "$in{'date'}$in{'hour'}$in{'minute'}"; $form_mode = ' name="regist"'; } else { $date = time(); } if ($in{'reno'} eq '') { $in{'reno'} = 0; } if ($in{'subj'} eq '') { $in{'subj'} = '無題'; } if ($in{'url'} eq 'http://') { $in{'url'} = ''; } $preview_text = $in{'text'}; $in{'text'} =~ s/"/"/g; $in{'text'} =~ s/
    /\n/g; if ($upload_mode == 1 && $in{'mode'} eq 'admin') { if ($in{'orgfile1'} ne '') { $file_name{'file1'} = $in{'orgfile1'}; } if ($in{'orgfile2'} ne '') { $file_name{'file2'} = $in{'orgfile2'}; } if ($in{'orgfile3'} ne '') { $file_name{'file3'} = $in{'orgfile3'}; } @file_name = (); $i = 0; foreach $file ('file1', 'file2', 'file3') { $i++; if ($file_name{$file} eq '') { next; } $file_name{$file} =~ /([^\/\\]*)\.([^.\/\\]*)$/; $ext{$file} = $2; $ext{$file} =~ tr/A-Z/a-z/; open(FILE, ">$upfile_dir$temporary_file$i") || &error("テンポラリファイルが作成できません。"); binmode(FILE); print FILE $file{$file}; close(FILE); push(@file_name, $file_name{$file}); } } &header(); print <<"_HTML_";

    プレビュー

    投稿フォーム

    _HTML_ $file_name = join('<>', @file_name); $logs[0] = "XXX\t$in{'reno'}\t1\t$date\t$in{'field'}\t$in{'name'}\t$in{'mail'}\t$in{'url'}\t$in{'subj'}\t$preview_text\t$in{'color'}\t$in{'icon'}\t$file_name\t\t$in{'pwd'}\t$host\n"; &showlog(@logs); print <<"_HTML_"; _HTML_ &footer(); } ### デコード sub decode { if ($ENV{'REQUEST_METHOD'} eq 'POST') { $length = $ENV{'CONTENT_LENGTH'}; binmode(STDIN); while ($length > 0) { $length -= sysread(STDIN, $buffer, $length); $alldata .= $buffer; } $flag = 0; $data_flag = 0; @in = (); %in = (); %file = (); %file_name = (); %file_size = (); %mime_type = (); foreach $data (split(/\r\n/, $alldata)) { if ($interval eq '') { $interval = $data; } else { if ($data !~ /^$interval/i) { if ($data =~ /^Content-Disposition:\sform-data;\sname="([^"]*)"/i && $key eq '') { $key = $1; if ($data =~ /filename="([^"]*)"/i) { $file_name{"$key"} = $1; $flag = 1; } $data_flag = 0; } elsif ($data =~ /^Content-type:\s(\S+)/i) { $mime_type{"$key"} = $1; } else { if ($data_flag == 0) { $data_flag = 1; next; } if ($flag == 1) { $file{"$key"} .= "$data\r\n"; } else { $in{"$key"} .= "$data\n"; } $file_size{"$key"} += length($data); } } else { $in_flag = 0; foreach $in (@in) { if ($in eq $key) { $in_flag = 1; } } if ($in_flag == 0) { push(@in, $key); } $key = ''; $flag = 0; } } } } else { $alldata = $ENV{'QUERY_STRING'}; foreach $data (split(/&/, $alldata)) { ($key, $value) = split(/=/, $data); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack('C', hex($1))/eg; $value =~ s/\t//g; $in{"$key"} = $value; } } while (($key, $value) = each(%in)) { $value =~ s/\r\n/\n/; $value =~ s/^\n//; $value =~ s/\n$//; &jcode'convert(*value, 'sjis', '', 'z'); $value =~ s/&/&/g; $value =~ s//>/g; $value =~ s/"/"/g; $in{"$key"} = $value; } while (($key, $value) = each(%file_name)) { $value =~ s/^\n//; $value =~ s/\n$//; &jcode'convert(*value, 'sjis', '', 'z'); $value =~ s/&/&/g; $value =~ s//>/g; $value =~ s/"/"/g; $file_name{"$key"} = $value; } return; } ### HTMLヘッダ sub header { if ($html_flag != 1) { print "Content-Type: text/html\n\n"; } print <<"_HTML_"; $title _HTML_ if ($rss_mode == 1) { print <<"_HTML_"; _HTML_ } if ($insert_mode == 1 && $in{'mode'} eq 'admin' && ($in{'exec'} eq 'new' || $in{'back'} ne '' || $in{'modify'} ne '')) { print <<"_HTML_"; _HTML_ } print <<"_HTML_";
    _HTML_ return; } ### HTMLフッタ sub footer { print <<"_HTML_";
    _HTML_ if ($html_flag != 1) { exit(); } } ### エラー出力 sub error { local($_) = @_; if ($html_flag == 1) { *STDOUT = $stdout; $html_flag = 0; } if ($mobile == 1) { print <<"_HTML_";

    エラーが発生しました。

    $_

    _HTML_ exit(); } &header(); print <<"_HTML_";

    エラーが発生しました

    • $_
    _HTML_ if ($in{'mode'} eq 'regist' || $in{'regist'} ne '' || $in{'modi'} ne '') { if ($in{'mode'} eq 'regist') { $in{'mode'} = 'res'; $in{'no'} = $in{'reno'}; } $in{'text'} =~ s/"/"/g; $in{'text'} =~ s/
    /\n/g; print <<"_HTML_";
    投稿フォーム

    _HTML_ } print <<"_HTML_";
    _HTML_ &footer(); } ### モバイル表示 sub mobile { $agent = $ENV{'HTTP_USER_AGENT'}; if ($agent !~ /DoCoMo/i && $agent !~ /J-PHONE/i && $agent !~ /UP\.Browser/i) { return; } else { $mobile = 1; } if ($agent =~ /DoCoMo/i) { $method = 'post'; } else { $method = 'get'; } print <<"_HTML_"; Content-Type: text/html $title _HTML_ &mobile_decode(); if ($in{'mode'} eq 'regist') { if ($in{'adminpwd'} ne $admin_pwd) { &error("パスワードが違います。"); } &mobile_check(); &lock($lock_file); open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); if ($in{'edit'} eq '') { &mobile_edit(); } else { &mobile_regist(); } open(FILE, ">$log_file") || &error("ログファイルに書き込めません。"); print FILE @logs; close(FILE); if ($html_mode == 1) { &output_htmlfile(); } if ($js_mode != 0) { &output_jsfile(@logs); } &unlock($lock_file); $in{'mode'} = ''; } elsif ($in{'mode'} eq 'responce') { #コメント投稿 ®ist(); } open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); $parent = 0; foreach (@logs) { if ((split(/\t/))[1] == 0) { $parent++; } } if ($in{'mode'} eq 'form') { if ($in{'adminpwd'} eq '') { #ログインフォーム表示 &mobile_login(); } else { #エントリ投稿フォーム表示 &mobile_form(); } } elsif ($in{'mode'} eq 'edit') { #エントリ編集フォーム表示 &mobile_editform(); } elsif ($in{'mode'} eq 'res') { #返信フォーム表示 &mobile_res(); } elsif ($in{'mode'} eq 'delete') { #記事削除 &mobile_delete(); } elsif ($in{'mode'} eq 'all') { #エントリ表示 &mobile_all(); } else { if ($mini_counter != 0) { if ($ENV{'REQUEST_METHOD'} ne 'POST' && $ENV{'QUERY_STRING'} eq '') { &count_up(); } open(COUNT, "$count_log") || &error("カウントログファイルを読み出せません。"); $data = ; close(COUNT); ($sum, $c_today, $c_yesterday, $key) = split(/\t/, $data); } #エントリ一覧 &mobile_list(); } print <<"_HTML_";
    Web Liberty _HTML_ exit(); } ### モバイル表示 - デコード sub mobile_decode { if ($ENV{'REQUEST_METHOD'} eq 'POST') { if ($ENV{'CONTENT_LENGTH'} > 15000) { &error("投稿量が大きすぎます。現在の投稿量:$ENV{'CONTENT_LENGTH'} / 最大投稿量:15000。"); } read(STDIN, $alldata, $ENV{'CONTENT_LENGTH'}); } else { $alldata = $ENV{'QUERY_STRING'}; } foreach $data (split(/&/, $alldata)) { ($key, $value) = split(/=/, $data); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack('C', hex($1))/eg; $value =~ s/\t//g; &jcode'convert(*value, 'sjis', '', 'z'); $value =~ s/&/&/g; $value =~ s//>/g; $value =~ s/"/"/g; if ($key eq 'del') { push(@delete, $value); } $in{"$key"} = $value; } $in{'page'} += 0; return; } ### モバイル表示 - 投稿内容チェック sub mobile_check { $in{'subj'} = &create_line($in{'subj'}); $in{'text'} = &create_text($in{'text'}); $in{'text'} =~ s/&/&/g; $in{'text'} =~ s/<//g; $in{'text'} =~ s/"/"/g; if ($in{'subj'} eq '') { &error("題名が入力されていません。"); } if ($in{'date'} !~ /^\d\d\d\d\d\d\d\d$/) { &error("日付の値が不正です。"); } if ($time_mode == 1) { if ($in{'time'} !~ /^\d\d\d\d$/) { &error("時間の値が不正です。"); } } else { $in{'time'} = '0000'; } if ($fields[1] ne '' && $in{'field'} eq '') { &error("分類が選択されていません。"); } if ($author_mode == 1 && $in{'name'} eq '') { &error("投稿者が選択されていません。"); } if ($in{'text'} eq '') { &error("本文が入力されていません。"); } return; } ### モバイル表示 - エントリ編集 sub mobile_edit { $host = $ENV{'REMOTE_HOST'}; $addr = $ENV{'REMOTE_ADDR'}; if ($host eq "" || $host eq $addr) { if ($gethostbyaddr == 1) { $host = gethostbyaddr(pack("C4", split(/\./, $addr)), 2) || $addr; } } $no = 0; $parent = 0; $subj = ''; $text = ''; foreach (@logs) { if ($_ + 0 > $no) { ($no, $date, $subj, $text) = (split(/\t/))[0, 2, 8, 9]; } if ((split(/\t/))[1] == 0) { $parent++; } } $no++; if ($in{'subj'} eq $subj && $in{'text'} eq $text) { &error("すでに書き込まれています。"); } $line = "$no\t0\t$in{'display'}\t$in{'date'}$in{'time'}\t$in{'field'}\t$in{'name'}\t\t\t$in{'subj'}\t$in{'text'}\t\t\t\t\t\t$host\n"; if ($make_past == 0 && $parent >= $max_log) { foreach (0 .. ($parent - $max_log)) { ($no, $reno) = split(/\t/, $logs[$#logs]); if ($reno == 0) { pop(@logs); } else { while ((split(/\t/, $logs[$#logs]))[1] != 0) { pop(@logs) } pop(@logs); } } } @new = (); $flag = 0; foreach (@logs) { ($no, $reno, $date) = split(/\t/); if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $date = "$1$2$3"; } if ($flag == 0 && $reno == 0 && $in{'date'} + 0 >= $date) { $flag = 1; push(@new, $line); } push(@new, $_); } if ($flag == 0) { push(@new, $line); } @logs = @new; return; } ### モバイル表示 - エントリ投稿 sub mobile_regist { $in{'file'} =~ s/<>/<>/g; $line = "$in{'edit'}\t0\t$in{'display'}\t$in{'date'}$in{'time'}\t$in{'field'}\t$in{'name'}\t\t\t$in{'subj'}\t$in{'text'}\t\t\t$in{'file'}\t\t\t$in{'host'}\n"; @new = (); @tmp = (); foreach (@logs) { ($no, $reno) = split(/\t/); if ($in{'edit'} == $no) { push(@tmp, $line); } elsif ($in{'edit'} == $reno) { push(@tmp, $_); } else { push(@new, $_); } } @logs = (); $flag = 0; foreach (@new) { ($no, $reno, $display, $date) = split(/\t/); if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $date = "$1$2$3"; } if ($flag == 0 && $reno == 0 && $in{'date'} + 0 >= $date) { $flag = 1; push(@logs, @tmp); } push(@logs, $_); } if ($flag == 0) { push(@logs, @tmp); } return; } ### モバイル表示 - ログインフォーム表示 sub mobile_login { print <<"_HTML_"; 認証

    パスワードを入力してください

    戻る
    _HTML_ return; } ### モバイル表示 - エントリ投稿フォーム表示 sub mobile_form { if ($in{'adminpwd'} ne $admin_pwd) { &error("パスワードが違います。"); } if ($in{'edit'} eq '') { ($sec, $min, $hour, $day, $mon, $year, $week) = localtime(time()); $date = sprintf("%04d%02d%02d", $year + 1900, $mon + 1, $day); $time = sprintf("%02d%02d", $hour, $min); $display = 1; } else { foreach (@logs) { ($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $rank, $pwd, $host) = split(/\t/); if ($in{'edit'} == $no) { last; } } if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $date = "$1$2$3"; $time = "$4$5"; } $text =~ s/
    /\n/g; chop($host); } if ($in{'edit'} eq '') { print "エントリ投稿
    \n"; } else { print "エントリ編集
    \n"; } print <<"_HTML_";
    題名

    日付

    _HTML_ if ($time_mode == 1) { print <<"_HTML_"; 時間

    _HTML_ } if ($fields[1] ne '') { print <<"_HTML_"; 分類

    _HTML_ } if ($author_mode == 1) { print <<"_HTML_"; 投稿者

    _HTML_ } print <<"_HTML_"; 本文

    エントリの状態
    _HTML_ if ($display == 0) { print <<"_HTML_"; _HTML_ } else { print <<"_HTML_"; _HTML_ } print <<"_HTML_";

    _HTML_ if ($fields[1] eq '') { print <<"_HTML_"; _HTML_ } print <<"_HTML_";
    戻る
    _HTML_ return; } ### モバイル表示 - エントリ編集フォーム表示 sub mobile_editform { print <<"_HTML_"; 認証

    編集するエントリの番号

    パスワード


    戻る
    _HTML_ return; } ### モバイル表示 - 返信フォーム表示 sub mobile_res { foreach (@logs) { ($no, $reno, $display, $date, $field, $name, $mail, $url, $subj) = split(/\t/); if ($display == 0) { next; } if ($in{'no'} == $no) { $subj = 'Re:' . $subj; last; } } print <<"_HTML_"; 記事投稿

    名前

    Eメール

    URL

    本文

    削除キー


    戻る
    _HTML_ return; } ### モバイル表示 - 記事削除 sub mobile_delete { if ($in{'del'} ne '') { if ($in{'user_pwd'} eq '') { &error("削除キーを入力してください。"); } &lock($lock_file); open(FILE, "$log_file") || &error("ログファイルを読み出せません。"); @logs = ; close(FILE); @new = (); $flag = 0; $del_list = ''; foreach (@logs) { ($no, $reno, $file, $pwd) = (split(/\t/))[0, 1, 12, 14]; if ($flag == 0 && $in{'del'} == $no) { if ($in{'user_pwd'} ne $admin_pwd) { &decrypt($in{'user_pwd'}, $pwd); } $flag = 1; } elsif ($flag == 1 && $in{'del'} == $reno) { $flag = 1; } else { $flag = 0; } if ($flag == 0) { push(@new, $_); } else { $del_list .= "$no "; foreach $file_name (split(/<>/, $file)) { if (-e "$upfile_dir$file_name") { unlink("$upfile_dir$file_name"); } if ($thumbnail_mode == 1 && -e "$thumbnail_dir$file_name") { unlink("$thumbnail_dir$file_name"); } } if (-e "$reserved_trackback_dir$no$reserved_trackback_ext") { unlink("$reserved_trackback_dir$no$reserved_trackback_ext"); } } } if ($del_list eq '') { &error("該当記事がありません。"); } $work_mesg = "$del_list番の記事を削除しました。"; open(FILE, ">$log_file") || &error("ログファイルに書き込めません。"); print FILE @new; close(FILE); if ($html_mode == 1) { &output_htmlfile(); } if ($js_mode != 0) { &output_jsfile(@logs); } &unlock($lock_file); } print <<"_HTML_"; 記事削除

    $work_mesg
    削除する記事の番号

    削除キー


    戻る
    _HTML_ return; } ### モバイル表示 - エントリ表示 sub mobile_all { print "エントリ表\示
    \n"; @show = (); foreach (@logs) { ($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($in{'no'} == $no || $in{'no'} == $reno) { push(@show, $_); } } foreach (@show) { ($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $rank, $pwd, $host) = split(/\t/); if ($display == 0) { next; } &jcode'convert(*subj, 'sjis', '', 'h'); &jcode'convert(*text, 'sjis', '', 'h'); if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { ($sec, $min, $hour, $day, $mon, $year, $week) = localtime(time()); $today = sprintf("%04d%02d%02d", $year + 1900, $mon + 1, $day); if ($new_date != 0 && $today - $date < $new_date) { $new = $new_mark; } else { $new = ''; } $year = sprintf("%04d", $1); $month = sprintf("%02d", $2); $day = sprintf("%02d", $3); $week = $week[&getweek($day, $year, $month)]; $date = qq|$year年$month月$day日($week)|; if ($time_mode == 1) { $time = sprintf("%02d:%02d", $4, $5); } else { $time = ''; } } else { ($sec, $min, $hour, $day, $mon, $year, $week) = localtime($date); $date = sprintf("%02d月%02d日%02d:%02d", $mon + 1, $day, $hour, $min); } if ($auto_link == 1) { $text = &auto_link($text); } if ($file eq '') { $file_list = ''; } else { @file = split(/<>/, $file); $file_list = ''; foreach $file (@file) { if ($thumbnail_mode == 1 && -e "$thumbnail_url$file") { $file_list .= qq| ファイル|; } else { $file_list .= qq| ファイル|; } } } if ($res_mode == 1 && $logs[0] + 0 != 0) { $res = qq|コメントを書く
    |; } chop($host); if ($reno == 0) { if ($fields[1] ne '') { $filed = "分類:$field
    "; } else { $filed = ''; } if ($author_mode == 1 && $name ne '') { $name = "投稿者:$name
    "; } else { $name = ''; } print <<"_HTML_";
    [$no] $subj$file_list

    $text

    $filed$name$date$time
    _HTML_ } else { if ($mail ne '') { $mail = qq| Eメール|; } if ($url ne '') { $url = qq| URL|; } print <<"_HTML_";
    [$no] $subj

    $name$mail$url$file

    $text

    $date
    _HTML_ } } print <<"_HTML_";
    $res 戻る
    _HTML_ return; } ### モバイル表示 - エントリ一覧 sub mobile_list { print <<"_HTML_"; $title

    _HTML_ $start = $in{'page'} * $page_size; $end = $start + $page_size; $i = 0; foreach (@logs) { ($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $rank, $pwd, $host) = split(/\t/); if ($reno == 0) { $i++; } else { next; } if ($i <= $start) { next; } if ($i > $end) { last; } if ($display == 0) { next; } &jcode'convert(*subj, 'sjis', '', 'h'); if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $year = sprintf("%04d", $1); $month = sprintf("%02d", $2); $day = sprintf("%02d", $3); $week = $week[&getweek($day, $year, $month)]; $date = qq|$month月$day日($week)|; } chop($host); print qq|$subj - $date
    \n|; } print "
    \n"; if ($in{'page'} > 0) { $n = $in{'page'} - 1; print qq|前のページ
    \n|; } if (int(($parent - 1) / $page_size) > $in{'page'}) { $n = $in{'page'} + 1; print qq|次のページ
    \n|; } if ($mini_counter == 1) { $counter = sprintf("Access %0${count_figure}d
    ", $sum); } print <<"_HTML_";
    エントリを書く
    エントリ編集
    記事削除
    $counter
    戻る
    _HTML_ return; } ### ミニアクセスカウンタカウントアップ sub count_up { local $host = $ENV{'REMOTE_HOST'}; local $addr = $ENV{'REMOTE_ADDR'}; if ($host eq "" || $host eq $addr) { if ($gethostbyaddr == 1) { $host = gethostbyaddr(pack("C4",split(/\./,$addr)),2) || $addr; } else { $host = $addr; } } local $flag = 0; foreach $list (@no_count_list) { if ($list ne '' && $host =~ /$list/i) { $flag = 1; last; } } if ($flag == 1) { return; } &lock($lock_file); open(COUNT, "$count_log") || &error("カウントログファイルを読み出せません。"); local $data = ; close(COUNT); local($sum, $today, $yesterday, $key, $ip) = split(/\t/, $data); if ($no_double_count == 1 && $host eq $ip) { &unlock($lock_file); return; } local($sec, $min, $hour, $day) = localtime(time()); if ($key == $day) { $today++; } else { $yesterday = $today; $today = 1; } $sum++; $data = "$sum\t$today\t$yesterday\t$day\t$host"; open(COUNT, ">$count_log") || &error("カウントログファイルに書き込めません。"); print COUNT $data; close(COUNT); &unlock($lock_file); return; } ### JSファイル出力 sub output_jsfile { local(@logs) = @_; if ($js_mode == 1 || $js_mode == 3) { @js_logs = (); $i = 0; foreach (@logs) { local($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($reno == 0) { $i++; } else { next; } if ($i > $js_output_text) { last; } if ($display == 0) { next; } if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $date = "$1/$2/$3"; } $subj =~ s/\'/\\\'/g; $text =~ s/\'/\\\'/g; if ($upload_mode == 1 && $file ne '') { @file_info = (); @file = split(/<>/, $file); $j = 0; foreach $file_name (@file) { if (! -e "$upfile_dir$file_name") { next; } $j++; $file_size = &comma(int((stat("$upfile_dir$file_name"))[7] / 1024)); $file_info = qq|

    $file_name(${file_size}KB)

    |; $file_insert[$j] = qq|$file_name(${file_size}KB)|; if ($text !~ /\$FILE$j/) { push(@file_info, $file_info); } } $file_info = ''; foreach $file (@file_info) { $file_info .= $file; } foreach $k (1 .. 3) { if ($k > $j) { last; } $text =~ s/\$FILE${k}_l/$file_insert[$k]/g; $text =~ s/\$FILE${k}_r/$file_insert[$k]/g; $text =~ s/\$FILE${k}/$file_insert[$k]/g; } } else { $file_info = ''; } if ($pause_string ne '' && $text =~ /$pause_string/) { if ($js_text_url_target ne '') { $target = qq| target="$js_text_url_target"|; } else { $target = ''; } $text = (split(/$pause_string/, $text, 2))[0]; $text .= qq|... 続きを読む|; } push(@js_logs, "document.write('■ $subj ... $date

    $file_info$text
    ');\n"); } local $line = qq|document.write('');\n|; push(@js_logs, $line); open(FILE, ">$js_text_file") || &error("JSファイルに書き込めません。"); print FILE @js_logs; close(FILE); } if ($js_mode == 2 || $js_mode == 3) { @js_logs = (); $i = 0; foreach (@logs) { local($no, $reno, $display, $date, $field, $name, $mail, $url, $subj, $text, $color, $icon, $file, $pwd, $host) = split(/\t/); if ($reno == 0) { $i++; } else { next; } if ($i >= $js_output_title) { last; } if ($display == 0) { next; } if ($date =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) { $date = "$1/$2/$3"; } if ($js_title_url ne '') { if ($js_title_url_target ne '') { $target = qq| target="$js_title_url_target"|; } else { $target = ''; } $subj = qq|$subj|; } $subj =~ s/\'/\\\'/g; $text =~ s/\'/\\\'/g; push(@js_logs, "document.write('$date ... $subj
    ');\n"); } open(FILE, ">$js_title_file") || &error("JSファイルに書き込めません。"); print FILE @js_logs; close(FILE); } return; } ### INPUT情報正規化 sub create_line { local($_) = @_; $_ =~ s/^\s+//; $_ =~ s/\s+$//; return $_; } ### TEXTAREA情報正規化 sub create_text { local($_) = @_; $_ =~ s/\r?\n/\r/g; $_ =~ s/^\r+//; $_ =~ s/\r+$//; $_ =~ s/\r/
    /g; return $_; } ### オートリンク sub auto_link { local($_) = @_; $_ =~ s/(https?:\/\/[\w\.\~\-\/\?\&\#\+\=\:\;\@\%]+)/$1<\/a>/gi; $_ =~ s/([\w\-]+\@[\w\-\.]+)/$1<\/a>/gi; return $_; } ### コンマの付加 sub comma { local($_) = @_; while ($_ =~ s/^([-+]?\d+)(\d\d\d)/$1,$2/) {} return $_; } ### 削除キー暗号化 sub encrypt { local($_) = @_; srand(time + $$); local $salt = pack('CC', int(rand(26) + 65), int(rand(10) + 48)); return crypt($_, $salt); } ### 削除キー照合 sub decrypt { local($inpwd, $pwd) = @_; if ($pwd eq '') { &error("該当記事には削除キーが設定されていません。"); } if (crypt($inpwd, $pwd) ne $pwd) { &error("削除キーが違います。"); } return; } ### 曜日を取得 sub getweek { local($day, $year, $month) = @_; if ($month == 1 || $month == 2) { $year--; $month += 12; } return int($year + int($year / 4) - int($year / 100) + int($year / 400) + int ((13 * $month + 8) / 5) + $day) % 7; } ### ファイルアップロード sub upfile { local($file, $filename, $no) = @_; $filename =~ /([^\/\\]*)\.([^.\/\\]*)$/; local $ext = $2; $ext =~ tr/A-Z/a-z/; open(FILE, ">$upfile_dir$no.$ext") || &error("アップロードファイルが保存できません。"); binmode(FILE); print FILE $file; close(FILE); return "$no.$ext"; } ### ログ移動処理 sub move_log { local(*logs, *past, $size) = @_; if ($size ne 're') { foreach (1 .. $size) { while ((split(/\t/, $logs[$#logs]))[1] != 0) { unshift(@past, pop(@logs)); } unshift(@past, pop(@logs)); } } else { foreach (@past) { push(@logs, $_); } } return (*logs, *past); } ### HTMLページ出力 sub output_htmlfile { $html_flag = 1; $stdout = *STDOUT; local $mode_tmp = $in{'mode'}; local $pwd_tmp = $in{'admin_pwd'}; %in = (); open(HTML, ">$html_file") || &error("HTMLファイルが作成できません。"); *STDOUT = *HTML; &html(); close(HTML); *STDOUT = $stdout; $in{'mode'} = $mode_tmp; $in{'admin_pwd'} = $pwd_tmp; $html_flag = 0; return; } ### ファイルロック sub lock { local($lock_file) = @_; local $flag = 0; foreach (1 .. 5) { if (-e $lock_file) { if (time() > (stat($lock_file))[9] + 60) { &unlock($lock_file); next; } sleep(1); } else { open(LOCK, ">$lock_file") || &error("ロックファイルが作成できません。"); close(LOCK); $flag = 1; last; } } if ($flag == 0) { &error("ファイルがロックされています。時間をおいてもう一度投稿してください。"); } return; } ### ファイルロック解除 sub unlock { local($_) = @_; unlink($_); return; } ### GIF,JPEG,PNGサイズ取得(参考:WWWimagesize ... http://www.bloodyeck.com/wwwis/) sub gifsize{ local($GIF) = @_; local($type, $a, $b, $c, $d, $s) = (0, 0, 0, 0, 0, 0); if (defined($GIF) && read($GIF, $type, 6) && $type =~ /GIF8[7,9]a/ && read($GIF, $s, 4) == 4) { ($a, $b, $c, $d) = unpack("C"x4, $s); return ($b << 8 | $a, $d << 8 | $c); } return (0, 0); } sub jpegsize { local($JPEG) = @_; local($done) = 0; local($c1, $c2, $ch, $s, $length, $dummy) = (0, 0, 0, 0, 0, 0); local($a, $b, $c, $d); if (defined($JPEG) && read($JPEG, $c1, 1) && read($JPEG, $c2, 1) && ord($c1) == 0xFF && ord($c2) == 0xD8) { while (ord($ch) != 0xDA && !$done) { while (ord($ch) != 0xFF) { return(0, 0) unless read($JPEG, $ch, 1); } while (ord($ch) == 0xFF) { return(0, 0) unless read($JPEG, $ch, 1); } if ((ord($ch) >= 0xC0) && (ord($ch) <= 0xC3)) { return(0, 0) unless read($JPEG, $dummy, 3); return(0, 0) unless read($JPEG, $s, 4); ($a, $b, $c, $d) = unpack("C"x4, $s); return ($c << 8 | $d, $a << 8 | $b); } else { return(0, 0) unless read ($JPEG, $s, 2); ($c1, $c2) = unpack("C"x2, $s); $length = $c1 << 8 | $c2; last if (!defined($length) || $length < 2); read($JPEG, $dummy, $length - 2); } } } return (0, 0); } sub pngsize { local($PNG) = @_; local($head) = ""; local($a, $b, $c, $d, $e, $f, $g, $h) = 0; if (defined($PNG) && read($PNG, $head, 8) == 8 && $head eq "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a" && read($PNG, $head, 4) == 4 && read($PNG, $head, 4) == 4 && $head eq "IHDR" && read($PNG, $head, 8) == 8){ ($a, $b, $c, $d, $e, $f, $g, $h) = unpack("C"x8, $head); return ($a << 24 | $b << 16 | $c << 8 | $d, $e << 24 | $f << 16 | $g << 8 | $h); } return (0, 0); } ### クッキー関連の処理 sub get_cookie { local($cookie_id) = @_; local %all_cookies = (); foreach (split(/; /, $ENV{'HTTP_COOKIE'})) { local($key, $value) = split(/=/); $all_cookies{"$key"} = $value; } foreach (split(/&/, $all_cookies{"$cookie_id"})) { local ($key, $value) = split(/:/); $value =~ s/&/&/g; $value =~ s//>/g; $value =~ s/"/"/g; $cookie{&unescape($key)} = &unescape($value); } return %cookie; } sub set_cookie { local(*cookie, $cookie_id, $hold_days) = @_; if (time() > $cookie{'refresh'} + 60 * 60 * 24 * 30) { $cookie{'refresh'} = time(); } local @pairs = (); foreach (sort keys %cookie) { push(@pairs, &escape($_) . ':' . &escape($cookie{"$_"})); } local $new_cookie = join('&', @pairs); local $date = &gmt_date(time + 60 * 60 * 24 * $hold_days); if ($new_cookie ne $all_cookies{"$cookie_id"}) { print "Set-Cookie: $cookie_id=$new_cookie; expires=$date\n"; } return; } sub escape { local($_) = @_; $_ =~ s/([&:;=%\x00-\x21])/sprintf("%%%02X", unpack('C',$1))/ge; return $_; } sub unescape { local($_) = @_; $_ =~ s/%([0-9A-Fa-f][0-9A-Fa-f])/pack('C', hex($1))/ge; return $_; } sub gmt_date { local($_) = @_; local($sec, $min, $hour, $day, $mon, $year, $wday) = gmtime($_); local @week = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); local @month = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); return sprintf("%s, %02d %s %04d %02d:%02d:%02d GMT", $week[$wday], $day, $month[$mon], $year + 1900, $hour, $min, $sec); }