· 4 years ago · Mar 18, 2021, 11:22 AM
1<%
2
3' Use: <!--#include virtual="cloudfilt.asp" -->
4
5varCloudFiltEnabled = True ' enable or disable CouldFilt Server Side
6
7If varCloudFiltEnabled = True Then
8
9
10 ' -- CONFIGURATION --
11
12 varCloudFiltKey = "Lxxxxxxxxxxxxxxxxxx2"
13 varCloudFiltRef = "yxxxxxxxxxxxxxxxxxxw"
14 varCloudFiltNumber = "12345"
15
16 ' -- CONFIGURATION --
17
18 varCloudFiltAPIServer = "api" & varCloudFiltNumber & ".cloudfilt.com"
19 varCloudScriptServer = "srv" & varCloudFiltNumber & ".cloudfilt.com"
20
21 %>
22 <script async src="https://<%=varCloudScriptServer%>/analyz.js?render=<%=varCloudFiltRef%>"></script>
23 <%
24
25 ' Refer to https://www.example-code.com/asp/global_unlock.asp for unlocking the Chilkat API
26 varChilkatKey = "Anything for 30-day trial"
27
28 ' Unlock Chilkat API
29 set glob = Server.CreateObject("Chilkat_9_5_0.Global")
30 success = glob.UnlockBundle(varChilkatKey)
31
32 ' get Users IP
33 sIPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
34 If sIPAddress = "" Then sIPAddress = Request.ServerVariables("REMOTE_ADDR")
35
36 set http = Server.CreateObject("Chilkat_9_5_0.Http")
37
38 ' Create an HTTP request onject
39 set req = Server.CreateObject("Chilkat_9_5_0.HttpRequest")
40
41 ' Build the request
42 varThisPage = "https://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") & "?" & Request.Querystring
43 varThisPage = Server.URLEncode(varThisPage)
44
45 req.HttpVerb = "POST"
46 req.Path = "/phpcurl"
47 req.AddParam "ip", sIPAddress
48 req.AddParam "KEY", varCloudFiltKey
49 req.AddParam "URL", varThisPage
50
51 For Each item In Request.Form
52 req.AddParam item, Request.Form(item)
53 Next
54
55 ' The request is ready... now send it using HTTPS
56 Set resp = http.SynchronousRequest(varCloudFiltAPIServer,443,1,req)
57
58 ' If there is some sort of error sending the request
59 If (http.LastMethodSuccess = 0) Then
60 ' Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>"
61 Response.End
62 End If
63
64
65 ' Response.Write "<pre>" & Server.HTMLEncode( resp.BodyStr) & "</pre>"
66
67
68 'If we receive a response from the CloudFilt API that is anything but 'OK' (and also not null) - add headers and redirect the user to the CloudFilt blocked page
69
70 If resp.BodyStr <> "OK" Then
71 If IsNull(resp.BodyStr) = False Then
72
73 Response.AddHeader "Cache-Control","no-store, no-cache, must-revalidate, max-age=0"
74 Response.AddHeader "Cache-Control","post-check=0, pre-check=0"
75 Response.AddHeader "Pragma","no-cache"
76 Response.AddHeader "Location","https://cloudfilt.com/stop-" & sIPAddress & "-" & varCloudFiltRef
77 Response.Redirect("https://cloudfilt.com/stop-" & sIPAddress & "-" & varCloudFiltRef)
78
79 End IF
80 End If
81
82
83End If
84%>