-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeader.php
More file actions
253 lines (216 loc) · 8.93 KB
/
Copy pathHeader.php
File metadata and controls
253 lines (216 loc) · 8.93 KB
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
<?php
include_once "lib/Cookies.php";
include_once 'lib/DBHelper.php';
include_once './lib/ShoppingCart.php';
include_once 'lib/User.php';
$dbh_hdr = new DBHelper();
session_start();
if($_SESSION[SHOPPING_CART] == null) {
$_SESSION[SHOPPING_CART] = new ShoppingCart();
}
$shoppingCart = $_SESSION[SHOPPING_CART];
$_SESSION['admin'] = false;
$uToken = null;
if(isset($_GET["userToken"])) {
error_log("Get user token");
$uToken = $_GET["userToken"];
setcookie(COOKIE_TAM_UTOKEN, $uToken, time() + (86400 * 30), "/");
setcookie(COOKIE_NAME, "");
setcookie(COOKIE_EMAIL, "");
$_COOKIE[COOKIE_TAM_UTOKEN] = $uToken;
$_COOKIE[COOKIE_NAME] = "";
$_COOKIE[COOKIE_EMAIL] = "";
}
session_write_close();
error_log("$_COOKIE[COOKIE_TAM_UTOKEN]: ".$_COOKIE[COOKIE_TAM_UTOKEN]);
$isAdmin = false;
?>
<div id="id01" class="modal">
<form class="modal-content animate" action="Login2.php">
<div class="imgcontainer">
<span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">×</span>
<img src="images/CoffeeIcon.png" alt="Avatar" class="avatar">
</div>
<div class="container">
<label for="uname"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required>
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required>
<button type="submit">Login</button>
<label>
<input type="checkbox" checked="checked" name="remember"> Remember me
</label>
</div>
<div class="container" style="background-color:#f1f1f1">
<button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Cancel</button>
<span class="psw">Forgot <a href="#">password?</a></span>
</div>
</form>
</div>
<div class="form-popup" id="loginForm" align="center" >
<form action="Login2.php" class="form-container">
<h1>Login</h1>
<label for="email"><b>Email</b></label>
<input type="text" placeholder="Enter Email" name="email" required>
<label for="psw"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required>
<input type="submit" class="btn" value="Login">
<input type="button" class="btn cancel" onclick="closeLoginForm()" value="Close">
</form>
</div>
<script>
function openLoginForm() {
document.getElementById("loginForm").style.display = "block";
}
function closeLoginForm() {
document.getElementById("loginForm").style.display = "none";
}
</script>
<script type="text/javascript">
function confirmPass() {
var pass = document.getElementById("psw").value;
var confPass = document.getElementById("psw_c").value;
if(pass !== confPass) {
alert('Wrong confirm password !');
}
}
</script>
<div class="form-popup" id="createAccountForm" align="center" style="width: 100%">
<form action="CreateAccount.php" method="post" class="form-container" style="width: 100%">
<h1>Login</h1>
<tr c>
<td >
<input type="text" placeholder="Enter First Name" placeholder="First Name" name="firstName" required >
</td>
<td >
<input type="text" placeholder="Enter Last Name" placeholder="Last Name" name="lastName" required>
</td>
</tr>
<div></div>
<input type="text" placeholder="Enter Email" name="email" required>
<input type="text" placeholder="Enter Address" name="addr" required>
<input type="text" placeholder="Apartment" name="apt" >
<input type="text" placeholder="City" name="city" required>
<input type="text" placeholder="State" name="state" required>
<input type="text" placeholder="Zipcode" name="zip" required>
<input type="text" placeholder="Home Phone" name="phone" required>
<input type="text" placeholder="Cell Phone" name="cellPhone" required>
<input type="password" placeholder="Enter Password" name="psw" required>
<input type="password" placeholder="Confirm Password" name="psw_c" onblur="confirmPass()" required>
<input type="submit" class="btn" value="Create Account">
<input type="button" class="btn cancel" onclick="closeCreateAccountForm()" value="Close">
</form>
</div>
<script>
function openCreateAccountForm() {
document.getElementById("createAccountForm").style.display = "block";
}
function closeCreateAccountForm() {
document.getElementById("createAccountForm").style.display = "none";
}
</script>
<script>
function handleHelloMenu() {
openCreateAccountForm();
var dropdown = document.getElementById("notLoggedInOpts");
switch(dropdown.value) {
case 0:
openLoginForm();
break;
case 1:
openCreateAccountForm();
break;
}
}
</script>
<?php $fileList = get_included_files();?>
<thumbnail><img class="thumbNail" src="images/CoffeeIcon.png" alt="" align="left"/></thumbnail>
<logo>
<hd1>
<?php
if(stripos($fileList[0], "RoncabeanzMain.php", 0) == false){
echo '<a href="RoncabeanzMain.php">Roncabeanz</a>';
}
else{
echo 'Roncabeanz';
}
?>
<br>
</hd1>
<hd2>We simply respect the beans!</hd2>
</logo>
<topMenus>
<?php
$userName = "";
$userEmail = "";
if($uToken == null && isset($_COOKIE[COOKIE_TAM_UTOKEN])){
$uToken = $_COOKIE[COOKIE_TAM_UTOKEN];
}
if($uToken != null){
$mktUser = $mktUser = User::fromToken($uToken);
$userName = $mktUser->fname;
$userEmail = $mktUser->email;
}
else if(isset($_COOKIE[COOKIE_NAME])) {
$userName = $_COOKIE[COOKIE_NAME];
$userEmail = $_COOKIE[COOKIE_EMAIL];
}
else {
$userName = "";
}
if($userName != "") {
error_log("User: ".$userName.", ".$userEmail);
$query = "SELECT firstName, lastName, emailAddress, groupID FROM Roncabeanz.User WHERE emailAddress='{$userEmail}' ";
$result = $dbh_hdr->query($query);
$row = mysqli_fetch_array($result);
$isAdmin = $row["groupID"] == "Administrator";
$_SESSION['admin'] = $isAdmin;
session_write_close();
?>
<div class="dropdown">
<button class="dropbtn">Hello <?php echo $userName; ?></button>
<div class="dropdown-content">
<a href="LogOff.php">Log Out</a>
<?php
if($isAdmin){
echo '<a href="ShowCustomers.php">Mangage Customers</a>';
echo '<a href="ManageFeedback.php">Mangage Customer Feedback</a>';
echo '<a href="ManageProducts.php">Mangage Products</a>';
echo '<a href="TeamInteropTest.php?feedName=RoncabeanzUser&feedUri=http%3A%2F%2Froncabeanz.com%2FRoncabeanz%2FReadUsers.php">Marketplace Customers</a>';
}
else {
echo '<a href="ShowPurchases.php">Order History</a>';
}
?>
</div>
</div>
<?php } else {
$retUrl = "http://roncabeanz.com/Roncabeanz/RoncabeanzMain.php";
?>
<div class="dropdown">
<button class="dropbtn">Login/Sign-up</button>
<div id="notLoggedInOpts" class="dropdown-content" >
<a href="#" onclick="document.getElementById('id01').style.display='block'">Login</a>
<a href="#" onClick="openCreateAccountForm()">Create Account</a>
<a href="http://www.TeamAlphaMarket.com/TeamAlphaMarket/GetCurrentUserToken.php?retAddr=<?php echo $retUrl;?>">Login Using TAM</a>
</div>
</div>
<?php } ?>
<div class="dropdown" id="shoppingCartMenu">
<input class="dropcartbtn" type="image" src="images/ShoppingCartIcon.png" width="70" height="60">
<div class="dropdown-content">
<?php
$cartEmpty = true;
if($shoppingCart != null){
$cartEmpty = $shoppingCart->isEmpty();
}
if(!$cartEmpty){
echo '<a href="ShowCart.php">View</a>';
echo '<a href="EmptyCart.php">Empty</a>';
}
?>
</div>
</div>
</topMenus>
<?php $dbh_hdr->close(); ?>
<div style="clear: both"><br></div>