'); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); error_log("PROPFIND HTTP код: " . $httpCode); if ($httpCode !== 207) { die("❌ Файл не найден в Nextcloud (HTTP $httpCode). Возможно, он не проиндексирован."); } // Извлекаем fileId из XML preg_match('/(\d+)<\/oc:fileid>/', $response, $matches); if (!isset($matches[1])) { die("❌ Не удалось получить fileId"); } $fileId = $matches[1]; error_log("Получен fileId: " . $fileId); // Извлекаем директорию из пути $dirPath = dirname($ncPath); // Формируем URL для открытия в Nextcloud // Nextcloud автоматически откроет OnlyOffice для редактирования $redirectUrl = $nextcloudUrl . '/apps/files/files/' . $fileId . '?dir=' . urlencode($dirPath) . '&openfile=true'; error_log("Redirect to: " . $redirectUrl); // Редирект в Nextcloud header('Location: ' . $redirectUrl); exit; ?>