Completed
Push — master ( 3facbb...d7e1eb )
by Markus
04:20
created
sendtomail.php 1 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.
epubfs.php 1 patch
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.
transliteration.php 1 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.
epubreader.php 1 patch
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.
feed.php 1 patch
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.
index.php 1 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.
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 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,20 +12,20 @@
 block discarded – undo
12 12
     require_once '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.
config_default.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      * The two first will be displayed in book entries
107 107
      * The other only appear in book detail
108 108
      */
109
-    $config['cops_prefered_format'] = array ("EPUB", "PDF", "AZW3", "AZW", "MOBI", "CBR", "CBZ");
109
+    $config['cops_prefered_format'] = array("EPUB", "PDF", "AZW3", "AZW", "MOBI", "CBR", "CBZ");
110 110
 
111 111
     /*
112 112
      * use URL rewriting for downloading of ebook in HTML catalog
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      *
169 169
      * Example : array ("All" => "", "Unread" => "!Read", "Read" => "Read")
170 170
      */
171
-    $config['cops_books_filter'] = array ();
171
+    $config['cops_books_filter'] = array();
172 172
 
173 173
     /*
174 174
      * Custom Columns to add  as an array containing the lookup names
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      *
179 179
      * Note that for now only the first, second and forth type of custom columns are supported
180 180
      */
181
-    $config['cops_calibre_custom_column'] = array ();
181
+    $config['cops_calibre_custom_column'] = array();
182 182
 
183 183
     /*
184 184
      * Rename .epub to .kepub.epub if downloaded from a Kobo eReader
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
      * - rating
257 257
      * - language
258 258
      */
259
-    $config ['cops_ignored_categories'] = array ();
259
+    $config ['cops_ignored_categories'] = array();
260 260
 
261 261
     /*
262 262
      * If you use a Sony eReader or Aldiko you can't download ebooks if your catalog
Please login to merge, or discard this patch.