| Author |
Message |
madman
Support Mod


Joined: Feb 15, 2004
Posts: 806
|
Posted:
Sat Aug 07, 2004 12:46 pm |
  |
I saw many people getting problem with not-existent theme and generate parse error. This is one of a solution: Open mainfile.php and find this block of code:
| Code: |
function get_theme() {
global $user, $cookie, $Default_Theme;
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;
}
return($ThemeSel);
} |
Replace with:
| Code: |
function get_theme() {
global $user, $cookie, $Default_Theme, $forum_admin, $inside_mod, $mad_known_good_theme;
if (isset($mad_known_good_theme) && preg_match('/^[a-zA-Z0-9_-]+$/', "$mad_known_good_theme")) {
return $mad_known_good_theme;
}
if (!preg_match('/^[a-zA-Z0-9_-]+$/', $Default_Theme)) $Default_Theme = '';
$ThemeSel = $Default_Theme;
$crpath = '';
if (isset($forum_admin) && ($forum_admin == 1)) $crpath = '../../../';
else if (isset($inside_mod) && ($inside_mod == 1)) $crpath = '../../';
if (is_user($user)) {
if (!is_array($user)) {
$t_cookie = addslashes($user);
$t_cookie = base64_decode($t_cookie);
$t_cookie = explode(":", $t_cookie);
} else {
$t_cookie = $user;
}
$theme_file = (isset($t_cookie[9]) && preg_match('/^[a-zA-Z0-9_-]+$/', $t_cookie[9])) ? "themes/".$t_cookie[9]."/theme.php" : '';
if (($theme_file != '') && file_exists("$crpath$theme_file")) {
$ThemeSel = $t_cookie[9];
} else {
$ThemeSel = $Default_Theme;
}
}
$theme_file = (($ThemeSel != '') && preg_match('/^[a-zA-Z0-9_-]+$/', $ThemeSel)) ? "themes/".$ThemeSel."/theme.php" : '';
if (($theme_file == '') || !file_exists("$crpath$theme_file")) {
$theme_found = false;
$hdir = @opendir($crpath."themes");
if ($hdir) {
while ($file = @readdir($hdir)) {
if ($file == '.') continue;
if ($file == '..') continue;
if (!is_dir($crpath."themes/".$file)) continue;
if (!preg_match('/^[a-zA-Z0-9_-]+$/', $file)) continue;
if (!file_exists($crpath."themes/".$file."/theme.php")) continue;
$theme_found = true;
$ThemeSel = $file;
break(1);
}
@closedir($hdir);
}
if ($theme_found == false) { die('fatal error: cannot find any valid themes!'); }
}
$mad_known_good_theme = $ThemeSel;
return $ThemeSel;
} |
These replacement code will evaluate for valid user theme, then check for existing themes. if not exists, use first theme that found in theme directory will be used. If any of themes cannot be found (your theme directory is empty or containing no valid themes), it will be terminated. This code is more secure (bad guys cannot play with relative paths from cookie), and won't generate non-existing theme error when you rename/delete existing themes. This code also speed optimized.  |
_________________ I'm  |
|
      |
 |
Keveen
Nuke Soldier


Joined: Aug 10, 2004
Posts: 11
|
Posted:
Sun Aug 15, 2004 12:03 pm |
  |
A beautiful piece of code - I haven't personally got a clue yet what exactly it all means but it instantly fixed my problem - I could not get access to my Admin panel when I installed a faulty theme. an excellent idea because it is logical to make the settings return to their defaults when there is a problem.
It works, that's what counts! |
|
|
   |
 |
shabazmo
Nuke Cadet


Joined: Aug 15, 2004
Posts: 6
|
Posted:
Sun Aug 15, 2004 8:14 pm |
  |
I love you for posting this, But when i did it gave me a phpnuke logo and said we are having trouble with the mysql server, sorry for the touble |
|
|
   |
 |
~corky~
Major


Joined: Feb 13, 2004
Posts: 777
|
Posted:
Fri Aug 27, 2004 12:51 pm |
  |
|
       |
 |
cliffro
Nuke Soldier


Joined: Nov 05, 2004
Posts: 12
|
Posted:
Fri Nov 05, 2004 8:57 pm |
  |
All i have to say is thank you it fixed my problem |
|
|
   |
 |
rmdort
Nuke Soldier


Joined: Nov 06, 2004
Posts: 14
|
Posted:
Fri Nov 05, 2004 9:14 pm |
  |
|
   |
 |
tomtomtom
Nuke Cadet


Joined: Dec 18, 2004
Posts: 3
|
Posted:
Sat Dec 18, 2004 5:23 pm |
  |
|
   |
 |
madman
Support Mod


Joined: Feb 15, 2004
Posts: 806
|
Posted:
Sun Dec 19, 2004 8:26 am |
  |
I didn't find any errors. What kind or error, actually? |
_________________ I'm  |
|
      |
 |
Attica
Nuke Soldier


Joined: Jul 03, 2005
Posts: 18
|
Posted:
Sat Jul 23, 2005 8:05 pm |
  |
This worked GREAT for me
but now i got an error stating:
| Quote: |
| Fatal error: Call to undefined function: adminblock() in /home/www/lordattica.hollosite.com/mainfile.php on line 467 |
Running nuke platinum 7.6.
any ideas why?? |
|
|
   |
 |
swsop99
Nuke Cadet


Joined: May 23, 2006
Posts: 1
|
Posted:
Tue May 23, 2006 12:38 am |
  |
I found this and it seems exactly what I needed to fix my issue. I did as it says in the post and figured it would work. It seems to have fixed the original issue, except I am also getting a parse error. Is there any other way to fix this issue? Or any other help would be greatly appreciated.
http://fugenskremin.org/php/index.php
Parse error: parse error, unexpected T_GLOBAL in /home/content/f/u/g/fugenskremin/html/php/mainfile.php on line 2 |
|
|
   |
 |
princess
Nuke Cadet


Joined: Nov 20, 2006
Posts: 8
|
Posted:
Tue Nov 21, 2006 5:52 am |
  |
one way i do it, ( all the time actually)
Because I get into this trouble alot! I just delete the (recently installed problem)theme and take one of the original ones and copy it , then rename it to the one you deleted, so essentially you have two of the same theme just named different things. I always get stuck in the white blank page because apparently the theme does not fit! LOL. But with this little trick I can bail myself out in about 60 secs! You guys rock!  |
|
|
   |
 |
khalid
Nuke Cadet


Joined: Dec 01, 2006
Posts: 2
|
Posted:
Fri Dec 08, 2006 5:12 pm |
  |
|
    |
 |
EU_Argus
Nuke Soldier


Joined: Jan 18, 2004
Posts: 27
|
Posted:
Fri Feb 16, 2007 1:25 pm |
  |
Hi all,
the code may work, I have had it on to my mainfile, but couldn't test it in deep.
What it does not cover is the forum admin panel, there it comes up with a "no valid theme" error message and admin panel of forum doesn't stat.
Cheers
=EU=Argus |
|
|
   |
 |
drunkmuppet
Nuke Cadet


Joined: Feb 27, 2007
Posts: 4
|
Posted:
Tue Feb 27, 2007 11:58 am |
  |
| Quote: |
Hi all,
the code may work, I have had it on to my mainfile, but couldn't test it in deep.
What it does not cover is the forum admin panel, there it comes up with a "no valid theme" error message and admin panel of forum doesn't stat.
Cheers
=EU=Argus |
Exactly what he said. I got everything working except the admin panel. Can't access that! |
|
|
   |
 |
drunkmuppet
Nuke Cadet


Joined: Feb 27, 2007
Posts: 4
|
Posted:
Fri Mar 02, 2007 7:18 am |
  |
|
   |
 |
|
|