boardlist.pl
#!/usr/local/bin/perl
# ปรับปรุง 28 กรกฎาคม 2545
# Version สำหรับ lovelampang.com และเปิดให้คนลำปางนำไปใช้ได้
############################################################
# เพื่อนำ 10 กะทู้ล่าสุดไปแสดง
# <iframe src=http://www.thaiall.com/lovelampang/board/board10.pl height="205" width="500" marginwidth="0" marginheight="0" vspace="0" hspace="0" frameborder="0"></iframe>
# เพิ่มข่าว หรือแสดงความเห็น
# <a href=http://www.lovelampang.com/board>http://www.lovelampang.com/board</a>
############################################################
require 'parse.pl';
&parse_form;
print "Content-type:text/html\n\n";
&header;
print "<table width=100% bgcolor=#808080><td align=center><font color=white>";
# $filename = ".";
$filename = join "",$v{'r'},"/.";
opendir(flist,"$filename");
@allf = readdir flist;
closedir(flist);
if (!$v{'sort'} or $v{'sort'} eq "id") {
$v{'sort'}="id";
@allf = reverse sort @allf;
} else {
$v{'sort'}="time";
@allf = reverse @allf;
}
foreach $r (@allf) { if (length($r) eq "17") { push @ar,$r; } }
$tot = @ar;
if (!$v{'total'}) { $v{'total'}=20; }
if (!$v{'show'}) { $v{'show'}="d"; }
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'<form action=boardlist.pl>';
#
print "<input type=checkbox name=fline ";
if (length($v{'fline'}) > 0) { print "checked"; }
print ">บรรทัดแรก ";
#
print '<select name=r>';
print '<!--#include virtual="parse.pl"-->';
print '</select>';
#
print '<select name=sort>';
print '<option value=id ';
if ($v{'sort'} eq "id") {print 'selected';}
print '>เรียงตามเลขกะทู้<option value=time ';
if ($v{'sort'} eq "time") {print 'selected';}
print '>เรียงตามเวลา</select>';
#
print '<select name=show>';
print '<option value=d ';
if ($v{'show'} eq "d") {print 'selected';}
print '>แสดงทุกกะทู้<option value=h ';
if ($v{'show'} eq "h") {print 'selected';}
print '>แสดงหัวข้อกะทู้</select>';
#
print '<select name=total>';
print '<option value=20 ';
if ($v{'total'} eq 20) {print 'selected';}
print '>20 /หน้า<option value=30 ';
if ($v{'total'} eq 30) {print 'selected';}
print '>30 /หน้า<option value=50 ';
if ($v{'total'} eq 50) {print 'selected';}
print '>50 /หน้า</select><input type=submit value="Update"><br>เลือกหน้า [ ';
for $i (1..$maxpage){
if ($v{'page'} eq $i) {
print "<input type=button value=[$i]>";
} else {
print "<input type=submit value=$i name=page>";
}
}
# print "<input type=submit value=$maxpage name=page>
print " ] จำนวนกะทู้ทั้งหมด: $tot";
print "</td></table></form><center>";
print '<table width=95% bgcolor=black cellpadding=1 cellspacing=1 border=0>';
print '<td bgcolor=white background=bgstar.gif><ul>';
for $i ($begin..$end) {
$j=$i-1;
open(myfile,"$v{'r'}/$ar[$j]");
@ra = <myfile>;
close(myfile);
$ra[0] =~ s/</</g;
$ra[0] =~ s/>/>/g;
@rec = split (/:/,$ra[0]);
if ($v{'show'} eq "d" or substr($ar[$j],10,3) eq "999") {
@stat = stat "$v{'r'}/$ar[$j]";
if (substr($ar[$j],10,3) eq "999") {
print "<img src=f.gif> ";
} else {
print "<img src=l.gif> ";
}
@t = localtime($stat[9]+50000);
print "<a href=boardread.pl?id=$rec[0]&r=$v{'r'}>$rec[1]</a>";
print "<! a href=boarddel.pl?passwd=thaia&id=$rec[0]&r=$v{'r'}>.</a> ";
print "<a href=boardview.pl?id=$rec[0]&r=$v{'r'}>#</a> ";
print "$rec[2] ";
print "$t[3]/",$t[4]+1,"/",$t[5]+2443,"|$stat[7]";
$firstline = substr($ra[2],0,80);
if (length($v{'fline'}) > 0) { print "<dd>:: $firstline .."; }
print "<br>";
}
}
print'</ul></td></table>';
&footer; |