-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
155 lines (126 loc) · 3.95 KB
/
index.php
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
144
145
146
147
148
149
150
151
152
153
154
155
<?php
/* ----------------------
Auto PHP Gallery - Abid Din (@craftedpixelz)
Usage: Drop this file into a folder containing images
for an instant gallery to showcase designs across devices.
---------------------- */
/* settings */
$images_dir = './';
/* Get files from Dir */
function get_files($images_dir,$exts = array('jpg', 'png')) {
$files = array();
if($handle = opendir($images_dir)) {
while(false !== ($file = readdir($handle))) {
$extension = strtolower(get_file_extension($file));
if($extension && in_array($extension,$exts)) {
$files[] = $file;
}
}
closedir($handle);
}
sort($files);
return $files;
}
/* Get file extensions */
function get_file_extension($file_name) {
return substr(strrchr($file_name,'.'),1);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Creative Concept Gallery</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<!-- STYLES -->
<style>
body {
margin: 0;
padding: 0;
font-family: Helvetica, Arial, sans-serif;
color: #fff;
background: #030303;
}
::-webkit-scrollbar {
display: none;
}
.swipe {
overflow: hidden;
position: relative;
visibility: hidden;
}
.swipe-wrap {
overflow: hidden;
position: relative;
}
.swipe-wrap > div {
float:left;
width:100%;
position: relative;
}
.swipe-wrap img {
display: block;
max-width: 100%;
}
</style>
</head>
<body>
<!-- SLIDESHOW CONTAINER -->
<div id="slider" class="swipe">
<div class="swipe-wrap">
<?php
/* Output images to page */
$image_files = get_files($images_dir);
if(count($image_files)) {
foreach($image_files as $file) {
$image = $images_dir.$file;
echo "<div><img src='" . $image . "' /></div>";
}
}
else {
echo "<p>There are no images in this gallery.</p>";
}
?>
</div>
</div>
<!-- JS -->
<script src="//cdnjs.cloudflare.com/ajax/libs/swipe/2.0/swipe.min.js"></script>
<script>
var gallery = gallery || {};
// Set up Slideshow
gallery.handleSwipe = function () {
var slider = document.getElementById("slider"),
slideshow = Swipe(slider, {
continuous: false
});
// Handle click event
slider.onclick = function () {
slideshow.next();
};
// Handle key events
window.onkeydown = function (e) {
e.preventDefault();
var keyCode = e.keyCode || e.which;
if (keyCode == 37) {
slideshow.prev();
}
if (keyCode == 39) {
slideshow.next();
}
}
};
// Hide URL bar on iPhone/iPad
gallery.hideUrlBar = function () {
/mobi/i.test(navigator.userAgent) && !location.hash && setTimeout(function () {
if (!pageYOffset) window.scrollTo(0, 1);
}, 1000);
};
// Init
gallery.init = function () {
gallery.handleSwipe();
gallery.hideUrlBar();
};
gallery.init();
</script>
</body>
</html>