@@ -49,8 +49,7 @@ |
||
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - switch ($type) |
|
| 53 | - { |
|
| 52 | + switch ($type) { |
|
| 54 | 53 | case 'jpg': |
| 55 | 54 | header('Content-Type: image/jpeg'); |
| 56 | 55 | //by default, we don't cache |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | header('Pragma: public'); |
| 24 | 24 | header('Cache-Control: max-age=' . $expires); |
| 25 | 25 | header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT'); |
| 26 | - $bookId = getURLParam('id', NULL); |
|
| 26 | + $bookId = getURLParam('id', null); |
|
| 27 | 27 | $type = getURLParam('type', 'jpg'); |
| 28 | - $idData = getURLParam('data', NULL); |
|
| 29 | - $viewOnly = getURLParam('view', FALSE); |
|
| 28 | + $idData = getURLParam('data', null); |
|
| 29 | + $viewOnly = getURLParam('view', false); |
|
| 30 | 30 | |
| 31 | 31 | if (is_null($bookId)) { |
| 32 | 32 | $book = Book::getBookByDataId($idData); |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | // clean output buffers before sending the ebook data do avoid high memory usage on big ebooks (ie. comic books) |
| 22 | 22 | ob_end_clean(); |
| 23 | 23 | |
| 24 | - $expires = 60*60*24*14; |
|
| 24 | + $expires = 60 * 60 * 24 * 14; |
|
| 25 | 25 | header('Pragma: public'); |
| 26 | 26 | header('Cache-Control: max-age=' . $expires); |
| 27 | - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT'); |
|
| 27 | + header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); |
|
| 28 | 28 | $bookId = getURLParam('id', NULL); |
| 29 | 29 | $type = getURLParam('type', 'jpg'); |
| 30 | 30 | $idData = getURLParam('data', NULL); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | if (!$book) { |
| 40 | - notFound (); |
|
| 40 | + notFound(); |
|
| 41 | 41 | return; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -59,15 +59,15 @@ discard block |
||
| 59 | 59 | header('Content-Type: image/jpeg'); |
| 60 | 60 | //by default, we don't cache |
| 61 | 61 | $thumbnailCacheFullpath = null; |
| 62 | - if ( isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '' ) { |
|
| 62 | + if (isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '') { |
|
| 63 | 63 | $thumbnailCacheFullpath = $config['cops_thumbnail_cache_directory']; |
| 64 | 64 | //if multiple databases, add a subfolder with the database ID |
| 65 | - $thumbnailCacheFullpath .= !is_null(GetUrlParam (DB)) ? 'db-' . GetUrlParam (DB) . DIRECTORY_SEPARATOR : ''; |
|
| 65 | + $thumbnailCacheFullpath .= !is_null(GetUrlParam(DB))?'db-' . GetUrlParam(DB) . DIRECTORY_SEPARATOR:''; |
|
| 66 | 66 | //when there are lots of thumbnails, it's better to save files in subfolders, so if the book's uuid is |
| 67 | 67 | //"01234567-89ab-cdef-0123-456789abcdef", we will save the thumbnail in .../0/12/34567-89ab-cdef-0123-456789abcdef-... |
| 68 | 68 | $thumbnailCacheFullpath .= substr($book->uuid, 0, 1) . DIRECTORY_SEPARATOR . substr($book->uuid, 1, 2) . DIRECTORY_SEPARATOR; |
| 69 | 69 | //check if cache folder exists or create it |
| 70 | - if ( file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true) ) { |
|
| 70 | + if (file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true)) { |
|
| 71 | 71 | //we name the thumbnail from the book's uuid and it's dimensions (width and/or height) |
| 72 | 72 | $thumbnailCacheName = substr($book->uuid, 3) . '-' . getURLParam('width') . 'x' . getURLParam('height') . '.jpg'; |
| 73 | 73 | $thumbnailCacheFullpath = $thumbnailCacheFullpath . $thumbnailCacheName; |
@@ -77,20 +77,20 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if ( $thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath) ) { |
|
| 80 | + if ($thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath)) { |
|
| 81 | 81 | //return the already cached thumbnail |
| 82 | - readfile( $thumbnailCacheFullpath ); |
|
| 82 | + readfile($thumbnailCacheFullpath); |
|
| 83 | 83 | return; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if ($book->getThumbnail (getURLParam('width'), getURLParam('height'), $thumbnailCacheFullpath)) { |
|
| 86 | + if ($book->getThumbnail(getURLParam('width'), getURLParam('height'), $thumbnailCacheFullpath)) { |
|
| 87 | 87 | //if we don't cache the thumbnail, imagejpeg() in $book->getThumbnail() already return the image data |
| 88 | - if ( $thumbnailCacheFullpath === null ) { |
|
| 88 | + if ($thumbnailCacheFullpath === null) { |
|
| 89 | 89 | // The cover had to be resized |
| 90 | 90 | return; |
| 91 | 91 | } else { |
| 92 | 92 | //return the just cached thumbnail |
| 93 | - readfile( $thumbnailCacheFullpath ); |
|
| 93 | + readfile($thumbnailCacheFullpath); |
|
| 94 | 94 | return; |
| 95 | 95 | } |
| 96 | 96 | } |