forked from nwoodthorpe/WatWhenWhere
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.html
199 lines (177 loc) · 7.05 KB
/
main.html
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
<?php
$modifier = "";
if(isset($_COOKIE['modifier'])){
//A MODIFIER IS SET
$modifier = $_COOKIE['modifier'];
}
if(!isset($_COOKIE['email']) || !isset($_COOKIE['platform'])){
header('Location: index.html');
}
include 'includes/mysqlconfig.php';
$conn = new mysqli(constant("HOST"), constant("USER"), constant("PASSWORD"), constant("DATABASE"));
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$query = $conn->query("SELECT * FROM users WHERE (email='" . $email ."' AND accounttype='" . $platform . "')");
if($query){
$row = $query->fetch_assoc();
if($row['schedule'] == ""){
header('Location: uploadschedule.html');
}
}else{
mysqli_close($conn);
die();
}
?>
<html>
<head>
<meta charset="utf-8">
<title>WatWhenWhere | Main </title>
<meta name="description" content="WatWhenWhere">
<link rel="stylesheet" href="style.css">
<link rel="icon" href="images/icon.png">
<meta name="google-signin-client_id" content="890020960337-hliq85p80t2b5koomq98dee5tfjjnpbn.apps.googleusercontent.com">
</head>
<body onload="modifierCheck()">
<script>
function getCookie(name) {
var value = "; " + document.cookie;
var parts = value.split("; " + name + "=");
if (parts.length == 2) return parts.pop().split(";").shift();
}
function deleteCookie(name) {
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
function modifierCheck(){
var modifier = getCookie("modifier");
console.log("MODIFER: " + modifier);
deleteCookie("modifier");
if(modifier == "scheduleAdded"){
alert("Your schedule has been successfully updated!");
}else if(modifier == "scheduleError"){
alert("There was an error adding your schedule!");
}
}
</script>
<!-- FACEBOOK SCRIPT BEGIN -->
<script>
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
if (response.status === 'connected') {
loggedIn();
} else if (response.status === 'not_authorized') {
notLoggedIn();
} else {
notLoggedIn();
}
}
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId : '555230491292682',
cookie : true,
xfbml : true,
version : 'v2.2'
});
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function loggedIn() {
console.log("USER LOGGED ON - FACEBOOK");
}
function notLoggedIn(){
if(getCookie("platform") != "google"){
console.log("NO GOOGLE TIE AND NOT LOGGED IN TO FACEBOOK - REDIRECTING...");
window.location.replace("index.html");
}else{
console.log("FB NOT LOGGED, USER ON GOOGLE");
}
}
</script>
<!-- FACEBOOK SCRIPT END -->
<!-- GOOGLE SCRIPT BEGIN -->
<script>
function signOut() {
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function () {
console.log('User signed out.');
});
}
function onLoad() {
gapi.load('auth2', function() {
gapi.auth2.init();
var auth = gapi.auth2.getAuthInstance();
console.log("LOADING...");
auth.then(function(){
if(!auth.isSignedIn.get()){
if(getCookie("platform") != "facebook"){
console.log("NO FACEBOOK TIE AND NOT LOGGED IN TO GOOGLE - REDIRECTING...");
window.location.replace("index.html");
}else{
console.log("GOOGLE NOT LOGGED, USER ON FB");
}
}else{
console.log("USER LOGGED IN - GOOGLE");
}
});
});
}
</script>
<script src="https://apis.google.com/js/platform.js?onload=onLoad" async defer></script>
<!-- GOOGLE SCRIPT END -->
<div id="container" class="container_main">
<div id="header">
<div id="logo">
<a href="main.html"><img src="images/logo.png" /></a>
</div>
</div>
<div class="line2"></div>
<h2>MAIN MENU</h2>
<input type=button id="compare" value="Compare Schedules" onclick="compareSchedule()"/></br>
<input type=button id="view_friends" value="View Friends" onclick="viewFriends()"/></br>
<input type=button id="settings" value="Settings" onclick="viewSettings()"/></br>
<input type=button id="logout" value="Log Out" onclick="logOut()"</></br>
</div>
</body>
</html>
<script>
function viewSettings(){
window.location.assign('settings.html');
}
function viewFriends(){
window.location.assign('friends.html');
}
function uploadSchedule(){
document.cookie = "timestamp=" + ((new Date()).getTime() / 1000);
window.location.assign('uploadschedule.html');
}
function compareSchedule(){
window.location.assign('compare.html');
}
function logOut(){
FB.api('/me', {fields: 'email, name'}, function(response) {
var id = response.id;
FB.api('/' + id + '/permissions', 'delete', function(response){
window.location.assign('index.html');
});
});
var auth2 = gapi.auth2.getAuthInstance();
auth2.disconnect().then(function () {
console.log("666");
window.location.assign('index.html');
});
}
</script>