Commit 823e55aa authored by Carsten  Rose's avatar Carsten Rose
Browse files

Manual.rst: notes how to enable a download of FE-GROUP protected pages.

Html2Pdf.php: Fake the current 'user-agent' and add it as '--custom-header ...' AND '--custom-header-propagation' option to the wkhtmltopdf call. Without, T3 will deny FE Group access. The --custom-header-propagation seems to be necessary.
parent 1a3338c5
......@@ -51,6 +51,8 @@ Preparation steps for Ubuntu 16.04::
sudo apt install php7.0-intl
sudo apt install pdftk libxrender1 # for PDF and 'HTML to PDF' (wkhtmltopdf)
.. _wkhtmltopdf:
wkhtmltopdf
^^^^^^^^^^^
......@@ -66,6 +68,10 @@ In `config-qfq-ini`_ specify the:
* installed `wkhtmltopdf` binary,
* the site base URL.
**Important**: To access FE_GROUP protected pages or content, it's necessary to set in the Typo3 Installtool: ::
[FE][lockIP] = 0
HTML to PDF conversion
''''''''''''''''''''''
......@@ -3691,7 +3697,8 @@ All files will be read by PHP - therefore the directory might be protected again
preferred way to offer secure downloads via QFQ.
In case the download needs a persistant URL (no SIP, no user session), a regular
link, pointing directly to a file, have to be used - the download functionality described here is not appropriate.
link, pointing directly to a file, have to be used - the download functionality described here is not appropriate for
such a scenario.
.. _download-parameter-files:
......@@ -3742,7 +3749,10 @@ Parameter and (element) sources
In that way, specific sources for the `download` might be SIP encrypted.
* Any current HTML cookies will be forwarded to/via `wkhtml`. This includes the active FE / BE Login as well as any QFQ session.
* Any current HTML cookies will be forwarded to/via `wkhtml`. This includes the current FE Login as well as any
QFQ session. Also the current User-Agent are faked via the `wkhtml` page request.
* If there are trouble with accessing FE_GROUP protected content, please check `wkhtmltopdf`_.
* *url*: `u:<url>` - any URL, pointing to an internal or external destination.
......
......@@ -903,7 +903,7 @@ const HTML2PDF_PAGEID = 'id';
const HTML2PDF_PARAM_GET = 'paramGet';
const HTML2PDF_URL_PRINT = 'urlPrint';
const SESSION_COOKIE_REFEIX = 'qfq.cookie.'; // temporary filename on server of single export file
const SESSION_COOKIE_PREFEIX = 'qfq.cookie.'; // temporary 'cookie file' to forward `fe_user` and `qfq` session.
// Class: LINK
const PARAM_DELIMITER = '|';
......
......@@ -179,7 +179,7 @@ class QuickFormQuery {
$html .= $this->doForm(FORM_LOAD);
$html .= $this->doReport();
// Only needed if there are download which show a popup during rendering/downloading.
// Only needed if there are potential 'download'-links, which shall show a popup during processing of the download.
if ($this->store->getVar(SYSTEM_DOWNLOAD_POPUP, STORE_SYSTEM) == DOWNLOAD_POPUP_REQUEST) {
$html .= $this->getModalCode();
}
......
......@@ -24,8 +24,8 @@ class SessionCookie {
public function __construct($domain, $path) {
$lines = '';
$this->pathFileNameCookie = tempnam(sys_get_temp_dir(), SESSION_COOKIE_REFEIX);
if (false === $this->pathFileNameCookie) {
// $_COOKIES[]
if (false === ($this->pathFileNameCookie = tempnam(sys_get_temp_dir(), SESSION_COOKIE_PREFEIX))) {
throw new CodeException('Error creating output file.', ERROR_IO_CREATE_FILE);
}
......@@ -54,4 +54,5 @@ class SessionCookie {
return $this->pathFileNameCookie;
}
}
\ No newline at end of file
......@@ -199,11 +199,12 @@ class Html2Pdf {
$filenameEscape = escapeshellarg($filename);
$cookieOptions = '--cookie-jar ' . escapeshellarg($this->sessionCookie->getFile());
$customHeader = '--custom-header User-Agent ' . escapeshellarg($_SERVER['HTTP_USER_AGENT']) . ' --custom-header-propagation'; // By default 'Typo3' expects the same User-Agent for the FE-Session
// Very important: The current lock on session SESSION_NAME has to be freed, cause wkhtmltopdf will use the same
// session in a few moments and this script remains active all the time.
$this->session->close();
$cmd = "$wkhtmlToPdf $cookieOptions $options $urlPrint $filenameEscape";
$cmd = "$wkhtmlToPdf $customHeader $cookieOptions $options $urlPrint $filenameEscape";
$rc = 0;
$line = system($cmd, $rc);
......
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