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