Completed
Push — master ( 306060...2234f3 )
by Markus
03:46
created
lib/PageAllLanguages.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 
9 9
 class PageAllSeries extends Page
10 10
 {
11
-    public function InitializeContent ()
11
+    public function InitializeContent()
12 12
     {
13 13
         $this->title = localize("series.title");
14 14
         $this->entryArray = Serie::getAllSeries();
Please login to merge, or discard this patch.
lib/PageAllPublishers.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 
9 9
 class PageAllSeries extends Page
10 10
 {
11
-    public function InitializeContent ()
11
+    public function InitializeContent()
12 12
     {
13 13
         $this->title = localize("series.title");
14 14
         $this->entryArray = Serie::getAllSeries();
Please login to merge, or discard this patch.
base.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@  discard block
 block discarded – undo
8 8
 
9 9
 require_once 'config.php';
10 10
 
11
-define ('VERSION', '1.0.0RC4');
12
-define ('DB', 'db');
11
+define('VERSION', '1.0.0RC4');
12
+define('DB', 'db');
13 13
 date_default_timezone_set($config['default_timezone']);
14 14
 
15 15
 
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 function serverSideRender($data)
23 23
 {
24 24
     // Get the templates
25
-    $theme = getCurrentTemplate ();
25
+    $theme = getCurrentTemplate();
26 26
     $header = file_get_contents('templates/' . $theme . '/header.html');
27 27
     $footer = file_get_contents('templates/' . $theme . '/footer.html');
28 28
     $main = file_get_contents('templates/' . $theme . '/main.html');
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
     $page = file_get_contents('templates/' . $theme . '/page.html');
31 31
 
32 32
     // Generate the function for the template
33
-    $template = new doT ();
34
-    $dot = $template->template ($page, array ('bookdetail' => $bookdetail,
33
+    $template = new doT();
34
+    $dot = $template->template($page, array('bookdetail' => $bookdetail,
35 35
                                               'header' => $header,
36 36
                                               'footer' => $footer,
37 37
                                               'main' => $main));
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
     }
43 43
     // Execute the template
44 44
     if (!empty ($data)) {
45
-        return $dot ($data);
45
+        return $dot($data);
46 46
     }
47 47
 
48 48
     return NULL;
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
 function notFound()
60 60
 {
61
-    header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
61
+    header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
62 62
     header('Status: 404 Not Found');
63 63
 
64 64
     $_SERVER['REDIRECT_STATUS'] = 404;
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 {
77 77
     global $config;
78 78
     if (isset($_COOKIE[$option])) {
79
-        if (isset($config ['cops_' . $option]) && is_array ($config ['cops_' . $option])) {
80
-            return explode (',', $_COOKIE[$option]);
79
+        if (isset($config ['cops_' . $option]) && is_array($config ['cops_' . $option])) {
80
+            return explode(',', $_COOKIE[$option]);
81 81
         } else {
82 82
             return $_COOKIE[$option];
83 83
         }
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
 
92 92
 function getCurrentCss()
93 93
 {
94
-    return 'templates/' . getCurrentTemplate () . '/styles/style-' . getCurrentOption('style') . '.css';
94
+    return 'templates/' . getCurrentTemplate() . '/styles/style-' . getCurrentOption('style') . '.css';
95 95
 }
96 96
 
97 97
 function getCurrentTemplate()
98 98
 {
99
-    return getCurrentOption ('template');
99
+    return getCurrentOption('template');
100 100
 }
101 101
 
102 102
 function getUrlWithVersion($url)
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
     libxml_use_internal_errors(true);
161 161
 
162 162
     $doc->loadHTML('<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body>' .
163
-                        $html  . '</body></html>'); // Load the HTML
163
+                        $html . '</body></html>'); // Load the HTML
164 164
     $output = $doc->saveXML($doc->documentElement); // Transform to an Ansi xml stream
165 165
     $output = xml2xhtml($output);
166
-    if (preg_match ('#<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></meta></head><body>(.*)</body></html>#ms', $output, $matches)) {
166
+    if (preg_match('#<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></meta></head><body>(.*)</body></html>#ms', $output, $matches)) {
167 167
         $output = $matches [1]; // Remove <html><body>
168 168
     }
169 169
     /*
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
     }
176 176
     */
177 177
 
178
-    if (!are_libxml_errors_ok ()) $output = 'HTML code not valid.';
178
+    if (!are_libxml_errors_ok()) $output = 'HTML code not valid.';
179 179
 
180 180
     libxml_use_internal_errors(false);
181 181
     return $output;
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
     //echo var_dump($langs);
265 265
     $lang_file = NULL;
266 266
     foreach ($langs as $language => $val) {
267
-        $temp_file = dirname(__FILE__). '/lang/Localization_' . $language . '.json';
267
+        $temp_file = dirname(__FILE__) . '/lang/Localization_' . $language . '.json';
268 268
         if (file_exists($temp_file)) {
269 269
             $lang = $language;
270 270
             $lang_file = $temp_file;
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         }
273 273
     }
274 274
     if (empty ($lang_file)) {
275
-        $lang_file = dirname(__FILE__). '/lang/Localization_' . $lang . '.json';
275
+        $lang_file = dirname(__FILE__) . '/lang/Localization_' . $lang . '.json';
276 276
     }
277 277
     return array($lang, $lang_file);
278 278
 }
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
  * This method is based on this page
282 282
  * http://www.mind-it.info/2010/02/22/a-simple-approach-to-localization-in-php/
283 283
  */
284
-function localize($phrase, $count=-1, $reset=false)
284
+function localize($phrase, $count = -1, $reset = false)
285 285
 {
286 286
     global $config;
287 287
     if ($count == 0)
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
         $lang_file_en = NULL;
302 302
         list ($lang, $lang_file) = getLangAndTranslationFile();
303 303
         if ($lang != 'en') {
304
-            $lang_file_en = dirname(__FILE__). '/lang/' . 'Localization_en.json';
304
+            $lang_file_en = dirname(__FILE__) . '/lang/' . 'Localization_en.json';
305 305
         }
306 306
 
307 307
         $lang_file_content = file_get_contents($lang_file);
@@ -309,8 +309,8 @@  discard block
 block discarded – undo
309 309
         $translations = json_decode($lang_file_content, true);
310 310
 
311 311
         /* Clean the array of all unfinished translations */
312
-        foreach (array_keys ($translations) as $key) {
313
-            if (preg_match ('/^##TODO##/', $key)) {
312
+        foreach (array_keys($translations) as $key) {
313
+            if (preg_match('/^##TODO##/', $key)) {
314 314
                 unset ($translations [$key]);
315 315
             }
316 316
         }
@@ -318,10 +318,10 @@  discard block
 block discarded – undo
318 318
         {
319 319
             $lang_file_content = file_get_contents($lang_file_en);
320 320
             $translations_en = json_decode($lang_file_content, true);
321
-            $translations = array_merge ($translations_en, $translations);
321
+            $translations = array_merge($translations_en, $translations);
322 322
         }
323 323
     }
324
-    if (array_key_exists ($phrase, $translations)) {
324
+    if (array_key_exists($phrase, $translations)) {
325 325
         return $translations[$phrase];
326 326
     }
327 327
     return $phrase;
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
         $urlParams = '';
334 334
     }
335 335
     $start = '';
336
-    if (preg_match ('#^\?(.*)#', $urlParams, $matches)) {
336
+    if (preg_match('#^\?(.*)#', $urlParams, $matches)) {
337 337
         $start = '?';
338 338
         $urlParams = $matches[1];
339 339
     }
Please login to merge, or discard this patch.
fetch.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
epubreader.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 
16 16
 $idData = getURLParam('data', NULL);
17 17
 $add = 'data=' . $idData . '&';
18
-if (!is_null (GetUrlParam (DB))) {
19
-    $add .= DB . '=' . GetUrlParam (DB) . '&';
18
+if (!is_null(GetUrlParam(DB))) {
19
+    $add .= DB . '=' . GetUrlParam(DB) . '&';
20 20
 }
21 21
 $myBook = Book::getBookByDataId($idData);
22 22
 
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
         Monocle.DEBUG = true;
38 38
         var bookData = {
39 39
           getComponents: function() {
40
-            <?php echo 'return [' . implode(', ', array_map(function($comp) { return "'" . $comp . "'"; }, $book->components ())) . '];'; ?>
40
+            <?php echo 'return [' . implode(', ', array_map(function($comp) { return "'" . $comp . "'"; }, $book->components())) . '];'; ?>
41 41
           },
42 42
           getContents: function() {
43
-            <?php echo 'return [' . implode(', ', array_map(function($content) { return "{title: '" . addslashes($content['title']) . "', src: '". $content['src'] . "'}"; }, $book->contents())) . '];'; ?>
43
+            <?php echo 'return [' . implode(', ', array_map(function($content) { return "{title: '" . addslashes($content['title']) . "', src: '" . $content['src'] . "'}"; }, $book->contents())) . '];'; ?>
44 44
           },
45 45
           getComponent: function (componentId) {
46 46
             return { url: "epubfs.php?<?php echo $add ?>comp="  + componentId };
Please login to merge, or discard this patch.
config.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,20 +12,20 @@
 block discarded – undo
12 12
     require_once dirname(__FILE__) . '/config_local.php';
13 13
 }
14 14
 
15
-$remote_user = array_key_exists('PHP_AUTH_USER', $_SERVER) ? $_SERVER['PHP_AUTH_USER'] : '';
15
+$remote_user = array_key_exists('PHP_AUTH_USER', $_SERVER)?$_SERVER['PHP_AUTH_USER']:'';
16 16
 // Clean username, only allow a-z, A-Z, 0-9, -_ chars
17
-$remote_user = preg_replace( '/[^a-zA-Z0-9_-]/', '', $remote_user);
17
+$remote_user = preg_replace('/[^a-zA-Z0-9_-]/', '', $remote_user);
18 18
 $user_config_file = 'config_local.' . $remote_user . '.php';
19 19
 if (file_exists(dirname(__FILE__) . '/' . $user_config_file) && (php_sapi_name() !== 'cli')) {
20 20
     require_once dirname(__FILE__) . '/' . $user_config_file;
21 21
 }
22 22
 
23
-if(!is_null($config['cops_basic_authentication']) &&
23
+if (!is_null($config['cops_basic_authentication']) &&
24 24
     is_array($config['cops_basic_authentication']))
25 25
 {
26 26
     if (!isset($_SERVER['PHP_AUTH_USER']) ||
27 27
         (isset($_SERVER['PHP_AUTH_USER']) &&
28
-        ($_SERVER['PHP_AUTH_USER']!=$config['cops_basic_authentication']['username'] ||
28
+        ($_SERVER['PHP_AUTH_USER'] != $config['cops_basic_authentication']['username'] ||
29 29
         $_SERVER['PHP_AUTH_PW'] != $config['cops_basic_authentication']['password'])))
30 30
     {
31 31
         header('WWW-Authenticate: Basic realm="COPS Authentication"');
Please login to merge, or discard this patch.
epubfs.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,11 +72,11 @@
 block discarded – undo
72 72
 try {
73 73
     $data = getComponentContent($book, $component, $add);
74 74
 
75
-    $expires = 60*60*24*14;
75
+    $expires = 60 * 60 * 24 * 14;
76 76
     header('Pragma: public');
77
-    header('Cache-Control: maxage='.$expires);
78
-    header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
79
-    header ('Content-Type: ' . $book->componentContentType($component));
77
+    header('Cache-Control: maxage=' . $expires);
78
+    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
79
+    header('Content-Type: ' . $book->componentContentType($component));
80 80
     echo $data;
81 81
 } catch (Exception $e) {
82 82
     error_log($e);
Please login to merge, or discard this patch.
checkconfig.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     require_once 'config.php';
13 13
     require_once 'base.php';
14 14
 
15
-    header ('Content-Type:text/html; charset=UTF-8');
15
+    header('Content-Type:text/html; charset=UTF-8');
16 16
 
17 17
     $err = getURLParam('err', -1);
18 18
     $full = getURLParam('full');
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     <meta charset="utf-8">
29 29
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
30 30
     <title>COPS Configuration Check</title>
31
-    <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss ()) ?>" media="screen" />
31
+    <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss()) ?>" media="screen" />
32 32
 </head>
33 33
 <body>
34 34
 <div class="container">
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             <h2>Check if the rendering will be done on client side or server side</h2>
154 154
             <h4>
155 155
             <?php
156
-            if (useServerSideRendering ()) {
156
+            if (useServerSideRendering()) {
157 157
                 echo 'Server side rendering';
158 158
             } else {
159 159
                 echo 'Client side rendering';
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
             <h2>Check if Calibre database path is not an URL</h2>
170 170
             <h4>
171 171
             <?php
172
-            if (!preg_match ('#^http#', $database)) {
172
+            if (!preg_match('#^http#', $database)) {
173 173
                 echo 'OK';
174 174
             } else {
175 175
                 echo 'Calibre path has to be local (no URL allowed)';
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
             <h4>
203 203
             <?php
204 204
             try {
205
-                $db = new PDO('sqlite:'. Base::getDbFileName($i));
205
+                $db = new PDO('sqlite:' . Base::getDbFileName($i));
206 206
                 echo $name . ' OK';
207 207
             } catch (Exception $e) {
208 208
                 echo $name . ' If the file is readable, check your php configuration. Exception detail : ' . $e;
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
             <h4>
216 216
             <?php
217 217
             try {
218
-                $db = new PDO('sqlite:'. Base::getDbFileName($i));
218
+                $db = new PDO('sqlite:' . Base::getDbFileName($i));
219 219
                 $count = $db->query('select count(*) FROM sqlite_master WHERE type="table" AND name in ("books", "authors", "tags", "series")')->fetchColumn();
220 220
                 if ($count == 4) {
221 221
                     echo $name . ' OK';
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
                 $result->execute();
240 240
                 while ($post = $result->fetchObject())
241 241
                 {
242
-                    if (!is_file (Base::getDbDirectory($i) . $post->fullpath)) {
242
+                    if (!is_file(Base::getDbDirectory($i) . $post->fullpath)) {
243 243
                         echo '<p>' . Base::getDbDirectory($i) . $post->fullpath . '</p>';
244 244
                     }
245 245
                 }
Please login to merge, or discard this patch.