分享
 
 
 

使用asp实现支持附件的邮件系统(二)

王朝asp·作者佚名  2008-05-30
窄屏简体版  字體: |||超大  

这次讲到的是处理发送的页面,前一部分是得到发送者ip地址和mac地址,并且禁止用户自己更改自己ip地址的代码,因为我们的系统是需要对个人修改ip的行为进行禁止的。

strIP = Request.ServerVariables("REMOTE_ADDR")

Set net = Server.CreateObject("wscript.network")

Set sh = Server.CreateObject("wscript.shell")

sh.run "%comspec% /c nbtstat -A " %26amp; strIP %26amp; " c:" %26amp; strIP %26amp; ".txt",0,true

Set sh = nothing

Set fso = createobject("scripting.filesystemobject")

Set ts = fso.opentextfile("c:" %26amp; strIP %26amp; ".txt")

macaddress = null

Do While 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:" %26amp; strIP %26amp; ".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='"%26amp;strMac%26amp;"'"

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('"%26amp;strIP%26amp;"','"%26amp;strMac%26amp;"',"%26amp;g_id%26amp;",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='"%26amp;trim(strIP)%26amp;"' and g_mac='"%26amp;trim(strMac)%26amp;"'"

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('"%26amp;strIP%26amp;"','"%26amp;strMac%26amp;"','"%26amp;now()%26amp;"')"

rs1.open sele,dsnpath

response.redirect("/reg/wrong.asp")

response.end

end if

end if

%

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}

邮件系统

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 %26amp; Chr(AscW(MidB(binstr,i+1,1) %26amp; clow))

skipflag=1

Else

ccc = ccc %26amp; 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( 13 ) %26amp; chrB( 10 )

binHTTPHeader=Request.BinaryRead(varByteCount)

'response.write vbenter

'response.write "

"%26amp; cstr(binhttpheader) %26amp;"

"

sread=0

eread=0

'开始读非文件域的数据

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 %26amp; bnCRLF )-1)

strHeaderData=bin2str(binHeaderData)

lngFieldNameStart=Instr(strHeaderData,"name="%26amp;chr(34))+Len("name="%26amp;chr(34))

'response.write "

lngfieldnamestart:"%26amp;lngfieldnamestart

lngFieldNameEnd=Instr(lngFieldNameStart,strHeaderData,chr(34))

'response.write "

lngfieldnameEND:"%26amp;lngfieldnameEND

strFieldName=Mid(strHeaderData,lngFieldNameStart,lngFieldNameEnd-lngFieldNameStart)

'RESPOnSE.WRITE "

STRFIELDNAME:" %26amp; STRfieldname

strFieldName=Trim(strFieldName)

strFieldName=Replace(strFieldName,vbcrlf,vbnullstring)

'判断文件数据时候开始

If strComp(strFieldName,"FileUploadStart",1)=0 and sread=0 Then

'response.write "找到了文件开始的地方"

sread=1

'response.write "

" %26amp; INSTRB( DataStart + 1, binHTTPHeader, divider ) %26amp;"

"

binHTTPHeader=MIDB(binHTTPHeader,INSTRB( DataStart + 1, binHTTPHeader, divider ))

exit do

End if

DataStart = INSTRB( binHTTPHeader, bnCRLF %26amp; bnCRLF ) + 4

DataEnd = INSTRB( DataStart + 1, binHTTPHeader, divider ) - DataStart

binFieldValue=MIDB( binHTTPHeader, DataStart, DataEnd )

strFieldValue=bin2str(binFieldValue)

'strFieldValue=Trim(strFieldValue)

strFieldValue=Replace(strFieldValue," "," ")

'非文件上传域变量赋值

'execute strFieldName%26amp;"="""%26amp;strFieldValue%26amp;""""

'response.write strFieldName%26amp;":"%26amp;strFieldValue%26amp;"

"

if strfieldname="geterempl" then

strFieldValue=Replace(strFieldValue,vbcrlf,vbnullstring)

if instr(strfieldvalue,"gr:")=1 then

'邮件组发

'response.write len(trim(strfieldvalue))

if len(trim(strfieldvalue))6 then

'格式错误返回

%

尝试发送邮件,但是失败了,请修改错误后重试!

response.end

else

if not isnumeric(mid(trim(strfieldvalue),4)) then

'格式错误返回

%

尝试发送邮件,但是失败了,请修改错误后重试!

response.end

else

thegroup=(mid(trim(strfieldvalue),4))

end if

end if

tmpSQL="select * from t_group where owner='"%26amp;session("myid")%26amp;"' and groupidowner='"%26amp;thegroup%26amp;"'"

'response.write tmpsql

set tmprs=server.CreateObject("ADODB.Recordset")

tmprs.Open tmpsql,conn

if tmprs.bof or tmprs.eof then

'没有找到该组

%

尝试发送邮件,但是失败了,请修改错误后重试!

response.end

else

if tmprs("personnum")=0 then

'组内没有用户

%

尝试发送邮件,但是失败了,请修改错误后重试!

response.end

else

strFieldValue=trim(tmprs("groupempl"))

tmprs.close

set tmprs=nothing

end if

end if

end if

if instr(strfieldValue,"|") then

'组发

allsearch=replace(trim(strfieldValue),"|","','")

allsearch="'"%26amp;allsearch%26amp;"'"

tmpstring=trim(strfieldValue)%26amp;"|"

tosearch=""

do while len(tmpstring)=5

tosearch=left(tmpstring,5)

tmpstring=mid(tmpstring,7)

if instr(tosearch,"|") then

'格式错误

%

尝试发送邮件,但是失败了,请修改错误后重试!

response.end

end if

tmpSQL="select * from (select userid from t_officer where userid in ("%26amp;allsearch%26amp;")) DERIVEDTBL where userid='"%26amp;tosearch%26amp;"'"

'response.write tmpsql

set tmprs=server.CreateObject("ADODB.Recordset")

tmprs.Open tmpsql,conn

if tmprs.eof or tmprs.bof then

%

尝试发送邮件,但是失败了,请修改错误后重试!

response.end

end if

tmprs.close

set tmprs=nothing

loop

strfieldValue=trim(strFieldValue)

else

if len(trim(strFieldValue))5 then

'格式不正确

%

尝试发送邮件,但是失败了,请修改错误后重试!

response.end

else

if isnumeric(trim(len(strFieldValue))) then

tmpSQL="select * from t_officer where userid='"%26amp;trim(strFieldValue)%26amp;"'"

set tmprs=server.CreateObject("ADODB.Recordset")

tmprs.Open tmpsql,conn

if tmprs.eof or tmprs.bof then

%

尝试发送邮件,但是失败了,请修改错误后重试!

response.end

end if

tmprs.close

set tmprs=nothing

strfieldValue=trim(strFieldValue)

else

%

尝试发送邮件,但是失败了,请修改错误后重试!

response.end

end if

end if

end if

end if

strFieldValue=replace(strFieldValue,"

'response.write strfieldname

rs(STRFIELDNAME)=replace(strFieldValue,"","")

binHTTPHeader=MIDB(binHTTPHeader,INSTRB( DataStart + 1, binHTTPHeader, divider ))

loop

'开始处理文件数据

titem=0

rs("filesize_1")=0

rs("filesize_2")=0

rs("filesize_3")=0

Do while lenB(binHTTPHeader)46

if INSTRB( binHTTPHeader, bnCRLF %26amp; bnCRLF )0 then

binHeaderData = LeftB(binHTTPHeader,INSTRB( binHTTPHeader, bnCRLF %26amp; bnCRLF )-1)

else

exit do

end if

strHeaderData=bin2str(binHeaderData)

'读取上传文件的Content-Type

lngFileContentTypeStart=Instr(strHeaderData,"Content-Type:")+Len("Content-Type:")

strFileContentType=Trim(Mid(strHeaderData,lngFileContentTypeStart))

strFileContentType=Replace(strFileContentType,vbCRLF,vbNullString)

'读取上传的文件名

if instr(strheaderdata,"filename=")0 then

lngFileNameStart=Instr(strHeaderData,"filename="%26amp;chr(34))+Len("filename="%26amp;chr(34))

lngFileNameEnd=Instr(lngFileNameStart,strHeaderData,chr(34))

strFileName=Mid(strHeaderData,lngFileNameStart,lngFileNameEnd-lngFileNameStart)

strFileName=Trim(strFileName)

strFileName=Replace(strFileName,vbCRLF,vbNullString)

else

strfilename=""

end if

'读取上传文件数据

DataStart = INSTRB( binHTTPHeader, bnCRLF %26amp; bnCRLF ) + 4

DataEnd = INSTRB( DataStart + 1, binHTTPHeader, divider ) - DataStart

If strFileName"" Then

if dataend0 then

binFieldValue=MIDB( binHTTPHeader, DataStart, DataEnd )

'将上传的文件写入数据库

titem=titem+1

'response.write "titem:"%26amp;titem

rs("FileContentType_"%26amp;titem)=strFileContentType

rs("FileContent_"%26amp;titem).AppendChunk binFieldValue

rs("filesize_"%26amp;titem)=lenb(binFieldValue)

rs("filename_"%26amp;titem)=strfilename

else

binfieldvalue=binhttpheader

end if

End if

if INSTRB( DataStart + 1, binHTTPHeader, divider )0 then

binHTTPHeader=MIDB(binHTTPHeader,INSTRB( DataStart + 1, binHTTPHeader, divider ))

else

binhttpheader=""

end if

loop

rs("sizetotal")=csng(rs("filesize_1"))+csng(rs("filesize_2"))+csng(rs("filesize_3"))+csng(len(rs("body")))+csng(len(rs("emailtitle")))+csng(len(rs("emailshowname")))+csng(len("geterempl"))

if csng(rs("sizetotal"))=csng(2*1024*1024) then

response.write "对不起,文件太大,请保证每封邮件的总大小不超过2M!"

response.end

end if

rs("mailtime")=now

rs("readerempl")=""

if rs("receempl")"" then

rs("receempl")=session("myid")

rs("readerempl")=session("myid")

end if

rs("deleempl")=""

rs("deleverempl")=""

rs("sendmac")=strmac

rs.update

rs.close

set rs=Nothing

conn.Close

set conn=Nothing

%

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有