aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Emoji.php
blob: a1459d1791f746ab3b39fcf54105c22229ada42c (plain) (blame)
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
<?php
namespace Zotlabs\Module;

use Zotlabs\Web\Controller;
use Zotlabs\Daemon\Master;
use Zotlabs\Lib\ActivityStreams;
use App;


class Emoji extends Controller {

	function init() {

		$shortname = argv(1);

		if (!$shortname) {
			killme();
		}

		$emojis = get_emojis();

		if (!isset($emojis[$shortname])) {
			killme();
		}

		$emoji = $emojis[$shortname];

		if (!file_exists($emoji['filepath'])) {
			killme();
		}

		$image = getimagesize($emoji['filepath']);

		if(ActivityStreams::is_as_request()) {
			$last_modified = date(ATOM_TIME, filemtime($emoji['filepath']));

			$obj = [
				'id' => z_root() . '/emoji/' . $shortname,
				'type' => 'Emoji',
				'name' => $emoji['shortname'],
				'updated' => $last_modified,
				'icon' => [
					'type' => 'Image',
					'mediaType' => $image['mime'],
					'url' => z_root() . '/' . $emoji['filepath']
				]
			];

			as_return_and_die($obj);
		}

		header('Content-Type: ' . $image['mime']);
		echo file_get_contents($emoji['filepath']);
		killme();
	}

}