'# 注意:如果系统不支持建立Scripting.FileSystemObject对象,那么数据库压缩功能将无法使用 '# Access 数据库类 '# CreateDbFile 建立一个Access 数据库文件 '# CompactDatabase 压缩一个Access 数据库文件 '# 建立对象方法: '# Set a = New DatabaseTools '# by (萧寒雪) s.f. '#########################################################################################
Class DatabaseTools
Public function CreateDBfile(byVal dbFileName,byVal DbVer,byVal SavePath) '建立数据库文件 'If DbVer is 0 Then Create Access97 dbFile 'If DbVer is 1 Then Create Access2000 dbFile On error resume Next If Right(SavePath,1)<>"/" Or Right(SavePath,1)<>"/" Then SavePath = Trim(SavePath) & "/" If Left(dbFileName,1)="/" Or Left(dbFileName,1)="/" Then dbFileName = Trim(Mid(dbFileName,2,Len(dbFileName))) If DbExists(SavePath & dbFileName) Then Response.Write ("对不起,该数据库已经存在!") CreateDBfile = False Else Dim Ca Set Ca = Server.CreateObject("ADOX.Catalog") If Err.number<>0 Then Response.Write ("无法建立,请检查错误信息 " & Err.number & " " & Err.Description) Err.Clear Exit function End If If DbVer=0 Then call Ca.Create("Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & SavePath & dbFileName) Else call Ca.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & SavePath & dbFileName) End If Set Ca = Nothing CreateDBfile = True End If End function
Public function CompactDatabase(byVal dbFileName,byVal DbVer,byVal SavePath) '压缩数据库文件 '0 为access 97 '1 为access 2000 On Error resume next If Right(SavePath,1)<>"/" Or Right(SavePath,1)<>"/" Then SavePath = Trim(SavePath) & "/" If Left(dbFileName,1)="/" Or Left(dbFileName,1)="/" Then dbFileName = Trim(Mid(dbFileName,2,Len(dbFileName))) If DbExists(SavePath & dbFileName) Then Response.Write ("对不起,该数据库已经存在!") CompactDatabase = False Else Dim Cd Set Cd =Server.CreateObject("JRO.JetEngine") If Err.number<>0 Then Response.Write ("无法压缩,请检查错误信息 " & Err.number & " " & Err.Description) Err.Clear Exit function End If If DbVer=0 Then call Cd.CompactDatabase("Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & SavePath & dbFileName,"Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & SavePath & dbFileName & ".bak.mdb;Jet OLEDB;Encrypt Database=True") Else call Cd.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & SavePath & dbFileName,"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & SavePath & dbFileName & ".bak.mdb;Jet OLEDB;Encrypt Database=True") End If '删除旧的数据库文件 call DeleteFile(SavePath & dbFileName) '将压缩后的数据库文件还原 call RenameFile(SavePath & dbFileName & ".bak.mdb",SavePath & dbFileName) Set Cd = False CompactDatabase = True End If end function
Public function DbExists(byVal dbPath) '查找数据库文件是否存在 On Error resume Next Dim c Set c = Server.CreateObject("ADODB.Connection") c.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPath If Err.number<>0 Then Err.Clear DbExists = false else DbExists = True End If set c = nothing End function
Public function AppPath() '取当前真实路径 AppPath = Server.MapPath("./") End function
Public function AppName() '取当前程序名称 AppName = Mid(Request.ServerVariables("SCRIPT_NAME"),(InStrRev(Request.ServerVariables("SCRIPT_NAME") ,"/",-1,1))+1,Len(Request.ServerVariables("SCRIPT_NAME"))) End Function
Public function DeleteFile(filespec) '删除一个文件 Dim fso Set fso = CreateObject("Scripting.FileSystemObject") If Err.number<>0 Then Response.Write("删除文件发生错误!请查看错误信息 " & Err.number & " " & Err.Description) Err.Clear DeleteFile = False End If call fso.DeleteFile(filespec) Set fso = Nothing DeleteFile = True End function
Public function RenameFile(filespec1,filespec2) '修改一个文件 Dim fso Set fso = CreateObject("Scripting.FileSystemObject") If Err.number<>0 Then Response.Write("修改文件名时发生错误!请查看错误信息 " & Err.number & " " & Err.Description) Err.Clear RenameFile = False End If call fso.CopyFile(filespec1,filespec2,True) call fso.DeleteFile(filespec1) Set fso = Nothing RenameFile = True End function
End Class %>
现在已可以压缩有密码的数据库,代码如下,但是压缩之后的数据库密码就没有了!如何解决?
<% Const JET_3X = 4
Function CompactDB(dbPath, boolIs97) Dim fso, Engine, strDBPath strDBPath = left(dbPath,instrrev(DBPath,"/")) Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(dbPath) Then Set Engine = CreateObject("JRO.JetEngine")
Else CompactDB = "数据库名称或路径不正确. 请重试!" & vbCrLf End If
End Function %> asp编程有用的例子(一) 1.如何用Asp判断你的网站的虚拟物理路径 答:使用Mappath方法 < p align="center" >< font size="4" face="Arial" >< b > The Physical path to this virtual website is: < /b >< /font > < font color="#FF0000" size="6" face="Arial" > < %= Server.MapPath("/")% > < /font >< /p > 2.我如何知道使用者所用的浏览器? 答:使用the Request object方法 strBrowser=Request.ServerVariables("HTTP_USER_AGENT") If Instr(strBrowser,"MSIE") < > 0 Then Response.redirect("ForMSIEOnly.htm") Else Response.redirect("ForAll.htm") End If
3.如何计算每天的平均反复访问人数 答:解决方法 < % startdate=DateDiff("d",Now,"01/01/1990") if strdate< 0 then startdate=startdate*-1 avgvpd=Int((usercnt)/startdate) % > 显示结果 < % response.write(avgvpd) % > that is it.this page have been viewed since November 10,1998
'*********************************************** '用COM对象Scripting.FileSystemObject操作文本文件 '*********************************************** Set fs = Wscript.CreateObject("Scripting.FileSystemObject") Set a = fs.CreateTextFile("c:/testfile.txt", True) a.WriteLine("这是一个测试。") a.Close
现在我们言归正传来看看如何对文件进行压缩和解压! 大家都知道winzip对文件解压和压缩都易如反掌,但是如何通过程序和命令行对其调用呢? 当然winzip的作者已经开发出 WinZip Command Line Support Add-On Version 1.0 大家去可以去http://www.winzip.com/wzcline.htm 下载wzcline.exe! 前提是本机须安装winzip8.0或更高版本的支持,如果你不是winzip8.0,去 http://www.winzip.com/download.htm 下载!
Public Property Let oFS(objOFS) m_oFS = objOFS End Property
Public Property Get oFS() Set oFS = Server.CreateObject("Scripting.FileSystemObject") End Property
Sub init(strRoot) 'Root to Search (c:, d:, e:) Dim oDrive, oRootDir IF oFS.FolderExists(strRoot) Then IF Len(strRoot) < 3 Then 'Must Be a Drive Set oDrive = oFS.GetDrive(strRoot) Set oRootDir = oDrive.RootFolder Else Set oRootDir = oFS.GetFolder(strRoot) End IF Else EchoB("Folder ( " & strRoot & " ) Not Found.") Exit Sub End IF setRoot = oRootDir
Echo("") BuildOptions End Sub
Sub getAllDlls(oParentFolder) Dim oSubFolders, oFile, oFiles Set oSubFolders = oParentFolder.SubFolders Set opFiles = oParentFolder.Files
For Each oFile in opFiles IF Right(lCase(oFile.Name), 4) = ".dll" OR Right(lCase(oFile.Name), 4) = ".ocx" Then Echo("") End IF Next
On Error Resume Next For Each oFolder In oSubFolders 'Iterate All Folders in Drive Set oFiles = oFolder.Files For Each oFile in oFiles IF Right(lCase(oFile.Name), 4) = ".dll" OR Right(lCase(oFile.Name), 4) = ".ocx" Then Echo("") End IF Next Call getAllDlls(oFolder) Next On Error GoTo 0 End Sub
Sub Register(strFilePath, regMethod) Dim theFile, strFile, oShell, exitcode Set theFile = oFS.GetFile(strFilePath) strFile = theFile.Path
Sub BuildOptions EchoB("Register: ") EchoB("unRegister: ") End Sub
Function Echo(str) Echo = Response.Write(str & vbCrLf) End Function
Function EchoB(str) EchoB = Response.Write(str & " " & vbCrLf) End Function
Sub Cleanup(obj) If isObject(obj) Then Set obj = Nothing End IF End Sub
Sub Class_Terminate() Cleanup oFS End Sub End Class %> 列出你的所有Session变: <%@ Language=VBScript %> <% Option Explicit %> <% Response.Write "在你的程序中一共使用了 " & Session.Contents.Count & _ " 个Session变量
" Dim strName, iLoop For Each strName in Session.Contents '判断一个Session变量是否为数组 If IsArray(Session(strName)) then '如果是数组,那么罗列出所有的数组元素内容 For iLoop = LBound(Session(strName)) to UBound(Session(strName)) Response.Write strName & "(" & iLoop & ") - " & _ Session(strName)(iLoop) & " " Next Else '如果不是数组,那么直接显示 Response.Write strName & " - " & Session.Contents(strName) & " " End If Next %> 利用CDONTS发送邮件的ASP函数 <% 'Last Updated By Recon On 05/14/2001 'On Error Resume Next
Sub ShowDriveInfo(drvPath) Dim fso, drv, s Set fso = CreateObject("Scripting.FileSystemObject") Set drv = fso.GetDrive(fso.GetDriveName(drvPath)) s = "Drive " & UCase(drvPath) & " - " s = s & drv.VolumeName & " " s = s & "Total Space: " & FormatNumber(drv.TotalSize / 1024, 0) s = s & " Kb" & " " s = s & "Free Space: " & FormatNumber(drv.FreeSpace / 1024, 0) s = s & " Kb" & " " Response.Write s End Sub
下面的代码说明在 JScript 中实现同样的功能: function ShowDriveInfo1(drvPath) { var fso, drv, s =""; fso = new ActiveXObject("Scripting.FileSystemObject"); drv = fso.GetDrive(fso.GetDriveName(drvPath)); s += "Drive " + drvPath.toUpperCase()+ " - "; s += drv.VolumeName + " "; s += "Total Space: " + drv.TotalSize / 1024; s += " Kb" + " "; s += "Free Space: " + drv.FreeSpace / 1024; s += " Kb" + " "; Response.Write(s); }
If curpage = 1 Then retval = retval & "首页 前页 " Else retval = retval & "首页前页 " End If If curpage = rs.pagecount Then retval = retval & "后页 末页" Else retval = retval & "后页末页" End if
retval = retval & " " BasePage = (curpage / 10) * 10 If BasePage > 0 Then retval = retval & " <<" For j = 1 to 10 pageNumber = BasePage + j If PageNumber > rs.pagecount Then Exit For If pageNumber = Cint(curpage) Then retval = retval & " " & pageNumber & "" Else retval = retval & " " & pageNumber & "" End If Next If rs.pagecount > BasePage Then retval = retval & " >>"
ExportPageInfo = retval End Function
应用
<% adoPageRS.open "SELECT * FROM news ORDER BY addtime DESC", conn, 1, 1 if err.number <> 0 then response.write "数据库操作失败:"&err.description else if adoPageRS.eof and adoPageRS.bof then response.write "没有记录" else %>
新 闻 标 题
日期
操 作
<% adoPageRS.pagesize = 10 adoPageRS.absolutepage = curpage for i = 0 to 9 %>
<% adoPageRS.movenext if adoPageRS.eof then i = i + 1 exit for End If next %>
<% = ExportPageInfo(adoPageRS, curpage, i, "Newsman.asp?") %>
从ASP调用SQL中的图像: 如 何处理ASP中的图象 在用ASP编程中,很多时侯要用到图象。对于单纯从数据库中处理一个图象,方法大家讲了很多,也不难, 可以看下面的代码: 这里假设你有个数据库名字叫:PUBS,在数据库中有一个叫:PUB_INFO的表,在表中有一个LOGO 的BLOB列。我们查出PUB_ID=0736的人的相片。 FILE: SHOWIMG.ASP *************************************** < %@ LANGUAGE="VBSCRIPT" %> < % ’ Clear out the existing HTTP header information Response.Expires = 0 Response.Buffer = TRUE Response.Clear ’ Change the HTTP header to reflect that an image is being passed. Response.ContentType = "image/gif" Set cn = Server.CreateObject("ADODB.Connection") ’ The following open line assumes you have set up a System DataSource ’ by the name of myDSN. cn.Open "DSN=myDSN;UID=sa;PWD=;DATABASE=pubs" Set rs = cn.Execute("SELECT logo FROM pub_info WHERE pub_id=’0736’") Response.BinaryWrite rs("logo") Response.End %> ***************************************** 执行这个ASP文件就可以看到你存在数据库中的图象了。 但如果是同时处理文字和图象就会有些困难了:-( 比如:一个企业的人员管理,后台数据库可以用SYBASE或SQL SERVER等。(我在这用SQL SERVER)当 你在企业内部需要用到BROWSE/SERVER方式,即用浏览器查看员工的个人信息时,就即要处理文字信息同时 还要用到关于图象的技巧。 问题在于你显示文字信息时HTML的HEAD中的CONTENT=“TEXT/HTML”,而显示图象则必须是 CONTENT=“IMAGE/GIF”或者是CONTENT=”IMAGE/JPEG“。因此你是无法只用一个ASP文件就把文字信息和 图象都处理完的,解决的办法是:用一个单独的ASP文件处理图象,然后在处理文字信息的ASP文件中调用 这个ASP文件。 在这给大家介绍一个我的解决方法,希望大家一起讨论: 环境:WINNT4.0 SQL SERVER IIS3.0 数据库名:RSDA 表名:RSDA_TABLE 目的:从RSDA_TABLE中查出ID=00001的人员的信息,包括姓名,年龄和照片 第一步:创建一个查询表单RSDA.HTM: ********************************** < html> < head> < /head> < body> < form method="POST" action="SEARCH.ASP"> < p>请输入编号:< input type="text" name="T1" size="20"> < input type="submit" value="提交" name="B1"> < /form> < /body> *********************************** 第二步:建立SEARCH.ASP *********************************** < html> < head> < meta http-equiv="content-type" content="text/html;charset=gb2312"> < title>查询结果< /title> < /head> < body bgColor=Azure> < % session("RSDA_ID")=Request.Form("T1") ’这里我用了一个SESSION变量,是为了在处理图象的ASP文件中再次调用 temp_id=session("RSDA_ID") < font size=4 color=OrangeRed> 查询结果:< /font> < %set conntemp=server.createobject("adodb.connection") conntemp.open "dsn=RSDA;uid=sa;pwd=SA" set rstemp=conntemp.execute("select * from RSDA_TABLE where rsda=’"&temp_id&"’") % > < % ’put headings on the table of field names nobody="对不起!在我们的数据库里没有您要找的资料!"%> ’判断是否有这个人 < %if rstemp.eof then % > < font size="5" color=OrangeRed> < %Response.Write(nobody)% >< /font> < %else% > < div align="center"> < center> < table border="1" width="73%" height="399"> < tr> < td width="21%" height="49" align="center">< p align="center">姓 名< /td> < td width="30%" height="49" align="center"> < font size=4 color=OrangeRed>< /font>< /td> < /td> < tr> < p align="center">年 龄< /td> < td width="30%" height="47" align="center"> < font size=4 color=OrangeRed>< %=rstemp(0)% >< /font>< /td> < /tr> < tr> < td width="49%" height="146" rowspan="3" colspan="2"> < img src="jpg.asp">< /td> ’JPG.ASP就是我们将要建立的专门处理图象的ASP文件 < /tr> < /table> < /center>< /div> rstemp.close set rstemp=nothing conntemp.close set conntemp=nothing % > < /BODY> < /HTML> *********************************** 第三步:建立处理图象的ASP文件。(JPG.ASP) *********************************** < % Response.Expires = 0 Response.Buffer = TRUE Response.Clear ’ Open database Set conntemp = Server.CreateObject("ADODB.Connection") conntemp.open "dsn=RSDA;uid=sa;pwd=SA" ’change http header Response.ContentType = "image/jpeg" ’ or "IMAGE/GIF" ’ Get picture TEMP_ID=session("RSDA_ID") Set Rs = conntemp.Execute("SELECT photo from RSDA_table where ID=’"&TEMP_ID&"’") Response.BinaryWrite Rs("photo") Session.Abandon Response.End % > ********************************** 这里主要就是用到了一个小技巧就是利用了一个SESSION变量来实现两次同条件查询。 大家如我上述只需少量改动,就可以实现一个页面既有文字又有图象了! asp常常用到的一些东西, 我做东西一般下面的东西经常用(拷贝)
<%=Request.ServerVariables("remote_addr")%>
FOR each item in Request.form tempvalue=trim(Request(item)) tempvalue=Replace(tempvalue,chr(13)&chr(10)," ") tempvalue=Replace(tempvalue,"
"," ") if tempvalue="" then tempvalue=0 Execute item&"="""&tempvalue&"""" 'response.write item&"="&tempvalue&" " next 'response.write request("id") 'response.end
if ="" then response.write "" response.write "" response.end end if
sql="select max(id) from pack" set RS=conn.execute(sql) if isnull(RS(0)) then id=1 else id=RS(0)+1 end if set rs=nothing
sql="insert into pack(id,strpackdm,strusername) values("&id&",'"&strpackdm&"','"&Session("username")&"')" set RS=conn.execute(sql)
sql="update pack set "&Itemname&"='"&tempvalue&"' where id="&id&"" if Itemname<>"id" then response.write sql&" " set rs=conn.execute(sql)
if err.number<>0 then '错误处理 response.write "数据库操作失败:" & err.description err.clear end if
Set rs=Nothing Conn.close Set conn=Nothing
do while not rs.eof and rowcount>0
rowcount=rowcount-1 rs.MoveNext
do while not rs.eof
rs.MoveNext loop
for each item in rs2.fields Execute item.name&"="""&trim(rs2(""&item.name&""))&"""" next
function Mycn(str) str=lcase(str) str=replace(str,"","") response.write str end function
dim conn dim connstr on error resume next set conn=server.CreateObject("adodb.connection")
Private Function LShift(lValue, iShiftBits) If iShiftBits = 0 Then LShift = lValue Exit Function ElseIf iShiftBits = 31 Then If lValue And 1 Then LShift = &H80000000 Else LShift = 0 End If Exit Function ElseIf iShiftBits < 0 Or iShiftBits > 31 Then Err.Raise 6 End If
If (lValue And m_l2Power(31 - iShiftBits)) Then LShift = ((lValue And m_lOnBits(31 - (iShiftBits + 1))) * m_l2Power(iShiftBits)) Or &H80000000 Else LShift = ((lValue And m_lOnBits(31 - iShiftBits)) * m_l2Power(iShiftBits)) End If End Function
Private Function RShift(lValue, iShiftBits) If iShiftBits = 0 Then RShift = lValue Exit Function ElseIf iShiftBits = 31 Then If lValue And &H80000000 Then RShift = 1 Else RShift = 0 End If Exit Function ElseIf iShiftBits < 0 Or iShiftBits > 31 Then Err.Raise 6 End If
RShift = (lValue And &H7FFFFFFE) / m_l2Power(iShiftBits)
If (lValue And &H80000000) Then RShift = (RShift Or (&H40000000 / m_l2Power(iShiftBits - 1))) End If End Function
Private Function RotateLeft(lValue, iShiftBits) RotateLeft = LShift(lValue, iShiftBits) Or RShift(lValue, (32 - iShiftBits)) End Function
Private Function AddUnsigned(lX, lY) Dim lX4 Dim lY4 Dim lX8 Dim lY8 Dim lResult
lX8 = lX And &H80000000 lY8 = lY And &H80000000 lX4 = lX And &H40000000 lY4 = lY And &H40000000
lResult = (lX And &H3FFFFFFF) + (lY And &H3FFFFFFF)
If lX4 And lY4 Then lResult = lResult Xor &H80000000 Xor lX8 Xor lY8 ElseIf lX4 Or lY4 Then If lResult And &H40000000 Then lResult = lResult Xor &HC0000000 Xor lX8 Xor lY8 Else lResult = lResult Xor &H40000000 Xor lX8 Xor lY8 End If Else lResult = lResult Xor lX8 Xor lY8 End If
AddUnsigned = lResult End Function
Private Function md5_F(x, y, z) md5_F = (x And y) Or ((Not x) And z) End Function
Private Function md5_G(x, y, z) md5_G = (x And z) Or (y And (Not z)) End Function
Private Function md5_H(x, y, z) md5_H = (x Xor y Xor z) End Function
Private Function md5_I(x, y, z) md5_I = (y Xor (x Or (Not z))) End Function
Private Sub md5_FF(a, b, c, d, x, s, ac) a = AddUnsigned(a, AddUnsigned(AddUnsigned(md5_F(b, c, d), x), ac)) a = RotateLeft(a, s) a = AddUnsigned(a, b) End Sub
Private Sub md5_GG(a, b, c, d, x, s, ac) a = AddUnsigned(a, AddUnsigned(AddUnsigned(md5_G(b, c, d), x), ac)) a = RotateLeft(a, s) a = AddUnsigned(a, b) End Sub
Private Sub md5_HH(a, b, c, d, x, s, ac) a = AddUnsigned(a, AddUnsigned(AddUnsigned(md5_H(b, c, d), x), ac)) a = RotateLeft(a, s) a = AddUnsigned(a, b) End Sub
Private Sub md5_II(a, b, c, d, x, s, ac) a = AddUnsigned(a, AddUnsigned(AddUnsigned(md5_I(b, c, d), x), ac)) a = RotateLeft(a, s) a = AddUnsigned(a, b) End Sub
Private Function ConvertToWordArray(sMessage) Dim lMessageLength Dim lNumberOfWords Dim lWordArray() Dim lBytePosition Dim lByteCount Dim lWordCount
Private Function WordToHex(lValue) Dim lByte Dim lCount
For lCount = 0 To 3 lByte = RShift(lValue, lCount * BITS_TO_A_BYTE) And m_lOnBits(BITS_TO_A_BYTE - 1) WordToHex = WordToHex & Right("0" & Hex(lByte), 2) Next End Function MD5不可逆加密算法的ASP实现实例(一) --------------------------------------
a = &H67452301 b = &HEFCDAB89 c = &H98BADCFE d = &H10325476
For k = 0 To UBound(x) Step 16 AA = a BB = b CC = c DD = d
md5_FF a, b, c, d, x(k + 0), S11, &HD76AA478 md5_FF d, a, b, c, x(k + 1), S12, &HE8C7B756 md5_FF c, d, a, b, x(k + 2), S13, &H242070DB md5_FF b, c, d, a, x(k + 3), S14, &HC1BDCEEE md5_FF a, b, c, d, x(k + 4), S11, &HF57C0FAF md5_FF d, a, b, c, x(k + 5), S12, &H4787C62A md5_FF c, d, a, b, x(k + 6), S13, &HA8304613 md5_FF b, c, d, a, x(k + 7), S14, &HFD469501 md5_FF a, b, c, d, x(k + 8), S11, &H698098D8 md5_FF d, a, b, c, x(k + 9), S12, &H8B44F7AF md5_FF c, d, a, b, x(k + 10), S13, &HFFFF5BB1 md5_FF b, c, d, a, x(k + 11), S14, &H895CD7BE md5_FF a, b, c, d, x(k + 12), S11, &H6B901122 md5_FF d, a, b, c, x(k + 13), S12, &HFD987193 md5_FF c, d, a, b, x(k + 14), S13, &HA679438E md5_FF b, c, d, a, x(k + 15), S14, &H49B40821
md5_GG a, b, c, d, x(k + 1), S21, &HF61E2562 md5_GG d, a, b, c, x(k + 6), S22, &HC040B340 md5_GG c, d, a, b, x(k + 11), S23, &H265E5A51 md5_GG b, c, d, a, x(k + 0), S24, &HE9B6C7AA md5_GG a, b, c, d, x(k + 5), S21, &HD62F105D md5_GG d, a, b, c, x(k + 10), S22, &H2441453 md5_GG c, d, a, b, x(k + 15), S23, &HD8A1E681 md5_GG b, c, d, a, x(k + 4), S24, &HE7D3FBC8 md5_GG a, b, c, d, x(k + 9), S21, &H21E1CDE6 md5_GG d, a, b, c, x(k + 14), S22, &HC33707D6 md5_GG c, d, a, b, x(k + 3), S23, &HF4D50D87 md5_GG b, c, d, a, x(k + 8), S24, &H455A14ED md5_GG a, b, c, d, x(k + 13), S21, &HA9E3E905 md5_GG d, a, b, c, x(k + 2), S22, &HFCEFA3F8 md5_GG c, d, a, b, x(k + 7), S23, &H676F02D9 md5_GG b, c, d, a, x(k + 12), S24, &H8D2A4C8A
md5_HH a, b, c, d, x(k + 5), S31, &HFFFA3942 md5_HH d, a, b, c, x(k + 8), S32, &H8771F681 md5_HH c, d, a, b, x(k + 11), S33, &H6D9D6122 md5_HH b, c, d, a, x(k + 14), S34, &HFDE5380C md5_HH a, b, c, d, x(k + 1), S31, &HA4BEEA44 md5_HH d, a, b, c, x(k + 4), S32, &H4BDECFA9 md5_HH c, d, a, b, x(k + 7), S33, &HF6BB4B60 md5_HH b, c, d, a, x(k + 10), S34, &HBEBFBC70 md5_HH a, b, c, d, x(k + 13), S31, &H289B7EC6 md5_HH d, a, b, c, x(k + 0), S32, &HEAA127FA md5_HH c, d, a, b, x(k + 3), S33, &HD4EF3085 md5_HH b, c, d, a, x(k + 6), S34, &H4881D05 md5_HH a, b, c, d, x(k + 9), S31, &HD9D4D039 md5_HH d, a, b, c, x(k + 12), S32, &HE6DB99E5 md5_HH c, d, a, b, x(k + 15), S33, &H1FA27CF8 md5_HH b, c, d, a, x(k + 2), S34, &HC4AC5665
md5_II a, b, c, d, x(k + 0), S41, &HF4292244 md5_II d, a, b, c, x(k + 7), S42, &H432AFF97 md5_II c, d, a, b, x(k + 14), S43, &HAB9423A7 md5_II b, c, d, a, x(k + 5), S44, &HFC93A039 md5_II a, b, c, d, x(k + 12), S41, &H655B59C3 md5_II d, a, b, c, x(k + 3), S42, &H8F0CCC92 md5_II c, d, a, b, x(k + 10), S43, &HFFEFF47D md5_II b, c, d, a, x(k + 1), S44, &H85845DD1 md5_II a, b, c, d, x(k + 8), S41, &H6FA87E4F md5_II d, a, b, c, x(k + 15), S42, &HFE2CE6E0 md5_II c, d, a, b, x(k + 6), S43, &HA3014314 md5_II b, c, d, a, x(k + 13), S44, &H4E0811A1 md5_II a, b, c, d, x(k + 4), S41, &HF7537E82 md5_II d, a, b, c, x(k + 11), S42, &HBD3AF235 md5_II c, d, a, b, x(k + 2), S43, &H2AD7D2BB md5_II b, c, d, a, x(k + 9), S44, &HEB86D391
a = AddUnsigned(a, AA) b = AddUnsigned(b, BB) c = AddUnsigned(c, CC) d = AddUnsigned(d, DD) Next
MD5 = LCase(WordToHex(a) & WordToHex(b) & WordToHex(c) & WordToHex(d)) ' MD5=LCase(WordToHex(b) & WordToHex(c)) 'I crop this to fit 16byte database password :D End Function
/* 时间有效性判断函数 All by happywinds */ function verifyDate(textObj) { var str=textObj.value; textObj.value = textObj.value.replace(//s+/g,""); if(str.search(/^/d{4}-/d{1,2}-/d{1,2}$/) == 0){ var y = parseInt(str.split("-")[0]); var m = parseInt(str.split("-")[1]); var d = parseInt(str.split("-")[2]); switch(m){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: if(d>31){ return false; textObj.focus(); textObj.select(); }else{ return true; } break; case 2: if((y%4==0 && d>29) ((y%4!=0 && d>28))){ return false; textObj.focus(); textObj.select(); }else{ return true; } break; case 4: case 6: case 9: case 11: if(d>30){ return false; textObj.focus(); textObj.select(); }else{ return true; } break; default: return false; textObj.focus(); textObj.select(); } }else{ return false; textObj.focus(); textObj.select(); } } meizz(梅花雨)斑竹的Javascript脚本日历输入控件(呵呵,我借花献佛了) ---------------------------------------------- 调用的代码:
或者
控件的代码:
'); document.writeln('
'); document.writeln('
'); var n=0; for (j=0;j<5;j++){ document.writeln ('
var meizzTheYear=new Date().getFullYear(); //定义年的变量的初始值 var meizzTheMonth=new Date().getMonth()+1; //定义月的变量的初始值 var meizzWDay=new Array(37); //定义写日期的数组
function document.onclick() //任意点击时关闭该控件 { with(window.event.srcElement) { if (tagName != "INPUT" && getAttribute("Author")==null) document.all.meizzDateLayer.style.display="none"; } }
function meizzWriteHead(yy,mm) //往 head 中写入当前的年与月 { document.all.meizzYearHead.innerText = yy; document.all.meizzMonthHead.innerText = mm; }
function tmpSelectYearInnerHTML(strYear) //年份的下拉框 { if (strYear.match(//D/)!=null){alert("年份输入参数不是数字!");return;} var m = (strYear) ? strYear : new Date().getFullYear(); if (m < 1000 m > 9999) {alert("年份值不在 1000 到 9999 之间!");return;} var n = m - 10; if (n < 1000) n = 1000; if (n + 26 > 9999) n = 9974; var s = ""; document.all.tmpSelectYearLayer.style.display=""; document.all.tmpSelectYearLayer.innerHTML = selectInnerHTML; document.all.tmpSelectYear.focus(); }
function tmpSelectMonthInnerHTML(strMonth) //月份的下拉框 { if (strMonth.match(//D/)!=null){alert("月份输入参数不是数字!");return;} var m = (strMonth) ? strMonth : new Date().getMonth() + 1; var s = ""; document.all.tmpSelectMonthLayer.style.display=""; document.all.tmpSelectMonthLayer.innerHTML = selectInnerHTML; document.all.tmpSelectMonth.focus(); }
function closeLayer() //这个层的关闭 { document.all.meizzDateLayer.style.display="none"; }
function document.onkeydown() { if (window.event.keyCode==27)document.all.meizzDateLayer.style.display="none"; }
function IsPinYear(year) //判断是否闰平年 { if (0==year%4&&((year%100!=0)(year%400==0))) return true;else return false; }
function GetMonthCount(year,month) //闰年二月为29天 { var c=MonHead[month-1];if((month==2)&&IsPinYear(year)) c++;return c; }
function GetDOW(day,month,year) //求某天的星期几 { var dt=new Date(year,month-1,day).getDay()/7; return dt; }
function meizzPrevY() //往前翻 Year { if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear--;} else{alert("年份超出范围(1000-9999)!");} meizzSetDay(meizzTheYear,meizzTheMonth); } function meizzNextY() //往后翻 Year { if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear++;} else{alert("年份超出范围(1000-9999)!");} meizzSetDay(meizzTheYear,meizzTheMonth); } function meizzToday() //Today Button { meizzTheYear = new Date().getFullYear(); meizzTheMonth = new Date().getMonth()+1; meizzSetDay(meizzTheYear,meizzTheMonth); } function meizzPrevM() //往前翻月份 { if(meizzTheMonth>1){meizzTheMonth--}else{meizzTheYear--;meizzTheMonth=12;} meizzSetDay(meizzTheYear,meizzTheMonth); } function meizzNextM() //往后翻月份 { if(meizzTheMonth==12){meizzTheYear++;meizzTheMonth=1}else{meizzTheMonth++} meizzSetDay(meizzTheYear,meizzTheMonth); }
function meizzSetDay(yy,mm) //主要的写程序********** { meizzWriteHead(yy,mm); for (var i = 0; i < 37; i++){meizzWDay[i]=""}; //将显示框的内容全部清空 var day1 = 1,firstday = new Date(yy,mm-1,1).getDay(); //某月第一天的星期几 for (var i = firstday; day1 < GetMonthCount(yy,mm)+1; i++){meizzWDay[i]=day1;day1++;} for (var i = 0; i < 37; i++) { var da = eval("document.all.meizzDay"+i) //书写新的一个月的日期星期排列 if (meizzWDay[i]!="") { da.innerHTML = "" + meizzWDay[i] + ""; da.style.backgroundColor = (yy == new Date().getFullYear() && mm == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate()) ? "#FFD700" : "#ADD8E6"; da.style.cursor="hand" } else{da.innerHTML="";da.style.backgroundColor="";da.style.cursor="default"} } } function meizzDayClick(n) //点击显示框选取日期,主输入函数************* { var yy = meizzTheYear; var mm = meizzTheMonth; if (mm < 10){mm = "0" + mm;} if (outObject) { if (!n) {outObject.value=""; return;} if ( n < 10){n = "0" + n;} outObject.value= yy + "" + mm + "" + n ; //注:在这里你可以输出改成你想要的格式 closeLayer(); } else {closeLayer(); alert("您所要输出的控件对象并不存在!");} } meizzSetDay(meizzTheYear,meizzTheMonth); // --> web进度条 ----------------------------------
这样,已经打开SomePage.asp的用户如果点击后退按钮,浏览器将重新请求服务器下载页面,服务器检查到Session ("FirstTimeToPage")包含了一个值,于是就清除Session("FirstTimeToPage"),并把用户重定向到其他页面。当然,所有 这一切都需要用户启用了Cookie,否则会话变量将是无效的。(有关该问题的更多说明,请参见For session variables to work, must the Web visitor have cookies enabled?) 另外,我们也可以用客户端代码使浏览器不再缓存Web页面:
* Microsoft Access databases.不支持 转换大写中文数字 ---------------------- 转换代码如下:
function Transform() { var whole = document.all.num.value;
//分离整数与小数 var num; var dig; if(whole.indexOf(".") == -1) { num = whole; dig = ""; } else { num = whole.substr(0,whole.indexOf(".")); dig = whole.substr( whole.indexOf(".")+1, whole.length); }
//转换整数部分 var i=1; var len = num.length;
var dw2 = new Array("","万","亿");//大单位 var dw1 = new Array("拾","佰","千");//小单位 var dw = new Array("","壹","贰","叁","肆","伍","陆","柒","捌","玖");//整数部分用 var dws = new Array("零","壹","贰","叁","肆","伍","陆","柒","捌","玖");//小数部分用 var k1=0;//计小单位 var k2=0;//计大单位 var str="";
for(i=1;i<=len;i++) { var n = num.charAt(len-i); if(n=="0") { if(k1!=0) str = str.substr( 1, str.length-1); }
set conn = server.createObject("adodb.connection") conn.open "Provider=OraOLEDB.Oracle;Data Source=oracle.mydomain.com;User ID=scott;PASSWORD=tiger;Persist Security Info=True"
set rs = conn.execute("SELECT blobcolumn FROM blobtable WHERE id = 7")
'Write it to the browser response.binaryWrite rs.fields("blobcolumn").value
'Write it to disk dim stream set stream = server.createObject("adodb.stream") stream.type = adTypeBinary stream.open stream.write(rs.fields("blobcolumn").value) stream.saveToFile folderAndFileName, adSaveCreateOverWrite stream.close %> web打印的大全:
#!/bin/bash
#
# Script to start LVS DR real server.
# description: LVS DR real server
#
#. /etc/rc.d/init.d/functions
VIP=10.10.6.252
host='/bin/hostname'
case "$1" in
sta
大多数java开发者使用的都是eclipse,今天感兴趣去eclipse官网搜了一下eclipse.ini的配置,供大家参考,我会把关键的部分给大家用中文解释一下。还是推荐有问题不会直接搜谷歌,看官方文档,这样我们会知道问题的真面目是什么,对问题也有一个全面清晰的认识。
Overview
1、Eclipse.ini的作用
Eclipse startup is controlled by th
import java.util.Arrays;
/**
* 最早是在陈利人老师的微博看到这道题:
* #面试题#An array with n elements which is K most sorted,就是每个element的初始位置和它最终的排序后的位置的距离不超过常数K
* 设计一个排序算法。It should be faster than O(n*lgn)。
原网页被墙,放这里备用。 MySQLdb User's Guide
Contents
Introduction
Installation
_mysql
MySQL C API translation
MySQL C API function mapping
Some _mysql examples
MySQLdb