Benefits->CanAccessFeeds){ throw new Exceptions\InvalidPermissionsException(); } } } // Everything OK, serve the file using Apache. // The xsendfile Apache module tells Apache to serve the file, including not-modified or etag headers. // 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'); if(preg_match('/\/index\.xml$/', $path)){ header('Content-Type: application/atom+xml;profile=opds-catalog;kind=navigation; charset=utf-8'); } } elseif(preg_match('/^\/feeds\/rss/', $path)){ header('Content-Type: application/rss+xml'); } elseif(preg_match('/^\/feeds\/atom/', $path)){ header('Content-Type: application/atom+xml'); } exit(); } catch(Exceptions\LoginRequiredException $ex){ header('WWW-Authenticate: Basic realm="Enter your Patrons Circle email address and leave the password empty."'); http_response_code(401); } catch(Exceptions\InvalidPermissionsException $ex){ http_response_code(403); } catch(Exceptions\InvalidFileException $ex){ Template::Emit404(); } // Print the login info page include(WEB_ROOT . '/feeds/401.php');