Grandt / PHPePub

PHP Classes for dynamically generating EPub files.
http://www.phpclasses.org/package/6115
241 stars 83 forks source link

Downloading Images from an https protocol #22

Open leikxile opened 10 years ago

leikxile commented 10 years ago

Hi Grandt,

I think downloading images from an https protocol is not allowed? i've tried downloading the same image from an https site and an http site. The image is downloaded from the http site, but the image fails to download from the https site.

Grandt commented 10 years ago

I hadn't thought of testing that possibility, I should have.

I'll test. Do you by any chance have a link you know won't work? Or is it all https links?

leikxile commented 10 years ago

All https links I guess, I tried 8 images from google images which has an https protocol and none of those have been downloaded. You may try this link https://lfe-cdn.lytro.com/lfe/b4817688-286e-11e2-9fef-12313904d542/carousel_preview.jpg

Grandt commented 10 years ago

I'm late for work already, so I have to test later. In the mean time, try to replace the curl_setopt lines in getFileContents with these lines:

        curl_setopt($ch, CURLOPT_HEADER         , 0); 
        curl_setopt($ch, CURLOPT_URL            , str_replace(" ","%20",$source));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER , true);
        curl_setopt($ch, CURLOPT_BUFFERSIZE     , 4096);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION , true);     // follow redirects
        curl_setopt($ch, CURLOPT_ENCODING       , "");       // handle all encodings
        curl_setopt($ch, CURLOPT_USERAGENT      , "EPub (Version " . self::VERSION . ") by A. Grandt"); // who am i
        curl_setopt($ch, CURLOPT_AUTOREFERER    , true);     // set referer on redirect
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , 120);      // timeout on connect
        curl_setopt($ch, CURLOPT_TIMEOUT        , 120);      // timeout on response
        curl_setopt($ch, CURLOPT_MAXREDIRS      , 10);       // stop after 10 redirects
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER , false);    // Disabled SSL Cert checks
leikxile commented 10 years ago

Thank you issue has been fixed. BTW i'm working on the processChapterImages function to download background images from other elements. Because it only downloads images from the image tag right? I'll send it to you when its done because I still don't know how to use Github :)

Grandt commented 10 years ago

Right now it only uses the img tag. ePub2 really doens't support the other tags. ePub3 does. It also downloads and adds images defined in the CSS files, though not from "inlined" CSS, or style attributes.

Please send me what you are done. The email is as always php@grandt.com

leikxile commented 10 years ago

Ok thanks for the heads up!