Skip to content

Commit

Permalink
Nextcloud links with index.php #41
Browse files Browse the repository at this point in the history
  • Loading branch information
kimbtech committed Jan 21, 2024
1 parent 598a561 commit 0fd15a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2.8.0
2.8.1
2.8
2
2 changes: 1 addition & 1 deletion php/classes/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Config {
/**
* The system's version.
*/
const VERSION = 'v2.8.0';
const VERSION = 'v2.8.1';

/**
* The real domain which should be used.
Expand Down
14 changes: 9 additions & 5 deletions php/classes/PodcastLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,21 @@ private static function loadRedis(){
* Nextcloud share loader
*/
private static function loadFromNextcloud( string $url ) : array {
$server = substr( $url, 0, strrpos( $url , '/s/' )+1 );
$share = substr( $url, strlen($server)+2 );
$share = preg_replace( '/[^0-9A-Za-z]/', '', $share );
// "<server base path> / <possibly index.php> /s/ <token>"
if(preg_match('/^(https?\:\/\/.*)(?<!index\.php)(\/index\.php)?\/s\/([0-9A-Za-z]+)/', $url, $matches) !== 1){
return array();
}
$server = $matches[1]; // the base path to nextcloud
$useindex = !empty($matches[2]); // used index.php to access files?
$share = $matches[3]; // the token/ name of share

$cont = stream_context_create( array(
"http" => array(
'method' => "PROPFIND",
"header" => "Authorization: Basic " . base64_encode($share . ':')
)
));
$data = file_get_contents( $server . 'public.php/webdav/', false, $cont );
$data = file_get_contents( $server . '/public.php/webdav/', false, $cont );
$data = explode( '<d:href>', $data );

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

0 comments on commit 0fd15a8

Please sign in to comment.