Welcome Guest, Not a member yet? Register   Sign In
Get the origin of files via requested <link>
#1

[eluser]seantaylor[/eluser]
I have a service that generates text files based on the url. So http://mysite.com/service/load/file1 would generate something useful, the point being text files can be generated dynamically based on url segements.

I can tell where the request is coming from when a user clicks a link using the $_SERVER['HTTP_REFERER'] method however this is not how I need the service to work. Instead I need a user to embed a <link> tag in their html to call the service in the style of
<link rel="stylesheet" href="http://mysite.com/service/load/file1" type="text/css"/>

Is there any way to tell when a file is requested through <link> where the request is coming from? I need this information to verify that the domain is privileged to access that file.
#2

[eluser]pickupman[/eluser]
I maybe wrong on this, but I don't think you can differentiate between the two. Either way, the browser is going to create a HTTP request in the same way either direct link or via a html tag. AJAX request do have a different header.
#3

[eluser]seantaylor[/eluser]
One thing I forgot to mention is that <link> does not seem to generate http referrer data (according to my tests) so I cannot check for this. Is there perhaps another server variable that is generated, or could I peer into the header (and how would you do that with CI?)
#4

[eluser]pickupman[/eluser]
Just var_dump() the $_SERVER array to see what you've got to work with. Or print get_headers().
#5

[eluser]seantaylor[/eluser]
Ok I tried the var_dump(). It actually revealed that HTTP_REFERER contains the address of the site that. Thanks for the help!




Theme © iAndrew 2016 - Forum software by © MyBB