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 1
/
Copy pathnews.php
162 lines (128 loc) · 5.59 KB
/
news.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
<?php
require_once("./basic.php");
require_once("./logout.php");
if(isset($_SESSION['id'])){
if(isset($_GET['id'])){
$id = validate($_GET['id']);
$result = mysqli_query($conn, "SELECT * FROM news WHERE id=".$id);
while($row = mysqli_fetch_assoc($result)){
$compid = $row['compid'];
$content = $row['content'];
$time = $row['time'];
$compresult = mysqli_query($conn, "SELECT * FROM comp WHERE id=".$compid);
while($comp = mysqli_fetch_assoc($compresult)){
$compname = $comp['name'];
$compprice = $comp['price'];
$comppprice = $comp['pprice'];
}
}
}
?>
<!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 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 hideBid(){
document.getElementById("black-cover").style.display='none';
document.getElementById("news-dialog").style.display='none';
}
function showNews(){
document.getElementById("black-cover").style.display='inline';
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="index.php">Home</a><br/>
<a href="mypage.php">My Page</a><br/>
<?php if($_SESSION['id']==1){ ?><a href="/admin.php">Admin Panel</a><?php } ?><br/>
<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">
<div id="stockcontent">
<?php if(isset($compid)){ ?>
<span style="text-align:left;font-size:35px;font-weight:bold;color:#fff" onClick="window.location='company.php?id=<?php echo $compid ?>';"><?php echo $compname; ?></span><br/>
<span style="font-size:25px;" class="price<?php if($comp['pprice']<$comp['price']){ echo "inc";}else if($comppprice>$compprice){echo "dec";}else{ echo "sta"; } ?>" >
<?php echo $compprice; ?>
</span><br/><br/>
<span style="font-size:25px;color:#fff;"><?php echo $content ?></span><br/><br/>
<div style="float:right;color:#fff;"><?php echo $time; ?></div>
<?php }else{ ?>
<?php
$result = mysqli_query($conn, "SELECT * FROM comp");
while($comp = mysqli_fetch_assoc($result)){
$cname[$comp['id']] = $comp['name'];
$cprice[$comp['id']] = $comp['price'];
$cpprice[$comp['id']] = $comp['pprice'];
}
$result = mysqli_query($conn, "SELECT * FROM news ORDER BY id");
while($row = mysqli_fetch_assoc($result)){ ?>
<span style="text-align:left;font-size:35px;font-weight:bold;color:#fff"><?php echo $cname[$row['compid']]; ?></span><br/>
<span style="font-size:25px;" class="price<?php if($cpprice[$row['compid']]<$cprice[$row['compid']]){ echo "inc";}else if($cpprice[$row['compid']]>$cprice[$row['compid']]){echo "dec";}else{ echo "sta"; } ?>" >
<?php echo $cprice[$row['compid']]; ?>
</span><br/><br/>
<span style="font-size:25px;color:#fff;"><?php echo $row['content'] ?></span><br/><br/>
<div style="float:right;color:#fff;"><?php echo $row['time']; ?></div><br/><br/>
<hr/><br/>
<?php } ?>
<?php } ?>
</div>
</div> <!-- /form -->
<script src="js/first.js"></script>
<script src="js/index.js"></script>
</body>
</html>
<?php }else{ header("Location:index.php"); } ?>