-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
192 lines (171 loc) · 6.56 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
<!-- User starts on this page -->
<!-- Clicks the Login button -->
<!-- if user go back to user home -->
<!-- Goes to shopping -->
<!-- Goes to shopping cart -->
<!-- if admin go to admin home -->
<!-- can add/edit/delete admins and users -->
<!-- can add/edit/delete items in the store -->
<!-- Can admins also login as regular users? -->
<?php
session_start();
$host = "localhost";
$username = "root";
$password = "";
$db_name = "vekabestwebsite";
if (isset($_GET['bool'])) {
$_SESSION['LoggedIn']=$_GET['bool'];
$_SESSION['admin']=$_GET['bool'];
}
?>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE = edge">
<meta name="viewport" content="width = device-width, initial-scale = 1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Website vader van Steffan</title>
<link href="VekaBest.css" rel="stylesheet" type="text/css">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body id="index" style="background-color: #f0f0f0;">
<div class="inlog">
<a href="user_registration.php"><button class="inlogknop">Registreren</button></a>
<?php
if($_SESSION["LoggedIn"] === true) {
echo "<a href=''><button class='inlogknop' onclick='toFalse();'>Uitloggen</button></a>";
if($_SESSION["admin"] === true) {
echo "<a href='admin_index.php'><button class='inlogknop'>Admin</button></a>";
}
echo "<span class='WelcomeText'> Welcome " . $_SESSION["Userlogin"] . "!</span>";
} else {
echo "<a href='user_login.php'><button class='inlogknop'>Inloggen</button></a>";
}
?>
</div>
<div class="banner">
<img src="stockvekafotos/busbanner.jpg"/>
<!-- Button temporary disabled -->
<!-- <div class="login">
<a href="user_login.php"><button>Log in</button></a> -->
</div>
<div class="nav2">
<button onclick="showPage('user_home');" class="edit-color">
Home page
</button>
<button onclick="showPage('user_contact');" class="edit-color">
Contact
</button>
<button onclick="showPage('user_webshop');" class="edit-color">
Webshop
</button>
<button onclick="showPage('user_shopping_cart');" class="edit-color">
Winkelwagen
</button>
</div>
<div style="padding-top: 10px;">
<div class="container">
<?php include("user_home.php"); ?>
<?php include("user_profile.php"); ?>
<?php include("user_edit_profile.php"); ?>
<?php include("user_contact.php"); ?>
<?php include("user_webshop.php"); ?>
<?php include("user_shopping_cart.php"); ?>
<?php include("webshop_auto.php"); ?>
<?php include("webshop_brommer.php"); ?>
<?php include("webshop_bus.php"); ?>
<?php include("webshop_motor.php"); ?>
<?php include("webshop_spiegel.php"); ?>
<?php include("webshop_vrachtwagen.php"); ?>
</div>
</div>
<script type="text/javascript">
var pages = ["user_home", "user_profile", "user_edit_profile", "user_contact", "user_webshop", "user_shopping_cart", "webshop_auto", "webshop_brommer", "webshop_motor", "webshop_vrachtwagen", "webshop_bus", "webshop_spiegel"];
function showPage(pagename) {
for (var i = 0; i < pages.length; i++) {
try {
//Hide all pages.
var page = document.getElementById(pages[i]);
page.setAttribute("style", "display: none");
} catch (err) {
}
}
// Show picked page.
var showpage = document.getElementById(pagename);
showpage.setAttribute("style", "display: block");
//See which buttons need to be changed of color.
var edit = document.getElementsByClassName('edit-color');
var aNode = edit[0];
var arrFromList = Array.prototype.slice.call(edit);
//Remove all colors from the buttons.
for (var i = 0; i < edit.length; i++) {
edit[i].classList.remove("button-color-blue");
edit[i].classList.remove("button-color-orange");
edit[i].classList.remove("button-color-yellow");
edit[i].classList.remove("button-color-green");
edit[i].classList.remove("button-color-darkblue");
}
//Check what the chosen pagename is and change the colors accordingly.
switch (pagename) {
case "webshop_vrachtwagen":
for (var i = 0; i < edit.length; i++) {
edit[i].className += " " + "button-color-orange";
}
break;
case "webshop_bus":
for (var i = 0; i < edit.length; i++) {
edit[i].className += " " + "button-color-orange";
}
break;
case "webshop_brommer":
for (var i = 0; i < edit.length; i++) {
edit[i].className += " " + "button-color-yellow";
}
break;
case "webshop_motor":
for (var i = 0; i < edit.length; i++) {
edit[i].className += " " + "button-color-green";
}
break;
case "webshop_auto":
for (var i = 0; i < edit.length; i++) {
edit[i].className += " " + "button-color-darkblue";
}
break;
case "webshop_spiegel":
for (var i = 0; i < edit.length; i++) {
edit[i].className += " " + "button-color-blue";
}
break;
default:
break;
}
}
function toFalse() {
$.ajax({
type : 'GET',
url : 'index.php',
data: {
bool : false,
},
success : function(data){
location.reload();
},
error : function(XMLHttpRequest, textStatus, errorThrown)
{alert ("Error Occured");}
});
}
</script>
<?php
if (isset($_POST["EditUser"]) || isset($_POST["DeleteUser"])) {
echo '<script>
showPage("admin_users");
</script>';
}
?>
</body>
</html>