New script: fudbox.php [message #19835] |
Thu, 09 September 2004 15:04 |
Squeebee
Messages: 110 Registered: November 2003
Karma: 0
|
Senior Member |
|
|
Hi all;
While adding a new mailing list mirror to my forums, I noticed that the list provider had a full archive of the list messages in mbox format. As a result I whipped up this little script to make it easy to import mbox messages into FUDforum.
The script is attached, and I'll include the script contents inline for your perusal.
<?php #!/usr/local/php/bin/php -q
<?php
/******************************************************************************
* fudBOX Version 0.1 - Copyright 2003 Mike Hillyer
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Code by Mike Hillyer (mike(at)openwin(dot)org) *MAINTAINER*
*
* SAMPLE USAGE: php -q fudbox.php
*
******************************************************************************/
/* THIS SCRIPT REQUIRES THE MBOX PEAR MODULE TO OPERATE */
define("MBOX_FILE", "/path/to/somearchive.mbox"); //THE MBOX FILE YOU WISH TO LOAD
define("SCRIPT_LOCATION", "/path/to/maillist.php");
define("MBOXPHP_LOCATION", "/usr/local/php/lib/php/Mail/mbox.php"); //THE MBOX PEAR MODULE
define("FORUM_ID", 5); //THE FORUM YOU WISH TO INPORT INTO
//DO NOT MAKE CHANGES BELOW THIS LINE!
require_once(MBOXPHP_LOCATION);
$mbox = new Mail_Mbox();
$mid = $mbox->open(MBOX_FILE);
for ($x = 0; $x < $mbox->size($mid); $x++)
{
$thisMessage = $mbox->get($mid,$x);
pipe_email($thisMessage, FORUM_ID);
}
exit();
function pipe_email($message, $scriptNum)
{
if(!$PIPE = popen(SCRIPT_LOCATION . " " . $scriptNum, "w"))
{
return false;
}
if (!fwrite($PIPE, $message))
{
pclose($PIPE);
return false;
}
pclose($PIPE);
return true;
}
?>
-
Attachment: fudbox.php
(Size: 1.98KB, Downloaded 1509 times)
|
|
|