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 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2008 by Roland Haeder *
21 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
45 // Add description as navigation point
46 ADD_DESCR('admin', __FILE__);
49 $ONLINE['code'] = '???';
51 // Get response from our server in an array
52 $response = sendGetRequest('check-updates3.php');
54 if (empty($response[0]) && empty($response[1]) && empty($response[2]) && empty($response[3])) {
56 $response = array('', '', '');
58 // Analyse header for response code
59 if (eregi("200 OK", $response[0])) {
62 foreach($response as $k => $v) {
65 // Header ends here (+1)
71 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]),
81 'revision' => str_replace("\n", '', $response[2]),
84 // Array for available patches
91 if (($response[3] != "[EOF]") && ($ONLINE['version'] == constant('FULL_VERSION'))) {
92 // We have found new patches (newer than FULL_VERSION)
93 $max = str_replace("\n", '', $response[count($response) - 2]); $totalSize = 0;
95 // Maximum of available pacthes extracted (above). Now we can get all informations
96 for ($idx = 0; $idx < $max; $idx++) {
97 // List only newer patches
98 $TEST = substr(str_replace("\n", '', $response[$idx * 5 + 2]), 0, strlen(getConfig('patch_level')));
100 // I have removed the addional test for the stored timemark in database or you cannot find
101 // new updates on my server when you haven't installed it before I upload a patch... :-(
102 if (bigintval($TEST) > getConfig(('patch_level'))) {
103 // Copy every data from the response array
104 $PATCHES['fname'][] = str_replace("\n", '', $response[$idx * 5 + 2]);
105 $PATCHES['fsize'][] = str_replace("\n", '', $response[$idx * 5 + 3]);
106 $PATCHES['ctime'][] = str_replace("\n", '', $response[$idx * 5 + 4]);
107 switch (getLanguage()) {
108 case 'de': $PATCHES['descr'][] = str_replace("\n", '', $response[$idx * 5 + 5]); break; // Load german description
109 default : $PATCHES['descr'][] = str_replace("\n", '', $response[$idx * 5 + 6]); break; // Load english description as default
112 // Add patch's size to total
113 $totalSize += $PATCHES['fsize'][$idx];
117 array_pk_sort($PATCHES, array("ctime", "fname"));
120 $ONLINE['code'] = "200 OK";
123 // 404 / 403 error from server
124 $ONLINE['code'] = $response[0];
128 // Is a newer version available?
129 if (empty($ONLINE['version'])) {
131 LOAD_TEMPLATE('admin_settings_saved', false, "<div class=\"admin_failed\">{--ADMIN_CANNOT_CHECK_VERSION--} (".$ONLINE['code'].")</div>");
132 } elseif (($ONLINE['version'] != constant('FULL_VERSION')) || ($ONLINE['revision'] != constant('CURR_SVN_REVISION'))) {
133 // New full-version available (all previous released patches are included in this version!)
134 define('__ONLINE_VERSION', $ONLINE['version']);
135 define('__ONLINE_CHANGE' , generateDateTime($ONLINE['changed'], '2'));
136 define('__ONLINE_REVISION', $ONLINE['revision']);
139 LOAD_TEMPLATE("admin_update_download");
141 // You have the latest version!
142 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('NO_UPDATES_AVAILABLE'));