-<?php\r
-/************************************************************************\r
- * MXChange v0.2.1 Start: 12/03/2004 *\r
- * =============== Last change: 12/13/2004 *\r
- * *\r
- * -------------------------------------------------------------------- *\r
- * File : theme-manager.php *\r
- * -------------------------------------------------------------------- *\r
- * Short description : Theme manager *\r
- * -------------------------------------------------------------------- *\r
- * Kurzbeschreibung : Themen-Manager *\r
- * -------------------------------------------------------------------- *\r
- * *\r
- * -------------------------------------------------------------------- *\r
- * Copyright (c) 2003 - 2007 by Roland Haeder *\r
- * For more information visit: http://www.mxchange.org *\r
- * *\r
- * This program is free software; you can redistribute it and/or modify *\r
- * it under the terms of the GNU General Public License as published by *\r
- * the Free Software Foundation; either version 2 of the License, or *\r
- * (at your option) any later version. *\r
- * *\r
- * This program is distributed in the hope that it will be useful, *\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *\r
- * GNU General Public License for more details. *\r
- * *\r
- * You should have received a copy of the GNU General Public License *\r
- * along with this program; if not, write to the Free Software *\r
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *\r
- * MA 02110-1301 USA *\r
- ************************************************************************/\r
-\r
-// Some security stuff...\r
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))\r
-{\r
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";\r
- require($INC);\r
-}\r
-\r
-//\r
-function GET_CURR_THEME()\r
-{\r
- global $_COOKIE, $INC_POOL, $CONFIG, $_GET, $_POST, $CSS;\r
- // The default theme is 'default'... ;-)\r
- $ret = "default";\r
-\r
- // Load default theme if not empty from configuration\r
- if (!empty($CONFIG['default_theme'])) $ret = $CONFIG['default_theme'];\r
-\r
- if (empty($_COOKIE['mxchange_theme']))\r
- {\r
- // Set default theme\r
- @setcookie("mxchange_theme", $ret, (time() + 60*60*24*365), COOKIE_PATH);\r
- }\r
- elseif ((!empty($_COOKIE['mxchange_theme'])) && (GET_EXT_VERSION("sql_patches") >= "0.1.4"))\r
- {\r
- // Get theme from cookie\r
- $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_themes WHERE theme_path='%s' LIMIT 1", array($_COOKIE['mxchange_theme']), __FILE__, __LINE__);\r
- if (SQL_NUMROWS($result) == 1)\r
- {\r
- // Design is valid!\r
- $ret = $_COOKIE['mxchange_theme'];\r
- }\r
-\r
- // Free memory\r
- SQL_FREERESULT($result);\r
- }\r
- elseif ((!mxchange_installed) && ((mxchange_installing) || ($CSS == true)) && ((!empty($_GET['theme'])) || (!empty($_POST['theme']))))\r
- {\r
- // Installation mode active\r
- if ((!empty($_GET['theme'])) && (file_exists(PATH."theme/".$_GET['theme']."/theme.php")))\r
- {\r
- // Set cookie from URL data\r
- @setcookie("mxchange_theme", $_GET['theme'], (time() + 60*60*24*365), COOKIE_PATH);\r
- $_COOKIE['mxchange_theme'] = $_GET['theme'];\r
- }\r
- elseif (file_exists(PATH."theme/".$_POST['theme']."/theme.php"))\r
- {\r
- // Set cookie from posted data\r
- @setcookie("mxchange_theme", $_POST['theme'], (time() + 60*60*24*365), COOKIE_PATH);\r
- $_COOKIE['mxchange_theme'] = $_POST['theme'];\r
- }\r
-\r
- // Set return value\r
- $ret = $_COOKIE['mxchange_theme'];\r
- }\r
- else\r
- {\r
- // Invalid design, reset cookie\r
- @setcookie("mxchange_theme", $ret, (time() + 60*60*24*365), COOKIE_PATH);\r
- }\r
-\r
- // Add (maybe) found theme.php file to inclusion list\r
- $theme = PATH."theme/".$ret."/theme.php";\r
- if (@file_exists($theme)) $INC_POOL[] = $theme;\r
-\r
- // Return theme value\r
- return $ret;\r
-}\r
-\r
-function THEME_SELECTION_BOX($mod, $act, $wht, $result)\r
-{\r
- // Construction URL\r
- global $CurrTheme;\r
- $FORM = URL."/modules.php?module=".$mod;\r
- if (!empty($act)) $FORM .= "&action=".$act;\r
- if (!empty($wht)) $FORM .= "&what=".$wht;\r
- define('__FORM_VALUE', $FORM);\r
-\r
- // Initialize array\r
- $THEMES = array(\r
- 'theme_unix' => array(), // Unix name from filesystem\r
- 'theme_name' => array() // Title\r
- );\r
-\r
- // Load all themes\r
- while(list($theme) = SQL_FETCHROW($result))\r
- {\r
- // Load it's theme.php file\r
- $INC = PATH."theme/".$theme."/theme.php";\r
- if (file_exists($INC))\r
- {\r
- // And save all data in array\r
- include($INC);\r
- $THEMES['theme_unix'][] = $theme;\r
- $THEMES['theme_name'][] = $THEME_NAME;\r
- }\r
- }\r
-\r
- // Sort whole array by title\r
- array_pk_sort($THEMES, array("theme_name"));\r
-\r
- // Construct selection form for the box template\r
- $OUT = "";\r
- foreach ($THEMES['theme_unix'] as $key=>$theme)\r
- {\r
- $OUT .= " <OPTION value=\"".$theme."\"";\r
- if ($theme == $CurrTheme) $OUT .= " selected=\"selected\"";\r
- $OUT .= ">".$THEMES['theme_name'][$key]."</OPTION>\n";\r
- }\r
-\r
- // Return generated selection\r
- define('__THEME_SELECTION_OPTIONS', $OUT);\r
- $OUT = LOAD_TEMPLATE("theme_select_form", true);\r
- return $OUT;\r
-}\r
-\r
-// Initialize variables\r
-$CurrTheme = GET_CURR_THEME();\r
-if (empty($_POST['new_theme'])) $_POST['new_theme'] = "";\r
-\r
-// Check if new theme is selcted\r
-if ((!empty($_POST['new_theme'])) && ($_POST['new_theme'] != $CurrTheme))\r
-{\r
- // Set new theme for guests\r
- $NewTheme = $_POST['new_theme'];\r
-\r
- // Change to new theme\r
- @setcookie("mxchange_theme", $NewTheme, (time() + 60*60*24*365), COOKIE_PATH);\r
-\r
- // Remove current from array and set new\r
- $theme = PATH."theme/".$CurrTheme."/theme.php";\r
- unset($INC_POOL[array_search($theme, $INC_POOL)]);\r
- $INC_POOL[] = PATH."theme/".$NewTheme."/theme.php";\r
-}\r
-\r
-// Remove variable again\r
-unset($_POST['new_theme']);\r
-\r
-//\r
-?>\r
+<?php
+/************************************************************************
+ * MXChange v0.2.1 Start: 12/03/2004 *
+ * =============== Last change: 12/13/2004 *
+ * *
+ * -------------------------------------------------------------------- *
+ * File : theme-manager.php *
+ * -------------------------------------------------------------------- *
+ * Short description : Theme manager *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung : Themen-Manager *
+ * -------------------------------------------------------------------- *
+ * *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder *
+ * For more information visit: http://www.mxchange.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
+ * MA 02110-1301 USA *
+ ************************************************************************/
+
+// Some security stuff...
+if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
+{
+ $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+ require($INC);
+}
+
+//
+function GET_CURR_THEME()
+{
+ global $_COOKIE, $INC_POOL, $CONFIG, $_GET, $_POST, $CSS;
+ // The default theme is 'default'... ;-)
+ $ret = "default";
+
+ // Load default theme if not empty from configuration
+ if (!empty($CONFIG['default_theme'])) $ret = $CONFIG['default_theme'];
+
+ if (empty($_COOKIE['mxchange_theme']))
+ {
+ // Set default theme
+ @setcookie("mxchange_theme", $ret, (time() + 60*60*24*365), COOKIE_PATH);
+ }
+ elseif ((!empty($_COOKIE['mxchange_theme'])) && (GET_EXT_VERSION("sql_patches") >= "0.1.4"))
+ {
+ // Get theme from cookie
+ $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_themes WHERE theme_path='%s' LIMIT 1", array($_COOKIE['mxchange_theme']), __FILE__, __LINE__);
+ if (SQL_NUMROWS($result) == 1)
+ {
+ // Design is valid!
+ $ret = $_COOKIE['mxchange_theme'];
+ }
+
+ // Free memory
+ SQL_FREERESULT($result);
+ }
+ elseif ((!mxchange_installed) && ((mxchange_installing) || ($CSS == true)) && ((!empty($_GET['theme'])) || (!empty($_POST['theme']))))
+ {
+ // Installation mode active
+ if ((!empty($_GET['theme'])) && (file_exists(PATH."theme/".$_GET['theme']."/theme.php")))
+ {
+ // Set cookie from URL data
+ @setcookie("mxchange_theme", $_GET['theme'], (time() + 60*60*24*365), COOKIE_PATH);
+ $_COOKIE['mxchange_theme'] = $_GET['theme'];
+ }
+ elseif (file_exists(PATH."theme/".$_POST['theme']."/theme.php"))
+ {
+ // Set cookie from posted data
+ @setcookie("mxchange_theme", $_POST['theme'], (time() + 60*60*24*365), COOKIE_PATH);
+ $_COOKIE['mxchange_theme'] = $_POST['theme'];
+ }
+
+ // Set return value
+ $ret = $_COOKIE['mxchange_theme'];
+ }
+ else
+ {
+ // Invalid design, reset cookie
+ @setcookie("mxchange_theme", $ret, (time() + 60*60*24*365), COOKIE_PATH);
+ }
+
+ // Add (maybe) found theme.php file to inclusion list
+ $theme = PATH."theme/".$ret."/theme.php";
+ if (@file_exists($theme)) $INC_POOL[] = $theme;
+
+ // Return theme value
+ return $ret;
+}
+
+function THEME_SELECTION_BOX($mod, $act, $wht, $result)
+{
+ // Construction URL
+ global $CurrTheme;
+ $FORM = URL."/modules.php?module=".$mod;
+ if (!empty($act)) $FORM .= "&action=".$act;
+ if (!empty($wht)) $FORM .= "&what=".$wht;
+ define('__FORM_VALUE', $FORM);
+
+ // Initialize array
+ $THEMES = array(
+ 'theme_unix' => array(), // Unix name from filesystem
+ 'theme_name' => array() // Title
+ );
+
+ // Load all themes
+ while(list($theme) = SQL_FETCHROW($result))
+ {
+ // Load it's theme.php file
+ $INC = PATH."theme/".$theme."/theme.php";
+ if (file_exists($INC))
+ {
+ // And save all data in array
+ include($INC);
+ $THEMES['theme_unix'][] = $theme;
+ $THEMES['theme_name'][] = $THEME_NAME;
+ }
+ }
+
+ // Sort whole array by title
+ array_pk_sort($THEMES, array("theme_name"));
+
+ // Construct selection form for the box template
+ $OUT = "";
+ foreach ($THEMES['theme_unix'] as $key=>$theme)
+ {
+ $OUT .= " <OPTION value=\"".$theme."\"";
+ if ($theme == $CurrTheme) $OUT .= " selected=\"selected\"";
+ $OUT .= ">".$THEMES['theme_name'][$key]."</OPTION>\n";
+ }
+
+ // Return generated selection
+ define('__THEME_SELECTION_OPTIONS', $OUT);
+ $OUT = LOAD_TEMPLATE("theme_select_form", true);
+ return $OUT;
+}
+
+// Initialize variables
+$CurrTheme = GET_CURR_THEME();
+if (empty($_POST['new_theme'])) $_POST['new_theme'] = "";
+
+// Check if new theme is selcted
+if ((!empty($_POST['new_theme'])) && ($_POST['new_theme'] != $CurrTheme))
+{
+ // Set new theme for guests
+ $NewTheme = $_POST['new_theme'];
+
+ // Change to new theme
+ @setcookie("mxchange_theme", $NewTheme, (time() + 60*60*24*365), COOKIE_PATH);
+
+ // Remove current from array and set new
+ $theme = PATH."theme/".$CurrTheme."/theme.php";
+ unset($INC_POOL[array_search($theme, $INC_POOL)]);
+ $INC_POOL[] = PATH."theme/".$NewTheme."/theme.php";
+}
+
+// Remove variable again
+unset($_POST['new_theme']);
+
+//
+?>