Obsolete update check replaced with SVN revision
[mailer.git] / inc / modules / admin / what-updates.php
index db13edb06cd54e60ddb2c17758e5b746558c9845..6e1e23f8af06e604330ced5951a5d3d132303a66 100644 (file)
  ************************************************************************/
 
 // Some security stuff...
-if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
-{
+if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN())) {
        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
        require($INC);
 }
+
 // Add description as navigation point
 ADD_DESCR("admin", basename(__FILE__));
 
@@ -44,31 +44,26 @@ ADD_DESCR("admin", basename(__FILE__));
 $ONLINE['code'] = "???";
 
 // Get response from our server in an array
-$response = MXCHANGE_OPEN("check-updates2.php");
-if (empty($response[0]) && empty($response[1]) && empty($response[2]))
-{
+$response = GET_URL("check-updates3.php");
+
+if (empty($response[0]) && empty($response[1]) && empty($response[2]) && empty($response[3])) {
        // Error!
        $response = array("", "", "");
-}
- else
-{
+} else {
        // Analyse header for response code
-       if (ereg("200 OK", $response[0]))
-       {
+       if (eregi("200 OK", $response[0])) {
                // Found, kill header
                $pos = 0;
-               foreach($response as $k=>$v)
-               {
+               foreach($response as $k => $v) {
                        $v = trim($v);
-                       if (empty($v))
-                       {
+                       if (empty($v)) {
                                // Header ends here (+1)
                                $pos = $k + 1; break;
                        }
                }
+
                $response2 = array();
-               for($i = $pos; $i < count($response); $i++)
-               {
+               for($i = $pos; $i < count($response); $i++) {
                        $response2[] = trim($response[$i]);
                }
                $response = $response2; unset($response2);
@@ -76,8 +71,9 @@ if (empty($response[0]) && empty($response[1]) && empty($response[2]))
 
                // Which is the latest version on server?
                $ONLINE = array(
-                       'version' => str_replace("\n", "", $response[0]),
-                       'changed' => str_replace("\n", "", $response[1])
+                       'version'  => str_replace("\n", "", $response[0]),
+                       'changed'  => str_replace("\n", "", $response[1]),
+                       'revision' => str_replace("\n", "", $response[2]),
                );
 
                // Array for available patches
@@ -87,27 +83,23 @@ if (empty($response[0]) && empty($response[1]) && empty($response[2]))
                        'ctime' => array()
                );
 
-               if (($response[2] != "[EOF]") && ($ONLINE['version'] == FULL_VERSION))
-               {
+               if (($response[3] != "[EOF]") && ($ONLINE['version'] == FULL_VERSION)) {
                        // We have found new patches (newer than FULL_VERSION)
                        $max = str_replace("\n", "", $response[sizeof($response) - 2]); $TOTAL_SIZE = "0";
 
                        // Maximum of available pacthes extracted (above). Now we can get all informations
-                       for ($idx = 0; $idx < $max; $idx++)
-                       {
+                       for ($idx = 0; $idx < $max; $idx++) {
                                // List only newer patches
-                               $TEST = substr(str_replace("\n", "", $response[$idx * 5 + 2]), 0, strlen($CONFIG['patch_level']));
+                               $TEST = substr(str_replace("\n", "", $response[$idx * 5 + 2]), 0, strlen($_CONFIG['patch_level']));
 
                                // I have removed the addional test for the stored timemark in database or you cannot find
                                // new updates on my server when you haven't installed it before I upload a patch... :-(
-                               if (bigintval($TEST) > bigintval($CONFIG['patch_level']))
-                               {
+                               if (bigintval($TEST) > bigintval($_CONFIG['patch_level'])) {
                                        // Copy every data from the response array
                                        $PATCHES['fname'][] = str_replace("\n", "", $response[$idx * 5 + 2]);
                                        $PATCHES['fsize'][] = str_replace("\n", "", $response[$idx * 5 + 3]);
                                        $PATCHES['ctime'][] = str_replace("\n", "", $response[$idx * 5 + 4]);
-                                       switch (GET_LANGUAGE())
-                                       {
+                                       switch (GET_LANGUAGE()) {
                                                case "de": $PATCHES['descr'][] = str_replace("\n", "", $response[$idx * 5 + 5]); break; // Load german description
                                                default  : $PATCHES['descr'][] = str_replace("\n", "", $response[$idx * 5 + 6]); break; // Load english description as default
                                        }
@@ -116,41 +108,34 @@ if (empty($response[0]) && empty($response[1]) && empty($response[2]))
                                        $TOTAL_SIZE += $PATCHES['fsize'][$idx];
                                }
                        }
+
                        array_pk_sort($PATCHES, array("ctime", "fname"));
 
                        // All done here!
                        $ONLINE['code'] = "200 OK";
                }
-       }
-        else
-       {
+       } else {
                // 404 / 403 error from server
                $ONLINE['code'] = $response[0];
        }
 }
 
-OPEN_TABLE("100%", "admin_content", "center");
 // Is a newer version available?
-if (empty($ONLINE['version']))
-{
+if (empty($ONLINE['version'])) {
        // Disconnected?
        LOAD_TEMPLATE("admin_settings_saved", false, "<FONT class=\"admin_failed\">".ADMIN_CANNOT_CHECK_VERSION." (".$ONLINE['code'].")</FONT>");
-}
- elseif ($ONLINE['version'] != FULL_VERSION)
-{
+} elseif (($ONLINE['version'] != FULL_VERSION) || ($ONLINE['revision'] != CURR_SVN_REVISION)) {
        // New full-version available (all previous released patches are included in this version!)
        define('__ONLINE_VERSION', $ONLINE['version']);
        define('__ONLINE_CHANGE' , MAKE_DATETIME($ONLINE['changed'], "2"));
+       define('__ONLINE_REVISION', $ONLINE['revision']);
 
        // Load template
        LOAD_TEMPLATE("admin_update_download");
-}
- elseif (sizeof($PATCHES['fname']) > 0)
-{
+} elseif (sizeof($PATCHES['fname']) > 0) {
        // Some patches are available
        $OUT = ""; $SW = "2";
-       foreach ($PATCHES['fname'] as $idx=>$file)
-       {
+       foreach ($PATCHES['fname'] as $idx => $file) {
                $SIZE = TRANSLATE_COMMA(round($PATCHES['fsize'][$idx]/102.4)/10);
                $content = array(
                        'sw'          => $SW,
@@ -175,12 +160,10 @@ if (empty($ONLINE['version']))
 
        // Load main template
        LOAD_TEMPLATE("admin_patches");
-}
- else
-{
+} else {
        // You have the latest version!
        LOAD_TEMPLATE("admin_settings_saved", false, NO_UPDATES_AVAILABLE);
 }
-CLOSE_TABLE();
+
 //
 ?>