2 /************************************************************************
\r
3 * MXChange v0.2.1 Start: 02/12/2004 *
\r
4 * ================ Last change: 11/12/2004 *
\r
6 * -------------------------------------------------------------------- *
\r
7 * File : what-theme_import.php *
\r
8 * -------------------------------------------------------------------- *
\r
9 * Short description : Import of new themes *
\r
10 * -------------------------------------------------------------------- *
\r
11 * Kurzbeschreibung : Importieren von neuen Themes *
\r
12 * -------------------------------------------------------------------- *
\r
14 * -------------------------------------------------------------------- *
\r
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
\r
16 * For more information visit: http://www.mxchange.org *
\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
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
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
34 // Some security stuff...
\r
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!is_admin()))
\r
37 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";
\r
41 // Add description as navigation point
\r
42 ADD_DESCR("admin", basename(__FILE__));
\r
44 // Switch to testing mode
\r
45 $THEME_MODE = "test";
\r
47 // Import selected theme if not present
\r
48 if (!empty($_POST['theme']))
\r
50 $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_themes WHERE theme_path='%s' LIMIT 1",
\r
51 array($_POST['theme']), __FILE__, __LINE__);
\r
52 if (SQL_NUMROWS($result) == 0)
\r
55 $file = PATH."theme/".$_POST['theme']."/theme.php";
\r
56 if (file_exists($file))
\r
59 $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_themes (theme_path, theme_active, theme_ver)
\r
60 VALUES ('%s', 'N', '%s')",
\r
61 array($_POST['theme'], $THEME_VERSION), __FILE__, __LINE__);
\r
62 $msg = ADMIN_THEME_IMPORTED_1.$_POST['theme'].ADMIN_THEME_IMPORTED_2;
\r
66 // Include file not found!
\r
67 $msg = ADMIN_THEME_INC_404_1.$_POST['theme'].ADMIN_THEME_INC_404_2;
\r
73 SQL_FREERESULT($result);
\r
75 // Theme already imported
\r
76 $msg = ADMIN_THEME_ALREADY_1.$_POST['theme'].ADMIN_THEME_ALREADY_2;
\r
80 LOAD_TEMPLATE("admin_settings_saved", false, $msg);
\r
81 OUTPUT_HTML ("<BR>");
\r
86 'theme_unix' => array(), // Unix name from filesystem
\r
87 'theme_name' => array(), // Title
\r
88 'theme_author' => array(), // Theme author's name
\r
89 'theme_email' => array(), // Author's email address
\r
90 'theme_url' => array(), // URL were you can download it from
\r
91 'theme_ver' => array(), // Version number of theme
\r
94 // Read directory "themes"
\r
95 $handle = opendir(PATH."theme/") or mxchange_die("Cannot read themes dir!");
\r
96 while ($dir = readdir($handle))
\r
98 // Construct absolute theme.php file name
\r
99 $theme = PATH."theme/".$dir."/"."theme.php";
\r
102 if (($dir != ".") && ($dir != "..") && (file_exists($theme)))
\r
104 // Found a valid directory so let's load it's theme.php file
\r
107 // Add found theme to array
\r
108 $THEMES['theme_unix'][] = $dir;
\r
109 $THEMES['theme_name'][] = $THEME_NAME;
\r
110 $THEMES['theme_author'][] = $THEME_AUTHOR;
\r
111 $THEMES['theme_email'][] = $THEME_EMAIL;
\r
112 $THEMES['theme_url'][] = $THEME_URL;
\r
113 $THEMES['theme_ver'][] = $THEME_VERSION;
\r
118 // Sort array by Uni* name
\r
119 array_pk_sort($THEMES, array("theme_name"));
\r
121 // Generate output lines for the template
\r
122 $OUT = ""; $SW = 2;
\r
123 foreach ($THEMES['theme_unix'] as $key=>$unix)
\r
125 // Check if current theme is already imported or not
\r
126 $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_themes WHERE theme_path='%s' LIMIT 1",
\r
127 array($unix), __FILE__, __LINE__);
\r
128 if (SQL_NUMROWS($result) == 1)
\r
131 SQL_FREERESULT($result);
\r
133 // Already installed
\r
134 $FOUND = "<FONT class=\"admin_note\">".ADMIN_THEME_ALREADY_INSTALLED."</FONT>";
\r
138 // Theme not installed
\r
139 $FOUND = "<FORM action=\"".URL."/modules.php?module=admin&what=theme_import\" method=\"POST\">
\r
140 <INPUT type=\"submit\" name=\"ok\" class=\"admin_submit\" value=\"".ADMIN_INSTALL_THEME."\">
\r
141 <INPUT type=\"hidden\" name=\"theme\" value=\"".$unix."\">
\r
147 <TD class=\"switch_sw".$SW." bottom2 right2\" align=\"center\" height=\"30\">".$unix."</TD>
\r
148 <TD class=\"switch_sw".$SW." bottom2 right2\" align=\"center\">".$THEMES['theme_name'][$key]."</TD>
\r
149 <TD class=\"switch_sw".$SW." bottom2 right2\" align=\"center\">
\r
150 <A href=\"mailto:".$THEMES['theme_email'][$key]."?Subject=[Theme:] ".$THEMES['theme_name'][$key]." (".$unix.")"."\">".$THEMES['theme_author'][$key]."</A>
\r
152 <TD class=\"switch_sw".$SW." bottom2 right2\" align=\"center\">
\r
153 <A href=\"".DEREFERER($THEMES['theme_url'][$key])."\" target=\"_blank\">".$THEMES['theme_url'][$key]."</A>
\r
155 <TD class=\"switch_sw".$SW." bottom2 right2\" align=\"center\">v".$THEMES['theme_ver'][$key]."</TD>
\r
156 <TD class=\"switch_sw".$SW." bottom2\" align=\"center\">
\r
164 // No themes found???
\r
166 <TD colspan=\"6\" class=\"bottom2\" height=\"80\">
\r
167 ".LOAD_TEMPLATE("admin_settings_saved", true, ADMIN_NO_THEMES_FOUND)."
\r
171 define('__THEME_LIST', $OUT);
\r
174 LOAD_TEMPLATE("admin_theme_import");
\r