Add an additionnal protection for Sony PRS-T2 / Aldiko. fix #120

This commit is contained in:
Sébastien Lucas 2013-12-10 21:34:19 +01:00
parent 2a20fa688e
commit da5ec2583a
5 changed files with 35 additions and 1 deletions

View file

@ -65,7 +65,7 @@ ExpiresByType text/javascript "access plus 1 year"
# You can try replacing the FilesMatch directive by this one # You can try replacing the FilesMatch directive by this one
# <FilesMatch "(index|feed)\.php"> # <FilesMatch "(index|feed)\.php">
# If helps for Sony PRS-TX and Aldiko, beware fetch.php can be accessed # If helps for Sony PRS-TX and Aldiko, beware fetch.php can be accessed
# with authentication # with authentication (see $config ['cops_fetch_protect'] for a workaround).
########################################### ###########################################
#<FilesMatch "\.php$"> #<FilesMatch "\.php$">
#AuthUserFile /path/to/file #AuthUserFile /path/to/file

View file

@ -246,3 +246,13 @@
* - publisher * - publisher
*/ */
$config ['cops_ignored_search_scope'] = array (); $config ['cops_ignored_search_scope'] = array ();
/*
* If you use a Sony eReader or Aldiko you can't download ebooks if your catalog
* is password protected. A simple workaround is to leave fetch.php not protected (see .htaccess).
* But In that case your COPS installation is not completely safe.
* Setting this parameter to "1" ensure that nobody can access fetch.php before accessing
* index.php or feed.php first.
* BEWARE : Do not touch this if you're not using password, not using PRS-TX or not using Aldiko.
*/
$config ['cops_fetch_protect'] = "0";

View file

@ -23,6 +23,13 @@
$page = Base::PAGE_OPENSEARCH_QUERY; $page = Base::PAGE_OPENSEARCH_QUERY;
$qid = getURLParam ("id"); $qid = getURLParam ("id");
if ($config ['cops_fetch_protect'] == "1") {
session_start();
if (!isset($_SESSION['connected'])) {
$_SESSION['connected'] = 0;
}
}
$OPDSRender = new OPDSRenderer (); $OPDSRender = new OPDSRenderer ();
switch ($page) { switch ($page) {

View file

@ -17,6 +17,14 @@ function notFound () {
$_SERVER['REDIRECT_STATUS'] = 404; $_SERVER['REDIRECT_STATUS'] = 404;
} }
if ($config ['cops_fetch_protect'] == "1") {
session_start();
if (!isset($_SESSION['connected'])) {
notFound ();
return;
}
}
global $config; global $config;
$expires = 60*60*24*14; $expires = 60*60*24*14;
header("Pragma: public"); header("Pragma: public");

View file

@ -44,6 +44,13 @@
$test = Base::getDb (); $test = Base::getDb ();
} }
if ($config ['cops_fetch_protect'] == "1") {
session_start();
if (!isset($_SESSION['connected'])) {
$_SESSION['connected'] = 0;
}
}
header ("Content-Type:text/html;charset=utf-8"); header ("Content-Type:text/html;charset=utf-8");
?><!DOCTYPE html> ?><!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
@ -55,6 +62,8 @@
<link rel="apple-touch-icon" sizes="72x72" href="./icons/icon72.png" /> <link rel="apple-touch-icon" sizes="72x72" href="./icons/icon72.png" />
<link rel="apple-touch-icon" sizes="114x114" href="./icons/icon114.png" /> <link rel="apple-touch-icon" sizes="114x114" href="./icons/icon114.png" />
<link rel="apple-touch-icon" sizes="144x144" href="./icons/icon144.png" /> <link rel="apple-touch-icon" sizes="144x144" href="./icons/icon144.png" />
<meta name="msapplication-TileColor" content="#123456"/>
<meta name="msapplication-TileImage" content="./icons/icon144.png"/>
<title>COPS</title> <title>COPS</title>