| 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 V18.14: transforms only verified known source fragments. No side effects on include. */
function pv1814_transform_reservations(string $source): string {
if (substr_count($source, 'function reservation_change_status(') !== 1) {
throw new RuntimeException('Nie rozpoznano jednoznacznie funkcji zmiany statusu.');
}
if (!preg_match('/function reservation_change_status\(.*?\n\}/s', $source, $m, PREG_OFFSET_CAPTURE)) {
throw new RuntimeException('Nie mozna bezpiecznie wyznaczyc konca funkcji zmiany statusu.');
}
$body = $m[0][0]; $offset = (int)$m[0][1];
if (str_contains($body, 'POLANA_V1814_GCAL_AFTER_STATUS') || str_contains($body, 'pg173_after_change(')) return $source;
$needle = " return \$reservation;\n}";
if (substr_count($body, $needle) !== 1) throw new RuntimeException('Nieznany koniec funkcji zmiany statusu.');
$hook = <<<'HOOK'
/* POLANA_V1814_GCAL_AFTER_STATUS: po zapisaniu nowego statusu, bez duplikatow. */
if ((string)$previous['status'] !== $status) {
try {
require_once __DIR__ . '/polana_gcal.php';
pg173_after_change($id, $adminUserId);
} catch (Throwable $calendarError) {
error_log('[POLANA GCAL AUTO V18.14] #'.$id.': '.$calendarError->getMessage());
try {
reservation_add_event($id, 'calendar_error', 'Automatyczna synchronizacja Kalendarza: '.mb_substr($calendarError->getMessage(), 0, 240, 'UTF-8'), $adminUserId);
} catch (Throwable $ignored) {}
}
}
HOOK;
$changed = str_replace($needle, $hook.$needle, $body);
return substr_replace($source, $changed, $offset, strlen($body));
}
function pv1814_transform_nav(string $source): string {
$marker = '<!-- POLANA_V1814_MODULY_NAV -->';
if (str_contains($source, $marker)) return $source;
$needle = '<a href="/admin/polana-zarzadzanie.php">Zarządzanie</a>';
if (substr_count($source, $needle) !== 1) throw new RuntimeException('Nie znaleziono jednego bezpiecznego miejsca w menu administratora.');
$added = <<<'ADD'
<!-- POLANA_V1814_MODULY_NAV -->
<?php if ($role === 'admin'): ?><a href="/admin/polana-v1814-moduly.php">Wszystkie moduły</a><?php endif; ?>
ADD;
return str_replace($needle, $needle."\n ".$added, $source);
}