forked from Someguy123/CryptoCoin-Instawallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
my.php
168 lines (166 loc) · 9.3 KB
/
my.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
<?php
include ("core/wallet.php");
if(isset($_SESSION['key']) && !isset($_GET['key'])) {
header( "location: /my/key/" . $_SESSION['key']);
}
if ($_GET ['key'] && $addr->verKey ( $_GET ['key'] )) {
$ltcaddr = $addr->verKey ( $_GET ['key'] );
if (! isset ( $_SESSION ["key"] )) {
$_SESSION ["key"] = $_GET ["key"];
header ( "location: /key/" . $_GET ["key"] );
}
} else {
$ltcaddr = "Invalid Key";
}
include ('templates/header.php');
?>
<div class="row push">
<?php
echo srsnot ( "<strong>IMPORTANT!</strong><br /><strong>Don't lose this link!</strong> This link contains your <strong>Wallet Identifier</strong>—if you lose it, you won't be able to find your account.</p>
<p style='text-align:center;'><a href=\"/key/{$_GET['key']}\" style=\"font-size: 12px;\">http://{$_SERVER['SERVER_NAME']}/key/{$_GET['key']}</a> (ctrl+D to bookmark)" );
?>
<div class="span10">
<div class="page-header">
<h4>Your <?php echo $coin; ?> receiving address:</h4>
<p style="font-size:2em;text-align:center;"><?php echo $ltcaddr; ?></p>
</div>
<?php
if ($_GET ['key']) {
if (!isset($_SESSION['password']) && $addr->hasPass($_GET['key'])) {
$loggedin = false;
$form = "<form action='/key/{$_GET['key']}' method='post'>
<input type='password' name='password' />
<input class='btn' type='submit' value='Login' />
</form>";
echo "<h2>Enter the password for this account to continue.</h2>";
if(isset($_POST['password'])) {
if($addr->checkPass($_GET['key'], $_POST['password']) === true) {
$_SESSION['password'] = "true";
echo "<h3>Thank you, <a href='/key/{$_GET['key']}'>click here</a> to continue.</h3>";
} else {
echo srserr("Sorry, that password is invalid, please try again:");
echo $form;
}
} else { echo $form; }
} else { $loggedin = true; }
if ($addr->verKey ( $_GET ['key'] )) {
if(isset($_POST['newpass'], $_POST['passconf'])) {
if($_POST['newpass'] == $_POST['passconf']) {
try {
if($addr->hasPass($_GET['key'])) {
$addr->setPass($_GET['key'], $_POST['newpass'], $_POST['currpass']);
echo srsnot("Password has been set successfully; we recommend you log out and back in again to finish setting the password correctly.");
} else {
$addr->setPass($_GET['key'], $_POST['newpass']);
echo srsnot("Password has been set successfully; we recommend you log out and back in again to finish setting the password correctly.");
}
} catch (Exception $error) {
switch($error) {
case "INV_PASSWORD":
echo srserr("You typed your current password incorrectly, go back and enter the correct password.");
break;
case "TOO_LONG":
echo srserr("Password is too long (max 32 characters).");
break;
case "TOO_SHORT":
echo srserr("Password is too short (at least 4 characters minimum)");
default:
echo srserr("Something went wrong, try again later.");
}
}
} else {
echo srserr("Make sure you typed your password correctly.");
}
}
$ltcaddr = $addr->verKey ( $_GET ['key'] );
// Sets/updates session_key with valid provided
if ($_POST ['amount'] && $_POST ['address'] && $loggedin == true) {
try {
$addr->sanitizedSend ( $_POST ['address'], $ltcaddr, $_GET ['key'], str_replace ( ",", ".", $_POST ['amount'] ) );
echo '<div class="alert-message success" data-alert="alert"><a class="close" onclick="\$().alert()" href="#">×</a><p>Successfully sent ' . $_POST ['amount'] . " {$coin} to " . $_POST ['address'] . '.</p></div>';
} catch ( Exception $erar ) {
switch ($erar->getMessage ()) {
case "INVALID_AMT" :
echo srserr ( "That isn't a valid amount" );
break;
case "INVALID_ADDR" :
echo srserr ( "Sending {$_POST['amount']} to {$_POST['address']} failed: Invalid {$coin} address" );
break;
case "SEND_FAILED" :
echo srserr ( "Sending {$_POST['amount']} to {$_POST['address']} failed: You don't have enough {$coin} in your account to do that" );
break;
case "LOW_BALANCE" :
echo srserr ( "Sending {$_POST['amount']} to {$_POST['address']} failed: You don't have enough {$coin} in your account to do that. Note: some transactions require a 0.005 minimum fee." );
break;
default :
echo srserr ( "Something has gone horribly wrong. Please contact us!" );
}
}
}
// echo "<h4>Address: <input type='text' value='{$ltcaddr}' style='width:260px;text-align:center;' readonly='readonly' /></h4>";
if($loggedin == true) {
echo "<h2>Balance: " . formnum($addr->ltc->getbalance($_GET ['key'],$minconf)) . " (unconfirmed: " . formnum($addr->ltc->getbalance($_GET['key'],0) - $addr->ltc->getbalance($_GET ['key'],$minconf)) .")</h2>
<p><em style='font-size:13px;'>Deposits are updated after {$minconf} confirmations; {$minleft} {$coin} is reserved for fees.</em><p>";
?>
<div class='row'>
<div class='span6'>
<h4>Send <?=$coin?>:</h4>
<form class='form-stacked' action='/key/<?=$_GET['key']?>' method='POST'>
<input type='text' id='address' name='address' placeholder='<?=$coin?> address to send to' style='width: 260px;'/><br />
<input type='text' id='amount' name='amount' placeholder='Amount of <?=$coin?> to send' style='width: 180px;' /> <input type='submit' class='btn info'value='Send'/>
</form>
</div>
<div class='span6'>
<table style="width: 560px;">
<thead>
<tr><td><h4>Security:</h4></td></tr>
</thead>
<tr>
<td style="border: 0px;">
<form class='form-stacked well' method='post' action='/key/<?=$_GET['key']?>'>
<?php if($addr->hasPass($_GET['key'])): ?>
<label for="pass">Your current password</label> <input type='password' id='currpass' name='currpass' style='width: 180px; text-align: left;' /><br />
<?php endif; ?>
<input type='password' id='newpass' name='newpass' placeholder='Your new password' style='width: 180px; text-align: left;' />
<input type='password' id='newpassconf' name='passconf' placeholder='Retype new password' style='width: 180px; text-align: left;' />
<input type='submit' class='btn info' value='SET' /> <br /> <em>WARNING: Setting a password will require you to enter it before you have access to your funds. DO NOT FORGET YOUR PASSWORD.</em>
</form>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</div>
</div>
<?php
echo "<br /><h4>Your last 15 transactions:</h4>";
echo "<div style=\"margin-right: 20px;\">
<table class='table table-bordered table-striped'>
<tr><td>Confirms</td><td>Transaction ID</td><td>Amount</td><td>Fee</td></tr>";
$dump = array_reverse ( $addr->ltc->listtransactions ( $_GET ['key'], "15" ) );
foreach ( $dump as $herp ) {
if ($herp ['account'] == $_GET ['key']) {
echo "<tr><td>" . $herp ['confirmations'] . "</td>
<td><input type='text' value='" . $herp ['txid'] . "' style='margin: 0px;width:500px;'/></td>
<td>" . formnum($herp ['amount']) . "</td>
<td>" . ($herp ['fee'] ? $herp ['fee'] : 0) . "</td>
</tr>";
}
}
echo "</table></div>";
}
$addr->PDO_Conn = NULL;
} else {
echo srserr ( "INVALID KEY..." );
}
} else {
echo srserr ( "No key specified." );
}
?>
</div>
</div>
<?php
include ("templates/sidebar.php");
include ('templates/footer.php');
?>