Non-initialized variable fix.
[openlib.git] / www / index.php
1 <?php
2 /**
3  * COPS (Calibre OPDS PHP Server) HTML main script
4  *
5  * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6  * @author     Sébastien Lucas <sebastien@slucas.fr>
7  *
8  */
9  
10     require_once ("config.php");
11     require_once ("base.php");
12     require_once ("author.php");
13     require_once ("serie.php");
14     require_once ("tag.php");
15     require_once ("language.php");
16     require_once ("book.php");
17     
18     // If we detect that an OPDS reader try to connect try to redirect to feed.php
19     if (preg_match("/(PocketBook|MantanoReader|FBReader|Stanza|Aldiko|Moon+ Reader|CoolReader)/", $_SERVER['HTTP_USER_AGENT'])) {
20         header("location: feed.php");
21         exit ();
22     }
23     
24     header ("Content-Type:text/html;charset=utf-8");
25     $page = getURLParam ("page", Base::PAGE_INDEX);
26     $query = getURLParam ("query");
27     $qid = getURLParam ("id");
28     $n = getURLParam ("n", "1");
29 ?>
30 <!DOCTYPE html>
31 <html xmlns="http://www.w3.org/1999/xhtml">
32 <head>
33     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
34     <title>COPS</title>
35     <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/jQuery/jquery-1.10.2.min.js") ?>"></script>
36     <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/jquery-cookie/jquery.cookies.js") ?>"></script>
37     <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/Magnific-Popup/jquery.magnific-popup.min.js") ?>"></script>
38     <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("resources/Magnific-Popup/magnific-popup.css") ?>" media="screen" />
39     <script type="text/javascript" src="<?php echo getUrlWithVersion("js/jquery.sortElements.js") ?>"></script>
40     <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/doT/doT.min.js") ?>"></script>
41     <script type="text/javascript" src="<?php echo getUrlWithVersion("resources/lru/lru.js") ?>"></script>
42     <script type="text/javascript" src="<?php echo getUrlWithVersion("util.js") ?>"></script>
43     <link rel="related" href="<?php echo $config['cops_full_url'] ?>feed.php" type="application/atom+xml;profile=opds-catalog" title="<?php echo $config['cops_title_default']; ?>" /> 
44     <link rel="icon" type="image/vnd.microsoft.icon" href="favicon.ico" />
45     <link rel='stylesheet' type='text/css' href='http://fonts.googleapis.com/css?family=Open+Sans:400,300italic,800,300,400italic,600,600italic,700,700italic,800italic' />
46     <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("resources/normalize/normalize.css") ?>" />
47     <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion("styles/font-awesome.css") ?>" media="screen" />
48     <link rel="stylesheet" type="text/css" href="<?php echo getUrlWithVersion(getCurrentCss ()) ?>" media="screen" />
49     <script type="text/javascript">
50     
51         $(document).ready(function() {
52             // Handler for .ready() called.
53             
54             var url = "<?php echo "getJSON.php?" . addURLParameter ($_SERVER["QUERY_STRING"], "complete", 1); ?>";
55             
56             $.when($.get('templates/default/header.html'),
57                    $.get('templates/default/footer.html'),
58                    $.get('templates/default/bookdetail.html'),
59                    $.get('templates/default/main.html'),
60                    $.get('templates/default/page.html'),
61                    $.getJSON(url)).done(function(header, footer, bookdetail, main, page, data){
62                 templateBookDetail = doT.template (bookdetail [0]);
63                 
64                 var defMain = {
65                     bookdetail: bookdetail [0]
66                 };
67                 
68                 templateMain = doT.template (main [0], undefined, defMain);
69                 
70                 var defPage = {
71                     header: header [0],
72                     footer: footer [0],
73                     main  : main [0],
74                     bookdetail: bookdetail [0]
75                 };
76                 
77                 templatePage = doT.template (page [0], undefined, defPage);
78                 currentData = data [0];
79                 
80                 updatePage (data [0]);
81                 cache.put (url, data [0]);
82                 history.replaceState(url, "", window.location);
83                 handleLinks ();
84             });
85             
86         });
87         
88         
89
90     </script>
91 </head>
92 <body>
93 </body>
94 </html>