-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgallery.php
55 lines (39 loc) · 1.04 KB
/
gallery.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
<?php
//Creates gallery of pictures
require 'vendor/autoload.php';
# SETTINGS
$max_width = 100;
$max_height = 100;
$pics = array();
$file2 = " ";
if(isset($_GET['phrase'])){
$phrase = $_GET['phrase']; }
else {
$phrase = 'j';}
if($phrase == null){
$phrase = 'j';
}
$loader = new Twig_Loader_Filesystem('templates/');
$twig = new Twig_Environment($loader, array(
// Uncomment the line below to cache compiled templates
// 'cache' => __DIR__.'/../cache',
));
global $max_width, $max_height;
if ( $handle = opendir("./pics/") ) {
while ( ($file = readdir($handle)) !== false ) {
if ( !is_dir($file) ) {
$split = explode('.', $file);
$ext = $split[count($split) - 1];
$id = substr($file,0,-4);
if ( $ext == 'jpg' ) {
if( strpos( $file, $phrase ) !== false ) {
$pics[] = array('file' => $file,'id' => $id);
}
}
}
}
}
echo $twig->render('gallery.html', array(
'pics' => $pics
));
?>