353a848b0972f7c6726d46f8abb1e06bd53f68e0
[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
46 <html>
47 <title><?php echo htmlspecialchars($title) ?></title>
48 <script src = "<?php echo $webbase.autoversion("/js/d3.min.js")?>"></script>
49 <link rel="stylesheet" type="text/css" href="<?php echo $webbase.autoversion("/css/normalize.css")?>" />
50 <link rel="stylesheet" type="text/css" href="<?php echo $webbase.autoversion("/css/style.css")?>" />
51
52 <body>
53
54 <div class="debug"></div>
55 <h1><?php echo htmlspecialchars($title) ?></h1>
56
57 <nav>
58 page <span class="index"></span>
59 <button class="prev" type="button" disabled="disabled" onclick="prev_page()"> prev </button>
60 <button class="next" type="button" onclick="next_page()">next </button>
61 <button class="all"  type="submit" onclick="document.location.href='<?php echo $webbase?>'">all</button>
62 </nav>
63
64 <div class="permalink"></div>
65
66 <div class="tagsearch">
67 <form method="get" action="">
68  Search for tag: <input list="MyTags" id="MyTagsInput" type="text" value="" />
69   <datalist id="MyTags">
70   </datalist>
71 </form>
72   Current tags:<span id="currenttags"></span>
73   <button class="next" type="button" onclick="tagcloud()">tag cloud</button>
74 </div>
75
76 <div class="nextprev"> <ul></ul></div>
77
78 <div class="pics"><ul></ul> </div>
79
80 <footer>
81   This gallery belongs to <?php echo htmlspecialchars($admin) ?>.
82   <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>
83 </footer>
84
85
86 <script src = "<?php echo $webbase.autoversion("/js/photo-tags.js")?>"></script>
87 <script type="text/javascript" >
88
89 /*hand parameters over to javascript*/
90 var page=<?php echo $page ?>;
91 var N=<?php echo $N ?>;
92 var T="<?php echo $tags ?>";
93 var ID=<?php echo $pic ?>;
94 var count=0;
95 var dbprefix="<?php echo $dbprefix ?>".replace(/\//g,"\/");
96 var webbase = "<?php echo $webbase?>";
97
98 init();
99 load_content();
100 update_page_index();
101
102 </script>
103
104 </body>
105 </html>