Phorce
Phorce

Reputation: 2664

Check if user is accessing from a browser

Recently, a friend of mine posted their email address using the mailto tag and has received a lot of spam bots because of this.

I'm just wondering whether or not it is possible to detect whether a person is using a "proper" browser to access the webpage, and, if they are, display the email address, if they are not, then do not display their email address?

I know you can get what someones email address is using HTTP_USER_AGENT but I don't really want to have to compile an array of the capable browsers and just wondered whether or not there is a pre-defined function in PHP.

Any help would be greatly appreciated.

P.S. I'm not asking for specific code, references will do.

Upvotes: 0

Views: 224

Answers (2)

Andrew FigPope
Andrew FigPope

Reputation: 93

While you could filter browsers by UserAgent from listings such as user-agents.org or use the built in detection through the get-browser method, you're still likely to get your address picked up by spiders if it's displayed in the raw html, due to UserAgent Spoofing. You are better off using javascript to display a mailto link, using window.open("mailto:[email protected]") with whatever other parameters you want to have included, and triggering using <a onclick="jsfunction" href="javascript:void(0);">.

EDIT: Or dynamically forming the link using a script on page load.

Upvotes: 1

Soundz
Soundz

Reputation: 1300

no, parse the array or leave it

E: Regarding your spam bots, assembly the emailadresse for the mailto with javascript, works fine for me and i never got spammed

Upvotes: 2

Related Questions