作者SnowWolf.bbs@xeon.tfcis.org (靜夜) 看板: plan
標題[文件] BLog for itoc-maple 設定blog目錄----3
時間動力核心 (Sun, 07 Sep 2003 23:52:00 +0800 (CST)) Updated: 2003/09/07
新增 LocalVars.pm 到~/bin/及~/blog/web/
#!/usr/bin/perl
package LocalVars;
require Exporter;
@ISA = qw/Exporter/;
@EXPORT = qw/
$BBSHOME
$BLOGROOT $BLOGDATA $BLOGCACHE
$BLOGdbname $BLOGdbhost $BLOGdbuser $BLOGdbpasswd $BLOGdefault
/;
$BBSHOME = '/home/bbs';
# BLOG:
# $BLOGDATA 是用來放置 Blog 資料的路徑
# $BLOGCACHE是用來放置 Template compiled 資料的路徑,
# 須為 apache owner 可寫入
$BLOGROOT = '/home/bbs/blog';
$BLOGDATA = '/home/bbs/blog/data';
$BLOGCACHE = '/home/bbs/blog/cache';
$BLOGdbname = 'blog';
$BLOGdbhost = 'localhost';
$BLOGdbuser = 'root';
$BLOGdbpasswd = 'yourpwd';
$BLOGdefault = 'sysop';
1;
新增 BBSFileHeader.pm 到~/bin/及~/blog/web
#!/usr/bin/perl
package BBSFileHeader;
use strict;
use IO::Handle;
use Data::Dumper;
use fields qw/dir fh cache num/;
sub TIEHASH
{
my($class, $dir,$dindex) = @_;
my $self = fields::new($class);
#JCWang:修改 for Maple
open $self->{fh}, "<$dir".$dindex;
return undef if( !$self->{fh} );
$self->{dir} = $dir;
$self->{num} = (-s $dir.$dindex)/256; #JCWang:fix for Maple
return $self;
}
sub FETCH
{
my($self, $k) = @_;
return $self->{dir} if( $k eq 'dir' );
return $self->{num} if($k eq 'num');
my($num, $key) = $k =~ /(.*)\.(.*)/;
my($t, %h);
$num += $self->FETCH('num') if( $num < 0 );
return $self->{cache}{$num}{$key} if( $self->{cache}{$num}{$key} );
# JCWang:有轉過DIR要改這裡的大小
seek($self->{fh}, $num * 256, 0);
$self->{fh}->read($t, 256);
if( $key eq 'isdir' ){
#JCWang:對Maple 3.10修正
return($self->FETCH("$num.xname")=~/^F*/);
}
elsif( $key eq 'content' ){
my $fn = "$self->{dir}".substr($self->FETCH("$num.xname"),7,1)."/".$self->FETCH("$num.xname");
my($c, $fh);
open $fh, "<$fn" || return '';
$fh->read($c, (-s $fn));
return $c;
}
else{
# JCWang:要依照.DIR的格式調整
($h{chrono},$h{xmode},$h{xid},$h{xname},$h{owner},$h{nick},
$h{score},$h{date},$h{title})= unpack('iiiZ32Z80Z49ZZ9Z73',$t);
$self->{cache}{$num}{$_} = $h{$_}
foreach('chrono','xmode', 'xname','owner','nick','date','title');
return $h{$key};
}
}
1;
--
=[﹎:�摃�◣��:﹎ Origin ]|[ �吨O�痐� processor.tfcis.org ]|[�搟說�﹎:]=
=[﹊:�摃�╱��:﹊ Author ]|[ 140.127.38.223 ]|[���插�﹊:]=