2 /************************************************************************
3 * MXChange v0.2.1 Start: 01/16/2004 *
4 * ================ Last change: 05/14/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-updates.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Check for updates *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Prueft nach Updates *
12 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be useful, *
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
26 * GNU General Public License for more details. *
28 * You should have received a copy of the GNU General Public License *
29 * along with this program; if not, write to the Free Software *
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
32 ************************************************************************/
34 // Some security stuff...
35 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
36 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
40 // Add description as navigation point
41 ADD_DESCR("admin", basename(__FILE__));
44 $ONLINE['code'] = "???";
46 // Get response from our server in an array
47 $response = GET_URL("check-updates3.php");
49 if (empty($response[0]) && empty($response[1]) && empty($response[2]) && empty($response[3])) {
51 $response = array("", "", "");
53 // Analyse header for response code
54 if (eregi("200 OK", $response[0])) {
57 foreach($response as $k => $v) {
60 // Header ends here (+1)
66 for($i = $pos; $i < count($response); $i++) {
67 $response2[] = trim($response[$i]);
69 $response = $response2; unset($response2);
72 // Which is the latest version on server?
74 'version' => str_replace("\n", "", $response[0]),
75 'changed' => str_replace("\n", "", $response[1]),
76 'revision' => str_replace("\n", "", $response[2]),
79 // Array for available patches
86 if (($response[3] != "[EOF]") && ($ONLINE['version'] == FULL_VERSION)) {
87 // We have found new patches (newer than FULL_VERSION)
88 $max = str_replace("\n", "", $response[sizeof($response) - 2]); $TOTAL_SIZE = 0;
90 // Maximum of available pacthes extracted (above). Now we can get all informations
91 for ($idx = 0; $idx < $max; $idx++) {
92 // List only newer patches
93 $TEST = substr(str_replace("\n", "", $response[$idx * 5 + 2]), 0, strlen($_CONFIG['patch_level']));
95 // I have removed the addional test for the stored timemark in database or you cannot find
96 // new updates on my server when you haven't installed it before I upload a patch... :-(
97 if (bigintval($TEST) > bigintval($_CONFIG['patch_level'])) {
98 // Copy every data from the response array
99 $PATCHES['fname'][] = str_replace("\n", "", $response[$idx * 5 + 2]);
100 $PATCHES['fsize'][] = str_replace("\n", "", $response[$idx * 5 + 3]);
101 $PATCHES['ctime'][] = str_replace("\n", "", $response[$idx * 5 + 4]);
102 switch (GET_LANGUAGE()) {
103 case "de": $PATCHES['descr'][] = str_replace("\n", "", $response[$idx * 5 + 5]); break; // Load german description
104 default : $PATCHES['descr'][] = str_replace("\n", "", $response[$idx * 5 + 6]); break; // Load english description as default
107 // Add patch's size to total
108 $TOTAL_SIZE += $PATCHES['fsize'][$idx];
112 array_pk_sort($PATCHES, array("ctime", "fname"));
115 $ONLINE['code'] = "200 OK";
118 // 404 / 403 error from server
119 $ONLINE['code'] = $response[0];
123 // Is a newer version available?
124 if (empty($ONLINE['version'])) {
126 LOAD_TEMPLATE("admin_settings_saved", false, "<FONT class=\"admin_failed\">".ADMIN_CANNOT_CHECK_VERSION." (".$ONLINE['code'].")</FONT>");
127 } elseif (($ONLINE['version'] != FULL_VERSION) || ($ONLINE['revision'] != CURR_SVN_REVISION)) {
128 // New full-version available (all previous released patches are included in this version!)
129 define('__ONLINE_VERSION', $ONLINE['version']);
130 define('__ONLINE_CHANGE' , MAKE_DATETIME($ONLINE['changed'], "2"));
131 define('__ONLINE_REVISION', $ONLINE['revision']);
134 LOAD_TEMPLATE("admin_update_download");
136 * DEACTIVATED ON 09/11/2008,02:47 AM
138 } elseif (sizeof($PATCHES['fname']) > 0) {
139 // Some patches are available
140 $OUT = ""; $SW = "2";
141 foreach ($PATCHES['fname'] as $idx => $file) {
142 $SIZE = TRANSLATE_COMMA(round($PATCHES['fsize'][$idx]/102.4)/10);
145 'patch_url' => SERVER_URL."/patches/".$file,
146 'patch_title' => str_replace("_", " ", str_replace(".zip", "", $file)),
147 'patch_ctime' => MAKE_DATETIME($PATCHES['ctime'][$idx], "2"),
148 'patch_size' => $SIZE,
149 'patch_desc' => COMPILE_CODE($PATCHES['descr'][$idx]),
151 // Evaluate descrition code
152 $eval = "\$content['patch_desc'] = \"".$content['patch_desc']."\";";
155 // Load template, switch color and count total size up
156 $OUT .= LOAD_TEMPLATE("admin_patches_row", true, $content);
159 define('__PATCH_ROWS', $OUT);
162 define('__TOTAL_SIZE', TRANSLATE_COMMA($TOTAL_SIZE / 1024));
164 // Load main template
165 LOAD_TEMPLATE("admin_patches");
168 // You have the latest version!
169 LOAD_TEMPLATE("admin_settings_saved", false, NO_UPDATES_AVAILABLE);