2 $logfiles = "/home/groups/o/op/openrocket/persistent/logs/access-";
5 // getallheaders method
6 if (!function_exists('getallheaders')) {
7 function getallheaders() {
8 foreach ($_SERVER as $name => $value) {
9 if (substr($name, 0, 5) == 'HTTP_') {
10 $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
18 // Parse + validate headers
26 foreach (getallheaders() as $header => $value) {
27 if (preg_match("/^[a-zA-Z0-9 !$%&()*+,.\\/:=?@_~-]{1,40}$/", $value)) {
28 $h = strtolower($header);
29 if ($h == 'x-openrocket-version') {
31 } else if ($h == 'x-openrocket-id') {
33 } else if ($h == 'x-openrocket-os') {
35 } else if ($h == 'x-openrocket-java') {
37 } else if ($h == 'x-openrocket-country') {
39 } else if ($h == 'x-openrocket-cpus') {
41 } else if ($h == 'x-openrocket-locale') {
48 if ((strlen($orversion) > 0 || strlen($orid) > 0 || strlen($oros) > 0
49 || strlen($orjava) > 0 || strlen($orcountry) > 0
50 || strlen($orcores) > 0 || strlen($orlocale) > 0) &&
51 (strlen($orversion) < 20 && strlen($orid) < 50 && strlen($oros) < 50
52 && strlen($orjava) < 50 && strlen($orcountry) < 50)
53 && strlen($orcores) < 10 && strlen($orlocale) < 20) {
55 $file = $logfiles . gmdate("Y-m");
56 $line = gmdate("Y-m-d H:i:s") . ";" . $orid . ";" . $orversion .
57 ";" . $oros . ";" . $orjava . ";" . $orcountry . ";" . $orcores .
58 ";" . $orlocale . "\n";
60 $fp = fopen($file, 'a');
68 // Set HTTP content-type header
69 // No charset allowed for 0.9.4
70 //header("Content-type: text/plain; charset=utf-8");
71 header("Content-type: text/plain");
74 * Currently all old versions are handled manually.
75 * Update checking was introduced in OpenRocket 0.9.4
77 * We ignore "pre" versions, they are handled exacly like
78 * their non-pre counterparts.
80 $version = $_GET["version"];
86 if (preg_match("/^1\.1\.8$/", $version)) {
87 $updates = "Version: " . $unstable . "\n" .
88 "6: Additional template printing\n" .
89 "5: Geodetic computations\n" .
92 } else if (preg_match("/^1\.1\.7$/", $version)) {
93 $updates = "Version: " . $unstable . "\n" .
94 "6: Additional template printing\n" .
95 "5: Geodetic computations\n" .
98 } else if (preg_match("/^1\.1\.6$/", $version)) {
99 $updates = "Version: " . $unstable . "\n" .
100 "8: Automatic rocket design optimization\n" .
101 "6: Additional template printing\n" .
102 "5: Geodetic computations\n" .
104 } else if (preg_match("/^1\.1\.5$/", $version)) {
105 $updates = "Version: " . $unstable . "\n" .
106 "8: Automatic rocket design optimization\n" .
107 "6: Initial localization support\n" .
108 "6: Additional template printing\n" .
109 "5: Geodetic computations\n" .
110 "5: Scaling support\n" .
113 } else if (preg_match("/^1\.1\.4$/", $version)) {
114 $updates = "Version: " . $unstable . "\n" .
115 "8: Automatic rocket design optimization\n" .
116 "6: Initial localization support\n" .
117 "5: Fixes to printing system\n" .
118 "5: Scaling support\n" .
120 } else if (preg_match("/^1\.1\.3$/", $version)) {
121 $updates = "Version: " . $unstable . "\n" .
122 "8: Automatic rocket design optimization\n" .
123 "7: Initial printing support\n" .
124 "6: Initial localization support\n" .
125 "5: Scaling support\n" .
128 } else if (preg_match("/^1\.1\.[12]$/", $version)) {
129 $updates = "Version: " . $unstable . "\n" .
130 "8: Automatic rocket design optimization\n" .
131 "6: Initial printing support\n" .
132 "5: Initial drag-and-drop support\n" .
133 "5: Initial localization support\n" .
134 "5: Scaling support\n" .
137 } else if (preg_match("/^1\.1\.0$/", $version)) {
138 $updates = "Version: " . $unstable . "\n" .
139 "8: Automatic rocket design optimization\n" .
140 "6: Initial printing support\n" .
141 "6: Initial localization support\n" .
142 "6: Enhanced motor selection\n" .
143 "5: Rewritten simulation code\n" .
144 "5: Drag-and-drop support\n" .
147 } else if (preg_match("/^0\.9\.6/", $version)) {
148 $updates = "Version: " . $stable . "\n" .
149 "6: Hundreds of new thrustcurves\n" .
152 } else if (preg_match("/^0\.9\.[45]/", $version)) {
153 $updates = "Version: " . $stable . "\n" .
154 "7: Hundreds of new thrustcurves\n" .
155 "6: Aerodynamic computation updates\n" .
156 "5: Numerous bug fixes" .
161 if (strlen($updates) == 0) {
163 // No updates available
164 header("HTTP/1.0 204 No Content");
168 header("HTTP/1.0 200 OK");