#!/usr/bin/perl
require 'parse.pl';
&parse_form;
print "Content-type:text/html\n\n";
$filename = ".";
opendir(flist,"$filename");
@allf = readdir flist;
closedir(flist);
@allf = reverse sort @allf;
foreach $r (@allf) { if (length($r) eq "17") { push @ar,$r; } }
$tot = @ar;
if (!$v{'total'}) { $v{'total'}=10; }
if (!$v{'page'}) { $v{'page'}=1; }
$begin = (($v{'page'} - 1) * $v{'total'}) + 1;
$end = $v{'page'} * $v{'total'};
$rest = $tot % $v{'total'};
if ($end > $tot) { $end=$end - $v{'total'} + $rest; }
$maxpage = (($tot - $rest) / $v{'total'}) + 1;
if ($rest eq 0) { $maxpage--; }
print'<ul><form action=boardlist.pl>';
print '<select name=total>';
print '<option value=10 checked>10 /page';
print '<option value=25>25 /page';
print '<option value=50>50 /page';
print '<option value=100>100 /page';
print '</select><input type=submit value=go> Page [ ';
for $i (1..$maxpage-1){
print "<a href=boardlist.pl?total=$v{'total'}&page=$i>$i</a> - ";
}
print "<a href=boardlist.pl?total=$v{'total'}&page=$maxpage>$maxpage</a> ] $tot</form>";
for $i ($begin..$end) {
$j=$i-1;
open(myfile,$ar[$j]);
@ra = <myfile>;
close(myfile);
$ra[0] =~ s/</</g;
$ra[0] =~ s/>/>/g;
@rec = split (/:/,$ra[0]);
if (substr($ar[$j],10,3) eq "999") {
print "$i. ";
} else {
print "$i. >> ";
}
print "<a href=boardread.pl?id=$rec[0]>$rec[1]</a> ";
print "<font color=#808080>$rec[2]</font><br>";
}
print'</ul>';
จำนวน : 47 บรรทัด