Wooya napisał/a:
Oto gotowiec :)
1) tworzymy sobie panel do zmiany skory:
openside("Wybierz skórkę");
echo "<center>";
echo "<form name='theme_switcher' method='post' action='".FUSION_SELF."'>";
echo "<select class='textbox' name='ThemeSwitcher' onChange=\"location = '".FUSION_SELF."?theme=' + document.theme_switcher.ThemeSwitcher.options[document.theme_switcher.ThemeSwitcher.selectedIndex].value;\">";
//2l mod
if ($handle = opendir(THEMES)) {
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != "/" && $file != "index.php") {
if ($file == TL_THEME) {
$checked = "selected";
} else {
$checked = "";
}
echo "<option value='$file' $checked>$file</option>\n";
}
}
closedir($handle);
}
//2l mod
echo "</select>";
echo "</form>";
echo "</center>";
closeside();
2) w pliku
maincore.php znajdujemy linijkę:
define("THEMES", BASEDIR."themes/");
i za nią wklejamy:
//2l mod
if (isset($_COOKIE['fusion_theme']) && $_COOKIE['fusion_theme']!='') {
define ("TL_THEME", $_COOKIE['fusion_theme']);
}
if (isset($theme)) {
setcookie("fusion_theme", $theme, time() + 3600*24*365, "/", "", "0");
redirect (FUSION_SELF);
}
//2l mod
3) w tym samym pliku znajdujemy (ok. linia 170):
if (isset($_COOKIE['fusion_user'])) {
$cookie_vars = explode(".", $_COOKIE['fusion_user']);
$cookie_1 = isNum($cookie_vars['0']) ? $cookie_vars['0'] : "0";
$cookie_2 = (preg_match("/^[0-9a-z]{32}$/", $cookie_vars['1']) ? $cookie_vars['1'] : "");
$result = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_id='$cookie_1' AND user_password='$cookie_2'");
unset($cookie_vars,$cookie_1,$cookie_2);
if (dbrows($result) != 0) {
$userdata = dbarray($result);
if ($userdata['user_status'] != 1) {
if ($userdata['user_theme'] != "Default" && file_exists(THEMES.$userdata['user_theme']."/theme.php")) {
define("THEME", THEMES.$userdata['user_theme']."/");
} else {
define("THEME", THEMES.$settings['theme']."/");
}
if ($userdata['user_offset'] <> 0) {
$settings['timeoffset'] = $settings['timeoffset'] + $userdata['user_offset'];
}
if (empty($_COOKIE['fusion_lastvisit'])) {
setcookie("fusion_lastvisit", $userdata['user_lastvisit'], time() + 3600, "/", "", "0");
$lastvisited = $userdata['user_lastvisit'];
} else {
$lastvisited = $_COOKIE['fusion_lastvisit'];
}
} else {
setcookie("fusion_user", "", time() - 7200, "/", "", "0");
setcookie("fusion_lastvisit", "", time() - 7200, "/", "", "0");
redirect(BASEDIR."index.php", "script");
}
} else {
setcookie("fusion_user", "", time() - 7200, "/", "", "0");
setcookie("fusion_lastvisit", "", time() - 7200, "/", "", "0");
redirect(BASEDIR."index.php", "script");
}
} else {
define("THEME", THEMES.$settings['theme']."/");
$userdata = ""; $userdata['user_level'] = 0; $userdata['user_rights'] = ""; $userdata['user_groups'] = "";
}
i zamieniamy na:
if (isset($_COOKIE['fusion_user'])) {
$cookie_vars = explode(".", $_COOKIE['fusion_user']);
$cookie_1 = isNum($cookie_vars['0']) ? $cookie_vars['0'] : "0";
$cookie_2 = (preg_match("/^[0-9a-z]{32}$/", $cookie_vars['1']) ? $cookie_vars['1'] : "");
$result = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_id='$cookie_1' AND user_password='$cookie_2'");
unset($cookie_vars,$cookie_1,$cookie_2);
if (dbrows($result) != 0) {
$userdata = dbarray($result);
if ($userdata['user_status'] != 1) {
if ($userdata['user_theme'] != "Default" && file_exists(THEMES.$userdata['user_theme']."/theme.php")) {
if (defined("TL_THEME")) {
define("THEME", THEMES.TL_THEME."/");
} else {
define("THEME", THEMES.$userdata['user_theme']."/");
}
} else {
if (defined("TL_THEME")) {
define("THEME", THEMES.TL_THEME."/");
} else {
define("THEME", THEMES.$settings['theme']."/");
}
}
if ($userdata['user_offset'] <> 0) {
$settings['timeoffset'] = $settings['timeoffset'] + $userdata['user_offset'];
}
if (empty($_COOKIE['fusion_lastvisit'])) {
setcookie("fusion_lastvisit", $userdata['user_lastvisit'], time() + 3600, "/", "", "0");
$lastvisited = $userdata['user_lastvisit'];
} else {
$lastvisited = $_COOKIE['fusion_lastvisit'];
}
} else {
header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'");
setcookie("fusion_user", "", time() - 7200, "/", "", "0");
setcookie("fusion_lastvisit", "", time() - 7200, "/", "", "0");
redirect(BASEDIR."index.php", "script");
}
} else {
header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'");
setcookie("fusion_user", "", time() - 7200, "/", "", "0");
setcookie("fusion_lastvisit", "", time() - 7200, "/", "", "0");
redirect(BASEDIR."index.php", "script");
}
} else {
//2l mod
if (!defined("TL_THEME")) {
define("THEME", THEMES.$settings['theme']."/");
} else {
define("THEME", THEMES.TL_THEME."/");
}
//2l mod
$userdata = ""; $userdata['user_level'] = 0; $userdata['user_rights'] = ""; $userdata['user_groups'] = "";
}
4) cieszymy siętheme-switcherem dla odwiedzajacych :)