@@ -13,19 +13,19 @@ discard block |
||
| 13 | 13 | if ($config ['cops_fetch_protect'] == "1") { |
| 14 | 14 | session_start(); |
| 15 | 15 | if (!isset($_SESSION['connected'])) { |
| 16 | - notFound (); |
|
| 16 | + notFound(); |
|
| 17 | 17 | return; |
| 18 | 18 | } |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - $expires = 60*60*24*14; |
|
| 21 | + $expires = 60 * 60 * 24 * 14; |
|
| 22 | 22 | header("Pragma: public"); |
| 23 | - header("Cache-Control: maxage=".$expires); |
|
| 24 | - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT'); |
|
| 25 | - $bookId = getURLParam ("id", NULL); |
|
| 26 | - $type = getURLParam ("type", "jpg"); |
|
| 27 | - $idData = getURLParam ("data", NULL); |
|
| 28 | - if (is_null ($bookId)) |
|
| 23 | + header("Cache-Control: maxage=" . $expires); |
|
| 24 | + header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); |
|
| 25 | + $bookId = getURLParam("id", NULL); |
|
| 26 | + $type = getURLParam("type", "jpg"); |
|
| 27 | + $idData = getURLParam("data", NULL); |
|
| 28 | + if (is_null($bookId)) |
|
| 29 | 29 | { |
| 30 | 30 | $book = Book::getBookByDataId($idData); |
| 31 | 31 | } |
@@ -35,18 +35,18 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | if (!$book) { |
| 38 | - notFound (); |
|
| 38 | + notFound(); |
|
| 39 | 39 | return; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | if ($book && ($type == "jpg" || empty ($config['calibre_internal_directory']))) { |
| 43 | 43 | if ($type == "jpg") { |
| 44 | - $file = $book->getFilePath ($type); |
|
| 44 | + $file = $book->getFilePath($type); |
|
| 45 | 45 | } else { |
| 46 | - $file = $book->getFilePath ($type, $idData); |
|
| 46 | + $file = $book->getFilePath($type, $idData); |
|
| 47 | 47 | } |
| 48 | - if (!$file || !file_exists ($file)) { |
|
| 49 | - notFound (); |
|
| 48 | + if (!$file || !file_exists($file)) { |
|
| 49 | + notFound(); |
|
| 50 | 50 | return; |
| 51 | 51 | } |
| 52 | 52 | } |
@@ -57,17 +57,17 @@ discard block |
||
| 57 | 57 | header("Content-Type: image/jpeg"); |
| 58 | 58 | //by default, we don't cache |
| 59 | 59 | $thumbnailCacheFullpath = null; |
| 60 | - if ( isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '' ) { |
|
| 60 | + if (isset($config['cops_thumbnail_cache_directory']) && $config['cops_thumbnail_cache_directory'] !== '') { |
|
| 61 | 61 | $thumbnailCacheFullpath = $config['cops_thumbnail_cache_directory']; |
| 62 | 62 | //if multiple databases, add a subfolder with the database ID |
| 63 | - $thumbnailCacheFullpath .= !is_null (GetUrlParam (DB)) ? 'db-' . GetUrlParam (DB) . DIRECTORY_SEPARATOR : ''; |
|
| 63 | + $thumbnailCacheFullpath .= !is_null(GetUrlParam(DB))?'db-' . GetUrlParam(DB) . DIRECTORY_SEPARATOR:''; |
|
| 64 | 64 | //when there are lots of thumbnails, it's better to save files in subfolders, so if the book's uuid is |
| 65 | 65 | //"01234567-89ab-cdef-0123-456789abcdef", we will save the thumbnail in .../0/12/34567-89ab-cdef-0123-456789abcdef-... |
| 66 | 66 | $thumbnailCacheFullpath .= substr($book->uuid, 0, 1) . DIRECTORY_SEPARATOR . substr($book->uuid, 1, 2) . DIRECTORY_SEPARATOR; |
| 67 | 67 | //check if cache folder exists or create it |
| 68 | - if ( file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true) ) { |
|
| 68 | + if (file_exists($thumbnailCacheFullpath) || mkdir($thumbnailCacheFullpath, 0700, true)) { |
|
| 69 | 69 | //we name the thumbnail from the book's uuid and it's dimensions (width and/or height) |
| 70 | - $thumbnailCacheName = substr($book->uuid, 3) . '-' . getURLParam ("width") . 'x' . getURLParam ("height") . '.jpg'; |
|
| 70 | + $thumbnailCacheName = substr($book->uuid, 3) . '-' . getURLParam("width") . 'x' . getURLParam("height") . '.jpg'; |
|
| 71 | 71 | $thumbnailCacheFullpath = $thumbnailCacheFullpath . $thumbnailCacheName; |
| 72 | 72 | } |
| 73 | 73 | else { |
@@ -76,45 +76,45 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - if ( $thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath) ) { |
|
| 79 | + if ($thumbnailCacheFullpath !== null && file_exists($thumbnailCacheFullpath)) { |
|
| 80 | 80 | //return the already cached thumbnail |
| 81 | - readfile( $thumbnailCacheFullpath ); |
|
| 81 | + readfile($thumbnailCacheFullpath); |
|
| 82 | 82 | return; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - if ($book->getThumbnail (getURLParam ("width"), getURLParam ("height"), $thumbnailCacheFullpath)) { |
|
| 85 | + if ($book->getThumbnail(getURLParam("width"), getURLParam("height"), $thumbnailCacheFullpath)) { |
|
| 86 | 86 | //if we don't cache the thumbnail, imagejpeg() in $book->getThumbnail() already return the image data |
| 87 | - if ( $thumbnailCacheFullpath === null ) { |
|
| 87 | + if ($thumbnailCacheFullpath === null) { |
|
| 88 | 88 | // The cover had to be resized |
| 89 | 89 | return; |
| 90 | 90 | } |
| 91 | 91 | else { |
| 92 | 92 | //return the just cached thumbnail |
| 93 | - readfile( $thumbnailCacheFullpath ); |
|
| 93 | + readfile($thumbnailCacheFullpath); |
|
| 94 | 94 | return; |
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | break; |
| 98 | 98 | default: |
| 99 | - $data = $book->getDataById ($idData); |
|
| 100 | - header("Content-Type: " . $data->getMimeType ()); |
|
| 99 | + $data = $book->getDataById($idData); |
|
| 100 | + header("Content-Type: " . $data->getMimeType()); |
|
| 101 | 101 | break; |
| 102 | 102 | } |
| 103 | - $file = $book->getFilePath ($type, $idData, true); |
|
| 103 | + $file = $book->getFilePath($type, $idData, true); |
|
| 104 | 104 | if ($type == "epub" && $config['cops_update_epub-metadata']) |
| 105 | 105 | { |
| 106 | - $book->getUpdatedEpub ($idData); |
|
| 106 | + $book->getUpdatedEpub($idData); |
|
| 107 | 107 | return; |
| 108 | 108 | } |
| 109 | 109 | if ($type == "jpg") { |
| 110 | - header('Content-Disposition: filename="' . basename ($file) . '"'); |
|
| 110 | + header('Content-Disposition: filename="' . basename($file) . '"'); |
|
| 111 | 111 | } else { |
| 112 | - header('Content-Disposition: attachment; filename="' . basename ($file) . '"'); |
|
| 112 | + header('Content-Disposition: attachment; filename="' . basename($file) . '"'); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | $dir = $config['calibre_internal_directory']; |
| 116 | 116 | if (empty ($config['calibre_internal_directory'])) { |
| 117 | - $dir = Base::getDbDirectory (); |
|
| 117 | + $dir = Base::getDbDirectory(); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | if (empty ($config['cops_x_accel_redirect'])) { |
@@ -124,5 +124,5 @@ discard block |
||
| 124 | 124 | fpassthru($fp); |
| 125 | 125 | } |
| 126 | 126 | else { |
| 127 | - header ($config['cops_x_accel_redirect'] . ": " . $dir . $file); |
|
| 127 | + header($config['cops_x_accel_redirect'] . ": " . $dir . $file); |
|
| 128 | 128 | } |
@@ -2,11 +2,11 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -9,70 +9,70 @@ |
||
| 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 ("&", "&", $out); |
|
| 36 | + return str_replace("&", "&", $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 |
@@ -90,7 +90,7 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -11,15 +11,15 @@ discard block |
||
| 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 |
||
| 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 }; |
@@ -10,13 +10,13 @@ discard block |
||
| 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 |
||
| 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 | } |
@@ -16,16 +16,16 @@ discard block |
||
| 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 |
||
| 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> |
@@ -9,8 +9,8 @@ |
||
| 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 | |
@@ -12,20 +12,20 @@ |
||
| 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"'); |