Forum Moderators: coopster

Message Too Old, No Replies

Get curent site hostname

not the current script's hostname, but the site that's running it

         

doodlebee

1:07 pm on Sep 17, 2009 (gmt 0)

10+ Year Member



Hey all - had a question for you.

I'm running a WordPress site that, unfortunately, has an issue: someone is stealing my stylesheet. I've done the whole "cease and desist" thing, but they aren't. Basically, their file is linking *directly* to my stylesheet - not only stealing my code, but also my bandwidth.

Now, when this is done with images, I can simply replace the image, and give *my* site the new filename. however, with WordPress, you can't do that. The file *has* to be named "style.css".

So what I'm attempting to do is us a combination of a dynamic stylesheet and @import. My style.css file has "@import url('newstyle.php')"

"newstyle.php" is *supposed* to have a hceck: if the site using the stylesheet is mine, then display correctstyle.css... but if the site using the stylesheet is *not* my site, then display "funstyle.css".

My issue is this: I can't figure out how to check if the site is mine or not. Use of $_SERVER['HTTP_HOST'] (and similar) returns the host of the *script* - which *is* my site, therefore it comes back as valid. This will not do. Is there a way to check the domain name of the site's server *without* using the source of the script?

Before you say anything - yes, I know I could probably prevent the whole thing with .htaccess. But dang - where's the fun in that?

leadegroot

8:57 pm on Sep 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try checking $_SERVER['HTTP_REFERER'] rather than http_host.
The classic solution is
if blank or myhost then display, else fail
(Many people supply a blank referer, but a different referer is a dead give away.)
Note that you have to check this *within* the css file, not the php file, as obviously the referer for the php file *will* correctly be a 3rd party much of the time.

Hope it helps :)

doodlebee

9:28 pm on Sep 17, 2009 (gmt 0)

10+ Year Member



Thanks Lead :)

Actually, Id' tried that. The Referrer is the legtimate site. I *think* the reason is because I'm @import-ing the script in the css file, so the referer *is* the legitimate site (of that makes any sense?) The file, however *has* to be named "style.css" - so I can't change it to "style.php" or anything.

However, this line of thinking has given me an idea... I think if I make "style.css" just blank, then the problem is basically solved. Then I can call in a different stylesheet to pull in the actual styles on my site. I could even make *that* one the .php styleshet, and then the referer won't be the originating site, just in case they try another level of theft :)

Dang - such a simple solution LOL - sometimes I need to drink more coffee in the morning.

leadegroot

2:20 am on Sep 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



style.css can be blank, and then you edit the header.php file so it also pulls a different file eg my.css
Just because wordpress is going to call a style.css file doesn't mean you have to use it :)

Edit: Doh! Read entire post before replying! :) Would you pas the coffee pot over here? :)