Commit 9d6d8a26 authored by Carsten  Rose's avatar Carsten Rose
Browse files

WIP

parent 9c229008
Pipeline #5413 failed with stages
in 1 minute and 59 seconds
......@@ -642,7 +642,7 @@ const SYSTEM_SHOW_ID_IN_FORM_TITLE = 'showIdInFormTitle';
const SYSTEM_INPUT_CLEAR_ME = 'clearMe';
const SYSTEM_CMD_WKHTMLTOPDF = 'cmdWkhtmltopdf';
const SYSTEM_CMD_CRPDF = 'cmdCrpdf';
const SYSTEM_CMD_QFQPDF = 'cmdQfqpdf';
const SYSTEM_CMD_INKSCAPE = 'cmdInkscape';
const SYSTEM_CMD_CONVERT = 'cmdConvert';
const SYSTEM_CMD_PDF2SVG = 'cmdPdf2svg';
......
......@@ -33,7 +33,7 @@ class SessionCookie {
* @throws \CodeException
*/
public function __construct(array $config) {
$lines = '';
$data = array();
// In debug mode, keep temporary files
$this->cleanTempFiles = !Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_DOWNLOAD, $config[SYSTEM_SHOW_DEBUG_INFO]);
......@@ -47,12 +47,19 @@ class SessionCookie {
throw new \CodeException('Error creating output file.', ERROR_IO_CREATE_FILE);
}
foreach ($_COOKIE as $name => $value) {
// e.g.: SANDBOXSESSION=a83f1o69jbv12932q54hmgphk6; domain=qfq.math.uzh.ch; path=/;
$lines .= $name . "=" . $value . "; domain=$domain; path=$path;\n";
// wkhtml
// foreach ($_COOKIE as $name => $value) {
// // e.g.: SANDBOXSESSION=a83f1o69jbv12932q54hmgphk6; domain=qfq.math.uzh.ch; path=/;
// $data .= $name . "=" . $value . "; domain=$domain; path=$path;\n";
// }
foreach ($_COOKIE as $key => $value) {
$data[] = ['name' => $key, 'value' => $value, 'url' => $domain, 'path' => $path];
}
file_put_contents($this->pathFileNameCookie, $lines, FILE_APPEND);
$data = json_encode(['cookies' => $data]);
file_put_contents($this->pathFileNameCookie, $data, FILE_APPEND);
}
/**
......
......@@ -11,18 +11,17 @@
namespace IMATHUZH\Qfq\Core\Report;
use IMATHUZH\Qfq\Core\Helper\HelperFile;
use IMATHUZH\Qfq\Core\Helper\KeyValueStringParser;
use IMATHUZH\Qfq\Core\Helper\Logger;
use IMATHUZH\Qfq\Core\Helper\OnArray;
use IMATHUZH\Qfq\Core\Helper\OnString;
use IMATHUZH\Qfq\Core\Helper\Path;
use IMATHUZH\Qfq\Core\Helper\SessionCookie;
use IMATHUZH\Qfq\Core\Helper\Support;
use IMATHUZH\Qfq\Core\Store\Config;
use IMATHUZH\Qfq\Core\Store\Session;
use IMATHUZH\Qfq\Core\Store\Sip;
use IMATHUZH\Qfq\Core\Helper\KeyValueStringParser;
use IMATHUZH\Qfq\Core\Helper\SessionCookie;
use IMATHUZH\Qfq\Core\Helper\Logger;
/**
......@@ -172,6 +171,7 @@ class Html2Pdf {
$urlPrint = escapeshellarg($url);
$wkhtmlToPdf = $this->config[SYSTEM_CMD_WKHTMLTOPDF];
$qfqPdf = $this->config[SYSTEM_CMD_QFQPDF];
$filename = HelperFile::tempnam();
$filenameEscape = escapeshellarg($filename);
......@@ -179,14 +179,16 @@ class Html2Pdf {
$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
// crpdf
// qfqpdf
$customHeader = '';
$cookieOptions = '--cookies-inline ' . json_encode(["cookies" => [$_COOKIE]]);
// $cookieOptions = '--cookies-inline ' . ) ;
$cookieOptions = '--cookie-file ' . escapeshellarg($this->sessionCookie->getFile());
// 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 during that time and that would cause a deadlock else.
$this->session->close();
$cmd = "$wkhtmlToPdf $customHeader $cookieOptions $options $urlPrint $filenameEscape";
// $cmd = "$wkhtmlToPdf $customHeader $cookieOptions $options $urlPrint $filenameEscape";
$cmd = "$qfqPdf $customHeader $cookieOptions $options $urlPrint $filenameEscape";
if ($this->logFilePathAbsolute != '') {
Logger::logMessage("Html2Pdf: $cmd", $this->logFilePathAbsolute);
......
......@@ -446,6 +446,7 @@ class Config {
SYSTEM_ENTER_AS_SUBMIT => 1,
SYSTEM_CMD_WKHTMLTOPDF => '/opt/wkhtmltox/bin/wkhtmltopdf',
SYSTEM_CMD_QFQPDF => '/opt/qfqpdf/qfqpdf',
SYSTEM_CMD_INKSCAPE => 'inkscape',
SYSTEM_CMD_CONVERT => 'convert',
SYSTEM_CMD_PDF2SVG => 'pdf2svg',
......
......@@ -277,7 +277,7 @@ BEGIN
END;
###
# QENT_DQUOTE(text)
# QESC_SQUOTE(text)
# Replaces double tick by html entity "
#
DROP FUNCTION IF EXISTS `QESC_SQUOTE`;
......@@ -292,7 +292,7 @@ END;
###
# QENT_DQUOTE(text)
# QESC_DQUOTE(text)
# Replaces double tick by html entity "
#
DROP FUNCTION IF EXISTS `QESC_DQUOTE`;
......
......@@ -34,8 +34,8 @@ cmdPdftocairo = pdftocairo
# cat=config/config; type=string; label=Command 'wkhtmltopdf':Default is '/opt/wkhtmltox/bin/wkhtmltopdf'. Command to convert a HTML page to a PDF.
cmdWkhtmltopdf = /opt/wkhtmltox/bin/wkhtmltopdf
# cat=config/config; type=string; label=Command 'crpdf':Default is 'crpdf'. Command to convert a HTML page to a PDF.
cmdCrpdf = /opt/wkhtmltox/bin/wkhtmltopdf
# cat=config/config; type=string; label=Command 'qfqpdf':Default is '/opt/qfqpdf/qfqpdf'. Command to convert a HTML page to a PDF.
cmdQfqpdf = /opt/qfqpdf/qfqpdf
# cat=config/config; type=string; label=Command 'qpdf':Default is 'qpdf'. Will be used to convert PDF to PDF (try to repair) if merging of PDF fails.
cmdQpdf = qpdf
......
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