给文章段落添加随机隐藏关键字

载入中
function FormatReArray(str)
dim temp,sindex,temp1
temp=str&","
temp1=split(temp,",")
for sindex=0 to ubound(temp1)
if temp1(sindex)<>"" then
temp=replace(temp,temp1(sindex)&",","")
temp=temp&temp1(sindex)&","
end if
next
FormatReArray=left(temp,len(temp)-1)
end function
Function ReplaceReg(str,patrn,replStr,Ignor)
'=========================================
'参数解释:
'str 原来的字符串
'patrn 要替换的字符串(正则表达式)
'replStr 要替换成的字符串
'Ignor 是否区分大小写(1不区分,0区分)
'=========================================
Dim regEx ' 建立变量。
If Ignor=1 Then Ignor=true else Ignor=false
Set regEx = New RegExp ' 建立正则表达式。飞飞As.p技术乐园
regEx.Pattern = "("&patrn&")" ' 设置模式。飞飞Asp技术乐园
regEx.IgnoreCase = Ignor ' 设置是否区分大小写。
regEx.Global=True
ReplaceReg = regEx.Replace(str,replStr) ' 作替换。飞飞Asp@技术乐园
End Function
Function HiddenKeyword(Content,RndKeyWordCount,AllKeyword,AllSign,HiddenColor)
'********************************************
'作者:飞飞
'QQ:276230416
'网址:www.ffasp.com
'邮箱:huanmie913@163.com
'********************************************
'函数使用参数说明
'Content: 需要执行添加隐藏关键字的文字、段落、文章
'RndKeyWordCount: 添加隐藏关键字的个数
'AllKeyword: 要添加到文章中的文字【要向段落末尾添加的关键字,多关键字请使用"|"分割】
'AllSign 添加到关键字中特殊符号【向关键字中添加随机特殊符号,多特殊符号请使用"|"分割,特殊符号请勿使用"|"】
'HiddenColor: 要添加到文章中的文字的颜色(和背景色相同,达到隐藏的目的)
'*********************************************
'使用的外部函数有
'1.ReplaceReg [正则表达式替换关键字]
'2.FormatReArray [去除数组中的重复项]
'*********************************************
'使用实例:
'Response.Write(HiddenKeyword("aaaaaaaaaaaa<br />bbbbbbbbbbb<br>ccccccccc<br>ddddddddd<br>eeeeeeeeeeeee",3,"飞飞Asp乐园|ffasp",",|.|。|,|@|!","ff0000"))
'请查看源代码查看效果
'
'*********************************************
Dim EContent,UboundEContent,RndKeyWordArray,DomainLength,DomainPoint,TagName
Dim Keyword,ArryKeyword,ArryCountKeyword,KeywordLength,ArryUboundKeyword
Dim Sign,ArrySign,ArryUboundsign,SignLength
'------------------------------------------------------
Content=ReplaceReg(Content,"<br>","<br />",1)
Content=ReplaceReg(Content,"<br/>","<br />",1)
Content=ReplaceReg(Content,"</div>","</div>",1)
Content=ReplaceReg(Content,"</p>","</p>",1)
Content=ReplaceReg(Content,"</a>","</a>",1)
'-------------------------------------------------------
If instr(Content,"</a>")>0 Then
TagName="</a>"
ElseIf instr(Content,"</div>")>0 Then
TagName="</div>"
ElseIf instr(Content,"</p>")>0 Then
TagName="</p>"
ElseIf instr(Content,"<br />") Then
TagName="<br />"
Else
TagName="</a>"
End If
Randomize
'-------------------------------------------------------
RndKeyWordArray=""
EContent=split(Content,TagName)
UboundEContent=Ubound(EContent)
If UboundEContent+1-RndKeyWordCount<0 Then RndKeyWordCount=UboundEContent+1
Content=""
'--------------------------------------------------------
for i=1 to RndKeyWordCount
RndKeyWordArray=RndKeyWordArray&Int((UboundEContent+1) * Rnd)
If i<>RndKeyWordCount Then RndKeyWordArray=RndKeyWordArray&","
next
RndKeyWordArray=","&FormatReArray(RndKeyWordArray)&","
for i=0 to UboundEContent
'=====取出关键字==========================
ArryKeyword=split(AllKeyword,"|")
ArryUboundKeyword=Ubound(ArryKeyword)
Keyword=ArryKeyword(int((ArryUboundKeyword+1)*Rnd))
KeywordLength=len(Keyword)
'=====取出特殊符号========================
ArrySign=Split(AllSign,"|")
ArryUboundSign=Ubound(ArrySign)
Sign=ArrySign(int((ArryUboundSign+1)*Rnd))
'=========================================
Content=Content&EContent(i)
If i<>UboundEContent Then Content=Content&TagName
If instr(RndKeyWordArray,","&i&",")>0 and i<>UboundEContent Then
DomainPoint=Int((KeywordLength) * Rnd + 1)
If DomainPoint=KeywordLength Then sign=""
Content=Content&"<span style=""color:#"&HiddenColor&";display:none"">"&left(Keyword,DomainPoint)&sign&mid(Keyword,DomainPoint+1)&"</span>"
End If
Next
'--------------------------------------------------------
HiddenKeyword=Content
End Function
Response.Write(HiddenKeyword("aaaaaaaaaaaa<br />bbbbbbbbbbb<br>ccccccccc<br>ddddddddd<br>eeeeeeeeeeeee",3,"飞飞Asp乐园|ffasp",",|.|。|,|@|!","ff0000"))
%> 文章来源:雨@哲
给文章部分内容增加权限[类似论坛购买贴][11-09]
留言本仿论坛模板及部分功能[11-08]
雨哲自定义表单系统 For SiteWeaver[11-07]
在线支付模板管理[11-07]
全站搜索 For SiteWeaver 通用[11-07]
企业会员展示系统[11-07]
文章搜索:
- 用户信息中心
- 与本文章相关内容
-
- >> [文章教程]asp关键字函数运算附 [日期:2008-07-04 16:23:37]
- >> [文章教程]不重复随机读取数据库记录 [日期:2007-10-21 01:00:43]
- >> [文章教程][ASP]隐藏文件下载地址方法 [日期:2007-03-25 02:00:09]
- >> [文章教程]一段asp高亮关键字代码 [日期:2007-03-25 01:58:23]
- >> [文章教程]隐藏在Win 2003中的“冷招” [日期:2007-02-21 20:38:16]
- >> [文章教程]在系统中隐藏超级用户多种方 [日期:2007-02-21 20:37:34]
- >> [文章教程]Word 鲜为人知的隐藏秘密 [日期:2007-02-10 18:13:58]
- >> [文章教程]巧妙隐藏Word文档文字内容 [日期:2007-02-10 17:55:18]
- >> [文章教程]文章关键字加亮工具 [日期:2007-02-09 23:29:08]
- >> [文章教程]js代码高亮关键字 [日期:2007-02-09 23:25:55]
- 热门排行TOP10
-
- 1WORD 页眉设置 技巧 (3870)
- 2在线播放FLV格式文件 (3529)
- 3关于动易会员中心模 (3230)
- 4雨哲增强SiteWeaver (3116)
- 5无限级树型栏目导航 (2696)
- 6xxmrxut.exe病毒的手 (2227)
- 7小谈关于动易聚合空 (2165)
- 8完美CSS控制图片大小 (2067)
- 9如何在静态HTML页面 (2038)
- 10WindowsServerServi (1857)
- 推荐排行TOP10
-
- 1在线播放FLV格式文件 (3529)
- 2在网页右下角添加书 (1732)
- 3[ASP]隐藏文件下载地 (1575)
- 4雨哲浅谈关于防采集 (1404)
- 5一段asp高亮关键字代 (1363)
- 6在文字前加上与文字 (1254)
- 7文字自动适应Table( (1244)
- 8自定义标签设置搜索 (1239)
- 9[雨哲]关于增强会员 (1237)
- 10ASP 程序实现自动升 (1229)
