KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Cloud Export and allow_url_fopen #1623

Open Kris Reddy opened this topic on on Sep 17, 2020 - 2 comments

Kris Reddy commented on Sep 17, 2020

Hello,

Using Cloud export - all the resources (css, js, images) are not loaded when the pdf is created. For security reasons allow_url_fopen is disabled on the server, so file_get_contents is failing

Is there a way to get this to work while keeping allow_url_fopen disabled?

Please advise,

Kris

Kris Reddy commented on Sep 17, 2020

I may have found a solution is to use curl in this case and update Exporter.php

function url_get_contents ($url) {
      if (function_exists('curl_exec')){
          $conn = curl_init($url);
          curl_setopt($conn, CURLOPT_SSL_VERIFYPEER, true);
          curl_setopt($conn, CURLOPT_FRESH_CONNECT,  true);
          curl_setopt($conn, CURLOPT_RETURNTRANSFER, 1);
          $url_get_contents_data = (curl_exec($conn));
          curl_close($conn);
      }elseif(function_exists('file_get_contents')){
          $url_get_contents_data = file_get_contents($url);
      }elseif(function_exists('fopen') && function_exists('stream_get_contents')){
          $handle = fopen ($url, "r");
          $url_get_contents_data = stream_get_contents($handle);
      }else{
          $url_get_contents_data = false;
      }
  return $url_get_contents_data;
  }
David Winterburn commented on Sep 18, 2020

Hi Kris,

Your solution when allow_url_fopen is disabled is brilliant. Please replace all occurences of file_get_contents in Exporter.php with a curl get file function. Let us know if there's any issue with this. Thanks!

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None