@@ -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: maxage=' . $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 | } |
@@ -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,9 +23,9 @@ |
||
| 23 | 23 | header('Pragma: public'); |
| 24 | 24 | header('Cache-Control: maxage=' . $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 { |
@@ -149,7 +149,9 @@ discard block |
||
| 149 | 149 | $errors = libxml_get_errors(); |
| 150 | 150 | |
| 151 | 151 | foreach ($errors as $error) { |
| 152 | - if ($error->code == 801) return false; |
|
| 152 | + if ($error->code == 801) { |
|
| 153 | + return false; |
|
| 154 | + } |
|
| 153 | 155 | } |
| 154 | 156 | return true; |
| 155 | 157 | } |
@@ -175,7 +177,9 @@ discard block |
||
| 175 | 177 | } |
| 176 | 178 | */ |
| 177 | 179 | |
| 178 | - if (!are_libxml_errors_ok ()) $output = 'HTML code not valid.'; |
|
| 180 | + if (!are_libxml_errors_ok ()) { |
|
| 181 | + $output = 'HTML code not valid.'; |
|
| 182 | + } |
|
| 179 | 183 | |
| 180 | 184 | libxml_use_internal_errors(false); |
| 181 | 185 | return $output; |
@@ -235,7 +239,9 @@ discard block |
||
| 235 | 239 | |
| 236 | 240 | // set default to 1 for any without q factor |
| 237 | 241 | foreach ($langs as $lang => $val) { |
| 238 | - if ($val === '') $langs[$lang] = 1; |
|
| 242 | + if ($val === '') { |
|
| 243 | + $langs[$lang] = 1; |
|
| 244 | + } |
|
| 239 | 245 | } |
| 240 | 246 | |
| 241 | 247 | // sort list based on value |
@@ -257,8 +263,7 @@ discard block |
||
| 257 | 263 | $lang = 'en'; |
| 258 | 264 | if (!empty($config['cops_language'])) { |
| 259 | 265 | $lang = $config['cops_language']; |
| 260 | - } |
|
| 261 | - elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
| 266 | + } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
| 262 | 267 | $langs = getAcceptLanguages(); |
| 263 | 268 | } |
| 264 | 269 | //echo var_dump($langs); |
@@ -284,12 +289,15 @@ discard block |
||
| 284 | 289 | function localize($phrase, $count=-1, $reset=false) |
| 285 | 290 | { |
| 286 | 291 | global $config; |
| 287 | - if ($count == 0) |
|
| 288 | - $phrase .= '.none'; |
|
| 289 | - if ($count == 1) |
|
| 290 | - $phrase .= '.one'; |
|
| 291 | - if ($count > 1) |
|
| 292 | - $phrase .= '.many'; |
|
| 292 | + if ($count == 0) { |
|
| 293 | + $phrase .= '.none'; |
|
| 294 | + } |
|
| 295 | + if ($count == 1) { |
|
| 296 | + $phrase .= '.one'; |
|
| 297 | + } |
|
| 298 | + if ($count > 1) { |
|
| 299 | + $phrase .= '.many'; |
|
| 300 | + } |
|
| 293 | 301 | |
| 294 | 302 | /* Static keyword is used to ensure the file is loaded only once */ |
| 295 | 303 | static $translations = NULL; |