FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » New script: fudbox.php
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
New script: fudbox.php [message #19835] Thu, 09 September 2004 11:04
Squeebee is currently offline  Squeebee   Canada
Messages: 110
Registered: November 2003
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
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 973 times)
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: New Version of popfud.php
Next Topic: adding a 'simple' thing to FUD
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Oct 17 13:07:05 EDT 2017

Total time taken to generate the page: 0.00609 seconds