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 ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
37 $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 = MXCHANGE_OPEN("check-updates2.php");
48 if (empty($response[0]) && empty($response[1]) && empty($response[2]))
51 $response = array("", "", "");
55 // Analyse header for response code
56 if (ereg("200 OK", $response[0]))
60 foreach($response as $k=>$v)
65 // Header ends here (+1)
70 for($i = $pos; $i < count($response); $i++)
72 $response2[] = trim($response[$i]);
74 $response = $response2; unset($response2);
77 // Which is the latest version on server?
79 'version' => str_replace("\n", "", $response[0]),
80 'changed' => str_replace("\n", "", $response[1])
83 // Array for available patches
90 if (($response[2] != "[EOF]") && ($ONLINE['version'] == FULL_VERSION))
92 // We have found new patches (newer than FULL_VERSION)
93 $max = str_replace("\n", "", $response[sizeof($response) - 2]); $TOTAL_SIZE = "0";
95 // Maximum of available pacthes extracted (above). Now we can get all informations
96 for ($idx = 0; $idx < $max; $idx++)
98 // List only newer patches
99 $TEST = substr(str_replace("\n", "", $response[$idx * 5 + 2]), 0, strlen($_CONFIG['patch_level']));
101 // I have removed the addional test for the stored timemark in database or you cannot find
102 // new updates on my server when you haven't installed it before I upload a patch... :-(
103 if (bigintval($TEST) > bigintval($_CONFIG['patch_level']))
105 // Copy every data from the response array
106 $PATCHES['fname'][] = str_replace("\n", "", $response[$idx * 5 + 2]);
107 $PATCHES['fsize'][] = str_replace("\n", "", $response[$idx * 5 + 3]);
108 $PATCHES['ctime'][] = str_replace("\n", "", $response[$idx * 5 + 4]);
109 switch (GET_LANGUAGE())
111 case "de": $PATCHES['descr'][] = str_replace("\n", "", $response[$idx * 5 + 5]); break; // Load german description
112 default : $PATCHES['descr'][] = str_replace("\n", "", $response[$idx * 5 + 6]); break; // Load english description as default
115 // Add patch's size to total
116 $TOTAL_SIZE += $PATCHES['fsize'][$idx];
119 array_pk_sort($PATCHES, array("ctime", "fname"));
122 $ONLINE['code'] = "200 OK";
127 // 404 / 403 error from server
128 $ONLINE['code'] = $response[0];
132 OPEN_TABLE("100%", "admin_content", "center");
133 // Is a newer version available?
134 if (empty($ONLINE['version']))
137 LOAD_TEMPLATE("admin_settings_saved", false, "<FONT class=\"admin_failed\">".ADMIN_CANNOT_CHECK_VERSION." (".$ONLINE['code'].")</FONT>");
139 elseif ($ONLINE['version'] != FULL_VERSION)
141 // New full-version available (all previous released patches are included in this version!)
142 define('__ONLINE_VERSION', $ONLINE['version']);
143 define('__ONLINE_CHANGE' , MAKE_DATETIME($ONLINE['changed'], "2"));
146 LOAD_TEMPLATE("admin_update_download");
148 elseif (sizeof($PATCHES['fname']) > 0)
150 // Some patches are available
151 $OUT = ""; $SW = "2";
152 foreach ($PATCHES['fname'] as $idx=>$file)
154 $SIZE = TRANSLATE_COMMA(round($PATCHES['fsize'][$idx]/102.4)/10);
157 'patch_url' => SERVER_URL."/patches/".$file,
158 'patch_title' => str_replace("_", " ", str_replace(".zip", "", $file)),
159 'patch_ctime' => MAKE_DATETIME($PATCHES['ctime'][$idx], "2"),
160 'patch_size' => $SIZE,
161 'patch_desc' => COMPILE_CODE($PATCHES['descr'][$idx]),
163 // Evaluate descrition code
164 $eval = "\$content['patch_desc'] = \"".$content['patch_desc']."\";";
167 // Load template, switch color and count total size up
168 $OUT .= LOAD_TEMPLATE("admin_patches_row", true, $content);
171 define('__PATCH_ROWS', $OUT);
174 define('__TOTAL_SIZE', TRANSLATE_COMMA($TOTAL_SIZE / 1024));
176 // Load main template
177 LOAD_TEMPLATE("admin_patches");
181 // You have the latest version!
182 LOAD_TEMPLATE("admin_settings_saved", false, NO_UPDATES_AVAILABLE);