-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-process.php
More file actions
47 lines (43 loc) · 2.04 KB
/
Copy pathcreate-process.php
File metadata and controls
47 lines (43 loc) · 2.04 KB
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
<?php
require_once("functions.php");
$doesExist = checkIfUserExists($_POST['email']);
$_SESSION['lastprocess'] = Array();
if($doesExist === false) {
$myAccountTypes = $_SESSION['types'];
// Don't trust the posted account type - actually check they are allowed to create it.
if(isset($myAccountTypes[$_POST['type']])) {
$duration = getDurationForAccountType($_POST['type']);
$accountStartDate = prettifyDate(time(), 'ymd');
$accountEndDate = prettifyDate(strtotime($accountStartDate)+($duration*86400), 'ymd');
$newUsername = createAccount($_POST['firstname'], $_POST['lastname'], $_POST['email'], $accountStartDate, $accountEndDate, $_POST['type']);
$_SESSION['lastprocess'][] = Array(
'username' => $newUsername,
'status' => 'This account has been created and the password has been emailed to the user.'
);
logAction('create', $newUsername);
} else {
die('Access denied');
}
} else {
switch($doesExist['type']) {
case 'local':
extendDate($doesExist['username'], $_POST['duration']);
$_SESSION['lastprocess'][] = Array(
'username' => $doesExist['username'],
'colour' => 'info',
'status' => 'This person already has a '.$systemName.' account. Their details are below:'
);
logAction('not-created-local', $doesExist['username']);
break;
case 'ldap':
$_SESSION['lastprocess'][] = Array(
'username' => false,
'colour' => 'warning',
'status' => 'This person already has a real LDAP account. Their username is <strong>'.$doesExist['username'].'</strong>'
);
logAction('not-created-ldap', $doesExist['username']);
break;
}
}
header('location: processed.php');
?>