-
Notifications
You must be signed in to change notification settings - Fork 11
/
walletnotify.php
executable file
·65 lines (45 loc) · 2.18 KB
/
walletnotify.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
54
55
56
57
58
59
60
61
62
63
64
65
<?php
require("/home/stakebox/UI/config.php");
require("jsonRPCClient.php");
include("/home/stakebox/UI/email.php");
include("diskusage.php");
session_start();
$_SESSION['currentWallet'] = $_GET['currentWallet'];
if (isset($_SESSION['currentWallet']) && !empty($_SESSION['currentWallet']))
$currentWallet = $_SESSION['currentWallet'];
$coinu = $wallets[$currentWallet];
$coin = new jsonRPCClient("{$coinu['protocol']}://{$coinu['user']}:{$coinu['pass']}@{$coinu['host']}:{$coinu['port']}", true);
$ticker = $coinu['ticker'];
$transactionHash = $_GET["transactionHash"];
$transactionFile = "/home/stakebox/UI/latest".$currentWallet."Transaction.php";
include("$transactionFile");
$walletinfo = $coin->getinfo();
$trxinfo = $coin->gettransaction($transactionHash);
$date = date('D M j Y g:i a', $trxinfo['time']);
if($trxinfo["details"][0]["category"]=="send"){
$new = "You have sent ".abs($trxinfo["details"][0]["amount"])." ".$ticker." to ".$trxinfo["details"][0]["address"]."."
."\nAs of ".$date." your current balance is ".$walletinfo["balance"];
}
if($trxinfo["details"][0]["category"]=="receive"){
$new = "You have received ".$trxinfo["details"][0]["amount"]." ".$ticker." with ".$trxinfo["details"][0]["address"]."."
."\nAs of ".$date." your current balance is ".$walletinfo["balance"];
}
if($trxinfo["details"][0]["category"]=="stake"){
$new = "You have received a staking reward of ".$trxinfo["details"][0]["amount"]." ".$ticker."."
."\nAs of ".$date." your current balance is ".$walletinfo["balance"];
}
if($trxinfo["details"][0]["category"]=="generate"){
$new = "You have received a staking reward of ".$trxinfo["details"][0]["amount"]." ".$ticker."."
."\nAs of ".$date." your current balance is ".$walletinfo["balance"];
}
if((!file_exists("$transactionFile"))||($transactionHash != $oldHash)){
$newHash = "<?php "."$"."oldHash = ".'"'."$transactionHash".'";'." ?>";
$fp = fopen("$transactionFile","w");
fwrite($fp,$newHash);
}elseif($dp>70){
exec("echo '$diskWarning' | mailx -s 'StakeBox disk space low!' $email");
}
if(($transactionHash==$oldHash)&&($new!="")){
exec("echo '$new' | mailx -s 'New $currentWallet transaction' $email");
}
?>