Author |
Message |
netgoodies
Regular


Joined: Sep 26, 2005
Posts: 63
Location: Oxfordshire. United Kingdom.
|
Posted:
Wed Nov 30, 2005 6:21 am |
|
Hi
Can anyone help me please.
I have phpnuke 7.6 3.1p with CNB Your Account, and have a problem installing the theme preview block.
The problem is with the file edits as follows:
mainfile.php edit.
Code:=====
Find:
=====
function get_theme() {
global $user, $cookie, $Default_Theme;
static $ThemeSelSave;
if (isset($ThemeSelSave)) return ($ThemeSelSave);
if(is_user($user)) {
$user2 = base64_decode($user);
$t_cookie = explode(":", $user2);
if($t_cookie[9]=="") $t_cookie[9]=$Default_Theme;
if(isset($theme)) $t_cookie[9]=$theme;
if(!$tfile=@opendir("themes/$t_cookie[9]")) {
$ThemeSel = $Default_Theme;
} else {
$ThemeSel = $t_cookie[9];
}
} else {
$ThemeSel = $Default_Theme;
}
$ThemeSelSave = $ThemeSel;
return($ThemeSel);
}
|
I have
Code:function get_theme() {
global $user, $userinfo, $Default_Theme, $name, $op;
if (isset($ThemeSelSave)) return $ThemeSelSave;
if(is_user($user) && ($name != "Your_Account" && $op != "logout")) {
getusrinfo($user);
if(empty($userinfo['theme'])) $userinfo['theme']=$Default_Theme;
if(file_exists("themes/".$userinfo['theme']."/theme.php")) {
$ThemeSel = $userinfo['theme'];
} else {
$ThemeSel = $Default_Theme;
}
} else {
$ThemeSel = $Default_Theme;
}
static $ThemeSelSave;
$ThemeSelSave = $ThemeSel;
return $ThemeSelSave;
}
|
Also the edit for "function savetheme" in CNB Your Account cannot be done because there is no "function savetheme"
Code:Go to modules/Your_Account folder and open your index.php file
then look for the following:
==========================================
function savetheme($user_id, $theme) {
==========================================
Inside that function
=====
Find:
=====
docookie($userinfo[user_id],$userinfo[username],$userinfo[user_password],$userinfo[storynum],$userinfo[umode],$userinfo[uorder],$userinfo[thold],$userinfo[noscore],$userinfo[ublockon],$userinfo[theme],$userinfo[commentmax]);
==========
change to:
==========
setcookie('theme',base64_encode($theme), 0);
docookie($userinfo[user_id],$userinfo[username],$userinfo[user_password],$userinfo[storynum],$userinfo[umode],$userinfo[uorder],$userinfo[thold],$userinfo[noscore],$userinfo[ublockon],$userinfo[theme],$userinfo[commentmax]);
|
Regards
Martyn. |
|
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Tue Dec 13, 2005 3:06 pm |
|
Did you ever resolve this? |
|
|
|
 |
netgoodies

|
Posted:
Tue Dec 13, 2005 4:39 pm |
|
Hi Raven
No I have not yet sorted it. I am halfway through it at the moment but left it to do others things. I will have another go at it this week and let you know. I now know thanks to hitwalker that savetheme has moved to the public folder of CNBYA.
Also I am working on this Only registered users can see links on this board! Get registered or login! if you have any ideas.
Regards
Martyn |
|
|
|
 |
netgoodies

|
Posted:
Wed Dec 28, 2005 1:09 pm |
|
Hi Raven
Sorry its taken longer than promised to get back to you but I forgot all about this problem.
Anyway here is the code so far:
Code:========================================================
Open your mainfile.php file and look for the following:
========================================================
=====
Find:
=====
function get_theme() {
global $user, $userinfo, $Default_Theme, $name, $op;
if (isset($ThemeSelSave)) return $ThemeSelSave;
if(is_user($user) && ($name != "Your_Account" && $op != "logout")) {
getusrinfo($user);
if(empty($userinfo['theme'])) $userinfo['theme']=$Default_Theme;
if(file_exists("themes/".$userinfo['theme']."/theme.php")) {
$ThemeSel = $userinfo['theme'];
} else {
$ThemeSel = $Default_Theme;
}
} else {
$ThemeSel = $Default_Theme;
}
static $ThemeSelSave;
$ThemeSelSave = $ThemeSel;
return $ThemeSelSave;
}
====================
Replace with this:
====================
function get_theme() {
global $user, $db, $user_prefix, $Default_Theme;
static $theme = false;
if ($theme)
{
return $theme;
}
$theme = (isset($_COOKIE['theme'])) ? base64_decode($_COOKIE['theme']) : false;
if (isset($_POST['themeprev']) && $theme != $_POST['themeprev'] && file_exists('themes/'.$_POST['themeprev'].'/theme.php'))
{
$theme = $_POST['themeprev'];
setcookie('theme',base64_encode($theme), 0);
if (is_user($user)) {
$user2 = explode(":", base64_decode(addslashes($user)));
$user_id = intval($user2[0]);
$info = base64_encode("$user2[0]:$user2[1]:$user2[2]:$user2[3]:$user2[4]:$user2[5]:$user2[6]:$user2[7]:$user2[8]:$theme:$user2[10]");
setcookie("user","$info",time()+2592000);
$db->sql_query("UPDATE ".$user_prefix."_users SET theme='$theme' WHERE user_id='$user_id'");
}
return $theme;
} elseif ($theme && file_exists('themes/'.$theme.'/theme.php')) {
return $theme;
}
if (!is_user($user)) {
$theme = $Default_Theme;
return $theme;
}
$user = addslashes($user);
$user2 = base64_decode($user);
$user2 = explode(":", $user2);
if($user2[9])
{
if(!file_exists('themes/'.$user2[9].'/theme.php')) {
$theme = $Default_Theme;
} else {
$theme = $user2[9];
}
} else {
$theme = $Default_Theme;
}
return $theme;
}
=====================================================================================
Open your modules/Your_Account/public/savetheme.php file and look for the following:
=====================================================================================
=====
Find:
=====
docookie($userinfo[user_id],$userinfo[username],$userinfo[user_password],$userinfo[storynum],$userinfo[umode],$userinfo[uorder],$userinfo[thold],$userinfo[noscore],$userinfo[ublockon],$userinfo[theme],$userinfo[commentmax]);
==========
change to:
==========
setcookie('theme',base64_encode($theme), 0);
docookie($userinfo[user_id],$userinfo[username],$userinfo[user_password],$userinfo[storynum],$userinfo[umode],$userinfo[uorder],$userinfo[thold],$userinfo[noscore],$userinfo[ublockon],$userinfo[theme],$userinfo[commentmax]);
=======================
##save and close files
##
##end
=======================
|
However there is still a bug, something to do with the theme cookies.
Theme preview block works ok but when you goto your account and try to change your theme it refers back to the site default theme.
If you take out Code:setcookie('theme',base64_encode($theme), 0);
| from the savetheme.php edit then goto your account and try to change your theme it does nothing.
To solve this bug the user has to log out.....clear cookies.....log in.
Theme change will then work in your account, as many time as you want until you change the theme in the preview block then it screws up again so user have to clear their cookies again.
Any ideas???
Regards
Martyn. |
|
|
|
 |
exterior
New Member


Joined: Jan 27, 2006
Posts: 6
|
Posted:
Fri Feb 17, 2006 1:07 pm |
|
hey netgoodies
work fine!
thanks |
|
|
|
 |
netgoodies

|
Posted:
Fri Feb 17, 2006 6:27 pm |
|
Hi exterior
Works fine! What without any problems?. If so let us know how you did it.
Regards
Martyn |
|
|
|
 |
shotokan
Worker


Joined: Aug 27, 2006
Posts: 172
|
Posted:
Sun Aug 27, 2006 7:15 pm |
|
Hey Haven
Where can I find the block theme preview to download? I've searched everywhere but no luch. I have phpnuke 7.3 and would like to use this block.
Thanks, |
|
|
|
 |
|