SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: php to manage css
-
May 31, 2001, 07:56 #1
- Join Date
- May 2001
- Location
- Egypt
- Posts
- 79
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
php to control the view of css
Hello,
I want to create a php file to check the visitor browser and version and upon it view a certain css
In my pages I have :
Code:<style type="text/css" media="all">@import "/css/css.php?1";</style>
Code:<?php if(ereg("\?1$", $REQUEST_URI)) { if (strstr (getenv('HTTP_USER_AGENT'), 'MSIE')) { include "/css/ie.css"; } elseif (strstr (getenv('HTTP_USER_AGENT'), 'Netscape')) { include "/css/ns.css"; } elseif (strstr (getenv('HTTP_USER_AGENT'), 'opera')) { include "/css/opera.css"; } else { include "/css/others.css"; }} ?>
Also is it possible to prevent users from downloading the css if accessed css.php?1 ?Last edited by mahmoud; May 31, 2001 at 08:03.
Mahmoud
-
May 31, 2001, 08:52 #2
- Join Date
- Jan 2001
- Location
- Your basement
- Posts
- 192
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Is there a problem with your code as it is? Does it not work?
Here is what I use:
PHP Code:<?
if(eregi("msie.[4|5]",getenv('HTTP_USER_AGENT')))
$browser = "msie";
// Netscape Navigator?
else if(eregi("nav",getenv('HTTP_USER_AGENT')) or eregi("moz",getenv('HTTP_USER_AGENT')))
$browser = "nav";
else
$browser = "other";
if($browser=="msie")
print "<LINK REL=StyleSheet HREF=\"ie.css\" TYPE=\"text/css\">";
else
print "<LINK REL=StyleSheet HREF=\"ns.css\" TYPE=\"text/css\">";
?>Overgrow the Government: The Edge Forums
presented by Overgrow Marijuana Magazine
*warning: adult content
-
Jun 1, 2001, 22:42 #3
- Join Date
- May 2001
- Location
- Egypt
- Posts
- 79
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
- The code works, but for all versions of IE, NS ..
Users using IE 6 won't C your style ie.css and will C ns.css
I want to add ( =<4 ) for IE
and ( =<6 ) .. so I won't change every time there is a new version
- And Also the users can C the stylesheet
if they went to the php file ..Mahmoud
Bookmarks