Test Setup Failed
Push — master ( 9fbeaf...6ecf0d )
by Sébastien
03:30 queued 33s
created
lib/PageAllBooksLetter.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,15 +8,15 @@
 block discarded – undo
8 8
 
9 9
 class PageAllBooksLetter extends Page
10 10
 {
11
-    public function InitializeContent ()
11
+    public function InitializeContent()
12 12
     {
13
-        list ($this->entryArray, $this->totalNumber) = Book::getBooksByStartingLetter ($this->idGet, $this->n);
14
-        $this->idPage = Book::getEntryIdByLetter ($this->idGet);
13
+        list ($this->entryArray, $this->totalNumber) = Book::getBooksByStartingLetter($this->idGet, $this->n);
14
+        $this->idPage = Book::getEntryIdByLetter($this->idGet);
15 15
 
16 16
         $count = $this->totalNumber;
17 17
         if ($count == -1)
18
-            $count = count ($this->entryArray);
18
+            $count = count($this->entryArray);
19 19
 
20
-        $this->title = str_format (localize ("splitByLetter.letter"), str_format (localize ("bookword", $count), $count), $this->idGet);
20
+        $this->title = str_format(localize("splitByLetter.letter"), str_format(localize("bookword", $count), $count), $this->idGet);
21 21
     }
22 22
 }
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
         $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/Entry.php 3 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -31,23 +31,23 @@  discard block
 block discarded – undo
31 31
         Publisher::ALL_PUBLISHERS_ID     => 'images/publisher.png'
32 32
     );
33 33
 
34
-    public function getUpdatedTime () {
35
-        if (!is_null ($this->localUpdated)) {
36
-            return date (DATE_ATOM, $this->localUpdated);
34
+    public function getUpdatedTime() {
35
+        if (!is_null($this->localUpdated)) {
36
+            return date(DATE_ATOM, $this->localUpdated);
37 37
         }
38
-        if (is_null (self::$updated)) {
38
+        if (is_null(self::$updated)) {
39 39
             self::$updated = time();
40 40
         }
41
-        return date (DATE_ATOM, self::$updated);
41
+        return date(DATE_ATOM, self::$updated);
42 42
     }
43 43
 
44
-    public function getNavLink () {
44
+    public function getNavLink() {
45 45
         foreach ($this->linkArray as $link) {
46 46
             /* @var $link LinkNavigation */
47 47
 
48 48
             if ($link->type != Link::OPDS_NAVIGATION_TYPE) { continue; }
49 49
 
50
-            return $link->hrefXhtml ();
50
+            return $link->hrefXhtml();
51 51
         }
52 52
         return "#";
53 53
     }
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
         {
67 67
             foreach (self::$icons as $reg => $image)
68 68
             {
69
-                if (preg_match ("/" . $reg . "/", $pid)) {
70
-                    array_push ($this->linkArray, new Link (getUrlWithVersion ($image), "image/png", Link::OPDS_THUMBNAIL_TYPE));
69
+                if (preg_match("/" . $reg . "/", $pid)) {
70
+                    array_push($this->linkArray, new Link(getUrlWithVersion($image), "image/png", Link::OPDS_THUMBNAIL_TYPE));
71 71
                     break;
72 72
                 }
73 73
             }
74 74
         }
75 75
 
76
-        if (!is_null (GetUrlParam (DB))) $this->id = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $this->id);
76
+        if (!is_null(GetUrlParam(DB))) $this->id = str_replace("cops:", "cops:" . GetUrlParam(DB) . ":", $this->id);
77 77
     }
78 78
 }
Please login to merge, or discard this patch.
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,7 +31,8 @@  discard block
 block discarded – undo
31 31
         Publisher::ALL_PUBLISHERS_ID     => 'images/publisher.png'
32 32
     );
33 33
 
34
-    public function getUpdatedTime () {
34
+    public function getUpdatedTime ()
35
+    {
35 36
         if (!is_null ($this->localUpdated)) {
36 37
             return date (DATE_ATOM, $this->localUpdated);
37 38
         }
@@ -41,7 +42,8 @@  discard block
 block discarded – undo
41 42
         return date (DATE_ATOM, self::$updated);
42 43
     }
43 44
 
44
-    public function getNavLink () {
45
+    public function getNavLink ()
46
+    {
45 47
         foreach ($this->linkArray as $link) {
46 48
             /* @var $link LinkNavigation */
47 49
 
@@ -52,7 +54,8 @@  discard block
 block discarded – undo
52 54
         return "#";
53 55
     }
54 56
 
55
-    public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pclass = "", $pcount = 0) {
57
+    public function __construct($ptitle, $pid, $pcontent, $pcontentType, $plinkArray, $pclass = "", $pcount = 0)
58
+    {
56 59
         global $config;
57 60
         $this->title = $ptitle;
58 61
         $this->id = $pid;
@@ -62,10 +65,8 @@  discard block
 block discarded – undo
62 65
         $this->className = $pclass;
63 66
         $this->numberOfElement = $pcount;
64 67
 
65
-        if ($config['cops_show_icons'] == 1)
66
-        {
67
-            foreach (self::$icons as $reg => $image)
68
-            {
68
+        if ($config['cops_show_icons'] == 1) {
69
+            foreach (self::$icons as $reg => $image) {
69 70
                 if (preg_match ("/" . $reg . "/", $pid)) {
70 71
                     array_push ($this->linkArray, new Link (getUrlWithVersion ($image), "image/png", Link::OPDS_THUMBNAIL_TYPE));
71 72
                     break;
@@ -73,6 +74,8 @@  discard block
 block discarded – undo
73 74
             }
74 75
         }
75 76
 
76
-        if (!is_null (GetUrlParam (DB))) $this->id = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $this->id);
77
+        if (!is_null (GetUrlParam (DB))) {
78
+            $this->id = str_replace ("cops:", "cops:" . GetUrlParam (DB) . ":", $this->id);
79
+        }
77 80
     }
78 81
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
     public $linkArray;
17 17
     public $localUpdated;
18 18
     public $className;
19
-    private static $updated = NULL;
19
+    private static $updated = null;
20 20
 
21 21
     public static $icons = array(
22 22
         Author::ALL_AUTHORS_ID           => 'images/author.png',
Please login to merge, or discard this patch.
lib/CustomColumnTypeSeries.php 1 patch
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         if ($post = $result->fetchObject()) {
58 58
             return new CustomColumn($id, $post->name, $this);
59 59
         }
60
-        return NULL;
60
+        return null;
61 61
     }
62 62
 
63 63
     protected function getAllCustomValuesFromDatabase()
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         if ($post = $result->fetchObject()) {
93 93
             return new CustomColumn($post->id, $post->name . " [" . $post->extra . "]", $this);
94 94
         }
95
-        return new CustomColumn(NULL, "", $this);
95
+        return new CustomColumn(null, "", $this);
96 96
     }
97 97
 
98 98
     public function isSearchable()
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.
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.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
 require_once dirname(__FILE__) . '/config.php';
4 4
 require_once dirname(__FILE__) . '/base.php';
5 5
 
6
-function checkConfiguration () {
6
+function checkConfiguration() {
7 7
     global $config;
8 8
 
9
-    if (is_null ($config['cops_mail_configuration']) ||
10
-        !is_array ($config['cops_mail_configuration']) ||
9
+    if (is_null($config['cops_mail_configuration']) ||
10
+        !is_array($config['cops_mail_configuration']) ||
11 11
         empty ($config['cops_mail_configuration']["smtp.host"]) ||
12 12
         empty ($config['cops_mail_configuration']["address.from"])) {
13 13
         return "NOK. bad configuration.";
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
     return False;
16 16
 }
17 17
 
18
-function checkRequest ($idData, $emailDest) {
18
+function checkRequest($idData, $emailDest) {
19 19
     if (empty ($idData)) {
20 20
         return 'No data sent.';
21 21
     }
@@ -29,22 +29,22 @@  discard block
 block discarded – undo
29 29
 
30 30
 global $config;
31 31
 
32
-if ($error = checkConfiguration ()) {
32
+if ($error = checkConfiguration()) {
33 33
     echo $error;
34 34
     exit;
35 35
 }
36 36
 
37 37
 $idData = $_REQUEST["data"];
38 38
 $emailDest = $_REQUEST["email"];
39
-if ($error = checkRequest ($idData, $emailDest)) {
39
+if ($error = checkRequest($idData, $emailDest)) {
40 40
     echo $error;
41 41
     exit;
42 42
 }
43 43
 
44 44
 $book = Book::getBookByDataId($idData);
45
-$data = $book->getDataById ($idData);
45
+$data = $book->getDataById($idData);
46 46
 
47
-if (filesize ($data->getLocalPath ()) > 10 * 1024 * 1024) {
47
+if (filesize($data->getLocalPath()) > 10 * 1024 * 1024) {
48 48
     echo 'Attachment too big';
49 49
     exit;
50 50
 }
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 $mail->From = $config['cops_mail_configuration']["address.from"];
67 67
 $mail->FromName = $config['cops_title_default'];
68 68
 
69
-foreach (explode (";", $emailDest) as $emailAddress) {
69
+foreach (explode(";", $emailDest) as $emailAddress) {
70 70
     if (empty ($emailAddress)) { continue; }
71 71
     $mail->AddAddress($emailAddress);
72 72
 }
73 73
 
74
-$mail->AddAttachment($data->getLocalPath ());
74
+$mail->AddAttachment($data->getLocalPath());
75 75
 
76 76
 $mail->IsHTML(true);
77 77
 $mail->CharSet = "UTF-8";
@@ -79,15 +79,15 @@  discard block
 block discarded – undo
79 79
 if (!empty ($config['cops_mail_configuration']["subject"])) {
80 80
     $mail->Subject = $config['cops_mail_configuration']["subject"];
81 81
 }
82
-$mail->Subject .= $data->getUpdatedFilename ();
83
-$mail->Body    = "<h1>" . $book->title . "</h1><h2>" . $book->getAuthorsName () . "</h2>" . $book->getComment ();
82
+$mail->Subject .= $data->getUpdatedFilename();
83
+$mail->Body    = "<h1>" . $book->title . "</h1><h2>" . $book->getAuthorsName() . "</h2>" . $book->getComment();
84 84
 $mail->AltBody = "Sent by COPS";
85 85
 
86 86
 if (!$mail->Send()) {
87
-   echo localize ("mail.messagenotsent");
87
+   echo localize("mail.messagenotsent");
88 88
    echo 'Mailer Error: ' . $mail->ErrorInfo;
89 89
    exit;
90 90
 }
91 91
 
92
-echo localize ("mail.messagesent");
92
+echo localize("mail.messagesent");
93 93
 
Please login to merge, or discard this patch.
Braces   +16 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3,7 +3,8 @@  discard block
 block discarded – undo
3 3
 require_once dirname(__FILE__) . '/config.php';
4 4
 require_once dirname(__FILE__) . '/base.php';
5 5
 
6
-function checkConfiguration () {
6
+function checkConfiguration ()
7
+{
7 8
     global $config;
8 9
 
9 10
     if (is_null ($config['cops_mail_configuration']) ||
@@ -15,7 +16,8 @@  discard block
 block discarded – undo
15 16
     return False;
16 17
 }
17 18
 
18
-function checkRequest ($idData, $emailDest) {
19
+function checkRequest ($idData, $emailDest)
20
+{
19 21
     if (empty ($idData)) {
20 22
         return 'No data sent.';
21 23
     }
@@ -59,10 +61,18 @@  discard block
 block discarded – undo
59 61
     $mail->Port = 465;
60 62
 }
61 63
 $mail->SMTPAuth = !empty ($config['cops_mail_configuration']["smtp.username"]);
62
-if (!empty ($config['cops_mail_configuration']["smtp.username"])) $mail->Username = $config['cops_mail_configuration']["smtp.username"];
63
-if (!empty ($config['cops_mail_configuration']["smtp.password"])) $mail->Password = $config['cops_mail_configuration']["smtp.password"];
64
-if (!empty ($config['cops_mail_configuration']["smtp.secure"])) $mail->SMTPSecure = $config['cops_mail_configuration']["smtp.secure"];
65
-if (!empty ($config['cops_mail_configuration']["smtp.port"])) $mail->Port = $config['cops_mail_configuration']["smtp.port"];
64
+if (!empty ($config['cops_mail_configuration']["smtp.username"])) {
65
+    $mail->Username = $config['cops_mail_configuration']["smtp.username"];
66
+}
67
+if (!empty ($config['cops_mail_configuration']["smtp.password"])) {
68
+    $mail->Password = $config['cops_mail_configuration']["smtp.password"];
69
+}
70
+if (!empty ($config['cops_mail_configuration']["smtp.secure"])) {
71
+    $mail->SMTPSecure = $config['cops_mail_configuration']["smtp.secure"];
72
+}
73
+if (!empty ($config['cops_mail_configuration']["smtp.port"])) {
74
+    $mail->Port = $config['cops_mail_configuration']["smtp.port"];
75
+}
66 76
 
67 77
 $mail->From = $config['cops_mail_configuration']["address.from"];
68 78
 $mail->FromName = $config['cops_title_default'];
Please login to merge, or discard this patch.
epubfs.php 2 patches
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.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
     return;
52 52
 }
53 53
 
54
-$idData = getURLParam('data', NULL);
54
+$idData = getURLParam('data', null);
55 55
 $add = 'data=' . $idData . '&';
56 56
 if (!is_null(GetUrlParam(DB))) {
57 57
     $add .= DB . '=' . GetUrlParam(DB) . '&';
Please login to merge, or discard this patch.
config.php 2 patches
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.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,20 +12,20 @@
 block discarded – undo
12 12
     require 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 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.
checkconfig.php 3 patches
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.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     <meta charset="utf-8">
27 27
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
28 28
     <title>COPS Configuration Check</title>
29
-    <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss ()) ?>" media="screen" />
29
+    <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss()) ?>" media="screen" />
30 30
 </head>
31 31
 <body>
32 32
 <div class="container">
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
             <h2>Check if the rendering will be done on client side or server side</h2>
152 152
             <h4>
153 153
             <?php
154
-            if (useServerSideRendering ()) {
154
+            if (useServerSideRendering()) {
155 155
                 echo 'Server side rendering';
156 156
             } else {
157 157
                 echo 'Client side rendering';
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
             <h2>Check if Calibre database path is not an URL</h2>
168 168
             <h4>
169 169
             <?php
170
-            if (!preg_match ('#^http#', $database)) {
170
+            if (!preg_match('#^http#', $database)) {
171 171
                 echo $name . ' OK';
172 172
             } else {
173 173
                 echo $name . ' Calibre path has to be local (no URL allowed)';
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
             <h4>
201 201
             <?php
202 202
             try {
203
-                $db = new PDO('sqlite:'. Base::getDbFileName($i));
203
+                $db = new PDO('sqlite:' . Base::getDbFileName($i));
204 204
                 echo $name . ' OK';
205 205
             } catch (Exception $e) {
206 206
                 echo $name . ' If the file is readable, check your php configuration. Exception detail : ' . $e;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
             <h4>
214 214
             <?php
215 215
             try {
216
-                $db = new PDO('sqlite:'. Base::getDbFileName($i));
216
+                $db = new PDO('sqlite:' . Base::getDbFileName($i));
217 217
                 $count = $db->query('select count(*) FROM sqlite_master WHERE type="table" AND name in ("books", "authors", "tags", "series")')->fetchColumn();
218 218
                 if ($count == 4) {
219 219
                     echo $name . ' OK';
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
                 $result->execute();
238 238
                 while ($post = $result->fetchObject())
239 239
                 {
240
-                    if (!is_file (Base::getDbDirectory($i) . $post->fullpath)) {
240
+                    if (!is_file(Base::getDbDirectory($i) . $post->fullpath)) {
241 241
                         echo '<p>' . Base::getDbDirectory($i) . $post->fullpath . '</p>';
242 242
                     }
243 243
                 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 
15 15
     $err   = getURLParam('err', -1);
16 16
     $full  = getURLParam('full');
17
-    $error = NULL;
17
+    $error = null;
18 18
     switch ($err) {
19 19
         case 1 :
20 20
             $error = 'Database error';
Please login to merge, or discard this patch.
lib/Data.php 5 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -152,6 +152,9 @@  discard block
 block discarded – undo
152 152
         return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title);
153 153
     }
154 154
 
155
+    /**
156
+     * @param Book $book
157
+     */
155 158
     public static function getDataByBook ($book) {
156 159
         $out = array ();
157 160
         $result = parent::getDb ()->prepare('select id, format, name
@@ -165,6 +168,9 @@  discard block
 block discarded – undo
165 168
         return $out;
166 169
     }
167 170
 
171
+    /**
172
+     * @param string $urlParam
173
+     */
168 174
     public static function handleThumbnailLink ($urlParam, $height) {
169 175
         global $config;
170 176
 
@@ -184,6 +190,10 @@  discard block
 block discarded – undo
184 190
         return $urlParam;
185 191
     }
186 192
 
193
+    /**
194
+     * @param string $type
195
+     * @param string $filename
196
+     */
187 197
     public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL, $view = false)
188 198
     {
189 199
         global $config;
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@
 block discarded – undo
105 105
     public function getUpdatedFilenameKepub () {
106 106
         $str = $this->getUpdatedFilename () . ".kepub.epub";
107 107
         return str_replace(array(':', '#', '&'),
108
-                           array('-', '-', ' '), $str );
108
+                            array('-', '-', ' '), $str );
109 109
     }
110 110
 
111 111
     public function getDataLink ($rel, $title = NULL, $view = false) {
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -59,25 +59,25 @@  discard block
 block discarded – undo
59 59
         $this->id = $post->id;
60 60
         $this->name = $post->name;
61 61
         $this->format = $post->format;
62
-        $this->realFormat = str_replace ("ORIGINAL_", "", $post->format);
63
-        $this->extension = strtolower ($this->realFormat);
62
+        $this->realFormat = str_replace("ORIGINAL_", "", $post->format);
63
+        $this->extension = strtolower($this->realFormat);
64 64
         $this->book = $book;
65 65
     }
66 66
 
67
-    public function isKnownType () {
68
-        return array_key_exists ($this->extension, self::$mimetypes);
67
+    public function isKnownType() {
68
+        return array_key_exists($this->extension, self::$mimetypes);
69 69
     }
70 70
 
71
-    public function getMimeType () {
71
+    public function getMimeType() {
72 72
         $result = "application/octet-stream";
73
-        if ($this->isKnownType ()) {
73
+        if ($this->isKnownType()) {
74 74
             return self::$mimetypes [$this->extension];
75 75
         } elseif (function_exists('finfo_open') === true) {
76 76
             $finfo = finfo_open(FILEINFO_MIME_TYPE);
77 77
 
78 78
             if (is_resource($finfo) === true)
79 79
             {
80
-                $result = finfo_file($finfo, $this->getLocalPath ());
80
+                $result = finfo_file($finfo, $this->getLocalPath());
81 81
             }
82 82
 
83 83
             finfo_close($finfo);
@@ -86,55 +86,55 @@  discard block
 block discarded – undo
86 86
         return $result;
87 87
     }
88 88
 
89
-    public function isEpubValidOnKobo () {
89
+    public function isEpubValidOnKobo() {
90 90
         return $this->format == "EPUB" || $this->format == "KEPUB";
91 91
     }
92 92
 
93
-    public function getFilename () {
94
-        return $this->name . "." . strtolower ($this->format);
93
+    public function getFilename() {
94
+        return $this->name . "." . strtolower($this->format);
95 95
     }
96 96
 
97
-    public function getUpdatedFilename () {
98
-        return $this->book->getAuthorsSort () . " - " . $this->book->title;
97
+    public function getUpdatedFilename() {
98
+        return $this->book->getAuthorsSort() . " - " . $this->book->title;
99 99
     }
100 100
 
101
-    public function getUpdatedFilenameEpub () {
102
-        return $this->getUpdatedFilename () . ".epub";
101
+    public function getUpdatedFilenameEpub() {
102
+        return $this->getUpdatedFilename() . ".epub";
103 103
     }
104 104
 
105
-    public function getUpdatedFilenameKepub () {
106
-        $str = $this->getUpdatedFilename () . ".kepub.epub";
105
+    public function getUpdatedFilenameKepub() {
106
+        $str = $this->getUpdatedFilename() . ".kepub.epub";
107 107
         return str_replace(array(':', '#', '&'),
108
-                           array('-', '-', ' '), $str );
108
+                           array('-', '-', ' '), $str);
109 109
     }
110 110
 
111
-    public function getDataLink ($rel, $title = NULL, $view = false) {
111
+    public function getDataLink($rel, $title = NULL, $view = false) {
112 112
         global $config;
113 113
 
114 114
         if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") {
115 115
             return $this->getHtmlLinkWithRewriting($title, $view);
116 116
         }
117 117
 
118
-        return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title, NULL, $view);
118
+        return self::getLink($this->book, $this->extension, $this->getMimeType(), $rel, $this->getFilename(), $this->id, $title, NULL, $view);
119 119
     }
120 120
 
121
-    public function getHtmlLink () {
121
+    public function getHtmlLink() {
122 122
         return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE)->href;
123 123
     }
124 124
 
125
-    public function getViewHtmlLink () {
125
+    public function getViewHtmlLink() {
126 126
         return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE, NULL, true)->href;
127 127
     }
128 128
 
129
-    public function getLocalPath () {
130
-        return $this->book->path . "/" . $this->getFilename ();
129
+    public function getLocalPath() {
130
+        return $this->book->path . "/" . $this->getFilename();
131 131
     }
132 132
 
133
-    public function getHtmlLinkWithRewriting ($title = NULL, $view = false) {
133
+    public function getHtmlLinkWithRewriting($title = NULL, $view = false) {
134 134
         global $config;
135 135
 
136 136
         $database = "";
137
-        if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/";
137
+        if (!is_null(GetUrlParam(DB))) $database = GetUrlParam(DB) . "/";
138 138
 
139 139
         $prefix = "download";
140 140
         if ($view) {
@@ -143,33 +143,33 @@  discard block
 block discarded – undo
143 143
         $href = $prefix . "/" . $this->id . "/" . $database;
144 144
 
145 145
         if ($config['cops_provide_kepub'] == "1" &&
146
-            $this->isEpubValidOnKobo () &&
146
+            $this->isEpubValidOnKobo() &&
147 147
             preg_match("/Kobo/", $_SERVER['HTTP_USER_AGENT'])) {
148
-            $href .= rawurlencode ($this->getUpdatedFilenameKepub ());
148
+            $href .= rawurlencode($this->getUpdatedFilenameKepub());
149 149
         } else {
150
-            $href .= rawurlencode ($this->getFilename ());
150
+            $href .= rawurlencode($this->getFilename());
151 151
         }
152
-        return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title);
152
+        return new Link($href, $this->getMimeType(), Link::OPDS_ACQUISITION_TYPE, $title);
153 153
     }
154 154
 
155
-    public static function getDataByBook ($book) {
156
-        $out = array ();
157
-        $result = parent::getDb ()->prepare('select id, format, name
155
+    public static function getDataByBook($book) {
156
+        $out = array();
157
+        $result = parent::getDb()->prepare('select id, format, name
158 158
                                              from data where book = ?');
159
-        $result->execute (array ($book->id));
159
+        $result->execute(array($book->id));
160 160
 
161
-        while ($post = $result->fetchObject ())
161
+        while ($post = $result->fetchObject())
162 162
         {
163
-            array_push ($out, new Data ($post, $book));
163
+            array_push($out, new Data($post, $book));
164 164
         }
165 165
         return $out;
166 166
     }
167 167
 
168
-    public static function handleThumbnailLink ($urlParam, $height) {
168
+    public static function handleThumbnailLink($urlParam, $height) {
169 169
         global $config;
170 170
 
171
-        if (is_null ($height)) {
172
-            if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
171
+        if (is_null($height)) {
172
+            if (preg_match('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
173 173
                 $height = $config['cops_opds_thumbnail_height'];
174 174
             }
175 175
             else
@@ -184,14 +184,14 @@  discard block
 block discarded – undo
184 184
         return $urlParam;
185 185
     }
186 186
 
187
-    public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL, $view = false)
187
+    public static function getLink($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL, $view = false)
188 188
     {
189 189
         global $config;
190 190
 
191 191
         $urlParam = addURLParameter("", "data", $idData);
192 192
         if ($view) $urlParam = addURLParameter($urlParam, "view", 1);
193 193
 
194
-        if (Base::useAbsolutePath () ||
194
+        if (Base::useAbsolutePath() ||
195 195
             $rel == Link::OPDS_THUMBNAIL_TYPE ||
196 196
             ($type == "epub" && $config['cops_update_epub-metadata']))
197 197
         {
@@ -200,18 +200,18 @@  discard block
 block discarded – undo
200 200
                 $urlParam = self::handleThumbnailLink($urlParam, $height);
201 201
             }
202 202
             $urlParam = addURLParameter($urlParam, "id", $book->id);
203
-            if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
203
+            if (!is_null(GetUrlParam(DB))) $urlParam = addURLParameter($urlParam, DB, GetUrlParam(DB));
204 204
             if ($config['cops_thumbnail_handling'] != "1" &&
205 205
                 !empty ($config['cops_thumbnail_handling']) &&
206 206
                 $rel == Link::OPDS_THUMBNAIL_TYPE) {
207
-                return new Link ($config['cops_thumbnail_handling'], $mime, $rel, $title);
207
+                return new Link($config['cops_thumbnail_handling'], $mime, $rel, $title);
208 208
             } else {
209
-                return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title);
209
+                return new Link("fetch.php?" . $urlParam, $mime, $rel, $title);
210 210
             }
211 211
         }
212 212
         else
213 213
         {
214
-            return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title);
214
+            return new Link(str_replace('%2F', '/', rawurlencode($book->path . "/" . $filename)), $mime, $rel, $title);
215 215
         }
216 216
     }
217 217
 }
Please login to merge, or discard this patch.
Braces   +47 added lines, -31 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,29 +88,35 @@  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
         $str = $this->getUpdatedFilename () . ".kepub.epub";
107 114
         return str_replace(array(':', '#', '&'),
108 115
                            array('-', '-', ' '), $str );
109 116
     }
110 117
 
111
-    public function getDataLink ($rel, $title = NULL, $view = false) {
118
+    public function getDataLink ($rel, $title = NULL, $view = false)
119
+    {
112 120
         global $config;
113 121
 
114 122
         if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") {
@@ -118,23 +126,29 @@  discard block
 block discarded – undo
118 126
         return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title, NULL, $view);
119 127
     }
120 128
 
121
-    public function getHtmlLink () {
129
+    public function getHtmlLink ()
130
+    {
122 131
         return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE)->href;
123 132
     }
124 133
 
125
-    public function getViewHtmlLink () {
134
+    public function getViewHtmlLink ()
135
+    {
126 136
         return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE, NULL, true)->href;
127 137
     }
128 138
 
129
-    public function getLocalPath () {
139
+    public function getLocalPath ()
140
+    {
130 141
         return $this->book->path . "/" . $this->getFilename ();
131 142
     }
132 143
 
133
-    public function getHtmlLinkWithRewriting ($title = NULL, $view = false) {
144
+    public function getHtmlLinkWithRewriting ($title = NULL, $view = false)
145
+    {
134 146
         global $config;
135 147
 
136 148
         $database = "";
137
-        if (!is_null (GetUrlParam (DB))) $database = GetUrlParam (DB) . "/";
149
+        if (!is_null (GetUrlParam (DB))) {
150
+            $database = GetUrlParam (DB) . "/";
151
+        }
138 152
 
139 153
         $prefix = "download";
140 154
         if ($view) {
@@ -152,28 +166,27 @@  discard block
 block discarded – undo
152 166
         return new Link ($href, $this->getMimeType (), Link::OPDS_ACQUISITION_TYPE, $title);
153 167
     }
154 168
 
155
-    public static function getDataByBook ($book) {
169
+    public static function getDataByBook ($book)
170
+    {
156 171
         $out = array ();
157 172
         $result = parent::getDb ()->prepare('select id, format, name
158 173
                                              from data where book = ?');
159 174
         $result->execute (array ($book->id));
160 175
 
161
-        while ($post = $result->fetchObject ())
162
-        {
176
+        while ($post = $result->fetchObject ()) {
163 177
             array_push ($out, new Data ($post, $book));
164 178
         }
165 179
         return $out;
166 180
     }
167 181
 
168
-    public static function handleThumbnailLink ($urlParam, $height) {
182
+    public static function handleThumbnailLink ($urlParam, $height)
183
+    {
169 184
         global $config;
170 185
 
171 186
         if (is_null ($height)) {
172 187
             if (preg_match ('/feed.php/', $_SERVER["SCRIPT_NAME"])) {
173 188
                 $height = $config['cops_opds_thumbnail_height'];
174
-            }
175
-            else
176
-            {
189
+            } else {
177 190
                 $height = $config['cops_html_thumbnail_height'];
178 191
             }
179 192
         }
@@ -189,18 +202,23 @@  discard block
 block discarded – undo
189 202
         global $config;
190 203
 
191 204
         $urlParam = addURLParameter("", "data", $idData);
192
-        if ($view) $urlParam = addURLParameter($urlParam, "view", 1);
205
+        if ($view) {
206
+            $urlParam = addURLParameter($urlParam, "view", 1);
207
+        }
193 208
 
194 209
         if (Base::useAbsolutePath () ||
195 210
             $rel == Link::OPDS_THUMBNAIL_TYPE ||
196
-            ($type == "epub" && $config['cops_update_epub-metadata']))
197
-        {
198
-            if ($type != "jpg") $urlParam = addURLParameter($urlParam, "type", $type);
211
+            ($type == "epub" && $config['cops_update_epub-metadata'])) {
212
+            if ($type != "jpg") {
213
+                $urlParam = addURLParameter($urlParam, "type", $type);
214
+            }
199 215
             if ($rel == Link::OPDS_THUMBNAIL_TYPE) {
200 216
                 $urlParam = self::handleThumbnailLink($urlParam, $height);
201 217
             }
202 218
             $urlParam = addURLParameter($urlParam, "id", $book->id);
203
-            if (!is_null (GetUrlParam (DB))) $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
219
+            if (!is_null (GetUrlParam (DB))) {
220
+                $urlParam = addURLParameter ($urlParam, DB, GetUrlParam (DB));
221
+            }
204 222
             if ($config['cops_thumbnail_handling'] != "1" &&
205 223
                 !empty ($config['cops_thumbnail_handling']) &&
206 224
                 $rel == Link::OPDS_THUMBNAIL_TYPE) {
@@ -208,9 +226,7 @@  discard block
 block discarded – undo
208 226
             } else {
209 227
                 return new Link ("fetch.php?" . $urlParam, $mime, $rel, $title);
210 228
             }
211
-        }
212
-        else
213
-        {
229
+        } else {
214 230
             return new Link (str_replace('%2F','/',rawurlencode ($book->path."/".$filename)), $mime, $rel, $title);
215 231
         }
216 232
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
                            array('-', '-', ' '), $str );
109 109
     }
110 110
 
111
-    public function getDataLink ($rel, $title = NULL, $view = false) {
111
+    public function getDataLink ($rel, $title = null, $view = false) {
112 112
         global $config;
113 113
 
114 114
         if ($rel == Link::OPDS_ACQUISITION_TYPE && $config['cops_use_url_rewriting'] == "1") {
115 115
             return $this->getHtmlLinkWithRewriting($title, $view);
116 116
         }
117 117
 
118
-        return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title, NULL, $view);
118
+        return self::getLink ($this->book, $this->extension, $this->getMimeType (), $rel, $this->getFilename (), $this->id, $title, null, $view);
119 119
     }
120 120
 
121 121
     public function getHtmlLink () {
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
     }
124 124
 
125 125
     public function getViewHtmlLink () {
126
-        return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE, NULL, true)->href;
126
+        return $this->getDataLink(Link::OPDS_ACQUISITION_TYPE, null, true)->href;
127 127
     }
128 128
 
129 129
     public function getLocalPath () {
130 130
         return $this->book->path . "/" . $this->getFilename ();
131 131
     }
132 132
 
133
-    public function getHtmlLinkWithRewriting ($title = NULL, $view = false) {
133
+    public function getHtmlLinkWithRewriting ($title = null, $view = false) {
134 134
         global $config;
135 135
 
136 136
         $database = "";
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         return $urlParam;
185 185
     }
186 186
 
187
-    public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = NULL, $height = NULL, $view = false)
187
+    public static function getLink ($book, $type, $mime, $rel, $filename, $idData, $title = null, $height = null, $view = false)
188 188
     {
189 189
         global $config;
190 190
 
Please login to merge, or discard this patch.