#!/usr/bin/perl print "Content-type: text/html\n\n"; use CGI; $cgi=new CGI; $pagecount=$cgi->param('text'); $page=$cgi->param('page'); $offset=$cgi->param('offset'); $set=$cgi->param('set'); $searchtext=$cgi->param('searchtext'); $class=$cgi->param('class'); $typ=$cgi->param('typ'); $search_typ=$cgi->param('search_typ'); $cpage=$cgi->param('cpage'); $submitgo=$cgi->param('submitgo'); $mode=$cgi->param('mode'); $typ=$cgi->param('typ'); $cat=$typ; $da=time()+1036800; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime($da); $year2=$year+1900; $mon2=$mon+1; $mday2=$mday; $searchtext=~ s/^\s+//; $searchtext=~ s/\s+$//; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); $year=$year+1900; $month=$mon+1; $day=$mday; $month=sprintf("%02d",$month); $day=sprintf("%02d",$day); open(GUEST,"header.htm"); @title=; close(GUEST); print "@title"; print "\n"; print <<"HED"; HED print "
"; $showcat=&showcat("typ.txt"); print $showcat; $select_typ=&selectindex("typ",$typ); print qq(
当前位置: 首页 > 新闻中心 > $cat
); print ""; print ""; print ""; print ""; print "
"; print "
"; print ""; print " "; print "
"; print "
"; $showday=60; $showday=600 if($searchtext); open (data,"data.txt"); @datas=; close(data); $total=@datas; if($typ ne ""){ for ($k=$total-1;$k>-1;$k--){ $row=@datas[$k]; @fields=split(/\|/,$row); if($row=~ m/$searchtext/i&&@fields[0] eq $typ) { $row=@datas[$k]; $y=substr(@fields[3],0,4); $m=substr(@fields[3],4,2); $d=substr(@fields[3],6,2); $newday=$year*12*30+$month*30+$day-($y*12*30+$m*30+$d); #next if($newday>$showday); push(@new,$row); push (@no,$k); } } } else { for ($k=$total-1;$k>-1;$k--){ $row=@datas[$k]; @fields=split(/\|/,$row); if($row=~ m/$searchtext/i) { $row=@datas[$k]; $y=substr(@fields[3],0,4); $m=substr(@fields[3],4,2); $d=substr(@fields[3],6,2); $newday=$year*12*30+$month*30+$day-($y*12*30+$m*30+$d); #next if($newday>$showday); push(@new,$row); push (@no,$k); } } } $total2=@new; if ($page eq "") { $page=1; } $pagecount=12; $pk=5; $offset=($page-1)*$pagecount; if ($offset eq "") { $offset=0; } if ($submitgo eq "go") { if ($cpage<=0) {$cpage=1;} $offset=($cpage-1)*$pagecount; $set=int($cpage/$pk); } $nr=$total2; $pages=int($nr/$pagecount)+1; #$pages变量现在包含所需的页数 if ($nr%$pagecount==0) { $pages=int($nr/$pagecount); } $kk=int(($pages)/$pk); if ($pages%$pk==0){ $kk=int($pages/$pk)-1; } if ($set eq "") { $set=0; } $show=$offset+$pagecount; if($show>$nr) { $show=$nr;} $from=$offset+1; $currpage=$offset/$pagecount+1; if ($pages==0){ $currpage=0; $from=0; } print "
显示".$from."-".$show."条  共有".$nr."条信息  页数:".$currpage."\/".$pages."
"; print "
"; print <<"TAB";

TAB @fields=('cat','title','author','form_data','content'); for ($j=$offset;$j<$offset+$pagecount;$j++){ if ($nr>$j){ $row2=@new[$j]; @field=split(/\|/,$row2); for($i=0;$i<@field;$i++){ $fff=@fields[$i]; $$fff=$field[$i]; } $y=substr($form_data,0,4); $m=substr($form_data,4,2); $d=substr($form_data,6,2); #$newrow=join("\|",@fields); $jjj=$j+1; print <<"HHH";
  • $title ($y年$m月$d日) HHH $jj=$jj+1; if ($jj==3) { $jj=1; } } } $tag=0; if($tag eq 1) { print "
    "; print "按日期浏览 $typ"; $yy=$year-1; print "年"; print ""; print "月"; print "日"; print ""; print "
    "; } ######################## else { print "
    "; print "按期刊浏览 $typ"; $yy=$year-1; print "年"; print ""; #print "期"; open (data,"data.txt"); @datas=; close(data); $total=@datas; $row=@datas[$total-1]; @field=split(/\|/,$row); $max=substr(@field[5],4,2); $intmax=int($max); print "期"; print ""; print "
    "; } ################################ print qq(

  • ); print "
    "; if ($kk>0&&$set!=0) { $j=$i+1; $setnew=$set-1; $ii=$pk*$setnew+1; $newpage=$ii; $newoffset=$pagecount*($ii-1); print "[ 上$pk页 ]"; } #else #{print " [ << ] "; #} if ($set eq $kk||$pages==0) { for ($i=($pk*$set+1);$i<=$pages;$i++) { $newoffset=$pagecount*($i-1); $j=$i+1; $newpage=$i; print " [ 第$i页 ]"; } } else { for ($i=$pk*$set+1;$i<=$pk*$set+$pk;$i++) { $newoffset=$pagecount*($i-1); $j=$i+1; $newpage=$i; print " [ 第$i页 ]"; } } if ($kk>0&&$set<$kk) { $newoffset=$pagecount*($i-1); $j=$i+1; $setnew=$set+1; $newpage=$i; print " [ 下$pk页 ]"; } #else #{print " [ 更多 ] "; #} ## #if ($offset ne 0) #{ #$newoffset=0; #print "[首页]"; #} #else #{print "[首页]"; #} #if ($offset ne 0) #{ #$newoffset=$offset-$pagecount; #print "[上一页]"; #} #else #{print "[上一页]"; #} #if ($offset ne ($pages-1)*$pagecount&&$nr!=0) #{$newoffset=$offset+$pagecount; #print "[下一页]"; #} #else #{print "[下一页]"; #} #if ($offset ne ($pages-1)*$pagecount&&$nr!=0) #{ #$newoffset=($pages-1)*$pagecount; #print "[尾页]"; #} #else #{print "[尾页]"; #} #print "

    当前页面

    "; print "
    "; print ""; print ""; open(GUEST,"footer.htm"); @title=; close(GUEST); print "@title"; sub selectindex { local($select_name,$selected)=@_; open(SE,"$select_name.txt"); @sel=; close(SE); undef $result; foreach $info (@sel) { chop($info); if($info eq $selected) { $result.="\n";} else { $result.="\n";} } return $result; } sub showcat { local($txt)=@_; open(SE,"$txt"); @sel=; close(SE); my $j=8; $result=""; for($i=0;$i<@sel;$i=$i+$j){ $result.=""; for($jj=0;$jj<$j;$jj++) { chop(@sel[$i+$jj]); $result.=""; } $result.=""; } $result.="
    @sel[$i+$jj]
    "; return $result; }