Even more rewrites/fixes from EL branch (please report any broken part after you...
[mailer.git] / inc / modules / admin / what-theme_check.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 03/22/2004 *
4  * ===================                          Last change: 12/13/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-extentions.php                              *
8  * -------------------------------------------------------------------- *
9  * Short description : Extension management                             *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Erweiterungen-Management                         *
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 // Normally we want the overview of all registered theme_check
49 $mode = 'overview';
50
51 // Get response from our server
52 $response = sendGetRequest('check-themes.php');
53
54 // Are theme_check found?
55 if (($response[count($response) - 1] == '[EOF]') && ($response[0] != '[EOF]')) {
56         // Ok, mark found and create the array
57         $themes = array(
58                 'fname'  => array(), // File names
59                 'fsize'  => array(), // File size
60                 'fctime' => array(), // File creation timestamp
61                 'infos'  => array(), // File informations (maybe loaded!)
62                 'ver'    => array(), // Version number
63                 'cver'   => array(), // Current version number
64         );
65
66         // Get count of theme_check for validation
67         $count = trim($response[count($response) - 2]);
68         foreach ($response as $idx => $value) {
69                 $value = str_replace("\n", '', $value); $ver = '';
70
71                 // Leave loop when data is invalid or EOF?
72                 if ((substr($value, 0, 6) == 'theme-') && (substr($value, -4) == '.zip')) {
73                         // Extract name and version
74                         $name = substr($value, 6, -4);
75                         $ver  = trim(substr($response[$idx + 3], 4));
76
77                         // Load version
78                         $cver = getThemeVersion($name);
79
80                         // Is the theme already installed or not?
81                         if (($ver != $cver) && ($cver != '?') && ($cver != '!')) {
82                                 // No, it isn't. So let's add this one!
83                                 $themes['fname'][]  = $name;
84                                 $themes['fsize'][]  = $response[$idx + 1];
85                                 $themes['fctime'][] = $response[$idx + 2];
86                                 $themes['ver'][]    = $ver;
87                                 $themes['cver'][]   = $cver;
88
89                                 // Extract language strings from reponse
90                                 $langDummy = explode('[nl]', $response[$idx + 4]);
91                                 $languages = array();
92                                 $themeInfo = getMessage('ADMIN_EXTENSION_NO_INFO_FOUND');
93
94                                 // Trim every data line
95                                 foreach ($langDummy as $k => $v) {
96                                         $v = trim($v);
97                                         if (substr($v, 3) == '') $v = '---';
98                                         $langDummy[$k] = $v;
99                                         if ($v == 'xx:xx') break;
100                                         $languages[] = $v;
101                                 } // END - foreach
102
103                                 // If language is found stop searching on matching line
104                                 foreach($languages as $search) {
105                                         if (substr($search, 0, 3) == (getLanguage().':')) { $themeInfo = substr($search, 3); break; }
106                                 } // END - foreach
107
108                                 // Add informations to array
109                                 $themes['infos'][] = $themeInfo;
110                         } // END - if
111                 } // END - if
112         } // END - foreach
113
114         // Ok, themes are on our server but maybe you have already installed them?
115         if (count($themes['fname']) > 0) {
116                 // Sort array (I missed ver and cver here)
117                 array_pk_sort($themes, array('cver', 'fname'), 0, 1);
118
119                 // Extensions where found which are not downloaded and installed
120                 $OUT = ''; $SW = 2; $totalSize = '0';
121                 foreach ($themes['fname'] as $idx => $name) {
122                         // Prepare data
123                         $content = array(
124                                 'sw'      => $SW,
125                                 'index'   => ($idx + 1),
126                                 'name'    => $name,
127                                 'created' => generateDateTime($themes['fctime'][$idx], 2),
128                                 'size'    => translateComma(round($themes['fsize'][$idx] / 1.024) / 1000),
129                                 'version' => $themes['ver'][$idx],
130                                 'current' => $themes['cver'][$idx],
131                                 'infos'   => $themes['infos'][$idx],
132                         );
133
134                         // Load row template
135                         $OUT .= loadTemplate('admin_list_theme_row', true, $content);
136
137                         // Add total size
138                         $totalSize += $themes['fsize'][$idx];
139
140                         // Switch color
141                         $SW = 3 - $SW;
142                 }
143                 $content['rows']   = $OUT;
144                 $content['total']  = count($themes['fname']);
145                 $content['kbytes'] = translateComma(round($totalSize / 1.024) / 1000);
146
147                 // Load template
148                 loadTemplate('admin_list_theme', false, $content);
149         } else {
150                 // All Themes are downloaded and installed
151                 loadTemplate('admin_theme_installed', false, $count);
152         }
153 } else {
154         // No theme where found
155         loadTemplate('admin_settings_saved', false, getMessage('ADMIN_THEME_NOTHING_FOUND'));
156 }
157
158 // [EOF]
159 ?>