#!C:/Perl/bin/perl ############################################################################## # shiromukuNEWS version 3.00 # Created 02/27/2003 # Copyright 2003 Shiromuku # Available at http://www.t-okada.com/cgi/ ############################################################################### # COPYRIGHT NOTICE (著作権の告示) # Copyright 2002 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 './s_news_lib.cgi'; ####################### use strict; my $gl = &get_globals("s_news_gl.cgi"); $gl->{version} = "version 3.00"; my ($form, $filename); if ($ENV{'CONTENT_LENGTH'} || $ENV{'QUERY_STRING'}) {$form = &parse_data($gl);} my $config = &open_config ($gl, $form); my %HoD = (); @HoD{"gl", "config", "form"} = ($gl, $config, $form); if ($ENV{'REQUEST_METHOD'} eq "POST") { if ($form->{action} eq "search_all") {&search_all(\%HoD); exit(0) ;} elsif ($form->{action} eq "write_article") {&write_article(\%HoD); exit(0) ;} elsif ($form->{action} eq "removearticle") { &check_pass(\%HoD); &selectsec(\%HoD); exit(0) ; } elsif ($form->{action} eq "download_log") {&selectsec(\%HoD); exit(0) ;} } if ($form->{action} eq "showlast") {&selectsec(\%HoD);} elsif ($form->{action} eq "show_detail") {&show_detail(\%HoD);} elsif ($form->{action} eq "show_all") {&selectsec(\%HoD);} else { $filename = "$gl->{basedir}/$gl->{passfile}"; if (-e $filename) {&selectsec(\%HoD);} else { &head("管理用ページ", \%HoD); print "

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

\n"; print "
まず最初にIDとパスワードの設定をして下さい
\n"; print "
{cgi_a}\">\n"; print "\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 = shift; my ($buffer, @pairs, $pair, $name, %form, $value); if ($ENV{'REQUEST_METHOD'} eq "POST") { if ($gl->{check_referer} == 1) {&check_referer($gl);} 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 ($ENV{'REQUEST_METHOD'} ne "POST") { if ($value =~ /\W/){&error("エラーです。\n");} } $value =~ s/\|\|\|//g; $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 write_article { my $HoD = shift; &check_pass ($HoD); &head("日記の書き込み",$HoD); print "
{gl}{cgi_r}\">\n"; print "\n"; print "{form}{txtnumber}\">\n"; &add_html ($HoD); &id_html1($HoD); print "
\n"; print "
\n"; if ($HoD->{config}{use_icon} eq "1") { print "
{gl}{cgi_a}\" TARGET=_blank>\n"; print "\n"; 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); my$searchword = $HoD->{form}{searchword}; my$next_page = $HoD->{form}{next_page}; if ($searchword eq '') {&error("Please enter keywords\n", $HoD);} $searchword =~ s/ / /g; my@searchword = split(' ', $searchword); $HoD->{config}{c1_d_title_color} = "Search"; $HoD->{config}{c2_title} = "

Search

"; $HoD->{config}{c2_introduction} = ""; &head_html(\*STDOUT,$HoD); print "

Search

\n"; print "
\n"; print "
【$searchword】 results\n"; my$section = "$HoD->{gl}{section}"; opendir (DIR, "$HoD->{gl}{basedir}"); foreach $filename ( readdir (DIR) ) { if ($filename =~ /^${section}_(\w+)\.txt$/o) { $lastnumx = $1; open(FILE,"<$HoD->{gl}{basedir}/$filename") or &error("can not open the file\n", $HoD); 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"; push (@match, $_) if ($pp > 0); } $s_num = @match; close(FILE); } } closedir (DIR); $HoD->{config}{n_page_max} = $HoD->{config}{n_old_max}; if ($s_num) { print "--- results: $s_numitems

\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};} foreach $lines (@match) { my @line = split(/\n/,$lines); chomp $line[0]; @s_data = split(/,/,$line[0]); $HoD->{form}{txtnumber} = $line[1]; if ($p >= $page_maxs) { $p_flag = 1; last; } if (($p < $page_maxs) && ($p >= $HoD->{form}{next_page})) { &subj_date_name_hp_html("main", \@s_data, $HoD); $ps++; } $p++; } $last{ps} = $ps; $last{page_maxs} = $page_maxs; $last{p_flag} = $p_flag; $HoD->{last} = {%last}; &last_html ($HoD); } else { print "
not be founded
\n"; } &search_html ($HoD); print "
\n"; &foot_html (\*STDOUT, $HoD); } ############################ #counter sub counter { my $HoD = shift; my $c_num = &get_number ($HoD->{gl}{c_numfile}, '1', $HoD); if ($HoD->{form}{txtnumber} eq "log") { &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; }