View Single Post
  #178  
Old 12-03-2005, 10:01 PM
moftary moftary is offline
 
Join Date: Sep 2005
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by frakman
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:
class pop 
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
PHP Code:
        return -2
Add
PHP Code:
    }    //MBOX 
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");

Or you could simply use /var/qmail/bin/maildir2mbox
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01312 seconds
  • Memory Usage 1,874KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (15)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete