#!/usr/bin/perl print "Content-type: text/html"; require '../get.cgi'; &read_cgi; $uuser=$FORM{'username'}; $password=$FORM{'password'}; $pagecount=$FORM{'text'}; $offset=$FORM{'offset'}; $set=$FORM{'set'}; $searchtext=$FORM{'searchtext'}; $class=$FORM{'class'}; $typ=$FORM{'typ'}; $search_typ=$FORM{'search_typ'}; $cpage=$FORM{'cpage'}; $submitgo=$FORM{'submitgo'}; $mode=$FORM{'mode'}; $da=time()+1036800; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime($da); $year2=$year+1900; $mon2=$mon+1; $mday2=$mday; require '../cookie.lib'; if(&GetCookies('user')){ #if($Cookies{'user'} ne ""){ $uuser=$Cookies{'user'}; } if(&GetCookies('pass')){ #if($Cookies{'pass'} ne ""){ $password=$Cookies{'pass'}; } if ($uuser eq "" or $password eq "") { print "Location: checkuser.cgi\n\n"; } open (FD,"adm.dat"); @info2=; close(FD); @info=split(/:/,@info2[0]); if ($uuser ne @info[0] or $password ne @info[1]){ print "Location: checkuser.cgi?err=错误的用户名和密码!\n\n"; } if (!&GetCookies('user')){ &SetCookies('user',$uuser); &SetCookies('pass',$password); } print "\n"; open(GUEST,"./header.htm"); @title=; close(GUEST); print "@title"; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); $year=$year+1900; $month=$mon+1; $day=$mday; print <<"HED"; Admin HED print ""; print "
"; print "
"; $showcat=&showcat("../typ.txt"); print $showcat; print "
"; $select_typ=&selectindex("../typ",$typ); print ""; print ""; print ""; print "
"; print "
"; print ""; print " "; print "
Today is $year-$month-$day
"; $searchtext=$FORM{'searchtext'}; print "
"; 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]; 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]; push(@new,$row); push (@no,$k); } } } $total2=@new; if ($offset eq "") { $offset=0; } $pagecount=10; $pk=5; 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 "
发布信息 帐号修改 类别修改 $nbsp显示".$from."-".$show."条  共有".$nr."条记录  页数:".$currpage."\/".$pages."
"; print "
"; print ""; print ""; #for ($j=0;$j<$total2;$j++){ print ""; $k=1; for ($j=$offset;$j<$offset+$pagecount;$j++){ if ($nr>$j){ $row2=@new[$j]; @fields=split(/\|/,$row2); $newrow=join(/\|/,@fields); $floor=@fields[6]; if ($jj==1) { print ""; } else { print "";} print ""; #print ""; #print ""; print ""; print ""; $jj=$jj+1; if ($jj==3) { $jj=1; } $k++; push(@idall,@no[$j]); } } print "
新闻名称 类别
"; print ""; print "@fields[1]"; print ""; #print "@fields[1]"; #print ""; #print "@fields[2]"; #print ""; print "@fields[0]"; print "
"; print "全部选中"; print ""; print ""; print "
"; if ($kk>0&&$set!=0) { $j=$i+1; $setnew=$set-1; $ii=$pk*$setnew+1; $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; print " [ 第$i页 ]"; } } else { for ($i=$pk*$set+1;$i<=$pk*$set+$pk;$i++) { $newoffset=$pagecount*($i-1); $j=$i+1; print " [ 第$i页 ]"; } } if ($kk>0&&$set<$kk) { $newoffset=$pagecount*($i-1); $j=$i+1; $setnew=$set+1; 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=@sel; $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; }