Completed
Push — master ( 08e2eb...3facbb )
by Markus
03:54
created
transliteration.php 5 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -163,7 +163,7 @@
 block discarded – undo
163 163
 /**
164 164
  * Replaces a Unicode character using the transliteration database.
165 165
  *
166
- * @param $ord
166
+ * @param integer $ord
167 167
  *   An ordinal Unicode character code.
168 168
  * @param $unknown
169 169
  *   Replacement string for characters that do not have a suitable ASCII
Please login to merge, or discard this patch.
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -26,56 +26,56 @@  discard block
 block discarded – undo
26 26
  *   Transliterated text.
27 27
  */
28 28
 function _transliteration_process($string, $unknown = '?', $source_langcode = NULL) {
29
-  // ASCII is always valid NFC! If we're only ever given plain ASCII, we can
30
-  // avoid the overhead of initializing the decomposition tables by skipping
31
-  // out early.
32
-  if (!preg_match('/[\x80-\xff]/', $string)) {
29
+    // ASCII is always valid NFC! If we're only ever given plain ASCII, we can
30
+    // avoid the overhead of initializing the decomposition tables by skipping
31
+    // out early.
32
+    if (!preg_match('/[\x80-\xff]/', $string)) {
33 33
     return $string;
34
-  }
34
+    }
35 35
 
36
-  static $tail_bytes;
36
+    static $tail_bytes;
37 37
 
38
-  if (!isset($tail_bytes)) {
38
+    if (!isset($tail_bytes)) {
39 39
     // Each UTF-8 head byte is followed by a certain number of tail bytes.
40 40
     $tail_bytes = array();
41 41
     for ($n = 0; $n < 256; $n++) {
42
-      if ($n < 0xc0) {
42
+        if ($n < 0xc0) {
43 43
         $remaining = 0;
44
-      }
45
-      elseif ($n < 0xe0) {
44
+        }
45
+        elseif ($n < 0xe0) {
46 46
         $remaining = 1;
47
-      }
48
-      elseif ($n < 0xf0) {
47
+        }
48
+        elseif ($n < 0xf0) {
49 49
         $remaining = 2;
50
-      }
51
-      elseif ($n < 0xf8) {
50
+        }
51
+        elseif ($n < 0xf8) {
52 52
         $remaining = 3;
53
-      }
54
-      elseif ($n < 0xfc) {
53
+        }
54
+        elseif ($n < 0xfc) {
55 55
         $remaining = 4;
56
-      }
57
-      elseif ($n < 0xfe) {
56
+        }
57
+        elseif ($n < 0xfe) {
58 58
         $remaining = 5;
59
-      }
60
-      else {
59
+        }
60
+        else {
61 61
         $remaining = 0;
62
-      }
63
-      $tail_bytes[chr($n)] = $remaining;
62
+        }
63
+        $tail_bytes[chr($n)] = $remaining;
64
+    }
64 65
     }
65
-  }
66 66
 
67
-  // Chop the text into pure-ASCII and non-ASCII areas; large ASCII parts can
68
-  // be handled much more quickly. Don't chop up Unicode areas for punctuation,
69
-  // though, that wastes energy.
70
-  preg_match_all('/[\x00-\x7f]+|[\x80-\xff][\x00-\x40\x5b-\x5f\x7b-\xff]*/', $string, $matches);
67
+    // Chop the text into pure-ASCII and non-ASCII areas; large ASCII parts can
68
+    // be handled much more quickly. Don't chop up Unicode areas for punctuation,
69
+    // though, that wastes energy.
70
+    preg_match_all('/[\x00-\x7f]+|[\x80-\xff][\x00-\x40\x5b-\x5f\x7b-\xff]*/', $string, $matches);
71 71
 
72
-  $result = '';
73
-  foreach ($matches[0] as $str) {
72
+    $result = '';
73
+    foreach ($matches[0] as $str) {
74 74
     if ($str[0] < "\x80") {
75
-      // ASCII chunk: guaranteed to be valid UTF-8 and in normal form C, so
76
-      // skip over it.
77
-      $result .= $str;
78
-      continue;
75
+        // ASCII chunk: guaranteed to be valid UTF-8 and in normal form C, so
76
+        // skip over it.
77
+        $result .= $str;
78
+        continue;
79 79
     }
80 80
 
81 81
     // We'll have to examine the chunk byte by byte to ensure that it consists
@@ -91,73 +91,73 @@  discard block
 block discarded – undo
91 91
     $len = $chunk + 1;
92 92
 
93 93
     for ($i = -1; --$len; ) {
94
-      $c = $str[++$i];
95
-      if ($remaining = $tail_bytes[$c]) {
94
+        $c = $str[++$i];
95
+        if ($remaining = $tail_bytes[$c]) {
96 96
         // UTF-8 head byte!
97 97
         $sequence = $head = $c;
98 98
         do {
99
-          // Look for the defined number of tail bytes...
100
-          if (--$len && ($c = $str[++$i]) >= "\x80" && $c < "\xc0") {
99
+            // Look for the defined number of tail bytes...
100
+            if (--$len && ($c = $str[++$i]) >= "\x80" && $c < "\xc0") {
101 101
             // Legal tail bytes are nice.
102 102
             $sequence .= $c;
103
-          }
104
-          else {
103
+            }
104
+            else {
105 105
             if ($len == 0) {
106
-              // Premature end of string! Drop a replacement character into
107
-              // output to represent the invalid UTF-8 sequence.
108
-              $result .= $unknown;
109
-              break 2;
106
+                // Premature end of string! Drop a replacement character into
107
+                // output to represent the invalid UTF-8 sequence.
108
+                $result .= $unknown;
109
+                break 2;
110 110
             }
111 111
             else {
112
-              // Illegal tail byte; abandon the sequence.
113
-              $result .= $unknown;
114
-              // Back up and reprocess this byte; it may itself be a legal
115
-              // ASCII or UTF-8 sequence head.
116
-              --$i;
117
-              ++$len;
118
-              continue 2;
112
+                // Illegal tail byte; abandon the sequence.
113
+                $result .= $unknown;
114
+                // Back up and reprocess this byte; it may itself be a legal
115
+                // ASCII or UTF-8 sequence head.
116
+                --$i;
117
+                ++$len;
118
+                continue 2;
119
+            }
119 120
             }
120
-          }
121 121
         } while (--$remaining);
122 122
 
123 123
         $n = ord($head);
124 124
         if ($n <= 0xdf) {
125
-          $ord = ($n - 192) * 64 + (ord($sequence[1]) - 128);
125
+            $ord = ($n - 192) * 64 + (ord($sequence[1]) - 128);
126 126
         }
127 127
         elseif ($n <= 0xef) {
128
-          $ord = ($n - 224) * 4096 + (ord($sequence[1]) - 128) * 64 + (ord($sequence[2]) - 128);
128
+            $ord = ($n - 224) * 4096 + (ord($sequence[1]) - 128) * 64 + (ord($sequence[2]) - 128);
129 129
         }
130 130
         elseif ($n <= 0xf7) {
131
-          $ord = ($n - 240) * 262144 + (ord($sequence[1]) - 128) * 4096 + (ord($sequence[2]) - 128) * 64 + (ord($sequence[3]) - 128);
131
+            $ord = ($n - 240) * 262144 + (ord($sequence[1]) - 128) * 4096 + (ord($sequence[2]) - 128) * 64 + (ord($sequence[3]) - 128);
132 132
         }
133 133
         elseif ($n <= 0xfb) {
134
-          $ord = ($n - 248) * 16777216 + (ord($sequence[1]) - 128) * 262144 + (ord($sequence[2]) - 128) * 4096 + (ord($sequence[3]) - 128) * 64 + (ord($sequence[4]) - 128);
134
+            $ord = ($n - 248) * 16777216 + (ord($sequence[1]) - 128) * 262144 + (ord($sequence[2]) - 128) * 4096 + (ord($sequence[3]) - 128) * 64 + (ord($sequence[4]) - 128);
135 135
         }
136 136
         elseif ($n <= 0xfd) {
137
-          $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);
137
+            $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 138
         }
139 139
         $result .= _transliteration_replace($ord, $unknown, $source_langcode);
140 140
         $head = '';
141
-      }
142
-      elseif ($c < "\x80") {
141
+        }
142
+        elseif ($c < "\x80") {
143 143
         // ASCII byte.
144 144
         $result .= $c;
145 145
         $head = '';
146
-      }
147
-      elseif ($c < "\xc0") {
146
+        }
147
+        elseif ($c < "\xc0") {
148 148
         // Illegal tail bytes.
149 149
         if ($head == '') {
150
-          $result .= $unknown;
150
+            $result .= $unknown;
151
+        }
151 152
         }
152
-      }
153
-      else {
153
+        else {
154 154
         // Miscellaneous freaks.
155 155
         $result .= $unknown;
156 156
         $head = '';
157
-      }
157
+        }
158 158
     }
159
-  }
160
-  return $result;
159
+    }
160
+    return $result;
161 161
 }
162 162
 
163 163
 /**
@@ -176,36 +176,36 @@  discard block
 block discarded – undo
176 176
  *   ASCII replacement character.
177 177
  */
178 178
 function _transliteration_replace($ord, $unknown = '?', $langcode = NULL) {
179
-  static $map = array();
179
+    static $map = array();
180 180
 
181
-  //GL: set language later
182
-  /*
181
+    //GL: set language later
182
+    /*
183 183
   if (!isset($langcode)) {
184 184
     global $language;
185 185
     $langcode = $language->language;
186 186
   }
187 187
   */
188 188
 
189
-  $bank = $ord >> 8;
189
+    $bank = $ord >> 8;
190 190
 
191
-  if (!isset($map[$bank][$langcode])) {
191
+    if (!isset($map[$bank][$langcode])) {
192 192
     $file = './resources/transliteration-data/' . sprintf('x%02x', $bank) . '.php';  
193 193
     if (file_exists($file)) {
194
-      include $file;
195
-      if ($langcode != 'en' && isset($variant[$langcode])) {
194
+        include $file;
195
+        if ($langcode != 'en' && isset($variant[$langcode])) {
196 196
         // Merge in language specific mappings.
197 197
         $map[$bank][$langcode] = $variant[$langcode] + $base;
198
-      }
199
-      else {
198
+        }
199
+        else {
200 200
         $map[$bank][$langcode] = $base;
201
-      }
201
+        }
202 202
     }
203 203
     else {
204
-      $map[$bank][$langcode] = array();
204
+        $map[$bank][$langcode] = array();
205
+    }
205 206
     }
206
-  }
207 207
 
208
-  $ord = $ord & 255;
208
+    $ord = $ord & 255;
209 209
 
210
-  return isset($map[$bank][$langcode][$ord]) ? $map[$bank][$langcode][$ord] : $unknown;
210
+    return isset($map[$bank][$langcode][$ord]) ? $map[$bank][$langcode][$ord] : $unknown;
211 211
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     // Counting down is faster. I'm *so* sorry.
91 91
     $len = $chunk + 1;
92 92
 
93
-    for ($i = -1; --$len; ) {
93
+    for ($i = -1; --$len;) {
94 94
       $c = $str[++$i];
95 95
       if ($remaining = $tail_bytes[$c]) {
96 96
         // UTF-8 head byte!
@@ -207,5 +207,5 @@  discard block
 block discarded – undo
207 207
 
208 208
   $ord = $ord & 255;
209 209
 
210
-  return isset($map[$bank][$langcode][$ord]) ? $map[$bank][$langcode][$ord] : $unknown;
210
+  return isset($map[$bank][$langcode][$ord])?$map[$bank][$langcode][$ord]:$unknown;
211 211
 }
Please login to merge, or discard this 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.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  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
   // ASCII is always valid NFC! If we're only ever given plain ASCII, we can
30 30
   // avoid the overhead of initializing the decomposition tables by skipping
31 31
   // out early.
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
  * @return
176 176
  *   ASCII replacement character.
177 177
  */
178
-function _transliteration_replace($ord, $unknown = '?', $langcode = NULL) {
178
+function _transliteration_replace($ord, $unknown = '?', $langcode = null) {
179 179
   static $map = array();
180 180
 
181 181
   //GL: set language later
Please login to merge, or discard this patch.
fetch.php 3 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -13,19 +13,19 @@  discard block
 block discarded – undo
13 13
     if ($config ['cops_fetch_protect'] == "1") {
14 14
         session_start();
15 15
         if (!isset($_SESSION['connected'])) {
16
-            notFound ();
16
+            notFound();
17 17
             return;
18 18
         }
19 19
     }
20 20
 
21
-    $expires = 60*60*24*14;
21
+    $expires = 60 * 60 * 24 * 14;
22 22
     header("Pragma: public");
23
-    header("Cache-Control: maxage=".$expires);
24
-    header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
25
-    $bookId = getURLParam ("id", NULL);
26
-    $type = getURLParam ("type", "jpg");
27
-    $idData = getURLParam ("data", NULL);
28
-    if (is_null ($bookId))
23
+    header("Cache-Control: maxage=" . $expires);
24
+    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
25
+    $bookId = getURLParam("id", NULL);
26
+    $type = getURLParam("type", "jpg");
27
+    $idData = getURLParam("data", NULL);
28
+    if (is_null($bookId))
29 29
     {
30 30
         $book = Book::getBookByDataId($idData);
31 31
     }
@@ -35,18 +35,18 @@  discard block
 block discarded – undo
35 35
     }
36 36
 
37 37
     if (!$book) {
38
-        notFound ();
38
+        notFound();
39 39
         return;
40 40
     }
41 41
 
42 42
     if ($book && ($type == "jpg" || empty ($config['calibre_internal_directory']))) {
43 43
         if ($type == "jpg") {
44
-            $file = $book->getFilePath ($type);
44
+            $file = $book->getFilePath($type);
45 45
         } else {
46
-            $file = $book->getFilePath ($type, $idData);
46
+            $file = $book->getFilePath($type, $idData);
47 47
         }
48
-        if (!$file || !file_exists ($file)) {
49
-            notFound ();
48
+        if (!$file || !file_exists($file)) {
49
+            notFound();
50 50
             return;
51 51
         }
52 52
     }
@@ -57,17 +57,17 @@  discard block
 block discarded – undo
57 57
             header("Content-Type: image/jpeg");
58 58
             //by default, we don't cache
59 59
             $thumbnailCacheFullpath = null;
60
-            if ( isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '' ) {
60
+            if (isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '') {
61 61
                 $thumbnailCacheFullpath = $config['cops_thumbnail_cache_directory'];
62 62
                 //if multiple databases, add a subfolder with the database ID
63
-                $thumbnailCacheFullpath .= !is_null (GetUrlParam (DB)) ? 'db-' . GetUrlParam (DB) . DIRECTORY_SEPARATOR : '';
63
+                $thumbnailCacheFullpath .= !is_null(GetUrlParam(DB))?'db-' . GetUrlParam(DB) . DIRECTORY_SEPARATOR:'';
64 64
                 //when there are lots of thumbnails, it's better to save files in subfolders, so if the book's uuid is
65 65
                 //"01234567-89ab-cdef-0123-456789abcdef", we will save the thumbnail in .../0/12/34567-89ab-cdef-0123-456789abcdef-...
66 66
                 $thumbnailCacheFullpath .= substr($book->uuid, 0, 1) . DIRECTORY_SEPARATOR . substr($book->uuid, 1, 2) . DIRECTORY_SEPARATOR;
67 67
                 //check if cache folder exists or create it
68
-                if ( file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true) ) {
68
+                if (file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true)) {
69 69
                     //we name the thumbnail from the book's uuid and it's dimensions (width and/or height)
70
-                    $thumbnailCacheName = substr($book->uuid, 3) . '-' . getURLParam ("width") . 'x' . getURLParam ("height") . '.jpg';
70
+                    $thumbnailCacheName = substr($book->uuid, 3) . '-' . getURLParam("width") . 'x' . getURLParam("height") . '.jpg';
71 71
                     $thumbnailCacheFullpath = $thumbnailCacheFullpath . $thumbnailCacheName;
72 72
                 }
73 73
                 else {
@@ -76,45 +76,45 @@  discard block
 block discarded – undo
76 76
                 }
77 77
             }
78 78
 
79
-            if ( $thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath) ) {
79
+            if ($thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath)) {
80 80
                 //return the already cached thumbnail
81
-                readfile( $thumbnailCacheFullpath );
81
+                readfile($thumbnailCacheFullpath);
82 82
                 return;
83 83
             }
84 84
 
85
-            if ($book->getThumbnail (getURLParam ("width"), getURLParam ("height"), $thumbnailCacheFullpath)) {
85
+            if ($book->getThumbnail(getURLParam("width"), getURLParam("height"), $thumbnailCacheFullpath)) {
86 86
                 //if we don't cache the thumbnail, imagejpeg() in $book->getThumbnail() already return the image data
87
-                if ( $thumbnailCacheFullpath === null ) {
87
+                if ($thumbnailCacheFullpath === null) {
88 88
                     // The cover had to be resized
89 89
                     return;
90 90
                 }
91 91
                 else {
92 92
                     //return the just cached thumbnail
93
-                    readfile( $thumbnailCacheFullpath );
93
+                    readfile($thumbnailCacheFullpath);
94 94
                     return;
95 95
                 }
96 96
             }
97 97
             break;
98 98
         default:
99
-            $data = $book->getDataById ($idData);
100
-            header("Content-Type: " . $data->getMimeType ());
99
+            $data = $book->getDataById($idData);
100
+            header("Content-Type: " . $data->getMimeType());
101 101
             break;
102 102
     }
103
-    $file = $book->getFilePath ($type, $idData, true);
103
+    $file = $book->getFilePath($type, $idData, true);
104 104
     if ($type == "epub" && $config['cops_update_epub-metadata'])
105 105
     {
106
-        $book->getUpdatedEpub ($idData);
106
+        $book->getUpdatedEpub($idData);
107 107
         return;
108 108
     }
109 109
     if ($type == "jpg") {
110
-        header('Content-Disposition: filename="' . basename ($file) . '"');
110
+        header('Content-Disposition: filename="' . basename($file) . '"');
111 111
     } else {
112
-        header('Content-Disposition: attachment; filename="' . basename ($file) . '"');
112
+        header('Content-Disposition: attachment; filename="' . basename($file) . '"');
113 113
     }
114 114
 
115 115
     $dir = $config['calibre_internal_directory'];
116 116
     if (empty ($config['calibre_internal_directory'])) {
117
-        $dir = Base::getDbDirectory ();
117
+        $dir = Base::getDbDirectory();
118 118
     }
119 119
 
120 120
     if (empty ($config['cops_x_accel_redirect'])) {
@@ -124,5 +124,5 @@  discard block
 block discarded – undo
124 124
         fpassthru($fp);
125 125
     }
126 126
     else {
127
-        header ($config['cops_x_accel_redirect'] . ": " . $dir . $file);
127
+        header($config['cops_x_accel_redirect'] . ": " . $dir . $file);
128 128
     }
Please login to merge, or discard this 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.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@
 block discarded – undo
22 22
     header("Pragma: public");
23 23
     header("Cache-Control: maxage=".$expires);
24 24
     header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
25
-    $bookId = getURLParam ("id", NULL);
25
+    $bookId = getURLParam ("id", null);
26 26
     $type = getURLParam ("type", "jpg");
27
-    $idData = getURLParam ("data", NULL);
27
+    $idData = getURLParam ("data", null);
28 28
     if (is_null ($bookId))
29 29
     {
30 30
         $book = Book::getBookByDataId($idData);
Please login to merge, or discard this patch.
sendtomail.php 4 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -78,9 +78,9 @@
 block discarded – undo
78 78
 $mail->AltBody = "Sent by COPS";
79 79
 
80 80
 if (!$mail->Send()) {
81
-   echo localize ("mail.messagenotsent");
82
-   echo 'Mailer Error: ' . $mail->ErrorInfo;
83
-   exit;
81
+    echo localize ("mail.messagenotsent");
82
+    echo 'Mailer Error: ' . $mail->ErrorInfo;
83
+    exit;
84 84
 }
85 85
 
86 86
 echo localize ("mail.messagesent");
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@  discard block
 block discarded – undo
2 2
 
3 3
 require_once ("config.php");
4 4
 
5
-function checkConfiguration () {
5
+function checkConfiguration() {
6 6
     global $config;
7 7
 
8
-    if (is_null ($config['cops_mail_configuration']) ||
9
-        !is_array ($config['cops_mail_configuration']) ||
8
+    if (is_null($config['cops_mail_configuration']) ||
9
+        !is_array($config['cops_mail_configuration']) ||
10 10
         empty ($config['cops_mail_configuration']["smtp.host"]) ||
11 11
         empty ($config['cops_mail_configuration']["address.from"])) {
12 12
         return "NOK. bad configuration.";
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     return False;
15 15
 }
16 16
 
17
-function checkRequest ($idData, $emailDest) {
17
+function checkRequest($idData, $emailDest) {
18 18
     if (empty ($idData)) {
19 19
         return 'No data sent.';
20 20
     }
@@ -28,22 +28,22 @@  discard block
 block discarded – undo
28 28
 
29 29
 global $config;
30 30
 
31
-if ($error = checkConfiguration ()) {
31
+if ($error = checkConfiguration()) {
32 32
     echo $error;
33 33
     exit;
34 34
 }
35 35
 
36 36
 $idData = $_REQUEST["data"];
37 37
 $emailDest = $_REQUEST["email"];
38
-if ($error = checkRequest ($idData, $emailDest)) {
38
+if ($error = checkRequest($idData, $emailDest)) {
39 39
     echo $error;
40 40
     exit;
41 41
 }
42 42
 
43 43
 $book = Book::getBookByDataId($idData);
44
-$data = $book->getDataById ($idData);
44
+$data = $book->getDataById($idData);
45 45
 
46
-if (filesize ($data->getLocalPath ()) > 10 * 1024 * 1024) {
46
+if (filesize($data->getLocalPath()) > 10 * 1024 * 1024) {
47 47
     echo 'Attachment too big';
48 48
     exit;
49 49
 }
@@ -65,23 +65,23 @@  discard block
 block discarded – undo
65 65
 $mail->From = $config['cops_mail_configuration']["address.from"];
66 66
 $mail->FromName = $config['cops_title_default'];
67 67
 
68
-foreach (explode (";", $emailDest) as $emailAddress) {
68
+foreach (explode(";", $emailDest) as $emailAddress) {
69 69
     if (empty ($emailAddress)) { continue; }
70 70
     $mail->AddAddress($emailAddress);
71 71
 }
72 72
 
73
-$mail->AddAttachment($data->getLocalPath ());
73
+$mail->AddAttachment($data->getLocalPath());
74 74
 
75 75
 $mail->IsHTML(true);
76
-$mail->Subject = 'Sent by COPS : ' . $data->getUpdatedFilename ();
77
-$mail->Body    = "<h1>" . $book->title . "</h1><h2>" . $book->getAuthorsName () . "</h2>" . $book->getComment ();
76
+$mail->Subject = 'Sent by COPS : ' . $data->getUpdatedFilename();
77
+$mail->Body    = "<h1>" . $book->title . "</h1><h2>" . $book->getAuthorsName() . "</h2>" . $book->getComment();
78 78
 $mail->AltBody = "Sent by COPS";
79 79
 
80 80
 if (!$mail->Send()) {
81
-   echo localize ("mail.messagenotsent");
81
+   echo localize("mail.messagenotsent");
82 82
    echo 'Mailer Error: ' . $mail->ErrorInfo;
83 83
    exit;
84 84
 }
85 85
 
86
-echo localize ("mail.messagesent");
86
+echo localize("mail.messagesent");
87 87
 
Please login to merge, or discard this 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.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
         empty ($config['cops_mail_configuration']["address.from"])) {
12 12
         return "NOK. bad configuration.";
13 13
     }
14
-    return False;
14
+    return false;
15 15
 }
16 16
 
17 17
 function checkRequest ($idData, $emailDest) {
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     if (empty ($emailDest)) {
22 22
         return 'No email sent.';
23 23
     }
24
-    return False;
24
+    return false;
25 25
 }
26 26
 
27 27
 if (php_sapi_name() === 'cli') { return; }
Please login to merge, or discard this patch.
epubfs.php 3 patches
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -9,70 +9,70 @@
 block discarded – undo
9 9
 require_once ("config.php");
10 10
 require_once ("base.php");
11 11
 
12
-function getComponentContent ($book, $component, $add) {
13
-    $data = $book->component ($component);
12
+function getComponentContent($book, $component, $add) {
13
+    $data = $book->component($component);
14 14
 
15
-    $callback = function ($m) use ($book, $component, $add) {
15
+    $callback = function($m) use ($book, $component, $add) {
16 16
         $method = $m[1];
17 17
         $path = $m[2];
18 18
         $end = "";
19
-        if (preg_match ("/^src\s*:/", $method)) {
19
+        if (preg_match("/^src\s*:/", $method)) {
20 20
             $end = ")";
21 21
         }
22
-        if (preg_match ("/^#/", $path)) {
22
+        if (preg_match("/^#/", $path)) {
23 23
             return "{$method}'{$path}'{$end}";
24 24
         }
25 25
         $hash = "";
26
-        if (preg_match ("/^(.+)#(.+)$/", $path, $matches)) {
26
+        if (preg_match("/^(.+)#(.+)$/", $path, $matches)) {
27 27
             $path = $matches [1];
28 28
             $hash = "#" . $matches [2];
29 29
         }
30
-        $comp = $book->getComponentName ($component, $path);
30
+        $comp = $book->getComponentName($component, $path);
31 31
         if (!$comp) return "{$method}'#'{$end}";
32 32
         $out = "{$method}'epubfs.php?{$add}comp={$comp}{$hash}'{$end}";
33 33
         if ($end) {
34 34
             return $out;
35 35
         }
36
-        return str_replace ("&", "&amp;", $out);
36
+        return str_replace("&", "&amp;", $out);
37 37
     };
38 38
 
39
-    $data = preg_replace_callback ("/(src=)[\"']([^:]*?)[\"']/", $callback, $data);
40
-    $data = preg_replace_callback ("/(href=)[\"']([^:]*?)[\"']/", $callback, $data);
41
-    $data = preg_replace_callback ("/(\@import\s+)[\"'](.*?)[\"'];/", $callback, $data);
42
-    $data = preg_replace_callback ("/(src\s*:\s*url\()(.*?)\)/", $callback, $data);
39
+    $data = preg_replace_callback("/(src=)[\"']([^:]*?)[\"']/", $callback, $data);
40
+    $data = preg_replace_callback("/(href=)[\"']([^:]*?)[\"']/", $callback, $data);
41
+    $data = preg_replace_callback("/(\@import\s+)[\"'](.*?)[\"'];/", $callback, $data);
42
+    $data = preg_replace_callback("/(src\s*:\s*url\()(.*?)\)/", $callback, $data);
43 43
 
44 44
     return $data;
45 45
 }
46 46
 
47 47
 if (php_sapi_name() === 'cli') { return; }
48 48
 
49
-$idData = getURLParam ("data", NULL);
49
+$idData = getURLParam("data", NULL);
50 50
 $add = "data=$idData&";
51
-if (!is_null (GetUrlParam (DB))) $add .= DB . "=" . GetUrlParam (DB) . "&";
51
+if (!is_null(GetUrlParam(DB))) $add .= DB . "=" . GetUrlParam(DB) . "&";
52 52
 $myBook = Book::getBookByDataId($idData);
53 53
 
54
-$book = new EPub ($myBook->getFilePath ("EPUB", $idData));
54
+$book = new EPub($myBook->getFilePath("EPUB", $idData));
55 55
 
56
-$book->initSpineComponent ();
56
+$book->initSpineComponent();
57 57
 
58 58
 if (!isset ($_GET["comp"])) {
59
-    notFound ();
59
+    notFound();
60 60
     return;
61 61
 }
62 62
 
63 63
 $component = $_GET["comp"];
64 64
 
65 65
 try {
66
-    $data = getComponentContent ($book, $component, $add);
66
+    $data = getComponentContent($book, $component, $add);
67 67
 
68
-    $expires = 60*60*24*14;
68
+    $expires = 60 * 60 * 24 * 14;
69 69
     header("Pragma: public");
70
-    header("Cache-Control: maxage=".$expires);
71
-    header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
72
-    header ("Content-Type: " . $book->componentContentType($component));
70
+    header("Cache-Control: maxage=" . $expires);
71
+    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
72
+    header("Content-Type: " . $book->componentContentType($component));
73 73
     echo $data;
74 74
 }
75 75
 catch (Exception $e) {
76
-    error_log ($e);
77
-    notFound ();
76
+    error_log($e);
77
+    notFound();
78 78
 }
79 79
\ No newline at end of file
Please login to merge, or discard this 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.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 
14 14
 header ("Content-Type: text/html;charset=utf-8");
15 15
 
16
-$idData = getURLParam ("data", NULL);
16
+$idData = getURLParam ("data", null);
17 17
 $add = "data=$idData&";
18 18
 if (!is_null (GetUrlParam (DB))) $add .= DB . "=" . GetUrlParam (DB) . "&";
19 19
 $myBook = Book::getBookByDataId($idData);
Please login to merge, or discard this patch.
epubreader.php 3 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
 require_once ("config.php");
12 12
 require_once ("base.php");
13 13
 
14
-header ("Content-Type: text/html;charset=utf-8");
14
+header("Content-Type: text/html;charset=utf-8");
15 15
 
16
-$idData = getURLParam ("data", NULL);
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))) $add .= DB . "=" . GetUrlParam(DB) . "&";
19 19
 $myBook = Book::getBookByDataId($idData);
20 20
 
21
-$book = new EPub ($myBook->getFilePath ("EPUB", $idData));
22
-$book->initSpineComponent ();
21
+$book = new EPub($myBook->getFilePath("EPUB", $idData));
22
+$book->initSpineComponent();
23 23
 
24 24
 ?>
25 25
 <head>
@@ -35,10 +35,10 @@  discard block
 block discarded – undo
35 35
         Monocle.DEBUG = true;
36 36
         var bookData = {
37 37
           getComponents: function () {
38
-            <?php echo "return [" . implode (", ", array_map (function ($comp) { return "'" . $comp . "'"; }, $book->components ())) . "];"; ?>
38
+            <?php echo "return [" . implode(", ", array_map(function($comp) { return "'" . $comp . "'"; }, $book->components())) . "];"; ?>
39 39
           },
40 40
           getContents: function () {
41
-            <?php echo "return [" . implode (", ", array_map (function ($content) { return "{title: '" . addslashes($content["title"]) . "', src: '". $content["src"] . "'}"; }, $book->contents ())) . "];"; ?>
41
+            <?php echo "return [" . implode(", ", array_map(function($content) { return "{title: '" . addslashes($content["title"]) . "', src: '" . $content["src"] . "'}"; }, $book->contents())) . "];"; ?>
42 42
           },
43 43
           getComponent: function (componentId) {
44 44
             return { url: "epubfs.php?<?php echo $add ?>comp="  + componentId };
Please login to merge, or discard this 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.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 
14 14
 header ("Content-Type: text/html;charset=utf-8");
15 15
 
16
-$idData = getURLParam ("data", NULL);
16
+$idData = getURLParam ("data", null);
17 17
 $add = "data=$idData&";
18 18
 if (!is_null (GetUrlParam (DB))) $add .= DB . "=" . GetUrlParam (DB) . "&";
19 19
 $myBook = Book::getBookByDataId($idData);
Please login to merge, or discard this patch.
feed.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
     require_once ("config.php");
11 11
     require_once ("base.php");
12 12
 
13
-    header ("Content-Type:application/xml");
14
-    $page = getURLParam ("page", Base::PAGE_INDEX);
15
-    $query = getURLParam ("query");
16
-    $n = getURLParam ("n", "1");
13
+    header("Content-Type:application/xml");
14
+    $page = getURLParam("page", Base::PAGE_INDEX);
15
+    $query = getURLParam("query");
16
+    $n = getURLParam("n", "1");
17 17
     if ($query)
18 18
         $page = Base::PAGE_OPENSEARCH_QUERY;
19
-    $qid = getURLParam ("id");
19
+    $qid = getURLParam("id");
20 20
 
21 21
     if ($config ['cops_fetch_protect'] == "1") {
22 22
         session_start();
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
         }
26 26
     }
27 27
 
28
-    $OPDSRender = new OPDSRenderer ();
28
+    $OPDSRender = new OPDSRenderer();
29 29
 
30 30
     switch ($page) {
31 31
         case Base::PAGE_OPENSEARCH :
32
-            echo $OPDSRender->getOpenSearch ();
32
+            echo $OPDSRender->getOpenSearch();
33 33
             return;
34 34
         default:
35
-            $currentPage = Page::getPage ($page, $qid, $query, $n);
36
-            $currentPage->InitializeContent ();
37
-            echo $OPDSRender->render ($currentPage);
35
+            $currentPage = Page::getPage($page, $qid, $query, $n);
36
+            $currentPage->InitializeContent();
37
+            echo $OPDSRender->render($currentPage);
38 38
             return;
39 39
     }
Please login to merge, or discard this 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.
index.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,14 +37,14 @@
 block discarded – undo
37 37
     header ("Content-Type:text/html;charset=utf-8");
38 38
 
39 39
     $data = array("title"                 => $config['cops_title_default'],
40
-                  "version"               => VERSION,
41
-                  "opds_url"              => $config['cops_full_url'] . "feed.php",
42
-                  "customHeader"          => "",
43
-                  "template"              => getCurrentTemplate (),
44
-                  "server_side_rendering" => useServerSideRendering (),
45
-                  "current_css"           => getCurrentCss (),
46
-                  "favico"                => $config['cops_icon'],
47
-                  "getjson_url"           => "getJSON.php?" . addURLParameter (getQueryString (), "complete", 1));
40
+                    "version"               => VERSION,
41
+                    "opds_url"              => $config['cops_full_url'] . "feed.php",
42
+                    "customHeader"          => "",
43
+                    "template"              => getCurrentTemplate (),
44
+                    "server_side_rendering" => useServerSideRendering (),
45
+                    "current_css"           => getCurrentCss (),
46
+                    "favico"                => $config['cops_icon'],
47
+                    "getjson_url"           => "getJSON.php?" . addURLParameter (getQueryString (), "complete", 1));
48 48
     if (preg_match("/Kindle/", $_SERVER['HTTP_USER_AGENT'])) {
49 49
         $data ["customHeader"] = '<style media="screen" type="text/css"> html { font-size: 75%; -webkit-text-size-adjust: 75%; -ms-text-size-adjust: 75%; }</style>';
50 50
     }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -16,16 +16,16 @@  discard block
 block discarded – undo
16 16
         exit ();
17 17
     }
18 18
 
19
-    $page = getURLParam ("page", Base::PAGE_INDEX);
20
-    $query = getURLParam ("query");
21
-    $qid = getURLParam ("id");
22
-    $n = getURLParam ("n", "1");
23
-    $database = GetUrlParam (DB);
19
+    $page = getURLParam("page", Base::PAGE_INDEX);
20
+    $query = getURLParam("query");
21
+    $qid = getURLParam("id");
22
+    $n = getURLParam("n", "1");
23
+    $database = GetUrlParam(DB);
24 24
 
25 25
 
26 26
     // Access the database ASAP to be sure it's readable, redirect if that's not the case.
27 27
     // It has to be done before any header is sent.
28
-    Base::checkDatabaseAvailability ();
28
+    Base::checkDatabaseAvailability();
29 29
 
30 30
     if ($config ['cops_fetch_protect'] == "1") {
31 31
         session_start();
@@ -34,32 +34,32 @@  discard block
 block discarded – undo
34 34
         }
35 35
     }
36 36
 
37
-    header ("Content-Type:text/html;charset=utf-8");
37
+    header("Content-Type:text/html;charset=utf-8");
38 38
 
39 39
     $data = array("title"                 => $config['cops_title_default'],
40 40
                   "version"               => VERSION,
41 41
                   "opds_url"              => $config['cops_full_url'] . "feed.php",
42 42
                   "customHeader"          => "",
43
-                  "template"              => getCurrentTemplate (),
44
-                  "server_side_rendering" => useServerSideRendering (),
45
-                  "current_css"           => getCurrentCss (),
43
+                  "template"              => getCurrentTemplate(),
44
+                  "server_side_rendering" => useServerSideRendering(),
45
+                  "current_css"           => getCurrentCss(),
46 46
                   "favico"                => $config['cops_icon'],
47
-                  "getjson_url"           => "getJSON.php?" . addURLParameter (getQueryString (), "complete", 1));
47
+                  "getjson_url"           => "getJSON.php?" . addURLParameter(getQueryString(), "complete", 1));
48 48
     if (preg_match("/Kindle/", $_SERVER['HTTP_USER_AGENT'])) {
49 49
         $data ["customHeader"] = '<style media="screen" type="text/css"> html { font-size: 75%; -webkit-text-size-adjust: 75%; -ms-text-size-adjust: 75%; }</style>';
50 50
     }
51
-    $headcontent = file_get_contents('templates/' . getCurrentTemplate () . '/file.html');
52
-    $template = new doT ();
53
-    $dot = $template->template ($headcontent, NULL);
54
-    echo ($dot ($data));
51
+    $headcontent = file_get_contents('templates/' . getCurrentTemplate() . '/file.html');
52
+    $template = new doT();
53
+    $dot = $template->template($headcontent, NULL);
54
+    echo ($dot($data));
55 55
 ?><body>
56 56
 <?php
57
-if (useServerSideRendering ()) {
57
+if (useServerSideRendering()) {
58 58
     // Get the data
59 59
     require_once ("JSON_renderer.php");
60
-    $data = JSONRenderer::getJson (true);
60
+    $data = JSONRenderer::getJson(true);
61 61
 
62
-    echo serverSideRender ($data);
62
+    echo serverSideRender($data);
63 63
 }
64 64
 ?>
65 65
 </body>
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
     }
51 51
     $headcontent = file_get_contents('templates/' . getCurrentTemplate () . '/file.html');
52 52
     $template = new doT ();
53
-    $dot = $template->template ($headcontent, NULL);
53
+    $dot = $template->template ($headcontent, null);
54 54
     echo ($dot ($data));
55 55
 ?><body>
56 56
 <?php
Please login to merge, or discard this patch.
getJSON.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@
 block discarded – undo
9 9
 
10 10
     require_once ("config.php");
11 11
 
12
-    header ("Content-Type:application/json;charset=utf-8");
12
+    header("Content-Type:application/json;charset=utf-8");
13 13
 
14 14
 
15
-    echo json_encode (JSONRenderer::getJson ());
15
+    echo json_encode(JSONRenderer::getJson());
16 16
 
Please login to merge, or discard this patch.
config.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,20 +12,20 @@
 block discarded – undo
12 12
     require_once '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 $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.
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.