Subversion Repositories web_pages

Rev

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

<?php
$config = json_decode(file_get_contents('config.json'), true);

function sanitize($data) {
  return htmlspecialchars(trim($data));
}

$requestor = sanitize($_POST['requestor'] ?? '');
$requestor_email = sanitize($_POST['requestor_email'] ?? '');
$workstation = sanitize($_POST['workstation'] ?? '');
$username = sanitize($_POST['username'] ?? '');
$remote = sanitize($_POST['remote_access'] ?? '');
$software = isset($_POST['software']) ? implode(", ", array_map('sanitize', $_POST['software'])) : '';
$notes = sanitize($_POST['notes'] ?? '');

$to = $config['mail']['to'];
$subject = $config['mail']['subject'];
$from = $config['mail']['from'];
$headers = "From: $from\r\nReply-To: $requestor_email\r\nContent-Type: text/plain; charset=UTF-8";

$body = "New Workstation Request Submitted:\n\n"
      . "Requestor: $requestor\n"
      . "Requestor Email: $requestor_email\n"
      . "Workstation Name: $workstation\n"
      . "User Name: $username\n"
      . "Remote Access: $remote\n"
      . "Software List: $software\n"
      . "Notes: $notes\n";
if (!mail($to, $subject, $body, $headers, "-f$from")) {
    header("Location: index.php?error=1");
    exit;
}
// Redirect to index.php with success message
header("Location: index.php?success=1");
exit;
?>

Generated by GNU Enscript 1.6.5.90.