-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_operator.php
executable file
·80 lines (61 loc) · 2.35 KB
/
new_operator.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
<?php
require_once('settings.php');
$link = mysql_connect($db_server,$db_username,$db_password);
if (! mysql_select_db($db_database)) {
die(mysql_error());
}
if (preg_match('/^\d+$/', $_POST['institution_id'])) {
$query = 'SELECT institution_id FROM institution WHERE institution_id=' . $_POST['institution_id'] . '';
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
if ($row = mysql_fetch_assoc($result)) {
$institution_id = $row['institution_id'];
} else {
$institution_id = 0;
}
} else {
$institution_id = 0;
}
$query = sprintf('insert into operator (operator_code, full_name, phone_number, email_address, institution_id, registered) values (SUBSTRING(UUID(),1,6), "%s", "%s", "%s", %d, NOW())',
mysql_real_escape_string( $_POST['full_name']),
mysql_real_escape_string( $_POST['phone_number']),
mysql_real_escape_string( $_POST['email_address']),
$institution_id);
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
$operator_id = mysql_insert_id();
$query = 'SELECT operator_code FROM operator WHERE operator_id="' . $operator_id . '"';
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
if ($row = mysql_fetch_assoc($result)) {
$operator_code = $row['operator_code'];
} else {
die('Operator not inserted');
}
if ($_POST['email_back']=='Notify') {
$headers = 'From: [email protected]' . "\r\n";
$email = $_POST['email_address'];
$text = '';
$text .= 'An operator code has been created for you be the ANZSNM software quality assurance website. ' . "\r\n";
$text .= 'Your operator code is ' . $operator_code . "\r\n";
$text .= 'You can use your code to anonymously participate in software audits at http://apps.anzsnm.org.au/sqa/' . "\r\n";
$text .= ''. "\r\n";
$text .= 'This is an automated alert. Inform the sender if this was sent in error.'. "\r\n";
if (! mail($email,'ANZSNM SQA Operator Code',$text,$headers)) die("Could not send email");
}
setcookie ( 'operator_code', $operator_code, time()+60*60*24*30);
require('checked_in.php');
return;
?>