added information when displaying a single picture
[photo-tags.git] / index.php
1 <?php
2 /* parse ini -file */
3 $iniarray=parse_ini_file("config.ini");
4 $webbase=$iniarray["webbase"];
5 $dbprefix=$iniarray["dbprefix"];
6 $admin=$iniarray["admin"];
7 $title=$iniarray["title"];
8 $N=$iniarray["pics_per_page"];
9 /* end parse ini-file */
10
11 /* parse flags */
12 if(isset($_REQUEST["page"]))
13   $page = intval($_REQUEST["page"]);
14 else
15   $page = 1;
16
17 if(isset($_REQUEST["tag"]))
18   $tags = htmlentities($_REQUEST["tag"]);
19 else
20   $tags = "";
21
22 if(isset($_REQUEST["pic"]))
23   $pic = intval(htmlentities($_REQUEST["pic"]));
24 else
25   $pic = -1;
26 /* end parse flags */
27
28 /* autoversioning of js and css files */
29 function autoversion($file)
30 {
31   /* changes the file name of e.g. css/style.css to css/style.<md5>.css/js
32    * this way the browser can cache the file and will reload it if the file changed
33    * needs to have .htaccess set up correctly to link back to css/style.css */
34
35   /* only use it for file that have an absolut path */
36   if(!file_exists(dirname($_SERVER['SCRIPT_FILENAME']). '/' . $file))
37     return $file;
38
39   $md5 = md5_file(dirname($_SERVER['SCRIPT_FILENAME']). '/' . $file);
40   return preg_replace('{\\.([^./]+)$}', ".$md5.\$1", $file);
41 }
42
43 /* The basic layout */
44 ?>
45 <!DOCTYPE html>
46 <html>
47 <head>
48 <meta charset="utf-8">
49 <title><?php echo htmlspecialchars($title) ?></title>
50 <script src = "<?php echo $webbase.autoversion("/js/d3.min.js")?>"></script>
51 <link rel="stylesheet" type="text/css" href="<?php echo $webbase.autoversion("/css/bootstrap.min.css")?>" />
52 <link rel="stylesheet" type="text/css" href="<?php echo $webbase.autoversion("/css/style.css")?>" />
53 </head>
54
55 <body>
56
57 <div class="debug"></div>
58 <h1><?php echo htmlspecialchars($title) ?></h1>
59
60 <nav>
61
62 <div class="pagination">
63   <ul>
64   </ul>
65 </div>
66
67 </nav>
68
69
70 <div class="permalink"></div>
71
72 <div class="tagsearch">
73 <form class="form-search" method="get" action="">
74  <label>Search for tag:</label> <input class="input-medium search-query" list="MyTags" id="MyTagsInput" type="text" value="" />
75   <datalist id="MyTags">
76   </datalist>
77  <p> Current tags:<span id="currenttags"></span>
78   <a class="next btn btn-small btn-info" onclick="tagcloud()">tag cloud</a>
79   <a class="btn btn-small btn-success" href='<?php echo $webbase?>'>all</a>
80  </p>
81 </form>
82 </div>
83
84 <div class="nextprev"> <ul></ul></div>
85
86 <div class="pics"><ul></ul> </div>
87
88 <footer>
89   This gallery belongs to <?php echo htmlspecialchars($admin) ?>.
90   <div class="copyright"> photo-tags: copyright 2011 Arun Persaud arun@nubati.net, code available at <a href="http://source.nubati.net/projects/photo-tags">source.nubati.net/projects/photo-tags</a></div>
91 </footer>
92
93
94 <script src = "<?php echo $webbase.autoversion("/js/photo-tags.js")?>"></script>
95 <script src="http://code.jquery.com/jquery-latest.js"></script>
96 <script src="js/bootstrap.min.js"></script>
97 <script type="text/javascript" >
98
99 /*hand parameters over to javascript*/
100 var page=<?php echo $page ?>;
101 var N=<?php echo $N ?>;
102 var T="<?php echo $tags ?>";
103 var ID=<?php echo $pic ?>;
104 var count=0;
105 var dbprefix="<?php echo $dbprefix ?>".replace(/\//g,"\/");
106 var webbase = "<?php echo $webbase?>";
107
108 init();
109 load_content();
110 update_page_index();
111
112 </script>
113
114 </body>
115 </html>