Word Press Importer – Remote server did not respond

I had this issue when importing media from a site protected with an SSL certificate to a development site on the same server.

After a lot of googling and adding extra (useful) debugging code to wordpress-importer.php I found that the issue was that cURL was failing to verify the certificate (possibly due to it connecting locally).

After a lot of searching I failed to find a way to temporarily prevent the importer checking the certificate, but with a bit of persistence I found that adding the following two lines to the file wp-content/plugins/wordpress-importer.php

Find the lines :

function fetch_remote_file( $url, $post ) {
add_filter( 'http_request_host_is_external', '__return_true' );

for me they were found starting on line 982

Add the following below the two lines

add_filter( 'https_local_ssl_verify', '__return_false' );
add_filter( 'https_ssl_verify', '__return_false' );

and re-run the import.

I doubt both are necessary, but adding both will cover more SSL eventualities.

Remember to remove them after your import to reduce the likelihood of the settings being exploited.

Arduino Bootloader Device signature = 0x1e150f

This is really just a note for anyone with a similar problem I was having during my development of the Holocom electronics.

When trying to burn the Arduino bootloader to the raw ATMEGA 328p device at 3.3v with using an internal clock, I kept getting an error :

avrdude: Device signature = 0x1e150f
avrdude: Expected signature for ATmega328P is 1E 95 0F
 Double check chip, or use -F to override this check.

Searches of the internet revealed nothing but a single other post that mentioned the chip could be broken.
I tried to burn the bootloader to 6 or 7 of the chips I had with the exact same result, so if felt like the chips weren’t the issue.

In the end I found the issue to be that the default bitclock speed was too fast causing a weird read error.

By adding -B5 to the avrdude command, the chip was correctly read and the bootloader burned.

I hope this helps someone.

FPDI php useTemplate and formatting on every page

This was something I was searching long and hard for whilst writing a billing system I was working on.

I thought I’d share this here just in case anyone else finds it useful.

Using the excellent FPDI php template library to write php generated text onto a PDF template, I needed to have the generated text span over a few pages. I struggled to get the template to appear on each new page, and when I did I need to add a margin to the top of the document to prevent overwriting the PDF template header.

In the end the only way I could do it was by extending the FPDI class to run my own code in the header of all new pages

class MYPDF extends FPDI {
    var $_tplIdx;  				// Store the template id of the imported page

    function Header() { 			// Include a background template for every page
        if (is_null($this->_tplIdx)) {
            $this->_tplIdx = $this->importPage(1);
        }
        $this->useTemplate($this->_tplIdx);
        $this->SetY(58);                        // Add a sufficent gap at the top of the page
    } 

    function Footer() {}
}