Test Setup Failed
Pull Request — master (#522)
by Mike's
01:01
created
fetch.php 1 patch
Switch Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -56,57 +56,57 @@
 block discarded – undo
56 56
 
57 57
 switch ($type) {
58 58
     // -DC- Add png type
59
-    case 'jpg':
60
-    case 'png':
61
-        if ($type == 'jpg') {
62
-            header('Content-Type: image/jpeg');
63
-        } else {
64
-            header('Content-Type: image/png');
65
-        }
66
-        //by default, we don't cache
67
-        $thumbnailCacheFullpath = null;
68
-        if (isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '') {
69
-            $thumbnailCacheFullpath = $config['cops_thumbnail_cache_directory'];
70
-            //if multiple databases, add a subfolder with the database ID
71
-            $thumbnailCacheFullpath .= !is_null(GetUrlParam(DB)) ? 'db-' . GetUrlParam(DB) . DIRECTORY_SEPARATOR : '';
72
-            //when there are lots of thumbnails, it's better to save files in subfolders, so if the book's uuid is
73
-            //"01234567-89ab-cdef-0123-456789abcdef", we will save the thumbnail in .../0/12/34567-89ab-cdef-0123-456789abcdef-...
74
-            $thumbnailCacheFullpath .= substr($book->uuid, 0, 1) . DIRECTORY_SEPARATOR . substr($book->uuid, 1, 2) . DIRECTORY_SEPARATOR;
75
-            //check if cache folder exists or create it
76
-            if (file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true)) {
77
-                //we name the thumbnail from the book's uuid and it's dimensions (width and/or height)
78
-                $thumbnailCacheName = substr($book->uuid, 3) . '-' . getURLParam('width') . 'x' . getURLParam('height') . '.' . $type;
79
-                $thumbnailCacheFullpath = $thumbnailCacheFullpath . $thumbnailCacheName;
59
+        case 'jpg':
60
+        case 'png':
61
+            if ($type == 'jpg') {
62
+                header('Content-Type: image/jpeg');
80 63
             } else {
81
-                //error creating the folder, so we don't cache
82
-                $thumbnailCacheFullpath = null;
64
+                header('Content-Type: image/png');
65
+            }
66
+            //by default, we don't cache
67
+            $thumbnailCacheFullpath = null;
68
+            if (isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '') {
69
+                $thumbnailCacheFullpath = $config['cops_thumbnail_cache_directory'];
70
+                //if multiple databases, add a subfolder with the database ID
71
+                $thumbnailCacheFullpath .= !is_null(GetUrlParam(DB)) ? 'db-' . GetUrlParam(DB) . DIRECTORY_SEPARATOR : '';
72
+                //when there are lots of thumbnails, it's better to save files in subfolders, so if the book's uuid is
73
+                //"01234567-89ab-cdef-0123-456789abcdef", we will save the thumbnail in .../0/12/34567-89ab-cdef-0123-456789abcdef-...
74
+                $thumbnailCacheFullpath .= substr($book->uuid, 0, 1) . DIRECTORY_SEPARATOR . substr($book->uuid, 1, 2) . DIRECTORY_SEPARATOR;
75
+                //check if cache folder exists or create it
76
+                if (file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true)) {
77
+                    //we name the thumbnail from the book's uuid and it's dimensions (width and/or height)
78
+                    $thumbnailCacheName = substr($book->uuid, 3) . '-' . getURLParam('width') . 'x' . getURLParam('height') . '.' . $type;
79
+                    $thumbnailCacheFullpath = $thumbnailCacheFullpath . $thumbnailCacheName;
80
+                } else {
81
+                    //error creating the folder, so we don't cache
82
+                    $thumbnailCacheFullpath = null;
83
+                }
83 84
             }
84
-        }
85
-
86
-        if ($thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath)) {
87
-            //return the already cached thumbnail
88
-            readfile($thumbnailCacheFullpath);
89
-            return;
90
-        }
91 85
 
92
-        $width = getURLParam('width');
93
-        $height = getURLParam('height');
94
-        if ($book->getThumbnail($width, $height, $thumbnailCacheFullpath, $type)) {
95
-            //if we don't cache the thumbnail, imagejpeg() in $book->getThumbnail() already return the image data
96
-            if ($thumbnailCacheFullpath === null) {
97
-                // The cover had to be resized
98
-                return;
99
-            } else {
100
-                //return the just cached thumbnail
86
+            if ($thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath)) {
87
+                //return the already cached thumbnail
101 88
                 readfile($thumbnailCacheFullpath);
102 89
                 return;
103 90
             }
104
-        }
105
-        break;
106
-    default:
107
-        $data = $book->getDataById($idData);
108
-        header('Content-Type: ' . $data->getMimeType());
109
-        break;
91
+
92
+            $width = getURLParam('width');
93
+            $height = getURLParam('height');
94
+            if ($book->getThumbnail($width, $height, $thumbnailCacheFullpath, $type)) {
95
+                //if we don't cache the thumbnail, imagejpeg() in $book->getThumbnail() already return the image data
96
+                if ($thumbnailCacheFullpath === null) {
97
+                    // The cover had to be resized
98
+                    return;
99
+                } else {
100
+                    //return the just cached thumbnail
101
+                    readfile($thumbnailCacheFullpath);
102
+                    return;
103
+                }
104
+            }
105
+            break;
106
+        default:
107
+            $data = $book->getDataById($idData);
108
+            header('Content-Type: ' . $data->getMimeType());
109
+            break;
110 110
 }
111 111
 
112 112
 // absolute path for single DB in PHP app here - cfr. internal dir for X-Accel-Redirect with Nginx
Please login to merge, or discard this patch.