| 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/includes/ |
Upload File : |
<?php
declare(strict_types=1);
/** POLANA V17.5.1 — pure patch transforms, no side effects on include. */
function pv1751_replace_once(string $text, string $before, string $after, string $label): string {
if (str_contains($text, $after)) return $text;
$count = substr_count($text, $before);
if ($count !== 1) throw new RuntimeException('Nie znaleziono jednoznacznego wzorca: '.$label.'. Nie zmieniono plików.');
return str_replace($before, $after, $text);
}
function pv1751_patch_email(string $s): string {
if (str_contains($s, 'POLANA_V1751_EMAIL_PHONE')) return $s;
$old = <<<'OLD'
$intro = $kind==='received' ? '<tr><td style="padding:0 30px 18px"><div style="padding:12px 16px;background:#fff7e8;border:1px solid #ebd7af;border-radius:10px;color:#5b4828;font-size:14px;line-height:1.5"><strong>To jeszcze nie jest potwierdzenie stolika.</strong> Obsługa sprawdzi dostępność i prześle osobną odpowiedź.</div></td></tr>' : '';
OLD;
$s = pv1751_replace_once($s, $old, " \$intro = ''; // POLANA_V1751_EMAIL_PHONE: zbędny komunikat usunięty", 'blok ostrzegawczy e-mail');
$old = <<<'OLD'
$bodyHtml=nl2br($safe($body),false);
OLD;
$new = <<<'NEW'
$bodyHtml=nl2br($safe($body),false);
// Telefon restauracji: osobny numer w e-mailach, a jeśli nieustawiony, użyj telefonu strony.
$restaurantPhone=trim((string)setting('polana_v175_email_phone', setting('phone', '')));
$restaurantTel=preg_replace('/[^0-9+]/', '', $restaurantPhone) ?? '';
$phoneHtml=($restaurantPhone!=='' && preg_match('/\d{6,}/', preg_replace('/\D/', '', $restaurantTel) ?? ''))
? 'Telefon: <a style="color:#36543a;font-weight:bold;text-decoration:none" href="tel:'.$safe($restaurantTel).'">'.$safe($restaurantPhone).'</a><br>' : '';
NEW;
$s=pv1751_replace_once($s,$old,$new,'telefon w e-mailu');
$s=pv1751_replace_once($s,'>Numer</td><td align="right"','>Nr rezerwacji</td><td align="right"','etykieta numeru rezerwacji');
$s=pv1751_replace_once($s,'Kraków<br>W sprawie rezerwacji napisz','Kraków<br>\'.$phoneHtml.\'W sprawie rezerwacji napisz','telefon w stopce');
return $s;
}
function pv1751_patch_admin(string $s): string {
if (str_contains($s, 'POLANA_V1751_PHONE_ADMIN')) return $s;
$s=pv1751_replace_once($s,
" if (\$action!=='save') throw new RuntimeException('Nieprawidłowa operacja.');",
" if (\$action!=='save') throw new RuntimeException('Nieprawidłowa operacja.');\n // POLANA_V1751_PHONE_ADMIN\n \$emailPhone=trim((string)(\$_POST['email_phone']??''));\n if (mb_strlen(\$emailPhone)>35 || (\$emailPhone!=='' && !preg_match('/^[+0-9(). \\-]+$/u',\$emailPhone))) throw new RuntimeException('Telefon w e-mailach: wpisz poprawny numer (maks. 35 znaków).');",
'walidacja telefonu');
$s=pv1751_replace_once($s,
" \$stmt->execute(['polana_v175_booking_enabled',\$enabled?'1':'0']);",
" \$stmt->execute(['polana_v175_booking_enabled',\$enabled?'1':'0']);\n \$stmt->execute(['polana_v175_email_phone',\$emailPhone]);",
'zapis telefonu');
$s=pv1751_replace_once($s,
' <label class="pv175-on" style="margin:20px 0">',
' <div style="margin:18px 0"><label for="pv175-email-phone" style="display:block;font-weight:700;margin-bottom:8px">Telefon restauracji w wiadomościach e-mail</label><input id="pv175-email-phone" type="tel" name="email_phone" maxlength="35" autocomplete="tel" placeholder="Np. +48 123 456 789" value="<?= e(setting(\'polana_v175_email_phone\', setting(\'phone\', \'\'))) ?>" style="display:block;width:100%;max-width:390px;padding:12px;border:1px solid #ccc;border-radius:10px"><div class="pv175-note">Numer będzie klikalny w stopce e-maila. Jeżeli go nie podasz, numer nie pojawi się w wiadomości. Numer rezerwacji pozostaje osobno w szczegółach.</div></div>' . "\n" . ' <label class="pv175-on" style="margin:20px 0">',
'pole telefonu w panelu');
return $s;
}