'*************************************** ***********''''
'Function ID: 0028 [image acquisition type | width | height]
'Function name: getimagedx
'Usage: Image Type obtained | width | height
'Parameter: filepath ---- file path and file name
'Return value: "type | width | height"
'*************************************** ***********''''
Public Function getimagedx (byval filepath)
Dim tempsm, nbxx, wjxx (3)
Set tempsm = server. Createobject ("ADODB. Stream ")
Tempsm. mode = 3
Tempsm. type = 1
Tempsm. Open
Tempsm. loadfromfile filepath
Nbxx = hex (binval (tempsm. Read (3 )))
Wjxx (0) = nbxx
Wjxx (1) = "0"
Wjxx (2) = "0"
If nbxx= "464947" then
Wjxx (0) = "GIF"
Tempsm. Read (3)
Wjxx (1) = binval (tempsm. Read (2 ))
Wjxx (2) = binval (tempsm. Read (2 ))
End if
If nbxx = "ffd8ff" then
Wjxx (0) = "jpg"
Do
Do: p1 = binval (tempsm. Read (1): loop while p1 = 255 and not tempsm. Eos
If P1> 191 and P1 <196 then exit do else tempsm. Read (binval2 (tempsm. Read (2)-2)
Do: p1 = binval (tempsm. Read (1): loop while P1 <255 and not tempsm. Eos
Loop while true
Tempsm. Read (3)
Wjxx (2) = binval2 (tempsm. Read (2 ))
Wjxx (1) = binval2 (tempsm. Read (2 ))
End if
If mid (nbxx, 3) = "4d42" then
Tempsm. Read (15)
Wjxx (0) = "BMP"
Wjxx (1) = binval (tempsm. Read (4 ))
Wjxx (2) = binval (tempsm. Read (4 ))
End if
If nbxx = "4e5089" then
Wjxx (0) = "PNG"
Tempsm. Read (15)
Wjxx (1) = binval2 (tempsm. Read (2 ))
Tempsm. Read (2)
Wjxx (2) = binval2 (tempsm. Read (2 ))
End if
If nbxx= "535743" then
Wjxx (0) = "SWF"
Tempsm. Read (5)
Bindata = tempsm. Read (1)
Sconv = num2str (ASCB (bindata), 2, 8)
Nbits = str2num (left (sconv, 5), 2)
Sconv = mid (sconv, 6)
While (LEN (sconv) <nbits * 4)
Bindata = tempsm. Read (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
Tempsm. Close
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
'*************************************** ***********''''
'Function ID: 0029 [Perform binary analysis on the local file and save it to the specified directory on the server]
'Function name: txtbininfo
'Usage: Perform binary analysis on the local file and save it to the specified directory on the server.
'Parameter: filestr ---- path of the analyzed file and file name
'Parameter: websvfile ---- path and name of the file for saving the analysis information
'Return value: "true" is returned; otherwise, "false" is returned.
'Example: tempsj = request. Form ("tfile ")
'Example: If trim (tempsj) <> "" Then call txtbininfo (tempsj, "d: \ aa.txt ")
'Example: response. write "<form method = 'post' action = 'test. ASP '> <input type = 'file' name = 'tfile'> <input type = 'submit' value = 'Submit' name = 'b1'> </form>"
'*************************************** ***********''''
Public Function txtbininfo (byval filestr, byval websvfile)
Txtbininfo = false
Dim wtempxx
Wtempxx = ""
Set tempsm = server. Createobject ("ADODB. Stream ")
Tempsm. mode = 3
Tempsm. type = 1
Tempsm. Open
Tempsm. loadfromfile (filestr)
Tempredimg = tempsm. Read
For I = lenb (tempredimg) to 1 step-1
Wtempxx = wtempxx & "Address:" & I & "address hexadecimal:" & hex (ASCB (midb (tempredimg, I, 1) & "decimal: "& ASCB (midb (tempredimg, I, 1) & vbcrlf
Next
Wtempxx = wtempxx & vbcrlf & "Size:" & lenb (tempredimg) & "in bytes, the file name is:" & filestr
Set m_fso = Createobject ("scripting. FileSystemObject ")
Set fnamen = m_fso.opentextfile (websvfile, 2, true)
Fnamen. Write wtempxx
Fnamen. Close
Set m_fso = nothing
Tempsm. Close
Set tempsm = nothing
Txtbininfo = true
End Function
'*************************************** ***********''''
'Function ID: 0030 [upload and import a local data table or database to a table in the server database]
'Function name: readcdbtoserv
'Usage: Upload a local data table or database and import it to a table in the server database.
'Parameter: cdbfileup ---- path and file name of the uploaded library or table File
'Parameter: sdbconnstr ---- Server database link string
'Parameter: sdbtbname ---- name of the table to be opened by the server
'Parameter: fildstrarr ---- imported data field string (separated)
'Return value: "true" is returned; otherwise, "false" is returned.
'Note: The file types that can be imported are: (0: Excel 1: Access 2: Text 3: DBF/FoxPro)
'Note: the Excel table is the sheet name, and the text and DBF/FoxPro table names are the full names of the data files, such as aa.txt or AA. DBF.
'Note: Text Data Tables are separated by commas (,). Note: The imported database can only contain one table, and the imported fields must be consistent with the table in the server database.
'Example: Call readcdbtoserv (tempsj, "driver = SQL Server; uid = sa; database = temp; server = 127.0.0.1; Pwd = mzy1029;", "IMG", "Mc, lx, Mem ")
'Example: response. write "<form method = 'post' action = 'test. ASP 'enctype = 'multipart/form-data'> <input type = 'file' name = 'tfile'> <input type = 'submit 'value = 'submit 'name =' b1 '> </form>"
'*************************************** ***********''''
Public Function readcdbtoserv (byval cdbfileup, byval sdbconnstr, byval sdbtbname, byval fildstrarr)
Readcdbtoserv = false
Dim mbdir, mbwjmc, arytemp, vrcdb_conn_str, ofu_conn, ofu_rs, sfu_conn, sfu_rs, ofu_ SQL _str, delimiter, oarytemp, tptrs, gtlx, cdbtbname
Vrcdb_conn_str = ""
Mbdir = readsyspath (1)
If right (mbdir, 1) <> "\" then mbdir = mbdir &"\"
Mbwjmc = cdbfileup
Arytemp = Split (mbwjmc ,"\")
Mbwjmc = arytemp (ubound (arytemp ))
Arytemp = Split (mbwjmc ,".")
Gtlx = ucase (arytemp (ubound (arytemp )))
If upfsrn (100, mbdir, "Temp." & gtlx) then
If gtlx = "xls" then vrcdb_conn_str = "provider = Microsoft. jet. oledb.4.0; extended properties = Excel 8.0; Data Source = "& mbdir &" temp. "& gtlx &"; "''excel [tbname $]
If gtlx = "mdb" then vrcdb_conn_str = "provider = Microsoft. jet. oledb.4.0; Data Source = "& mbdir &" temp. "& gtlx &"; Jet oledb: Database Password =; "'' access
If gtlx = "TXT" then vrcdb_conn_str = "provider = Microsoft. jet. oledb.4.0; Data Source = "& mbdir &"; extended properties = 'text; HDR = yes; FMt = delimited '"'' text (, split)
If gtlx = "DBF" then vrcdb_conn_str = "provider = Microsoft. jet. oledb.4.0; Data Source = "& mbdir &"; extended properties = dbase iv; user id = admin; Password = "'' DBF/FoxPro
Set sfu_conn = server. Createobject ("ADODB. Connection ")
Set sfu_rs = server. Createobject ("ADODB. recordset ")
Sfu_conn.open sdbconnstr
Sfu_ SQL _str = "select" & fildstrarr & "from" & sdbtbname
Set ofu_conn = server. Createobject ("ADODB. Connection ")
Set ofu_rs = server. Createobject ("ADODB. recordset ")
Ofu_conn.open vrcdb_conn_str
Set tptrs = ofu_conn.openschema (20)
Cdbtbname = tptrs (2)
Tptrs. Close
Set tptrs = nothing
If gtlx = "xls" then cdbtbname = "[" & cdbtbname & "]"
Ofu_ SQL _str = "select" & fildstrarr & "from" & cdbtbname
Oarytemp = Split (fildstrarr ,",")
Sfu_rs.open sfu_ SQL _str, sfu_conn, 1, 3
Ofu_rs.open ofu_ SQL _str, ofu_conn, 1, 3
Do while not ofu_rs.eof
Sfu_rs.addnew
For I = lbound (oarytemp) to ubound (oarytemp)
Sfu_rs (oarytemp (I) = ofu_rs (oarytemp (I ))
Next
Sfu_rs.update
Ofu_rs.movenext
Loop
Ofu_rs.close
Ofu_conn.close
Set ofu_rs = nothing
Set ofu_conn = nothing
Sfu_rs.close
Sfu_conn.close
Set sfu_rs = nothing
Set sfu_conn = nothing
Readcdbtoserv = true
Delfile (mbdir & "Temp." & gtlx)
End if
End Function
'*************************************** ***********
'Function ID: 0031 [server information returned]
'Function name: getserverinfo
'Use: return server information
'Parameter: lx ---- return information code class
'0: Server Domain Name
'1: IP address of the server
'2: Server Operating System
'3: Server interpretation Engine
'4: Name and version of the server software
'5: the port on which the server is running
'6: Server CPU count
'7: Number of server applications
'8: Number of Server sessions
'9: physical path of the request
'10: requested URL
'11: current server time
'12: script connection timeout
'13: Server CPU details
'14:
'Return value: return message string
'Example: getserverinfo (2)
'*************************************** ***********
Public Function getserverinfo (byval lx)
Getserverinfo = ""
Dim okcpus, okcpu, okos
On Error resume next
Set wshshell = server. Createobject ("wscript. Shell ")
Set wshsysenv = wshshell. Environment ("system ")
Okos = CSTR (wshsysenv ("OS "))
Okcpus = CSTR (wshsysenv ("number_of_processors "))
Okcpu = CSTR (wshsysenv ("processor_identifier "))
If isnull (okcpus) & "" = "" then
Okcpus = request. servervariables ("number_of_processors ")
End if
Tnow = now (): oknow = CSTR (tnow)
If oknow <> year (tnow) & "-" & month (tnow) & "-" & Day (tnow) & "& hour (tnow )&": "& right (formatnumber (minute (tnow)/100,2), 2) &": "& right (formatnumber (second (tnow)/100,2), 2) then oknow = oknow & "(the date format is not standard )"
If Lx = 0 then getserverinfo = request. servervariables ("SERVER_NAME ")
If Lx = 1 then getserverinfo = request. servervariables ("local_addr ")
If Lx = 2 then getserverinfo = okos ''request. servervariables ("OS ")
If Lx = 3 then getserverinfo = scriptengine & "/" & scriptenginemajorversion & "." & scriptengineminorversion & "." & scriptenginebuildversion
If Lx = 4 then getserverinfo = request. servervariables ("server_software ")
If Lx = 5 then getserverinfo = request. servervariables ("server_port ")
If Lx = 6 then getserverinfo = okcpus ''request. servervariables (" number_of_processors ")
If Lx = 7 then getserverinfo = application. Contents. Count
If Lx = 8 then getserverinfo = session. Contents. Count
If Lx = 9 then getserverinfo = request. servervariables ("path_translated ")
If Lx = 10 then getserverinfo = request. servervariables ("SERVER_NAME") & request. servervariables ("script_name ")
If Lx = 11 then getserverinfo = oknow
If Lx = 12 then getserverinfo = server. scripttimeout
If Lx = 13 then getserverinfo = okcpu
End Function
'*************************************** ***********
'Function ID: 0032 [generate a unique ID with 20 characters in length]
'Function name: maketheid
'Use: generate a unique ID with 20 characters
'Parameter :----
'Return value: return the unique ID of the 20-bit length.
'Example: maketheid ()
'*************************************** ***********
Public Function maketheid ()
Dim datestr, mytime, myyear, mymonth, myday, I
Myyear = CSTR (Year (date ()))
Mymonth = CSTR (month (date ()))
Myday = CSTR (Day (date ()))
Mymonth = lpad (mymonth, 0, 2)
Maketheid = myyear & "_" & mymonth & "_" & myday &"_"
Datestr = CSTR (now ())
I = instr (datestr ,"")
Mytime = right (datestr, Len (datestr)-I)
Mytime = Replace (mytime ,":","_")
Randomize
I = int (9999-1000 + 1) * RND + 1000)
Maketheid = maketheid & mytime & "_" & I
Maketheid = Replace (maketheid ,"_","")
End Function
'*************************************** ***********
'Function ID: 0033 [used to fill the specified number of characters on the left to reach the standard length]
'Function name: lpad
'Usage: used to fill the specified number of characters on the left to reach the standard length.
'Parameter: desstr ---- target character
'Parameter: padchar ---- fill character
'Parameter: lenint ---- the total length of the filled characters
'Return value: return character
'Example: Response. Write lpad (00004, 5). The result is.
'*************************************** ***********
Public Function lpad (byval desstr, byval padchar, byval lenint)
Dim D, P, T
D = CSTR (desstr)
P = CSTR (padchar)
Lpad = ""
For t = 1 to lenint-len (d)
Lpad = P & lpad
Next
Lpad = lpad & D
End Function
'*************************************** ***********