added web pages
[debian/openrocket] / web / html / actions / reportbug.php
1 <?
2 $mailaddr = "openrocket-bugs@lists.sourceforge.net";
3 //$mailaddr = "sampo.niskanen@gmail.com";
4
5 $version = $_POST["version"];
6 $content = $_POST["content"];
7
8
9 // Parse headers
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;
15            }
16        }
17        return $headers;
18     }
19 }
20
21 $headers = "\n\n\n";
22 foreach (getallheaders() as $header => $value) {
23         $headers = $headers . "$header: $value\n";
24 }
25
26 // Set HTTP content-type header
27 header("Content-type: text/plain; charset=utf-8");
28
29
30 // Check for valid submission
31 if (preg_match("/^[a-zA-Z0-9. -]{1,30}$/", $version) &&
32     strlen($content) > 0) {
33
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")) {
38         
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";
43         
44     } else {
45         
46         // Sending mail failed
47         header("HTTP/1.0 503 Service Unavailable");
48         echo "503 Service Unavailable:  Unable to send bug report.";
49         
50     }
51
52 } else {
53         
54         // Bad request
55         header("HTTP/1.0 400 Bad Request");
56         echo "400 Bad Request:  Illegal request.\n";
57         
58 }
59
60 ?>