Using ASP to implement the email system supporting the attachment (2)

Source: Internet
Author: User
Tags exit chr dsn implement insert trim
But this is only to get the sender's IP address and MAC address, but also prohibit users to change their own IP address code, because our system is the need for personal modification of the IP behavior to prohibit.

<%
StrIP = Request.ServerVariables ("REMOTE_ADDR")


Set net = Server.CreateObject ("Wscript.Network")
Set sh = Server.CreateObject ("Wscript.Shell")
Sh.run "%comspec%/C Nbtstat-a" & StrIP & "> C:\" & strip & "TXT", 0,true
Set sh = Nothing
Set fso = CreateObject ("Scripting.FileSystemObject")
Set ts = fso.opentextfile ("C:\" & StrIP & ". txt")
MACAddress = null
Do and not TS. AtEndOfStream
data = UCase (Trim (ts.readline))
If InStr (Data, "MAC address") Then
MACAddress = Trim (Split (data, "=") (1))
Exit do
End If
Loop
Ts.close
Set ts = Nothing
Fso.deletefile "C:\" & StrIP & ". txt"
Set FSO = Nothing
Getmacaddress = MACAddress
Strmac = getmacaddress
Set Conn=server. CreateObject ("Adodb.connection")
Conn.Open "dsn=; uid=; Pwd= "
Dsnpath= "dsn=; uid=; Pwd= "
Set Rs=server. CreateObject ("Adodb.recordset")
Sele= "SELECT * from Getmac where g_mac= '" &strMac& ""

Rs.Open Sele,dsnpath
If Rs.bof Then
Set Conn=server. CreateObject ("Adodb.connection")
Conn.Open "dsn=; uid=; Pwd= "
Dsnpath= "dsn=; uid=; Pwd= "
Set Rs=server. CreateObject ("Adodb.recordset")
G_id=mid (strip,9)
G_id=left (g_id,2)
' Response.Write g_id
If IsNumeric (g_id) Then
G_id=cint (g_id)
Else
G_id=0
End If
sele= INSERT INTO Getmac (G_IP,G_MAC,G_ID,G_OK) VALUES (' &strIP& ', ' &strMac& ', ' &g_id& ', 0 )"
Rs.Open Sele,dsnpath
Else
Set Conn=server. CreateObject ("Adodb.connection")
Conn.Open "dsn=; uid=; Pwd= "
Dsnpath= "dsn=; uid=; Pwd= "
Set Rs=server. CreateObject ("Adodb.recordset")

Sele= "SELECT * from Getmac where g_ip= '" &trim (StrIP) & "' and G_mac= '" &trim (STRMAC) & ""
Rs.Open Sele,dsnpath

If Rs.bof or rs.eof then
Set Rs1=server. CreateObject ("Adodb.recordset")
sele= "INSERT into Badmac (IP, Mac, Thetime) VALUES (' &strIP&" ', ' "&strMac&" ', ' "&now () &") "
Rs1.open Sele,dsnpath
Response.Redirect ("/reg/wrong.asp")
Response.End
End If
End If
%>
<link rel= "stylesheet" type= "Text/css" href= "/css/forum". CSS ">
<style type=text/css>
!--
input {font-size:9pt; color: #0011dd; Background-color: #e9e9f9; padding-top:0px}
Select {font-size:9pt; color: #0011dd; Background-color: #e9e9f9; padding-top:0px}
textarea {font-size:9pt; color: #0011dd; Background-color: #e9e9f9; padding-top:0px}
-->
</style>
<title> mail system </title> <%
Response.expires=0
Function Bin2str (BINSTR)
Dim Varlen,clow,ccc,skipflag

Skipflag=0
CCC = ""
If not IsNull (BINSTR) Then
Varlen=lenb (BINSTR)
For I=1 to Varlen
If skipflag=0 Then
Clow = MidB (binstr,i,1)
If AscB (Clow) > 127 Then
CCC =CCC & Chr (AscW (MidB (binstr,i+1,1) & Clow))
Skipflag=1
Else
CCC = CCC & Chr (AscB (Clow))
End If
Else
Skipflag=0
End If
Next
End If
BIN2STR = CCC
End Function


Varbytecount = Request.TotalBytes
' Response.Write Varbytecount

Bncrlf = ChrB (+) & ChrB (10)

Binhttpheader=request.binaryread (Varbytecount)

' Response.Write Vbenter
' Response.Write '

"& CStr (Binhttpheader) &"

"


Sread=0
Eread=0


' Start reading data from non-file fields
Set conn = Server.CreateObject ("ADODB. Connection ")
Conn.Open "dsn=; uid=; Pwd= "

Sql= "SELECT * from T_mail where mailid=0"
Set Rs=server. CreateObject ("ADODB.") Recordset ")
Rs. Open sql,conn,3,3
Rs.addnew
RS ("EmailLevel") =0
RS ("Receempl") = ""
Do While LenB (Binhttpheader) >46

Divider = LEFTb (Binhttpheader, INSTRB (Binhttpheader, Bncrlf)-1)
Binheaderdata = Leftb (Binhttpheader, INSTRB (Binhttpheader, Bncrlf & Bncrlf)-1)
Strheaderdata=bin2str (Binheaderdata)

Lngfieldnamestart=instr (Strheaderdata, "name=" &AMP;CHR) +len ("Name=" &AMP;CHR (34))
' Response.Write '
Lngfieldnamestart: "&lngfieldnamestart
Lngfieldnameend=instr (LNGFIELDNAMESTART,STRHEADERDATA,CHR (34))
' Response.Write '
Lngfieldnameend: "&lngfieldnameend


Strfieldname=mid (Strheaderdata,lngfieldnamestart,lngfieldnameend-lngfieldnamestart)

' Response.Write ' <BR> strfieldname: ' & strFieldName


Strfieldname=trim (strFieldName)


Strfieldname=replace (strfieldname,vbcrlf,vbnullstring)

' When you start to judge the file data

If StrComp (strFieldName, "Fileuploadstart", 1) =0 and Sread=0 Then
"Response.Write" found where the file started.
Sread=1
' Response.Write '
"& INSTRB (Datastart + 1, Binhttpheader, divider) &"
"
Binhttpheader=midb (BINHTTPHEADER,INSTRB (Datastart + 1, Binhttpheader, divider))
Exit Do
End If
Datastart = INSTRB (Binhttpheader, Bncrlf & Bn



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.