-
Notifications
You must be signed in to change notification settings - Fork 119
/
index.php
365 lines (364 loc) · 15.8 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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
<?php
session_start();
error_reporting(0);
require_once'jsonRPCClient.php';
require_once'auth.php';
if($Logged_In===7) {
header("Location: home.php");
}
$coin_selecter = security($_GET['c']);
if($coin_selecter) {
if($coin_selecter=="LTC") { $_SESSION['trade_coin'] = "LTC"; }
if($coin_selecter=="BTC") { $_SESSION['trade_coin'] = "BTC"; }
header("Location: index.php");
}
$Buying_Rate = buyrate($BTE);
$Selling_Rate = sellrate($BTE);
if(!$Buying_Rate) { $Buying_Rate = '0'; }
if(!$Selling_Rate) { $Selling_Rate = '0'; }
$login_attempts = $_SESSION['login_attempts'];
if(!$login_attempts) {
$_SESSION['login_attempts'] = 0;
}
$myusername = security($_POST['username']);
$mypassword = security($_POST['password']);
$myrepeat = security($_POST['repeat']);
$form_action = security($_POST['action']);
if($form_action=="login") {
$_SESSION['login_attempts'] = $login_attempts + 1;
if($login_attempts<=5) {
if($myusername) {
if($mypassword) {
$mypassword2 = md5($mypassword);
$sql = "SELECT * FROM users WHERE username='$myusername'";
$result = mysql_query($sql);
$count = mysql_num_rows($result);
if($count==1) {
$Pass_Query = mysql_query("SELECT * FROM users WHERE username='$myusername'");
while($Pass_Row = mysql_fetch_assoc($Pass_Query)) {
$db_Login_Pass_Check = $Pass_Row['password'];
if($mypassword2==$db_Login_Pass_Check) {
$return_error = "Logged in.";
$_SESSION['user_session'] = $myusername;
header("location: index.php");
} else {
$return_error = "Invalid Password.";
}
}
} else {
$return_error = "User does not exist.";
}
} else {
$return_error = "No password was entered.";
}
} else {
$return_error = "No username was entered.";
}
} else {
$return_error = "Temporary block due to excessive failed logins.";
}
}
if($form_action=="register") {
if($coo_coo=="tootoo") {
if($myusername) {
if($mypassword) {
if($mypassword==$myrepeat) {
$uLength = strlen($myusername);
$pLength = strlen($mypassword);
if($uLength >= 3 && $uLength <= 30) {
$return_error = "";
} else {
$return_error = "Username must be between 3 and 30 characters.";
}
if($pLength >= 3 && $pLength <= 30) {
$return_error = "";
} else {
$return_error = "Password must be between 3 and 30 characters.";
}
if($return_error == "") {
if($db_found) {
$mypassword = md5($mypassword);
$SQL = "SELECT * FROM users WHERE username='$myusername'";
$result = mysql_query($SQL);
$num_rows = mysql_num_rows($result);
if($num_rows==1) {
$return_error = "Username already taken.";
} else {
if(!mysql_query("INSERT INTO users (id,date,ip,username,password) VALUES ('','$date','$ip','$myusername','$mypassword')")){
$return_error = "System error.";
} else {
$return_error = "Logged in.";
$_SESSION['user_session'] = $myusername;
header ("Location: index.php");
}
}
}
}
} else {
$return_error = "Passwords did not match";
}
} else {
$return_error = "No password was entered.";
}
} else {
$return_error = "No username was entered.";
}
} else {
$return_error = "Registrations are disabled.";
}
}
?>
<html>
<head>
<title><?php echo $script_title; ?></title>
<link rel="shortcut icon" href="image/favicon.ico">
<?php echo $CSS_Stylesheet; ?>
<script src="js/jquery-1.9.1.js"></script>
<script type="text/javascript">
$(document).ready(function () {
setInterval(function () {
$("#orderspast").load("ajax.php?id=orderspast-<?php echo $BTC; ?>");
$("#buyorders").load("ajax.php?id=buyorders-<?php echo $BTC; ?>");
$("#sellorders").load("ajax.php?id=sellorders-<?php echo $BTC; ?>");
$(".count").load("online.php");
$("#stats").load("ajax.php?id=stats");
}, 60000);
$("#buy-sells").scrollbars();
});
</script>
<script type="text/javascript">
function buycalculator() {
m = document.getElementById('buy-quantity').value;
n = document.getElementById('buy-rate').value;
if(m=='') { m = 0; }
if(n=='') { n = 0; }
o = m*n;
g = o.toFixed(8);
b = o/100;
c = b/5;
l = c.toFixed(8);
document.getElementById('buy-subtotal').innerHTML = g;
document.getElementById('buy-fee').innerHTML = l;
}
function sellcalculator() {
x = document.getElementById('sell-quantity').value;
y = document.getElementById('sell-rate').value;
if(x=='') { x = 0; }
if(x=='') { x = 0; }
z = x*y;
r = z.toFixed(8);
e = z/100;
f = e/5;
s = f.toFixed(8);
document.getElementById('sell-subtotal').innerHTML = r;
document.getElementById('sell-fee').innerHTML = s;
}
function setbuyamounts(text) {
document.getElementById('buy-quantity').value = text;
buycalculator();
}
function setbuyrates(text) {
document.getElementById('buy-rate').value = text;
buycalculator();
}
function setsellamounts(text) {
document.getElementById('sell-quantity').value = text;
sellcalculator();
}
function setsellrates(text) {
document.getElementById('sell-rate').value = text;
sellcalculator();
}
function setbuyrateamounts(text) {
pla = document.getElementById('buy-rate').value;
plb = text/pla;
plc = plb.toFixed(8);
document.getElementById('buy-quantity').value = plc;
buycalculator();
}
</script>
</head>
<body title="[zelles]">
<center>
<div align="center" class="headdiv">
<div align="center" class="balancesdiv"><span id="stats"><?php require'ajax/stats.php'; ?></span></div>
<table style="width: 100%; height: 50px;">
<tr>
<td align="left" style="width: 30px;" nowrap>
<a href="http://<?php echo $server_url; ?>"><img src="image/logob.png" title="<?php echo $script_title; ?>" alt="Logo" border="0"></a>
</td>
<td align="left" style="font-size: 18px; font-weight: bold;" nowrap>
<a href="http://<?php echo $server_url; ?>"><img src="image/logo.png" title="<?php echo $script_title; ?>" alt="[zelles]" border="0"></a>
</td>
<td align="right" nowrap>
<form action="index.php" method="POST">
<input type="hidden" name="action" value="login">
<table>
<tr>
<td align="right"><input type="text" name="username" placeholder="Username" value="<?php echo $myusername; ?>" style="width: 110px;" required autofocus></td>
<td align="right"><input type="password" name="password" placeholder="Password" style="width: 110px;" required></td>
<td align="right"><input type="submit" name="submit" class="button" value="Login"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</div>
<p></p>
<?php if($return_error) { echo '<div align="center" class="error-msg" nowrap>'.$return_error.'</div><p></p>'; } ?>
<table class="right-panel-table">
<tr>
<td valign="top" align="left" class="right-panel-left">
<div align="center" class="bodydiv">
<table style="width: 100%; height: 50px;">
<tr>
<td align="left" valign="top" style="padding: 5px;" nowrap>
<table>
<tr>
<td>
<div class="coin-button">
<a href="index.php?c=BTC" class="coin-link">BTE/BTC</a>
</div>
</td>
<td style="padding-left: 20px;">
<div class="coin-button">
<a href="index.php?c=LTC" class="coin-link">BTE/LTC</a>
</div>
</td>
</tr>
</table>
</td>
</tr><tr>
<td align="center" valign="top" style="padding: 5px;" nowrap>
<div align="center" class="buy-sells-box">
<table style="width: 260px; height: 50px;">
<tr>
<td align="left" style="font-weight: bold;" nowrap>Balance:</td>
<td align="right" style="font-weight: bold;" nowrap>Lowest Sell Value:</td>
</tr><tr>
<td align="left" nowrap><a href="#" onclick="setbuyrateamounts(0);">0</a> <?php echo $BTC; ?></td>
<td align="right" nowrap><?php echo '<a href="#" onclick="setbuyrates('.$Selling_Rate.');">'.$Selling_Rate.'</a> '.$BTC; ?></td>
</tr>
</table>
</div>
<table>
<tr>
<td colspan="3" style="height: 10px;">
</td>
</tr><tr>
<td align="right" nowrap><b>Quantity</b></td>
<td align="right" nowrap><input type="text" name="order-amount" value="0" id="buy-quantity" onkeyup="buycalculator();" onmouseenter="buycalculator();" onchange="buycalculator();" onmouseleave="buycalculator();" class="inputtrade"></td>
<td align="left" nowrap><?php echo $BTE; ?></td>
</tr><tr>
<td align="right" nowrap><b>Rate</b></td>
<td align="right" nowrap><input type="text" name="order-rate" value="<?php echo $Selling_Rate; ?>" id="buy-rate" onkeyup="buycalculator();" onmouseenter="buycalculator();" onchange="buycalculator();" onmouseleave="buycalculator();" class="inputtrade"></td>
<td align="left" nowrap><?php echo $BTC; ?></td>
</tr><tr>
<td align="right" nowrap><b>Sub-total</b></td>
<td align="right" nowrap><font id="buy-subtotal"><?php $bsubtotal = 0 * $Selling_Rate; echo satoshitize($bsubtotal); ?></font></td>
<td align="left" nowrap><?php echo $BTC; ?></td>
</tr><tr>
<td align="right" nowrap><b>Fee</b></td>
<td align="right" nowrap><font id="buy-fee"><?php $bfee = (($bsubtotal / 100) / 5); echo satoshitize($bfee); ?></font></td>
<td align="left" nowrap><?php echo $BTC; ?></td>
</tr><tr>
<td colspan="3" style="height: 10px;"></td>
</tr><tr>
<td colspan="3" align="right" nowrap><input type="submit" value="Buy" onmouseenter="buycalculator();" class="buybutton"></td>
</tr>
</table>
</td>
<td align="center" valign="top" style="padding: 5px;" nowrap>
<div align="center" class="buy-sells-box">
<table style="width: 260px; height: 50px;">
<tr>
<td align="left" style="font-weight: bold;" nowrap>Balance:</td>
<td align="right" style="font-weight: bold;" nowrap>Highest Buy Value:</td>
</tr><tr>
<td align="left" nowrap><a href="#" onclick="setsellamounts(0);">0</a> <?php echo $BTE; ?></td>
<td align="right" nowrap><?php echo '<a href="#" onclick="setsellrates('.$Buying_Rate.');">'.$Buying_Rate.'</a> '.$BTC; ?></td>
</tr>
</table>
</div>
<table>
<tr>
<td colspan="3" style="height: 10px;">
</td>
</tr><tr>
<td align="right" nowrap><b>Quantity</b></td>
<td align="right" nowrap><input id="sell-quantity" type="text" name="order-amount" value="0" onkeyup="sellcalculator();" onchange="sellcalculator();" onmouseenter="sellcalculator();" onmouseleave="sellcalculator();" class="inputtrade"></td>
<td align="left" nowrap><?php echo $BTE; ?></td>
</tr><tr>
<td align="right" nowrap><b>Rate</b></td>
<td align="right" nowrap><input id="sell-rate" type="text" name="order-rate" value="<?php echo $Buying_Rate; ?>" onkeyup="sellcalculator();" onchange="sellcalculator();" onmouseenter="sellcalculator();" onmouseleave="sellcalculator();" class="inputtrade"></td>
<td align="left" nowrap><?php echo $BTC; ?></td>
</tr><tr>
<td align="right" nowrap><b>Sub-total</b></td>
<td align="right" nowrap><font id="sell-subtotal"><?php $bsubtotal = 0 * $Buying_Rate; echo satoshitize($bsubtotal); ?></font></td>
<td align="left" nowrap><?php echo $BTC; ?></td>
</tr><tr>
<td align="right" nowrap><b>Fee</b></td>
<td align="right" nowrap><font id="sell-fee"><?php $sfee = (($ssubtotal / 100) / 5); echo satoshitize($sfee); ?></font></td>
<td align="left" nowrap><?php echo $BTC; ?></td>
</tr><tr>
<td colspan="3" style="height: 10px;"></td>
</tr><tr>
<td colspan="3" align="right" nowrap><input type="submit" value="Sell" onmouseenter="sellcalculator();" class="sellbutton"></td>
</tr>
</table>
</td>
</tr><tr>
<td align="left" valign="top" style="padding: 5px;" nowrap>
<span id="sellorders"><?php require"ajax/sellorders-$BTC.php"; ?></span>
</td>
<td align="left" valign="top" style="padding: 5px;" nowrap>
<span id="buyorders"><?php require"ajax/buyorders-$BTC.php"; ?></span>
</td>
</tr><tr>
<td colspan="2" align="left" valign="top" style="padding: 5px;" nowrap>
<span id="orderspast"><?php require"ajax/orderspast-$BTC.php"; ?></span>
</td>
</tr>
</table>
</div>
</td>
<td style="width: 6px;">
</td>
<td valign="top" align="left" class="right-panel-right">
<div align="left" class="right-panel">
<form action="index.php" method="POST">
<input type="hidden" name="action" value="register">
<table style="width: 100%;">
<tr>
<td align="left"><b>Register a new account:</b></td>
</tr><tr>
<td align="right"><input type="text" name="username" placeholder="Username" value"<?php echo $myusername; ?>" style="width: 100%;" required></td>
</tr><tr>
<td align="right"><input type="password" name="password" placeholder="Password" style="width: 100%;" required></td>
</tr><tr>
<td align="right"><input type="password" name="repeat" placeholder="Repeat Password" style="width: 100%;" required></td>
</tr><tr>
<td align="right"><input type="submit" name="submit" class="button" value="Register"></td>
</tr>
</table>
</form>
</div>
<p></p>
<div align="center" class="pending-right">
Under development.
</div>
<p></p>
<div align="left" class="right-panel"><b>Online:</b><p></p><span class="count"><?php require"online.php"; ?></span></div>
</td>
</tr>
</table>
<p></p>
<?php require'ajax/footer.php'; ?>
<p></p>
</center>
</body>
</html>
<?php
mysql_close($db_handle);
?>