-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
327 lines (270 loc) · 10.4 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
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<?php
require('config.php');
require('include.php');
// if ($cmd != "") {
// print("s:".$s);
// print("<br>cmd:".$cmd);
// print("<br>user:".$user);
// print("<br>pwd:".$pwd);
// print("<br>adminview:".$adminview);
// exit;
// }
if ($cmd == "test") {
sendEmailChangeVenue(1, 1, "der grund");
// changevenue(trim($reason));
// sendEmailInvitation(1, 1);
// sendEmailReminder(1, 1);
}
$nextMeetingTS = getNextMeetingTimeStamp();
$nextMeetingDate = date('D, d.m.Y', $nextMeetingTS);
$nextMeetingDateShort = date('F j', $nextMeetingTS);
$mid = getNextMeeting();
//printf("<br><br><br><br><br><br><br><br>Next Meeting MID: ". getNextMeeting());
$locationName = getMeetingLocationName($mid);
$locationAddress = getMeetingLocationAddress($mid);
$locationText = "The next <i>Stammtisch</i> <b>".$nextMeetingDate."</b> is going to happen <br>at <a href='http://www.google.de/search?q=".$locationName.", ".$locationAddress."' target='_blank'>".$locationName.", ".$locationAddress."</a>";
if (isMeetingDayWrapper($TODAY)) {
$nextMeetingDate = "today";
$nextMeetingDateShort = "today";
$locationText = "The next <i>Stammtisch</i> happens <b>TODAY</b> <br>at <a href='http://www.google.de/search?q=".$locationName.", ". $locationAddress."' target='_blank'>".$locationName.", ".$locationAddress."</a>";
}
if ($locationName == "") {
$locationText = "The next <i>Stammtisch</i> will be <b>".$nextMeetingDate.".</b><BR>The venue has not been chosen yet - you can still vote for one!";
if (isMeetingDayWrapper($TODAY)) {
$locationText = "The next <i>Stammtisch</i> happens <b>TODAY</b>".$nextMeetingDate.".<BR>The venue has not been chosen yet - you can still vote for one!";
}
}
$locationText = $locationText."<BR>@ ".date("h:i A",$MEETINGSTART+$UTCTIMEDIFF)."";
$message = "";
$errormsg = false;
$tmpuid = "";
// cookie control I of II
$cookie_name = "s";
if ($cmd == "ics") {
exportICS($mid, "2"); // alarm 2 hours before
}
if ($cmd == "vcs") {
exportVCS($mid);
}
if ($cmd == "login") {
$uid = getUID($user);
if ($uid < 0) {
// fall back, allow login with email too
$uid = getUIDbyMail($user);
}
if (login($uid, $pwd)) {
$s = createRandomSession($uid);
$message = "Welcome ".getName($uid)."!";
//printf("<br><br><br><br><br>Session/UID".$s." / ".$tmpuid);
// cookie control II of II
// cookie is valid for (1 day cookie)
$cookie_value = $s;
setcookie($cookie_name, $cookie_value, time() + $EXPIRECOOKIE, "/");
$tmpuid = $uid;
require('index-login.php');
exit;
//printf("logged in:".$s);
} else {
if ($user != "") {
// delete cookie
setcookie($cookie_name, "invalid", time() + $EXPIRECOOKIE, "/");
$message = "Authentication failed";
$errormsg = true;
}
}
}
if ($cmd == "removeaccount") {
$tmpuid = getSessionUID($s);
$vglpwd = getPwd($tmpuid);
//$message = $vglpwd ." == ".$tmpuid;
if ($vglpwd == md5($pwd)) {
removeAccount($tmpuid);
$message = "Account removed, we are sad that you leave! :-(";
$errormsg = false;
logout($uid);
$uid = "";
$s = "";
} else if ($pwd != "") {
$message = "Wrong password. Account NOT removed.";
$errormsg = true;
}
}
// this is the currently logged in user
$tmpuid = getSessionUID($s);
// test if we need a cookie and if there is one that helps
if ($tmpuid <= 0 && ($errormsg == "")) {
if (isset($_COOKIE[$cookie_name])) {
$s = $_COOKIE[$cookie_name];
$tmpuid = getSessionUID($s);
}
}
//printf("<br><br><br><br><br>Session/UID".$s." / ".$tmpuid);
if ($tmpuid > 0) {
$uid = $tmpuid;
if ($cmd == "logout") {
logout($uid);
$uid = "";
$s = "";
$message = "Good Bye!";
header("Location: ".$BASEURL."?cmd=logout");
exit;
} else {
// cookie control II of II
// cookie is valid for (1 day cookie)
$cookie_value = $s;
setcookie($cookie_name, $cookie_value, time() + $EXPIRECOOKIE, "/");
require('index-login.php');
exit;
}
}
if ($cmd == "logout") {
$uid = "";
$s = "";
$message = "Good Bye!";
}
?>
<!DOCTYPE html>
<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 -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="favicon.png">
<meta http-equiv="expires" content="0">
<title>RtSys Stammtisch - Est. 2016</title>
<!-- Bootstrap core CSS -->
<link href="bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="bootstrap/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="jumbotron.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="bootstrap/assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="bootstrap/assets/js/ie-emulation-modes-warning.js"></script>
<?php
if (($cmd == "logout")||(($cmd == "login") && $errormsg != "")) {
printf(' <meta http-equiv=REFRESH content="2; URL='.$BASEURL.'">');
}
?>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
function showMessage() {
document.getElementById("title").style.display = 'none';
document.getElementById("message").style.display = 'block';
setTimeout(function() {
document.getElementById("message").style.display = 'none';
document.getElementById("title").style.display = 'block';
}, 5000); // <-- time in milliseconds
}
</script>
<style>
.floatcontainer{
display: flex
}
</style>
</head>
<?php if($cmd == "location") {printf('<body>'.$locationText.'</body>'); exit;} ?>
<body>
<?php if($cmd == "minimal") {printf('<span id="message" style="display: none;">');} ?>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<span id="title">
<a class="navbar-brand" href="#">RtSys Stammtisch</a>
</span>
<span id="message" style="display: none;">
<a class="navbar-brand" href="<?php print($BASEURL)?>" style="font-weight: bold;color:#<?php if ($errormsg) { printf("FE8787"); } else { printf("66FF66");} ?>"><?php printf($message)?></a>
</span>
<?php
if ($message != "") {
printf("<script> showMessage(); </script>");
}
?>
</div>
<div id="navbar" class="navbar-collapse collapse">
<form class="navbar-form navbar-right" method="post" action="<?php print($BASEURL)?>">
<div class="form-group">
<input type="text" placeholder="Name or Email" name="user" class="form-control">
</div>
<div class="form-group">
<input type="password" placeholder="Password" name="pwd" class="form-control">
</div>
<input type="hidden" name="cmd" value="login">
<button type="submit" class="btn btn-success">Sign in</button>
</form>
</div><!--/.navbar-collapse -->
</div>
</nav>
<?php if($cmd == "minimal") {printf('</span>');} ?>
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
<div class="container">
<?php if($cmd == "minimal") {printf('<span id="message" style="display: none;">');} ?>
<div class="col-md-3">
<img src="clockman_m.png" alt="" vspace="20" class="jumbotronwidth">
</div>
<?php if($cmd == "minimal") {printf('</span>');} ?>
<div class="col-md-6">
<?php if($cmd == "minimal") {printf('<span id="message" style="display: none;">');} ?>
<h1>RtSys Stammtisch</h1>
<?php if($cmd == "minimal") {printf('</span>');} ?>
<p><?php printf( $locationText );?></p>
<div class="form-group floatcontainer">
<?php
if ($locationName != "") {
printf("<p></p><div class='scol-md-5' style='margin-left: -0em;'><a class='btn btn-primary btn-lg' href='http://maps.google.de/maps?q=".$locationAddress."' target='_blank' role='button'>Google Maps »</a></div> ");
} else {
printf("<br>");
}
printf("<div class='scol-md-3' style='margin-left: -0em;'><a class='btn btn-primary btn-lg' href='".$BASEURL."?cmd=ics' role='button'>To Calendar »</a></div>");
?>
</div>
</div>
</div>
</div>
<div class="container">
<!-- Example row of columns -->
<div class="row">
<div class="col-md-4">
</div>
<div class="col-md-4">
<form method="post" action="<?php print($BASEURL)?>">
<div class="form-group">
<input type="text" placeholder="Name or Email" name="user" class="form-control">
</div>
<div class="form-group">
<input type="password" placeholder="Password" name="pwd" class="form-control">
</div>
<p>
<input type="hidden" name="cmd" value="login">
<button type="submit" class="btn btn-default">Sign in</button>
</p>
</form>
</div>
<div class="col-md-4">
</div>
</div>
<?php if($cmd == "minimal") {printf('<span id="message" style="display: none;">');} ?>
<hr>
<footer>
<p>© 2016 <a href="http://www.rtsys.informatik.uni-kiel.de">EmbRtSys Group</a>, Kiel University, Germany</p>
</footer>
<?php if($cmd == "minimal") {printf('</span>');} ?>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
<script src="../../dist/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>