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,6 +20,7 @@ class OpdsFeed{
} }
private function Sha1Entries(string $xmlString): string{ private function Sha1Entries(string $xmlString): string{
try{
$xml = new SimpleXMLElement(str_replace('xmlns=', 'ns=', $xmlString)); $xml = new SimpleXMLElement(str_replace('xmlns=', 'ns=', $xmlString));
$xml->registerXPathNamespace('dc', 'http://purl.org/dc/elements/1.1/'); $xml->registerXPathNamespace('dc', 'http://purl.org/dc/elements/1.1/');
$xml->registerXPathNamespace('schema', 'http://schema.org/'); $xml->registerXPathNamespace('schema', 'http://schema.org/');
@ -32,6 +33,11 @@ class OpdsFeed{
return sha1(preg_replace('/\s/ius', '', $output)); return sha1(preg_replace('/\s/ius', '', $output));
} }
catch(Exception $ex){
// Invalid XML
return '';
}
}
public function Save(string $filename): void{ public function Save(string $filename): void{
$updatedTimestamp = gmdate('Y-m-d\TH:i:s\Z'); $updatedTimestamp = gmdate('Y-m-d\TH:i:s\Z');

View file

@ -227,7 +227,10 @@ if [ "${verbose}" = "true" ]; then
printf "Rebuilding OPDS catalog ... " printf "Rebuilding OPDS catalog ... "
fi fi
bash -c "php \"${scriptsDir}\"/generate-opds.php --webroot \"${webRoot}\" --weburl \"${webUrl}\"" php "${scriptsDir}/generate-opds.php" --webroot "${webRoot}" --weburl "${webUrl}"
sudo chown se:committers /standardebooks.org/web/www/opds/*.xml
sudo chmod 664 /standardebooks.org/web/www/opds/*.xml
if [ "${verbose}" = "true" ]; then if [ "${verbose}" = "true" ]; then
printf "Done.\n" printf "Done.\n"

View file

@ -14,7 +14,7 @@ if(!isset($isCrawlable)){
print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
?> ?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:schema="http://schema.org/" xmlns:fh="http://purl.org/syndication/history/1.0"> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:schema="http://schema.org/"<? if($isCrawlable){ ?> xmlns:fh="http://purl.org/syndication/history/1.0"<? } ?>>
<id><?= $id ?></id> <id><?= $id ?></id>
<link href="<?= $url ?>" rel="self" type="application/atom+xml;profile=opds-catalog;kind=acquisition"/> <link href="<?= $url ?>" rel="self" type="application/atom+xml;profile=opds-catalog;kind=acquisition"/>
<link href="<?= SITE_URL ?>/opds" rel="start" type="application/atom+xml;profile=opds-catalog;kind=navigation"/> <link href="<?= SITE_URL ?>/opds" rel="start" type="application/atom+xml;profile=opds-catalog;kind=navigation"/>