Test Setup Failed
Pull Request — master (#522)
by Mike's
01:01
created
checkconfig.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
             <h4>
202 202
             <?php
203 203
     try {
204
-        $db = new PDO('sqlite:'. Base::getDbFileName($i));
204
+        $db = new PDO('sqlite:' . Base::getDbFileName($i));
205 205
         echo $name . ' OK';
206 206
     } catch (Exception $e) {
207 207
         echo $name . ' If the file is readable, check your php configuration. Exception detail : ' . $e;
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
             <h4>
215 215
             <?php
216 216
         try {
217
-            $db = new PDO('sqlite:'. Base::getDbFileName($i));
217
+            $db = new PDO('sqlite:' . Base::getDbFileName($i));
218 218
             $count = $db->query('select count(*) FROM sqlite_master WHERE type="table" AND name in ("books", "authors", "tags", "series")')->fetchColumn();
219 219
             if ($count == 4) {
220 220
                 echo $name . ' OK';
Please login to merge, or discard this patch.
fetch.php 2 patches
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.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
     ob_end_clean();
27 27
 }
28 28
 
29
-$expires = 60*60*24*14;
29
+$expires = 60 * 60 * 24 * 14;
30 30
 header('Pragma: public');
31 31
 header('Cache-Control: max-age=' . $expires);
32
-header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
32
+header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
33 33
 $bookId   = getURLParam('id', null);
34 34
 $type     = getURLParam('type', 'jpg');
35 35
 $idData   = getURLParam('data', null);
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         if (isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '') {
74 74
             $thumbnailCacheFullpath = $config['cops_thumbnail_cache_directory'];
75 75
             //if multiple databases, add a subfolder with the database ID
76
-            $thumbnailCacheFullpath .= !is_null(GetUrlParam(DB)) ? 'db-' . GetUrlParam(DB) . DIRECTORY_SEPARATOR : '';
76
+            $thumbnailCacheFullpath .= !is_null(GetUrlParam(DB))?'db-' . GetUrlParam(DB) . DIRECTORY_SEPARATOR:'';
77 77
             //when there are lots of thumbnails, it's better to save files in subfolders, so if the book's uuid is
78 78
             //"01234567-89ab-cdef-0123-456789abcdef", we will save the thumbnail in .../0/12/34567-89ab-cdef-0123-456789abcdef-...
79 79
             $thumbnailCacheFullpath .= substr($book->uuid, 0, 1) . DIRECTORY_SEPARATOR . substr($book->uuid, 1, 2) . DIRECTORY_SEPARATOR;
Please login to merge, or discard this patch.
config.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 }
14 14
 /** @var array $config */
15 15
 
16
-$remote_user = array_key_exists('PHP_AUTH_USER', $_SERVER) ? $_SERVER['PHP_AUTH_USER'] : '';
16
+$remote_user = array_key_exists('PHP_AUTH_USER', $_SERVER)?$_SERVER['PHP_AUTH_USER']:'';
17 17
 // Clean username, only allow a-z, A-Z, 0-9, -_ chars
18 18
 $remote_user = preg_replace('/[^a-zA-Z0-9_-]/', '', $remote_user);
19 19
 $user_config_file = 'config_local.' . $remote_user . '.php';
Please login to merge, or discard this patch.