better display of description and time for a single photo
[photo-tags.git] / index.php
1 <?php
2
3   /**
4     copyright 2012,2013 Arun Persaud <arun@nubati.net>
5
6     This file is part of photo-tags.
7
8     Photo-tags is free software: you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation, either version 3 of the License, or
11     (at your option) any later version.
12
13     Photo-tags is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17
18     You should have received a copy of the GNU General Public License
19     along with Photo-tags.  If not, see <http://www.gnu.org/licenses/>.
20
21   **/
22
23 /* parse ini -file */
24 $iniarray=parse_ini_file("config.ini");
25 $webbase=$iniarray["webbase"];
26 $dbprefix=$iniarray["dbprefix"];
27 $admin=$iniarray["admin"];
28 $title=$iniarray["title"];
29 $N=$iniarray["pics_per_page"];
30 /* end parse ini-file */
31
32 /* parse flags */
33 if(isset($_REQUEST["page"]))
34   $page = intval($_REQUEST["page"]);
35 else
36   $page = 1;
37
38 if(isset($_REQUEST["tag"]))
39   $tags = htmlentities($_REQUEST["tag"]);
40 else
41   $tags = "";
42
43 if(isset($_REQUEST["pic"]))
44   $pic = intval(htmlentities($_REQUEST["pic"]));
45 else
46   $pic = -1;
47 /* end parse flags */
48
49 /* autoversioning of js and css files */
50 function autoversion($file)
51 {
52   /* changes the file name of e.g. css/style.css to css/style.<md5>.css/js
53    * this way the browser can cache the file and will reload it if the file changed
54    * needs to have .htaccess set up correctly to link back to css/style.css */
55
56   /* only use it for file that have an absolut path */
57   if(!file_exists(dirname($_SERVER['SCRIPT_FILENAME']). '/' . $file))
58     return $file;
59
60   $md5 = md5_file(dirname($_SERVER['SCRIPT_FILENAME']). '/' . $file);
61   return preg_replace('{\\.([^./]+)$}', ".$md5.\$1", $file);
62 }
63
64 /* The basic layout */
65 ?>
66 <!DOCTYPE html>
67 <html>
68 <head>
69 <meta charset="utf-8">
70 <title><?php echo htmlspecialchars($title) ?></title>
71 <script src = "<?php echo $webbase.autoversion("/js/d3.min.js")?>"></script>
72 <link rel="stylesheet" type="text/css" href="<?php echo $webbase.autoversion("/css/bootstrap.min.css")?>" />
73 <link rel="stylesheet" type="text/css" href="<?php echo $webbase.autoversion("/css/style.css")?>" />
74 </head>
75
76 <body>
77
78 <div class="debug"></div>
79 <h1><?php echo htmlspecialchars($title) ?></h1>
80
81 <nav>
82
83 <div class="pagination">
84   <ul>
85   </ul>
86 </div>
87
88 </nav>
89
90
91 <div class="permalink"></div>
92
93 <div class="tagsearch">
94 <form class="form-search" method="get" action="">
95   <p>
96     <label>Search for tag:</label> <input class="input-medium search-query" list="MyTags" id="MyTagsInput" type="text" value="" />
97     <datalist id="MyTags">
98     </datalist>
99     Current tags:<span id="currenttags"></span>
100     <a class="next btn btn-small btn-info" onclick="tagcloud()">tag cloud</a>
101     <a class="btn btn-small btn-success" href='<?php echo $webbase?>'>all</a>
102     <span id="pictags"></span>
103   </p>
104 </form>
105 </div>
106
107 <div class="nextprev"> <ul></ul></div>
108
109 <div class="pics"><ul></ul> </div>
110
111 <footer>
112   <div class="pull-left">This gallery belongs to <?php echo htmlspecialchars($admin) ?>.</div>
113   <div class="copyright pull-right"> photo-tags: copyright 2011-2012 Arun Persaud arun@nubati.net,<br /> code available at <a href="http://source.nubati.net/projects/photo-tags">source.nubati.net/projects/photo-tags</a></div>
114 </footer>
115
116
117 <script src = "<?php echo $webbase.autoversion("/js/photo-tags.js")?>"></script>
118 <script src="http://code.jquery.com/jquery-latest.js"></script>
119 <script src="js/bootstrap.min.js"></script>
120 <script type="text/javascript" >
121
122 /*hand parameters over to javascript*/
123 var page=<?php echo $page ?>;
124 var N=<?php echo $N ?>;
125 var T="<?php echo $tags ?>";
126 var ID=<?php echo $pic ?>;
127 var count=0;
128 var dbprefix="<?php echo $dbprefix ?>".replace(/\//g,"\/");
129 var webbase = "<?php echo $webbase?>";
130
131 init();
132 load_content();
133 update_page_index();
134
135 </script>
136
137 </body>
138 </html>