-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
81 lines (70 loc) · 2.07 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
<?php
require_once(__DIR__.'/config/dependency_loader.php');
$activepage = 'tool';
$language = Helper::get_language();
$csrf_token = Security::set_csrf_cookie_and_return_token();
if(ENVIRONMENT == 'production')
{
require_once('/var/simplesamlphp/lib/_autoload.php');
$auth = new \SimpleSAML\Auth\Simple('default-sp');
$attributes = $auth->getAttributes();
$authn_instant = $auth->getAuthData('AuthnInstant');
}
else
{
$attributes = [
'pbdf.gemeente.personalData.fullname' => [
!empty($_POST['fullname']) ? $_POST['fullname'] : NULL
]
];
$authn_instant = time();
}
$is_authenticated = FALSE;
$id = NULL;
if(
!empty($_POST['bestandstype']) &&
!empty($_POST['filename']) &&
!empty($_POST['hash']) &&
!empty($attributes['pbdf.gemeente.personalData.fullname'][0]) &&
!empty($authn_instant)
)
{
$db = Database::get_instance();
$is_authenticated = TRUE;
$id = Helper::generate_uuid();
$now = time();
$db->change_query('
INSERT INTO `certificates` (`id`, `file_type`, `filename`, `file_hash`, `name`, `name_verified_at`, `contact_info`, `created_at`, `updated_at`)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
', [
$id,
$_POST['bestandstype'],
$_POST['filename'],
$_POST['hash'],
$attributes['pbdf.gemeente.personalData.fullname'][0],
$authn_instant,
$_POST['contact_info'],
$now,
$now
]);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include 'parts/head-meta.php' ?>
<title>TakeNode</title>
</head>
<body class="<?= $is_authenticated ? 'show-tool '.$activepage : $activepage ?>">
<!-- Modals -->
<?php include 'parts/'.$language.'/modals/bestandstype.php' ?>
<?php include 'parts/'.$language.'/modals/persoonsgegevens.php' ?>
<?php include 'parts/'.$language.'/modals/toestemming.php' ?>
<?php include 'parts/'.$language.'/modals/mijntakenode.php' ?>
<?php include 'parts/header.php' ?>
<main>
<?php include 'parts/'.$language.'/tool.php' ?>
</main>
<script src="<?= BASE_URL ?>assets/js/main-min.js?<?= VERSION ?>" type="text/javascript"></script>
</body>
</html>