Linux 版 (精华区)
发信人: cucme (说你说我), 信区: Linux
标 题: 将订阅的电子杂志自动转贴到BBS上来的源码
发信站: 紫 丁 香 (Sun Aug 22 20:32:57 1999), 转信
发信人: fuse (保险丝), 信区: BBSMan_Dev
标 题: Re: 有这样现成的源码么?
发信站: BBS 水木清华站 (Sat Jul 3 12:09:12 1999)
【 在 Sinob (暑假干什么去?) 的大作中提到: 】
: 我不会做,要不到这儿来问?
: 有没有现成的可以down的说?
嘻嘻,我会作啊~~
Firebird和Maple我都作了的。
估计你们是用Firebird,我贴一篇以前的文章给你
作者 SYSOP (管理员), 信区: sysop
标题 Maillist -> bbs
时间 笑书亭 (Sun Jun 14 10:34:08 1998), 转信
———————————————————————————————————————
目的: 将Mailling list转入bbs
过程: mail
->freebsd@bbs.zju.ml.org
->.forward
->mailpost
->bbspost->board
mailpost改编附后
bbspost也作相应修改,在此略过
作者 SYSOP (管理员), 信区: sysop
标题 Mailpost.pl
时间 笑书亭 (Sun Jun 14 10:41:10 1998), 转信
———————————————————————————————————————
主要修改在parse_header和mail_article
修改mail_article中的path更改post的版。
----------------------------------------------
#!/usr/bin/perl
#
# mailpost
($bbshome) = @ARGV;
if( ! $bbshome ) {
print "Usage: mailpost bbs_home < article_from_user_mail\n";
exit( 0 );
}
$tmpfile = "/tmp/mailpost.$$";
$logfile = "$bbshome/bbslog";
# $mailbox = "$bbshome/mailbox";
$inndhome = "$bbshome/innd";
$poster = "$inndhome/bbspost";
$parsedate = "$inndhome/parsedate";
$denyfile = "$inndhome/email.deny";
$INC[ @INC ] = "$inndhome";
&mail_article();
sub logit
{
if( $logfile ) {
open( FN, ">> $logfile" );
print FN @_;
close( FN );
} else {
print @_;
}
}
sub log_tmpfile
{
open( FN, $tmpfile );
$result = ;
close( FN );
unlink( $tmpfile );
&logit( $result );
}
sub junk_mail
{
local ($msg) = @_;
&logit( "unknown mail $msg\n" );
if( ! $name ) {
$name = "Mail-Daemon";
}
if( ! $subject ) {
$subject = ": $msg";
}
open( FN, "| $poster post $bbshome/boards/junk > $tmpfile" );
print FN "$name\n";
print FN "$subject\n";
print FN @MAIL;
close( FN );
&log_tmpfile();
exit( 0 );
}
sub uudecode
{
local ($begin) = @_;
$line = $MAIL[ $begin + 1 ];
if( substr( $line, 0, 1 ) ne "M" ) {
return;
}
$tmpfile = "/tmp/decode.$$";
open( FN, "| /bin/uudecode" );
print FN "begin 644 $tmpfile\n";
foreach $n ($begin + 1 .. $#MAIL) {
print FN $MAIL[ $n ];
}
close( FN );
$#MAIL = $begin - 1;
open( FN, $tmpfile );
while( ) {
$MAIL[ @MAIL ] = $_;
}
close( FN );
unlink( $tmpfile );
}
sub decode_mail
{
foreach $n (0 .. $#MAIL) {
$line = $MAIL[ $n ];
if( substr( $line, 0, 6 ) eq "begin " ) {
if( $line =~ /^begin \d+ \w/ ) {
&uudecode( $n );
return;
}
}
}
}
sub parse_header
{
$header = 1;
$line = 0;
while( !( $subject ) ) {
if( $line > $#MAIL ) {
&junk_mail( "from $realfrom" );
}
$_ = $MAIL[ $line++ ];
chop;
if( $_ eq "" ) {
$header = "";
}
if( $header ) {
if( index( $_, "From: " ) == 0 ) {
$from = substr( $_, 6, 99 );
($name) = split( "\@", $from );
} elsif( index( $_, "Subject: " ) == 0 ) {
$subject = substr( $_, 9, 99 );
}
}
}
}
$name = $from;
$line = 0;
# if( $header ) {
while( $line <= $#MAIL && $MAIL[ $line ] ne "\n" ) {
$line++;
}
$MAILBODY = $line
# }
}
sub mail_article
{
chdir( $bbshome );
@MAIL = ;
if( $mailbox ) {
open( FN, ">> $mailbox" );
print FN @MAIL;
close( FN );
}
if( $MAIL[ 0 ] =~ /^From (\S+) / ) {
$realfrom = $1;
} else {
&junk_mail( "format (without From)" );
}
if( -f $denyfile ) {
open( FN, $denyfile );
while( ) {
($deny) = split( /\s+/, $_ );
if( $realfrom eq $deny ) {
&junk_mail( "Denyaddr $realfrom" );
}
}
close( FN );
}
&decode_mail();
&parse_header();
$boardpath = "$bbshome/boards/test";
if( ! -d $boardpath ) {
&junk_mail( "board `$board' from $realfrom." );
} else {
# $title =~ s/^[/^[/g;
$title = $subject;
# open( FN, "| $poster post $boardpath > $tmpfile" );
open( FN, "| $poster mail $bbshome/boards/FreeBSD_Question > $tmpfile" );
print FN "$realfrom\n";
print FN "$title\n";
for ($n= $MAILBODY; $n <= $#MAIL; $n++) {
print FN $MAIL[$n];
}
close( FN );
&log_tmpfile();
}
}
这是转FreeBSD-Question Mailinglist 的程序。
我只是拿bbsmail的程序来改。
哪位大侠有空愿意改的可以把它改得好一点。
--
※ 来源:.紫 丁 香 bbs.hit.edu.cn.[FROM: 202.118.243.5]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.722毫秒