plugins/SpecialAdmin.php
changeset 329 0437a7cf1acc
parent 328 dc838fd61a06
child 334 c72b545f1304
--- a/plugins/SpecialAdmin.php	Thu Dec 20 22:23:07 2007 -0500
+++ b/plugins/SpecialAdmin.php	Fri Dec 21 18:21:20 2007 -0500
@@ -57,6 +57,38 @@
     return;
   }
   
+  if ( $paths->getParam(0) == 'updates.xml' )
+  {
+    require_once(ENANO_ROOT . '/includes/http.php');
+    $req = new Request_HTTP('germantown.enanocms.org', '/meta/updates.xml');
+    $response = $req->get_response_body();
+    header('Content-type: application/xml');
+    if ( $req->response_code != HTTP_OK )
+    {
+      // Error in response
+      echo '<enano><latest><error><![CDATA[
+Did not properly receive response from server. Response code: ' . $req->response_code . ' ' . $req->response_string . '
+]]></error></latest></enano>';
+    }
+    else
+    {
+      // Retrieve first update
+      $first_update = preg_match('/<release tag="([^"]+)" version="([^"]+)" (codename="([^"]+)" )?relnotes="([^"]+)" ?\/>/', $response, $match);
+      if ( !$first_update )
+      {
+        echo '<enano><latest><error><![CDATA[
+Received invalid XML response.
+]]></error></latest></enano>';
+      }
+      if ( version_compare(enano_version(true), $match[2], '<') )
+      {
+        $response = str_replace_once('</latest>', "  <haveupdates />\n  </latest>", $response);
+      }
+      echo $response;
+    }
+    return;
+  }
+  
   // Basic information
   echo RenderMan::render(
 '== Welcome to Runt, the Enano administration panel. ==
@@ -78,6 +110,10 @@
     echo '<div class="error-box"><b>NOTE:</b> It appears that your install.php and/or schema.sql files still exist. It is HIGHLY RECOMMENDED that you delete or rename these files, to prevent getting your server hacked.</div>';
   }
   
+  echo '<h3>Check for updates</h3>';
+  echo '<p>Periodically, new releases of Enano will be made available. Click the button below to check for updates to Enano. During this process, a request will be sent to the Enano CMS server (germantown.enanocms.org) over HTTP. No information about your Enano installation will be transmitted.</p>';
+  echo '<div id="update_check_container"><input type="button" onclick="ajaxUpdateCheck(this.parentNode.id);" value="Check for updates" /></div>';
+  
   // Inactive users
   $q = $db->sql_query('SELECT * FROM '.table_prefix.'logs WHERE log_type=\'admin\' AND action=\'activ_req\';');
   if($q)