Reading external CSS files to detect non-absolute image path

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Reading external CSS files to detect non-absolute image path

Post by JAB Creations »

I'm considering adding the option to let visitors save a path to a cookie to a stylesheet to allow them to override my site's CSS. However browsers can be very inconsistent and my concern is the possibility of a plague of unknown 404s polluting my site's report making it difficult for me to correct my own errors if people use relative paths for images instead of absolute paths.

So what I would like to do is if a style sheet is linked in the cookie to have PHP scan for any lines with urls (for backgrounds and cursors in example) where the path does not start with url(http://. Since I am for insane backwards compatibility (and IE on Mac doesn't support URLs with quotes in the URL) using quotes for URL paths would be disallowed (so having to worry about quotes isn't something we'd have to worry about). The only way an external CSS file would be accepted is if all URLs specified follow this rule.

With the rules being that simple I would simply like to know if this is possible?
Post Reply