diff --git a/composer.json b/composer.json index ecda0b4e..639dd4ad 100644 --- a/composer.json +++ b/composer.json @@ -8,13 +8,14 @@ "files": ["lib/Constants.php", "lib/CoreFunctions.php"] }, "platform":{ - "php": "7.2.24" + "php": "8.1.2" }, "require": { "thecodingmachine/safe": "^1.3.3", "phpmailer/phpmailer": "^6.6.0", "ramsey/uuid": "4.2.3", "gregwar/captcha": "^1.1.9", - "php-webdriver/webdriver": "^1.12.1" + "php-webdriver/webdriver": "^1.12.1", + "pear/http2": "^2.0.0" } } diff --git a/composer.lock b/composer.lock index 7c7aea55..4a4df5d1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0a100c86bc1d94d7883ed56c9e3304fa", + "content-hash": "c3a2ec797ba64706306394cca97dd37e", "packages": [ { "name": "brick/math", @@ -50,6 +50,10 @@ "brick", "math" ], + "support": { + "issues": "https://github.com/brick/math/issues", + "source": "https://github.com/brick/math/tree/0.9.3" + }, "funding": [ { "url": "https://github.com/BenMorel", @@ -64,16 +68,16 @@ }, { "name": "gregwar/captcha", - "version": "v1.1.9", + "version": "v1.2.0", "source": { "type": "git", "url": "https://github.com/Gregwar/Captcha.git", - "reference": "4bb668e6b40e3205a020ca5ee4ca8cff8b8780c5" + "reference": "6e5b61b66ac89885b505153f4ef9a74ffa5b3074" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Gregwar/Captcha/zipball/4bb668e6b40e3205a020ca5ee4ca8cff8b8780c5", - "reference": "4bb668e6b40e3205a020ca5ee4ca8cff8b8780c5", + "url": "https://api.github.com/repos/Gregwar/Captcha/zipball/6e5b61b66ac89885b505153f4ef9a74ffa5b3074", + "reference": "6e5b61b66ac89885b505153f4ef9a74ffa5b3074", "shasum": "" }, "require": { @@ -85,7 +89,7 @@ "require-dev": { "phpunit/phpunit": "^6.4" }, - "type": "captcha", + "type": "library", "autoload": { "psr-4": { "Gregwar\\": "src/Gregwar" @@ -113,41 +117,93 @@ "captcha", "spam" ], - "time": "2020-03-24T14:39:05+00:00" + "support": { + "issues": "https://github.com/Gregwar/Captcha/issues", + "source": "https://github.com/Gregwar/Captcha/tree/v1.2.0" + }, + "time": "2023-03-24T22:12:41+00:00" }, { - "name": "php-webdriver/webdriver", - "version": "1.13.1", + "name": "pear/http2", + "version": "v2.0.0", "source": { "type": "git", - "url": "https://github.com/php-webdriver/php-webdriver.git", - "reference": "6dfe5f814b796c1b5748850aa19f781b9274c36c" + "url": "https://github.com/pear/HTTP2.git", + "reference": "72e15b4faa86f6109c6fc3aa82c5515b6453b3b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/6dfe5f814b796c1b5748850aa19f781b9274c36c", - "reference": "6dfe5f814b796c1b5748850aa19f781b9274c36c", + "url": "https://api.github.com/repos/pear/HTTP2/zipball/72e15b4faa86f6109c6fc3aa82c5515b6453b3b5", + "reference": "72e15b4faa86f6109c6fc3aa82c5515b6453b3b5", + "shasum": "" + }, + "require-dev": { + "phpunit/phpunit": "^9" + }, + "type": "library", + "autoload": { + "psr-0": { + "HTTP2": "./" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Michael Wallner", + "email": "mike@php.net", + "role": "Lead" + }, + { + "name": "Philippe Jausions", + "email": "jausions@php.net", + "role": "Lead" + } + ], + "description": "Miscellaneous HTTP utilities", + "homepage": "http://pear.php.net/package/HTTP2", + "support": { + "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=HTTP2", + "source": "https://github.com/pear/HTTP2" + }, + "time": "2023-03-22T20:22:11+00:00" + }, + { + "name": "php-webdriver/webdriver", + "version": "1.14.0", + "source": { + "type": "git", + "url": "https://github.com/php-webdriver/php-webdriver.git", + "reference": "3ea4f924afb43056bf9c630509e657d951608563" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/3ea4f924afb43056bf9c630509e657d951608563", + "reference": "3ea4f924afb43056bf9c630509e657d951608563", "shasum": "" }, "require": { "ext-curl": "*", "ext-json": "*", "ext-zip": "*", - "php": "^5.6 || ~7.0 || ^8.0", + "php": "^7.3 || ^8.0", "symfony/polyfill-mbstring": "^1.12", - "symfony/process": "^2.8 || ^3.1 || ^4.0 || ^5.0 || ^6.0" + "symfony/process": "^5.0 || ^6.0" }, "replace": { "facebook/webdriver": "*" }, "require-dev": { - "ondram/ci-detector": "^2.1 || ^3.5 || ^4.0", + "ergebnis/composer-normalize": "^2.20.0", + "ondram/ci-detector": "^4.0", "php-coveralls/php-coveralls": "^2.4", - "php-mock/php-mock-phpunit": "^1.1 || ^2.0", + "php-mock/php-mock-phpunit": "^2.0", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpunit/phpunit": "^5.7 || ^7 || ^8 || ^9", + "phpunit/phpunit": "^9.3", "squizlabs/php_codesniffer": "^3.5", - "symfony/var-dumper": "^3.3 || ^4.0 || ^5.0 || ^6.0" + "symfony/var-dumper": "^5.0 || ^6.0" }, "suggest": { "ext-SimpleXML": "For Firefox profile creation" @@ -174,20 +230,24 @@ "selenium", "webdriver" ], - "time": "2022-10-11T11:49:44+00:00" + "support": { + "issues": "https://github.com/php-webdriver/php-webdriver/issues", + "source": "https://github.com/php-webdriver/php-webdriver/tree/1.14.0" + }, + "time": "2023-02-09T12:12:19+00:00" }, { "name": "phpmailer/phpmailer", - "version": "v6.7.1", + "version": "v6.8.0", "source": { "type": "git", "url": "https://github.com/PHPMailer/PHPMailer.git", - "reference": "49cd7ea3d2563f028d7811f06864a53b1f15ff55" + "reference": "df16b615e371d81fb79e506277faea67a1be18f1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/49cd7ea3d2563f028d7811f06864a53b1f15ff55", - "reference": "49cd7ea3d2563f028d7811f06864a53b1f15ff55", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/df16b615e371d81fb79e506277faea67a1be18f1", + "reference": "df16b615e371d81fb79e506277faea67a1be18f1", "shasum": "" }, "require": { @@ -244,26 +304,30 @@ } ], "description": "PHPMailer is a full-featured email creation and transfer class for PHP", + "support": { + "issues": "https://github.com/PHPMailer/PHPMailer/issues", + "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.8.0" + }, "funding": [ { "url": "https://github.com/Synchro", "type": "github" } ], - "time": "2022-12-08T13:30:06+00:00" + "time": "2023-03-06T14:43:22+00:00" }, { "name": "ramsey/collection", - "version": "1.2.2", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/ramsey/collection.git", - "reference": "cccc74ee5e328031b15640b51056ee8d3bb66c0a" + "reference": "ad7475d1c9e70b190ecffc58f2d989416af339b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/collection/zipball/cccc74ee5e328031b15640b51056ee8d3bb66c0a", - "reference": "cccc74ee5e328031b15640b51056ee8d3bb66c0a", + "url": "https://api.github.com/repos/ramsey/collection/zipball/ad7475d1c9e70b190ecffc58f2d989416af339b4", + "reference": "ad7475d1c9e70b190ecffc58f2d989416af339b4", "shasum": "" }, "require": { @@ -326,6 +390,10 @@ "queue", "set" ], + "support": { + "issues": "https://github.com/ramsey/collection/issues", + "source": "https://github.com/ramsey/collection/tree/1.3.0" + }, "funding": [ { "url": "https://github.com/ramsey", @@ -356,7 +424,7 @@ "brick/math": "^0.8 || ^0.9", "ext-json": "*", "php": "^7.2 || ^8.0", - "ramsey/collection": "1.2.2", + "ramsey/collection": "^1.0", "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-php80": "^1.14" }, @@ -420,6 +488,10 @@ "identifier", "uuid" ], + "support": { + "issues": "https://github.com/ramsey/uuid/issues", + "source": "https://github.com/ramsey/uuid/tree/4.2.3" + }, "funding": [ { "url": "https://github.com/ramsey", @@ -432,88 +504,25 @@ ], "time": "2021-09-25T23:10:38+00:00" }, - { - "name": "symfony/deprecation-contracts", - "version": "v2.5.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-01-02T09:53:40+00:00" - }, { "name": "symfony/finder", - "version": "v5.4.19", + "version": "v6.3.0", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "6071aebf810ad13fe8200c224f36103abb37cf1f" + "reference": "d9b01ba073c44cef617c7907ce2419f8d00d75e2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/6071aebf810ad13fe8200c224f36103abb37cf1f", - "reference": "6071aebf810ad13fe8200c224f36103abb37cf1f", + "url": "https://api.github.com/repos/symfony/finder/zipball/d9b01ba073c44cef617c7907ce2419f8d00d75e2", + "reference": "d9b01ba073c44cef617c7907ce2419f8d00d75e2", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php80": "^1.16" + "php": ">=8.1" + }, + "require-dev": { + "symfony/filesystem": "^6.0" }, "type": "library", "autoload": { @@ -540,6 +549,9 @@ ], "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/finder/tree/v6.3.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -554,7 +566,7 @@ "type": "tidelift" } ], - "time": "2023-01-14T19:14:44+00:00" + "time": "2023-04-02T01:25:41+00:00" }, { "name": "symfony/polyfill-ctype", @@ -619,6 +631,9 @@ "polyfill", "portable" ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -699,6 +714,9 @@ "portable", "shim" ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -779,6 +797,9 @@ "portable", "shim" ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -855,6 +876,9 @@ "portable", "shim" ], + "support": { + "source": "https://github.com/symfony/polyfill-php81/tree/v1.27.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -873,21 +897,20 @@ }, { "name": "symfony/process", - "version": "v5.4.19", + "version": "v6.3.0", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "c5ba874c9b636dbccf761e22ce750e88ec3f55e1" + "reference": "8741e3ed7fe2e91ec099e02446fb86667a0f1628" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/c5ba874c9b636dbccf761e22ce750e88ec3f55e1", - "reference": "c5ba874c9b636dbccf761e22ce750e88ec3f55e1", + "url": "https://api.github.com/repos/symfony/process/zipball/8741e3ed7fe2e91ec099e02446fb86667a0f1628", + "reference": "8741e3ed7fe2e91ec099e02446fb86667a0f1628", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/polyfill-php80": "^1.16" + "php": ">=8.1" }, "type": "library", "autoload": { @@ -914,6 +937,9 @@ ], "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/process/tree/v6.3.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -928,7 +954,7 @@ "type": "tidelift" } ], - "time": "2023-01-01T08:32:19+00:00" + "time": "2023-05-19T08:06:44+00:00" }, { "name": "thecodingmachine/safe", @@ -1063,22 +1089,26 @@ "MIT" ], "description": "PHP core functions that throw exceptions instead of returning FALSE on error", + "support": { + "issues": "https://github.com/thecodingmachine/safe/issues", + "source": "https://github.com/thecodingmachine/safe/tree/v1.3.3" + }, "time": "2020-10-28T17:51:34+00:00" } ], "packages-dev": [ { "name": "phpstan/phpstan", - "version": "1.9.14", + "version": "1.10.20", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "e5fcc96289cf737304286a9b505fbed091f02e58" + "reference": "c4c8adb56313fbd59ff5a5f4a496bbed1a6b8803" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e5fcc96289cf737304286a9b505fbed091f02e58", - "reference": "e5fcc96289cf737304286a9b505fbed091f02e58", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c4c8adb56313fbd59ff5a5f4a496bbed1a6b8803", + "reference": "c4c8adb56313fbd59ff5a5f4a496bbed1a6b8803", "shasum": "" }, "require": { @@ -1106,6 +1136,13 @@ "dev", "static analysis" ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, "funding": [ { "url": "https://github.com/ondrejmirtes", @@ -1120,7 +1157,7 @@ "type": "tidelift" } ], - "time": "2023-01-19T10:47:09+00:00" + "time": "2023-06-20T12:07:40+00:00" }, { "name": "thecodingmachine/phpstan-safe-rule", @@ -1173,6 +1210,10 @@ } ], "description": "A PHPStan rule to detect safety issues. Must be used in conjunction with thecodingmachine/safe", + "support": { + "issues": "https://github.com/thecodingmachine/phpstan-safe-rule/issues", + "source": "https://github.com/thecodingmachine/phpstan-safe-rule/tree/v1.2.0" + }, "time": "2022-01-17T10:12:29+00:00" } ], @@ -1183,5 +1224,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.3.0" } diff --git a/config/apache/standardebooks.org.conf b/config/apache/standardebooks.org.conf index 305b5bcd..aa26ed81 100644 --- a/config/apache/standardebooks.org.conf +++ b/config/apache/standardebooks.org.conf @@ -309,14 +309,4 @@ Define webroot /standardebooks.org/web XSendFile on XSendFilePath /standardebooks.org/web/www/feeds - - # Emit content-types for RSS/Atom feeds - rss|atom)/.+"> - # Note the trailing e is required to complete the environmental variable reference - Header set Content-Type "application/%{MATCH_FEEDTYPE}e+xml; charset=utf-8" - - - Header set Content-Type "application/xhtml+xml; charset=utf-8" - - diff --git a/config/apache/standardebooks.test.conf b/config/apache/standardebooks.test.conf index f3d7d099..35cab4ed 100644 --- a/config/apache/standardebooks.test.conf +++ b/config/apache/standardebooks.test.conf @@ -291,14 +291,4 @@ Define webroot /standardebooks.org/web XSendFile on XSendFilePath /standardebooks.org/web/www/feeds - - # Emit content-types for RSS/Atom feeds - rss|atom)/.+"> - # Note the trailing e is required to complete the environmental variable reference - Header set Content-Type "application/%{MATCH_FEEDTYPE}e+xml; charset=utf-8" - - - Header set Content-Type "application/xhtml+xml; charset=utf-8" - - diff --git a/www/feeds/atom/style.php b/www/feeds/atom/style.php index 9656347f..83111d9f 100644 --- a/www/feeds/atom/style.php +++ b/www/feeds/atom/style.php @@ -1,8 +1,17 @@ negotiateMimeType($contentType, 'application/xslt+xml'); + +header('Content-Type: ' . $mime . '; charset=utf-8'); print("\n") ?> @@ -19,7 +28,7 @@ print("\n")

-

This page is an Atom 1.0 feed. The URL in your browser’s address bar () can be used in any Atom client.

+

This page is an Atom 1.0 feed. The URL in your browser’s address bar () can be used in any Atom client. If you’re prompted to authenticate, enter the email address you used to join the Patrons Circle and a blank password.

  1. diff --git a/www/feeds/download.php b/www/feeds/download.php index 05f05487..bc27581e 100644 --- a/www/feeds/download.php +++ b/www/feeds/download.php @@ -54,20 +54,49 @@ try{ // Much more efficient than reading it in PHP and outputting it that way. header('X-Sendfile: ' . WEB_ROOT . $path); - if(preg_match('/^\/feeds\/opds/', $path)){ - header('Content-Type: application/atom+xml;profile=opds-catalog;kind=acquisition; charset=utf-8'); + $http = new HTTP2(); + $mime = 'application/xml'; - if(preg_match('/\/index\.xml$/', $path)){ - header('Content-Type: application/atom+xml;profile=opds-catalog;kind=navigation; charset=utf-8'); + // Decide on what content-type to serve via HTTP content negotation. + // If the feed is viewed from a web browser, we will usuall serve application/xml as that's typically what's in the browser's Accept header. + // If the Accept header has application/rss+xml or application/atom+xml then serve that instead, as those are the + // "technically correct" content types that may be requested by RSS readers. + if(preg_match('/^\/feeds\/opds/', $path)){ + $contentType = [ + 'application/atom+xml', + 'application/xml', + 'text/xml' + ]; + $mime = $http->negotiateMimeType($contentType, 'application/atom+xml'); + + if($mime == 'application/atom+xml'){ + if(preg_match('/\/index\.xml$/', $path)){ + $mime .= ';profile=opds-catalog;kind=navigation; charset=utf-8'; + } + else{ + $mime .= ';profile=opds-catalog;kind=acquisition; charset=utf-8'; + } } } elseif(preg_match('/^\/feeds\/rss/', $path)){ - header('Content-Type: application/rss+xml'); + $contentType = [ + 'application/rss+xml', + 'application/xml', + 'text/xml' + ]; + $mime = $http->negotiateMimeType($contentType, 'application/rss+xml'); } elseif(preg_match('/^\/feeds\/atom/', $path)){ - header('Content-Type: application/atom+xml'); + $contentType = [ + 'application/atom+xml', + 'application/xml', + 'text/xml' + ]; + $mime = $http->negotiateMimeType($contentType, 'application/atom+xml'); } + header('Content-Type: ' . $mime); + exit(); } catch(Exceptions\LoginRequiredException){ diff --git a/www/feeds/opds/style.php b/www/feeds/opds/style.php index ff18768f..e8fd0709 100644 --- a/www/feeds/opds/style.php +++ b/www/feeds/opds/style.php @@ -1,8 +1,17 @@ negotiateMimeType($contentType, 'application/xslt+xml'); + +header('Content-Type: ' . $mime . '; charset=utf-8'); print("\n") ?> @@ -19,7 +28,7 @@ print("\n")

    -

    This page is an OPDS 1.2 feed. The URL in your browser’s address bar () can be used in any OPDS client.

    +

    This page is an OPDS 1.2 feed. The URL in your browser’s address bar () can be used in any OPDS client. If you’re prompted to authenticate, enter the email address you used to join the Patrons Circle and a blank password.

      diff --git a/www/feeds/rss/style.php b/www/feeds/rss/style.php index b5d5cc2d..1d60ddca 100644 --- a/www/feeds/rss/style.php +++ b/www/feeds/rss/style.php @@ -1,8 +1,17 @@ negotiateMimeType($contentType, 'application/xslt+xml'); + +header('Content-Type: ' . $mime . '; charset=utf-8'); print("\n") ?> @@ -19,7 +28,7 @@ print("\n")

      -

      This page is an RSS 2.0 feed. The URL in your browser’s address bar () can be used in any RSS reader.

      +

      This page is an RSS 2.0 feed. The URL in your browser’s address bar () can be used in any RSS reader. If you’re prompted to authenticate, enter the email address you used to join the Patrons Circle and a blank password.