Fixes for stripped HTML tags, and false warnings in debug log
[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  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39
40 // Add description as navigation point
41 ADD_DESCR("admin", __FILE__);
42
43 // Normally we want the overview of all registered theme_check
44 $mode = "overview";
45 $SEL = 0;
46
47 // Get response from our server
48 $response = GET_URL("check-themes.php");
49
50 // Are theme_check found?
51 if (($response[sizeof($response) - 1] == "[EOF]") && ($response[0] != "[EOF]")) {
52         // Ok, mark found and create the array
53         $THEMES = array(
54                 'fname'  => array(), // File names
55                 'fsize'  => array(), // File size
56                 'fctime' => array(), // File creation timestamp
57                 'infos'  => array(), // File informations (maybe loaded!)
58                 'ver'    => array(), // Version number
59                 'cver'   => array(), // Current version number
60         );
61
62         // Get count of theme_check for validation
63         $count = trim($response[sizeof($response) - 2]);
64         foreach ($response as $idx => $value) {
65                 $value = str_replace("\n", "", $value); $ver = "";
66
67                 // Leave loop when data is invalid or EOF?
68                 if ((substr($value, 0, 6) == "theme-") && (substr($value, -4) == ".zip")) {
69                         // Extract name and version
70                         $name = substr($value, 6, -4);
71                         $ver  = trim(substr($response[$idx + 3], 4));
72
73                         // Load version
74                         $cver = THEME_GET_VERSION($name);
75
76                         // Is the theme already installed or not?
77                         if (($ver != $cver) && ($cver != "?") && ($cver != "!")) {
78                                 // No, it isn't. So let's add this one!
79                                 $THEMES['fname'][]  = $name;
80                                 $THEMES['fsize'][]  = $response[$idx + 1];
81                                 $THEMES['fctime'][] = $response[$idx + 2];
82                                 $THEMES['ver'][]    = $ver;
83                                 $THEMES['cver'][]   = $cver;
84
85                                 // Extract language strings from reponse
86                                 $LANG_DUMMY = explode("[nl]", $response[$idx + 4]);
87                                 $LANG = array();
88                                 $INFO = getMessage('ADMIN_EXT_NO_INFO_FOUND');
89
90                                 // Trim every data line
91                                 foreach ($LANG_DUMMY as $k => $v) {
92                                         $v = trim($v);
93                                         if (substr($v, 3) == "") $v = "---";
94                                         $LANG_DUMMY[$k] = $v;
95                                         if ($v == "xx:xx") break;
96                                         $LANG[] = $v;
97                                 } // END - foreach
98
99                                 // If language is found stop searching on matching line
100                                 foreach($LANG as $search) {
101                                         if (substr($search, 0, 3) == (GET_LANGUAGE().":")) { $INFO = substr($search, 3); break; }
102                                 } // END - foreach
103
104                                 // Add informations to array
105                                 $THEMES['infos'][] = $INFO;
106                         } // END - if
107                 } // END - if
108         } // END - foreach
109
110         // Ok, themes are on our server but maybe you have already installed them?
111         if (sizeof($THEMES['fname']) > 0) {
112                 // Sort array (I missed ver and cver here)
113                 array_pk_sort($THEMES, array("cver", "fname"), 0, 1);
114
115                 // Extensions where found which are not downloaded and installed
116                 $SW = 2; $OUT = ""; $TSIZE = 0;
117                 foreach ($THEMES['fname'] as $idx => $name) {
118                         // Generate download link
119                         $LINK = SERVER_URL."/themes/theme-".$name.".zip";
120
121                         // @TODO Move this HTML code to a template "admin_theme_row"
122                         $OUT .= "<tr>
123   <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".($idx + 1).".</td>
124   <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\"><a href=\"".$LINK."\">".$name."</a></td>
125   <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".MAKE_DATETIME($THEMES['fctime'][$idx], "2")."</td>
126   <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".TRANSLATE_COMMA(round($THEMES['fsize'][$idx] / 1.024) / 1000)." ".KBYTES."</td>
127   <td align=\"center\" class=\"switch_sw".$SW." bottom2\">".$THEMES['ver'][$idx]." (".$THEMES['cver'][$idx].")</td>
128 </tr>
129 <tr>
130   <td class=\"switch_sw".$SW." bottom2\">&nbsp;</td>
131   <td colspan=\"4\" class=\"switch_sw".$SW." bottom2\">
132     <div class=\"tiny\">".$THEMES['infos'][$idx]."</div>
133   </td>
134 </tr>\n";
135                         $TSIZE += $THEMES['fsize'][$idx];
136                         $SW = 3 - $SW;
137                 }
138                 define('__THEMES_ROWS', $OUT);
139                 define('__TKBYTES_VALUE', TRANSLATE_COMMA(round($TSIZE / 1.024) / 1000));
140                 define('__TTHEME_VALUE', sizeof($THEMES['fname']));
141
142                 // Load template
143                 LOAD_TEMPLATE("admin_theme_list");
144         } else {
145                 // All Themes are downloaded and installed
146                 LOAD_TEMPLATE("admin_theme_installed", false, $count);
147         }
148 } else {
149         // No theme where found
150         LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_THEME_NOTHING_FOUND'));
151 }
152
153 //
154 ?>