@@ -19,10 +19,10 @@ discard block |
||
| 19 | 19 | } |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - $expires = 60*60*24*14; |
|
| 22 | + $expires = 60 * 60 * 24 * 14; |
|
| 23 | 23 | header('Pragma: public'); |
| 24 | 24 | header('Cache-Control: max-age=' . $expires); |
| 25 | - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT'); |
|
| 25 | + header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); |
|
| 26 | 26 | $bookId = getURLParam('id', NULL); |
| 27 | 27 | $type = getURLParam('type', 'jpg'); |
| 28 | 28 | $idData = getURLParam('data', NULL); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | if (!$book) { |
| 36 | - notFound (); |
|
| 36 | + notFound(); |
|
| 37 | 37 | return; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -55,15 +55,15 @@ discard block |
||
| 55 | 55 | header('Content-Type: image/jpeg'); |
| 56 | 56 | //by default, we don't cache |
| 57 | 57 | $thumbnailCacheFullpath = null; |
| 58 | - if ( isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '' ) { |
|
| 58 | + if (isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '') { |
|
| 59 | 59 | $thumbnailCacheFullpath = $config['cops_thumbnail_cache_directory']; |
| 60 | 60 | //if multiple databases, add a subfolder with the database ID |
| 61 | - $thumbnailCacheFullpath .= !is_null(GetUrlParam (DB)) ? 'db-' . GetUrlParam (DB) . DIRECTORY_SEPARATOR : ''; |
|
| 61 | + $thumbnailCacheFullpath .= !is_null(GetUrlParam(DB))?'db-' . GetUrlParam(DB) . DIRECTORY_SEPARATOR:''; |
|
| 62 | 62 | //when there are lots of thumbnails, it's better to save files in subfolders, so if the book's uuid is |
| 63 | 63 | //"01234567-89ab-cdef-0123-456789abcdef", we will save the thumbnail in .../0/12/34567-89ab-cdef-0123-456789abcdef-... |
| 64 | 64 | $thumbnailCacheFullpath .= substr($book->uuid, 0, 1) . DIRECTORY_SEPARATOR . substr($book->uuid, 1, 2) . DIRECTORY_SEPARATOR; |
| 65 | 65 | //check if cache folder exists or create it |
| 66 | - if ( file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true) ) { |
|
| 66 | + if (file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true)) { |
|
| 67 | 67 | //we name the thumbnail from the book's uuid and it's dimensions (width and/or height) |
| 68 | 68 | $thumbnailCacheName = substr($book->uuid, 3) . '-' . getURLParam('width') . 'x' . getURLParam('height') . '.jpg'; |
| 69 | 69 | $thumbnailCacheFullpath = $thumbnailCacheFullpath . $thumbnailCacheName; |
@@ -73,20 +73,20 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - if ( $thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath) ) { |
|
| 76 | + if ($thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath)) { |
|
| 77 | 77 | //return the already cached thumbnail |
| 78 | - readfile( $thumbnailCacheFullpath ); |
|
| 78 | + readfile($thumbnailCacheFullpath); |
|
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if ($book->getThumbnail (getURLParam('width'), getURLParam('height'), $thumbnailCacheFullpath)) { |
|
| 82 | + if ($book->getThumbnail(getURLParam('width'), getURLParam('height'), $thumbnailCacheFullpath)) { |
|
| 83 | 83 | //if we don't cache the thumbnail, imagejpeg() in $book->getThumbnail() already return the image data |
| 84 | - if ( $thumbnailCacheFullpath === null ) { |
|
| 84 | + if ($thumbnailCacheFullpath === null) { |
|
| 85 | 85 | // The cover had to be resized |
| 86 | 86 | return; |
| 87 | 87 | } else { |
| 88 | 88 | //return the just cached thumbnail |
| 89 | - readfile( $thumbnailCacheFullpath ); |
|
| 89 | + readfile($thumbnailCacheFullpath); |
|
| 90 | 90 | return; |
| 91 | 91 | } |
| 92 | 92 | } |
@@ -23,9 +23,9 @@ |
||
| 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); |
|
| 28 | + $idData = getURLParam('data', null); |
|
| 29 | 29 | if (is_null($bookId)) { |
| 30 | 30 | $book = Book::getBookByDataId($idData); |
| 31 | 31 | } else { |