@@ -8,10 +8,15 @@ |
||
| 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 { |
@@ -31,7 +31,8 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -149,7 +149,9 @@ discard block |
||
| 149 | 149 | $errors = libxml_get_errors(); |
| 150 | 150 | |
| 151 | 151 | foreach ($errors as $error) { |
| 152 | - if ($error->code == 801) return false; |
|
| 152 | + if ($error->code == 801) { |
|
| 153 | + return false; |
|
| 154 | + } |
|
| 153 | 155 | } |
| 154 | 156 | return true; |
| 155 | 157 | } |
@@ -175,7 +177,9 @@ discard block |
||
| 175 | 177 | } |
| 176 | 178 | */ |
| 177 | 179 | |
| 178 | - if (!are_libxml_errors_ok ()) $output = 'HTML code not valid.'; |
|
| 180 | + if (!are_libxml_errors_ok ()) { |
|
| 181 | + $output = 'HTML code not valid.'; |
|
| 182 | + } |
|
| 179 | 183 | |
| 180 | 184 | libxml_use_internal_errors(false); |
| 181 | 185 | return $output; |
@@ -235,7 +239,9 @@ discard block |
||
| 235 | 239 | |
| 236 | 240 | // set default to 1 for any without q factor |
| 237 | 241 | foreach ($langs as $lang => $val) { |
| 238 | - if ($val === '') $langs[$lang] = 1; |
|
| 242 | + if ($val === '') { |
|
| 243 | + $langs[$lang] = 1; |
|
| 244 | + } |
|
| 239 | 245 | } |
| 240 | 246 | |
| 241 | 247 | // sort list based on value |
@@ -257,8 +263,7 @@ discard block |
||
| 257 | 263 | $lang = 'en'; |
| 258 | 264 | if (!empty($config['cops_language'])) { |
| 259 | 265 | $lang = $config['cops_language']; |
| 260 | - } |
|
| 261 | - elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
| 266 | + } elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
| 262 | 267 | $langs = getAcceptLanguages(); |
| 263 | 268 | } |
| 264 | 269 | //echo var_dump($langs); |
@@ -284,12 +289,15 @@ discard block |
||
| 284 | 289 | function localize($phrase, $count=-1, $reset=false) |
| 285 | 290 | { |
| 286 | 291 | global $config; |
| 287 | - if ($count == 0) |
|
| 288 | - $phrase .= '.none'; |
|
| 289 | - if ($count == 1) |
|
| 290 | - $phrase .= '.one'; |
|
| 291 | - if ($count > 1) |
|
| 292 | - $phrase .= '.many'; |
|
| 292 | + if ($count == 0) { |
|
| 293 | + $phrase .= '.none'; |
|
| 294 | + } |
|
| 295 | + if ($count == 1) { |
|
| 296 | + $phrase .= '.one'; |
|
| 297 | + } |
|
| 298 | + if ($count > 1) { |
|
| 299 | + $phrase .= '.many'; |
|
| 300 | + } |
|
| 293 | 301 | |
| 294 | 302 | /* Static keyword is used to ensure the file is loaded only once */ |
| 295 | 303 | static $translations = NULL; |
@@ -21,13 +21,11 @@ |
||
| 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'; |
@@ -237,8 +237,7 @@ |
||
| 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 | } |
@@ -55,7 +55,9 @@ |
||
| 55 | 55 | public function getDescription() |
| 56 | 56 | { |
| 57 | 57 | $desc = $this->getDatabaseDescription(); |
| 58 | - if ($desc === NULL || empty($desc)) $desc = str_format(localize("customcolumn.description"), $this->getTitle()); |
|
| 58 | + if ($desc === NULL || empty($desc)) { |
|
| 59 | + $desc = str_format(localize("customcolumn.description"), $this->getTitle()); |
|
| 60 | + } |
|
| 59 | 61 | return $desc; |
| 60 | 62 | } |
| 61 | 63 | |
@@ -55,7 +55,9 @@ |
||
| 55 | 55 | public function getDescription() |
| 56 | 56 | { |
| 57 | 57 | $desc = $this->getDatabaseDescription(); |
| 58 | - if ($desc === NULL || empty($desc)) $desc = str_format(localize("customcolumn.description"), $this->getTitle()); |
|
| 58 | + if ($desc === NULL || empty($desc)) { |
|
| 59 | + $desc = str_format(localize("customcolumn.description"), $this->getTitle()); |
|
| 60 | + } |
|
| 59 | 61 | return $desc; |
| 60 | 62 | } |
| 61 | 63 | |
@@ -55,7 +55,9 @@ |
||
| 55 | 55 | public function getDescription() |
| 56 | 56 | { |
| 57 | 57 | $desc = $this->getDatabaseDescription(); |
| 58 | - if ($desc === NULL || empty($desc)) $desc = str_format(localize("customcolumn.description"), $this->getTitle()); |
|
| 58 | + if ($desc === NULL || empty($desc)) { |
|
| 59 | + $desc = str_format(localize("customcolumn.description"), $this->getTitle()); |
|
| 60 | + } |
|
| 59 | 61 | return $desc; |
| 60 | 62 | } |
| 61 | 63 | |
@@ -3,7 +3,8 @@ 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 | 8 | global $config; |
| 8 | 9 | |
| 9 | 10 | if (is_null ($config['cops_mail_configuration']) || |
@@ -15,7 +16,8 @@ discard block |
||
| 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 |
||
| 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']; |