@@ -12,20 +12,20 @@ |
||
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_once 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"'); |
@@ -26,7 +26,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -3,11 +3,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -8,8 +8,8 @@ discard block |
||
8 | 8 | |
9 | 9 | require 'config.php'; |
10 | 10 | |
11 | -define ('VERSION', '1.1.1'); |
|
12 | -define ('DB', 'db'); |
|
11 | +define('VERSION', '1.1.1'); |
|
12 | +define('DB', 'db'); |
|
13 | 13 | date_default_timezone_set($config['default_timezone']); |
14 | 14 | |
15 | 15 | |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | function serverSideRender($data) |
23 | 23 | { |
24 | 24 | // Get the templates |
25 | - $theme = getCurrentTemplate (); |
|
25 | + $theme = getCurrentTemplate(); |
|
26 | 26 | $header = file_get_contents('templates/' . $theme . '/header.html'); |
27 | 27 | $footer = file_get_contents('templates/' . $theme . '/footer.html'); |
28 | 28 | $main = file_get_contents('templates/' . $theme . '/main.html'); |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | $page = file_get_contents('templates/' . $theme . '/page.html'); |
31 | 31 | |
32 | 32 | // Generate the function for the template |
33 | - $template = new doT (); |
|
34 | - $dot = $template->template ($page, array ('bookdetail' => $bookdetail, |
|
33 | + $template = new doT(); |
|
34 | + $dot = $template->template($page, array('bookdetail' => $bookdetail, |
|
35 | 35 | 'header' => $header, |
36 | 36 | 'footer' => $footer, |
37 | 37 | 'main' => $main)); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | } |
43 | 43 | // Execute the template |
44 | 44 | if (!empty ($data)) { |
45 | - return $dot ($data); |
|
45 | + return $dot($data); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | return NULL; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | function notFound() |
60 | 60 | { |
61 | - header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); |
|
61 | + header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); |
|
62 | 62 | header('Status: 404 Not Found'); |
63 | 63 | |
64 | 64 | $_SERVER['REDIRECT_STATUS'] = 404; |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | { |
77 | 77 | global $config; |
78 | 78 | if (isset($_COOKIE[$option])) { |
79 | - if (isset($config ['cops_' . $option]) && is_array ($config ['cops_' . $option])) { |
|
80 | - return explode (',', $_COOKIE[$option]); |
|
79 | + if (isset($config ['cops_' . $option]) && is_array($config ['cops_' . $option])) { |
|
80 | + return explode(',', $_COOKIE[$option]); |
|
81 | 81 | } else { |
82 | 82 | return $_COOKIE[$option]; |
83 | 83 | } |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | |
92 | 92 | function getCurrentCss() |
93 | 93 | { |
94 | - return 'templates/' . getCurrentTemplate () . '/styles/style-' . getCurrentOption('style') . '.css'; |
|
94 | + return 'templates/' . getCurrentTemplate() . '/styles/style-' . getCurrentOption('style') . '.css'; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | function getCurrentTemplate() |
98 | 98 | { |
99 | - return getCurrentOption ('template'); |
|
99 | + return getCurrentOption('template'); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | function getUrlWithVersion($url) |
@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | libxml_use_internal_errors(true); |
161 | 161 | |
162 | 162 | $doc->loadHTML('<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body>' . |
163 | - $html . '</body></html>'); // Load the HTML |
|
163 | + $html . '</body></html>'); // Load the HTML |
|
164 | 164 | $output = $doc->saveXML($doc->documentElement); // Transform to an Ansi xml stream |
165 | 165 | $output = xml2xhtml($output); |
166 | - if (preg_match ('#<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></meta></head><body>(.*)</body></html>#ms', $output, $matches)) { |
|
166 | + if (preg_match('#<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></meta></head><body>(.*)</body></html>#ms', $output, $matches)) { |
|
167 | 167 | $output = $matches [1]; // Remove <html><body> |
168 | 168 | } |
169 | 169 | /* |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | */ |
177 | 177 | |
178 | - if (!are_libxml_errors_ok ()) $output = 'HTML code not valid.'; |
|
178 | + if (!are_libxml_errors_ok()) $output = 'HTML code not valid.'; |
|
179 | 179 | |
180 | 180 | libxml_use_internal_errors(false); |
181 | 181 | return $output; |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | //echo var_dump($langs); |
265 | 265 | $lang_file = NULL; |
266 | 266 | foreach ($langs as $language => $val) { |
267 | - $temp_file = dirname(__FILE__). '/lang/Localization_' . $language . '.json'; |
|
267 | + $temp_file = dirname(__FILE__) . '/lang/Localization_' . $language . '.json'; |
|
268 | 268 | if (file_exists($temp_file)) { |
269 | 269 | $lang = $language; |
270 | 270 | $lang_file = $temp_file; |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | } |
273 | 273 | } |
274 | 274 | if (empty ($lang_file)) { |
275 | - $lang_file = dirname(__FILE__). '/lang/Localization_' . $lang . '.json'; |
|
275 | + $lang_file = dirname(__FILE__) . '/lang/Localization_' . $lang . '.json'; |
|
276 | 276 | } |
277 | 277 | return array($lang, $lang_file); |
278 | 278 | } |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * This method is based on this page |
282 | 282 | * http://www.mind-it.info/2010/02/22/a-simple-approach-to-localization-in-php/ |
283 | 283 | */ |
284 | -function localize($phrase, $count=-1, $reset=false) |
|
284 | +function localize($phrase, $count = -1, $reset = false) |
|
285 | 285 | { |
286 | 286 | global $config; |
287 | 287 | if ($count == 0) |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | $lang_file_en = NULL; |
302 | 302 | list ($lang, $lang_file) = getLangAndTranslationFile(); |
303 | 303 | if ($lang != 'en') { |
304 | - $lang_file_en = dirname(__FILE__). '/lang/' . 'Localization_en.json'; |
|
304 | + $lang_file_en = dirname(__FILE__) . '/lang/' . 'Localization_en.json'; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | $lang_file_content = file_get_contents($lang_file); |
@@ -309,18 +309,18 @@ discard block |
||
309 | 309 | $translations = json_decode($lang_file_content, true); |
310 | 310 | |
311 | 311 | /* Clean the array of all unfinished translations */ |
312 | - foreach (array_keys ($translations) as $key) { |
|
313 | - if (preg_match ('/^##TODO##/', $key)) { |
|
312 | + foreach (array_keys($translations) as $key) { |
|
313 | + if (preg_match('/^##TODO##/', $key)) { |
|
314 | 314 | unset ($translations [$key]); |
315 | 315 | } |
316 | 316 | } |
317 | 317 | if (!is_null($lang_file_en)) { |
318 | 318 | $lang_file_content = file_get_contents($lang_file_en); |
319 | 319 | $translations_en = json_decode($lang_file_content, true); |
320 | - $translations = array_merge ($translations_en, $translations); |
|
320 | + $translations = array_merge($translations_en, $translations); |
|
321 | 321 | } |
322 | 322 | } |
323 | - if (array_key_exists ($phrase, $translations)) { |
|
323 | + if (array_key_exists($phrase, $translations)) { |
|
324 | 324 | return $translations[$phrase]; |
325 | 325 | } |
326 | 326 | return $phrase; |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | $urlParams = ''; |
333 | 333 | } |
334 | 334 | $start = ''; |
335 | - if (preg_match ('#^\?(.*)#', $urlParams, $matches)) { |
|
335 | + if (preg_match('#^\?(.*)#', $urlParams, $matches)) { |
|
336 | 336 | $start = '?'; |
337 | 337 | $urlParams = $matches[1]; |
338 | 338 | } |