|
|
 |
Today's
Tip
จะให้เวบบอร์ดแสดงกระทู้ล่าสุดที่หน้าแรก
ทำอย่างไร ?
- สำหรับเวบบอร์ดเวอร์ชั่นเก่า
ไม่ใช่ 2.3b ให้นำแทกต่อไปนี้ ไปเก็บไว้ที่ไฟฟล์ viewboard.pl และ save
จากนั้น upload ลงไป ที่ cgi-bin chmod เป็น 755 จากนั้นให้นำแทก <!--#exec
cgi="/cgi-bin/viewboard.pl"--> นี้ไปไว้หน้าแรก หรือหน้าที่คุณต้องการให้แสดงกระทู้ล่าสุด
และหน้านั้น จะต้อง save เป็นไฟลล์ .shtml เท่านั้น เนื่องจากใช้ความสามารถของ
ssi เข้ามาช่วย
#!/usr/bin/perl
print "Content-type:text/html\n\n";
$limitpage=10; #
กำหนดว่าต้องการให้แสดงกี่กระทู้
open( MSGFILE , 'webboard/topic.dat' );
@msgdata = <MSGFILE>;
close( MSGFILE );
@msgdata=reverse( @msgdata );
$size = @msgdata;
$numtopic = $size + 1;
for($i=0; $i<$limitpage; $i++){ $numtopic--; print "$msgdata[$i]";
&checknum; }
########################
sub checknum{
if ($numtopic< 10) {$numtopic = "0000$numtopic";}
elsif ($numtopic < 100){$numtopic = "000$numtopic";}
elsif ($numtopic < 1000){$numtopic = "00$numtopic";}
else {$numtopic = "0$numtopic";}
$BASEDIR="webboard";
$fname = "$numtopic.dat";
$FILE_NAME="$BASEDIR/$fname";
open (NUMMSG,"$FILE_NAME") ;
$nummsg = <NUMMSG>;
close(NUMMSG);
if ($nummsg ne ""){ print "\($nummsg\)";
}
} |
- เอาล่ะครับ
คราวนี้มาถึง 2.3b มั่ง สำหรับเวบบอร์ดเวอร์ชั่น่ 2.3b ให้นำแทกต่อไปนี้
ไปเก็บไว้ที่ไฟฟล์ viewboard.pl และ save จากนั้น upload ลงไป ที่ cgi-bin
chmod เป็น 755 จากนั้นให้นำแทก <!--#exec cgi="/cgi-bin/viewboard.pl"-->
นี้ไปไว้หน้าแรก หรือหน้าที่คุณต้องการให้แสดงกระทู้ล่าสุด และหน้านั้น
จะต้อง save เป็นไฟลล์ .shtml เท่านั้น เนื่องจากใช้ความสามารถของ ssi
เข้ามาช่วย
#!/usr/bin/perl
require "config.pl";
print "Content-type:text/html\n\n";
$limitview=10; #
กำหนดว่าต้องการให้แสดงกี่กระทู้
open( MSGFILE ,"$Topic_Dir/topic.dat");
@msgdata = <MSGFILE>;
close( MSGFILE );
@msgdata=reverse( @msgdata );
$size = @msgdata;
$numtopic = $size + 1;
for($i=0; $i<$limitview; $i++){ $numtopic--; print "$msgdata[$i]";
&checknum; }
########################
sub checknum{
if ($numtopic< 10) {$numtopic = "0000$numtopic";}
elsif ($numtopic < 100){$numtopic = "000$numtopic";}
elsif ($numtopic < 1000){$numtopic = "00$numtopic";}
else {$numtopic = "0$numtopic";}
$FNAME = "$Topic_Dir/$numtopic.dat";
$FILE_NAME="$FNAME";
open (NUMMSG,"$FILE_NAME") ;
$nummsg = <NUMMSG>;
close(NUMMSG);
if ($nummsg ne ""){ print "\($nummsg\)";
}
} |
ตัวอย่าง
[an error occurred while processing this directive]
|