admin/styles.php workaround

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
rescbr

admin/styles.php workaround

Post by rescbr »

I had some problems with admin/style.php, and I've corrected them.
Here goes admin/style.php for you that having the same problem (no style being displayed)

Code: Select all

<?php
// Style.php Workaround by rescbr
//CHANGED
header("Content-type: text/css");
require_once("../include.php");
require_once("../lib/classes/class.user.inc.php");
$theme=get_preference(get_userid(),"admintheme");
$style="style";
if (isset($_GET['ie']))
    {
    $style.="_ie";
    }
$style .= ".css";
if (file_exists(dirname(__FILE__)."/themes/".$theme."/css/".$style))
	{
	
        //change readfile to these commands:
	//readfile(dirname(__FILE__)."/themes/".$theme."/css/".$style);
        $localfile = file_get_contents(dirname(__FILE__)."/themes/default/css/".$style);
	echo($localfile);
	
	}
else if (file_exists(dirname(__FILE__)."/themes/default/css/".$style))
	{
        // Same thing here
	//readfile(dirname(__FILE__)."/themes/default/css/".$style);
	$localfile = file_get_contents(dirname(__FILE__)."/themes/default/css/".$style);
	echo($localfile);
}
?>
That's only this.
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: admin/styles.php workaround

Post by Ted »

Hmm.  Interesting.  The only real issue I see is that file_get_contents was introduced in 4.3.0.  However, I think this could be adjusted into an if/else.  At least the majority of people will get file_get_contents and rest will get readfile.
tonypiazza
Forum Members
Forum Members
Posts: 12
Joined: Tue Dec 12, 2006 2:06 am

Re: admin/styles.php workaround

Post by tonypiazza »

I had this exact problem and tried a number of things to fix it with no success. I decided to give your workaround a try. It worked perfectly! Maybe this code should get added to the code base.

Thanks very much for posting this.

Tony
User avatar
Elijah Lofgren
Power Poster
Power Poster
Posts: 811
Joined: Mon Apr 24, 2006 1:01 am

Re: admin/styles.php workaround

Post by Elijah Lofgren »

tonypiazza wrote: I had this exact problem and tried a number of things to fix it with no success. I decided to give your workaround a try. It worked perfectly! Maybe this code should get added to the code base.

Thanks very much for posting this.

Tony
Hmm.... Any idea why this fixes the problem?

I'd be glad to apply this patch if it would be helpful to everyone and didn't have any downsides.

I'd first like to understand more about this patch though.

Thanks,

Elijah
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. :)
DanH

Re: admin/styles.php workaround

Post by DanH »

I realize that this is an old post, but for what it worths, this workaround works for me too :)
The instalation worked like a charm until I logged in in the admin area ... where I had no style. Browsed the forums like crazy after that until I stumbled on this thread :)
Thx a lot rescbr.
User avatar
Elijah Lofgren
Power Poster
Power Poster
Posts: 811
Joined: Mon Apr 24, 2006 1:01 am

Re: admin/styles.php workaround

Post by Elijah Lofgren »

Hmm... If I had more time I'd post this in the wiki somewhere. For now I'll bookmark it on my CMSMS tips page.

Thanks  :)
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. :)
SideshowBob
Forum Members
Forum Members
Posts: 80
Joined: Thu Sep 13, 2007 10:50 am

Re: admin/styles.php workaround

Post by SideshowBob »

Hi Everyone,

I appreciate this is an old thread so apologies if this isn't new info to you, however this issue still exists in V1.1.1.

This issue crops up a number of times in the forums so anything you can do to solve it or make it more visible would be a good thing.

For me (and no doubt many others) this problem is caused by my host disabling readfile for security reasons.

The solution for me is to replace readfile with echo file_get_contents

The readfile command occurs in a few files so be sure to replace all of them.

Bob
Post Reply

Return to “Tips and Tricks”