仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 325|回复: 8
打印 上一主题 下一主题

[学习教程] ASP网站制作之做网页经常用的ASP函数

[复制链接]
飘灵儿 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 22:08:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
源代码保护方面其实现在考虑得没那么多了..NET也可以反编译.ASP写得复杂的话别人能看得懂的话.他也有能力自己写了.这方面担心的倒不太多.纵观现在网上可以下载的那些所谓BBS还有什么网站等等的源代码----------------------------------------------------------------------
函数功效: 屏障HTML代码
参  数: StrInput用户输出信息
----------------------------------------------------------------------
functionFunInput(StrInput)
ifnotisnull(Str)then
StrInput=RePlace(StrInput,"<","<")
StrInput=replace(StrInput,">",">")
StrinPut=replace(Strinput,chr(32),"")
strinput=replace(strinput,chr(34),""")
strinput=replace(strinput,chr(39),"")
strinput=replace(strinput,chr(13),"")
FunInput=strinput
endif
endfunction

----------------------------------------------------------------------
函数功效: 避免SQL注进
参  数: StrValue用户提交的数据
BloType数据范例
参数值:true数值型数据
false字符型数据
----------------------------------------------------------------------
functionFunSQL(StrValue,BloType)
ifBloTypethen
ifIsnumeric(StrValue)then
FunSQL=clng(StrValue)
else
StrValue=0
endif
else
ifnotisnull(StrValue)then
StrValue=lcase(StrValue)
StrValue=Replace(StrValue,"","")
StrValue=replace(StrValue,"select","")
StrValue=replace(StrValue,"update","")
StrValue=replace(StrValue,"insert","")
StrValue=replace(StrValue,"delete","")
StrValue=replace(StrValue,";","")
StrValue=replace(StrValue,"","")
StrValue=replace(StrValue,chr(255),"")
StrValue=replace(StrValue,"*","")
StrValue=replace(StrValue,"%","")
endif
endif
FunSQL=StrValue
endfunction

--------------------------------------------------------------------------
函数功效: 经常使用范例转换
参数:_Type 数据范例
_Value数据
参数值:_Type1:转换成数值型数据
_Type2:转换成字符型数据
_Type3:转换成布尔型数据
--------------------------------------------------------------------------
functionFunSwitch(Value_,Type_)
onerrorresumenext
selectcaseType_
case1
ifisnumeric(Value_)then
ifnotisnull(Value_)then
FunSwitch=clng(Value_)
else
FunSwitch=0
endif
else
FunSwitch=0
endif
case2
ifnotisnull(Value_)then
FunSwitch=cstr(Value_)
else
FunSwitch=""
endif
case3
ifnotisnull(Value_)andisnumeric(Value_)then
FunSwitch=cbool(Value_)
else
FunSwitch=false
endif
caseelse
response.redirect("Error.asp?err=请指定FunSwitch中要传达换成的数据范例!")
endselect
iferr.number0then
response.redirect("Error.asp?err=数据转换时发生未知毛病!")
err.clear
endif
endfunction
----------------------------------------------------------------------
函数功效: 考证是数据是不是来自内部
参数:无
----------------------------------------------------------------------
functioncheckfrom()
server_v1=Cstr(Request.ServerVariables("HTTP_REFERER"))
server_v2=Cstr(Request.ServerVariables("SERVER_NAME"))
ifmid(server_v1,8,len(server_v2))server_v2then
checkfrom=true
else
checkfrom=false
endif
endfunction

----------------------------------------------------------------------
函数功效: JS提醒框
参数:StrURL:点击断定后前往到的页面地点
StrMSG:对话框的提醒信息
----------------------------------------------------------------------
FunctionFunMsg(StrURL,StrMSG)
Response.write"<scriptlanguage=javascript>"&_
Vbcrlf&"alert("""&StrMSG&""");"&_
Vbcrlf&"window.location="""&StrURL&""";"&_
Vbcrlf&"</script>"
EndFunction
--------------------------------------------------------------------------
函数功效: 通用分页
参数:Intpagecount 总页数
Intmypage以后页数
Intrecordcount纪录总数
Intpagesize每页显现的纪录数
--------------------------------------------------------------------------
functionfunpage(Intpagecount,Intmypage,Intrecordcount,Intpagesize)
onerrorresumenext
dimIntfor,Intlist,intlist_b
Dimquery,a,x,temp
action="http://"&Request.ServerVariables("HTTP_HOST")&Request.ServerVariables("SCRIPT_NAME")
query=Split(Request.ServerVariables("QUERY_STRING"),"&")
ForEachxInquery
a=Split(x,"=")
IfStrComp(a(0),"page",vbTextCompare)0Then
temp=temp&a(0)&"="&a(1)&"&"
EndIf
Next
ifintmypage>1then
funpage=funpage&"<ahref="&action&"?"&temp&"page=1title=最前页class=no><fontface=Webdings>9</font></a>"
funpage=funpage&"<ahref="&action&"?"&temp&"page="&Intmypage-1&"title=上一页class=no><fontface=Webdings>7</font></a>"
else
funpage=funpage&"<fontface=Webdings>9</font>"
funpage=funpage&"<fontface=Webdings>7</font>"
endif
ifIntlist0then
ifcintmypage=Intlistthen
Intlist=Intlist+5
endif
else
Intlist=Intmypage+5
endif
ifintlist-9<1then
intlist_b=1
else
intlist_b=intlist-9
endif
forIntfor=intlist_btoIntlist
ifintfor<=Intpagecountthen
ifintfor=Intmypagethen-------使以后页笔墨为白色,其实不可点击
funpage=funpage&strMode&"<fontcolor=#FF0000><b>"&Intfor&"</b></font>"
else
funpage=funpage&strMode&"<ahref="&action&"?"&temp&"page="&Intfor&"class=no>"&Intfor&"</a>"
endif
endif
strMode="<fontcolor=#BBBBBB>|</font>"
next
ifintmypage<intpagecountthen
funpage=funpage&"<ahref="&action&"?"&temp&"page="&Intmypage+1&"title=后一页class=no><fontface=Webdings>8</font></a>"
funpage=funpage&"<ahref="&action&"?"&temp&"page="&Intpagecount&"title=最初页class=no><fontface=Webdings>:</font></a>"
else
funpage=funpage&"<fontface=Webdings>8</font>"
funpage=funpage&"<fontface=Webdings>:</font></a>"
endif
funpage="<tablewidth=100%border=0cellspacing=0cellpadding=0><tr>"&_
vbcrlf&"<tdwidth=40%style=font:14px>以后第"&Intmypage&"页 "&Intpagesize&"条/页 共"&Intpagecount&"页/"&Intrecordcount&"笔记录</td>"&_
vbcrlf&"<tdwidth=60%align=right>"&_
vbcrlf&"<tablewidth=360border=0cellspacing=0cellpadding=0><tr>"&_
vbcrlf&"<tdalign=rightstyle=font:14px>"&funpage&"</td>"&_
vbcrlf&"</tr></table></td></tr>"&_
vbcrlf&"</table>"
iferr.number0then
err.clear
response.redirect("error.asp?err=分页函数堕落,请与办理员接洽!|")
endif
endfunction
***************************************************
函数名:Highlight
功效:搜刮的关头词以高亮的色彩显现
参数strText是要被高亮显现的字符串或变量地点的字串或变量
strFind是要被高亮显现的字符串或变量,
strBefore被高亮显现的HTML代码前缀如:<fontcolor=red>
strAfter被高亮显现的HTML代码的后缀:</font>
*****************************************************
FunctionHighlight(strText,strFind,strBefore,strAfter)
DimnPos
DimnLen
DimnLenAll
nLen=Len(strFind)
nLenAll=nLen+Len(strBefore)+Len(strAfter)+1
Highlight=strText
IfnLen>0AndLen(Highlight)>0Then
nPos=InStr(1,Highlight,strFind,1)
DoWhilenPos>0
Highlight=Left(Highlight,nPos-1)&_
strBefore&Mid(Highlight,nPos,nLen)&strAfter&_
Mid(Highlight,nPos+nLen)
nPos=InStr(nPos+nLenAll,Highlight,strFind,1)
Loop
EndIf
EndFunction


Windows本身的所有问题都会一成不变的也累加到了它的身上。安全性、稳定性、跨平台性都会因为与NT的捆绑而显现出来;
金色的骷髅 该用户已被删除
沙发
发表于 2015-1-18 20:59:06 | 只看该作者
如何更好的使自己的东西看上去很不错等等。其实这些都不是问题的实质,我们可以在实践中不断提升自己,不断充实自己。
愤怒的大鸟 该用户已被删除
板凳
发表于 2015-1-26 14:54:39 | 只看该作者
学习ASP其实应该上升到如何学习程序设计这种境界,其实学习程序设计又是接受一种编程思想。比如ASP如何学习,你也许在以前的学习中碰到过。以下我仔细给你说几点:
蒙在股里 该用户已被删除
地板
发表于 2015-2-4 19:40:31 | 只看该作者
还有如何才能在最短的时间内学完?我每天可以有效学习2小时,双休日4小时。
透明 该用户已被删除
5#
发表于 2015-2-10 06:14:27 | 只看该作者
他的语法和设计思路和VB完全相同,导致很多ASP的书都留一句“相关内容请参考VB的相关教材....”更糟糕的是,相当多的ASP教程混合了Javascript,VBscript等等脚本语言,搞的初学者。
乐观 该用户已被删除
6#
发表于 2015-2-28 23:16:48 | 只看该作者
完全不知道到底自己学的是什么。最后,除了教程里面说的几个例子,还是什么都不会。
兰色精灵 该用户已被删除
7#
发表于 2015-3-10 10:19:45 | 只看该作者
接下来就不能纸上谈兵了,最好的方法其实是实践。实践,只能算是让你掌握语言特性用的。而提倡做实际的Project也不是太好,因为你还没有熟练的能力去综合各种技术,这样只能使你自己越来越迷糊。
老尸 该用户已被删除
8#
发表于 2015-3-17 06:45:45 | 只看该作者
ASP.Net和ASP的最大区别在于编程思维的转换,而不仅仅在于功能的增强。ASP使用VBS/JS这样的脚本语言混合html来编程,而那些脚本语言属于弱类型、面向结构的编程语言,而非面向对象,这就明显产生以下几个问题:
小女巫 该用户已被删除
9#
发表于 2015-3-24 00:50:47 | 只看该作者
我就感觉到ASP和一些常用的数据库编程以及软件工程方面的思想是非常重要的。我现在也在尝试自己做网页,这其中就用到了ASP,我想它的作用是可想而知的。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-9-27 17:32

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表