2 /************************************************************************
\r
3 * MXChange v0.2.1 Start: 01/16/2004 *
\r
4 * ================ Last change: 05/14/2004 *
\r
6 * -------------------------------------------------------------------- *
\r
7 * File : what-updates.php *
\r
8 * -------------------------------------------------------------------- *
\r
9 * Short description : Check for updates *
\r
10 * -------------------------------------------------------------------- *
\r
11 * Kurzbeschreibung : Prueft nach Updates *
\r
12 * -------------------------------------------------------------------- *
\r
14 * -------------------------------------------------------------------- *
\r
15 * Copyright (c) 2003 - 2007 by Roland Haeder *
\r
16 * For more information visit: http://www.mxchange.org *
\r
18 * This program is free software; you can redistribute it and/or modify *
\r
19 * it under the terms of the GNU General Public License as published by *
\r
20 * the Free Software Foundation; either version 2 of the License, or *
\r
21 * (at your option) any later version. *
\r
23 * This program is distributed in the hope that it will be useful, *
\r
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
\r
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
\r
26 * GNU General Public License for more details. *
\r
28 * You should have received a copy of the GNU General Public License *
\r
29 * along with this program; if not, write to the Free Software *
\r
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
\r
31 * MA 02110-1301 USA *
\r
32 ************************************************************************/
\r
34 // Some security stuff...
\r
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
\r
37 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";
\r
40 // Add description as navigation point
\r
41 ADD_DESCR("admin", basename(__FILE__));
\r
44 $ONLINE['code'] = "???";
\r
46 // Get response from our server in an array
\r
47 $response = MXCHANGE_OPEN("check-updates2.php");
\r
48 if (empty($response[0]) && empty($response[1]) && empty($response[2]))
\r
51 $response = array("", "", "");
\r
55 // Analyse header for response code
\r
56 if (ereg("200 OK", $response[0]))
\r
58 // Found, kill header
\r
60 foreach($response as $k=>$v)
\r
65 // Header ends here (+1)
\r
66 $pos = $k + 1; break;
\r
69 $response2 = array();
\r
70 for($i = $pos; $i < count($response); $i++)
\r
72 $response2[] = trim($response[$i]);
\r
74 $response = $response2; unset($response2);
\r
77 // Which is the latest version on server?
\r
79 'version' => str_replace("\n", "", $response[0]),
\r
80 'changed' => str_replace("\n", "", $response[1])
\r
83 // Array for available patches
\r
90 if (($response[2] != "[EOF]") && ($ONLINE['version'] == FULL_VERSION))
\r
92 // We have found new patches (newer than FULL_VERSION)
\r
93 $max = str_replace("\n", "", $response[sizeof($response) - 2]); $TOTAL_SIZE = "0";
\r
95 // Maximum of available pacthes extracted (above). Now we can get all informations
\r
96 for ($idx = 0; $idx < $max; $idx++)
\r
98 // List only newer patches
\r
99 $TEST = substr(str_replace("\n", "", $response[$idx * 5 + 2]), 0, strlen($CONFIG['patch_level']));
\r
101 // I have removed the addional test for the stored timemark in database or you cannot find
\r
102 // new updates on my server when you haven't installed it before I upload a patch... :-(
\r
103 if (bigintval($TEST) > bigintval($CONFIG['patch_level']))
\r
105 // Copy every data from the response array
\r
106 $PATCHES['fname'][] = str_replace("\n", "", $response[$idx * 5 + 2]);
\r
107 $PATCHES['fsize'][] = str_replace("\n", "", $response[$idx * 5 + 3]);
\r
108 $PATCHES['ctime'][] = str_replace("\n", "", $response[$idx * 5 + 4]);
\r
109 switch (GET_LANGUAGE())
\r
111 case "de": $PATCHES['descr'][] = str_replace("\n", "", $response[$idx * 5 + 5]); break; // Load german description
\r
112 default : $PATCHES['descr'][] = str_replace("\n", "", $response[$idx * 5 + 6]); break; // Load english description as default
\r
115 // Add patch's size to total
\r
116 $TOTAL_SIZE += $PATCHES['fsize'][$idx];
\r
119 array_pk_sort($PATCHES, array("ctime", "fname"));
\r
122 $ONLINE['code'] = "200 OK";
\r
127 // 404 / 403 error from server
\r
128 $ONLINE['code'] = $response[0];
\r
132 OPEN_TABLE("100%", "admin_content", "center");
\r
133 // Is a newer version available?
\r
134 if (empty($ONLINE['version']))
\r
137 LOAD_TEMPLATE("admin_settings_saved", false, "<FONT class=\"admin_failed\">".ADMIN_CANNOT_CHECK_VERSION." (".$ONLINE['code'].")</FONT>");
\r
139 elseif ($ONLINE['version'] != FULL_VERSION)
\r
141 // New full-version available (all previous released patches are included in this version!)
\r
142 define('__ONLINE_VERSION', $ONLINE['version']);
\r
143 define('__ONLINE_CHANGE' , MAKE_DATETIME($ONLINE['changed'], "2"));
\r
146 LOAD_TEMPLATE("admin_update_download");
\r
148 elseif (sizeof($PATCHES['fname']) > 0)
\r
150 // Some patches are available
\r
151 $OUT = ""; $SW = "2";
\r
152 foreach ($PATCHES['fname'] as $idx=>$file)
\r
154 $SIZE = TRANSLATE_COMMA(round($PATCHES['fsize'][$idx]/102.4)/10);
\r
157 'patch_url' => SERVER_URL."/patches/".$file,
\r
158 'patch_title' => str_replace("_", " ", str_replace(".zip", "", $file)),
\r
159 'patch_ctime' => MAKE_DATETIME($PATCHES['ctime'][$idx], "2"),
\r
160 'patch_size' => $SIZE,
\r
161 'patch_desc' => COMPILE_CODE($PATCHES['descr'][$idx]),
\r
163 // Evaluate descrition code
\r
164 $eval = "\$content['patch_desc'] = \"".$content['patch_desc']."\";";
\r
167 // Load template, switch color and count total size up
\r
168 $OUT .= LOAD_TEMPLATE("admin_patches_row", true, $content);
\r
171 define('__PATCH_ROWS', $OUT);
\r
174 define('__TOTAL_SIZE', TRANSLATE_COMMA($TOTAL_SIZE / 1024));
\r
176 // Load main template
\r
177 LOAD_TEMPLATE("admin_patches");
\r
181 // You have the latest version!
\r
182 LOAD_TEMPLATE("admin_settings_saved", false, NO_UPDATES_AVAILABLE);
\r