Add to Favorites    Make Home Page 10859 Online  
 Language Categories  
 Our Services  

Home » ASP Home » Components Home » Protect your Client Side Script with ASP

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Protect your Client Side Script with ASP
Description This code will allow you to use ASP to check that the request for your JavaScript and VBScript is a real request or just someone trying to steal your code. If the request.servervariables(HTTP_REFERER) returns a page from your site then your return the JavaScript if request.servervariables(HTTP_REFERER) does not return a page from your site you return an appropriate response of your own.
Category ASP » Components
Hits 366880
Code Select and Copy the Code
'************************************** ' Name: Protect your Client Side Script ' with ASP v1.1 ' Description:This code will allow you t ' o use ASP to check that the request for ' your JavaScript and VBScript is a "real" ' request or just someone trying to steal ' your code. If the request.servervariable ' s("HTTP_REFERER") returns a page from yo ' ur site then your return the JavaScript ' if request.servervariables("HTTP_REFERER ' ") doesn't return a page from your site ' you return an appropriate response of yo ' ur own. ' Inputs:This is the basic idea laid out ' for you to examine. You will still have ' to do a little work to integrate it in t ' o your site but it isn't much more than ' copy and paste. The Input Request.ServerVariables("HTTP_REFERER") which Is automatically sent by the browser. ' ' Returns:Will return the JavaScript or ' VBScript if appropriate, if not a messag ' e to the user. ' ' Assumes:Pretty basic really, but if yo ' u have any questions then post them and ' I'll try to answer them. I'll be doing a ' n example of this on my site http://www. ' cjcraft.com someday :P ' ' Side Effects:It doesn't seem to work o ' n Netscape without setting up IIS to par ' se .js files like it does .asp. The user ' can still open the file from the user's ' cache unless you include: <% Response.Expires = 60 Response.ExpiresAbsolute = Now() - 1 Response.AddHeader "pragma","no-cache" Response.AddHeader "cache-control","private" Response.CacheControl = "no-cache" %> At the top of the protected JavaScript file. This Is stop the browser from saving a Local copy of the file. ' Use the line below In place of your normal JavaScript include line. <SCRIPT src="testcjs.asp" language="JavaScript" Type="text/javascript"></SCRIPT> Use the code below In place of your normal JavaScript .JS file. It must be saved As a .ASP file Or it will Not work. Actually, you can Set IIS server To read .js files just like it does .asp files. This Is a good idea To hide your protection scheme For any users who are trying bypass it. Then you could save it As a .js file. If you Do this a lot more people will be stumped. Of course you could just As easily protect your vbscript With the technique too. <% ' This is to force file to open save as ' dialog box and not open in user's browse ' r ' It would be even safer to have it as " ' badtype/badtype" instead of "text/javasc ' ript" Response.ContentType = "text/javascript" ' Set the line below to the page that wi ' ll be granted acess to the file ' You could change the test to allow all ' pages on your site access, etc. If (Request.ServerVariables("HTTP_REFERER") = "http://www.mysite.com/myfolder/mypage.asp") Then %> /* This Is where you put the real JavaScript that you want To run */ document.write(" ACCESS GRANTED @ <%=time%> <BR/>"); document.write(" request.servervariables("HTTP_REFERER") = "<%=Request.ServerVariables("HTTP_REFERER")%>""); <% Else %> /* This Is where you put the message you want users To see In place of your real JavaScript */ /* I wouldn't use the bottom line since it will give away your protection scheme and help */ /* users find a way To break it */ No soup For you. Request.ServerVariables("HTTP_REFERER") = "<%=request.servervariables("HTTP_REFERER")%>" <% End If %>

Related Source Codes

Script Name Author
ııııııııııııııııııııı VyomWorld
Resistor color code reader A.Chermarajan.
Telephone Directory dhivya
card swapping game (Mini Project) nityanand
simple hangman-pascalsource Seabert
college dirtectory (Mini Project) msridhar
Poll Application John van Meter
ASP Daily Hit Counter. Tejaskumar Gandhi
To avoid null in asp environment using sql Sami
Maklumbalas webmaster
poll John van Meter
EasyASP Template Engine. TjoekBezoer
Basic Calculator using HTML & Javascript. Patrick M. D Souza
What servers support ASP ? VyomWorld
What is ASP? VyomWorld

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=393


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review