isotope / core

Core repository of Isotope eCommerce, an eCommerce extension for Contao Open Source CMS
https://isotopeecommerce.org
136 stars 107 forks source link

problems with pdf and open_basedir #426

Closed ghost closed 11 years ago

ghost commented 11 years ago

Since the update of the RC to the 1.3 stable, there are problems with creating PDF files (billings). The problem is probably with the open_basedir.

Generate PDF files with Contao itself works fine.

it works, when comment out the header-lines in the tcpdf.php (https://github.com/contao/core/issues/840)

Error Message: Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set

Note: My safe_mode is disabled

--- Originally created by ways2web on 2012-04-27 22:51:19 (ID 3124)

ghost commented 11 years ago

update: comment out the header lines doesnt work

--- Originally created by ways2web on 2012-04-28 10:04:47

ghost commented 11 years ago

update 2: the pdf-function works, when the billing-logo is diabled in the shop-config

whats the solutions to fix the problem?

--- Originally created by ways2web on 2012-05-07 22:40:36

ghost commented 11 years ago

Hi,

i got a similar problem. If I try to insert a logo to my bill, I will get this error-message: @TCPDF ERROR: [Image] Unable to get image: URL@

If I go back to my page the shopping basket is empty but no order is visible in the admin panel.

When I don't insert a logo everything works fine.

Contao 2.11.3 and Isotope 1.3.1

Thanks for your help!

--- Originally created by Eluin on 2012-06-05 09:15:27

Toflar commented 11 years ago

Can you please provide the entire path to your invoice logo? E.g. "tl_files/foo/bar/...../logo.png"

--- Originally created by Toflar on 2012-06-05 11:17:41

Toflar commented 11 years ago

I think you might have non-ASCII characters in your image path which will produce an HTML violation because Isotope is not yet handling this case.

Can you try modifying line 837 in IsotopeProductCollection.php (https://github.com/isotope/core/blob/master/system/modules/isotope/IsotopeProductCollection.php#L837) from this:

$objTemplate->logoImage = '<img src="' . $this->Environment->base . '/' . $this->Isotope->Config->invoiceLogo . '" alt="" />';

into this:

$objTemplate->logoImage = '<img src="' . $this->urlEncode($this->Environment->base . '/' . $this->Isotope->Config->invoiceLogo) . '" alt="" />';

And give feedback then, please? :-)

--- Originally created by Toflar on 2012-06-05 11:25:27

ghost commented 11 years ago

i´ve tested this code, too. Unfortunately, no improvement. I dont have any non ASCII characters in my image path.

the complete error message:

Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in .../plugins/tcpdf/tcpdf.php on line 7700 http://www.contao-forge.org/issues/ [internal function]: __error(2, 'curl_setopt(): ...', '/home/client198...', 7700)http://www.contao-forge.org/issues/ .../system/modules/exceptional/Exceptional.php(108): call_user_func('__error', 2, 'curl_setopt(): ...', '/home/client198...', 7700)http://www.contao-forge.org/issues/ [internal function]: Exceptional::handle_error(2, 'curl_setopt(): ...', '/home/client198...', 7700, Array)http://www.contao-forge.org/issues/ .../plugins/tcpdf/tcpdf.php(7700): curl_setopt(Resource idhttp://www.contao-forge.org/issues/ , 52, 1)http://www.contao-forge.org/issues/ ...1/plugins/tcpdf/tcpdf.php(23560): TCPDF->Image('http://www.ways...', 21.379986111111, 15.644444444444, 0, 0, '', '', 'B', false, 300, '', false, false, 0, false, false, true)http://www.contao-forge.org/issues/ .../plugins/tcpdf/tcpdf.php(22965): TCPDF->openHTMLTagHandler(Array, 2, true)http://www.contao-forge.org/issues/ .../plugins/tcpdf/tcpdf.php(6537): TCPDF->writeHTML('a:0:{...', true, false, true, true, '')http://www.contao-forge.org/issues/ .../plugins/tcpdf/tcpdf.php(22897): TCPDF->MultiCell(179.26460277778, 0, 'a:0:{...', false, '', false, 2, '', '', true, 0, true, true, 0, 'T', false)http://www.contao-forge.org/issues/ .../system/modules/isotope/IsotopeProductCollection.php(1002): TCPDF->writeHTML('

if desired: backend- or ftp acccess is possible for the Devs.

--- Originally created by ways2web on 2012-06-05 11:41:43

ghost commented 11 years ago

Hi,

my complete error Path: TCPDF ERROR: [Image] Unable to get image: http://shop.bredex.de/web//tl_files/Style/b_logo.png no ASCII-characters in it...

if I paste this path into the url I got the image I want

I've inserted your code, too - but nothing changed.

--- Originally created by Eluin on 2012-06-05 12:15:01

fredbliss commented 11 years ago

I'd like to point out the following:

"safe_mode had good intentions, but was implemented unevenly. It was deprecated because it caused more problems than it solved, and was not a general security solution. There are better ways to achieve application environment protection now (like FastCGI, suexec, chroots, jails, VPSes...)"

We probably shouldn't be trying to fix support for a deprecated server setting... ;)

More information: http://au.php.net/manual/ro/function.curl-setopt.php#71313

This setting is completely gone as of PHP 5.4.

--- Originally created by fred on 2012-06-05 14:54:34

Toflar commented 11 years ago

Okay, so I'd like to summarize the problem here.

The TCPDF library tries to load images using cURL. The TCPDF library sets CURLOPT_FOLLOWLOCATION to true, which tells the cURL extension to follow every "Location" redirect. This is impossible when safe_mode is enabled or an open_basedir is set which causes the error that has been reported in this ticket.

But:

Isotope cannot change the TCPDF library. Isotope cannot change the safe_mode setting. Isotope cannot change the open_basedir setting.

In short: Isotope can't do anything about that problem and it's thus an issue that is not related to Isotope --> Invalid.

--- Originally created by Toflar on 2012-06-05 16:26:38

Toflar commented 11 years ago

But we can try disabling the image option if the server doesn't support adding an image.

Can you post us the results of this piece of code, please?

var_dump(ini_get('open_basedir'));
var_dump(ini_get('safe_mode'));

--- Originally created by Toflar on 2012-06-05 16:33:42

ghost commented 11 years ago

var_dump(ini_get('safe_mode')) = string(0) ""

var_dump(ini_get('open_basedir')) = its possible, to send the path-info to an mailadresse or pm`?

--- Originally created by ways2web on 2012-06-05 16:45:07

Toflar commented 11 years ago

If there is a string, it means open_basedir is set ;-)

@Andy: we can check for those two values and hide the corresponding fields if one of them is set :-)

--- Originally created by Toflar on 2012-06-05 16:46:49

ghost commented 11 years ago

im not a Dev.. but i think so :) string(186) ......

--- Originally created by ways2web on 2012-06-05 16:48:38

Toflar commented 11 years ago

A workaround is implemented and will be shipped with Isotope 1.3.2: https://github.com/isotope/core/compare/f44860ed42...9c7ee3db43 It will prevent users from adding an image to their invoice if safe_mode is enabled or an open_basedir is set.

If you need this functionality, there are two ways of how you could proceed:

--- Originally created by Toflar on 2012-06-05 16:57:31

ghost commented 11 years ago

Couldn't we find an equivalent to the old code which used the generateImage-function?

$objTemplate->logoImage = str_replace('src="', 'src="' . TL_PATH . '/', $this->generateImage($this->Isotope->Config->invoiceLogo));

Because we have an older Extension which is based on the old Isotope Code..that extension still works like a charm and tcpdf doesn't fail including the image.

--- Originally created by scribble on 2012-07-23 15:19:43

andy commented 11 years ago

Guys, really sorry, but I'm not the Andy you think I am!