-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·46 lines (37 loc) · 1.02 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
<?php
/**
* Created by Umut Can Alaçam,
* with emoji.json
* This simple script retrieves emoji's from MaxCdn according to the name
*/
include_once "resources/data.php";
//Get query params
if (!isset($_GET["name"])) {
die_response(0, "Parameters wrong.");
}
//Get emoji file name
$queryName = $_GET["name"];
$code = strtolower(EMOJI_MAP[$queryName]);
if ( empty($code) || $code == null) {
die_response(40, "Invalid name.");
}
/** Echo SVG file **/
$svg_url = CDN_END_POINT . $code . ".svg";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $svg_url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if(curl_exec($ch) === FALSE) {
die_response(0, "Couldn't read file.");
} else {
header("Content-type: image/svg+xml");
echo curl_exec($ch);
}
curl_close($ch);
function die_response($code, $message){
header('Content-Type: application/json');
$response["status"] = $code;
$response["message"] = $message;
echo json_encode($response);
exit();
}