Commit 84a63fae authored by Carsten  Rose's avatar Carsten Rose
Browse files

Download/Excel: Check if 'allow_url_fopen' is set. Necessary for Excel export.

parent e753f8cf
Pipeline #752 passed with stage
in 2 minutes and 3 seconds
......@@ -257,6 +257,7 @@ const ERROR_DOWNLOAD_NOTHING_TO_DO = 1702;
const ERROR_DOWNLOAD_UNEXPECTED_MIME_TYPE = 1703;
const ERROR_DOWNLOAD_UNEXPECTED_NUMBER_OF_SOURCES = 1704;
const ERROR_DOWNLOAD_FILE_NOT_READABLE = 1705;
const ERROR_DOWNLOAD_FOPEN_BLOCKED = 1706;
// Excel
const ERROR_EXCEL_POSITION_ARGUMENT_EMPTY = 1800;
......
......@@ -8,6 +8,8 @@
namespace qfq;
require_once(__DIR__ . '/../exceptions/UserReportException.php');
/**
* Class DownloadPage
......@@ -22,6 +24,7 @@ class DownloadPage {
* @param string $page - Full URL like 'https://example.com' or T3 specific like 'export&s=badcaffee1234'
* @param string $baseUrl - baserUrl from Configfile
* @return bool|string
* @throws UserReportException
*/
public static function getContent($page, $baseUrl) {
......@@ -37,6 +40,11 @@ class DownloadPage {
$page = $baseUrl . $page;
}
// Check php.ini
if(ini_get('allow_url_fopen')!='1'){
throw new UserReportException("php.ini: 'allow_url_fopen' is off and needs to be open to get '$page''", ERROR_DOWNLOAD_FOPEN_BLOCKED);
}
// Download page
$ctx = array(
"ssl" => array(
......
......@@ -211,13 +211,14 @@ class Download {
* @param string $element - U:id=myExport&r=12, u:http://www.nzz.ch/issue?nr=21, f:fileadmin/sample.pdf
*
* @param string $downloadMode - DOWNLOAD_MODE_EXCEL | ....
* @param string $tmpData - With $downloadMod=DOWNLOAD_MODE_EXCEL, this contains the rendered code from the give T3 page.
* @param string $rcData - With $downloadMode=DOWNLOAD_MODE_EXCEL, this contains the rendered code from the given T3 page.
* @return string filename - already ready or fresh exported. Fresh exported needs to be deleted later.
* @throws CodeException
* @throws DownloadException
* @throws UserFormException
* @throws UserReportException
*/
private function getElement($element, $downloadMode, &$tmpData) {
private function getElement($element, $downloadMode, &$rcData) {
$filename = '';
$rcArgs = array();
......@@ -245,7 +246,7 @@ class Download {
}
$baseUrl = $this->store->getVar(SYSTEM_BASE_URL, STORE_SYSTEM);
$tmpData = DownloadPage::getContent($urlParamString, $baseUrl);
$rcData = DownloadPage::getContent($urlParamString, $baseUrl);
} else {
$filename = $this->html2pdf->page2pdf($token, $value);
}
......@@ -316,10 +317,12 @@ class Download {
* @param string $outputMode OUTPUT_MODE_DIRECT | OUTPUT_MODE_FILE
* @return string Filename of the generated file. The filename only points to a real existing filename with $outputMode=OUTPUT_MODE_FILE
* @throws CodeException
* @throws DbException
* @throws DownloadException
* @throws UserFormException
* @throws UserReportException
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
private function doElements(array $vars, $outputMode) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment