forked from nwoodthorpe/WatWhenWhere
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.html
211 lines (189 loc) · 7.43 KB
/
settings.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
200
201
202
203
204
205
206
207
208
209
210
211
<?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();
}
?>
<head>
<meta charset="utf-8">
<title>WatWhenWhere | Settings </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>
<html>
<body>
<script>
function getCookie(name) {
var value = "; " + document.cookie;
var parts = value.split("; " + name + "=");
if (parts.length == 2) return parts.pop().split(";").shift();
}
</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.disconnect().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">
<input type=button id="back_button" value="⬅︎" onclick="backButton()"/>
<div id="logo">
<a href="main.html"><img src="images/logo.png" /></a>
</div>
</div>
<div class="line2"></div>
<h2>SETTINGS</h2>
<input type=button id="update_schedule" value="Update Schedule" onclick="uploadSchedule()"/></br>
<input type=button id="privacy" value="Privacy Policy" onclick="viewPrivacy()"/></br>
<input type=button id="contact" value="Contact Us" onclick="viewContact()"/></br>
<input type=button id="delete_account" value="Delete Account" onclick="nuke()"</></br>
</div>
</body>
</html>
<script>
function viewPrivacy(){
window.location.assign('privacy.html');
}
function viewContact(){
window.location.assign('contact.html');
}
function uploadSchedule(){
document.cookie = "timestamp=" + ((new Date()).getTime() / 1000);
window.location.assign('uploadschedule.html');
}
function nuke(){
if(confirm("WARNING: Are you sure you want to delete your account?")){
var now = new Date();
var time = now.getTime();
time += 15 * 1000; //15 seconds
now.setTime(time);
document.cookie =
'time=1' +
'; expires=' + now.toUTCString() +
'; path=/';
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
if(xmlhttp.responseText == "success"){
logOut();
}
}
}
var vars = "";
xmlhttp.open("POST", "delacc.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send(vars);
}
}
function backButton(){
window.location.assign('main.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>