Calibre OPDS (and HTML) PHP Server : web-based light alternative to Calibre content server / Calibre2OPDS to serve ebooks (epub, mobi, pdf, ...) http://blog.slucas.fr/en/oss/calibre-opds-php-server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

290 lines
9.4KB

  1. <?php
  2. /**
  3. * COPS (Calibre OPDS PHP Server) class file
  4. *
  5. * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
  6. * @author Sébastien Lucas <sebastien@slucas.fr>
  7. */
  8. if (!isset($config))
  9. $config = array();
  10. /*
  11. * The directory containing calibre's metadata.db file, with sub-directories
  12. * containing all the formats.
  13. * BEWARE : it has to end with a /
  14. * You can enable multiple database with this notation instead of a simple string :
  15. * $config['calibre_directory'] = array ("My database name" => "/home/directory/calibre1/", "My other database name" => "/home/directory/calibre2/");
  16. */
  17. $config['calibre_directory'] = './';
  18. /*
  19. * SPECIFIC TO NGINX
  20. * The internal directory set in nginx config file
  21. * Leave empty if you don't know what you're doing
  22. */
  23. $config['calibre_internal_directory'] = '';
  24. /*
  25. * Full URL prefix (with trailing /)
  26. * useful especially for Opensearch where a full URL is often required
  27. * For example Mantano, Aldiko and Marvin require it.
  28. */
  29. $config['cops_full_url'] = '';
  30. /*
  31. * Number of recent books to show
  32. */
  33. $config['cops_recentbooks_limit'] = '50';
  34. /*
  35. * Catalog's author name
  36. */
  37. $config['cops_author_name'] = "Sébastien Lucas";
  38. /*
  39. * Catalog's author uri
  40. */
  41. $config['cops_author_uri'] = "http://blog.slucas.fr";
  42. /*
  43. * Catalog's author email
  44. */
  45. $config['cops_author_email'] = "sebastien@slucas.fr";
  46. /*
  47. * Catalog's title
  48. */
  49. $config['cops_title_default'] = "COPS";
  50. /*
  51. * Catalog's subtitle
  52. */
  53. $config['cops_subtitle_default'] = "";
  54. /*
  55. * Wich header to use when downloading books outside the web directory
  56. * Possible values are :
  57. * X-Accel-Redirect : For Nginx
  58. * X-Sendfile : For Lightttpd or Apache (with mod_xsendfile)
  59. * No value (default) : Let PHP handle the download
  60. */
  61. $config['cops_x_accel_redirect'] = "";
  62. /*
  63. * Height of thumbnail image for OPDS
  64. */
  65. $config['cops_opds_thumbnail_height'] = "164";
  66. /*
  67. * Height of thumbnail image for HTML
  68. */
  69. $config['cops_html_thumbnail_height'] = "164";
  70. /*
  71. * Icon for both OPDS and HTML catalog
  72. * Note that this has to be a real icon (.ico)
  73. */
  74. $config['cops_icon'] = "favicon.ico";
  75. /*
  76. * Show icon for authors, series, tags and books on OPDS feed
  77. * 1 : enable
  78. * 0 : disable
  79. */
  80. $config['cops_show_icons'] = "1";
  81. /*
  82. * Default timezone
  83. * Check following link for other timezones :
  84. * http://www.php.net/manual/en/timezones.php
  85. */
  86. $config['default_timezone'] = "Europe/Paris";
  87. /*
  88. * Prefered format for HTML catalog
  89. * The two first will be displayed in book entries
  90. * The other only appear in book detail
  91. */
  92. $config['cops_prefered_format'] = array ("EPUB", "PDF", "AZW3", "AZW", "MOBI", "CBR", "CBZ");
  93. /*
  94. * use URL rewriting for downloading of ebook in HTML catalog
  95. * See Github wiki for more information
  96. * 1 : enable
  97. * 0 : disable
  98. */
  99. $config['cops_use_url_rewriting'] = "0";
  100. /*
  101. * generate a invalid OPDS stream to allow bad OPDS client to use search
  102. * Example of non compliant OPDS client : Moon+ Reader
  103. * Example of good OPDS client : Mantano, FBReader
  104. * 1 : enable support for non compliant OPDS client
  105. * 0 : always generate valid OPDS code
  106. */
  107. $config['cops_generate_invalid_opds_stream'] = "0";
  108. /*
  109. * Max number of items per page
  110. * -1 unlimited
  111. */
  112. $config['cops_max_item_per_page'] = "-1";
  113. /*
  114. * split authors by first letter
  115. * 1 : Yes
  116. * 0 : No
  117. */
  118. $config['cops_author_split_first_letter'] = "1";
  119. /*
  120. * split titles by first letter
  121. * 1 : Yes
  122. * 0 : No
  123. */
  124. $config['cops_titles_split_first_letter'] = "1";
  125. /*
  126. * Enable the Lightboxes (for popups)
  127. * 1 : Yes (enable)
  128. * 0 : No
  129. */
  130. $config['cops_use_fancyapps'] = "1";
  131. /*
  132. * Update Epub metadata before download
  133. * 1 : Yes (enable)
  134. * 0 : No
  135. */
  136. $config['cops_update_epub-metadata'] = "0";
  137. /*
  138. * Filter on tags to book list
  139. * Only works with the OPDS catalog
  140. * Usage : array ("I only want to see books using the tag : Tag1" => "Tag1",
  141. * "I only want to see books not using the tag : Tag1" => "!Tag1",
  142. * "I want to see every books" => "",
  143. *
  144. * Example : array ("All" => "", "Unread" => "!Read", "Read" => "Read")
  145. */
  146. $config['cops_books_filter'] = array ();
  147. /*
  148. * Custom Columns to add as an array containing the lookup names
  149. * configured in Calibre
  150. *
  151. * For example : array ("genre", "mycolumn");
  152. *
  153. * Note that for now only the first, second and forth type of custom columns are supported
  154. */
  155. $config['cops_calibre_custom_column'] = array ();
  156. /*
  157. * Rename .epub to .kepub.epub if downloaded from a Kobo eReader
  158. * The ebook will then be recognized a Kepub so with chaptered paging, statistics, ...
  159. * You have to enable URL rewriting if you want to enable kepup.epub download
  160. * 1 : Yes (enable)
  161. * 0 : No
  162. */
  163. $config['cops_provide_kepub'] = "0";
  164. /*
  165. * Enable and configure Send To Kindle (or Email) feature.
  166. *
  167. * Don't forget to authorize the sender email you configured in your Kindle's Approved Personal Document E-mail List.
  168. *
  169. * If you want to use a simple smtp server (provided by your ISP for example), you can configure it like that :
  170. * $config['cops_mail_configuration'] = array( "smtp.host" => "smtp.free.fr",
  171. * "smtp.username" => "",
  172. * "smtp.password" => "",
  173. * "smtp.secure" => "",
  174. * "address.from" => "cops@slucas.fr"
  175. * );
  176. *
  177. * For Gmail (ssl is mandatory) :
  178. * $config['cops_mail_configuration'] = array( "smtp.host" => "smtp.gmail.com",
  179. * "smtp.username" => "YOUR GMAIL ADRESS",
  180. * "smtp.password" => "YOUR GMAIL PASSWORD",
  181. * "smtp.secure" => "ssl",
  182. * "address.from" => "cops@slucas.fr"
  183. * );
  184. */
  185. $config['cops_mail_configuration'] = NULL;
  186. /*
  187. * Use filter in HTML catalog
  188. * 1 : Yes (enable)
  189. * 0 : No
  190. */
  191. $config['cops_html_tag_filter'] = "0";
  192. /*
  193. * Thumbnails are generated on-the-fly so it can be problematic on servers with slow CPU (Raspberry Pi, Dockstar, Piratebox, ...).
  194. * This configuration item allow to customize how thumbnail will be generated
  195. * "" : Generate thumbnail (CPU hungry)
  196. * "1" : always send the full size image (Network hungry)
  197. * any url : Send a constant image as the thumbnail (you can try "images/bookcover.png")
  198. */
  199. $config['cops_thumbnail_handling'] = "";
  200. /*
  201. * Contains a list of user agent for browsers not compatible with client side rendering
  202. * For now : Kindle, Sony PRS-T1, Sony PRS-T2, All Cybook devices (maybe a little extreme).
  203. * This item is used as regular expression so "." will force server side rendering for all devices
  204. */
  205. $config['cops_server_side_render'] = "Kindle\/1\.0|Kindle\/2\.0|Kindle\/3\.0|EBRD1101|EBRD1201|cybook";
  206. /*
  207. * Specify the ignored categories for the home screen and with search
  208. * Meaning that if you don't want to search in publishers or tags just add them from the list
  209. * Only accepted values :
  210. * - author
  211. * - book
  212. * - series
  213. * - tag
  214. * - publisher
  215. * - rating
  216. * - language
  217. */
  218. $config ['cops_ignored_categories'] = array ();
  219. /*
  220. * If you use a Sony eReader or Aldiko you can't download ebooks if your catalog
  221. * is password protected. A simple workaround is to leave fetch.php not protected (see .htaccess).
  222. * But In that case your COPS installation is not completely safe.
  223. * Setting this parameter to "1" ensure that nobody can access fetch.php before accessing
  224. * index.php or feed.php first.
  225. * BEWARE : Do not touch this if you're not using password, not using PRS-TX or not using Aldiko.
  226. */
  227. $config ['cops_fetch_protect'] = "0";
  228. /*
  229. * WARNING NOT READY FOR PRODUCTION USE
  230. * Make the search better (don't care about diacritics, uppercase should work on Cyrillic) but slower.
  231. * 1 : Yes (enable)
  232. * 0 : No
  233. */
  234. $config ['cops_normalized_search'] = "0";
  235. /*
  236. * Enable PHP password protection (You can use if htpasswd is not possible for you)
  237. * If possible prefer htpasswd !
  238. * array( "username" => "xxx", "password" => "secret") : Enable PHP password protection
  239. * NULL : Disable PHP password protection (You can still use htpasswd)
  240. */
  241. $config['cops_basic_authentication'] = NULL;
  242. /*
  243. * Which template is used by default :
  244. * 'default'
  245. * 'bootstrap'
  246. */
  247. $config['cops_template'] = 'default';
  248. /*
  249. * Set language code to force a language (see lang/ directory for available languages).
  250. * When empty it will auto detect the language.
  251. */
  252. $config['cops_language'] = '';