1
0
Ver Fonte

Support for OC-Checksum header

bohwaz há 2 anos atrás
pai
commit
6856eafda8
3 ficheiros alterados com 34 adições e 15 exclusões
  1. 2 1
      README.md
  2. 24 10
      index.php
  3. 8 4
      server.php

+ 2 - 1
README.md

@@ -21,13 +21,14 @@ If you drop the [`index.php`](https://github.com/kd2org/picodav/raw/main/index.p
 	* Download all files of a directory
 * Manage users and password with only a text file!
 * Restrict users to some directories, control where they can write!
+* Support for [rclone](https://rclone.org) as a NextCloud provider
 
 ## WebDAV clients
 
 You can use any WebDAV client, but we recommend these:
 
 * Windows/OSX: [CyberDuck](https://cyberduck.io/download/)
-* Linux: Any file manager should be able to connect to WebDAV (Dolphin, Thunar, Nautilus, etc.), but you can also use [FUSE webdavfs](https://github.com/miquels/webdavfs)
+* Linux: Any file manager should be able to connect to WebDAV (Dolphin, Thunar, Nautilus, etc.), but you can also use [FUSE webdavfs](https://github.com/miquels/webdavfs), or [rclone](https://rclone.org)
 * Android: [RCX](https://f-droid.org/en/packages/io.github.x0b.rcx/) and [DAVx⁵](https://www.davx5.com/), see [the manual](https://manual.davx5.com/webdav_mounts.html)
 
 ## Install

Diff do ficheiro suprimidas por serem muito extensas
+ 24 - 10
index.php


+ 8 - 4
server.php

@@ -249,7 +249,7 @@ namespace PicoDAV
 
 					return $permissions;
 				case Server::PROP_DIGEST_MD5:
-					if (!is_file($target)) {
+					if (!is_file($target) || is_dir($target) || !is_readable($target)) {
 						return null;
 					}
 
@@ -286,7 +286,7 @@ namespace PicoDAV
 			return $out;
 		}
 
-		public function put(string $uri, $pointer, ?string $hash, ?int $mtime): bool
+		public function put(string $uri, $pointer, ?string $hash_algo, ?string $hash, ?int $mtime): bool
 		{
 			if (preg_match(self::PUT_IGNORE_PATTERN, basename($uri))) {
 				return false;
@@ -334,10 +334,14 @@ namespace PicoDAV
 				@unlink($tmp_file);
 				throw new WebDAV_Exception('Your quota is exhausted', 403);
 			}
-			elseif ($hash && md5_file($tmp_file) != $hash) {
+			elseif ($hash && $hash_algo == 'MD5' && md5_file($tmp_file) != $hash) {
 				@unlink($tmp_file);
 				throw new WebDAV_Exception('The data sent does not match the supplied MD5 hash', 400);
 			}
+			elseif ($hash && $hash_algo == 'SHA1' && sha1_file($tmp_file) != $hash) {
+				@unlink($tmp_file);
+				throw new WebDAV_Exception('The data sent does not match the supplied SHA1 hash', 400);
+			}
 			else {
 				rename($tmp_file, $target);
 			}
@@ -680,7 +684,7 @@ namespace {
 
 	if (!$dav->route($uri)) {
 		http_response_code(404);
-		die('Invalid URL, sorry');
+		die('Unknown URL, sorry.');
 	}
 
 	exit;

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff