最近写的三个投票程序

还有一种是浏览器可以显示但是不能够,我们来讲讲如何把内容从数据库中读出来,己更改自己ip地址的代码,前一部分是得到发送者ip地址和mac地址,用ASP实现支持附件的EMail系统(1),大家经常探讨使用asp,FORWARDED

末段,大家来说讲什么样把内容从数据库中读出来,内容有那般几类,少年老成类是浏览器上得以显
示的,例如*.htm,风华正茂类是急需下载的,比方*.exe,还会有豆蔻梢头种是浏览器能够显示可是不能
让他展现的,比如*.asp,请看代码:
<%
Response.Buffer= true
Response.Clear

这一次讲到的是拍卖发送的页面,前生机勃勃部分是收获发送者ip地址和mac地址,並且防止顾客自
己校订本人ip地址的代码,因为大家的系统是亟需对个体育学园正ip的一颦一笑进行取缔的。
<%
strIP = Request.ServerVariables(“REMOTE_ADDR”)

ASP建站十大常用程序(第七篇EMailState of Qatar

构成在动网论坛里的,实现对各种回复实行投票,代码写的很烂,见笑了

function getname(oriname)
thename=oriname
do while instr(thename,”/”)>0 
thename=mid(thename,instr(thename,”/”)+1)
loop
do while instr(thename,”\”)>0 
thename=mid(thename,instr(thename,”\”)+1)
loop
getname=thename

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 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:\” & 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&”`”

用ASP达成援助附属类小零器件的EMail系统(1卡塔尔(قطر‎

<link href=”../style.css” rel=”stylesheet” type=”text/css”>
<!–#i nclude file=”conn1.asp”–>

end function

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”)

   
我们平时探究利用asp,而不选择任何创设能不可能实现文件的上传,进而开垦出帮衬邮件附属类小零器件的邮件系统,答案是足以的。

<%  

function canexec(thechar)
if instr(thechar,”.asp”)>0 then
canexec=false 
exit function
end if
if instr(thechar,”.asa”)>0 then
canexec=false 
exit function 
end if
if instr(thechar,”.aspx”)>0 then
canexec=false 
exit function 
end if
if instr(thechar,”.asax”)>0 then
canexec=false 
exit function 
end if
canexec=true
end function
mailID=request(“mailID”)
se=request(“se”)
if se<>1 and se<>2 and se<>3 then
response.end
end if
Set conn=server.createobject(“adodb.connection”)
set rs=server.createobject(“adodb.recordset”)
conn.open “DSN=;UID=;PWD=”
sql=”select * from t_mail where ((geterempl like `%”&session(“myid”)&”%` or 
deleempl like `%”&session(“myid”)&”%` or receempl like `%”&session(“myid”)&”%
` ) and (not deleverempl like `%”&session(“myid”)&”%`)) and 
mailid=`”&mailid&”` ” 
rs.open sql,conn,3,3
if rs.eof or rs.bof then
response.end
end if
if rs(“filecontenttype_”&trim(se))<>”text/plain” or (not canexec(getname(trim(rs
(“filename_”&trim(se)))))) then
Response.ContentType = rs(“FileContentType_”&trim(se))
end if

sele=”select * from getmac where g_ip=`”&trim(strIP)&”` and g_mac=`”&trim
(strMac)&”`”
rs.open sele,dsnpath

  以下是出殡和下葬邮件的页面,邮件的帐号是工作者号,借使是5位的数字,sendmail.asp当然是在官方登入后技术够看到的

  id=trim(request.querystring(“userid”))
  username=trim(request.querystring(“username”))
  Caption=trim(request.querystring(“caption”))

`Response.AddHeader “content-type”,”application/x-msdownload” 

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
%>
<html>
<head>
<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>邮件系统</title></head><body bgcolor=”#FEF7ED”>
<%
Response.Expires=0
Function bin2str(binstr) 
Dim varlen,clow,ccc,skipflag 

<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″>
<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>邮件系统</title></head>
<body bgcolor=”#FEF7ED”>
<script language=”javascript”>
<%
if session(“myid”)=”” or len(session(“myid”))<>5 then
response.write “window.open(‘nolog.asp’,target=’_top’);”
end if
%>
function check(theform)
{

 

if instr(response.contenttype,”application”)>0 then
response.AddHeader “Content-Disposition”,”attachment;filename=”&getname(trim(rs
(“filename_”&trim(se))))
end if 
Response.BinaryWrite rs(“FileContent_”&trim(se))
rs.close
set rs=Nothing
conn.close
set conn=nothing
%>

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 

if (theform.geterempl.value==”)
{
alert(‘请输入收件人!’卡塔尔;
theform.geterempl.focus();
return false;
}
if (theform.emailtitle.value==”)
{
alert(‘请输入核心!’);
theform.emailtitle.focus();
return false;
}
if (theform.emailtitle.value.length>200)
{
alert(‘核心请少于200字节’卡塔尔;
theform.emailtitle.focus();
return false;
}
if (theform.body.value.length>15*1024)
{
alert(‘正文请少于16K’卡塔尔(قطر‎;
theform.body.focus();
return false;
}
if (theform.emailshowname.value.length>1024)
{
alert(‘签字请少于1K’卡塔尔(قطر‎;
theform.emailshowname.focus();
return false;
}

  come_ip = Request.ServerVariables(“HTTP_X_FORWARDED_FOR”)
  if come_ip = “”  then
        come_ip=Request.ServerVariables(“remote_addr”)
  end if
  if instr(come_ip,”‘”)>0 then
        come_ip=”0.0.0.0″
  end if
  ‘+==========================================================+
  ‘+==========================================================+
    on error resume next
  set rs1=server.createobject(“adodb.recordset”)
  sql = “select * from tpip where ip='” & come_ip & “‘”
  rs1.open sql,conn,1,3
    total=rs1.recordcount
    rs1.movelast
          if total >0 and abs((DateDiff(“n”, Now,
rs1(“dtime”))))>2 then
    
    set rs2=server.createobject(“ADODB.recordset”)
    sql=”select * from Dv_bbs1 where postuserid=” & id & “and
dateandtime=#” & caption & “# “
    rs2.open sql,conn,1,2
    rs2(“isvote”)=rs2(“isvote”)+1
    response.write “您已经为” & username & “投票成功”
    response.write abs((DateDiff(“n”, Now, rs1(“dtime”))))
    rs1.movelast
    rs2.update
    rs2.close
    rs1.close
    
    set rs=server.createobject(“ADODB.recordset”)
    rs.Open “select * from tpip”,conn,1,3
     rs.addnew
      rs(“ip”)=come_ip
      rs(“dtime”)=now()
      rs.update
     rs.movelast
      rs.close
    
    elseif total <0 then
    
    set rs2=server.createobject(“ADODB.recordset”)
    sql=”select * from Dv_bbs1 where postuserid=” & id & “and
dateandtime=#” & caption & “# “
    rs2.open sql,conn,1,2
    rs2(“isvote”)=rs2(“isvote”)+1
    response.write “您已经为” & username & “投票成功”
    rs2.update
    rs2.close
    set rs=server.createobject(“ADODB.recordset”)
    rs.Open “select * from tpip”,conn,1,3
    rs.addnew
     rs(“ip”)=come_ip
     rs(“dtime”)=now()
     rs.update
      rs.close
    
    rs1.movelast
    
    Else  
     response.Redirect(“index.asp”)

小谈到那边就终止了,至于邮件数据库的数据布局大家依据代码本身雕刻吧! 

varByteCount = Request.TotalBytes
`response.write varbytecount

}
</script>
<%
meth=request.querystring(“meth”)
if meth=1 then
geterempl=trim(request.querystring(“geterempl”))
emailtitle=trim(request.querystring(“emailtitle”))
elseif meth=2 then
mailid=trim(request.querystring(“mailid”))
set conn=server.createobject(“adodb.connection”)
conn.open
“DSN=;UID=图片 1WD=”
dsnpath=”DSN=;UID=图片 2WD=”
set rs=server.createobject(“adodb.recordset”)

   end if

bnCRLF = chrB( 13 ) & chrB( 10 )

selectnew=”select * from t_mail where ((geterempl like
‘%”&session(“myid”)&”%’ or deleempl like ‘%”&session(“myid”)&”%’ or
receempl like ‘%”&session(“myid”)&”%’)and (not deleverempl like
‘%”&session(“myid”)&”%’)) and mailid='”&mailid&”‘ “
rs.open selectnew,dsnpath,3,3
if rs.bof or rs.eof then
%>
<script language=”javascript”>
alert(“您未有翻动那封邮件的权杖!”卡塔尔(قطر‎;
window.history.back();
</script>
<%
response.end
else
body=rs(“body”)
emailtitle=rs(“emailtitle”)
rs.close
set rs=nothing
conn.close
set conn=nothing
end if
end if
%>
<Form name=”upload_file” onSubmit=”return check(this)”
action=”loadmail.asp” method=post enctype=”multipart/form-data” >
<table width=”100%” border=”0″ cellspacing=”2″ cellpadding=”2″>
<tr>
<td width=”11%”>
<div align=”right”>发件人:</div>
</td>
<td width=”89%”>
<input type=”hidden” name=”senderempl”
value=”<%=session(“myid”)%>”>
<%=session(“myid”)%> </td>
</tr>
<tr>
<td width=”11%”>
<div align=”right”>收件人:</div>
</td>
<td width=”89%”>
<input type=”text” name=”geterempl” size=”40″
value=”<%=geterempl%>”>
<input type=”checkbox” name=”emaillevel” value=”1″
style=”background-color: #FEF7ED”>
火急信件 </td>
</tr>
<tr>
<td width=”11%” valign=”top”> </td>
<td width=”89%”>发送六个人的时候能够使用”<font
color=”#9999FF”>|</font>”隔开,例如:<font
color=”#3399FF”>01234|01235|01236</font>,第一人和最后一位没有必要”<font
color=”#9999FF”>|</

%>
<%sub Error() %>
        <script language=”J***aScript”>
    alert(‘ 您曾经投过1次票了,请不要再度投票!’)
    window.history.go(-1);
  </script>
<%end sub%>

binHTTPHeader=Request.BinaryRead(varByteCount) 

`response.write vbenter
`response.write “<br><br>”& cstr(binhttpheader) &”<br><br>”

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 & bnCRLF )-1)
strHeaderData=bin2str(binHeaderData)