#!/usr/local/bin/perl ############################################################################## # shiromuku(u2)LINKS version 1.32 # Created 06/18/2003 # Copyright 2003 Shiromuku # Available at http://www.t-okada.com/cgi/ ############################################################################### # COPYRIGHT NOTICE (著作権の告示) # Copyright 2003 Shiromuku All Rights Reserved. # This script can be used and modified free of charge as long as you don't change this header or any of the parts that give me credit for writing this. (このスクリプトは無償で使用または改変できます。ただしこの著作権の告知と上記のコメント、及びCGIにより生成されるHTML表示下部にある著作権表示部は変えないで下さい。) # By using this script you agree to indemnify me from any liability that might arise from its use. In simple English, if this script somehow makes your computer run amuck and kill the pope, it's not my fault.(このスクリプトを使用することにより、使用者はその使用によって起こる可能性のあるいかなる事柄に対する責務についても、私Shiromukuに免責の保証を与えることに同意したものとします。) # Redistributing and selling the code for this program without prior written consent is expressly forbidden.(前もって書面での承諾を得ることなくこのプログラムのコードを再配布したり売ったりすることは 明確に禁じられています。) ####################### require './jcode.pl'; require './su2_links_lib.cgi'; ####################### use strict; my $gl = &get_globals("su2_links_gl.cgi"); $gl->{version} = "version 1.31"; my ($form); my$config = &open_config ($gl); if ($ENV{'CONTENT_LENGTH'} || $ENV{'QUERY_STRING'}) { $form = &parse_data($gl,$config); } my %HoD = (); @HoD{"gl", "config", "form"} = ($gl, $config, $form); #foreach $key (keys (%{$HoD{config}})) { #if ($key =~ /^c2_/) {$HoD{config}{$key} =~ s/
/\n/g;} #} if ($ENV{'REQUEST_METHOD'} eq "POST") { if ($form->{action} eq "make_html") { unless (defined $form->{cat}) { &error("カテゴリーを選択して下さい。\n", \%HoD); } &make_html (\*STDOUT, \%HoD); exit (0) ; } elsif ($form->{action} eq "user_a1") { &check_pass (\%HoD); &make_html (\*STDOUT, \%HoD); exit (0) ; #&user_a1(\%HoD); } elsif ($form->{action} eq "search_all") {&search_all(\%HoD); exit (0) ;} elsif ($form->{action} eq "search_all_lists") {&search_all_lists(\%HoD); exit (0) ;} } if ($form->{action} eq "make_html") { unless (defined $form->{cat}) { &error("カテゴリーを選択して下さい。\n", \%HoD); } &make_html (\*STDOUT, \%HoD); } else { if (-e "$gl->{basedir}/$gl->{passfile}") {&return_main(\%HoD);} else { &head("管理用ページ", \%HoD); print "

IDとパスワードの設定をする

\n"; print "
まず最初にIDとパスワードの設定をして下さい
\n"; print "
{cgi_a}\">\n"; print "\n"; print "
\n"; print "\n"; print "\n"; print "
ユーザID
(半角英数字で8文字以内にして下さい。)
パスワード
(半角英数字で8文字以内にして下さい。)
パスワード
(確認のためもう一度)
\n"; print "
\n"; print "
\n"; print "\n"; } } exit (0) ; ############################ sub parse_data { my ($gl,$config) = @_; my ($buffer, @pairs, $pair, $name, %form, %cform, %sform, $value, $value_count, $value_count1); if ($ENV{'REQUEST_METHOD'} eq "POST") { if ($config->{check_referer} == 1) {&check_referer($gl,$config);} read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else {$buffer = $ENV{'QUERY_STRING'};} @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; if (($value =~ /\W/) && ($ENV{'REQUEST_METHOD'} ne "POST")) { &error("エラーです。\n",$config); } $value =~ s/\|\|\|//g; $value =~ s/&/&/ig; $value =~ s//>/ig; $value =~ s/\r\n/
/g; $value =~ s/\r/
/g; $value =~ s/\n/
/g; jcode::convert(\$value,$gl->{mycode}); if ($gl->{mycode} eq 'sjis') {jcode::h2z_sjis(\$value); } if ($gl->{mycode} eq 'euc') {jcode::h2z_euc(\$value); } $form{$name} = $value; } return \%form; } ############################ #修正・削除 sub user_a1 { my $HoD = shift; my(@u_data, $test_pass, $flag, $key); &check_pass ($HoD); foreach $key (keys (%{$HoD->{config}})) { if ($key =~ /^c2_/) {$HoD->{config}{$key} =~ s/
/\n/g;} } if ($HoD->{form}{cat} eq "") {&error("カテゴリーを選択して下さい。\n", $HoD->{config});} $HoD->{config}{c1_d_title_color} = "修正・削除"; $HoD->{config}{c2_title} = "

修正・削除

"; print "Content-type: text/html\n\n"; &head_html(\*STDOUT, $HoD); print "$HoD->{config}{c2_title}\n"; open(LOG,"<$HoD->{gl}{basedir}/$HoD->{form}{cat}_$HoD->{form}{txtnumber}\.cgi") or &error("ファイルがオープンできません。\n",$HoD->{config}); my@afile = ; close(LOG); &table_html (\*STDOUT, $HoD); foreach (reverse sort @afile) { next if /^\d+$/; chomp; my@data=split(/\|\|\|/,$_); &subj_date_name_hp_html(\*STDOUT, \@data, $HoD); } print "
\n"; print "


\n"; &admin_html ($HoD); &foot_html (\*STDOUT, $HoD); } ############################ #全記事検索処理 sub search_all { my $HoD = shift; my ($filename, $i, @match, $page_maxs, $p, $ps, $lines, @s_data, $cat_data, $cat_name_j,$lastnumx,$pp,$s_num, $p_flag, %last,$COL); if ($HoD->{config}{show_date}) {$COL = "5";} else {$COL = "4";} if ($HoD->{form}{cat} eq "") {&error("BBSを選択して下さい。\n",$HoD->{config});} if (($HoD->{config}{img_c_mark} eq "") || ($HoD->{config}{img_c_mark} eq "http://")) {$HoD->{config}{img_c_mark} = $HoD->{config}{c1_c_comment};} else {$HoD->{config}{img_c_mark} = "{config}{img_c_mark}\">";} my $searchword = $HoD->{form}{searchword}; my $next_page = $HoD->{form}{next_page}; my $cat = $HoD->{form}{cat}; if ($searchword eq '') {&error("キーワードを記入して下さい。\n",$HoD->{config});} $cat_data = &get_catname ($cat, $HoD); $cat_name_j = $cat_data->[2]; $searchword =~ s//>/ig; $searchword =~ s/ / /g; my @searchword = split(' ', $searchword); $HoD->{config}{c1_d_title_color} = "Search"; print "Content-type: text/html\n\n"; &head_html(\*STDOUT,$HoD); print "

Search

\n"; print "
【$searchword】の検索結果です\n"; open (LFILE,">$HoD->{gl}{basedir}/$HoD->{form}{cat}$HoD->{gl}{lockfile}") or &error("ファイルがオープンできません。\n",$HoD->{config}); eval("flock(LFILE, 2)"); opendir (DIR, "$HoD->{gl}{basedir}"); foreach $filename ( readdir (DIR) ) { if ($filename =~ /^$cat\_(\w+)\.cgi$/o) { $lastnumx = $1; open(FILE,"<$HoD->{gl}{basedir}/$filename") or &error("ファイルがオープンできません。\n",$HoD->{config}); while () { next if /^\d+$/; $pp = 0; foreach $i (@searchword) { if (index($_,$i) >= 0) { $pp++; if ($HoD->{form}{s} eq 'or') { last; } } else { $pp = 0; if ($HoD->{form}{s} eq 'and') { last; } } } $_ .= $lastnumx . "\n"; $_ .= $cat_name_j . "\n"; push (@match, $_) if ($pp > 0); } $s_num = @match; close(FILE); } } closedir (DIR); eval("flock(LFILE, 8)"); close(LFILE); if ($s_num) { print "--- 該当記事: $s_num

\n"; if (!$HoD->{form}{next_page}) { $page_maxs = $HoD->{config}{n_page_max}; $p = 0; $HoD->{form}{next_page} = 0; $ps = 0;} else { $page_maxs = $HoD->{form}{next_page} + $HoD->{config}{n_page_max}; $p = 0; $ps = $HoD->{form}{next_page};} &table_html (\*STDOUT, $HoD); foreach $lines (@match) { my @line = split(/\n/,$lines); chomp $line[0]; @s_data = split(/\|\|\|/,$line[0]); $HoD->{form}{txtnumber} = $line[1]; my $cat_name_j = $line[2]; if ($p >= $page_maxs) { $p_flag = 1; last; } if (($p < $page_maxs) && ($p >= $HoD->{form}{next_page})) { print "カテゴリー: $cat_name_j {gl}{cgi}?action=make_html&cat=$HoD->{form}{cat}&txtnumber=$HoD->{form}{txtnumber}\">[BACK]\n"; &subj_date_name_hp_html(\*STDOUT, \@s_data, $HoD); $ps++; } $p++; } print "
\n"; $last{ps} = $ps; $last{page_maxs} = $page_maxs; $last{p_flag} = $p_flag; $HoD->{last} = {%last}; &last_html ($HoD); } else { print "
該当する記事はありませんでした。
\n"; } print "
\n"; &search_html(\*STDOUT,$HoD); print "
\n"; &foot_html (\*STDOUT, $HoD); } ############################ #全記事条件検索処理 sub search_all_lists { my $HoD = shift; my ($filename, $i, @match, $page_maxs, $p, $ps, $lines, @s_data, $cat_data, $cat_name_j,$lastnumx,$pp,$s_num, $p_flag, %last, @pp_data, $cat,$COL,$catx); if ($HoD->{config}{show_date}) {$COL = "5";} else {$COL = "4";} #if ($HoD->{form}{cat} eq "") {&error("BBSを選択して下さい。\n",$HoD->{config});} if (($HoD->{config}{img_c_mark} eq "") || ($HoD->{config}{img_c_mark} eq "http://")) {$HoD->{config}{img_c_mark} = $HoD->{config}{c1_c_comment};} else {$HoD->{config}{img_c_mark} = "{config}{img_c_mark}\">";} my$searchword = $HoD->{form}{searchword}; $searchword =~ s//>/ig; my$searchword_1 = $HoD->{form}{searchword_1}; my$searchword_2 = $HoD->{form}{searchword_2}; my$searchword_3 = $HoD->{form}{searchword_3}; my$searchword_4 = $HoD->{form}{searchword_4}; my$searchword_5 = $HoD->{form}{searchword_5}; my $next_page = $HoD->{form}{next_page}; $catx = $HoD->{form}{cat}; $cat = $HoD->{form}{cat}; if ($cat eq "") {$cat = qr/\d+/;} #if ($searchword eq '') {&error("キーワードを記入して下さい。\n",$HoD->{config});} $searchword =~ s/ / /g; my @searchword = split(' ', $searchword); $HoD->{config}{c1_d_title_color} = "Search"; print "Content-type: text/html\n\n"; &head_html(\*STDOUT,$HoD); print "

Search

\n"; if($searchword) { print "
【$searchword】の検索結果です\n"; } open (LFILE,">$HoD->{gl}{basedir}/$HoD->{form}{cat}$HoD->{gl}{lockfile}") or &error("ファイルがオープンできません。\n",$HoD->{config}); eval("flock(LFILE, 2)"); opendir (DIR, "$HoD->{gl}{basedir}"); foreach $filename ( readdir (DIR) ) { if ($filename =~ /^($cat)\_(\w+)\.cgi$/o) { my$cat = $1; $cat_data = &get_catname ($cat, $HoD); $cat_name_j = $cat_data->[2]; $lastnumx = $2; open(FILE,"<$HoD->{gl}{basedir}/$filename") or &error("ファイルがオープンできません。\n",$HoD->{config}); while () { @pp_data = split(/\|\|\|/,$_); next if /^\d+$/; if ((($pp_data[7] eq $searchword_1) || ($searchword_1 eq "")) && (($pp_data[20] eq $searchword_2) || ($searchword_2 eq "")) && (($pp_data[31] eq $searchword_3) || ($searchword_3 eq "")) && (($pp_data[32] eq $searchword_4) || ($searchword_4 eq "")) && (($pp_data[33] eq $searchword_5) || ($searchword_5 eq ""))) { if ($searchword eq "") { $_ .= $cat . "\n"; $_ .= $lastnumx . "\n"; $_ .= $cat_name_j . "\n"; push (@match, $_); } else { $pp = 0; foreach $i (@searchword) { if (index($_,$i) >= 0) { $pp++; if ($HoD->{form}{s} eq 'or') { last; } } else { $pp = 0; if ($HoD->{form}{s} eq 'and') { last; } } } $_ .= $cat . "\n"; $_ .= $lastnumx . "\n"; $_ .= $cat_name_j . "\n"; push (@match, $_) if ($pp > 0); } } } close(FILE); } } closedir (DIR); eval("flock(LFILE, 8)"); close(LFILE); $s_num = @match; if ($s_num) { print "--- 該当記事: $s_num

\n"; if (!$HoD->{form}{next_page}) { $page_maxs = $HoD->{config}{n_page_max}; $p = 0; $HoD->{form}{next_page} = 0; $ps = 0;} else { $page_maxs = $HoD->{form}{next_page} + $HoD->{config}{n_page_max}; $p = 0; $ps = $HoD->{form}{next_page};} &table_html (\*STDOUT, $HoD); foreach $lines (@match) { my @line = split(/\n/,$lines); chomp $line[0]; @s_data = split(/\|\|\|/,$line[0]); $HoD->{form}{cat} = $line[1]; $HoD->{form}{txtnumber} = $line[2]; my $cat_name_j = $line[3]; if ($p >= $page_maxs) { $p_flag = 1; last; } if (($p < $page_maxs) && ($p >= $HoD->{form}{next_page})) { print "カテゴリー: $cat_name_j {gl}{cgi}?action=make_html&cat=$HoD->{form}{cat}&txtnumber=$HoD->{form}{txtnumber}\">[BACK]\n"; &subj_date_name_hp_html(\*STDOUT, \@s_data, $HoD); $ps++; } $p++; } print "
\n"; $last{ps} = $ps; $last{page_maxs} = $page_maxs; $last{p_flag} = $p_flag; $HoD->{last} = {%last}; $HoD->{form}{cat} = $catx; &last_html ($HoD); } else { print "
該当する記事はありませんでした。
\n"; } $HoD->{form}{cat} = ""; print "
\n"; &search_html(\*STDOUT,$HoD); print "
\n"; &foot_html (\*STDOUT, $HoD); } ############################ #メインページ sub return_main { my $HoD = shift; my ($page_maxs, $p, $ps, $p_flag, $new_mark, @data, $yearn1, $monn1, $dayn1, $hourn1, $minn1, $secn1, $week1, $date1, $time1, $timex1, $pp_flag, %last, $key); #$HoD->{config}{img_bkgd_img} = $HoD->{config}{img_bkgd_img1}; $HoD->{config}{use_random_img} = $HoD->{config}{use_random_img1}; $HoD->{config}{c2_bkgd_img} = $HoD->{config}{c2_bkgd_img1}; $HoD->{config}{bgcolor} = $HoD->{config}{bgcolor1}; $HoD->{config}{text_color} = $HoD->{config}{text_color1}; $HoD->{config}{link_color} = $HoD->{config}{link_color1}; $HoD->{config}{alink_color} = $HoD->{config}{alink_color1}; $HoD->{config}{vlink_color} = $HoD->{config}{vlink_color1}; $HoD->{config}{c2_stylesheet} = $HoD->{config}{c2_stylesheet1}; my ($yearn, $monn, $dayn, $hourn, $minn, $secn, $week, $date, $time, $timex) = &date_time; if (($HoD->{config}{img_n_mark} eq "") || ($HoD->{config}{img_n_mark} eq "http://")) {$HoD->{config}{img_n_mark} = $HoD->{config}{c1_n_comment};} else {$HoD->{config}{img_n_mark} = "{config}{img_n_mark}\">";} if (($HoD->{config}{img_n_mark1} eq "") || ($HoD->{config}{img_n_mark1} eq "http://")) {$HoD->{config}{img_n_mark1} = $HoD->{config}{c1_n_comment1};} else {$HoD->{config}{img_n_mark1} = "{config}{img_n_mark1}\">";} $HoD->{config}{n_page_max} = $HoD->{config}{n_page_max2}; if (!$HoD->{form}{next_page}) { $page_maxs = $HoD->{config}{n_page_max}; $p = 0; $HoD->{form}{next_page} = 0; $ps = 0;} else { $page_maxs = $HoD->{form}{next_page} + $HoD->{config}{n_page_max}; $p = 0; $ps = $HoD->{form}{next_page};} my $file = &file_open("$HoD->{gl}{basedir}/$HoD->{gl}{catfile}",1); print "Content-type: text/html\n\n"; &head_html(\*STDOUT,$HoD); my$c_num; if ($HoD->{config}{show_counter}) {$c_num = &counter ($HoD);} if ($HoD->{config}{show_counter}) { print "{config}{figure_color}\" SIZE=2>$c_num\n"; } print "$HoD->{config}{c2_title}\n"; if ($HoD->{config}{n_b_width} eq "") {$HoD->{config}{n_b_width} = 1;} if ($HoD->{config}{border_color_t}) { print "
{config}{n_b_width} COLOR=\"$HoD->{config}{border_color_t}\" WIDTH=\"$HoD->{config}{t_width_t}\">\n"; } else { print "
{config}{n_b_width} WIDTH=\"$HoD->{config}{t_width_t}\">\n"; } print "
\n"; if ($HoD->{config}{img_back_url}) { print "[{config}{img_back_url}\" TARGET=_top style=\"text-decoration:none\">HOME]\n"; } if ($HoD->{config}{allow_submit} && ($HoD->{form}{action} !~ /search/)) { print "[{gl}{cgi_u}?action=show_form\" style=\"text-decoration:none\">登録]\n"; } print "[{gl}{cgi_u}?action=show_search\">検索]\n"; print "[{gl}{cgi_u}?action=admin_enter\">Admin]\n"; print "
\n"; if ($HoD->{config}{border_color_t}) { print "
{config}{n_b_width} COLOR=\"$HoD->{config}{border_color_t}\" WIDTH=\"$HoD->{config}{t_width_t}\">\n"; } else { print "
{config}{n_b_width} WIDTH=\"$HoD->{config}{t_width_t}\">\n"; } print "$HoD->{config}{c2_introduction1}\n"; if ($HoD->{config}{border_color_t} eq "") { $HoD->{config}{border_color_t} = $HoD->{config}{text_color1}; } #if ($HoD->{config}{td_color_t} eq "") { #$HoD->{config}{td_color_t} = $HoD->{config}{bgcolor1}; #} #if ($HoD->{config}{table_color_t} eq "") { #$HoD->{config}{table_color_t} = $HoD->{config}{bgcolor1}; #} $HoD->{config}{border_color} = $HoD->{config}{border_color_t}; $HoD->{config}{text_color} = $HoD->{config}{text_color1}; $HoD->{config}{table_color} = $HoD->{config}{table_color_t}; $HoD->{config}{t_width} = $HoD->{config}{t_width_t}; $HoD->{config}{border_style} = $HoD->{config}{border_style_t}; my$x; if ($HoD->{config}{border_color}) {$x = $HoD->{config}{border_color};} else {$x = $HoD->{config}{text_color1};} my$y; if ($HoD->{config}{td_color_t}) {$y = "BGCOLOR=\"$HoD->{config}{td_color_t}\"";} else {$y = "";} my$z; if ($HoD->{config}{table_color}) {$z = "BGCOLOR=\"$HoD->{config}{table_color}\"";} else {$z = "";} if (@{$file}) { #print "
{config}{t_width_t}\" BORDER=0 CELLSPACING=$HoD->{config}{n_b_width} CELLPADDING=5 BGCOLOR=\"$HoD->{config}{border_color_t}\">\n"; print "
\n"; &table_b_html(\*STDOUT,$HoD); foreach (@{$file}) { @data = split(/\|\|\|/,$_); if ($p >= $page_maxs) { $pp_flag = 1; last; } if (($p < $page_maxs) && ($p >= $HoD->{form}{next_page})) { if (($timex - $data[6]) > ($HoD->{config}{n_show_new_time} * 3600)) {$new_mark ="";} else {$new_mark = $HoD->{config}{img_n_mark};} $date1 = ""; if ($data[6]) { ($yearn1, $monn1, $dayn1, $hourn1, $minn1, $secn1, $week1, $date1, $time1, $timex1) = &date_time($data[6]); } if ($date1 eq $date) {$date1 = $HoD->{config}{img_n_mark1};} if (!$date1) {$date1 = "未登録";} print "
\n"; if ($data[3]) {print "\n";} else {print "\n";} if ($HoD->{config}{show_date}) { print "\n"; } print "\n"; $ps++; } $p++; } print "
{config}{border_style}; border-width: $HoD->{config}{n_b_width}px; border-collapse: collapse\">{gl}{cgi}?action=make_html&cat=$data[1]&txtnumber=log\" style=\"text-decoration:none\">\n"; if ($data[4] && ($data[4] ne 'http://')) { print " "; } print "{config}{c1_cat_color}>$data[2]\n"; print "$new_mark\n"; print "{config}{border_style}; border-width: $HoD->{config}{n_b_width}px; border-collapse: collapse\">{config}{c1_catd_color}>$data[3]{config}{border_style}; border-width: $HoD->{config}{n_b_width}px; border-collapse: collapse\">{config}{c1_catd_color}>{config}{border_style}; border-width: $HoD->{config}{n_b_width}px; border-collapse: collapse\">$date1

\n"; } $last{ps} = $ps; $last{page_maxs} = $page_maxs; $last{p_flag} = $pp_flag; $HoD->{last} = {%last}; &last_html ($HoD,$HoD->{gl}{cgi}); print "$HoD->{config}{c2_back1}\n"; &foot_html1 (\*STDOUT,$HoD); } ############################ #counter sub counter { my $HoD = shift; my $c_num = &get_number ($HoD->{gl}{c_numfile}, '0', $HoD); if ($ENV{'REQUEST_METHOD'} ne "POST") { $c_num = &increment_num ($HoD->{gl}{c_numfile},$c_num, $HoD); } if (length $c_num < $HoD->{config}{n_figure1}) { $c_num = &make_figure ($c_num,length $c_num,$HoD->{config}{n_figure1}); } return $c_num; } ############################ #桁数調整 sub make_figure { my ($num, $length, $figure) = @_; my $keta = $figure - $length; my $i = 0; while ($i < $keta) { $num = "0$num"; $i++; } return $num; }