Browse Source

Refactor rewrite rules in .htaccess and index.php, and parse config file consistently

poesty 1 year ago
parent
commit
451ba2f8f2
3 changed files with 6 additions and 8 deletions
  1. 1 2
      .htaccess
  2. 4 5
      index.php
  3. 1 1
      server.php

+ 1 - 2
.htaccess

@@ -3,7 +3,6 @@ DirectoryIndex disabled
 RedirectMatch 404 \.picodav\.ini
 
 RewriteEngine On
-RewriteBase /
 
 # Uncomment the following 2 lignes to make things a bit faster for
 # downloading files, AND you don't use PicoDAV users to manage access,
@@ -11,4 +10,4 @@ RewriteBase /
 #RewriteCond %{REQUEST_FILENAME} !-f [OR]
 #RewriteCond %{REQUEST_METHOD} !GET
 
-RewriteRule ^.*$ /index.php [END]
+RewriteRule ^.*$ index.php [END]

+ 4 - 5
index.php

@@ -1909,7 +1909,6 @@ namespace {
 RedirectMatch 404 \\.picodav\\.ini
 
 RewriteEngine On
-RewriteBase /
 
 # Uncomment the following 2 lignes to make things a bit faster for
 # downloading files, AND you don\'t use PicoDAV users to manage access,
@@ -1917,7 +1916,7 @@ RewriteBase /
 #RewriteCond %{REQUEST_FILENAME} !-f [OR]
 #RewriteCond %{REQUEST_METHOD} !GET
 
-RewriteRule ^.*$ /index.php [END]
+RewriteRule ^.*$ index.php [END]
 '));
 	}
 
@@ -1940,11 +1939,11 @@ RewriteRule ^.*$ /index.php [END]
 		$fp = fopen(__FILE__, 'r');
 
 		if ($relative_uri == '.webdav/webdav.js') {
-			fseek($fp, 52608, SEEK_SET);
+			fseek($fp, 52648, SEEK_SET);
 			echo fread($fp, 27798);
 		}
 		else {
-			fseek($fp, 52608 + 27798, SEEK_SET);
+			fseek($fp, 52648 + 27798, SEEK_SET);
 			echo fread($fp, 7004);
 		}
 
@@ -1966,7 +1965,7 @@ RewriteRule ^.*$ /index.php [END]
 	$storage = new Storage($self_dir);
 
 	if (file_exists($config_file)) {
-		$config = parse_ini_file($config_file, true);
+		$config = parse_ini_string(file_get_contents($config_file), true, INI_SCANNER_TYPED);
 		$users = array_filter($config, 'is_array');
 		$config = array_diff_key($config, $users);
 		$config = array_change_key_case($config, \CASE_UPPER);

+ 1 - 1
server.php

@@ -628,7 +628,7 @@ namespace {
 	$storage = new Storage($self_dir);
 
 	if (file_exists($config_file)) {
-		$config = parse_ini_file($config_file, true);
+        $config = parse_ini_string(file_get_contents($config_file), true, INI_SCANNER_TYPED);
 		$users = array_filter($config, 'is_array');
 		$config = array_diff_key($config, $users);
 		$config = array_change_key_case($config, \CASE_UPPER);