Welcome Guest, Not a member yet? Register   Sign In
JS and CSS as a php file
#11

[eluser]GSV Sleeper Service[/eluser]
[quote author="Mareshal" date="1247171496"]Honestly I don't care about IE6, since firefox 2 is free and runs on every computer. Is so hard to click on a download button and spend 10 seconds to install firefox?[/quote]

most of the IE users have no choice, they work at huge mega corps. with strict IT policies. Installing firefox is not possible, or likely to get them fired.
Not caring about IE6 is a surefire way to lose out on traffic/customers
#12

[eluser]Mareshal[/eluser]
no one told them about ff
#13

[eluser]TheFuzzy0ne[/eluser]
[quote author="GSV Sleeper Service" date="1247173458"]most of the IE users have no choice, they work at huge mega corps. with strict IT policies. Installing firefox is not possible, or likely to get them fired.
Not caring about IE6 is a surefire way to lose out on traffic/customers[/quote]

If it's anything like my last place of employment, if it's locked down that tight, there's a good chance that you're not actually allowed to use the Internet at all. Tongue
#14

[eluser]skunkbad[/eluser]
[quote author="skunkbad" date="1247108322"]You should consider that IE6 can't use a compressed CSS file, and a compressed js file may have similar issues. If you're using output compression with php, you will need to turn it off. I was trying an experiment with serving up css via php, and ran into this issue, and in the end I just went back to using plain css files. If you don't care about IE6 users, then by all means, proceed.[/quote]

original comment bolded for emphasis.
#15

[eluser]slowgary[/eluser]
Hey skunk, I hope you didn't take my comment as a hate crime directed at you. There was no hate involved, and it was actually in response to Mareshal who does not need to worry about IE6 support on his own site, but cannot assume that the rest of the internet is anything like his visitor's stats.

I agree and would love to drop support for IE6, but some sites claim that as much as 25% of internet users are still using it. Fortunately for us this number is declining, but not fast enough and it still stands that some sites need to monitor stats and cater to THEIR users. If you're lucky like Mareshal, you can drop IE6 support.

I still vote that when we can, we should all make the effort to notify IE6 users that their browser is outdated and provide links to FireFox, Chrome, Opera, Safari, take your pick. We should also not spend too much time on the small stuff and just make sure that our sites WORK in IE6, not necessarily to perfection. This is, of course, ultimately up to our clients.

To the argument that "most IE users work at mega corps and have strict IT policies"... would they still be using IE6? I would expect them to be on IE8, which is a MUCH better alternative. If you're at work and stuck on IE6, you shouldn't be browsing the web - get back to work!
#16

[eluser]skunkbad[/eluser]
[quote author="slowgary" date="1247216325"]Hey skunk, I hope you didn't take my comment as a hate crime directed at you. There was no hate involved, and it was actually in response to Mareshal who does not need to worry about IE6 support on his own site, but cannot assume that the rest of the internet is anything like his visitor's stats.

I agree and would love to drop support for IE6, but some sites claim that as much as 25% of internet users are still using it. Fortunately for us this number is declining, but not fast enough and it still stands that some sites need to monitor stats and cater to THEIR users. If you're lucky like Mareshal, you can drop IE6 support.

I still vote that when we can, we should all make the effort to notify IE6 users that their browser is outdated and provide links to FireFox, Chrome, Opera, Safari, take your pick. We should also not spend too much time on the small stuff and just make sure that our sites WORK in IE6, not necessarily to perfection. This is, of course, ultimately up to our clients.

To the argument that "most IE users work at mega corps and have strict IT policies"... would they still be using IE6? I would expect them to be on IE8, which is a MUCH better alternative. If you're at work and stuck on IE6, you shouldn't be browsing the web - get back to work![/quote]

Oh, I wasn't offended. I still design/develop for IE6, and for the same reason you noted; My site, which caters to a special group of users (old ladies), still have a high percentage of IE6 in the stats.

I feel like the thread got hi-jacked a little. Maybe somebody would be kind enough to post a sample php file that serves up css or javascript. I'd do it myself, but I've been up for about 21 hours and need to get to bed.
#17

[eluser]slowgary[/eluser]
Ahh... back to the original post.

Mareshal, you can echo your JS or CSS from PHP as stated above. You should add appropriate headers as umefarooq mentioned. The easiest way to "protect" the files like the site you found is to do a check in your "css.php" or "js.php" for a defined constant, and only echo the contents if the constant is defined. So:

Code:
<?php
//js/script.php
if(defined(APPNAME))
{
     $username = "Bob Dole";
     header('Content-type: 'text/javascript');
     //this javascript uses the jQuery framework
     echo <<< JAVASCRIPT
     $(document).ready(function(){
          alert('Welcome, $username');
     }
JAVASCRIPT;
}
?&gt;
Then in your view:
Code:
&lt;?php define('APPNAME', 'skynet.v1'); ?&gt;

&lt; script type='text/javascript' src='/js/script.php' &gt;&lt; /script >

Keep in mind that this isn't any real protection as users still get those files when they view your page in full. It might stop a noob from viewing your JS or CSS directly, although plain old compression would probably be slightly better as well as have the added benefit of shrinking the download.
#18

[eluser]Mareshal[/eluser]
Hey guys, please stop your war there...

thank you for idea @slowgary, but instead of "&lt;?php define('APPNAME', 'skynet.v1'); ?&gt;" I can use "if ( ! defined('BASEPATH')) exit('No direct script access allowed');", there's no difference.

offtopic: And I was asking myself: what is the difference here between "return FALSE", "exit()", and redirect("main_page") ?




Theme © iAndrew 2016 - Forum software by © MyBB