forked from Kieran/void.cat
add crypto tip pages
This commit is contained in:
parent
a81c75e4c0
commit
8e1fc3a710
@ -31,7 +31,10 @@
|
||||
|
||||
<div class="footer">
|
||||
<div class="links">
|
||||
<a href="https://discord.gg/8BkxTGs">Discord</a>
|
||||
<a href="https://discord.gg/8BkxTGs">Discord</a> |
|
||||
<a href="/src/php/tip-me.php">Crypto Tips</a> |
|
||||
<a href="/src/php/lightning-tip.php">⚡Lightning Tip⚡</a> |
|
||||
<a href="dat://0d7fe5f1e26e8541745f585f38f7075f135abcba78409b8b93d13c4322771297/">Dat</a>
|
||||
</div>
|
||||
<img src="/graph"/>
|
||||
</div>
|
||||
@ -60,4 +63,4 @@
|
||||
|
||||
}
|
||||
customElements.define(VoidMain.is, VoidMain)
|
||||
</script>
|
||||
</script>
|
||||
|
@ -26,6 +26,7 @@
|
||||
define('_BLOCK_REFERER', array("yobuilder.com", "adf.ly"));
|
||||
define('_UA_NO_VIEW', array("YandexBot/3.0", "Googlebot/2.1", "Yahoo! Slurp"));
|
||||
define('_VIRUSTOTAL_KEY', 'API_KEY');
|
||||
define('_ETHERSCAN_API_KEY', 'API_KEY');
|
||||
|
||||
/* CLOUDFLARE SETTINGS */
|
||||
define('_CLOUDFLARE_API_EMAIL', 'me@me.com');
|
||||
@ -37,4 +38,24 @@
|
||||
define('_CAPTCHA_DL_EXPIRE', 86400);
|
||||
define('_CAPTCHA_KEY', 'CAP_KEY');
|
||||
define('_CAPTCHA_SECRET', 'CAP_SECRET');
|
||||
|
||||
/* LN RPC-FILE */
|
||||
define('_LN_RPC_FILE', 'unix:///root/.lightning/lightning-rpc');
|
||||
define("MSAT", 0.00000000001);
|
||||
define("SAT", 0.00000001);
|
||||
|
||||
/* TIP ADDRS */
|
||||
define('_TIP_ADDRS', array(
|
||||
"BTC" => "3AL9jqxVTjAZJMseBBnC75F3S6r4HSphUt",
|
||||
"BCH" => "1qbcr7Bnt53sq9qEbPPrzu4jAvEeF6oUm",
|
||||
"BTG" => "AbtKHMqpwUqJJVYj7f1roR6FCecViPt1zK",
|
||||
"DASH" => "XfFNizQfuqwRtdx4WqpcK3L8tZEvG4WaJk",
|
||||
"LTC" => "MGBNvUefXrFvdiZRNrQTG6UX8za2Phr5Eu",
|
||||
"ZEC" => "t1VSkrikVyjoCKrC7DXnVPxPZCWRQihneTz",
|
||||
"ETH" => "0x367e6864d84b38c58312a340afbd55417d1c9Ce2",
|
||||
"EOS" => "0x367e6864d84b38c58312a340afbd55417d1c9Ce2",
|
||||
"TRX" => "0x367e6864d84b38c58312a340afbd55417d1c9Ce2",
|
||||
"ETC" => "0x5653306b771d0ECD9f1010114a378a50301f68c3",
|
||||
"XEM" => "NDWAWGJ5E5FCQTGKMTAQPS5TACICPB5NA4ZVT232"
|
||||
));
|
||||
?>
|
167
src/php/functions.php
Normal file
167
src/php/functions.php
Normal file
@ -0,0 +1,167 @@
|
||||
<?php
|
||||
include_once("config.php");
|
||||
|
||||
function ln_query($method, $params = NULL){
|
||||
$sock = fsockopen(_LN_RPC_FILE);
|
||||
if($sock) {
|
||||
fwrite($sock, json_encode(array("jsonrpc" => "2.0", "method" => $method, "params" => $params, "id" => 1)) . "\n");
|
||||
$rsp = fgets($sock);
|
||||
fclose($sock);
|
||||
return json_decode($rsp);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
function curl_json_get($url)
|
||||
{
|
||||
return json_decode(curl_text($url));
|
||||
}
|
||||
|
||||
function curl_text($url)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, _CURL_USER_AGENT);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function GetAllAddrInfo($addrs)
|
||||
{
|
||||
$ret = array();
|
||||
|
||||
foreach($addrs as $cur => $addr)
|
||||
{
|
||||
$f = "GetAddrInfo_" . $cur;
|
||||
if(is_callable($f)) {
|
||||
$val = call_user_func($f, $addr);
|
||||
if($val)
|
||||
{
|
||||
array_push($ret, (object) [
|
||||
"currency" => $cur,
|
||||
"address" => $addr,
|
||||
"balance" => $val->balance,
|
||||
"txns" => $val->txns
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function GetAddrInfo_BTC($addr)
|
||||
{
|
||||
$val = curl_json_get("https://api.blockcypher.com/v1/btc/main/addrs/" . $addr . "/balance");
|
||||
return (object) [
|
||||
"balance" => $val->final_balance * SAT,
|
||||
"txns" => $val->final_n_tx
|
||||
];
|
||||
}
|
||||
|
||||
function GetAddrInfo_LTC($addr)
|
||||
{
|
||||
$val = curl_json_get("https://api.blockcypher.com/v1/ltc/main/addrs/" . $addr . "/balance");
|
||||
return (object) [
|
||||
"balance" => $val->final_balance,
|
||||
"txns" => $val->final_n_tx
|
||||
];
|
||||
}
|
||||
|
||||
function GetAddrInfo_DASH($addr)
|
||||
{
|
||||
$val = curl_json_get("https://api.blockcypher.com/v1/dash/main/addrs/" . $addr . "/balance");
|
||||
return (object) [
|
||||
"balance" => $val->final_balance,
|
||||
"txns" => $val->final_n_tx
|
||||
];
|
||||
}
|
||||
|
||||
function GetAddrInfo_BCH($addr)
|
||||
{
|
||||
$val = curl_json_get("https://bitcoincash.blockexplorer.com/api/addr/" . $addr . "/balance");
|
||||
return (object) [
|
||||
"balance" => $val->balance,
|
||||
"txns" => $val->txApperances,
|
||||
"new_addr" => $val->addrStr
|
||||
];
|
||||
}
|
||||
|
||||
function GetAddrInfo_ETH_ERC20($contract, $addr)
|
||||
{
|
||||
$val = curl_json_get("https://api.etherscan.io/api?module=account&action=tokenbalance&contractaddress=" . $contract . "&address=" . $addr . "&tag=latest&apikey=" . _ETHERSCAN_API_KEY);
|
||||
return (object) [
|
||||
"balance" => $val->response,
|
||||
"txns" => 0
|
||||
];
|
||||
}
|
||||
|
||||
function GetAddrInfo_EOS($addr)
|
||||
{
|
||||
return GetAddrInfo_ETH_ERC20("0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0", $addr);
|
||||
}
|
||||
|
||||
function GetAddrInfo_TRX($addr)
|
||||
{
|
||||
return GetAddrInfo_ETH_ERC20("0xf230b790e05390fc8295f4d3f60332c93bed42e2", $addr);
|
||||
}
|
||||
|
||||
function GetAddrInfo_ETH($addr)
|
||||
{
|
||||
$val = curl_json_get("https://api.etherscan.io/api?module=account&action=balance&address=" . $addr . "&tag=latest&apikey=" . _ETHERSCAN_API_KEY);
|
||||
return (object) [
|
||||
"balance" => $val->response,
|
||||
"txns" => 0
|
||||
];
|
||||
}
|
||||
|
||||
function GetAddrInfo_ETC($addr)
|
||||
{
|
||||
$val = curl_json_get("https://etcchain.com/api/v1/getAddressBalance?address=" . $addr);
|
||||
return (object) [
|
||||
"balance" => $val->balance,
|
||||
"txns" => 0
|
||||
];
|
||||
}
|
||||
|
||||
function GetAddrInfo_BTG($addr)
|
||||
{
|
||||
$val = curl_text("https://btgexp.com/ext/getaddress/" . $addr);
|
||||
return (object) [
|
||||
"balance" => floatval($val),
|
||||
"txns" => 0
|
||||
];
|
||||
}
|
||||
|
||||
function GetAddrInfo_ZEC($addr)
|
||||
{
|
||||
$val = curl_text("https://api.zcha.in/v2/mainnet/accounts/" . $addr);
|
||||
return (object) [
|
||||
"balance" => $val->balance,
|
||||
"txns" => $val->recvCount
|
||||
];
|
||||
}
|
||||
|
||||
function GetAddrInfo_XEM($addr)
|
||||
{
|
||||
//pick a random node to query
|
||||
$nodes = curl_json_get("https://nodeexplorer.com/api_openapi_version");
|
||||
$api = array_rand($nodes->nodes);
|
||||
|
||||
$val = curl_json_get("http://" . $nodes->nodes[$api] . "/account/get?address=" . $addr);
|
||||
return (object) [
|
||||
"balance" => $val->account->balance,
|
||||
"txns" => 0
|
||||
];
|
||||
}
|
||||
|
||||
function GetBTCPrice()
|
||||
{
|
||||
$val = curl_json_get("https://api.coinmarketcap.com/v2/ticker/1/");
|
||||
return $val->data->quotes->USD->price;
|
||||
}
|
||||
?>
|
53
src/php/lightning-tip.php
Normal file
53
src/php/lightning-tip.php
Normal file
@ -0,0 +1,53 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>⚡ Tip! ⚡</title>
|
||||
<style>
|
||||
html, body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: Arial;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
div.body {
|
||||
width: 720px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-top: 10px;
|
||||
|
||||
border-radius: 10px;
|
||||
border: 1px solid #888;
|
||||
overflow:hidden;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="body">
|
||||
<?php
|
||||
include_once("config.php");
|
||||
include_once("functions.php");
|
||||
|
||||
$id = uniqid();
|
||||
$inv = ln_query("invoice", array("any", $id, "void.cat tip"));
|
||||
|
||||
if(isset($inv->result)) {
|
||||
echo "wip...";
|
||||
|
||||
echo "<pre>" . $inv->result->bolt11 . "</pre>";
|
||||
|
||||
$cmd = "/usr/local/bin/myqr lightning:" . $inv->result->bolt11 . " -n " . $id . ".png -c -d /tmp/ 2>&1";
|
||||
|
||||
$qr = shell_exec($cmd);
|
||||
$img_b64 = base64_encode(file_get_contents(substr(explode(", ", substr(explode("\n", $qr)[1], 1, -1))[3], 1, -1)));
|
||||
|
||||
echo "<img style=\"width: 300px\" src=\"data:image/png;base64," . $img_b64 . "\"/>";
|
||||
}else{
|
||||
echo "<pre>" . json_encode($inv) . "</pre>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
93
src/php/tip-me.php
Normal file
93
src/php/tip-me.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
include_once("config.php");
|
||||
include_once("functions.php");
|
||||
|
||||
$uri_format = array(
|
||||
"BTC" => "bitcoin:%s",
|
||||
"BCH" => "bitcoincash:%s",
|
||||
"BTG" => "bitcoingold:%s",
|
||||
"DASH" => "dash:%s",
|
||||
"LTC" => "litecoin:%s",
|
||||
"ZEC" => "zcash:%s",
|
||||
"ETH" => "ethereum:%s",
|
||||
"EOS" => "ethereum:%s",
|
||||
"TRX" => "ethereum:%s",
|
||||
"ETC" => "ethereum:%s&id=61",
|
||||
"XEM" => "nem:%s"
|
||||
);
|
||||
|
||||
$redis = new Redis();
|
||||
$redis->pconnect(_REDIS_SERVER);
|
||||
|
||||
$inf = array();
|
||||
$inf_cache = $redis->get("tip_info_cache");
|
||||
if($inf_cache == false) {
|
||||
$inf = GetAllAddrInfo(_TIP_ADDRS);
|
||||
$redis->setEx("tip_info_cache", 3600, json_encode($inf));
|
||||
}else{
|
||||
$inf = json_decode($inf_cache);
|
||||
}
|
||||
?>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Tips</title>
|
||||
<style>
|
||||
html, body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: Arial;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
div.body {
|
||||
width: 720px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-top: 10px;
|
||||
|
||||
border-radius: 10px;
|
||||
border: 1px solid #888;
|
||||
overflow:hidden;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
div.body div.tip-row {
|
||||
margin-top: 10px;
|
||||
overflow: hidden;
|
||||
padding: 10px;
|
||||
|
||||
background-color: #ccc;
|
||||
border-radius: 3px;
|
||||
border: 1px solid #555;
|
||||
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
div.body div.tip-row img {
|
||||
float: left;
|
||||
height: 24px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
div.body div.tip-row div {
|
||||
float: left;
|
||||
}
|
||||
div.body div.tip-row div.bal {
|
||||
float: right;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="body">
|
||||
<p>Tips help me get drunk, please consider tipping if you like the service I am currenly paying all the server bills myself.</p>
|
||||
<?php
|
||||
foreach($inf as $addr)
|
||||
{
|
||||
$addr_name = (isset($uri_format[strtoupper($addr->currency)]) ? ("<a href=\"" . sprintf($uri_format[$addr->currency], $addr->address) . "\">" . $addr->address . "</a>") : $addr->address);
|
||||
echo "<div class=\"tip-row\"><img src=\"/src/img/" . strtolower($addr->currency) . ".png\"/><div class=\"addr\">" . $addr_name . "</div><div class=\"bal\">" . strtoupper($addr->currency) . " " . number_format($addr->balance, 8) . "</div></div>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user