This repository has been archived by the owner on May 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
367 lines (216 loc) · 8.22 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
366
367
<?php
require_once("./basic.php");
require_once("./login.php");
require_once("./logout.php");
require_once("./database.php");
require_once("./action.php");
if(isset($_SESSION['id'])){
//--------------------USER LOGGED IN!!
?>
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Welcome, <?php echo $_SESSION['name']; ?>!</title>
<link rel='stylesheet' href="css/font.css" type='text/css'>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css">
<script>
function Ref() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("stockcontent").innerHTML = xhttp.responseText;
}
};
xhttp.open("GET", "offers.php", true);
xhttp.send();
}
function getNews() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("news-content").innerHTML = xhttp.responseText;
}
};
xhttp.open("GET", "actions.php?getnews", true);
xhttp.send();
}
function placeBid() {
compid=document.getElementById('compid').value;
quantity=document.getElementById('quantity').value;
price=document.getElementById('price').value;
type=document.getElementById('type').value;
if(compid == "" || quantity == "" || price == "" || type == ""){
document.getElementById("bid-error").innerHTML = "All values not filled in!";
return 1;
}
var regex = /^[0-9,.]+$/;
if(!price.match(regex)){
document.getElementById("bid-error").innerHTML = "Price must be a number only!";
return 1;
}
var regex = /^[0-9]+$/;
if(!quantity.match(regex)){
document.getElementById("bid-error").innerHTML = "Quantity must be a number only!";
return 1;
}
var regex = /^[0-1]+$/;
if(!type.match(regex)){
document.getElementById("bid-error").innerHTML = "Select from the list only";
return 1;
}
var regex = /^[0-9]+$/;
if(!compid.match(compid)){
document.getElementById("bid-error").innerHTML = "Please refresh the page";
return 1;
}
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("bid-error").innerHTML = xhttp.responseText;
}
};
xhttp.open("POST", "actions.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("buysell=1&compid="+compid+"&quantity="+quantity+"&price="+price+"&type="+type);
}
function del(id) {
//place code for confirming.
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
//document.getElementById("bid-error").innerHTML = xhttp.responseText;
}
};
xhttp.open("POST", "actions.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("delete="+id);
}
function showBid(id){
document.getElementById("compid").value=id;
document.getElementById("news-dialog").style.display='none';
document.getElementById("bid-dialog").style.display='inline';
document.getElementById("black-cover").style.display='inline';
}
function hideBid(){
document.getElementById("compid").value=0;
document.getElementById("black-cover").style.display='none';
document.getElementById("bid-dialog").style.display='none';
document.getElementById("bid-error").innerHTML="";
document.getElementById("news-dialog").style.display='none';
}
function showNews(){
document.getElementById("compid").value=0;
document.getElementById("black-cover").style.display='inline';
document.getElementById("bid-dialog").style.display='none';
document.getElementById("bid-error").innerHTML="";
document.getElementById("news-dialog").style.display='inline';
getNews();
}
</script>
</head>
<body>
<div id="black-cover" onclick="hideBid();"> </div>
<div id="bid-dialog">
<div style="float:right;padding:0px 5px;margin:0px;border:1px solid #fff;color:#fff;cursor:pointer" onclick="hideBid()">X</div><br/>
<div style="width:100%;text-align:center;padding:0px 0px 10px 0px;font-size:25px;color:#fff;"> Place Bid</div>
<div id="bid-error"></div>
<div>
<select name="type" id="type">
<option value="0">Buy</option>
<option value="1">Sell</option>
</select><br/><br/>
<input type="text" id="price" name="price" placeholder="Enter the price" /><br/>
<input type="number" id="quantity" name="quantity" placeholder="Enter number of stock" /><br/>
<input type="hidden" id="compid" name="compid" value="0" />
<button class="bid-dialog-button" onclick="placeBid()">Place Bid</button>
</div>
</div>
<div id="news-dialog">
<div style="float:right;padding:0px 5px;margin:0px;border:1px solid #fff;color:#fff;cursor:pointer" onclick="hideBid()">X</div><br/>
<div style="width:100%;text-align:center;padding:0px 0px 10px 0px;font-size:25px;color:#fff;"> News Board</div>
<div id="news-content">
<center style="font-size:20px;color:#fff"><br/><br/>Loading...<br/><br/></center>
</div>
</div>
<div id="user">
<div id="logout">
<form action="./index.php" method="post" >
<input id="logoutbutton" type="submit" name="logout" value="Logout" /><br/>
</form>
<button id="news-button" onClick="showNews()">News</button>
</div>
<div>
<b><?php echo $_SESSION['name'] ?><br/></b>
Balance: <b>Rs. <?php echo $_SESSION['amount'] ?>/-</b><br/>
<a href="mypage.php">My Page</a><br/>
<?php if($_SESSION['id']==1){ ?><a href="/admin.php">Admin Panel</a><br/><?php } ?>
<a href="instr.php">Instructions and Rules</a><br/>
</div>
</div><br/><br/><br/>
<div class="heading">
<h1>Wolf of Wallstreet</h1>
</div>
<div class="form">
<center>
<div id="stockcontent">
<span style="color:#fff;font-weight:20px;font-size:20px;">Loading...</span>
</div>
<script>setInterval(Ref, 1000);</script>
</center>
</div> <!-- /form -->
<script src="js/first.js"></script>
<script src="js/index.js"></script>
</body>
</html>
<?php }else{
//---------------------USER NOT LOGGED IN!!
?>
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Wolf of Wall Street : Login / Signup</title>
<link rel='stylesheet' href="css/font.css" type='text/css'>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="heading">
<h1>Wolf of Wallstreet</h1>
</div>
<div class="form">
<!--<ul class="tab-group">
<li class="tab"><a href="#signup">Sign Up</a></li>
<li class="tab active"><a href="#login">Log In</a></li>
</ul>-->
<div id="login">
<h1>Greed is Good!</h1>
<h4 class="formerr"><?php echo $loginerr; ?></h4>
<form action="/" method="post">
<div class="field-wrap">
<label>
UserID<span class="req">*</span>
</label>
<input type="text" name="user" required autocomplete="off"/>
</div>
<div class="field-wrap">
<label>
Password<span class="req">*</span>
</label>
<input type="password" name="password" required autocomplete="off"/>
</div>
<input type="hidden" name="login" value="Login" />
<button class="button button-block"/>Log In</button>
</form>
</div>
</div><!-- tab-content -->
</div> <!-- /form -->
<script src="js/first.js"></script>
<script src="js/index.js"></script>
</body>
</html>
<?php
};
?>