'**************************************************
'Function ID: 0025 [Get database link string]
'Function name: GetConnStr
'Function: Obtain the database link string, and can generate MsAccess and MsSqlServer link strings.
'Parameter: Lx --- 0 is MsAccess, 1 is MsSqlServer
'Parameter: Dbiporpath ---- Database IP or path
'Parameter: Dbmc ---- Database name
'Parameter: Dbuid ---- Database user name
'Parameter: Dbupwd ---- Database user password
'Return value: link string
'Example:/
'**************************************************
Public Function GetConnStr(ByVal Lx,ByVal Dbiporpath,ByVal Dbmc,ByVal Dbuid,ByVal Dbupwd)
GetConnStr=""
If Lx=0 Then
If Right(Dbiporpath,1)<>"\" Then Dbiporpath=Dbiporpath & "\"
GetConnStr ="Provider=.4.0;Data Source="&Dbiporpath&Dbmc&";Jet OLEDB:Database Password="&Dbupwd&";"
End If
If Lx=1 Then
GetConnStr ="DRIVER=SQL Server;UID="&Dbuid&";DATABASE="&Dbmc&";SERVER="&Dbiporpath&";PWD="&Dbupwd&";"
End If
End Function
'**************************************************
'Function ID: 0026 [Get multipart/form-data upload file]
'Function name: GetImageData
'Function: Get multipart/form-data to upload files
'Parameter: MaxSize ---- The limit size of upload, unit: M (megabytes)
'Return value: binary data
'Example:
'**************************************************
Public Function GetImageData(ByVal MaxSize)
GetImageData=""
DIM formsize,Formdata,bncrlf,divider,datastart,dataend,mydata
formsize=
if (formsize<=(MaxSize*1024*1024)) then
Formdata=(formsize)
Pos_ts=LenB(getByteString(Chr(13) & Chr(10) & Chr(13) & Chr(10)))
Pos_b=InstrB(Formdata,getByteString(Chr(13) & Chr(10) & Chr(13) & Chr(10)))+Pos_ts
nFormdata=MidB(Formdata,Pos_b)
Pos_ts=InstrB(nFormdata,getByteString(Chr(13) & Chr(10) & "--"))
nnFormdata=MidB(nFormdata,Pos_ts)
Pos_e=LenB(Formdata)-LenB(nnFormdata)-Pos_b+1
datastart =Pos_b
dataend=Pos_e
mydata=midb(Formdata,datastart,dataend)
End If
GetImageData=mydata
End Function
''''Convert the string to a binary string
Function getByteString(StringStr)
For i=1 to Len(StringStr)
char=Mid(StringStr,i,1)
getByteString=getByteString & chrB(AscB(char))
Next
End function
'**************************************************
'Function ID: 0027 [Save or view the data uploaded to the database, with call upload window]
'Function name: GoImgToDb
'Function: Save or view the data uploaded to the database, with call upload window
'Arguments: PPLX ---- Execution type (empty is save, ID number is the file that views the ID)
'Arguments: PUrl ---- The URL part of the main executor
'Parameter: ConnStr --- The database link string for uploading the file
'Parameter: ImagTbname ---- The name of the data table saved by the file
'Parameter: Did ---- File ID field name
'Arguments: Dmc ---- File name Field name
'Arguments: Dlx ---- File type field name
'Parameter: Dmem ---- File description field name
'Arguments: Ddata ---- The field name of the binary data of the file
'Parameter: MaxSize ---- The limit size of upload, unit: M (megabytes)
'Parameter: IDLX ---- The type of the ID field is identified (0 character type 1 numerical (non-auto-incremental type) 2 numerical (auto-incremental type))
'Return value: successfully saved JAVASCRIPT Note that the field length should exceed 20 characters in non-auto increments.
'Example: GoImgToDb("17","http://127.0.0.1/",GetConnStr(1,"127.0.0.1","temp","sa","mzy1029"),"img","id","mc","lx","mem","data",20)
'Example: GoImgToDb("","http://127.0.0.1/",GetConnStr(1,"127.0.0.1","temp","sa","mzy1029"),"img","id","mc","lx","mem","data",20)
'**************************************************
Public Function GoImgToDb(ByVal PPLX,ByVal PUrl,ByVal ConnStr,ByVal ImagTbname,ByVal Did,ByVal Dmc,ByVal Dlx,ByVal Dmem,ByVal Ddata,ByVal MaxSize,ByVal IDLX)
DIM Pjobs,Pjurl
tempimg_conn_str=ConnStr
Set fu_Conn=("")
Set fu_Rs=("")
fu_Conn.open tempimg_conn_str
If JCID(PPLX)=0 Then
Pjobs=Request("img")
If InStr(PUrl,"?")>0 Then
Pjurl=PUrl&"&img=sav"
Else
Pjurl=PUrl&"?img=sav"
End If
If Pjobs="" then PosImageWin(Pjurl)
If Pjobs="sav" Then
Sql_Str="SELECT "&Did&","&Dmc&","&Dlx&","&Dmem&","&Ddata&" FROM "&ImagTbname
fu_Rs.open Sql_Str,fu_Conn,3,3
fu_Rs.addnew
If IDLX < 2 Then
fu_Rs(Did) =MakeTheID()
End If
fu_Rs(Dmc) =Request("mc")
fu_Rs(Dlx) =Request("lx")
fu_Rs(Dmem) =Request("mem")
fu_Rs(Ddata).AppendChunk GetImageData(JCID(MaxSize))
fu_Rs.update
fu_Rs.Close
fu_Rs.open Sql_Str,fu_Conn,3,3
fu_Rs.MoveLast
"<SCRIPT LANGUAGE=JAVASCRIPT>"&vbCrlf
"='"&fu_Rs(Did)&"';"&vbCrlf
"='Data has been saved successfully!';"
"</SCRIPT>"&vbCrlf
End If
Else
If IDLX > 0 Then
Sql_Str="SELECT "&Did&","&Dmc&","&Dlx&","&Dmem&","&Ddata&" FROM "&ImagTbname&" WHERE ("&Did&" ="&PPLX&")"
Else
Sql_Str="SELECT "&Did&","&Dmc&","&Dlx&","&Dmem&","&Ddata&" FROM "&ImagTbname&" WHERE ("&Did&" ='"&PPLX&"')"
End If
fu_Rs.open Sql_Str,fu_Conn,1,1
If fu_Rs.RecordCount >0 Then
tempaa=Trim(fu_Rs(Dlx))
= -9999
"pragma", "no-cache"
"cache-ctrol", "no-cache"
= TRUE
"Content-Disposition:","attachment;filename="&fu_Rs(Dmc)&"."&tempaa
="application/"&Trim(fu_Rs(Dlx))
fu_Rs(Ddata)
End If
End If
fu_Rs.Close
fu_Conn.close
Set fu_Rs = Nothing
Set fu_Conn = Nothing
End Function
'**************************************************''''
'Function ID: 0028 [Get the image type|width|height]
'Function name: GetImageDx
'Effect: obtain the type of image|width|height
'Parameters: filepath ---- File path and file naming
'Return value: "Type|Width|High"
'**************************************************''''
Public Function GetImageDx(ByVal filepath)
DIM Tempsm,NBxx,WJXX(3)
SET Tempsm = ("")
=3
=1
filepath
NBxx=Hex(BinVal((3)))
WJXX(0)=NBxx
WJXX(1)="0"
WJXX(2)="0"
If NBxx="464947" Then
WJXX(0)="GIF"
(3)
WJXX(1)=BinVal((2))
WJXX(2)=BinVal((2))
End If
If NBxx="FFD8FF" Then
WJXX(0)="JPG"
do
do: p1=binVal((1)): loop while p1=255 and not
if p1>191 and p1<196 then exit do else (binval2((2))-2)
do:p1=binVal((1)):loop while p1<255 and not
loop while true
(3)
WJXX(2)=binval2((2))
WJXX(1)=binval2((2))
End If
If Mid(NBxx,3)="4D42" Then
(15)
WJXX(0)="BMP"
WJXX(1)=binval((4))
WJXX(2)=binval((4))
End If
If NBxx="4E5089" Then
WJXX(0)="PNG"
(15)
WJXX(1)=BinVal2((2))
(2)
WJXX(2)=BinVal2((2))
End If
If NBxx="535743" Then
WJXX(0)="SWF"
(5)
binData=(1)
sConv=Num2Str(ascb(binData),2 ,8)
nBits=Str2Num(left(sConv,5),2)
sConv=mid(sConv,6)
while(len(sConv)<nBits*4)
binData=(1)
sConv=sConv&Num2Str(ascb(binData),2 ,8)
wend
WJXX(1)=int(abs(Str2Num(mid(sConv,1*nBits+1,nBits),2)-Str2Num(mid(sConv,0*nBits+1,nBits),2))/20)
WJXX(2)=int(abs(Str2Num(mid(sConv,3*nBits+1,nBits),2)-Str2Num(mid(sConv,2*nBits+1,nBits),2))/20)
End If
SET Tempsm=nothing
GetImageDx = WJXX(0)&"|"&WJXX(1)&"|"&WJXX(2)
End Function
Function BinVal(bin)
dim ret
ret = 0
for i = lenb(bin) to 1 step -1
ret = ret *256 + ascb(midb(bin,i,1))
next
BinVal=ret
End Function
Function BinVal2(bin)
dim ret
ret = 0
for i = 1 to lenb(bin)
ret = ret *256 + ascb(midb(bin,i,1))
next
BinVal2=ret
End Function
Function Str2Num(str,base)
dim ret
ret = 0
for i=1 to len(str)
ret = ret *base + cint(mid(str,i,1))
next
Str2Num=ret
End Function
Function Num2Str(num,base,lens)
dim ret
ret = ""
while(num>=base)
ret = (num mod base) & ret
num = (num - num mod base)/base
wend
Num2Str = right(string(lens,"0") & num & ret,lens)
End Function
Previous page12345678Next pageRead the full text