1c9d7f0684ecc8eef85fb387a9a29380c1913a5f
[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", basename(__FILE__));
42
43 global $cacheInstance, $cacheArray, $cacheMode;
44
45 // Normally we want the overview of all registered theme_check
46 $mode = "overview";
47 $SEL = 0;
48
49 // Get response from our server
50 $response = GET_URL("check-themes.php");
51
52 // Are theme_check found?
53 if (($response[sizeof($response) - 1] == "[EOF]") && ($response[0] != "[EOF]"))
54 {
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[sizeof($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                         $name = substr($value, 6, -4);
73                         $file = sprintf("%sthemes/%s/theme.php", PATH, $name);
74                         $ver  = trim(substr($response[$idx + 3], 4));
75
76                         // Load version
77                         $cver = THEME_GET_VERSION($name);
78
79                         // Is the extension already installed or not?
80                         if (((SQL_NUMROWS($result) == 0) && (!FILE_READABLE($file))) || ($ver != $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                                 $LANG_DUMMY = explode("[nl]", $response[$idx + 4]);
89                                 $LANG = array();
90                                 $INFO = ADMIN_EXT_NO_INFO_FOUND;
91
92                                 // Trim every data line
93                                 foreach ($LANG_DUMMY as $k => $v) {
94                                         $v = trim($v);
95                                         if (substr($v, 3) == "") $v = "---";
96                                         $LANG_DUMMY[$k] = $v;
97                                         if ($v == "xx:xx") break;
98                                         $LANG[] = $v;
99                                 } // END - foreach
100
101                                 // If language is found stop searching on matching line
102                                 foreach($LANG as $search) {
103                                         if (substr($search, 0, 3) == (GET_LANGUAGE().":")) { $INFO = substr($search, 3); break; }
104                                 } // END - foreach
105
106                                 // Add informations to array
107                                 $THEMES['infos'][] = $INFO;
108                         } // END - if
109                 } // END - if
110         } // END - foreach
111
112         // Ok, themes are on our server but maybe you have already installed them?
113         if (sizeof($THEMES['fname']) > 0) {
114                 // Sort array (I missed ver and cver here)
115                 array_pk_sort($THEMES, array("cver", "fname"), 0, 1);
116
117                 // Extensions where found which are not downloaded and installed
118                 $SW = 2; $OUT = ""; $TSIZE = 0;
119                 foreach ($THEMES['fname'] as $idx => $name) {
120                         // Generate download link
121                         $LINK = SERVER_URL."/themes/theme-".$name.".zip";
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     <FONT class=\"tiny\">".$THEMES['infos'][$idx]."</FONT>
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_theme_404");
151 }
152
153 //
154 ?>