A lot CSS classes rewritten, please update all your themes.
[mailer.git] / inc / modules / admin / what-updates.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 01/16/2004 *
4  * ===================                          Last change: 05/14/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-updates.php                                 *
8  * -------------------------------------------------------------------- *
9  * Short description : Check for updates                                *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Prueft nach Updates                              *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
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 - 2009 by Roland Haeder                           *
21  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
42         die();
43 } // END - if
44
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
47
48 // Init array
49 $ONLINE['code'] = '???';
50
51 // Get response from our server in an array
52 $response = sendGetRequest('check-updates3.php');
53
54 if (empty($response[0]) && empty($response[1]) && empty($response[2]) && empty($response[3])) {
55         // Error!
56         $response = array('', '', '');
57 } else {
58         // Analyse header for response code
59         if (isInStringIgnoreCase('200 OK', $response[0])) {
60                 // Found, kill header
61                 $pos = '0';
62                 foreach($response as $k => $v) {
63                         $v = trim($v);
64                         if (empty($v)) {
65                                 // Header ends here (+1)
66                                 $pos = $k + 1; break;
67                         }
68                 }
69
70                 $response2 = array();
71                 for($i = $pos; $i < count($response); $i++) {
72                         $response2[] = trim($response[$i]);
73                 }
74                 $response = $response2; unset($response2);
75                 unset($pos);
76
77                 // Which is the latest version on server?
78                 $ONLINE = array(
79                         'version'  => trim(str_replace("\n", '', $response[0])),
80                         'changed'  => trim(str_replace("\n", '', $response[1])),
81                         'revision' => trim(str_replace("\n", '', $response[2])),
82                         'code'     => '200 OK'
83                 );
84         } else {
85                 // 404 / 403 error from server
86                 $ONLINE['code'] = $response[0];
87         }
88 }
89
90 // Is a newer version available?
91 if (empty($ONLINE['version'])) {
92         // Disconnected?
93         loadTemplate('admin_settings_unsaved', false, '{--ADMIN_CANNOT_CHECK_VERSION--} (' . $ONLINE['code'] . ')');
94 } elseif (($ONLINE['version'] != getFullVersion()) || ($ONLINE['revision'] > getCurrSvnRevision())) {
95         // New full-version available (all previous released patches are included in this version!)
96         $ONLINE['changed'] = generateDateTime($ONLINE['changed'], 2);
97
98         // Load template
99         loadTemplate('admin_update_download', false, $ONLINE);
100 } elseif ($ONLINE['revision'] < getCurrSvnRevision()) {
101         // Installed revision is newer than on server
102         loadTemplate('admin_settings_saved', false, '{--ADMIN_LOCAL_REVISION_IS_NEWER_THAN_UPDATE--}');
103 } else {
104         // You have the latest version!
105         loadTemplate('admin_settings_saved', false, '{--ADMIN_NO_UPDATES_AVAILABLE--}');
106 }
107
108 // [EOF]
109 ?>