Theme Switcher Panel with Preview v2.01
PHP-Fusion v7
Author: Wooya
Update: Dallas, SiteMaster style
-------------------------------------------
Released under the terms and conditions of
the GNU General Public License (Version 2)
-------------------------------------------

DESCRIPTION
-----------
A Theme Switcher panel with a preview of the theme, enabling site visitors to change the theme from the dropdown menu

Tested with PHP-Fusion v7.07


INSTALLATION
------------
1. Upload the folders and files to their respective locations on your server
2. Go to Admin Panel -> System Admin -> Panels
3. Select "Theme Switcher Panel" and enter in title and password
5. enable the panel.
6. replace the maincore.php in the root dir with the modified maincore.php.
7. If you want to do it without replacing your maincore.php just follow these simple instructions below.

Open maincore.php and find.

define("THEMES", BASEDIR."themes/");

Directly after that paste this code

//THEME switcher
if (isset($_COOKIE[COOKIE_PREFIX.'theme']) && $_COOKIE[COOKIE_PREFIX.'theme']!='') {
	if (file_exists(THEMES.$_COOKIE[COOKIE_PREFIX.'theme']."/theme.php")) {
	   define ("THEME_SWITCH", $_COOKIE[COOKIE_PREFIX.'theme']);
	}
}

if (isset($_POST['theme_switch'])) {
	if (file_exists(THEMES.$_POST['theme_switch']."/theme.php")) {
	   setcookie(COOKIE_PREFIX."theme", $_POST['theme_switch'], time() + 3600*24*365, "/", "", "0");
	   redirect (FUSION_SELF);
	} else {
	   redirect (FUSION_SELF);
	}
}
//THEME switcher


Then on or about line 205 to 233 find:


//check that site or user theme exists
function theme_exists($theme) {
	if (!file_exists(THEMES) || !is_dir(THEMES)) {
		return false;	
	} else if (file_exists(THEMES.$theme."/theme.php") && file_exists(THEMES.$theme."/styles.css")) {
		define("THEME", THEMES.$theme."/");
		return true;
	} else {
		$dh = opendir(THEMES);
		while (false !== ($entry = readdir($dh))) {
			if ($entry != "." && $entry != ".." && is_dir(THEMES.$entry)) {
				if (file_exists(THEMES.$entry."/theme.php") && file_exists(THEMES.$entry."/styles.css")) {
					define("THEME", THEMES.$entry."/");
					return true;
					exit;
				}
			}
		}
		closedir($dh);
		if (!defined("THEME")) {
			return false;
		}
	}
}

and replace with this.


//check that site or user theme exists
function theme_exists($theme) {
	if (!file_exists(THEMES) || !is_dir(THEMES)) {
		return false;	
	} else if (file_exists(THEMES.$theme."/theme.php") && file_exists(THEMES.$theme."/styles.css")) {
		if (!defined("THEME_SWITCH")) {
			define("THEME", THEMES.$theme."/");
			return true;
		}else{
			define("THEME", THEMES.THEME_SWITCH."/");
			return true;
		}
	} else {
		$dh = opendir(THEMES);
		while (false !== ($entry = readdir($dh))) {
			if ($entry != "." && $entry != ".." && is_dir(THEMES.$entry)) {
				if (file_exists(THEMES.$entry."/theme.php") && file_exists(THEMES.$entry."/styles.css")) {
					define("THEME", THEMES.$entry."/");
					return true;
					exit;
				}
			}
		}
		closedir($dh);
		if (!defined("THEME")) {
			return false;
		}
	}
}


CHANGELOG
---------
v2.01
* Updated to work with PHP Fusion v7.07 By SiteMaster style
v2.00
* Updated to work with PHP Fusion V7 By Dallas.