View Full Version : Way to include CSS from a non-public folder?
Eric Lim 12-13-2004, 09:01 PM I'm not even sure if this is possible, but I want to include several CSS from a protected directory (permission being 700).
I'm writing my scripts using CGI-version PHP so that the running process belongs to my real UID. If I'm using
<code>
<link href="styles/styles.css" rel="stylesheet" type="text/css" />
</code>
It will not be able to access the stylesheets since the folder is protected.
If I use require('styles/styles.css'), the CSS code will be shown along with the HTML.
Do you think if it's a way to include all the CSS w/o letting anybody to view/download?
This is not possible. CSS needs to be includedin document source.
CSS is applied clientside so if the client cannot get the data, they cannot apply it. And if the client can get it, they can view it. If you want to "hide" it, best bet is to run it through some obfuscator.
JPortal 12-14-2004, 01:27 AM Originally posted by mkc
CSS is applied clientside so if the client cannot get the data, they cannot apply it. And if the client can get it, they can view it. If you want to "hide" it, best bet is to run it through some obfuscator.
You could use php...
CSS src = /path/to/css.php?css_file=main_styles
The client can still view the data...
oh my lord..
yes you can use require, in the css file you just have to include the <style> </style> tags in the beginning / end, and include it in the header tag on the document.. This is how I include all my stylesheet files...
VolkNet 12-15-2004, 03:27 PM I have a simple solution that i think would work well. what you can do is in the head of your html include code like this:
<style>
<?php include 'style.dat' ?>
</style>
inside that .dat file have the information such as a{ ... };
and write it as if it were an internally included css document.
Maybe that will work, maybe not. Just a thought tho.
azizny 12-15-2004, 06:56 PM Originally posted by VolkNet
I have a simple solution that i think would work well. what you can do is in the head of your html include code like this:
<style>
<?php include 'style.dat' ?>
</style>
inside that .dat file have the information such as a{ ... };
and write it as if it were an internally included css document.
Maybe that will work, maybe not. Just a thought tho.
Nope...
Unless the server knows how to treat the .dat file... at which it will become the same as above..
You can never do such thing... we had any discussions about it (search will show them)..
Peace,
WO-Jacob 12-17-2004, 08:51 AM It's actually really easy.
Just make it a php file, and check the referer. If it's not from your site, don't give it out :)
inimino 12-19-2004, 07:21 AM The questio is "can I make a file available to browsers and simultaneously make it unavailable to users."
The answer is simple: "no".
Originally posted by inimino
The questio is "can I make a file available to browsers and simultaneously make it unavailable to users."
The answer is simple: "no".
the last time i checked, you can...
fpassthru
by the way, i just tried what I said
<style>
<?PHP include("../wtf/style.css"); ?>
</style>
and it worked.
http://www.license2cruise.com/test.php
../wtf is under public_html.
I don't know why everyone else seems to not understand this?
include includes a file, text and all, and then parses whatever is included.. if you have <style> before and after, it isn't possible for it not to understand.. unless your apache doesn't like you.
inimino 12-19-2004, 08:29 PM mg-
fpassthru() is a php function for sending a file to a client in response to an HTTP request.
In this regard it is identical to every other technique described so far on this page, and is irrelevant to the issue at hand for the same reason:
The HTTP server sees an HTTP request. The request will either be honored or not.
Perhaps you misunderstood the original question, or only read the title and not the entire original post.
Eric Lim asked:
Do you think if it's a way to include all the CSS w/o letting anybody to view/download?
His question about using a protected directory was a means to that end.
The page you link to simply returns the CSS inline with the HTML document to the browser directly. Thus it is a simple matter of a menu option in most browsers to view the source of the page, including the CSS, so the "solution" you provide simply has nothing to do with the question being asked here.
oh my mistake then -_-
i read it differentely
inimino 12-19-2004, 10:28 PM All's well that ends well :)
|