Forum Moderators: coopster

Message Too Old, No Replies

empty $_SERVER['HTTP_USER_AGENT']?

         

JavaReb

8:30 pm on Mar 19, 2006 (gmt 0)

10+ Year Member



edited to add:
actually its not set, rather than empty in this case.

also, this doesnt happen all the time, just occasionally.

On several of my pages using this value, although Im not checking if it exists (which i think is most of my problem). When the function is called that uses this value, i get error log email, reporting that
"Undefined index: HTTP_USER_AGENT"

on the line number that the $_SERVER variable is used.

What should I do if something (web crawler possibly?) is hitting my website and not reporting a user agent. Im tempted to just do a redirect if this value isnt set.

comments?

DanA

8:42 pm on Mar 19, 2006 (gmt 0)

10+ Year Member



Empty UAs are quite common.
They may be visitors with anonymizing utilities, robots, php/asp reading your files, proxies, link checkers...

JavaReb

8:47 pm on Mar 19, 2006 (gmt 0)

10+ Year Member



reading my files? what do you mean?

All the more reason, i think i should send them away to some obsure website or send them back some jibberish characters.

Probably web crawlers looking for email address or any number of other things.

DanA

9:02 pm on Mar 19, 2006 (gmt 0)

10+ Year Member



file("yoururl"); will read the page and send an empty UA by default, this is sometimes done to filter your page, remove javascript, flash or java.
User Agent switcher will allow any user to send an empty UA this is why I don't redirect (though for the pages displaying email contact, I redirect to a form asking for a confimation - most bots don't follow a redirection and none confirms)

JavaReb

9:21 pm on Mar 19, 2006 (gmt 0)

10+ Year Member



so somone with php on another server can read the php source on my web server? surely not

as for bots etc that arent sending a user agent, instead of redirecting, maybe ill just echo a few characters then exit();

:=)

DanA

9:28 pm on Mar 19, 2006 (gmt 0)

10+ Year Member



They can't read the php source but are interested in the html served.
You can send a message explaining why the page won't be served.

Anyango

6:31 am on Mar 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if u dont serve content based on the decission that whether the user agent string was empty or not, trust u me u are going to loose hundreds of potential visitors.