Fix permissions on OPDS feeds

This commit is contained in:
Alex Cabal 2020-06-25 01:28:07 -05:00
parent 6252cff1e5
commit ffa3ab8a74
3 changed files with 20 additions and 11 deletions

View file

@ -20,17 +20,23 @@ class OpdsFeed{
}
private function Sha1Entries(string $xmlString): string{
$xml = new SimpleXMLElement(str_replace('xmlns=', 'ns=', $xmlString));
$xml->registerXPathNamespace('dc', 'http://purl.org/dc/elements/1.1/');
$xml->registerXPathNamespace('schema', 'http://schema.org/');
$entries = $xml->xpath('/feed/entry') ?? [];
try{
$xml = new SimpleXMLElement(str_replace('xmlns=', 'ns=', $xmlString));
$xml->registerXPathNamespace('dc', 'http://purl.org/dc/elements/1.1/');
$xml->registerXPathNamespace('schema', 'http://schema.org/');
$entries = $xml->xpath('/feed/entry') ?? [];
$output = '';
foreach($entries as $entry){
$output .= $entry->asXml();
$output = '';
foreach($entries as $entry){
$output .= $entry->asXml();
}
return sha1(preg_replace('/\s/ius', '', $output));
}
catch(Exception $ex){
// Invalid XML
return '';
}
return sha1(preg_replace('/\s/ius', '', $output));
}
public function Save(string $filename): void{