Skip to content

Commit 0fd15a8

Browse files
committed
Nextcloud links with index.php #41
1 parent 598a561 commit 0fd15a8

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
2.8.0
1+
2.8.1
22
2.8
33
2

php/classes/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Config {
7777
/**
7878
* The system's version.
7979
*/
80-
const VERSION = 'v2.8.0';
80+
const VERSION = 'v2.8.1';
8181

8282
/**
8383
* The real domain which should be used.

php/classes/PodcastLoader.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,21 @@ private static function loadRedis(){
3434
* Nextcloud share loader
3535
*/
3636
private static function loadFromNextcloud( string $url ) : array {
37-
$server = substr( $url, 0, strrpos( $url , '/s/' )+1 );
38-
$share = substr( $url, strlen($server)+2 );
39-
$share = preg_replace( '/[^0-9A-Za-z]/', '', $share );
37+
// "<server base path> / <possibly index.php> /s/ <token>"
38+
if(preg_match('/^(https?\:\/\/.*)(?<!index\.php)(\/index\.php)?\/s\/([0-9A-Za-z]+)/', $url, $matches) !== 1){
39+
return array();
40+
}
41+
$server = $matches[1]; // the base path to nextcloud
42+
$useindex = !empty($matches[2]); // used index.php to access files?
43+
$share = $matches[3]; // the token/ name of share
4044

4145
$cont = stream_context_create( array(
4246
"http" => array(
4347
'method' => "PROPFIND",
4448
"header" => "Authorization: Basic " . base64_encode($share . ':')
4549
)
4650
));
47-
$data = file_get_contents( $server . 'public.php/webdav/', false, $cont );
51+
$data = file_get_contents( $server . '/public.php/webdav/', false, $cont );
4852
$data = explode( '<d:href>', $data );
4953

5054
$poddata = array(
@@ -63,7 +67,7 @@ private static function loadFromNextcloud( string $url ) : array {
6367
$poddata['episodes'][$eid] = array(
6468
'title' => $fina,
6569
'desc' => '',
66-
'url' => $server . 's/'. $share .'/download?path=%2F&files=' . rawurlencode( $fina )
70+
'url' => $server . ($useindex ? '/index.php' : '') . '/s/'. $share .'/download?path=%2F&files=' . rawurlencode( $fina )
6771
);
6872
$eid++;
6973
}

0 commit comments

Comments
 (0)