Completed
Push — master ( 08e2eb...3facbb )
by Markus
03:54
created
fetch.php 1 patch
Braces   +7 added lines, -15 removed lines patch added patch discarded remove patch
@@ -25,12 +25,9 @@  discard block
 block discarded – undo
25 25
     $bookId = getURLParam ("id", NULL);
26 26
     $type = getURLParam ("type", "jpg");
27 27
     $idData = getURLParam ("data", NULL);
28
-    if (is_null ($bookId))
29
-    {
28
+    if (is_null ($bookId)) {
30 29
         $book = Book::getBookByDataId($idData);
31
-    }
32
-    else
33
-    {
30
+    } else {
34 31
         $book = Book::getBookById($bookId);
35 32
     }
36 33
 
@@ -51,8 +48,7 @@  discard block
 block discarded – undo
51 48
         }
52 49
     }
53 50
 
54
-    switch ($type)
55
-    {
51
+    switch ($type) {
56 52
         case "jpg":
57 53
             header("Content-Type: image/jpeg");
58 54
             //by default, we don't cache
@@ -69,8 +65,7 @@  discard block
 block discarded – undo
69 65
                     //we name the thumbnail from the book's uuid and it's dimensions (width and/or height)
70 66
                     $thumbnailCacheName = substr($book->uuid, 3) . '-' . getURLParam ("width") . 'x' . getURLParam ("height") . '.jpg';
71 67
                     $thumbnailCacheFullpath = $thumbnailCacheFullpath . $thumbnailCacheName;
72
-                }
73
-                else {
68
+                } else {
74 69
                     //error creating the folder, so we don't cache
75 70
                     $thumbnailCacheFullpath = null;
76 71
                 }
@@ -87,8 +82,7 @@  discard block
 block discarded – undo
87 82
                 if ( $thumbnailCacheFullpath === null ) {
88 83
                     // The cover had to be resized
89 84
                     return;
90
-                }
91
-                else {
85
+                } else {
92 86
                     //return the just cached thumbnail
93 87
                     readfile( $thumbnailCacheFullpath );
94 88
                     return;
@@ -101,8 +95,7 @@  discard block
 block discarded – undo
101 95
             break;
102 96
     }
103 97
     $file = $book->getFilePath ($type, $idData, true);
104
-    if ($type == "epub" && $config['cops_update_epub-metadata'])
105
-    {
98
+    if ($type == "epub" && $config['cops_update_epub-metadata']) {
106 99
         $book->getUpdatedEpub ($idData);
107 100
         return;
108 101
     }
@@ -122,7 +115,6 @@  discard block
 block discarded – undo
122 115
         $fp = fopen($filename, 'rb');
123 116
         header("Content-Length: " . filesize($filename));
124 117
         fpassthru($fp);
125
-    }
126
-    else {
118
+    } else {
127 119
         header ($config['cops_x_accel_redirect'] . ": " . $dir . $file);
128 120
     }
Please login to merge, or discard this patch.
sendtomail.php 1 patch
Braces   +13 added lines, -5 removed lines patch added patch discarded remove patch
@@ -2,7 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 require_once ("config.php");
4 4
 
5
-function checkConfiguration () {
5
+function checkConfiguration ()
6
+{
6 7
     global $config;
7 8
 
8 9
     if (is_null ($config['cops_mail_configuration']) ||
@@ -14,7 +15,8 @@  discard block
 block discarded – undo
14 15
     return False;
15 16
 }
16 17
 
17
-function checkRequest ($idData, $emailDest) {
18
+function checkRequest ($idData, $emailDest)
19
+{
18 20
     if (empty ($idData)) {
19 21
         return 'No data sent.';
20 22
     }
@@ -58,9 +60,15 @@  discard block
 block discarded – undo
58 60
     $mail->Port = 465;
59 61
 }
60 62
 $mail->SMTPAuth = !empty ($config['cops_mail_configuration']["smtp.username"]);
61
-if (!empty ($config['cops_mail_configuration']["smtp.username"])) $mail->Username = $config['cops_mail_configuration']["smtp.username"];
62
-if (!empty ($config['cops_mail_configuration']["smtp.password"])) $mail->Password = $config['cops_mail_configuration']["smtp.password"];
63
-if (!empty ($config['cops_mail_configuration']["smtp.secure"])) $mail->SMTPSecure = $config['cops_mail_configuration']["smtp.secure"];
63
+if (!empty ($config['cops_mail_configuration']["smtp.username"])) {
64
+    $mail->Username = $config['cops_mail_configuration']["smtp.username"];
65
+}
66
+if (!empty ($config['cops_mail_configuration']["smtp.password"])) {
67
+    $mail->Password = $config['cops_mail_configuration']["smtp.password"];
68
+}
69
+if (!empty ($config['cops_mail_configuration']["smtp.secure"])) {
70
+    $mail->SMTPSecure = $config['cops_mail_configuration']["smtp.secure"];
71
+}
64 72
 
65 73
 $mail->From = $config['cops_mail_configuration']["address.from"];
66 74
 $mail->FromName = $config['cops_title_default'];
Please login to merge, or discard this patch.
epubfs.php 1 patch
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,7 +9,8 @@  discard block
 block discarded – undo
9 9
 require_once ("config.php");
10 10
 require_once ("base.php");
11 11
 
12
-function getComponentContent ($book, $component, $add) {
12
+function getComponentContent ($book, $component, $add)
13
+{
13 14
     $data = $book->component ($component);
14 15
 
15 16
     $callback = function ($m) use ($book, $component, $add) {
@@ -28,7 +29,9 @@  discard block
 block discarded – undo
28 29
             $hash = "#" . $matches [2];
29 30
         }
30 31
         $comp = $book->getComponentName ($component, $path);
31
-        if (!$comp) return "{$method}'#'{$end}";
32
+        if (!$comp) {
33
+            return "{$method}'#'{$end}";
34
+        }
32 35
         $out = "{$method}'epubfs.php?{$add}comp={$comp}{$hash}'{$end}";
33 36
         if ($end) {
34 37
             return $out;
@@ -48,7 +51,9 @@  discard block
 block discarded – undo
48 51
 
49 52
 $idData = getURLParam ("data", NULL);
50 53
 $add = "data=$idData&";
51
-if (!is_null (GetUrlParam (DB))) $add .= DB . "=" . GetUrlParam (DB) . "&";
54
+if (!is_null (GetUrlParam (DB))) {
55
+    $add .= DB . "=" . GetUrlParam (DB) . "&";
56
+}
52 57
 $myBook = Book::getBookByDataId($idData);
53 58
 
54 59
 $book = new EPub ($myBook->getFilePath ("EPUB", $idData));
@@ -71,8 +76,7 @@  discard block
 block discarded – undo
71 76
     header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
72 77
     header ("Content-Type: " . $book->componentContentType($component));
73 78
     echo $data;
74
-}
75
-catch (Exception $e) {
79
+} catch (Exception $e) {
76 80
     error_log ($e);
77 81
     notFound ();
78 82
 }
79 83
\ No newline at end of file
Please login to merge, or discard this patch.
transliteration.php 1 patch
Braces   +21 added lines, -36 removed lines patch added patch discarded remove patch
@@ -25,7 +25,8 @@  discard block
 block discarded – undo
25 25
  * @return
26 26
  *   Transliterated text.
27 27
  */
28
-function _transliteration_process($string, $unknown = '?', $source_langcode = NULL) {
28
+function _transliteration_process($string, $unknown = '?', $source_langcode = NULL)
29
+{
29 30
   // ASCII is always valid NFC! If we're only ever given plain ASCII, we can
30 31
   // avoid the overhead of initializing the decomposition tables by skipping
31 32
   // out early.
@@ -41,23 +42,17 @@  discard block
 block discarded – undo
41 42
     for ($n = 0; $n < 256; $n++) {
42 43
       if ($n < 0xc0) {
43 44
         $remaining = 0;
44
-      }
45
-      elseif ($n < 0xe0) {
45
+      } elseif ($n < 0xe0) {
46 46
         $remaining = 1;
47
-      }
48
-      elseif ($n < 0xf0) {
47
+      } elseif ($n < 0xf0) {
49 48
         $remaining = 2;
50
-      }
51
-      elseif ($n < 0xf8) {
49
+      } elseif ($n < 0xf8) {
52 50
         $remaining = 3;
53
-      }
54
-      elseif ($n < 0xfc) {
51
+      } elseif ($n < 0xfc) {
55 52
         $remaining = 4;
56
-      }
57
-      elseif ($n < 0xfe) {
53
+      } elseif ($n < 0xfe) {
58 54
         $remaining = 5;
59
-      }
60
-      else {
55
+      } else {
61 56
         $remaining = 0;
62 57
       }
63 58
       $tail_bytes[chr($n)] = $remaining;
@@ -100,15 +95,13 @@  discard block
 block discarded – undo
100 95
           if (--$len && ($c = $str[++$i]) >= "\x80" && $c < "\xc0") {
101 96
             // Legal tail bytes are nice.
102 97
             $sequence .= $c;
103
-          }
104
-          else {
98
+          } else {
105 99
             if ($len == 0) {
106 100
               // Premature end of string! Drop a replacement character into
107 101
               // output to represent the invalid UTF-8 sequence.
108 102
               $result .= $unknown;
109 103
               break 2;
110
-            }
111
-            else {
104
+            } else {
112 105
               // Illegal tail byte; abandon the sequence.
113 106
               $result .= $unknown;
114 107
               // Back up and reprocess this byte; it may itself be a legal
@@ -123,34 +116,27 @@  discard block
 block discarded – undo
123 116
         $n = ord($head);
124 117
         if ($n <= 0xdf) {
125 118
           $ord = ($n - 192) * 64 + (ord($sequence[1]) - 128);
126
-        }
127
-        elseif ($n <= 0xef) {
119
+        } elseif ($n <= 0xef) {
128 120
           $ord = ($n - 224) * 4096 + (ord($sequence[1]) - 128) * 64 + (ord($sequence[2]) - 128);
129
-        }
130
-        elseif ($n <= 0xf7) {
121
+        } elseif ($n <= 0xf7) {
131 122
           $ord = ($n - 240) * 262144 + (ord($sequence[1]) - 128) * 4096 + (ord($sequence[2]) - 128) * 64 + (ord($sequence[3]) - 128);
132
-        }
133
-        elseif ($n <= 0xfb) {
123
+        } elseif ($n <= 0xfb) {
134 124
           $ord = ($n - 248) * 16777216 + (ord($sequence[1]) - 128) * 262144 + (ord($sequence[2]) - 128) * 4096 + (ord($sequence[3]) - 128) * 64 + (ord($sequence[4]) - 128);
135
-        }
136
-        elseif ($n <= 0xfd) {
125
+        } elseif ($n <= 0xfd) {
137 126
           $ord = ($n - 252) * 1073741824 + (ord($sequence[1]) - 128) * 16777216 + (ord($sequence[2]) - 128) * 262144 + (ord($sequence[3]) - 128) * 4096 + (ord($sequence[4]) - 128) * 64 + (ord($sequence[5]) - 128);
138 127
         }
139 128
         $result .= _transliteration_replace($ord, $unknown, $source_langcode);
140 129
         $head = '';
141
-      }
142
-      elseif ($c < "\x80") {
130
+      } elseif ($c < "\x80") {
143 131
         // ASCII byte.
144 132
         $result .= $c;
145 133
         $head = '';
146
-      }
147
-      elseif ($c < "\xc0") {
134
+      } elseif ($c < "\xc0") {
148 135
         // Illegal tail bytes.
149 136
         if ($head == '') {
150 137
           $result .= $unknown;
151 138
         }
152
-      }
153
-      else {
139
+      } else {
154 140
         // Miscellaneous freaks.
155 141
         $result .= $unknown;
156 142
         $head = '';
@@ -175,7 +161,8 @@  discard block
 block discarded – undo
175 161
  * @return
176 162
  *   ASCII replacement character.
177 163
  */
178
-function _transliteration_replace($ord, $unknown = '?', $langcode = NULL) {
164
+function _transliteration_replace($ord, $unknown = '?', $langcode = NULL)
165
+{
179 166
   static $map = array();
180 167
 
181 168
   //GL: set language later
@@ -195,12 +182,10 @@  discard block
 block discarded – undo
195 182
       if ($langcode != 'en' && isset($variant[$langcode])) {
196 183
         // Merge in language specific mappings.
197 184
         $map[$bank][$langcode] = $variant[$langcode] + $base;
198
-      }
199
-      else {
185
+      } else {
200 186
         $map[$bank][$langcode] = $base;
201 187
       }
202
-    }
203
-    else {
188
+    } else {
204 189
       $map[$bank][$langcode] = array();
205 190
     }
206 191
   }
Please login to merge, or discard this patch.
epubreader.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,9 @@
 block discarded – undo
15 15
 
16 16
 $idData = getURLParam ("data", NULL);
17 17
 $add = "data=$idData&";
18
-if (!is_null (GetUrlParam (DB))) $add .= DB . "=" . GetUrlParam (DB) . "&";
18
+if (!is_null (GetUrlParam (DB))) {
19
+    $add .= DB . "=" . GetUrlParam (DB) . "&";
20
+}
19 21
 $myBook = Book::getBookByDataId($idData);
20 22
 
21 23
 $book = new EPub ($myBook->getFilePath ("EPUB", $idData));
Please login to merge, or discard this patch.
feed.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@
 block discarded – undo
14 14
     $page = getURLParam ("page", Base::PAGE_INDEX);
15 15
     $query = getURLParam ("query");
16 16
     $n = getURLParam ("n", "1");
17
-    if ($query)
18
-        $page = Base::PAGE_OPENSEARCH_QUERY;
17
+    if ($query) {
18
+            $page = Base::PAGE_OPENSEARCH_QUERY;
19
+    }
19 20
     $qid = getURLParam ("id");
20 21
 
21 22
     if ($config ['cops_fetch_protect'] == "1") {
Please login to merge, or discard this patch.
config.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,13 +21,11 @@
 block discarded – undo
21 21
 }
22 22
 
23 23
 if(!is_null($config['cops_basic_authentication']) &&
24
-    is_array($config['cops_basic_authentication']))
25
-{
24
+    is_array($config['cops_basic_authentication'])) {
26 25
     if (!isset($_SERVER['PHP_AUTH_USER']) ||
27 26
         (isset($_SERVER['PHP_AUTH_USER']) &&
28 27
         ($_SERVER['PHP_AUTH_USER']!=$config['cops_basic_authentication']['username'] ||
29
-        $_SERVER['PHP_AUTH_PW'] != $config['cops_basic_authentication']['password'])))
30
-    {
28
+        $_SERVER['PHP_AUTH_PW'] != $config['cops_basic_authentication']['password']))) {
31 29
         header('WWW-Authenticate: Basic realm="COPS Authentication"');
32 30
         header('HTTP/1.0 401 Unauthorized');
33 31
         echo 'This site is password protected';
Please login to merge, or discard this patch.
config_default.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,8 +6,9 @@
 block discarded – undo
6 6
  * @author     Sébastien Lucas <[email protected]>
7 7
  */
8 8
 
9
-    if (!isset($config))
10
-        $config = array();
9
+    if (!isset($config)) {
10
+            $config = array();
11
+    }
11 12
 
12 13
     /*
13 14
      * The directory containing calibre's metadata.db file, with sub-directories
Please login to merge, or discard this patch.
checkconfig.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -237,8 +237,7 @@
 block discarded – undo
237 237
                 $db = new PDO('sqlite:'. Base::getDbFileName ($i));
238 238
                 $result = $db->prepare("select books.path || '/' || data.name || '.' || lower (format) as fullpath from data join books on data.book = books.id");
239 239
                 $result->execute ();
240
-                while ($post = $result->fetchObject ())
241
-                {
240
+                while ($post = $result->fetchObject ()) {
242 241
                     if (!is_file (Base::getDbDirectory ($i) . $post->fullpath)) {
243 242
                         echo "<p>" . Base::getDbDirectory ($i) . $post->fullpath . "</p>";
244 243
                     }
Please login to merge, or discard this patch.