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 // Normally we want the overview of all registered theme_check
47 // Get response from our server
48 $response = GET_URL("check-themes.php");
50 // Are theme_check found?
51 if (($response[sizeof($response) - 1] == "[EOF]") && ($response[0] != "[EOF]")) {
52 // Ok, mark found and create the 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
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 = "";
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));
74 $cver = THEME_GET_VERSION($name);
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;
85 // Extract language strings from reponse
86 $LANG_DUMMY = explode("[nl]", $response[$idx + 4]);
88 $INFO = getMessage('ADMIN_EXT_NO_INFO_FOUND');
90 // Trim every data line
91 foreach ($LANG_DUMMY as $k => $v) {
93 if (substr($v, 3) == "") $v = "---";
95 if ($v == "xx:xx") break;
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; }
104 // Add informations to array
105 $THEMES['infos'][] = $INFO;
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);
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";
121 // @TODO Move this HTML code to a template "admin_theme_row"
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>
130 <td class=\"switch_sw".$SW." bottom2\"> </td>
131 <td colspan=\"4\" class=\"switch_sw".$SW." bottom2\">
132 <div class=\"tiny\">".$THEMES['infos'][$idx]."</div>
135 $TSIZE += $THEMES['fsize'][$idx];
138 define('__THEMES_ROWS', $OUT);
139 define('__TKBYTES_VALUE', TRANSLATE_COMMA(round($TSIZE / 1.024) / 1000));
140 define('__TTHEME_VALUE', sizeof($THEMES['fname']));
143 LOAD_TEMPLATE("admin_theme_list");
145 // All Themes are downloaded and installed
146 LOAD_TEMPLATE("admin_theme_installed", false, $count);
149 // No theme where found
150 LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_THEME_NOTHING_FOUND'));