进入旧版 | 服务项目 | 成功案例 | 联系方式 | 过客留言 | 友情链接
   
设为首页
加入收藏
联系我们
网站首页 | 新闻资讯 | 操作系统 | 办公软件 | 网络软件 | 工具软件 | 媒体动画 | 网页制作 | 网站开发 | 程序开发 | 平面设计
Photoshop视频教程 | Word入门 | Flash入门 | JScript | VBScript | ASP | PHP | ADO | 网页特效 | 3DS MAX6.0命令 | 系统进程
您当前的位置:GOODSGY电脑学习网 -> 网站开发 -> ASP -> 文章内容  
面向对象的asp编程之八---服务器端函数

<Script language="vbscript" runat="server">
'****************************************************************
' Script Compont Object Model
' Design for Active Server Pages
' Copyright 2004 Version 2.0
' Made by 尹曙光
' All Rights Reserved.
' ****************************************************************
'
' 系统常用的一些公用函数
'
'*****************************************************************

'系统公用信息显示
'strMsg:提示信息
'msgType:信息提示类型
'jumpUrl:页面眺转地址
'strCopyRight:版权信息
Function FShowMsg(strMsg,msgType,jumpUrl,strCopyRight)
Response.Write "<Style>"&chr(13)
Response.Write "BODY { margin: 0px 0px 0px 0px;FONT-FAMILY: '宋体','Tahoma', 'MS Shell Dlg';color: #000000;font: 9pt;background-color:#f0f1eb;}"&chr(13)
Response.Write "A{font:normal 12px 宋体;COLOR: #336699; TEXT-DECORATION: none}"&chr(13)
Response.Write "TD{font-family:宋体; font-size: 12px; line-height: 15px;background-color:#f0f1eb;}"&chr(13)
Response.Write ".THead{ background-color: #336699;color:#ffffff;font-weight:bold;}"&chr(13)
Response.Write ".TFoot{ background-color: #336699;COLOR: #ffffff;}"&chr(13)
Response.Write "</style>"&chr(13)

Response.Write "<table height='90%' width='100%'> <tr>"&chr(13)
Response.Write "<td align=center> <table align=center cellpadding=0 cellspacing=0 bordercolor='#336699' bgcolor='#336699' style='width:90%'>"
Response.Write "<tr align=center>"&chr(13)
Response.Write "<td width='100%' height=20 colspan=2 bgcolor='#336699' class='THead' >系统提示信息</t> "&chr(13)
Response.Write "<tr><td width='100%' colspan=2 align='center' bgcolor='#FFFFFF'><br> "&chr(13)
Response.Write strMsg
Select Case cint(msgType)
case 1
Response.Write "[<a href='javascript:window.close();'>关闭窗口</a>]"
Case 2
Response.Write "[<a href='javascript:history.back(-1);'>返回</a>]"
case 3
Response.Write "[<a href='javascript:history.back("&jumpUrl&");'>返回</a>]"
case 4
Response.Write "<meta HTTP-EQUIV=REFRESH CONTENT='3; URL="&jumpUrl&"'>,正在跳转..."
case 5
Response.Write "[<a href='"&jumpUrl&"'>返回</a>]"

End Select

Response.Write "<br><br></td></tr><tr align=center><td width='100%' height=20 colspan=2 class='TFoot'>"&chr(13)

Response.Write strCopyRight

Response.Write "</td> </tr></table></td> </tr> </table>"&chr(13)

Response.End()

End Function

'检查系统错误
'errMsg:出错后的提示信息
Function FIfError(errMsg)
if Err.number>0 then
Response.Write "<br>"
Response.Write errMsg
Response.End
end if
End Function

'显示系统错误信息
Function FSystemError()
if Err.number>0 then
Response.Write "<br>"
Response.Write "错误来源:"&Err.Source&"<br>"
Response.Write "错误代码:"&Err.number&"<br>"
Response.Write "错误说明:"&Err.Description &"<br>"
Response.End
end if
End Function

'判断是不是从form提交过来的
Function FIsPostBack()
if ( UCase(trim(Request.ServerVariables("REQUEST_METHOD")))="POST") then
FIsPostBack=true
else
FIsPostBack=false
end if
End Function


function FGetUserIp()
FGetUserIp=Request.ServerVariables("remote_addr")
End Function
</Script>





<Script language="vbscript" runat="server">
'****************************************************************
' Script Compont Object Model
' Design for Active Server Pages
' Copyright 2004 Version 2.0
' Made by 尹曙光
' All Rights Reserved.
' ****************************************************************
'
' 字符串处理函数
'
'*****************************************************************

'取得一个长度为ilen的字符串,含字母和数字
Function FRandomStr(ilen)
dim c,strResult
ilen=cint(ilen)
for i=1 to ilen
Randomize
c=Int((74 * Rnd) + 48) 'c>48 and c<122
while (c>57 and c<65) or (c>90 and c<97)
Randomize
c=Int((74 * Rnd) + 48)
wend
strResult=strResult&cstr(chr(c))
next
FRandomStr=strResult
End Function
'以下两个函数是用于检查身份证件号的
Function FCheckIdCard2(strIdCard)
dim iIdCard,strTmp
iIdCard=Len(strIdCard)
if (iIdCard=null or (not(iIdCard=15 or iIdCard=18))) then
FCheckIdCard2=false
exit function
end if

if iIdCard=15 then
strTmp=strIdCard
else
strTmp=mid(strIdCard,1,17)
end if

if IsNumeric(strTmp) then
FCheckIdCard2=true
else
FCheckIdCard2=false
exit function
end if

if iIdCard=18 then
strTmp=mid(strIdCard,18,1)
strTmp=ucase(strTmp)
if not (IsNumeric(strTmp) or strTmp="X") then
FCheckIdCard2=false
exit function
end if
end if
End Function

'检查身份证号
'参数:str:待检查的字符串
'参数2:出生日期的年(4位)
'参数3:出生日期的月
'参数4:出生日期的日
Function FCheckIdCard(byval strIdCard,byval iYear,byval iMonth,byval iDay)
dim strBirthDay,strTmp1

if not FCheckIdCard2(strIdCard) then
FCheckIdCard=false
exit function
end if

if len(iYear)<>4 then
FCheckIdCard=false
exit function
end if
strBirthDay=cstr(iYear)+String(2-len(cstr(iMonth)),"0")+cstr(iMonth)+String(2-len(cstr(iDay)),"0")+cstr(iDay)

if len(strIdCard)=15 then
strTmp1=mid(strIdCard,7,6)
strBirthDay=mid(strBirthDay,3,6)
if strTmp1<>strBirthDay then
FCheckIdCard=false
exit function
end if
else
strTmp1=mid(strIdCard,7,8)
if strTmp1<>strBirthDay then
FCheckIdCard=false
exit function
end if
end if
FCheckIdCard=true
End Function

'检查邮编
function FCheckPostCode(byval strCode)
if (len(trim(strCode))<>6) then
FCheckPostCode=false
exit function
else
FCheckPostCode=IsNumeric(strCode)
Exit Function
end if
End function
'-----------------可逆加密----------------------------------------------
function encrypt(byval ecode)
Dim texts
dim i
for i=1 to len(ecode)
texts=texts & chr(asc(mid(ecode,i,1))+i)
next
encrypt = texts
end function

function decrypt(byval dcode)
dim texts
dim i
for i=1 to len(dcode)
texts=texts & chr(asc(mid(dcode,i,1))-i)
next
decrypt=texts
end function
'----------------不可逆加密---------------------------------------------------
function mistake(byval preString)
Dim texts
Dim seed
Dim i,length
prestring = trim(preString)
length = len(preString)
seed = length
Randomize(length)
texts = ""
for i = 1 to length
seed = int(94*rnd(-asc(mid(preString,i,1))-seed*asc(right(prestring,1)))+32)
texts = texts & chr(seed) & chr(int(94*rnd(-seed)+32))
next
dim dist
dist=""
for i = 1 to len(texts)
if mid(texts,i,1)<>"'" then
dist=dist+mid(texts,i,1)
end if
next
mistake = dist
end function


</Script>










<SCRIPT LANGUAGE=javascript RUNAT=Server>
// ************************************************************************
// Script Compont Object Model
// Design for Active Server Pages
//
// Copyright 2003 Version 1.0
// Made by 尹曙光
// ************************************************************************

function getArrayOrder(aMain,str){ //数组,给定其数值,求其在数组的下标
//aMain为数组,str为数组中的内容
var iMain=-1
if ((aMain.length==0)||(str.length==0)){
return iMain
}
for(var i=0;i<aMain.length;i++){
if (aMain[i]==str) {
iMain=i
break;
}
}
return iMain
}

function getArrayOrders(aMain,str){ //数组,给定其数值,求其在数组的下标
//该函数返回树组,依次列出,值在数组中的下标
//aMain为数组,str为数组中的内容
thisResult=new Array
thisResult[0]=-1
if ((aMain.length==0)||(str.length==0)){
return thisResult
}
var j=0;
for(var i=0;i<aMain.length;i++){
if (aMain[i]==str) {
thisResult[j++]=i
}
}
return thisResult
}
</SCRIPT>
















<script language=jscript runat=server>
// ************************************************************************
// Script Compont Object Model
// Design for Active Server Pages
//
// Copyright 2003 Version 1.0
// Made by 尹曙光
// ************************************************************************
function saveRsToTxtFile(rs,filename)
{
//将RecordSet的内容保存进一个txt文件中,rs数据集,filename文件的绝对路径
var fs = Server.CreateObject("Scripting.FileSystemObject")

if (fs.FileExists(filename))
fs.DeleteFile(filename)

var txtFile = fs.CreateTextFile(filename)

var strLine=""

//写入字段名
var nFields = rs.Fields.Count;

for (var i=0; i < nFields; i++)
strLine+= rs(i).name+"\t"

txtFile.WriteLine(strLine)

//写入内容
while (! rs.EOF ){
strLine=""
for (var i=0; i < nFields; i++)
strLine+= rs(i).value+"\t"

txtFile.WriteLine(strLine)

rs.MoveNext()
}
txtFile= null
fs=null
}

</script>

在百度中搜索:面向对象的asp编程之八---服务器端函数
在Google中搜索:面向对象的asp编程之八---服务器端函数
在Yahoo中搜索:面向对象的asp编程之八---服务器端函数

收藏到网摘:新浪VIVI 365key 我摘 POCO网摘 博采中心 YouNote 和讯网摘 天天收藏
[] [返回上一页] [打 印] [收 藏]

 相关文章    最新文章
· 微软面向黑莓推出语音网络搜索软件
· 面向Java程序员的db4o指南: 数组和集合
· Java中消除实现继承和面向接口编程
· 浅谈JavaScript中面向对象技术的模拟
· [组图] AJAX中JavaScript支持面向对象的基..
· 面向HTML6.0:W3C启动下一代Web语言
· 面向搜索引擎的网站设计
· PHP中实现面向对象编程
· 利用索引服务和ASP建立面向整个网站搜索程..
· 面向对象的asp编程之九---客户器端函数
 
· 初学ASP编程易犯的一个错误要注意
· ASP实现SQL语句日期格式的加减运算
· ASP程序中输出Excel文件实例一则
· ASP实现IE地址栏参数的判断
· ASP技巧:判断远程图片是否存在
· ASP去掉字符串头尾连续回车和空格的Funct..
· 深入认识学习ASP应用Cookies的技巧
· ASP实现邮件发送普通附件和嵌入附件
· 在ASP.NET中把图片保存到SQL SERVER数据库..
· 巧用枚举CommandBehavior关闭SqlDataRead..

∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论…]
站内搜索

精彩图文
  网站导航  
操作系统 办公软件 网络软件
Vista Windows2003 WindowsXP Windows2000/NT Windows9X/ME Linux 其他 Word Excel Powerpoint Outlook 金山系列 其他 网页浏览 上传下载 联络聊天 邮件工具 服务器软件 网络辅助
工具软件 媒体动画 网页制作
系统工具 媒体工具 压缩工具 图文处理 文件管理 其他 3DMAX Authorware Director Maya 视频处理 其他 Flash Dreamweaver FireWorks FrontPage LiveMotion Golive HTML/CSS 其它
网站开发 平面设计 程序设计
ASP JSP PHP CGI JavaScript VBScript XML/SOAP Web服务器 Photoshop PhotoImpact CorelDraw Illustrator Freehand 设计欣赏 其他 VB VC .NET C/C++ DELPHI JAVA

冀ICP备05019428号
Copyright © 2004-2008 电脑学习网 Inc.All rights reserved.
TEL:13832340607
QQ:39873155
E_Mail:goodsgy(#)hotmail.com   (把(#)替换成@)
MSN:goodsgy(#)hotmail.com   (把(#)替换成@)