can add basic auth credentials to load image file from protected shop

# Conflicts:
#	Application/views/admin_smarty/de/pdfdocuments_lang.php
#	Application/views/admin_smarty/en/pdfdocuments_lang.php
This commit is contained in:
2025-05-14 13:27:29 +02:00
bovenliggende a5c618c34f
commit 4a538bcec3
4 gewijzigde bestanden met toevoegingen van 53 en 0 verwijderingen

Bestand weergeven

@ -206,6 +206,27 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
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;
}

Bestand weergeven

@ -11,11 +11,22 @@
use D3\PdfDocuments\Application\Model\Constants;
$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(
'charset' => 'utf-8',
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Grundeinstellungen',
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Entwicklermodus',
'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Mit aktiviertem Entwicklermodus wird das Dokument im '.
'HTML-Format ausgegeben. Inhaltliche Fehler können so besser nachvollzogen werden.',
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => 'BasicAuth des Shops - Benutzername (optional)',
'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => $basicAuthHelp,
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthPassword' => 'BasicAuth des Shops - Passwort (optional)',
'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthPassword' => $basicAuthHelp,
'D3_PDFDOCUMENTS' => 'PDF-Dokumente',
'D3_PDFDOCUMENTS_INVOICE' => 'Rechnung',

Bestand weergeven

@ -11,11 +11,22 @@
use D3\PdfDocuments\Application\Model\Constants;
$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(
'charset' => 'utf-8',
'SHOP_MODULE_GROUP_d3PdfDocumentsmain' => 'Basic settings',
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'Developer mode',
'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'bDev' => 'If developer mode is activated, the document is output in '.
'HTML format. This makes it much easier to trace content errors.',
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => 'BasicAuth of the shop - user name (optional)',
'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthUserName' => $basicAuthHelp,
'SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthPassword' => 'BasicAuth of the shop - password (optional)',
'HELP_SHOP_MODULE_'. Constants::OXID_MODULE_ID.'basicAuthPassword' => $basicAuthHelp,
'D3_PDFDOCUMENTS' => 'PDF Documents',
'D3_PDFDOCUMENTS_INVOICE' => 'Invoice',

Bestand weergeven

@ -84,6 +84,16 @@ $aModule = [
'name' => Constants::OXID_MODULE_ID.'bDev',
'type' => 'bool',
'value' => false
],
[
'group' => $sModuleId.'main',
'name' => $sModuleId.'basicAuthUserName',
'type' => 'str'
],
[
'group' => $sModuleId.'main',
'name' => $sModuleId.'basicAuthPassword',
'type' => 'password'
]
]
];