154 |
154 |
155 function acphome_process_updates() |
155 function acphome_process_updates() |
156 { |
156 { |
157 require_once(ENANO_ROOT . '/includes/http.php'); |
157 require_once(ENANO_ROOT . '/includes/http.php'); |
158 |
158 |
159 $req = new Request_HTTP('ktulu.enanocms.org', '/meta/updates.xml'); |
159 try |
160 $response = $req->get_response_body(); |
160 { |
161 header('Content-type: application/xml'); |
161 $req = new Request_HTTP('ktulu.enanocms.org', '/meta/updates.xml'); |
|
162 $response = $req->get_response_body(); |
|
163 header('Content-type: application/xml'); |
|
164 } |
|
165 catch ( Exception $e ) |
|
166 { |
|
167 header('Content-type: application/xml'); |
|
168 echo '<enano><error><![CDATA[ |
|
169 Cannot connect to server: ' . $e->getMessage() . ' |
|
170 ]]></error></enano>'; |
|
171 return true; |
|
172 } |
162 if ( $req->response_code != HTTP_OK ) |
173 if ( $req->response_code != HTTP_OK ) |
163 { |
174 { |
164 // Error in response |
175 // Error in response |
165 echo '<enano><latest><error><![CDATA[ |
176 echo '<enano><error><![CDATA[ |
166 Did not properly receive response from server. Response code: ' . $req->response_code . ' ' . $req->response_string . ' |
177 Did not properly receive response from server. Response code: ' . $req->response_code . ' ' . $req->response_string . ' |
167 ]]></error></latest></enano>'; |
178 ]]></error></enano>'; |
168 } |
179 } |
169 else |
180 else |
170 { |
181 { |
171 // Retrieve first update |
182 // Retrieve first update |
172 $first_update = preg_match('/<release tag="([^"]+)" version="([^"]+)" (codename="([^"]+)" )?relnotes="([^"]+)" ?\/>/', $response, $match); |
183 $first_update = preg_match('/<release tag="([^"]+)" version="([^"]+)" (codename="([^"]+)" )?relnotes="([^"]+)" ?\/>/', $response, $match); |
173 if ( !$first_update ) |
184 if ( !$first_update ) |
174 { |
185 { |
175 echo '<enano><latest><error><![CDATA[ |
186 echo '<enano><error><![CDATA[ |
176 Received invalid XML response. |
187 Received invalid XML response. |
177 ]]></error></latest></enano>'; |
188 ]]></error></enano>'; |
178 } |
189 } |
179 else |
190 else |
180 { |
191 { |
181 if ( version_compare(enano_version(true), $match[2], '<') ) |
192 if ( version_compare(enano_version(true), $match[2], '<') ) |
182 { |
193 { |