[Iamb-dev] CVS: iamb-dev/scripts process.pl,NONE,1.1 set_threadid.pl,NONE,1.1
Status: Beta
Brought to you by:
rbowen
From: Rich B. <rb...@us...> - 2001-01-31 00:52:23
|
Update of /cvsroot/iamb/iamb-dev/scripts In directory usw-pr-cvs1:/tmp/cvs-serv8425/scripts Added Files: process.pl set_threadid.pl Log Message: Moved non-cgi stuff into scripts subdirectory. Might do something with these some day, or we may just blow them away later on. --- NEW FILE --- #!/usr/bin/perl use DBI; use Community::IAMB; use strict; my $iamb = new Community::IAMB; my $dbh = DBI->connect($iamb->database, $iamb->DBIlogin, $iamb->DBIpassword); my (@info, $line, $subject, $from, $body); @info = <STDIN>; $line = "X"; # Get the headers while ($line =~ /\w/) { $line = shift @info; if ($line =~ /^Subject:/) { ($subject = $line) =~ s/^Subject:\s+//; } # Endif elsif ($line =~ /^From:/) { ($from = $line) =~ s/^From:\s+//; } # Endif } # Wend # Get the body $body = join "", @info; # Put it in the database my $id = GetID($dbh, 'article','ID'); my $time = time; my $sth = $dbh->prepare("insert into article (ID, title, body, date_time, author, email, parent) values ($id, '$subject','$body',$time, '$from','$from',0) "); $sth->execute; ####### =head1 NAME process.pl =head1 DESCRIPTION This was an early attempt to make a mail->IAMB gateway. It even worked pretty well. I left it out because I thought - and still think - that a mail->IAMB gateway allows people to throw things at the board without actually participating, which is rather contrary to the whole notion of Community. But I've left the code in here because I expect that I'll be called upon to write it again some time, and I'd rather not have to write it from scratch. =cut --- NEW FILE --- #!/usr/bin/perl; use Community::IAMB; use strict; my $iamb = new Community::IAMB; # Need to ditch all thread IDs for this to work my $sth = $iamb->dbh->prepare("update " . $iamb->articles . " set threadID=-1"); $sth->execute; my (@root, $id); $sth = $iamb->dbh->prepare("select ID from " . $iamb->articles . " where parent=0"); $sth->execute; $sth->bind_columns (undef, \$id); push @root, $id while $sth->fetch; foreach $id (@root) { print "Setting thread ids on thread $id\n"; my @kids = $iamb->Decendants($iamb->dbh, $id); my $kids = join ', ', @kids; print "$kids\n"; $sth = $iamb->dbh->prepare("update " . $iamb->articles . " set threadID = $id where ID in ($kids) "); $sth->execute; } |