uawdijnntqw1x1x1
IP : 216.73.216.39
Hostname : diefsweb003.fsit.ch
Kernel : Linux diefsweb003.fsit.ch 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
Disable Function : None :)
OS : Linux
PATH:
/
home
/
wirbesti
/
nousdecidons.ch
/
472b8
/
..
/
..
/
public_html
/
php
/
InitiatorCoverSheet.php
/
/
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); // Use Composer autoloader $autoloadPath = __DIR__ . '/../libraries2/dompdf/vendor/autoload.php'; if (!file_exists($autoloadPath)) { die('Error: Composer autoloader not found at ' . $autoloadPath . '. Please run "composer install" in /home/wirbesti/public_html.'); } require_once $autoloadPath; use Dompdf\Dompdf; if (!class_exists('Dompdf\Dompdf')) { die('Error: Dompdf class not found. Ensure "dompdf/dompdf" is installed via Composer.'); } class InitiatorCoverSheet { // Default coordinates for the initiator address on the cover sheet private $defaultCoordinates = [ // Left address (below "Wir bestimmen", second half of page) "left-name-x" => "95", "left-name-y" => "800", "left-street-x" => "95", "left-street-y" => "820", "left-zip-x" => "95", "left-zip-y" => "840", "left-town-x" => "135", "left-town-y" => "840", // Right address (same height, right side) "right-name-x" => "475", "right-name-y" => "800", "right-street-x" => "475", "right-street-y" => "820", "right-zip-x" => "475", "right-zip-y" => "840", "right-town-x" => "515", "right-town-y" => "840" ]; // Cover sheet JPGs mapped by language private $coverSheetByLanguage = [ 'de' => 'WIBE_Adr_DE.jpg', // German 'fr' => 'WIBE_Adr_FR.jpg', // French (temporary for testing) 'it' => 'WIBE_Adr_IT.jpg' // Italian ]; // Default language if none is provided private $defaultLanguage = 'de'; public function __construct() { // No dependencies injected yet; we might add a Metadata class dependency later } public function generateCoverSheet($data) { $dompdf = new Dompdf(); $options = $dompdf->getOptions(); $options->setDefaultFont('Arial'); $options->setIsHtml5ParserEnabled(true); $options->setChroot('/home/wirbesti/public_html/images/InitiativePDF'); // Production directory for cover sheet images $dompdf->setOptions($options); // Extract initiator details, language, and slogan from data $initiatorname = $data['initiatorname'] ?? ''; $initiatorstreet = $data['initiatorstreet'] ?? ''; $initiatorzipcode = $data['initiatorzipcode'] ?? ''; $initiatortown = $data['initiatortown'] ?? ''; $language = $data['language'] ?? $this->defaultLanguage; // Fallback to default if not provided $randnum = $data['randnum'] ?? rand(1000, 9999); // Random number for filename if not provided $slogan = $data['slogan'] ?? ''; // Slogan from data // Select cover sheet based on language $coverSheetFile = $this->coverSheetByLanguage[$language] ?? $this->coverSheetByLanguage[$this->defaultLanguage]; $formpath = '/home/wirbesti/public_html/images/InitiativePDF/' . $coverSheetFile; // Production path for images // Use default coordinates $coordinates = $this->defaultCoordinates; // HTML for the cover sheet with initiator address and slogan $html = <<<EOD <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <style> span.cls_015 {font-family:Arial,sans-serif;font-size:12px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none} div.cls_015 {font-family:Arial,sans-serif;font-size:12px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none} span.cls_slogan {font-family:Arial,sans-serif;font-size:10pt;color:rgb(0,0,255);font-weight:bold;font-style:normal;text-decoration:none;font-stretch:condensed} @page { margin: 0px !important; size: A4 portrait !important; } body, html { margin: 0px !important; } </style> </head> <body> <div style="position:absolute;left:0px;top:0px;right:0;bottom:0"> <img src="$formpath" style="width:100%; height:auto"> </div> <div style="position:absolute;left:47px;top:125px;width:710px;text-align:left" class="cls_slogan"><span class="cls_slogan">{$this->escapeHtml($slogan)}</span></div> <!-- Left Address --> <div style="position:absolute;left:{$coordinates['left-name-x']}px;top:{$coordinates['left-name-y']}px" class="cls_015"><span class="cls_015">{$this->escapeHtml($initiatorname)}</span></div> <div style="position:absolute;left:{$coordinates['left-street-x']}px;top:{$coordinates['left-street-y']}px" class="cls_015"><span class="cls_015">{$this->escapeHtml($initiatorstreet)}</span></div> <div style="position:absolute;left:{$coordinates['left-zip-x']}px;top:{$coordinates['left-zip-y']}px" class="cls_015"><span class="cls_015">{$this->escapeHtml($initiatorzipcode)}</span></div> <div style="position:absolute;left:{$coordinates['left-town-x']}px;top:{$coordinates['left-town-y']}px" class="cls_015"><span class="cls_015">{$this->escapeHtml($initiatortown)}</span></div> <!-- Right Address --> <div style="position:absolute;left:{$coordinates['right-name-x']}px;top:{$coordinates['right-name-y']}px" class="cls_015"><span class="cls_015">{$this->escapeHtml($initiatorname)}</span></div> <div style="position:absolute;left:{$coordinates['right-street-x']}px;top:{$coordinates['right-street-y']}px" class="cls_015"><span class="cls_015">{$this->escapeHtml($initiatorstreet)}</span></div> <div style="position:absolute;left:{$coordinates['right-zip-x']}px;top:{$coordinates['right-zip-y']}px" class="cls_015"><span class="cls_015">{$this->escapeHtml($initiatorzipcode)}</span></div> <div style="position:absolute;left:{$coordinates['right-town-x']}px;top:{$coordinates['right-town-y']}px" class="cls_015"><span class="cls_015">{$this->escapeHtml($initiatortown)}</span></div> </body> </html> EOD; $dompdf->loadHtml($html); $dompdf->render(); // Output the PDF to a file $filename = 'cover-sheet-' . $language . '-' . $randnum . '.pdf'; $filepath = '/home/wirbesti/public_html/images/CoverSheets/' . $filename; // Production path for PDF output $output = $dompdf->output(); $result = file_put_contents($filepath, $output); return $result !== false ? $filename : false; // Return filename on success, false on failure } // Helper method to escape HTML safely private function escapeHtml($string) { return htmlspecialchars($string, ENT_QUOTES | ENT_HTML5, 'UTF-8'); } } ?>
/home/wirbesti/nousdecidons.ch/472b8/../../public_html/php/InitiatorCoverSheet.php