Page 1 of 1

admin/styles.php workaround

Posted: Fri Mar 10, 2006 7:45 pm
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.

Re: admin/styles.php workaround

Posted: Sat Mar 11, 2006 1:14 pm
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.

Re: admin/styles.php workaround

Posted: Sat Jan 13, 2007 10:11 pm
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

Re: admin/styles.php workaround

Posted: Mon Mar 12, 2007 4:17 pm
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

Re: admin/styles.php workaround

Posted: Thu Mar 22, 2007 12:38 am
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.

Re: admin/styles.php workaround

Posted: Thu Mar 22, 2007 12:42 am
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  :)

Re: admin/styles.php workaround

Posted: Thu Sep 13, 2007 11:01 am
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