#!/usr/bin/perl require "./ain.pl"; #-------------------------------------------------------------------------- # 初期処理 #-------------------------------------------------------------------------- if ($] < 5) { &error('システムエラー','Perlはv5以降のバージョンを使用してください.'); } if (!-e $base_dir) { &error('エラー',"データディレクトリが見つかりません."); } $date_now = sprintf("%01d/%01d(%s)%02d:%02d:%02d",$mon +1,$mday,$wday_array[$wday],$hour,$min,$sec); read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); if ($ENV{'QUERY_STRING'} ne '') { $buffer .= "\&$ENV{'QUERY_STRING'}"; } if ($center) { $center1 = '
'; $center2 = '
'; } @pairs = split(/&/,$buffer); foreach $pair (@pairs) { ($name,$value) = split(/=/,$pair); if ($name eq '') { next; } if ($name ne 'FF' && $name ne 'IDX') { push(@Buf,"$name=$value"); } $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; &jcode'convert(*value,'euc'); $value =~ s///g; $value =~ s/\n//g; $value =~ s/\r//g; $value =~ s/\f//g; $value =~ s/\t//g; $FORM{$name} = $value; } if ($FORM{'strings'} ne '') { $strings_sjis = $FORM{'strings'}; &jcode'convert(*strings_sjis,'sjis'); } #-------------------------------------------------------------------------- # 出品データ取得 #-------------------------------------------------------------------------- ($secg,$ming,$hourg,$mdayg,$mong,$yearg,$wdayg,$ydayg,$isdstg) = gmtime(time - 24*60*60); $tmp_remove = sprintf("%04d%02d%02d%02d%02d%02d",$yearg +1900,$mong +1,$mdayg,$hourg,$ming,$secg); $check = (eval { opendir(DIR,$base_dir); }, $@ eq ""); if (!$check) { &error("エラー","Can't get directory"); } @BASE = (); @list = readdir(DIR); foreach $directory (@list) { next if $directory eq '.'; next if $directory eq '..'; unless (-d "$base_dir$directory") { next; } if ($directory =~ /(\d+)\.o/) { push(@BASE,$1); } elsif ($directory < $tmp_remove) { &delete_all("$base_dir$directory"); rmdir("$base_dir$directory") } } close(DIR); @BASE = sort { $a <=> $b; } @BASE; #-------------------------------------------------------------------------- # ページ処理 #-------------------------------------------------------------------------- if ($FORM{'FF'} eq '') { $FF = 0; } else { $FF = $FORM{'FF'}; } $TO = $FF + $page - 1; if ($TO > $#BASE) { $TO = $#BASE; } $hit = 0; $next_num = ''; foreach $num ($FF .. $#BASE) { $directory = $BASE[$num]; &GetData($BASE[$num]); $search_strings = "$GOODS{$directory}{'email'} $GOODS{$directory}{'handle'} $GOODS{$directory}{'goods_remarks'} $GOODS{$directory}{'goods_name'} $directory"; &jcode'convert(*search_strings,'euc'); ($limit,$remain) = &remain($directory); if ($FORM{'action'} eq 'endlist') { if ($remain <= 0) { ; } else { next; } } else { if ($remain > 0) { ; } else { next; } } if ($FORM{'strings'} ne '') { if ($search_strings =~ /^([\x00-\x7F]|[\x8E\xA1-\xFE][\xA1-\xFE]|\x8F[\xA1-\xFE]{2})*$FORM{'strings'}/i) { ; } else { next; } } if ($FORM{'FF'} ne '') { $allhits = $FORM{'allhits'}; if ($hit == $page) { last; } else { push(@NEW,$directory); $hit++; } } else { if ($allhits % $page == 0) { push(@Index,$num); } if ($hit < $page) { $hit++; push(@NEW,$directory); } $allhits++; if (defined($code{$code})) { push(@ERR,$code); } else { $code{$code} = $code; } } } if ($FORM{'allhits'} eq '') { push(@Buf,"allhits=$allhits"); $FORM{'allhits'} = $allhits; } if ($FORM{'FF'} ne '') { @Index = split(/\s/,$FORM{'IDX'}); } $count_new = @NEW; #-------------------------------------------------------------------------- # 画面出力 #-------------------------------------------------------------------------- print "Content-type: text/html\n\n"; print <<"EOF"; Nyan里親探し
$date_now
EOF if ($FORM{'action'} ne 'endlist') { print <<"EOF";
文字列
[ 登録一覧 ]
EOF } if (!@NEW) { print "○ありません.

\n"; } else { print "検索結果 $FORM{'allhits'} 件 [ "; $buf = join('&',@Buf); $idx = join('+',@Index); foreach (0 .. $#Index) { $view_page = $_ + 1; if ($FF == $Index[$_] || ($FORM{'FF'} eq '' && $_ == 0)) { print " $view_page"; $page_now = $view_page; } else { print " $view_page"; } } $FROM = $page_now * $page - ($page - 1); $LAST = $FROM + $count_new - 1; if ($FORM{'action'} eq 'endlist') { $tmes = "落札情報"; } else { $tmes = "残り入札時間"; } print <<"EOF"; ] [最新の状態][登録する]


ページ $page_now ($FROM〜$LAST)

EOF if ($FORM{'action'} eq 'endlist') { print "\n"; $f = 0; foreach $directory (@NEW) { 1 while $GOODS{$directory}{'min_fee'} =~ s/(.*\d)(\d\d\d)/$1,$2/g; $c++; unless ($c % 2) { $bg = "#ffeedd"; } else { $bg = "#ffffff"; } if ($GOODS{$directory}{'attc'} ne '') { $goods_view = "\"画像あり\""; } #写真付き else { $goods_view = ""; } if (open(DATA,"$base_dir$directory\.o\/tender.dat")) { @TEND = ; close(DATA); ($number2,$pwd,$now_fee,$handle,$user_name,$email,$post_number,$addr,$tel,$fax,$birth,$pref,$date,$host) = &DecodeCSV($TEND[$#TEND]); 1 while $now_fee =~ s/(.*\d)(\d\d\d)/$1,$2/g; $now_fee2 = 0; } else { $now_fee = "(入札なし)"; $now_fee2 = 1; } ($limit,$remain) = &remain($directory); if ($remain > 0) { $bar = int($remain / 8640); if ($bar == 0) { $bar = 1; } if ($remain < 86400) { $bar_image ="red.gif"; } elsif ($remain >= 86400 && $remain < 172800) { $bar_image ="yellow.gif"; } else { $bar_image ="blue.gif"; } $limit_time = ""; } else { if ($now_fee2) { $limit_time = ""; } else { $limit_time = ""; } } print <<"EOF"; EOF if ($FORM{'action'} eq 'endlist') { @START = (); foreach (split("\0",$GOODS{$directory}{'start'})) { push(@START,$_); } $START = join('
',@START); } print "\n"; } print <<"EOF";
登録日付 画像 猫種類 紹介文(再)登録時間\n"; } print "
$limit
処理待機中(終了/再登録)落札者決定(案内中)
$GOODS{$directory}{'start'} $goods_view $GOODS{$directory}{'goods_name'} $GOODS{$directory}{'goods_remarks'}

EOF } print <<"EOF";


[最新の状態] [登録する] EOF if ($FORM{'action'} ne 'endlist') { print "\n"; } else { print "[登録一覧]\n"; } print <<"EOF";
$msg_btm1

$center2

TOP PAGEに戻る

Copyright(C) 2000 Wan Nyan Love Land Link All Rights Reserved,

EOF exit; sub DecodeCSV { #-------------------------------------------------------------------------- # CSVデコード処理 #-------------------------------------------------------------------------- local($text) = @_; local(@fields) = (); local($a); $text =~ s/\n//; if ($text eq '') { return (); } while ($text =~ m/"([^\\]*(\\.[^\\]*)*)",?|([^,]+),?|,/g) { $a = defined($1) ? $1 : $3; $a =~ s/""/"/g; $a =~ s/&/&/g; $a =~ s/"/"/g; $a =~ s//>/g; push(@fields,$a); } push(@fields, undef) if $text =~ m/,$/; @fields; } sub delete_all { #-------------------------------------------------------------------------- # ディレクトリ内のファイルをすべて削除する処理 #-------------------------------------------------------------------------- local($dir) = @_; #ディレクトリ名 local($file,@list,$count,$count1); $check = (eval { opendir(DIR,$dir); }, $@ eq ""); if (!$check) { &error("致命的なエラー","Can't get directory"); } @list = readdir(DIR); foreach $file (@list) { next if $file eq '.'; next if $file eq '..'; $count1 = unlink "$dir/$file"; $count += $count1; } close(DIR); return $count; #削除した数を返す } sub remain { #-------------------------------------------------------------------------- # 残時間処理 #-------------------------------------------------------------------------- local($limit) = @_; local($sec,$remain); $now = time; $remain = $sec = $limit - $now; $DAY{'day'} = int($sec / 86400); $sec = $sec - ($DAY{'day'} * 86400); $DAY{'hour'} = int($sec / 3600); $sec = $sec - ($DAY{'hour'} * 3600); $DAY{'min'} = int($sec / 60); $DAY{'sec'} = $sec - ($DAY{'min'} * 60); if ($DAY{'day'} == 0) { return $DAY{'hour'} . '時間' . $DAY{'min'} . '分' . $DAY{'sec'} .'秒' , $remain; } else { return $DAY{'day'} . '日' . $DAY{'hour'} . '時間' . $DAY{'min'} . '分' . $DAY{'sec'} .'秒' , $remain; } } sub GetData { #-------------------------------------------------------------------------- # 出品データの読みこみ #-------------------------------------------------------------------------- local($directory) = @_; local($data,$key,$val); if (open(DAT,"$base_dir$directory\.o/index.dat")) { while () { s/\n//g; ($key,$val) = split(/\t/); $GOODS{$directory}{$key} .= "\0" if (defined($GOODS{$directory}{$key})); $GOODS{$directory}{$key} .= $val; } close(DAT); } } sub error { #-------------------------------------------------------------------------- # エラー処理 #-------------------------------------------------------------------------- local (@msg) = @_; local ($i); print "Content-type: text/html\n\n"; print <<"EOF"; ERROR $body $center1

$_[0]

EOF print "\n"; print <<"EOF";

[戻る]

$center2 EOF exit; }