This repository has been archived by the owner on Apr 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gifstream.php
59 lines (41 loc) · 1.44 KB
/
gifstream.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
<?php
//Yes, we're actually using JSON!
header('content-type: application/json');
//Load configuration
require_once('./lib/Config.php');
//Load abstract library
require_once('./lib/ImageIterator.php');
require_once('./lib/NameObfuscator.php');
require_once('./lib/ImageLoader.php');
$config = CONFIG::get();
$obfuscator = NameObfuscator::getNew();
$iterator = ImageIterator::getNew();
if (!$config->read("allowGifStream"))
die();
//Return values for GifStream
$return = array();
$images = array();
//Fixed values
$return["version"] = 1;
//Needed values
$return["title"] = $config->read("siteName");
$return["base"] = $config->read("siteURL") . $config->read("imagePath");
//Possible values
if (!is_null($config->read("gifStreamIdentifier")))
$return["identifier"] = $config->read("gifStreamIdentifier");
else
$return["identifier"] = $config->read("siteName");
if (!is_null($config->read("gifStreamLicense")))
$return["license"] = $config->read("gifStreamLicense");
while ($iterator->hasNext()) {
$nImage = array();
$nImage["src"] = $iterator->getCurrent()['filename'];
//LOLWUT, we're checking for extension here ^_^
//Last time I looked GifStream doesn't break when you serve a PNG or something, but if this
//stupid thing breaks it in the future: Go nag Philipp about it!
if (strtolower($iterator->getCurrent()["extension"]) == "gif")
array_push($images, $nImage);
$iterator->next();
}
$return["files"] = $images;
echo json_encode($return);