Jump to content

Is there a way to detect running a file from a local drive.


brynkaufman

Recommended Posts

When I save any PHP file to my local PC, I see it runs with a local URL, such as file:///C:, however, PHP still feels it is running on my web server.  All the $_SERVER elements come up just as if I was running it from my web server.  I need to be able to detect one is running the file from their local PC. 

 

Any way to do that?

 

If you are wondering why I would want to do it the reason is my local board of Realtors is restricting what can be shown on my Website, but they have no restrictions if the file is not on my Website, another words on someone’s local PC.

 

Link to comment
Share on other sites

I don't really understand what you mean by the last paragraph, and you've piqued my curiosity, so a more lengthy explanation would be appreciated, but have you tried checking $_SERVER['HTTP_HOST'] to check if it's being run off localhost, an IP address or a website or what?

Link to comment
Share on other sites

Yes, I tried $_SERVER['HTTP_HOST'] and even when the file is located on my C: drive the host is my domain www.oahure.com.

 

Regarding the restrictions the Board of Realtors in my area said we have 60 days to stop showing homes that are in escrow, withdrawn, and expired on our Website.  This is very bad for buyers and sellers as not having this information stops them from having a complete picture of the market.  The Board makes these restrictions to try and force people to use Realtors to get this information.

 

The way the rule is written it says on my Website.  So if it is not on my Website, perhaps in an Email, local file downloaded, spreadsheet, etc.., then they do not have the right to censor it.

 

I found that saving a file to the local C: drive looks and works great even though it is not on my server.  The challenge is I need to have code in that file that tells me where it is being run from.  If it is run from my Website, then the information the board wants blocked is blocked, but if it is run locally then I can show it.

 

I did find that Javascript could correctly identify the URL using this simple command $URL = document.location.href.  However, there is no easy way to pass that information to PHP to design my page accordingly.

 

Link to comment
Share on other sites

Unfortunately for you, your "website" is different to your "web host", so even if you don't store it on your server, you're still showing it on your website to the public. Just saving it locally doesn't make it so that it follows the rules.

 

And if you were taken to legal proceedings, the judge would look at the intent of the law, and declare that you're in violation

 

And as for passing Javascript to PHP, there's no easy way to do it, but if you use AJAX (I recomend using the JQuery framework to make AJAX easier) you can parse the location to a PHP file, and then display the output of your PHP File

Link to comment
Share on other sites

I am not sure what you mean by my Website is different to your web host, but it would never get to the point of being in front of a judge. 

 

My logic is I am allowed to send it to them in any format I want such as xls, pdf, doc, txt, Email, html, jpg etc.  So why can’t I send it to them in a mht file?  From a functional and ease of programming standpoint, the mht file works best for me. 

 

The rule is I am not allowed to display it on my Website.  As long as it is not on my Website they have no other rules covering what file formats or technology I can use to send it to them.  The rule does not say I am not allowed to use data from my Website database, only that it can’t be displayed on my Website.

 

AJAX is a possibility, but that would require redoing the entire page, and I am trying to find a solution without redoing the entire page as the page works great. 

 

 

AJAX is a possibility, but that would require redoing the entire page, and I am trying to find a solution without redoing the entire page as the page works great.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.