Make it work with Mobile client

This commit is contained in:
bohwaz 2022-09-03 06:25:02 +02:00
parent 66335fda5c
commit 3dfea64ad9
8 changed files with 26 additions and 8 deletions

View file

@ -27,6 +27,10 @@ The second API is different but is explained in the documentation, it involves e
Those endpoints are requested by the clients and one or the other client will fail if they don't return something that looks valid.
## Mobile app
* `getcontentlength` must be present and be a number, even for collections
## Desktop client
### Requests performed

View file

@ -25,6 +25,6 @@ $name = $_SERVER['SERVER_NAME'];
$port = !in_array($_SERVER['SERVER_PORT'], [80, 443]) ? ':' . $_SERVER['SERVER_PORT'] : '';
$root = '/';
define('KaraDAV\WWW_URL', sprintf('http%s://%s%s%s', $https, $name, $port, $root));
#define('KaraDAV\WWW_URL', sprintf('http%s://%s%s%s', $https, $name, $port, $root));
//const WWW_URL = 'http://192.168.43.171:8080/';
const WWW_URL = 'http://192.168.43.171:8081/';

View file

@ -169,7 +169,7 @@ class Server extends WebDAV_NextCloud
switch ($name) {
case 'DAV::getcontentlength':
return is_dir($target) ? '' : filesize($target);
return is_dir($target) ? 0 : filesize($target);
case 'DAV::getcontenttype':
return mime_content_type($target);
case 'DAV::resourcetype':
@ -206,7 +206,7 @@ class Server extends WebDAV_NextCloud
return new \DateTime('@' . filectime($target));
// NextCloud stuff
case self::PROP_OC_ID:
return md5($target);
return $this->nc_direct_id($uri);
case self::PROP_OC_PERMISSIONS:
return implode('', [self::PERM_READ, self::PERM_WRITE, self::PERM_CREATE, self::PERM_DELETE, self::PERM_RENAME_MOVE]);
case self::PROP_OC_SIZE:

View file

@ -152,7 +152,7 @@ class Users
$session = $this->appSessionCreate();
$current = $this->current();
return sprintf(Server::NC_AUTH_REDIRECT_URL, WWW_URL, $session->token, $session->password);
return sprintf(Server::NC_AUTH_REDIRECT_URL, WWW_URL, $current->login, $session->token . ':' . $session->password);
}
public function appSessionValidateToken(string $token): ?stdClass

View file

@ -15,7 +15,12 @@ if (PHP_SAPI == 'cli-server') {
return false;
}
file_put_contents('php://stderr', $uri . "\n");
$method = $_SERVER['REQUEST_METHOD'] ?? $_SERVER['REDIRECT_REQUEST_METHOD'];
file_put_contents('php://stderr', sprintf("%s %s\n", $method, $uri));
if ($method != 'GET' && $method != 'HEAD') {
file_put_contents('php://stderr', file_get_contents('php://input') . "\n");
}
}
$s = new Server;

View file

@ -112,6 +112,7 @@ dialog.preview {
padding: 0;
border-radius: 0;
background: #ddd;
overflow: hidden;
}
iframe, .md_preview {
@ -127,7 +128,15 @@ iframe, .md_preview {
}
.preview form {
height: calc(100% - 2em);
display: flex;
align-items: center;
justify-content: center;
}
.preview form div {
height: 100%;
margin: 0;
display: flex;
align-items: center;
justify-content: center;

View file

@ -12,7 +12,7 @@ function html(unsafe)
.replace(/'/g, "'");
}
const url = location.href;
const url = location.pathname;
const PREVIEW_TYPES = /^image\/(png|webp|svg|jpeg|jpg|gif|png)|^application\/pdf|^text\/|^audio\/|^video\//;

View file

@ -64,7 +64,7 @@ echo '
<legend>Login</legend>
<dl>
<dt><label for="f_login">Login</label></dt>
<dd><input type="text" name="login" id="f_login" required /></dd>
<dd><input type="text" name="login" id="f_login" required autocapitalize="none" /></dd>
<dt><label for="f_password">Password</label></dt>
<dd><input type="password" name="password" id="f_password" required /></dd>
</dl>