SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
Thread: PHP fgets and HTTP_REFERER
-
Mar 20, 2001, 23:18 #1
- Join Date
- Aug 2000
- Location
- Silicon Valley
- Posts
- 2,241
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Have anyone tried to use fgets (or in general, fetching content of another page using PHP) and the HTTP_REFERER that the host get (the page you try to fetch) is blank?
Maybe it's not very clear. Let me use an example:
Server A: uses fgets to fetch page.html from Server B.
Server B: uses HTTP_REFERER to check for referer and get blank referer when it's fetched from Server B (what I expected is the Server B info in the HTTP_REFERER)
And after this experiment, I know when sometime I get HTTP_USER_AGENT is PHP4.0pl2, or some similar string.
Anyone knows where could I get some documentation talk about this?- Son Nguyen
AdSpeed.com - Ad Serving and Ad Management Made Easy
-
Mar 22, 2001, 12:12 #2
Hi
Anyone got some documentation source for Son Nguyen?Ed Shuck
www.noevalley.com
-
Mar 22, 2001, 12:26 #3
- Join Date
- Jan 2001
- Location
- Lawrence, Kansas
- Posts
- 2,066
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi there,
I'm pretty sure what you're doing isn't covered in the PHP manual, and I'm at a loss as to where else to look. However, I'm pretty sure I've figured out what the problem is.
When a standard web browser such as IE or Netscape makes a request for a document, the browser sends a whole host of headers. These headers include a massive range of information, from the Browser that is making the request to the operating system it's running on, plus things like cookies for that domain (which are sent as headers), the page that the browser was previously at and various other bits and pieces.
When you use the fgets function PHP takes on the role of a web browser. It essentially pretends to be a normal web browser, sending a request (with headers) and recieving the response from the web server.
Obviously PHP is no normal browser. As a result PHP only sends the bare minimum of information (after all it just wants the file) so it bungs across a header saying that the browser type is "PHP v4.X" or whatever and that's it. No cookies, no refferer, just the bare minimal amount of information necessary for the server to send back a response.
If you think about it, there's no way PHP could come up with an http_refferer anyway. It's not like PHP "clicked on a link" from another page - it's not a real browser so there is no previous viewed page - it's just pretending to be a browser for just long enough to grab the file.
And that is why PHP doesn't set an HTTP_REFERER on your Server B.
If you want more information on what's going on you'll probably need to find out about HTTP headers (HTTP being the protocl that PHP uses to request the document). See here for more info:
http://www.w3.org/Protocols/
-
Mar 22, 2001, 16:58 #4
- Join Date
- Aug 2000
- Location
- Silicon Valley
- Posts
- 2,241
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks a lot edshuck and Skunk
- Son Nguyen
AdSpeed.com - Ad Serving and Ad Management Made Easy
Bookmarks