019a1bf6baf1ac4895c8f1ffdce68ef1184b32e1
[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  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
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.                                  *
27  *                                                                      *
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.                         *
32  *                                                                      *
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,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!isAdmin())) {
41         die();
42 } // END - if
43
44 // Add description as navigation point
45 addMenuDescription('admin', __FILE__);
46
47 // Normally we want the overview of all registered theme_check
48 $mode = 'overview';
49
50 // Get response from our server
51 $response = sendGetRequest('check-themes.php');
52
53 // Are theme_check found?
54 if (($response[count($response) - 1] == '[EOF]') && ($response[0] != '[EOF]')) {
55         // Ok, mark found and create the array
56         $themes = array(
57                 'fname'  => array(), // File names
58                 'fsize'  => array(), // File size
59                 'fctime' => array(), // File creation timestamp
60                 'infos'  => array(), // File informations (maybe loaded!)
61                 'ver'    => array(), // Version number
62                 'cver'   => array(), // Current version number
63         );
64
65         // Get count of theme_check for validation
66         $count = trim($response[count($response) - 2]);
67         foreach ($response as $idx => $value) {
68                 $value = str_replace("\n", '', $value); $ver = '';
69
70                 // Leave loop when data is invalid or EOF?
71                 if ((substr($value, 0, 6) == 'theme-') && (substr($value, -4) == '.zip')) {
72                         // Extract name and version
73                         $name = substr($value, 6, -4);
74                         $ver  = trim(substr($response[$idx + 3], 4));
75
76                         // Load version
77                         $cver = getThemeVersion($name);
78
79                         // Is the theme already installed or not?
80                         if (($ver != $cver) && ($cver != '?') && ($cver != '!')) {
81                                 // No, it isn't. So let's add this one!
82                                 $themes['fname'][]  = $name;
83                                 $themes['fsize'][]  = $response[$idx + 1];
84                                 $themes['fctime'][] = $response[$idx + 2];
85                                 $themes['ver'][]    = $ver;
86                                 $themes['cver'][]   = $cver;
87
88                                 // Extract language strings from reponse
89                                 $langDummy = explode('[nl]', $response[$idx + 4]);
90                                 $languages = array();
91                                 $themeInfo = getMessage('ADMIN_EXT_NO_INFO_FOUND');
92
93                                 // Trim every data line
94                                 foreach ($langDummy as $k => $v) {
95                                         $v = trim($v);
96                                         if (substr($v, 3) == '') $v = '---';
97                                         $langDummy[$k] = $v;
98                                         if ($v == 'xx:xx') break;
99                                         $languages[] = $v;
100                                 } // END - foreach
101
102                                 // If language is found stop searching on matching line
103                                 foreach($languages as $search) {
104                                         if (substr($search, 0, 3) == (getLanguage().':')) { $themeInfo = substr($search, 3); break; }
105                                 } // END - foreach
106
107                                 // Add informations to array
108                                 $themes['infos'][] = $themeInfo;
109                         } // END - if
110                 } // END - if
111         } // END - foreach
112
113         // Ok, themes are on our server but maybe you have already installed them?
114         if (count($themes['fname']) > 0) {
115                 // Sort array (I missed ver and cver here)
116                 array_pk_sort($themes, array('cver', 'fname'), 0, 1);
117
118                 // Extensions where found which are not downloaded and installed
119                 $OUT = ''; $SW = 2; $totalSize = '0';
120                 foreach ($themes['fname'] as $idx => $name) {
121                         // Prepare data
122                         $content = array(
123                                 'sw'      => $SW,
124                                 'index'   => ($idx + 1),
125                                 'name'    => $name,
126                                 'created' => generateDateTime($themes['fctime'][$idx], 2),
127                                 'size'    => translateComma(round($themes['fsize'][$idx] / 1.024) / 1000),
128                                 'version' => $themes['ver'][$idx],
129                                 'current' => $themes['cver'][$idx],
130                                 'infos'   => $themes['infos'][$idx],
131                         );
132
133                         // Load row template
134                         $OUT .= loadTemplate('admin_list_theme_row', true, $content);
135
136                         // Add total size
137                         $totalSize += $themes['fsize'][$idx];
138
139                         // Switch color
140                         $SW = 3 - $SW;
141                 }
142                 $content['rows']   = $OUT;
143                 $content['total']  = count($themes['fname']);
144                 $content['kbytes'] = translateComma(round($totalSize / 1.024) / 1000);
145
146                 // Load template
147                 loadTemplate('admin_list_theme', false, $content);
148         } else {
149                 // All Themes are downloaded and installed
150                 loadTemplate('admin_theme_installed', false, $count);
151         }
152 } else {
153         // No theme where found
154         loadTemplate('admin_settings_saved', false, getMessage('ADMIN_THEME_NOTHING_FOUND'));
155 }
156
157 // [EOF]
158 ?>