can add basic auth credentials to load image file from protected shop
This commit is contained in:
@ -196,6 +196,27 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
|||||||
|
|
||||||
self::$_blIsAdmin = $blCurrentRenderFromAdmin;
|
self::$_blIsAdmin = $blCurrentRenderFromAdmin;
|
||||||
|
|
||||||
|
$content = $this->addBasicAuth($content);
|
||||||
|
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function addBasicAuth($content)
|
||||||
|
{
|
||||||
|
$username = trim(Registry::getConfig()->getConfigParam('d3PdfDocumentsbasicAuthUserName'));
|
||||||
|
$password = trim(Registry::getConfig()->getConfigParam('d3PdfDocumentsbasicAuthPassword'));
|
||||||
|
|
||||||
|
if ($username && $password) {
|
||||||
|
$shopUrl = parse_url( Registry::getConfig()->getShopCurrentUrl() );
|
||||||
|
$pattern = '/(["|\'])'.
|
||||||
|
'(' . preg_quote( $shopUrl['scheme'], '/' ) . ':\/\/)'.
|
||||||
|
'(' . preg_quote( $shopUrl['host'], '/' ) . '.*?)'.
|
||||||
|
'\1/m';
|
||||||
|
$replace = "$1$2" . urlencode($username). ":" . urlencode($password) . "@$3$1";
|
||||||
|
|
||||||
|
$content = preg_replace( $pattern, $replace, $content );
|
||||||
|
}
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,11 +9,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$sLangName = "Deutsch";
|
$sLangName = "Deutsch";
|
||||||
|
|
||||||
|
$basicAuthHelp = <<<HELP
|
||||||
|
Befindet sich der aktuelle Shop hinter einem BasicAuth, können beim Generieren des PDFs die Bilder nicht geladen werden. Tragen Sie hier die Zugangsdaten ein, um die Bilder zu sehen.
|
||||||
|
HELP;
|
||||||
|
|
||||||
$aLang = array(
|
$aLang = array(
|
||||||
'charset' => 'utf-8',
|
'charset' => 'utf-8',
|
||||||
|
|
||||||
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Grundeinstellungen',
|
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Grundeinstellungen',
|
||||||
'SHOP_MODULE_d3PdfDocumentsbDev' => 'Entwicklermodus',
|
'SHOP_MODULE_d3PdfDocumentsbDev' => 'Entwicklermodus',
|
||||||
|
'HELP_SHOP_MODULE_d3PdfDocumentsbDev' => 'Mit aktiviertem Entwicklermodus wird das Dokument im '.
|
||||||
|
'HTML-Format ausgegeben. Inhaltliche Fehler können so besser nachvollzogen werden.',
|
||||||
|
'SHOP_MODULE_d3PdfDocumentsbasicAuthUserName' => 'BasicAuth des Shops - Benutzername (optional)',
|
||||||
|
'HELP_SHOP_MODULE_d3PdfDocumentsbasicAuthUserName' => $basicAuthHelp,
|
||||||
|
'SHOP_MODULE_d3PdfDocumentsbasicAuthPassword' => 'BasicAuth des Shops - Passwort (optional)',
|
||||||
|
'HELP_SHOP_MODULE_d3PdfDocumentsbasicAuthPassword' => $basicAuthHelp,
|
||||||
|
|
||||||
'D3_PDFDOCUMENTS' => 'PDF-Dokumente',
|
'D3_PDFDOCUMENTS' => 'PDF-Dokumente',
|
||||||
'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung',
|
'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung',
|
||||||
|
@ -9,11 +9,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$sLangName = "English";
|
$sLangName = "English";
|
||||||
|
|
||||||
|
$basicAuthHelp = <<<HELP
|
||||||
|
If the current shop is protected by a BasicAuth, the images cannot be loaded when the PDF is generated. Enter the access data here to view the images.
|
||||||
|
HELP;
|
||||||
|
|
||||||
$aLang = array(
|
$aLang = array(
|
||||||
'charset' => 'utf-8',
|
'charset' => 'utf-8',
|
||||||
|
|
||||||
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Basic settings',
|
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Basic settings',
|
||||||
'SHOP_MODULE_d3PdfDocumentsbDev' => 'Developer mode',
|
'SHOP_MODULE_d3PdfDocumentsbDev' => 'Developer mode',
|
||||||
|
'HELP_SHOP_MODULE_d3PdfDocumentsbDev' => 'If developer mode is activated, the document is output in '.
|
||||||
|
'HTML format. This makes it much easier to trace content errors.',
|
||||||
|
'SHOP_MODULE_d3PdfDocumentsbasicAuthUserName' => 'BasicAuth of the shop - user name (optional)',
|
||||||
|
'HELP_SHOP_MODULE_d3PdfDocumentsbasicAuthUserName' => $basicAuthHelp,
|
||||||
|
'SHOP_MODULE_d3PdfDocumentsbasicAuthPassword' => 'BasicAuth of the shop - password (optional)',
|
||||||
|
'HELP_SHOP_MODULE_d3PdfDocumentsbasicAuthPassword' => $basicAuthHelp,
|
||||||
|
|
||||||
'D3_PDFDOCUMENTS' => 'PDF Documents',
|
'D3_PDFDOCUMENTS' => 'PDF Documents',
|
||||||
'D3_PDFDOCUMENTS_INVOICE' => 'Invoice',
|
'D3_PDFDOCUMENTS_INVOICE' => 'Invoice',
|
||||||
|
10
metadata.php
10
metadata.php
@ -85,6 +85,16 @@ $aModule = [
|
|||||||
'name' => $sModuleId.'bDev',
|
'name' => $sModuleId.'bDev',
|
||||||
'type' => 'bool',
|
'type' => 'bool',
|
||||||
'value' => false
|
'value' => false
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'group' => $sModuleId.'main',
|
||||||
|
'name' => $sModuleId.'basicAuthUserName',
|
||||||
|
'type' => 'str'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'group' => $sModuleId.'main',
|
||||||
|
'name' => $sModuleId.'basicAuthPassword',
|
||||||
|
'type' => 'password'
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user