2 /************************************************************************
3 * MXChange v0.2.1 Start: 03/22/2004 *
4 * ================ Last change: 12/13/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-extentions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Extension management *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Erweiterungen-Management *
12 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
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. *
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. *
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, *
32 ************************************************************************/
34 // Some security stuff...
35 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
36 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
40 // Add description as navigation point
41 ADD_DESCR("admin", __FILE__);
43 global $cacheInstance, $cacheArray, $cacheMode;
45 // Normally we want the overview of all registered theme_check
49 // Get response from our server
50 $response = GET_URL("check-themes.php");
52 // Are theme_check found?
53 if (($response[sizeof($response) - 1] == "[EOF]") && ($response[0] != "[EOF]")) {
54 // Ok, mark found and create the array
56 'fname' => array(), // File names
57 'fsize' => array(), // File size
58 'fctime' => array(), // File creation timestamp
59 'infos' => array(), // File informations (maybe loaded!)
60 'ver' => array(), // Version number
61 'cver' => array(), // Current version number
64 // Get count of theme_check for validation
65 $count = trim($response[sizeof($response) - 2]);
66 foreach ($response as $idx => $value) {
67 $value = str_replace("\n", "", $value); $ver = "";
69 // Leave loop when data is invalid or EOF?
70 if ((substr($value, 0, 6) == "theme-") && (substr($value, -4) == ".zip")) {
71 // Extract name and version
72 $name = substr($value, 6, -4);
73 $ver = trim(substr($response[$idx + 3], 4));
76 $cver = THEME_GET_VERSION($name);
78 // Is the theme already installed or not?
79 if (($ver != $cver) && ($cver != "?") && ($cver != "!")) {
80 // No, it isn't. So let's add this one!
81 $THEMES['fname'][] = $name;
82 $THEMES['fsize'][] = $response[$idx + 1];
83 $THEMES['fctime'][] = $response[$idx + 2];
84 $THEMES['ver'][] = $ver;
85 $THEMES['cver'][] = $cver;
87 // Extract language strings from reponse
88 $LANG_DUMMY = explode("[nl]", $response[$idx + 4]);
90 $INFO = getMessage('ADMIN_EXT_NO_INFO_FOUND');
92 // Trim every data line
93 foreach ($LANG_DUMMY as $k => $v) {
95 if (substr($v, 3) == "") $v = "---";
97 if ($v == "xx:xx") break;
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; }
106 // Add informations to array
107 $THEMES['infos'][] = $INFO;
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);
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";
123 // @TODO Move this HTML code to a template "admin_theme_row"
125 <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".($idx + 1).".</td>
126 <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\"><a href=\"".$LINK."\">".$name."</a></td>
127 <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".MAKE_DATETIME($THEMES['fctime'][$idx], "2")."</td>
128 <td align=\"center\" class=\"switch_sw".$SW." bottom2 right2\">".TRANSLATE_COMMA(round($THEMES['fsize'][$idx] / 1.024) / 1000)." ".KBYTES."</td>
129 <td align=\"center\" class=\"switch_sw".$SW." bottom2\">".$THEMES['ver'][$idx]." (".$THEMES['cver'][$idx].")</td>
132 <td class=\"switch_sw".$SW." bottom2\"> </td>
133 <td colspan=\"4\" class=\"switch_sw".$SW." bottom2\">
134 <div class=\"tiny\">".$THEMES['infos'][$idx]."</div>
137 $TSIZE += $THEMES['fsize'][$idx];
140 define('__THEMES_ROWS', $OUT);
141 define('__TKBYTES_VALUE', TRANSLATE_COMMA(round($TSIZE / 1.024) / 1000));
142 define('__TTHEME_VALUE', sizeof($THEMES['fname']));
145 LOAD_TEMPLATE("admin_theme_list");
147 // All Themes are downloaded and installed
148 LOAD_TEMPLATE("admin_theme_installed", false, $count);
151 // No theme where found
152 LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_THEME_NOTHING_FOUND'));