Okay, this is only a quick hack so I could import my MBOX file (extracted from Yahoo Goops) direct. (most because my server is running qmail).
I hope this gets included in standard. (does not require much polish)
First, install mbox.php from PEAR into the
includes directory.
I don't think we are to post complete code - if I'm wong on that please tell me - so here are just the changes to
pop.php:
Before
PHP Code:
require_once('./includes/mbox.php');
After
PHP Code:
function prepare_connection( $user, $pass, $host = "127.0.0.1", $port = "110" )
PHP Code:
if (! (strpos($host, '/')===false) ) { //mbox
$this->mbox = true; //mbox
$this->_mbox = new Mail_Mbox(); //mbox
} else { //mbox
Replace
PHP Code:
if ($host == '') {
return 0;
}
$this->port = $port;
$this->username = $user;
$this->password = $pass;
$this->host = $host;
With
PHP Code:
$this->password = $pass;
} //mbox
if ($host == '') { //mbox
return 0; //mbox
} //mbox
$this->host = $host; //mbox
after
PHP Code:
function connect()
{
Add
PHP Code:
//MBOX-START
if ($this->mbox) {
$this->pop_connect = $this->_mbox->open( $this->host );
if (!$this->pop_connect) {
echo "ERROR OPENING MBOX FILE\r\n";
return -1;
}
} else {
//MBOX-END
After
Add
Replace this block
PHP Code:
function howmany()
{
return $this->_howmany();
}
with
PHP Code:
function _howmany()
{
if ($this->mbox) { //MBOX
return $this->_mbox->size( $this->pop_connect )-1; //MBOX
} else { //MBOX
$this->_write("STAT");
$results = $this->_gets();
$this->log .= $results;
list ($results, $messages, $bytes) = split(' ', $results);
return $messages;
} //MBOX
}
Lastly replace
PHP Code:
function delete_mail ( $id )
{
$this->_write("DELE $id");
$results = $this->_gets();
}
WITH
PHP Code:
function delete_mail ( $id )
{
if ( !$this->mbox ) { //MBOX
$this->_write("DELE $id");
$results = $this->_gets();
} //MBOX
}
When testing this I imported 10585 messages in 5m20s (not really a benchmark without doing it via POP3 as a comparison however surely the overheads are a lot less with this system)
How does this work? Put a file reference in the host box eg
/usr/local/apache2/www/mbox_locost_oz
where mbox_locost_oz is the MBOX archive. If you are on a Windows server the code would need to be changed (it looks for "/" which will not appear in a host name - would need to be changed to "\")
It will not delete messages from the archive. I do not see this as a bad thing for my purposes (ie dump in starting messages)
I also in my testing dug up a problem when there are no posts at all (I think its a NULL issue) I get this error:
Invalid SQL:
Code:
UPDATE vb_nntp_settings
SET value = WHERE varname = 'last_postid';
And this comes (in gateway.php)from
PHP Code:
$get_max_postid = $db->query_first("
SELECT MAX(postid) as postid FROM " . TABLE_PREFIX . "post
");
ALSO somebody was complaining about lack of HTML formatting in Firefox:
in gateway.php change this line:
header("Content-Type: text/plain");
TO
header("Content-Type: text/html");