Friday, 24 May 2013

Random number in asp

Random number in asp
---------------------------------------------------------
Function getRandomnum()
Randomize
dim randomVar1, randomVar2, randomVar3, currDate

currDate = Replace(Now(), "/", "")
currDate = Replace(currDate, " ", "")
currDate = Replace(currDate, ":", "")
currDate = Replace(currDate, "AM", "")
currDate = Replace(currDate, "PM", "")

randomVar1 = (Rnd() * 1000000)
randomVar2 = Sqr(randomVar1)
randomVar3 = Round(1000000 * (randomVar1 * randomVar2))

getRandomnum = (currDate & randomVar3)
End Function

random password in asp

Random Password Generator in ASP
-----------------------------------------------------------------------------

<%
Dim Password
Dim RandomPassword
Dim nCharacters

Dim array_cod(35)
array_cod(0) = "0"
array_cod(1) = "1"
array_cod(2) = "2"
array_cod(3) = "3"
array_cod(4) = "4"
array_cod(5) = "5"
array_cod(6) = "6"
array_cod(7) = "7"
array_cod(8) = "8"
array_cod(9) = "9"
array_cod(10) = "a"
array_cod(11) = "b"
array_cod(12) = "c"
array_cod(13) = "d"
array_cod(14) = "e"
array_cod(15) = "f"
array_cod(16) = "g"
array_cod(17) = "h"
array_cod(18) = "i"
array_cod(19) = "j"
array_cod(20) = "k"
array_cod(21) = "l"
array_cod(22) = "m"
array_cod(23) = "n"
array_cod(24) = "o"
array_cod(25) = "p"
array_cod(26) = "q"
array_cod(27) = "r"
array_cod(28) = "s"
array_cod(29) = "t"
array_cod(30) = "u"
array_cod(31) = "v"
array_cod(32) = "w"
array_cod(33) = "x"
array_cod(34) = "y"
array_cod(35) = "z"

for cod=0 to 9
MaxCod = 35 
MinCod = 0 
Randomize 

RandomPassword = CStr(RandomPassword & array_cod(Int(Rnd * MaxCod) - MinCod))
next

Password = RandomPassword
response.write(password)
%>

Wednesday, 1 May 2013

Strip Special Characters or REGEx in asp
---------------------------------------------------------------------------------------------
Strip Special Characters in ASP


Function StripSpecialChar(inStr)
dim sOut,outStr,arrSpecialChar,intCounter,arrSpecialChar1
' arrSpecialChar  = Array("%20","&amp;","&","#","+","@","(","","","","","","","","")

arrSpecialChar=Array("#","$","%","&","@","`","/",":",";","<","=",">","?","[","\","]","^","{","|","}","~","'","+",",")
outStr=replace(inStr," ","-")
intCounter = 0

Do Until intCounter = UBOUND(arrSpecialChar)+1
  sOut = replace(outStr,arrSpecialChar(intCounter),"")
  intCounter = intCounter + 1
  outStr = sOut
Loop
StripSpecialChar = outStr
End Function

---------------------------------------------------------------------------------------------
dim regEx
Set regEx = New RegExp
regEx.Pattern = "[ /\<|\>|\|\'|\%|\;|\(|\)|\&|\+|\/g]"
regEx.IgnoreCase = True
regEx.Global = True

regEx.Replace(fulltext,"-")
---------------------------------------------------------------------------------------------
dim regEx
Set regEx = New RegExp
regEx.Pattern = "(<a[^>]+>)|(<\/a>)"
regEx.IgnoreCase = True
regEx.Global = True
regEx.Replace(fulltext,"-")
---------------------------------------------------------------------------------------------

asp use full blogs list

Tuesday, 23 April 2013

download Free captcha code in asp

Free captcha code in classic asp
-------------------------------------------------------------------------------------------------------------

The below Website(tipstricks.org) provides free captcha for .net developers and classic asp developer
Choose the options and download the code

http://www.tipstricks.org/

(OR)

Visit the below URLS
http://sqlinjectiontruths.blogspot.in/2013/04/recaptcha-in-classic-asp.html

https://www.google.com/recaptcha/admin/create

https://developers.google.com/recaptcha/docs/asp

https://developers.google.com/recaptcha/docs/customization

-------------------------------------------------------------------------------------------------------------

recaptcha in classic asp

Recaptcha In Classic ASP
----------------------------------------------------------------------------------------------------------
Visit the below URLS
https://www.google.com/recaptcha/admin/create
https://developers.google.com/recaptcha/docs/asp
https://developers.google.com/recaptcha/docs/customization

(OR)

download free captcha code in the below URL
http://sqlinjectiontruths.blogspot.in/2013/04/download-free-captcha-code-in-asp.html

Recaptcha Code Steps
Step1:

Place the following code, above the <form> tag

<script type="text/javascript">
 var RecaptchaOptions = {
    theme : 'clean',
 };
 </script>

Step2:

Place the following code between <form></form> tags (or) above the <submit> button
Replace the public_key with re


Complete a quick security check, Type both words separated by a space below*
          <script type="text/javascript"
    src="http://www.google.com/recaptcha/api/challenge?k=public_key">
 </script>
          <noscript>
          <iframe src="http://www.google.com/recaptcha/api/noscript?k=public_key"
        height="300" width="500" frameborder="0"></iframe>
          <br>
          <textarea name="recaptcha_challenge_field" rows="3" cols="40">
   </textarea>
          <input type="hidden" name="recaptcha_response_field" value="manual_challenge">
          </noscript>

Step3:

Place the following code in the action page


<!-- #include virtual="/includes/recaptcha.asp" -->
<% if server_response <> "" or newCaptcha then %>
<% if newCaptcha = False then %>
<!-- An error occurred -->
Wrong Captcha value entered!
<%
Response.End
end if
%>
<%end if%>

Step4:

Create recaptcha.asp in includes folder, Replace public_key,private_key

<%
dim recaptcha_challenge_field,recaptcha_response_field,recaptcha_public_key,recaptcha_private_key
dim server_response,newCaptcha
  recaptcha_challenge_field  = Request.Form("recaptcha_challenge_field")
  recaptcha_response_field   = Request.Form("recaptcha_response_field")
  recaptcha_public_key       = "public_key" ' your public key
  recaptcha_private_key      = "private_key" ' your private key

  ' returns the HTML for the widget
  function recaptcha_challenge_writer()

  recaptcha_challenge_writer = _
  "<script type=""text/javascript"">" & _
  "var RecaptchaOptions = {" & _
  "   theme : 'clean'," & _
  "   tabindex : 0" & _
  "};" & _
  "</script>" & _
  "<script type=""text/javascript"" src=""http://www.google.com/recaptcha/api/challenge?k=" & recaptcha_public_key & """></script>" & _
  "<noscript>" & _
    "<iframe src=""http://www.google.com/recaptcha/api/noscript?k=" & recaptcha_public_key & """ frameborder=""1""></iframe><>" & _
      "<textarea name=""recaptcha_challenge_field"" rows=""3"" cols=""40""></textarea>" & _
      "<input type=""hidden"" name=""recaptcha_response_field""value=""manual_challenge"">" & _
  "</noscript>"

  end function

  ' returns "" if correct, otherwise it returns the error response
  function recaptcha_confirm(rechallenge,reresponse)

  Dim VarString
  VarString = _
          "privatekey=" & recaptcha_private_key & _
          "&remoteip=" & Request.ServerVariables("REMOTE_ADDR") & _
          "&challenge=" & rechallenge & _
          "&response=" & reresponse

  Dim objXmlHttp
  Set objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
  objXmlHttp.open "POST", "http://www.google.com/recaptcha/api/verify", False
  objXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  objXmlHttp.send VarString

  Dim ResponseString
  ResponseString = split(objXmlHttp.responseText, vblf)
  Set objXmlHttp = Nothing

  if ResponseString(0) = "true" then
    'They answered correctly
     recaptcha_confirm = ""
  else
    'They answered incorrectly
     recaptcha_confirm = ResponseString(1)
  end if

  end function

  server_response = ""
  newCaptcha = True
  if (recaptcha_challenge_field <> "" or recaptcha_response_field <> "") then
    server_response = recaptcha_confirm(recaptcha_challenge_field, recaptcha_response_field)
    newCaptcha = False
  end if
  %>


Source:


Friday, 12 April 2013

PDF Creation in Classic ASP

PDF Creation in Classic ASP
----------------------------------------------------------------------------------------
Click the below links

http://sourceforge.net/projects/aspdf/?source=dlp

http://www.fileguru.com/ASPDF---PDF-Creation-With-Classic-ASP/download

Source FPDF.ORG
http://fpdf.org/