-
Notifications
You must be signed in to change notification settings - Fork 5
/
galleri.php
89 lines (73 loc) · 2.17 KB
/
galleri.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
<?
header('Content-Type: text/html;charset=utf-8');
date_default_timezone_set ('Europe/Oslo');
setlocale(LC_ALL, 'nb_NO.UTF-8');
$this_month = strftime('%Y-%m');
$photodir = opendir("/photos");
$photos = array();
$months = array();
while ($ent = readdir($photodir))
{
if ($ent[0] == '.')
continue;
$extension = pathinfo($ent, PATHINFO_EXTENSION);
$description_path = "/photos/$ent.txt";
if (!file_exists($description_path))
continue;
$path = "/photos/$ent";
$mtime = filemtime($path);
$name = "photos/$ent";
$photos[] = array('name' => $name,
'mtime' => strftime('%Y-%m-%d %H:%M:%S', $mtime),
'machine_day' => strftime('%Y-%m-%d', $mtime),
'day' => strftime('%A %e. %B, %Y', $mtime),
'description' => file_get_contents($description_path));
$months[] = strftime('%Y-%m', $mtime);
}
function mtimecmp($lhs, $rhs)
{
return strcmp($rhs['mtime'], $lhs['mtime']);
}
usort($photos, mtimecmp);
$days = array();
$descriptions = array();
?>
<html>
<head>
<title>Bitraf: Galleri</title>
<style type='text/css'>
body { font-family: sans-serif; background: #333; color: #ccd0cc; text-align: center; }
.photo { width: 960px; margin: 0 auto 10px; }
.photo { background: black; padding: 0 0 5px; color: white; border: 2px solid black; text-align: center; }
.photo img { margin-bottom: 5px; }
.photo div { margin: 0 5px; text-align: left; }
.t { border-spacing: 0; border-collapse: collapse; }
.t td, .t th { padding: 5px 10px; border: 1px solid black; }
.t th { background: #ddd; }
a { color: #eee; }
a:hover { color: #fff; }
</style>
</head>
<body>
<h1>Galleri</h1>
<p><a href='/'>Tilbake til forsiden</a>
<?
foreach ($photos as $photo)
{
if ($photo['day'] != $day)
{
$day = $photo['day'];
$machine_day = $photo['machine_day'];
?><h2><?=$day?><?
if ($days[$machine_day])
{
?> — <?=$days[$machine_day]?><?
}
?></h2><?
}
list($width, $height, $type, $attr) = getimagesize($photo['name']);
?><div class='photo'><img src='<?=$photo['name']?>' height='<?=$height?>' alt='' /><div><?=$photo['description']?></div></div><?
}
?>
</body>
</html>