first of all big thanks to marcelg for the spider and mobile code (included here)
<%
userAgent = request.serverVariables("HTTP_USER_AGENT")
browser_Name = "Unbekannt"
browser_Ncheck = "false"
browser_Version = 0
browser_Vcheck = "false"
browser_Spider = 0
browser_Mobile = 0
browser_pass = 0
'############### Mozilla
If inStr(userAgent,"Mozilla") > 0 then
browser_Name = "Mozilla"
browser_Ncheck = "ok"
browser_Version = mid(userAgent,inStr(userAgent,"rv")+3,3)
browser_Vcheck = "ok"
browser_Spider = 0
browser_Mobile = 0
browser_pass = 0
end If
'############### Mozilla Firebird
If inStr(userAgent,"Firebird") > 0 then
browser_Name = "Mozilla Firebird"
browser_Ncheck = "ok"
browser_Version = mid(userAgent,inStr(userAgent,"Firebird")+9,4)
browser_Vcheck = "ok"
browser_Spider = 0
browser_Mobile = 0
browser_pass = 0
end If
'############### Mozilla Firefox
If inStr(userAgent,"Firefox") > 0 then
browser_Name = "Mozilla Firefox"
browser_Ncheck = "ok"
browser_Version = mid(userAgent,inStr(userAgent,"Firefox")+8,3)
browser_Vcheck = "ok"
browser_Spider = 0
browser_Mobile = 0
browser_pass = 1
end If
'############### Mozilla K-Meleon
If inStr(userAgent,"K-Meleon") > 0 then
browser_Name = "Mozilla K-Meleon"
browser_Ncheck = "ok"
browser_Version = mid(userAgent,inStr(userAgent,"K-Meleon")+9,5)
If mid(browser_Version,4,1) = "" then
browser_Version = mid(userAgent,inStr(userAgent,"K-Meleon")+9,3)
end If
browser_Vcheck = "ok"
browser_Spider = 0
browser_Mobile = 0
browser_pass = 0
end If
'############### Mozilla Phoenix
If inStr(userAgent,"Phoenix") > 0 then
browser_Name = "Mozilla Phoenix"
browser_Ncheck = "ok"
browser_Version = mid(userAgent,inStr(userAgent,"Phoenix")+8,3)
browser_Vcheck = "ok"
browser_Spider = 0
browser_Mobile = 0
browser_pass = 0
end If
'############### Internet Explorer
If inStr(userAgent,"MSIE") > 0 then
browser_Name = "Internet Explorer"
browser_Ncheck = "ok"
browser_Version = mid(userAgent,inStr(userAgent,"MSIE")+5,4)
If mid(browser_Version,4,1) = ";" then
browser_Version = mid(userAgent,inStr(userAgent,"MSIE")+5,3)
end If
If browser_Version >= 4 then
browser_Vcheck = "ok"
browser_pass = 1
else
browser_Vcheck = "false"
browser_pass = 0
end if
browser_Spider = 0
browser_Mobile = 0
end If
'############### Crazy Browser
If inStr(userAgent,"Crazy") > 0 then
browser_Name = "Crazy Browser"
browser_Ncheck = "ok"
browser_Version = mid(userAgent,inStr(userAgent,"Crazy Browser")+14,5)
browser_Vcheck = "ok"
browser_Spider = 0
browser_Mobile = 0
browser_pass = 0
end If
'############### Galeon
If inStr(userAgent,"Galeon") > 0 then
browser_Name = "Galeon"
browser_Ncheck = "ok"
browser_Version = mid(userAgent,inStr(userAgent,"Galeon")+7,6)
browser_Vcheck = "ok"
browser_Spider = 0
browser_Mobile = 0
browser_pass = 0
end If
'############### Konqueror
If inStr(userAgent,"Konqueror") > 0 then
browser_Name = "Konqueror"
browser_Ncheck = "ok"
browser_Version = mid(userAgent,inStr(userAgent,"Konqueror")+10,5)
If ( mid(browser_Version,2,1) = ";" or mid(browser_Version,2,1) = ")" )then
browser_Version = mid(userAgent,inStr(userAgent,"Konqueror")+10,1)
end If
If ( mid(browser_Version,4,1) = ";" or mid(browser_Version,4,1) = ")" )then
browser_Version = mid(userAgent,inStr(userAgent,"Konqueror")+10,3)
end If
browser_Vcheck = "ok"
browser_Spider = 0
browser_Mobile = 0
browser_pass = 0
end If
'############### Opera
If inStr(userAgent,"Opera") > 0 then
browser_Name = "Opera"
browser_Ncheck = "ok"
browser_Version = mid(userAgent,inStr(userAgent,"Opera")+6,4)
browser_Vcheck = "ok"
browser_Spider = 0
browser_Mobile = 0
browser_pass = 0
end If
'############### Safari
If inStr(userAgent,"Safari") > 0 then
browser_Name = "Safari"
browser_Ncheck = "ok"
browser_Version = mid(userAgent,inStr(userAgent,"Safari")+7,5)
browser_Vcheck = "ok"
browser_Spider = 0
browser_Mobile = 0
browser_pass = 0
end If
'############### Lotus-Notes
If inStr(userAgent,"Lotus-Notes") > 0 then
browser_Name = "Lotus Notes"
browser_Ncheck = "ok"
browser_Version = mid(userAgent,inStr(userAgent,"Lotus-Notes")+12,3)
browser_Vcheck = "ok"
browser_Spider = 0
browser_Mobile = 0
browser_pass = 0
end If
'############### Lynx
If inStr(userAgent,"Lynx") > 0 then 'Lynx
browser_Name = "Lynx"
browser_Ncheck = "ok"
browser_Version = mid(userAgent,inStr(userAgent,"Lynx")+5,5)
browser_Vcheck = "ok"
browser_Spider = 0
browser_Mobile = 0
browser_pass = 0
end If
'############### Netscape
If inStr(userAgent,"Netscape") > 0 or inStr(userAgent,"Nav") > 0 then
browser_Name = "Netscape"
browser_Ncheck = "ok"
browser_Version = mid(userAgent,inStr(userAgent,"Netscape")+5,5)
browser_Vcheck = "ok"
browser_Spider = 0
browser_Mobile = 0
browser_pass = 0
end If
'############### Spider
If inStr(userAgent,"bot") > 0 or _
inStr(userAgent,"perl") > 0 or _
inStr(userAgent,"java") > 0 or _
inStr(userAgent,"libw") > 0 or _
inStr(userAgent,"crawl") > 0 or _
inStr(userAgent,"DA 7") > 0 or _
inStr(userAgent,"DA 6") > 0 or _
inStr(userAgent,"DA 5") > 0 or _
inStr(userAgent,"DA 4") > 0 or _
inStr(userAgent,"DA 3") > 0 or _
inStr(userAgent,"DA 2") > 0 or _
inStr(userAgent,"DA 1") > 0 or _
inStr(userAgent,"download") > 0 then
browser_Name = "Spider"
browser_Ncheck = "false"
browser_Version = 0
browser_Vcheck = "false"
browser_Spider = 1
browser_Mobile = 0
browser_pass = 0
end if
'############### Mobile
If inStr(userAgent,"pda") > 0 or _
inStr(userAgent,"wap") > 0 then
browser_Name = "Mobile"
browser_Ncheck = "false"
browser_Version = 0
browser_Vcheck = "false"
browser_Spider = 0
browser_Mobile = 1
browser_pass = 0
end if
'############### OS
If inStr(userAgent,"Win") > 0 then
browser_OS = "Windows"
browser_OScheck = "ok"
elseIf inStr(userAgent,"Mac") > 0 then
browser_OS = "Macintosh"
browser_OScheck = "warn"
elseIf inStr(userAgent,"Linux") > 0 then
browser_OS = "Linux"
browser_OScheck = "warn"
elseIf inStr(userAgent,"Unix") > 0 then
browser_OS = "Unix"
browser_OScheck = "warn"
elseIf inStr(userAgent,"SunOS") > 0 then
browser_OS = "Sun Solaris"
browser_OScheck = "warn"
elseIf inStr(userAgent,"FreeBSD") > 0 then
browser_OS = "FreeBSD"
browser_OScheck = "warn"
else
browser_OS = "Unbekannt"
browser_OScheck = "warn"
end If
%>
<!--#INCLUDE FILE="browser_check.asp" -->
<%
<font color="red">if browser_pass = 1 or Request.QueryString("site") = "view" then</font id="red">
<font color="green">' ### content of the page to see it</font id="green">
<font color="red">elseif browser_Spider = 0 and browser_Mobile = 0 then</font id="red">
<font color="navy">Response.Redirect "browser_check_result.asp?site=error"</font id="navy">
<font color="green">' ### call error page if browser don't pass the test</font id="green">
<font color="red">elseif browser_Spider = 0 and browser_Mobile = 1 then</font id="red">
<font color="navy">Response.Redirect "browser_check_result.asp?site=mobile"</font id="navy">
<font color="green">' ### call mobile page if browser is a mobile</font id="green">
else
<font color="navy">Response.Redirect "browser_check_result.asp?site=spider"</font id="navy">
<font color="green">' ### call spider page if browser is a spider or someone want to pass it manualy</font id="green">
end if
<font color="red">if Request.QueryString("site") = "error" then</font id="red">
<font color="navy">Response.Redirect "browser_check_result.asp?site=error"</font id="navy">
<font color="green">' ### call error page to test it --> enter default.asp?site=error to see it</font id="green">
end if
%>
<!--#INCLUDE FILE="config.asp"-->
<!--#INCLUDE FILE="inc_header.asp" -->
<!--#INCLUDE FILE="browser_check.asp" -->
<%
select case Request.QueryString("site")
<font color="red">'############### browser check result beginn</font id="red">
case "error"
%>
<br>
page can not be displayed
to see the page anyway (without warenty) <a href="default.asp?site=view">click here</a>
<TABLE cellSpacing=3 cellPadding=3 border=0>
<TBODY>
<tr><td width="200">Browser Details:</td><td><% = request.serverVariables("HTTP_USER_AGENT")%></td></tr>
<tr><td>Browser Name:</FONT></td><td><img src="icon_<% = browser_Ncheck %>.gif" width="15" height="15" border="0" align="absmiddle"> <% = browser_Name %></td></tr>
<tr><td>Browser Version:</FONT></td><td><img src="icon_<% = browser_Vcheck %>.gif" width="15" height="15" border="0" align="absmiddle"> <% = browser_Version %></td></tr>
<tr><td>Betriebssystem:</FONT></td><td><img src="icon_<% = browser_OScheck %>.gif" width="15" height="15" border="0" align="absmiddle"> <% = browser_OS %></td></tr>
</TBODY>
</TABLE>
<br>
<br>
<%
<font color="red">'############### browser check result end
'############### browser check mobile beginn</font id="red">
case "mobile"
%>
page can not been displayed for mobile browser!
<%
<font color="red">'############### browser check mobile end
'############### browser check spider beginn</font id="red">
case "spider"
'show nothing
<font color="red">'############### browser check spider end</font id="red">
case else
'show nothing
end select
%>
--> users who can not pass the check can send me a mail with their client browser version and i can test it and set variable to "pass"