快精灵印艺坊 您身边的文印专家
广州名片 深圳名片 会员卡 贵宾卡 印刷 设计教程
产品展示 在线订购 会员中心 产品模板 设计指南 在线编辑
 首页 名片设计   CorelDRAW   Illustrator   AuotoCAD   Painter   其他软件   Photoshop   Fireworks   Flash  

 » 彩色名片
 » PVC卡
 » 彩色磁性卡
 » 彩页/画册
 » 个性印务
 » 彩色不干胶
 » 明信片
   » 明信片
   » 彩色书签
   » 门挂
 » 其他产品与服务
   » 创业锦囊
   » 办公用品
     » 信封、信纸
     » 便签纸、斜面纸砖
     » 无碳复印纸
   » 海报
   » 大篇幅印刷
     » KT板
     » 海报
     » 横幅

面向对象的ASP编程之八-服务器端函数

<Script language="vbscript" runat="server">
\\\' 系统常用的一些公用函数
\\\'
\\\'*****************************************************************

\\\'系统公用信息显示
\\\'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>
返回类别: 教程
上一教程: 用ASPJPEG组件制作图片的缩略图和加水印
下一教程: 如何制作无状态的ASP组件

您可以阅读与"面向对象的ASP编程之八-服务器端函数"相关的教程:
· 面向对象的ASP编程之九-客户器端函数
· 面向对象的ASP编程之四-一些常用的函数
· 面向对象的ASP编程之六-用于自动显示RECORDSET的表格
· 面向对象的ASP编程之五-ADODB的类封装
· asp+语法介绍(三)----asp+的服务器端编程初步
    微笑服务 优质保证 索取样品