ASP页面随机添加字符实现防复制的代码

时间:2022-07-02 01:23:17
  1. <%  
  2.         '作用:文字防复制乱码 函数  
  3.         'Date:2006-3-6  
  4.         '作者:blue2004  
  5.         '参数str 为原文,str1作者也是你自己,reslut产生乱码的种子  
  6.         Function ReadToCode(str,Str1,result)  
  7.                 dim name  
  8.                 dim i,j,k  
  9.                 If isnull(str) then  
  10.                         ReadToCode=""  
  11.                         Exit Function  
  12.                 End If  
  13.                 Randomize   
  14.                 k=instr(str,"</P>")  
  15.                 Do while k>0  
  16.                         result=""  
  17.                         for i=0 to 19  
  18.                                 j=Int(128 * Rnd)+1  
  19.                                 if j=60 or j=62 then  
  20.                                         j=j+1  
  21.                                 end if  
  22.                                 result =result&chr(j) ' 产生随机数。  
  23.                         next   
  24.                         result="<span style='DISPLAY: none'>"&result&"</span>"  
  25.                         str=replace(str,"</p>",result&"<'/p>",1,1)  
  26.                         k=instr(str,"</p>")  
  27.                 loop  
  28.                 str=replace(str,"<'/p>","</p>")  
  29.  
  30.                 k=instr(str,"<br>")  
  31.                 Do while k>0  
  32.                         result=""  
  33.                         for i=0 to 19  
  34.                                 j=Int(128 * Rnd)+1  
  35.                                 if j=60 or j=62 then  
  36.                                         j=j+1  
  37.                                 end if  
  38.                                 result =result&chr(j) ' 产生随机数。  
  39.                         next   
  40.                         result="<span style='DISPLAY: none'>"&result&"</span>"  
  41.                         str=replace(str,"<br>",result&"<'br>",1,1)  
  42.                         k=instr(str,"<br>")  
  43.                 loop  
  44.                 str=replace(str,"<'br>","<br>")  
  45.                 ReadToCode=str&"<div align=right style='color=gray'>[版权归原作者及"&Str1&"共同拥有,转载请注明出处]</div>"  
  46.         End Function  
  47.  
  48.  
  49. Dim a   
  50. a="嘎嘎,一篇<br>不错的好<p>文章哦</P><br><P>我艹,,让你偷。。木 JJ的家伙,嬲。。</p>"  
  51.  
  52.  
  53. 'Only For Test  
  54. response.write (a)  
  55.  
  56. Dim b  
  57. '为配合转换,字符串a的大小都替换成小写  
  58. b=ReadToCode(LCase(a),"blue2004","www.xxx.com")  
  59.  
  60. 'Output  
  61. response.write b  
  62. %>