Subversion Repositories web_pages

Rev

Rev 10 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10 randell 1
<?php
2
$config = json_decode(file_get_contents('config.json'), true);
3
 
4
function sanitize($data) {
5
  return htmlspecialchars(trim($data));
6
}
7
 
8
$requestor = sanitize($_POST['requestor'] ?? '');
9
$requestor_email = sanitize($_POST['requestor_email'] ?? '');
10
$workstation = sanitize($_POST['workstation'] ?? '');
11
$username = sanitize($_POST['username'] ?? '');
12
$remote = sanitize($_POST['remote_access'] ?? '');
13
$software = isset($_POST['software']) ? implode(", ", array_map('sanitize', $_POST['software'])) : '';
14
$notes = sanitize($_POST['notes'] ?? '');
15
 
16
$to = $config['mail']['to'];
17
$subject = $config['mail']['subject'];
18
$from = $config['mail']['from'];
19
$headers = "From: $from\r\nReply-To: $requestor_email\r\nContent-Type: text/plain; charset=UTF-8";
20
 
21
$body = "New Workstation Request Submitted:\n\n"
22
      . "Requestor: $requestor\n"
23
      . "Requestor Email: $requestor_email\n"
24
      . "Workstation Name: $workstation\n"
25
      . "User Name: $username\n"
26
      . "Remote Access: $remote\n"
27
      . "Software List: $software\n"
28
      . "Notes: $notes\n";
29
if (!mail($to, $subject, $body, $headers, "-f$from")) {
30
    header("Location: index.php?error=1");
31
    exit;
32
}
33
// Redirect to index.php with success message
34
header("Location: index.php?success=1");
35
exit;
36
?>