You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 123 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - (How to) Fixing Theme Problem (Parse Errors, etc) [ ]
 Forum FAQ  •  Search  •   •  Memberlist  •  Usergroups   •  Register  •  Profile •    •  Log in to check your private messages  •  Log in

 
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
Author Message
madman
Support Mod
Support Mod


Joined: Feb 15, 2004
Posts: 806


PostPosted: Sat Aug 07, 2004 12:46 pm Reply with quoteBack to top

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. Smile

_________________
I'm Image
Find all posts by madmanView user's profileSend private messageVisit poster's websiteYahoo MessengerMSN Messenger
Keveen
Nuke Soldier
Nuke Soldier


Joined: Aug 10, 2004
Posts: 11


PostPosted: Sun Aug 15, 2004 12:03 pm Reply with quoteBack to top

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!
Find all posts by KeveenView user's profileSend private message
shabazmo
Nuke Cadet
Nuke Cadet


Joined: Aug 15, 2004
Posts: 6


PostPosted: Sun Aug 15, 2004 8:14 pm Reply with quoteBack to top

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
Find all posts by shabazmoView user's profileSend private message
~corky~
Major
Major


Joined: Feb 13, 2004
Posts: 777


PostPosted: Fri Aug 27, 2004 12:51 pm Reply with quoteBack to top

very nice code man

_________________
Free Christian Support and Advice
[b][COLOR=Red]Web Hosting Coupons, Rebates, and Reviews[/COLOR][/b]
Find all posts by ~corky~View user's profileSend private messageVisit poster's websiteAIM AddressYahoo MessengerMSN Messenger
cliffro
Nuke Soldier
Nuke Soldier


Joined: Nov 05, 2004
Posts: 12


PostPosted: Fri Nov 05, 2004 8:57 pm Reply with quoteBack to top

All i have to say is thank you it fixed my problem
Find all posts by cliffroView user's profileSend private message
rmdort
Nuke Soldier
Nuke Soldier


Joined: Nov 06, 2004
Posts: 14


PostPosted: Fri Nov 05, 2004 9:14 pm Reply with quoteBack to top

thankx for the code MOD
Find all posts by rmdortView user's profileSend private message
tomtomtom
Nuke Cadet
Nuke Cadet


Joined: Dec 18, 2004
Posts: 3


PostPosted: Sat Dec 18, 2004 5:23 pm Reply with quoteBack to top

I tried this and it gave me some error, id appriecitate help

site is http://www.emulationz.com
Find all posts by tomtomtomView user's profileSend private message
madman
Support Mod
Support Mod


Joined: Feb 15, 2004
Posts: 806


PostPosted: Sun Dec 19, 2004 8:26 am Reply with quoteBack to top

tomtomtom wrote:
I tried this and it gave me some error, id appriecitate help site is http://www.emulationz.com

I didn't find any errors. What kind or error, actually?

_________________
I'm Image
Find all posts by madmanView user's profileSend private messageVisit poster's websiteYahoo MessengerMSN Messenger
Attica
Nuke Soldier
Nuke Soldier


Joined: Jul 03, 2005
Posts: 18


PostPosted: Sat Jul 23, 2005 8:05 pm Reply with quoteBack to top

This worked GREAT for me Smile

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??
Find all posts by AtticaView user's profileSend private message
swsop99
Nuke Cadet
Nuke Cadet


Joined: May 23, 2006
Posts: 1


PostPosted: Tue May 23, 2006 12:38 am Reply with quoteBack to top

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
Find all posts by swsop99View user's profileSend private message
princess
Nuke Cadet
Nuke Cadet


Joined: Nov 20, 2006
Posts: 8


PostPosted: Tue Nov 21, 2006 5:52 am Reply with quoteBack to top

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! Idea Cool
Find all posts by princessView user's profileSend private message
khalid
Nuke Cadet
Nuke Cadet


Joined: Dec 01, 2006
Posts: 2


PostPosted: Fri Dec 08, 2006 5:12 pm Reply with quoteBack to top

thankx for the code MOD
Find all posts by khalidView user's profileSend private messageVisit poster's website
EU_Argus
Nuke Soldier
Nuke Soldier


Joined: Jan 18, 2004
Posts: 27


PostPosted: Fri Feb 16, 2007 1:25 pm Reply with quoteBack to top

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
Find all posts by EU_ArgusView user's profileSend private message
drunkmuppet
Nuke Cadet
Nuke Cadet


Joined: Feb 27, 2007
Posts: 4


PostPosted: Tue Feb 27, 2007 11:58 am Reply with quoteBack to top

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!
Find all posts by drunkmuppetView user's profileSend private message
drunkmuppet
Nuke Cadet
Nuke Cadet


Joined: Feb 27, 2007
Posts: 4


PostPosted: Fri Mar 02, 2007 7:18 am Reply with quoteBack to top

Any update?
Find all posts by drunkmuppetView user's profileSend private message
Display posts from previous:      
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2005 phpBB Group

Ported by Nuke Cops © 2003 www.nukecops.com
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::
Powered by TOGETHER TEAM srl ITALY http://www.togetherteam.it - DONDELEO E-COMMERCE http://www.DonDeLeo.com - TUTTISU E-COMMERCE http://www.tuttisu.it
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.058 Seconds - 172 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::