2 $mailaddr = "openrocket-bugs@lists.sourceforge.net";
3 //$mailaddr = "sampo.niskanen@gmail.com";
5 $version = $_POST["version"];
6 $content = $_POST["content"];
10 if (!function_exists('getallheaders')) {
11 function getallheaders() {
12 foreach ($_SERVER as $name => $value) {
13 if (substr($name, 0, 5) == 'HTTP_') {
14 $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
22 foreach (getallheaders() as $header => $value) {
23 $headers = $headers . "$header: $value\n";
26 // Set HTTP content-type header
27 header("Content-type: text/plain; charset=utf-8");
30 // Check for valid submission
31 if (preg_match("/^[a-zA-Z0-9. -]{1,30}$/", $version) &&
32 strlen($content) > 0) {
34 $subject = date("Y-m-d H:i:s") . " Automatic bug report for OpenRocket " . $version;
35 if (mail($mailaddr, $subject, $content . $headers,
36 "From: Automatic Bug Reports <".$mailaddr.">\r\n".
37 "Content-Type: text/plain; charset=utf-8")) {
39 // Success - OpenRocket recognizes status code 202
40 header("HTTP/1.0 202 Accepted");
41 echo "202 Accepted: Bug report successfully sent.";
42 // echo "\nContent:\n$content";
46 // Sending mail failed
47 header("HTTP/1.0 503 Service Unavailable");
48 echo "503 Service Unavailable: Unable to send bug report.";
55 header("HTTP/1.0 400 Bad Request");
56 echo "400 Bad Request: Illegal request.\n";