Passed
Push — master ( 1a2937...7c8e79 )
by Markus
14:21
created
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.
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.
lib/Language.php 1 patch
Braces   +15 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,20 +13,24 @@  discard block
 block discarded – undo
13 13
     public $id;
14 14
     public $lang_code;
15 15
 
16
-    public function __construct($pid, $plang_code) {
16
+    public function __construct($pid, $plang_code)
17
+    {
17 18
         $this->id = $pid;
18 19
         $this->lang_code = $plang_code;
19 20
     }
20 21
 
21
-    public function getUri () {
22
+    public function getUri ()
23
+    {
22 24
         return "?page=".parent::PAGE_LANGUAGE_DETAIL."&id=$this->id";
23 25
     }
24 26
 
25
-    public function getEntryId () {
27
+    public function getEntryId ()
28
+    {
26 29
         return self::ALL_LANGUAGES_ID.":".$this->id;
27 30
     }
28 31
 
29
-    public static function getLanguageString ($code) {
32
+    public static function getLanguageString ($code)
33
+    {
30 34
         $string = localize("languages.".$code);
31 35
         if (preg_match ("/^languages/", $string)) {
32 36
             return $code;
@@ -34,12 +38,14 @@  discard block
 block discarded – undo
34 38
         return $string;
35 39
     }
36 40
 
37
-    public static function getCount() {
41
+    public static function getCount()
42
+    {
38 43
         // str_format (localize("languages.alphabetical", count(array))
39 44
         return parent::getCountGeneric ("languages", self::ALL_LANGUAGES_ID, parent::PAGE_ALL_LANGUAGES);
40 45
     }
41 46
 
42
-    public static function getLanguageById ($languageId) {
47
+    public static function getLanguageById ($languageId)
48
+    {
43 49
         $result = parent::getDb ()->prepare('select id, lang_code  from languages where id = ?');
44 50
         $result->execute (array ($languageId));
45 51
         if ($post = $result->fetchObject ()) {
@@ -50,15 +56,15 @@  discard block
 block discarded – undo
50 56
 
51 57
 
52 58
 
53
-    public static function getAllLanguages() {
59
+    public static function getAllLanguages()
60
+    {
54 61
         $result = parent::getDb ()->query('select languages.id as id, languages.lang_code as lang_code, count(*) as count
55 62
 from languages, books_languages_link
56 63
 where languages.id = books_languages_link.lang_code
57 64
 group by languages.id, books_languages_link.lang_code
58 65
 order by languages.lang_code');
59 66
         $entryArray = array();
60
-        while ($post = $result->fetchObject ())
61
-        {
67
+        while ($post = $result->fetchObject ()) {
62 68
             $language = new Language ($post->id, $post->lang_code);
63 69
             array_push ($entryArray, new Entry (Language::getLanguageString ($language->lang_code), $language->getEntryId (),
64 70
                 str_format (localize("bookword", $post->count), $post->count), "text",
Please login to merge, or discard this patch.
lib/PageQueryResult.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,11 +15,13 @@  discard block
 block discarded – undo
15 15
     const SCOPE_BOOK = "book";
16 16
     const SCOPE_PUBLISHER = "publisher";
17 17
 
18
-    private function useTypeahead () {
18
+    private function useTypeahead ()
19
+    {
19 20
         return !is_null (getURLParam ("search"));
20 21
     }
21 22
 
22
-    private function searchByScope ($scope, $limit = FALSE) {
23
+    private function searchByScope ($scope, $limit = FALSE)
24
+    {
23 25
         $n = $this->n;
24 26
         $numberPerPage = NULL;
25 27
         $queryNormedAndUp = $this->query;
@@ -54,7 +56,8 @@  discard block
 block discarded – undo
54 56
         return $array;
55 57
     }
56 58
 
57
-    public function doSearchByCategory () {
59
+    public function doSearchByCategory ()
60
+    {
58 61
         $database = GetUrlParam (DB);
59 62
         $out = array ();
60 63
         $pagequery = Base::PAGE_OPENSEARCH_QUERY;
Please login to merge, or discard this patch.
lib/Page.php 1 patch
Braces   +26 added lines, -9 removed lines patch added patch discarded remove patch
@@ -76,7 +76,8 @@  discard block
 block discarded – undo
76 76
         }
77 77
     }
78 78
 
79
-    public function __construct($pid, $pquery, $pn) {
79
+    public function __construct($pid, $pquery, $pn)
80
+    {
80 81
         global $config;
81 82
 
82 83
         $this->idGet = $pid;
@@ -109,23 +110,33 @@  discard block
 block discarded – undo
109 110
             }
110 111
             if (!in_array (PageQueryResult::SCOPE_SERIES, getCurrentOption ('ignored_categories'))) {
111 112
                 $series = Serie::getCount();
112
-                if (!is_null ($series)) array_push ($this->entryArray, $series);
113
+                if (!is_null ($series)) {
114
+                    array_push ($this->entryArray, $series);
115
+                }
113 116
             }
114 117
             if (!in_array (PageQueryResult::SCOPE_PUBLISHER, getCurrentOption ('ignored_categories'))) {
115 118
                 $publisher = Publisher::getCount();
116
-                if (!is_null ($publisher)) array_push ($this->entryArray, $publisher);
119
+                if (!is_null ($publisher)) {
120
+                    array_push ($this->entryArray, $publisher);
121
+                }
117 122
             }
118 123
             if (!in_array (PageQueryResult::SCOPE_TAG, getCurrentOption ('ignored_categories'))) {
119 124
                 $tags = Tag::getCount();
120
-                if (!is_null ($tags)) array_push ($this->entryArray, $tags);
125
+                if (!is_null ($tags)) {
126
+                    array_push ($this->entryArray, $tags);
127
+                }
121 128
             }
122 129
             if (!in_array (PageQueryResult::SCOPE_RATING, getCurrentOption ('ignored_categories'))) {
123 130
                 $rating = Rating::getCount();
124
-                if (!is_null ($rating)) array_push ($this->entryArray, $rating);
131
+                if (!is_null ($rating)) {
132
+                    array_push ($this->entryArray, $rating);
133
+                }
125 134
             }
126 135
             if (!in_array ("language", getCurrentOption ('ignored_categories'))) {
127 136
                 $languages = Language::getCount();
128
-                if (!is_null ($languages)) array_push ($this->entryArray, $languages);
137
+                if (!is_null ($languages)) {
138
+                    array_push ($this->entryArray, $languages);
139
+                }
129 140
             }
130 141
             foreach ($config['cops_calibre_custom_column'] as $lookup) {
131 142
                 $customId = CustomColumn::getCustomId ($lookup);
@@ -135,7 +146,9 @@  discard block
 block discarded – undo
135 146
             }
136 147
             $this->entryArray = array_merge ($this->entryArray, Book::getCount());
137 148
 
138
-            if (Base::isMultipleDatabaseEnabled ()) $this->title =  Base::getDbName ();
149
+            if (Base::isMultipleDatabaseEnabled ()) {
150
+                $this->title =  Base::getDbName ();
151
+            }
139 152
         }
140 153
     }
141 154
 
@@ -171,8 +184,12 @@  discard block
 block discarded – undo
171 184
 
172 185
     public function containsBook ()
173 186
     {
174
-        if (count ($this->entryArray) == 0) return false;
175
-        if (get_class ($this->entryArray [0]) == "EntryBook") return true;
187
+        if (count ($this->entryArray) == 0) {
188
+            return false;
189
+        }
190
+        if (get_class ($this->entryArray [0]) == "EntryBook") {
191
+            return true;
192
+        }
176 193
         return false;
177 194
     }
178 195
 }
Please login to merge, or discard this patch.
lib/Data.php 1 patch
Braces   +42 added lines, -29 removed lines patch added patch discarded remove patch
@@ -55,7 +55,8 @@  discard block
 block discarded – undo
55 55
         'zip'   => 'application/zip'
56 56
     );
57 57
 
58
-    public function __construct($post, $book = null) {
58
+    public function __construct($post, $book = null)
59
+    {
59 60
         $this->id = $post->id;
60 61
         $this->name = $post->name;
61 62
         $this->format = $post->format;
@@ -64,19 +65,20 @@  discard block
 block discarded – undo
64 65
         $this->book = $book;
65 66
     }
66 67
 
67
-    public function isKnownType () {
68
+    public function isKnownType ()
69
+    {
68 70
         return array_key_exists ($this->extension, self::$mimetypes);
69 71
     }
70 72
 
71
-    public function getMimeType () {
73
+    public function getMimeType ()
74
+    {
72 75
         $result = "application/octet-stream";
73 76
         if ($this->isKnownType ()) {
74 77
             return self::$mimetypes [$this->extension];
75 78
         } elseif (function_exists('finfo_open') === true) {
76 79
             $finfo = finfo_open(FILEINFO_MIME_TYPE);
77 80
 
78
-            if (is_resource($finfo) === true)
79
-            {
81
+            if (is_resource($finfo) === true) {
80 82
                 $result = finfo_file($finfo, $this->getLocalPath ());
81 83
             }
82 84
 
@@ -86,27 +88,33 @@  discard block
 block discarded – undo
86 88
         return $result;
87 89
     }
88 90
 
89
-    public function isEpubValidOnKobo () {
91
+    public function isEpubValidOnKobo ()
92
+    {
90 93
         return $this->format == "EPUB" || $this->format == "KEPUB";
91 94
     }
92 95
 
93
-    public function getFilename () {
96
+    public function getFilename ()
97
+    {
94 98
         return $this->name . "." . strtolower ($this->format);
95 99
     }
96 100
 
97
-    public function getUpdatedFilename () {
101
+    public function getUpdatedFilename ()
102
+    {
98 103
         return $this->book->getAuthorsSort () . " - " . $this->book->title;
99 104
     }
100 105
 
101
-    public function getUpdatedFilenameEpub () {
106
+    public function getUpdatedFilenameEpub ()
107
+    {
102 108
         return $this->getUpdatedFilename () . ".epub";
103 109
     }
104 110
 
105
-    public function getUpdatedFilenameKepub () {
111
+    public function getUpdatedFilenameKepub ()
112
+    {
106 113
         return $this->getUpdatedFilename () . ".kepub.epub";
107 114
     }
108 115
 
109
-    public function getDataLink ($rel, $title = NULL) {
116
+    public function getDataLink ($rel, $title = NULL)
117
+    {
110 118
         global $config;
111 119
 
112 120
         if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") {
@@ -116,19 +124,24 @@  discard block
 block discarded – undo
116 124
         return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title);
117 125
     }
118 126
 
119
-    public function getHtmlLink () {
127
+    public function getHtmlLink ()
128
+    {
120 129
         return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE)->href;
121 130
     }
122 131
 
123
-    public function getLocalPath () {
132
+    public function getLocalPath ()
133
+    {
124 134
         return $this->book->path . "/" . $this->getFilename ();
125 135
     }
126 136
 
127
-    public function getHtmlLinkWithRewriting ($title = NULL) {
137
+    public function getHtmlLinkWithRewriting ($title = NULL)
138
+    {
128 139
         global $config;
129 140
 
130 141
         $database = "";
131
-        if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/";
142
+        if (!is_null (GetUrlParam (DB))) {
143
+            $database = GetUrlParam (DB) . "/";
144
+        }
132 145
 
133 146
         $href = "download/" . $this->id . "/" . $database;
134 147
 
@@ -142,28 +155,27 @@  discard block
 block discarded – undo
142 155
         return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title);
143 156
     }
144 157
 
145
-    public static function getDataByBook ($book) {
158
+    public static function getDataByBook ($book)
159
+    {
146 160
         $out = array ();
147 161
         $result = parent::getDb ()->prepare('select id, format, name
148 162
                                              from data where book = ?');
149 163
         $result->execute (array ($book->id));
150 164
 
151
-        while ($post = $result->fetchObject ())
152
-        {
165
+        while ($post = $result->fetchObject ()) {
153 166
             array_push ($out, new Data ($post, $book));
154 167
         }
155 168
         return $out;
156 169
     }
157 170
 
158
-    public static function handleThumbnailLink ($urlParam, $height) {
171
+    public static function handleThumbnailLink ($urlParam, $height)
172
+    {
159 173
         global $config;
160 174
 
161 175
         if (is_null ($height)) {
162 176
             if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
163 177
                 $height = $config['cops_opds_thumbnail_height'];
164
-            }
165
-            else
166
-            {
178
+            } else {
167 179
                 $height = $config['cops_html_thumbnail_height'];
168 180
             }
169 181
         }
@@ -182,14 +194,17 @@  discard block
 block discarded – undo
182 194
 
183 195
         if (Base::useAbsolutePath () ||
184 196
             $rel == Link::OPDS_THUMBNAIL_TYPE ||
185
-            ($type == "epub" && $config['cops_update_epub-metadata']))
186
-        {
187
-            if ($type != "jpg") $urlParam = addURLParameter($urlParam, "type", $type);
197
+            ($type == "epub" && $config['cops_update_epub-metadata'])) {
198
+            if ($type != "jpg") {
199
+                $urlParam = addURLParameter($urlParam, "type", $type);
200
+            }
188 201
             if ($rel == Link::OPDS_THUMBNAIL_TYPE) {
189 202
                 $urlParam = self::handleThumbnailLink($urlParam, $height);
190 203
             }
191 204
             $urlParam = addURLParameter($urlParam, "id", $book->id);
192
-            if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
205
+            if (!is_null (GetUrlParam (DB))) {
206
+                $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
207
+            }
193 208
             if ($config['cops_thumbnail_handling'] != "1" &&
194 209
                 !empty ($config['cops_thumbnail_handling']) &&
195 210
                 $rel == Link::OPDS_THUMBNAIL_TYPE) {
@@ -197,9 +212,7 @@  discard block
 block discarded – undo
197 212
             } else {
198 213
                 return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title);
199 214
             }
200
-        }
201
-        else
202
-        {
215
+        } else {
203 216
             return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title);
204 217
         }
205 218
     }
Please login to merge, or discard this patch.
lib/PageAllBooksLetter.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
         $this->idPage = Book::getEntryIdByLetter ($this->idGet);
15 15
 
16 16
         $count = $this->totalNumber;
17
-        if ($count == -1)
18
-            $count = count ($this->entryArray);
17
+        if ($count == -1) {
18
+                    $count = count ($this->entryArray);
19
+        }
19 20
 
20 21
         $this->title = str_format (localize ("splitByLetter.letter"), str_format (localize ("bookword", $count), $count), $this->idGet);
21 22
     }
Please login to merge, or discard this patch.
lib/EntryBook.php 1 patch
Braces   +12 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,24 +10,29 @@
 block discarded – undo
10 10
 {
11 11
     public $book;
12 12
 
13
-    public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pbook) {
13
+    public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pbook)
14
+    {
14 15
         parent::__construct ($ptitle, $pid, $pcontent, $pcontentType, $plinkArray);
15 16
         $this->book = $pbook;
16 17
         $this->localUpdated = $pbook->timestamp;
17 18
     }
18 19
 
19
-    public function getCoverThumbnail () {
20
+    public function getCoverThumbnail ()
21
+    {
20 22
         foreach ($this->linkArray as $link) {
21
-            if ($link->rel == Link::OPDS_THUMBNAIL_TYPE)
22
-                return $link->hrefXhtml ();
23
+            if ($link->rel == Link::OPDS_THUMBNAIL_TYPE) {
24
+                            return $link->hrefXhtml ();
25
+            }
23 26
         }
24 27
         return null;
25 28
     }
26 29
 
27
-    public function getCover () {
30
+    public function getCover ()
31
+    {
28 32
         foreach ($this->linkArray as $link) {
29
-            if ($link->rel == Link::OPDS_IMAGE_TYPE)
30
-                return $link->hrefXhtml ();
33
+            if ($link->rel == Link::OPDS_IMAGE_TYPE) {
34
+                            return $link->hrefXhtml ();
35
+            }
31 36
         }
32 37
         return null;
33 38
     }
Please login to merge, or discard this patch.
lib/LinkNavigation.php 1 patch
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,10 +8,15 @@
 block discarded – undo
8 8
 
9 9
 class LinkNavigation extends Link
10 10
 {
11
-    public function __construct($phref, $prel = NULL, $ptitle = NULL) {
11
+    public function __construct($phref, $prel = NULL, $ptitle = NULL)
12
+    {
12 13
         parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle);
13
-        if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
14
-        if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href;
14
+        if (!is_null (GetUrlParam (DB))) {
15
+            $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB));
16
+        }
17
+        if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) {
18
+            $this->href = "?" . $this->href;
19
+        }
15 20
         if (preg_match ("/(bookdetail|getJSON).php/", parent::getScriptName())) {
16 21
             $this->href = "index.php" . $this->href;
17 22
         } else {
Please login to merge, or discard this patch.