List active/inactive extensions
[mailer.git] / 0.2.1 / inc / modules / admin / what-theme_check.php
1 <?php\r
2 /************************************************************************\r
3  * MXChange v0.2.1                                    Start: 03/22/2004 *\r
4  * ================                             Last change: 12/13/2004 *\r
5  *                                                                      *\r
6  * -------------------------------------------------------------------- *\r
7  * File              : what-extentions.php                              *\r
8  * -------------------------------------------------------------------- *\r
9  * Short description : Extension management                             *\r
10  * -------------------------------------------------------------------- *\r
11  * Kurzbeschreibung  : Erweiterungen-Management                         *\r
12  * -------------------------------------------------------------------- *\r
13  *                                                                      *\r
14  * -------------------------------------------------------------------- *\r
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *\r
16  * For more information visit: http://www.mxchange.org                  *\r
17  *                                                                      *\r
18  * This program is free software; you can redistribute it and/or modify *\r
19  * it under the terms of the GNU General Public License as published by *\r
20  * the Free Software Foundation; either version 2 of the License, or    *\r
21  * (at your option) any later version.                                  *\r
22  *                                                                      *\r
23  * This program is distributed in the hope that it will be useful,      *\r
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *\r
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *\r
26  * GNU General Public License for more details.                         *\r
27  *                                                                      *\r
28  * You should have received a copy of the GNU General Public License    *\r
29  * along with this program; if not, write to the Free Software          *\r
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *\r
31  * MA  02110-1301  USA                                                  *\r
32  ************************************************************************/\r
33 \r
34 // Some security stuff...\r
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))\r
36 {\r
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";\r
38         require($INC);\r
39 }\r
40 // Add description as navigation point\r
41 ADD_DESCR("admin", basename(__FILE__));\r
42 \r
43 global $CACHE, $KEEP_ACTIVE, $CACHE_FILE;\r
44 \r
45 // Normally we want the overview of all registered theme_check\r
46 $mode = "overview";\r
47 $SEL = "0";\r
48 \r
49 // Get response from our server\r
50 $response = MXCHANGE_OPEN("check-themes.php");\r
51 \r
52 // Are theme_check found?\r
53 if (($response[sizeof($response) - 1] == "[EOF]") && ($response[0] != "[EOF]"))\r
54 {\r
55         // Ok, mark found and create the array\r
56         $THEMES = array(\r
57                 'fname'  => array(), // File names\r
58                 'fsize'  => array(), // File size\r
59                 'fctime' => array(), // File creation timestamp\r
60                 'infos'  => array(), // File informations (maybe loaded!)\r
61                 'ver'    => array(), // Version number\r
62                 'cver'   => array(), // Current version number\r
63         );\r
64 \r
65         // Get count of theme_check for validation\r
66         $count = trim($response[sizeof($response) - 2]);\r
67         foreach ($response as $idx=>$value)\r
68         {\r
69                 $value = str_replace("\n", "", $value); $ver = "";\r
70 \r
71                 // Leave loop when data is invalid or EOF?\r
72                 if ((substr($value, 0, 6) == "theme-") && (substr($value, -4) == ".zip"))\r
73                 {\r
74                         $name = substr($value, 6, -4);\r
75                         $file = PATH."themes/".$name."/theme.php";\r
76                         $ver = trim(substr($response[$idx + 3], 4));\r
77 \r
78                         // Load version\r
79                         $result = SQL_QUERY_ESC("SELECT theme_ver FROM "._MYSQL_PREFIX."_themes WHERE theme_path='%s' LIMIT 1",\r
80                          array($name), __FILE__, __LINE__);\r
81                         list($cver) = SQL_FETCHROW($result);\r
82                         if (empty($cver)) $cver = "-.-";\r
83 \r
84                         // Is the extension already installed or not?\r
85                         if (((SQL_NUMROWS($result) == 0) && (!file_exists($file))) || ($ver != $cver))\r
86                         {\r
87                                 // No, it isn't. So let's add this one!\r
88                                 $THEMES['fname'][]  = $name;\r
89                                 $THEMES['fsize'][]  = $response[$idx + 1];\r
90                                 $THEMES['fctime'][] = $response[$idx + 2];\r
91                                 $THEMES['ver'][]    = $ver;\r
92                                 $THEMES['cver'][]   = $cver;\r
93 \r
94                                 $LANG_DUMMY = explode("[nl]", $response[$idx + 4]);\r
95                                 $LANG = array();\r
96                                 $INFO = ADMIN_EXT_NO_INFO_FOUND;\r
97 \r
98                                 // Trim every data line\r
99                                 foreach ($LANG_DUMMY as $k=>$v)\r
100                                 {\r
101                                         $v = trim($v);\r
102                                         if (substr($v, 3) == "") $v = "---";\r
103                                         $LANG_DUMMY[$k] = $v;\r
104                                         if ($v == "xx:xx") break;\r
105                                         $LANG[] = $v;\r
106                                 }\r
107 \r
108                                 // If language is found stop searching on matching line\r
109                                 foreach($LANG as $search)\r
110                                 {\r
111                                         if (substr($search, 0, 3) == (GET_LANGUAGE().":")) { $INFO = substr($search, 3); break; }\r
112                                 }\r
113 \r
114                                 // Add informations to array\r
115                                 $THEMES['infos'][] = $INFO;\r
116                         }\r
117                 }\r
118         }\r
119 \r
120         // Ok, themes are on our server but maybe you have already installed them?\r
121         if (sizeof($THEMES['fname']) > 0)\r
122         {\r
123                 // Sort array (I missed ver and cver here)\r
124                 array_pk_sort($THEMES, array("cver", "fname"), 0, 1);\r
125 \r
126                 // Extensions where found which are not downloaded and installed\r
127                 $SW = 2; $OUT = ""; $TSIZE = 0;\r
128                 foreach ($THEMES['fname'] as $idx=>$name)\r
129                 {\r
130                         // Generate download link\r
131                         $LINK = SERVER_URL."/themes/theme-".$name.".zip";\r
132                         $OUT .= "<TR>\r
133   <TD align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".($idx + 1).".</TD>\r
134   <TD align=\"center\" class=\"switch_sw".$SW." bottom2 right2\"><A href=\"".$LINK."\">".$name."</A></TD>\r
135   <TD align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".MAKE_DATETIME($THEMES['fctime'][$idx], "2")."</TD>\r
136   <TD align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".TRANSLATE_COMMA(round($THEMES['fsize'][$idx] / 1.024) / 1000)." ".KBYTES."</TD>\r
137   <TD align=\"center\" class=\"switch_sw".$SW." bottom2\">".$THEMES['ver'][$idx]." (".$THEMES['cver'][$idx].")</TD>\r
138 </TR>\r
139 <TR>\r
140   <TD class=\"switch_sw".$SW." bottom2\">&nbsp;</TD>\r
141   <TD colspan=\"4\" class=\"switch_sw".$SW." bottom2\">\r
142     <FONT class=\"tiny\">".stripslashes($THEMES['infos'][$idx])."</FONT>\r
143   </TD>\r
144 </TR>\n";\r
145                         $TSIZE += $THEMES['fsize'][$idx];\r
146                         $SW = 3 - $SW;\r
147                 }\r
148                 define('__THEMES_ROWS', $OUT);\r
149                 define('__TKBYTES_VALUE', TRANSLATE_COMMA(round($TSIZE / 1.024) / 1000));\r
150                 define('__TTHEME_VALUE', sizeof($THEMES['fname']));\r
151 \r
152                 // Load template\r
153                 LOAD_TEMPLATE("admin_theme_list");\r
154         }\r
155          else\r
156         {\r
157                 // All Themes are downloaded and installed\r
158                 LOAD_TEMPLATE("admin_theme_installed", false, $count);\r
159         }\r
160 }\r
161  else\r
162 {\r
163         // No theme where found\r
164         LOAD_TEMPLATE("admin_theme_404");\r
165 }\r
166 //\r
167 ?>\r