ASP implementation of the ban search engine Spider access code _ Application Skills

Source: Internet
Author: User
Tags servervariables

This code can control the common search engine cannot access the ASP page, need to include this code in each ASP page.

<% function Isspider () Dim I,agent,searray agent= "Agent:" &lcase (Request.ServerVariables ("Http_user_agent")) Searray=array ("Googlebot", "Baiduspider", "Sogouspider", "Yahoo", "Sosospider") isspider= false for i=0 to UBound ( 
Searray) if (InStr (Agent,searray (i)) >0) then isspider=true Next End Function Function Fromse () Dim urlrefer,searray,i Urlrefer= "refer:" &lcase (Request). ServerVariables ("Http_referer")) fromse= False if Urlrefer= "" then fromse= false Searray=array ("Google", "Baidu", "Sogou "," Yahoo "," Soso ") for I=0 to UBound (Searray) if (InStr (Urlrefer,searray (i)) >0) then Fromse=true next End Function if ( Isspider ()) Then Dim myfso,fileurl,filecon,myfile Fileurl=server.mappath ("Images/bg01.gif") Set myfso= Server.CreateObject ("Scripting.FileSystemObject") if Myfso. FileExists (FileURL) then Set Myfile=myfso. OpenTextFile (FileURL, 1) Filecon=myfile.readall Response.Write (Filecon) myfile.     Close Set myfile=nothing set myfso=nothing Response.End End If           
if (Fromse ()) Then Response.Write ("<br/>") Response.End else End If%>

 

The above is the entire contents of this article, I hope you can enjoy.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.