A lot rewrites from double-quote to single-quote, some fixes for extension handling...
[mailer.git] / inc / modules / admin / what-theme_check.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    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 - 2008 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')) || (!IS_ADMIN())) {
41         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
42         require($INC);
43 }
44
45 // Add description as navigation point
46 ADD_DESCR('admin', __FILE__);
47
48 // Normally we want the overview of all registered theme_check
49 $mode = "overview";
50 $SEL = 0;
51
52 // Get response from our server
53 $response = GET_URL("check-themes.php");
54
55 // Are theme_check found?
56 if (($response[count($response) - 1] == "[EOF]") && ($response[0] != "[EOF]")) {
57         // Ok, mark found and create the array
58         $THEMES = array(
59                 'fname'  => array(), // File names
60                 'fsize'  => array(), // File size
61                 'fctime' => array(), // File creation timestamp
62                 'infos'  => array(), // File informations (maybe loaded!)
63                 'ver'    => array(), // Version number
64                 'cver'   => array(), // Current version number
65         );
66
67         // Get count of theme_check for validation
68         $count = trim($response[count($response) - 2]);
69         foreach ($response as $idx => $value) {
70                 $value = str_replace("\n", '', $value); $ver = '';
71
72                 // Leave loop when data is invalid or EOF?
73                 if ((substr($value, 0, 6) == "theme-") && (substr($value, -4) == ".zip")) {
74                         // Extract name and version
75                         $name = substr($value, 6, -4);
76                         $ver  = trim(substr($response[$idx + 3], 4));
77
78                         // Load version
79                         $cver = THEME_GET_VERSION($name);
80
81                         // Is the theme already installed or not?
82                         if (($ver != $cver) && ($cver != "?") && ($cver != "!")) {
83                                 // No, it isn't. So let's add this one!
84                                 $THEMES['fname'][]  = $name;
85                                 $THEMES['fsize'][]  = $response[$idx + 1];
86                                 $THEMES['fctime'][] = $response[$idx + 2];
87                                 $THEMES['ver'][]    = $ver;
88                                 $THEMES['cver'][]   = $cver;
89
90                                 // Extract language strings from reponse
91                                 $LANG_DUMMY = explode("[nl]", $response[$idx + 4]);
92                                 $LANG = array();
93                                 $INFO = getMessage('ADMIN_EXT_NO_INFO_FOUND');
94
95                                 // Trim every data line
96                                 foreach ($LANG_DUMMY as $k => $v) {
97                                         $v = trim($v);
98                                         if (substr($v, 3) == "") $v = "---";
99                                         $LANG_DUMMY[$k] = $v;
100                                         if ($v == "xx:xx") break;
101                                         $LANG[] = $v;
102                                 } // END - foreach
103
104                                 // If language is found stop searching on matching line
105                                 foreach($LANG as $search) {
106                                         if (substr($search, 0, 3) == (GET_LANGUAGE().":")) { $INFO = substr($search, 3); break; }
107                                 } // END - foreach
108
109                                 // Add informations to array
110                                 $THEMES['infos'][] = $INFO;
111                         } // END - if
112                 } // END - if
113         } // END - foreach
114
115         // Ok, themes are on our server but maybe you have already installed them?
116         if (count($THEMES['fname']) > 0) {
117                 // Sort array (I missed ver and cver here)
118                 array_pk_sort($THEMES, array("cver", "fname"), 0, 1);
119
120                 // Extensions where found which are not downloaded and installed
121                 $OUT = ''; $SW = 2; $TSIZE = 0;
122                 foreach ($THEMES['fname'] as $idx => $name) {
123                         // Generate download link
124                         $LINK = SERVER_URL."/themes/theme-".$name.".zip";
125
126                         // @TODO Move this HTML code to a template "admin_theme_row"
127                         $OUT .= "<tr>
128   <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".($idx + 1).".</td>
129   <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\"><a href=\"".$LINK."\">".$name."</a></td>
130   <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".MAKE_DATETIME($THEMES['fctime'][$idx], "2")."</td>
131   <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".TRANSLATE_COMMA(round($THEMES['fsize'][$idx] / 1.024) / 1000)." ".KBYTES."</td>
132   <td align=\"center\" class=\"switch_sw".$SW." bottom2\">".$THEMES['ver'][$idx]." (".$THEMES['cver'][$idx].")</td>
133 </tr>
134 <tr>
135   <td class=\"switch_sw".$SW." bottom2\">&nbsp;</td>
136   <td colspan=\"4\" class=\"switch_sw".$SW." bottom2\">
137     <div class=\"tiny\">".$THEMES['infos'][$idx]."</div>
138   </td>
139 </tr>\n";
140                         $TSIZE += $THEMES['fsize'][$idx];
141                         $SW = 3 - $SW;
142                 }
143                 define('__THEMES_ROWS', $OUT);
144                 define('__TKBYTES_VALUE', TRANSLATE_COMMA(round($TSIZE / 1.024) / 1000));
145                 define('__TTHEME_VALUE', count($THEMES['fname']));
146
147                 // Load template
148                 LOAD_TEMPLATE("admin_theme_list");
149         } else {
150                 // All Themes are downloaded and installed
151                 LOAD_TEMPLATE("admin_theme_installed", false, $count);
152         }
153 } else {
154         // No theme where found
155         LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_THEME_NOTHING_FOUND'));
156 }
157
158 //
159 ?>