diff --git a/src/modules/main.html b/src/modules/main.html index dc96ba2..db8f633 100644 --- a/src/modules/main.html +++ b/src/modules/main.html @@ -31,7 +31,10 @@ @@ -60,4 +63,4 @@ } customElements.define(VoidMain.is, VoidMain) - \ No newline at end of file + diff --git a/src/php/config.php.sample b/src/php/config.php.sample index 70b96b5..a289b32 100644 --- a/src/php/config.php.sample +++ b/src/php/config.php.sample @@ -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" + )); ?> \ No newline at end of file diff --git a/src/php/functions.php b/src/php/functions.php new file mode 100644 index 0000000..0a6fa6f --- /dev/null +++ b/src/php/functions.php @@ -0,0 +1,167 @@ + "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; + } +?> diff --git a/src/php/lightning-tip.php b/src/php/lightning-tip.php new file mode 100644 index 0000000..4cb45fb --- /dev/null +++ b/src/php/lightning-tip.php @@ -0,0 +1,53 @@ + + + + ⚡ Tip! ⚡ + + + +
+ result)) { + echo "wip..."; + + echo "
" . $inv->result->bolt11 . "
"; + + $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 ""; + }else{ + echo "
" . json_encode($inv) . "
"; + } + ?> +
+ + \ No newline at end of file diff --git a/src/php/tip-me.php b/src/php/tip-me.php new file mode 100644 index 0000000..cd4811b --- /dev/null +++ b/src/php/tip-me.php @@ -0,0 +1,93 @@ + "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); + } +?> + + + + Tips + + + +
+

Tips help me get drunk, please consider tipping if you like the service I am currenly paying all the server bills myself.

+ currency)]) ? ("currency], $addr->address) . "\">" . $addr->address . "") : $addr->address); + echo "
currency) . ".png\"/>
" . $addr_name . "
" . strtoupper($addr->currency) . " " . number_format($addr->balance, 8) . "
"; + } + ?> +
+ + \ No newline at end of file