-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathicon_icx.php
42 lines (39 loc) · 1.29 KB
/
icon_icx.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
<?php
//$selectedToken = $_GET['token'];
//$filename = 'icons/icon/' . $selectedToken . '.png';
//
//if (file_exists($filename)) {
// $image = file_get_contents('icons/icon/' . $selectedToken . '.png');
//} else {
// $image = file_get_contents('icons/unknown.png');
//}
//
//echo $image;
header ('Content-Type: image/png');
$selectedToken = $_GET['token'];
$autoResolve = $_GET['autoResolve'];
$filename = 'icons/icon/' . $selectedToken . '.png';
if (file_exists($filename)) {
$image = file_get_contents('icons/icon/' . $selectedToken . '.png');
} else {
$image = file_get_contents('icons/icon/' . strtolower($selectedToken) . '.png');
if ($image) {
} else {
// Get image from external source
//$image = file_get_contents('https://raw.githubusercontent.com/iotexproject/iotex-token-metadata/master/images/' . $selectedToken . '.png');
if ($image) {
$file = 'icons/icon/' . $selectedToken . '.png';
file_put_contents($file, $image, FILE_APPEND | LOCK_EX);
$file = 'icons/icon/' . strtolower($selectedToken) . '.png';
file_put_contents($file, $image, FILE_APPEND | LOCK_EX);
} else {
if ($autoResolve === 'false') {
http_response_code(404);
die();
} else {
$image = file_get_contents('icons/unknown.png');
}
}
}
}
echo $image;