4 Provides access to preview images of book. It is run with privileges and provides a reduced
5 access wrapper around BookReaderImages.
7 Michael Ang <http://github.com/mangtronix>
9 Copyright (c) 2010 Internet Archive. Software license AGPL version 3.
11 This file is part of BookReader.
13 BookReader is free software: you can redistribute it and/or modify
14 it under the terms of the GNU Affero General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
18 BookReader is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU Affero General Public License for more details.
23 You should have received a copy of the GNU Affero General Public License
24 along with BookReader. If not, see <http://www.gnu.org/licenses/>.
27 require_once('BookReaderImages.inc.php');
29 function BRfatal($message) {
30 header("HTTP/1.0 404 Not Found");
31 header("Content-type: text/plain");
36 $allowedPages = array('title','cover','preview');
37 $allowedPattern = '#^(' . join('|', $allowedPages) . ')#';
39 $page = $_REQUEST['page'];
41 if (preg_match($allowedPattern, $page)) {
43 $bri = new BookReaderImages();
46 $bri->serveLookupRequest($_REQUEST);
47 } catch (Exception $e) {
48 header("HTTP/1.0 404 Not Found");
49 header("Content-type: text/plain");
51 print "Error serving request:\n";
52 print " " . $e->getMessage() . "\n\n";
53 print "Debugging information:\n";
54 echo $e->getTraceAsString();
57 BRfatal("Bad or no page specified");