Plugin Directory

Changeset 421867


Ignore:
Timestamp:
08/10/2011 09:14:06 PM (14 years ago)
Author:
Orson Teodoro
Message:

increase script execution time and fix attachments

Location:
forumconverter
Files:
13 added
2 edited

Legend:

Unmodified
Added
Removed
  • forumconverter/trunk/PhpbbToBbpress.php

    r421376 r421867  
    3636            $this->processAttachments = true;
    3737            $this->forumLoginSrc = $forumSrc;
     38
     39            //timeouts - this may require adjusting based on amount of posts that need to be converted
     40            set_time_limit(3600);
    3841        }
    3942       
     
    502505           
    503506            $fdb = new wpdb($this->forumLoginSrc->username, $this->forumLoginSrc->password, $this->forumLoginSrc->databasename, $this->forumLoginSrc->hostname);
    504             //$fdb->show_errors();
    505             //$wpdb->show_errors();
     507            //$fdb->query("set session wait_timeout=1");
     508            $fdb->show_errors();
     509            $wpdb->show_errors();
    506510
    507511            //trash existing topics
     
    619623                    if ($this->processAttachments)
    620624                    {
     625                        //create a folder to dump the attachments
     626                        $dir = wp_upload_dir();
     627                        if (is_dir ($dir['basedir'].DIRECTORY_SEPARATOR.'bbpress'.DIRECTORY_SEPARATOR.$insertId) == FALSE)
     628                            mkdir($dir['basedir'].DIRECTORY_SEPARATOR.'bbpress'.DIRECTORY_SEPARATOR.$insertId,0644,true);
     629                       
    621630                        if (strpos($postText, '[attachment=') !== FALSE)
    622631                        {
     
    637646                                    if ($data->post_attachment)
    638647                                    {
    639                                         //create a folder to dump the attachments
    640                                         $dir = wp_upload_dir();
    641                                         if (is_dir ($dir['basedir'].DIRECTORY_SEPARATOR.'bbpress'.DIRECTORY_SEPARATOR.$insertId) == FALSE)
    642                                             mkdir($dir['basedir'].DIRECTORY_SEPARATOR.'bbpress'.DIRECTORY_SEPARATOR.$insertId,0644,true);
    643                                        
    644648                                        //insert as attachment
    645649                                        $attachment = $fdb->get_row('SELECT * FROM '.$this->forumLoginSrc->prefix.'attachments WHERE post_msg_id='.$data->post_id.' AND real_filename="'.$filename.'"');
     
    655659                                        $status = copy($this->forumLoginSrc->uploadpath.DIRECTORY_SEPARATOR.$attachment->physical_filename, $dir['basedir'].DIRECTORY_SEPARATOR.'bbpress'.DIRECTORY_SEPARATOR.$insertId.DIRECTORY_SEPARATOR.$filename);
    656660                                        if ($status == FALSE)
    657                                             $this->fc_echo('failed to copy file');
     661                                            $this->fc_echo('failed to copy file<br/>');
    658662
    659663                                        $attachmenturl = content_url().'/uploads/bbpress/'.$insertId.'/'.$filename;
     
    729733                        else
    730734                        {
     735
    731736                            //lookup attachment
    732                             $attachments = $fdb->get_results('SELECT * FROM '.$this->forumLoginSrc->prefix.'fc_attachments WHERE post_msg_id='.$data->post_id);
     737                            $attachments = $fdb->get_results('SELECT * FROM '.$this->forumLoginSrc->prefix.'attachments WHERE post_msg_id='.$data->post_id);
    733738                            if ($attachments === false)
    734                                 $this->fc_die('failed to check attachment'.$wpdb->last_error);
     739                                $this->fc_die('failed to check attachment'.$fdb->last_error);
    735740                            if ($wpdb->num_rows > 0)
    736741                            {
     
    738743                                foreach ($attachments as $attachment)
    739744                                {
    740                                     //$this->fc_echo('adding post/reply attachment<br/>');
     745                                    $this->fc_echo('adding post/reply attachment<br/>');
    741746
    742747                                    //add download link
    743748                                    if ($data->post_attachment)
    744749                                    {
    745                                         //create a folder to dump the attachments
    746                                         $dir = wp_upload_dir();
    747                                         if (is_dir ($dir['basedir'].DIRECTORY_SEPARATOR.'bbpress'.DIRECTORY_SEPARATOR.$insertId) == FALSE)
    748                                             mkdir($dir['basedir'].DIRECTORY_SEPARATOR.'bbpress'.DIRECTORY_SEPARATOR.$insertId,0644,true);
    749                                        
    750                                         //insert as attachment
    751                                         $attachment = $fdb->get_row('SELECT * FROM '.$this->forumLoginSrc->prefix.'attachments WHERE post_msg_id='.$data->post_id.' AND real_filename="'.$filename.'"');
    752 
    753750                                        //try to maintain the original filename name without any extra fancy script
    754751                                        //copy attachment to wordpress uploads folder
     
    761758                                        $status = copy($this->forumLoginSrc->uploadpath.DIRECTORY_SEPARATOR.$attachment->physical_filename, $dir['basedir'].DIRECTORY_SEPARATOR.'bbpress'.DIRECTORY_SEPARATOR.$insertId.DIRECTORY_SEPARATOR.$filename);
    762759                                        if ($status == FALSE)
    763                                             $this->fc_echo('failed to copy file');
     760                                            $this->fc_echo('failed to copy file<br/>');
    764761
    765762                                        $attachmenturl = content_url().'/uploads/bbpress/'.$insertId.'/'.$filename;
     
    820817                                        );
    821818
    822                                         $postText .= '<p>Download <a href="'.$attachmenturl.'">'.$attachment->real_filename.'</a>. (Caution: This file may not be virus scanned.)</p>';
     819                                        $postText .= '<p>Download <a href="'.$attachmenturl.'">'.$attachment->real_filename.'</a>. (1Caution: This file may not be virus scanned.)</p>';
    823820                                    }
    824821                                }
  • forumconverter/trunk/readme.txt

    r421376 r421867  
    119119
    120120== Upgrade Notice ==
     121= 1.05 =
     122None
     123
    121124= 1.04 =
    122125None
     
    132135
    133136== Changelog ==
     137= 1.05 =
     138* Bugfix: increase execution time to 1 hour for those who don't have it in their php.ini
     139* Bugfix: fix attachments for those not attached inline
     140
    134141= 1.04 =
    135142* Remove end of file whitespace to get rid of plugin activation warnings.
Note: See TracChangeset for help on using the changeset viewer.