karadav/lib/KaraDAV/WebDAV.php

41 lines
1 KiB
PHP
Raw Normal View History

<?php
namespace KaraDAV;
use KD2\WebDAV\Server as WebDAV_Server;
class WebDAV extends WebDAV_Server
{
2022-10-10 12:01:20 +00:00
protected function html_directory(string $uri, iterable $list): ?string
{
2022-10-10 12:01:20 +00:00
$out = parent::html_directory($uri, $list);
if (null !== $out) {
if (WOPI_DISCOVERY_URL) {
$out = str_replace('<html', sprintf('<html data-wopi-discovery-url="%s" data-wopi-host-url="%s"', WOPI_DISCOVERY_URL, WWW_URL . 'wopi/'), $out);
}
2022-10-10 12:01:20 +00:00
$out = str_replace('<body>', sprintf('<body style="opacity: 0"><script type="text/javascript" src="%swebdav.js"></script>', WWW_URL), $out);
}
return $out;
}
2022-10-10 12:01:20 +00:00
public function http_options(): void
{
parent::http_options();
if (ACCESS_CONTROL_ALL) {
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Headers: Authorization, *');
header('Access-Control-Allow-Methods: GET,HEAD,PUT,DELETE,COPY,MOVE,PROPFIND,MKCOL,LOCK,UNLOCK');
}
2022-10-10 12:01:20 +00:00
}
2022-10-21 16:21:38 +00:00
public function log(string $message, ...$params)
{
http_log('DAV: ' . $message, ...$params);
}
}