File indexing completed on 2025-01-18 09:27:06
0001 <?php
0002 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
0003
0004 $name = $_POST['name'];
0005 $workingGroup = $_POST['workingGroup'];
0006 $plotName = $_POST['plotName'];
0007 $description = $_POST['description'];
0008 $instructions = $_POST['instructions'];
0009
0010
0011 $files = $_FILES['plotFile'];
0012
0013
0014 $to = 'roark@jlab.org';
0015 $subject = 'New Plot Type Submission';
0016 $boundary = md5(uniqid(time()));
0017
0018
0019 $headers = "MIME-Version: 1.0\r\n";
0020 $headers .= "Content-Type: multipart/mixed; boundary=\"{$boundary}\"\r\n";
0021
0022
0023 $message = "--{$boundary}\r\n";
0024 $message .= "Content-Type: text/html; charset=UTF-8\r\n";
0025 $message .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
0026 $message .= "<p><strong>Name:</strong> $name</p>
0027 <p><strong>Working Group:</strong> $workingGroup</p>
0028 <p><strong>Plot Name:</strong> $plotName</p>
0029 <p><strong>Description:</strong> $description</p>
0030 <p><strong>Instructions:</strong> $instructions</p>\r\n";
0031 $message .= "--{$boundary}\r\n";
0032
0033
0034 for ($i = 0; $i < count($files['name']); $i++) {
0035 if ($files['error'][$i] == UPLOAD_ERR_OK) {
0036 $fileName = $files['name'][$i];
0037 $fileType = $files['type'][$i];
0038 $fileContent = chunk_split(base64_encode(file_get_contents($files['tmp_name'][$i])));
0039
0040 $message .= "Content-Type: {$fileType}; name=\"{$fileName}\"\r\n";
0041 $message .= "Content-Disposition: attachment; filename=\"{$fileName}\"\r\n";
0042 $message .= "Content-Transfer-Encoding: base64\r\n\r\n";
0043 $message .= "{$fileContent}\r\n";
0044 $message .= "--{$boundary}\r\n";
0045 }
0046 }
0047
0048
0049 if (mail($to, $subject, $message, $headers)) {
0050 echo json_encode(['status' => 'success', 'message' => 'Message has been sent']);
0051 } else {
0052 echo json_encode(['status' => 'error', 'message' => 'Message could not be sent']);
0053 }
0054 }
0055 ?>