| Server IP : 188.114.96.3 / Your IP : 216.73.216.143 Web Server : Apache System : Linux sv058.home.net.pl 6.8.2 husak_dirty_pages_fix #1 SMP PREEMPT_DYNAMIC Tue Apr 2 22:06:51 CEST 2024 x86_64 User : ( 3194769) PHP Version : 8.5.12 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /polana/admin/ |
Upload File : |
<?php
declare(strict_types=1);
require_once dirname(__DIR__).'/includes/tklm_word_v5.php';
require_admin_role();
header('Cache-Control: private, no-store, max-age=0');
header('X-Robots-Tag: noindex, nofollow');
$id=filter_input(INPUT_GET,'menu_id',FILTER_VALIDATE_INT);
$lang=strtolower((string)($_GET['lang']??'en'));
$draft=(string)($_GET['draft']??'')==='1';
if (!$id || !in_array($lang,['pl','en','de','es'],true)) {http_response_code(400);exit('Nieprawidłowa karta lub język.');}
try {
[$menu,$cats]=tklm_v5_rows((int)$id);
$parts=tklm_v5_word_document_parts($menu,$cats,$lang,$draft);
$binary=tklm_v5_word_zip($parts);
$filename='Polana_Menu_'.(int)$id.'_'.strtoupper($lang).($draft?'_ROBOCZE':'').'.docx';
header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Content-Length: '.strlen($binary));
header('X-Content-Type-Options: nosniff');
echo $binary;exit;
} catch(Throwable $e) {
error_log('[TKLM Word V5] '.$e->getMessage());
http_response_code(409);
header('Content-Type: text/html; charset=utf-8');
echo '<!doctype html><html lang="pl"><meta charset="utf-8"><title>Word POLANA</title><body style="font-family:system-ui;margin:8vh auto;max-width:700px;padding:20px">';
echo '<h1>Nie można pobrać Worda</h1><p>'.htmlspecialchars($e->getMessage(),ENT_QUOTES|ENT_SUBSTITUTE,'UTF-8').'</p>';
echo '<p><a href="/admin/menus.php">Wróć do kart menu</a></p></body></html>';
}