forked from Encrypt-S/navpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·232 lines (220 loc) · 9.15 KB
/
index.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<?php
include ("header.php");
include ("pass.php");
$updateFile = file_get_contents ('./update.json');
$updateData = json_decode($updateFile, TRUE);
if ($updateData) {
switch($updateData["code"]) {
case "UPDATE_INSTALLED":
echo "<br><p class='bg-success'><b>NOTICE: A new version of NavCoin has been installed. Click here to Apply the update and restart your device <a href='/applyupdate.php?updated=true' class='btn btn-default' style='margin:0;'>Apply Update</a></b></p>";
break;
default:
echo "<br><p class='bg-danger'><b>NOTICE: Something went wrong trying to update the NavCoin daemon. Click here to dismiss this message and restart your device <a href='/applyupdate.php?updated=false' class='btn btn-default' style='margin:0;'>Dismiss Notice</a>.</b></p>";
echo ('<pre>');
print_r ($updateData);
echo ('</pre>');
}
}
$info = $coin->getinfo();
$y = array_reverse($info);
$bal1 = $coin->getbalance();
$bal2 = $coin->getbalance("*", 0);
$bal3 = abs($bal1 - $bal2);
$bal4 = abs("{$y['stake']}");
$showMainAddressChangedMessage = false;
$oldAddress = $primary;
$newAddress;
// Fixes bug when the main address is set to an address not in the wallet -----------------------------------------------------
if($primary != ""){
$hasPrimary = false;
$addresses = $coin->getaddressesbyaccount("");
foreach($addresses as $add){
if($add == $primary){
$hasPrimary = true;
}
}
if ($hasPrimary) {
$address = $primary;
} else {
$address = $coin->getaddressesbyaccount("")[0];
// Duplicated code from setPrimary, as we can't access the function ----------------
$primaryLocation = "/home/stakebox/UI/primary".$currentWallet."address.php";
// Open the file and erase the contents if any
$fp = fopen($primaryLocation, "w");
// Write the data to the file
// CODE INJECTION WARNING!
fwrite($fp, "<?php\n\$primary='';\n?>");
// Close the file
fclose($fp);
$showMainAddressChangedMessage = true;
$newAddress = $address;
}
}
else{
$address = $coin->getaddressesbyaccount("")[0];
}
//-------------------------------------------------------------
if ($currentWallet == NavCoin){
$stakinginfo = $coin->getstakinginfo();
$stakereport = $coin->getstakereport();
$x = array_reverse($stakinginfo);
$time = $x['expectedtime'];
}
$days = floor($time / 86400);
$hours = floor(($time / 3600) % 24);
$minutes = floor(($time / 60) % 60);
$fiatValue = ($bal1 * $priceUsd);
$fiatValue = sprintf("%01.2f", $fiatValue);
$btcValue = ($bal1 * $priceBtc);
$btcValue = sprintf("%01.8f", $btcValue);
$img = shell_exec("qrencode --output=- -l H -d 144 -s 50 -m 1 $address"); $imgData = "data:image/png;base64," . base64_encode($img);
$fiatValue = number_format($fiatValue);
?>
<div class="row">
<?php
if ($showMainAddressChangedMessage == true)
echo "
<div class='col-lg-12'>
<div class='alert alert-info'>
<strong>Primary Address Updated:</strong>We detected your saved primary address was not owned by your wallet. It has been replaced with a valid address.
<p><small>This can occur when you restore your wallet after manually setting the primary address.</small></p>
<small>
New Address: \"{$address}\"
<br>Old Address: \"{$oldAddress}\"
</small>
</div>
</div>";
?>
<div class="col-lg-6">
<h3>Available Balance: <font color='green'><?php echo number_format($bal1); ?></font> <?php echo $currentWallet; ?></h3>
<h4>Unavailable Due To Staking: <font color='red'><?php echo $bal4; ?></font> <?php echo $currentWallet; ?></h4>
<h4>BTC Value: <font color='green'><?php echo "{$btcValue}"; ?></font></h4>
<h4><?php echo $longCurrency; ?> Value: <font color='green'><?php echo "{$symbol}{$fiatValue}"; ?></font></h4><br>
<div class="col-lg-8">
<form action="lockcontrol">
<button class='btn btn-default btn-block'>Your Wallet Is <?php print($lockState)?> Click To Change</button>
</form>
</div>
</div>
<div class="col-lg-3">
<?php if (isset($_POST['show'])){
$privKey = $coin->dumpprivkey($address);
$privKeyImg = shell_exec("qrencode --output=- -l H -d 144 -s 50 -m 1 $privKey");
$privKeyImgData = "data:image/png;base64," . base64_encode($privKeyImg);
?>
<center><img class="emrQRCode" src="<?=$privKeyImgData?>"height="30%" />
<h4>Private Key</h4></center>
<?php
}
else {
?>
<center><h4>In order to</h4>
<form name="sql-data" method="post" action="<?php $_SERVER['PHP_SELF']?>">
<button class='btn btn-default' type="submit" name="show" value="show">Show private key</button>
</form>
<h4>Wallet must be unlocked for sending, or not encrypted.</h4></center>
<?php
}
?>
</div>
<div class="col-lg-3">
<center><img class="emrQRCode" src="<?=$imgData?>"height="30%" />
<h4>Public Key</h4></center>
</div>
</div>
</div>
<div class="well">
<div class="row">
<div class="col-lg-5">
<?php
$configPath = "/home/stakebox/.navcoin4/navcoin.conf";
$configFile = file_get_contents($configPath);
if (strpos($configFile, "stakervote=1")) {
$vote = "YES";
} else if (strpos($configFile, "stakervote=0")) {
$vote = "NO";
} else {
$vote = "NOT_VOTED";
}
?>
<h4>Network Vote</h4>
<p>
The Nav Coin Network is currently voting on introducing changes on the consensus protocol. As a participant in our network, we value your input and the decision ultimately is yours. Please cast your vote. For more information on the proposal, please visit <a href="https://navcoin.org/community-fund" style="color:black;text-decoration:underline;">this link</a>
</p>
<p>
<?php if($vote === 'NOT_VOTED') { ?>
<b>You have not cast your vote yet.</b>
<?php } else { ?>
Currently your vote is set to <b><?php echo ucfirst(strtolower($vote)); ?></b>. If you want to change it, use the form below.
<?php } ?>
</p>
<p>
Would you like the Nav Coin Network to update the staking rewards to fund a decentralised community fund to help grow the network?
</p>
<form name="sql-data" method="post" action="/updatevote">
<div>
<label for="voteYes">Yes</label>
<input type="radio" name="vote" value="YES" id="voteYes" <?php if($vote == "YES") echo "checked"; ?> />
</div>
<div>
<label for="voteNo">No</label>
<input type="radio" name="vote" value="NO" id="voteNo" <?php if($vote == "NO") echo "checked"; ?> />
</div>
<button class='btn btn-default' type="submit" name="submitVote" value="vote">Set Vote</button>
</form>
</div>
</div>
</div>
<div class="well">
<div class="row">
<div class="col-lg-7">
<p> Your main wallet address is: <input type="text" name="main_wallet_address" value="<?php print_r($address); ?>" onClick="this.setSelectionRange(0, this.value.length);" size="48" readonly />
<p>The network is currently on block <?php print_r($coin->getblockcount()); ?>.
<?php if ($currentWallet == NavCoin): ?>
<?php echo "<p><b>Stake report</b></p><p>Last 24h: {$stakereport['Last 24H']} NAV</p><p>Last 7d: {$stakereport['Last 7 Days']} NAV</p><p>Last 30d: {$stakereport['Last 30 Days']} NAV</p><p>Last 365d: {$stakereport['Last 365 Days']} NAV</p>" ?>
<?php endif; ?>
<?php if ($currentWallet == Philosopherstone): ?>
<?php echo "<p>Your stake weight is {$x['stakeweight']}.</p>"?>
<?php endif; ?>
<?php if ($currentWallet == NavCoin): ?>
<?php echo "<p>Your estimated time to earn rewards is "?>
<?php if ($hours < 1 && $days < 1)echo "$minutes minutes.</p>"?>
<?php if ($hours == 1 && $days < 1)echo "$hours hour $minutes minutes.</p>"?>
<?php if ($hours > 1 && $days < 1)echo "$hours hours $minutes minutes.</p>"?>
<?php if ($hours == 0 && $days == 1)echo "$days day $hours hour $minutes minutes"?>
<?php if ($hours == 1 && $days == 1)echo "$days day $hours hours $minutes minutes"?>
<?php if ($hours < 1 && $days == 1)echo "$days day $hours hours $minutes minutes"?>
<?php if ($hours == 0 && $days > 1)echo "$days days $hours hours $minutes minutes"?>
<?php if ($hours == 1 && $days > 1)echo "$days days $hours hour $minutes minutes"?>
<?php if ($hours > 1 && $days > 1)echo "$days days $hours hours $minutes minutes"?>
<?php endif; ?>
</p></p>
<?php if($currentVersion != $newestVersion):?>
<!--<a href='update' class='btn btn-default' role='button'>A new update to the WebUI is available, click to get it.</a>-->
<?php endif; ?>
</div>
<?php if(file_exists("/home/stakebox/UI/".$currentWallet."notes.php")){
include('/home/stakebox/UI/'.$currentWallet.'notes.php');
echo "<div class='col-lg-5'>
<div class='form-group'>
<form action='notes' method='POST'><input type='hidden'>
<label for='notes'>Notes:</label>
<textarea class='form-control' name='notes' id='notes' cols='60' rows='10'>$notes</textarea>
<button class='btn btn-default' type='submit' value='setprimary' style='margin-top:10px;'>Save Notes</button>
</form>
</div>
</div>";}
else{
echo "<div class='col-lg-5'>
<div class='form-group'>
<form action='notes' method='POST'><input type='hidden'>
<label for='notes'>Notes:</label>
<textarea class='form-control' name='notes' id='notes' cols='60' rows='10'></textarea>
<button class='btn btn-default' type='submit' value='setprimary' style='margin-top:10px;'>Save Notes</button>
</form>
</div>
</div>";}
?>
</div>
</div>
<?php include ("footer.php"); ?>