#!/usr/bin/perl ################################################## # Topics BackNumberCGI Rev.2.0.0.1 # Created by CATWALK(伊藤智子) # Created on 2002年5月1日 ################################################## use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser); ################################################## # 初期設定ここから ################################################## require 'shinsengumi.pl'; require 'jcode.pl'; #このCGIのURL $CgiURL = './bnumber.cgi'; #デザインファイル $CSSFile = '../css/font_win.css'; #データファイル $DataFile = '../data/info.dat'; #HTMLファイル $INFO_HTML = '../data/topics.html'; #画像のURL $ImgURL = '../img/'; #CGIのタイトル $CgiTitle = '新着情報CGI'; # 最大表示件数 $MaxShowSize = 4; #三角アイコン $TriIcon = $ImgURL . 'pinkicon.gif'; #アイコンへのパス $image = <<"EOL"; "$TriIcon" width="20" height="20" border="0" alt="●" EOL #Newアイコン $NewIcon = $ImgURL . 'icn_newer.gif'; #新しい記事アイコン $new_icon = <<"EOL"; "$NewIcon" width="100" height="40" alt="新しい記事へ" border="0" EOL #Oldアイコン $OldIcon = $ImgURL . 'icn_older.gif'; #古い記事アイコン $old_icon = <<"EOL"; "$OldIcon" width="100" height="40" alt="古い記事へ" border="0" EOL ################################################## # 初期設定ここまで ################################################## $CopyRight = <<"EOL"; TopicsCGIWeb新撰組 EOL sub bynumber { $b <=> $a; } if(param('start')){ $start = param('start'); }else{ $start = 0; } $end = $start + $MaxShowSize - 1; ################ #データ読み込み ################ open(DATA,"$DataFile") || &error(100,"Can not open DataFile."); while(){ $line = $_; chop($line); $sec = (split(/Enc_Sep_Code/,$line))[3]; push @allsec,$sec; $ALLLINES{$sec} = $line; } close(DATA); @allsec = sort bynumber @allsec; foreach $sec(@allsec){ push @datas,$ALLLINES{$sec}; } ############# #データ表示 ############# open HTML,"$INFO_HTML" || &error(400,'infocgi.htmlが開けません'); while(){ $line = $_; &jcode::convert(*line,'euc'); last if($line =~ m|<\!\-\-[^<>]*\"DATASTART\"[^<>]*\-\->|i); if ($line =~ m|<\!\-\-[^<>]*\"NEWLINK\"[^<>]*\-\->|i){ if ($start > 0){ $f_start = $start - $MaxShowSize; if ($f_start < 0){ $f_start = 0; } $line =~ s|<\!\-\-[^<>]*\"NEWLINK\"[^<>]*\-\->||i; }else{ $line =~ s|<\!\-\-[^<>]*\"NEWLINK\"[^<>]*\-\->| |i; } } if ($line =~ m|<\!\-\-[^<>]*\"OLDLINK\"[^<>]*\-\->|i){ if ($end < $#datas){ $f_start = $end +1; $line =~ s|<\!\-\-[^<>]*\"OLDLINK\"[^<>]*\-\->||i; }else{ $line =~ s|<\!\-\-[^<>]*\"OLDLINK\"[^<>]*\-\->| |i; } } $HTML_1 .= $line; } while(){ $line = $_; &jcode::convert(*line,'euc'); if($line =~ m|<\!\-\-[^<>]*\"DATAEND([^\"]*)\"[^<>]*\-\->|i){ $dataend=$1; last; } $tmp_html .= $line; } while(){ $line = $_; &jcode::convert(*line,'euc'); if ($line =~ m|<\!\-\-[^<>]*\"NEWLINK\"[^<>]*\-\->|i){ if ($start > 0){ $s_start = $start - $MaxShowSize; if ($s_start < 0){ $s_start = 0; } $line =~ s|<\!\-\-[^<>]*\"NEWLINK\"[^<>]*\-\->||i; }else{ $line =~ s|<\!\-\-[^<>]*\"NEWLINK\"[^<>]*\-\->| |i; } } if ($line =~ m|<\!\-\-[^<>]*\"OLDLINK\"[^<>]*\-\->|i){ if ($end < $#datas){ $s_start = $end +1; $line =~ s|<\!\-\-[^<>]*\"OLDLINK\"[^<>]*\-\->||i; }else{ $line =~ s|<\!\-\-[^<>]*\"OLDLINK\"[^<>]*\-\->| |i; } } $HTML_3 .= $line; } close(HTML); for($i=$start;$i<=$end;$i++){ last if ($i > $#datas); $data = $datas[$i]; ($num,$name,$text,$sec) = split(/Enc_Sep_Code/,$data); $date = &GetToday($sec); undef($dmy_html); $dmy_html = $tmp_html; $dmy_html =~ s|<\!\-\-[^<>]*\"DATAICON\"[^<>]*\-\->||i; $dmy_html =~ s|<\!\-\-[^<>]*\"DATE\"[^<>]*\-\->|$date|i; $dmy_html =~ s|<\!\-\-[^<>]*\"TEXT\"[^<>]*\-\->|$text|i; $dmy_html =~ s|<\!\-\-[^<>]*\"NAME\"[^<>]*\-\->|$name|i; $HTML_2 .= $dmy_html; } $HTML_2 =~ s/
$//; $HTML = $HTML_1 . $HTML_2 . $HTML_3; $HTML =~ s||$CopyRight|i; &jcode::euc2sjis(*HTML); print "Content-type: text/html; charset=Shift_JIS\n\n"; print $HTML; exit; ################################################# # 今日の日付 ################################################# sub GetToday { my($time) = @_; my($today); my($sec,$min,$hour,$mday,$mon,$year,$wday,$lyear,$syear,$tmon,$weekj,$weekjs,$weeke,$weekes,$monj,$monjs,$mone,$mones); ($sec,$min,$hour,$mday,$mon,$year,$wday,$lyear,$syear,$tmon,$weekj,$weekjs,$weeke,$weekes,$monj,$monjs,$mone,$mones)=&SHIN_CGI::GetTime($time); if($min < 10){ $min = '0' . $min; } if($sec < 10){ $sec = '0' . $sec; } $today=$lyear . '年' . $tmon . '月' . $mday . '日(' . $weekjs . ')' . $hour . ':' . $min . ':' . $sec; return $today; } ################################################# # エラー表示 ################################################# sub error { ($num,$word,$lflag)=@_; if($lflag){ &SHIN_CGI::FileLockLock(0,$LockFile,$lockflag); } $HTML=<<"EOL"; $CgiTItle

Error!!

No:$num

$word

EOL $HTML = jcode($HTML)->sjis; print "Content-type: text/html; charset=Shift_JIS\n\n"; print $HTML; exit; }