-
Notifications
You must be signed in to change notification settings - Fork 2
/
icon_sys.php
53 lines (45 loc) · 1.89 KB
/
icon_sys.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
<?php
// https://raw.githubusercontent.com/Pollum-io/pegasys-tokenlists/master/pegasys.tokenlist.json
// https://raw.githubusercontent.com/Pollum-io/pegasys-tokenlists/master/tanembaum.tokenlist.json
header('Content-Type: image/png');
$selectedToken = $_GET['token'];
$autoResolve = $_GET['autoResolve'];
$filename = 'icons/syscoin/' . $selectedToken . '.png';
if (file_exists($filename)) {
$image = file_get_contents('icons/syscoin/' . $selectedToken . '.png');
} else {
$image = file_get_contents('icons/syscoin/' . strtolower($selectedToken) . '.png');
if ($image) {
} else {
$json_mochiswap = file_get_contents('https://raw.githubusercontent.com/Pollum-io/pegasys-tokenlists/master/pegasys.tokenlist.json');
$infoMochiswapData = json_decode($json_mochiswap);
foreach ($infoMochiswapData->tokens as $infoMochiswap) {
if (strtolower($selectedToken) === strtolower($infoMochiswap->address)) {
$image = file_get_contents($infoMochiswap->logoURI);
}
}
if ($image){} else{
$json_mochiswap = file_get_contents('https://raw.githubusercontent.com/Pollum-io/pegasys-tokenlists/master/tanembaum.tokenlist.json');
$infoMochiswapData = json_decode($json_mochiswap);
foreach ($infoMochiswapData->tokens as $infoMochiswap) {
if (strtolower($selectedToken) === strtolower($infoMochiswap->address)) {
$image = file_get_contents($infoMochiswap->logoURI);
}
}
}
if ($image) {
$file = 'icons/syscoin/' . $selectedToken . '.png';
file_put_contents($file, $image, FILE_APPEND | LOCK_EX);
$file = 'icons/syscoin/' . 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;