-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfolder-gallery.php
More file actions
143 lines (119 loc) · 4.46 KB
/
Copy pathfolder-gallery.php
File metadata and controls
143 lines (119 loc) · 4.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
/* Folder-Gallery */
/* A simple bootstrap-powered gallery */
/* created by placing pictures in folders */
/* (C) 2013 Marco Cirillo */
/* SETUP */
/* galleries are placed in the gallery directory, as defined in the $gallery variable */
$gallery = 'gallery';
/* END SETUP */
$current_dir = NULL; // Initially null, will be filled in if the current dir is valid
if( (!isset($_GET['gallery'])) || ($_GET['gallery'] == "") ) {
// send user to latest gallery
header("Location: index.php?gallery=latest");
exit;
} else {
// check if gallery exists
$current_dir = $gallery . '/' . $_GET['gallery'];
if(!count(glob($current_dir . '/*'))) {
/* This directory has no files,
* let's assume the user made an error and send them to the latest gallery
*/
header("Location: index.php?gallery=latest");
exit;
}
}
// Get all directories (galleries) in the $gallery directory
$directories = glob($gallery . '/*' , GLOB_ONLYDIR);
// Set the current folder based on the page the user requested
$folder = $_GET['gallery'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>folder-gallery</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- CSS -->
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
<link href="css/screen.css" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<![endif]-->
<!-- Fav and touch icons -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="img/icon/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="img/icon/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="img/icon/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="img/icon/apple-touch-icon-57-precomposed.png">
<link rel="shortcut icon" href="img/icon/favicon.png">
<!-- Sharing -->
<script type="text/javascript">var switchTo5x=true;</script>
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">stLight.options({publisher: "c1bee76d-57e6-4119-b0cb-22e60ba62a93", doNotHash: false, doNotCopy: false, hashAddressBar: false});</script>
</head>
<body>
<div class="container">
<!-- Carousel -->
<div id="imgCarousel" class="carousel slide">
<ol class="carousel-indicators">
<!-- Carousel slide numbers are 0-indexed -->
<?php
$i = 0;
foreach (glob($current_dir . '/*') as $file) {
echo "<li data-target='#imgCarousel' data-slide-to='$i' ";
if ($i++ == 0) echo 'class="active"'; // set first item as active item
echo "></li>";
}
?>
</ol>
<!-- Carousel items -->
<div class="carousel-inner">
<?php
$i = 0;
foreach (glob($current_dir . '/*') as $file) {
// set first item as active
if ($i++ == 0) echo '<div class="active item">';
else echo '<div class="item">';
//$link = rawurlencode($file);
echo "<img src='$file' alt=''>";
echo '</div>';
}
?>
</div>
<!-- Carousel nav -->
<a class="carousel-control left" href="#imgCarousel" data-slide="prev">‹</a>
<a class="carousel-control right" href="#imgCarousel" data-slide="next">›</a>
</div>
<div>
<h1>Galleries</h1>
<ul>
<?php
foreach ($directories as $dir) {
$name = str_replace($gallery . '/', "", $dir);
$files = glob($dir . '/*');
$size = count($files);
echo "<li><a href='index.php?gallery=$name'>$name</a></li>";
}
?>
</ul>
</div>
</div> <!-- /container -->
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.1.min.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>
<script type="text/javascript">
// Start the carousel
$().ready(function(){
$('.carousel').carousel({
interval: 2000
});
});
</script>
</body>
</html>