This repository was archived by the owner on Nov 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathontherun.php
82 lines (79 loc) · 2.67 KB
/
ontherun.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
<?php
include_once('includes/common.php');
include_once('includes/validation.php');
include_once('includes/queries.php');
if (isset($_GET['t']) && isset($_GET['u'])) {
if ((($user = sanitize_username($_GET['u'])) !== FALSE) &&
(($token = sanitize_md5value($_GET['t'], 'Token')) !== FALSE))
{
if (!isset($_SESSION)) {
session_start();
}
if (($userinfo =
find_user_uid_token_login_and_timezone_by_login_and_token(
$user, $token)) === NULL)
{
flash('Invalid token or username', FLASH_ERROR);
$result->close();
redirect_to('index');
}
$token = $userinfo['utoken'];
$user = $userinfo['ulogin'];
$profileid = $userinfo['uid'];
$timezone = $userinfo['utimezone'];
if ($timezone == NULL) {
flash(
'Your timezone is not set, you should ' .
'<a href="auth/login">login</a> ' .
'and define a timezone!',
FLASH_WARNING);
}
}
else {
redirect_to('index');
}
}
else {
errorpage('Bad request', 'The request was bad.', '400 Bad Request');
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['coffeetime']) && (($coffeetime = sanitize_datetime($_POST['coffeetime'])) !== FALSE)) {
register_coffee($profileid, $coffeetime, $timezone);
}
elseif (isset($_POST['matetime']) && (($matetime = sanitize_datetime($_POST['matetime'])) !== FALSE)) {
register_mate($profileid, $matetime, $timezone);
}
redirect_to($_SERVER['REQUEST_URI']);
}
include_once('includes/jsvalidation.php');
include("header.php");
?>
<div class="white-box fullWidth">
<h2>On the run?</h2>
<center>
<?php render_flash('registerdrink'); ?>
<form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post" id="coffeeform" class="otrblockform">
<input type="submit" value="Coffee!" /><br />
<input type="hidden" id="coffeetime" name="coffeetime" />
</form>
<form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post" id="mateform" class="otrblockform">
<input type="submit" value="Mate!" /><br />
<input type="hidden" id="matetime" name="matetime" />
</form>
</center>
</div>
<script type="text/javascript" src="lib/jquery.min.js"></script>
<?php js_sanitize_datetime(); ?>
<script type="text/javascript">
$(document).ready(function() {
$('#coffeeform').submit(function(event) {
return sanitize_datetime('input#coffeetime');
});
$('#mateform').submit(function(event) {
return sanitize_datetime('input#matetime');
});
});
</script>
<?php
include('footer.php');
?>