?? savevote.asp
字號:
<!--#include file="conn.asp"-->
<!-- #include file="inc/char.asp" -->
<!-- #include file="inc/const.asp" -->
<!-- #include file="chkuser.asp" -->
<!--#include file="inc/theme.asp"-->
<!--#include file="md5.asp"-->
<%
rem ----------------------
rem ------主程序開始------
rem ----------------------
dim announceid
dim UserName
dim userPassword
dim useremail
dim article
dim Topic
dim body
dim dateTimeStr
dim addAll
dim newUser
dim UserID
dim ip
dim Expression
dim boardID
dim sql
dim rs
dim signflag
dim mailflag
dim TIME_ADJUST
dim boardstat
dim votetype,vote,votenum
stats="發(fā)表投票"
rem ------獲得asp文件參數(shù)------
call getInput()
rem -----檢查user輸入數(shù)據(jù)的合法性------
call chkData()
if FoundErr then
call nav()
call headline(2)
call Error()
else
call checkUser()
call nav()
call headline(2)
if FoundErr then
call Error()
else
call saveAnnounce()
call savevote()
end if
end if
call endline()
rem ----------------------
rem ------主程序結(jié)束------
rem ----------------------
rem 檢測用戶輸入數(shù)據(jù)合法性
sub checkUser()
select case boardskin
case 1
case 2
exit sub
case 3
if not(boardmaster or master) then
Founderr=true
Errmsg=Errmsg+"<br>"+"<li>評論論壇,壇主和版主允許發(fā)言,其他<a href=reg.asp><font color="&TableContentColor&">注冊用戶</font></a>只能回復(fù)"
exit sub
end if
case 4
if not(boardmaster or master) then
Founderr=true
Errmsg=Errmsg+"<br>"+"<li>精華區(qū),只允許版主和壇主發(fā)言和操作"
exit sub
end if
case 5
if username="" then
founderr=true
Errmsg=Errmsg+"<br>"+"<li>本論壇為認(rèn)證論壇,請<a href=login.asp>登陸</a>并確認(rèn)您的用戶名已經(jīng)得到管理員的認(rèn)證后進入。"
exit sub
else
if chkboardlogin(boardid,username)=false then
founderr=true
Errmsg=Errmsg+"<br>"+"<li>本論壇為認(rèn)證論壇,請確認(rèn)您的用戶名已經(jīng)得到管理員的認(rèn)證后進入。"
exit sub
end if
end if
case 6
if username="" then
Founderr=true
Errmsg=Errmsg+"<br>"+"<li>正規(guī)論壇,只有<a href=login.asp><font color="&TableContentColor&">登陸用戶</a>才能瀏覽論壇并發(fā)言"
exit sub
end if
end select
usercookies=request.Cookies("aspsky")("usercookies")
if isnull(usercookies) or usercookies="" then usercookies=3
if chkuserlogin(username,userpassword,usercookies,2)=false then
errmsg=errmsg+"<br>"+"<li>您的用戶名并不存在,或者您的密碼錯誤,或者您的帳號已被管理員鎖定。"
founderr=true
exit sub
end if
if lockboard=1 then
if not master then
Errmsg=ErrMsg+"<Br>"+"<li>您沒有權(quán)限在本版面發(fā)布貼子!"
FoundErr=true
end if
end if
end sub
rem 保存貼子信息
sub saveAnnounce()
DateTimeStr=CSTR(NOW()+TIMEADJUST/24)
Sql="insert into bbs1(Boardid,ParentID,Child,username,topic,body,DateAndTime,hits,length,rootid,layer,orders,ip,Expression,locktopic,signflag,emailflag,istop,isbest,isvote,times) values "&_
"("&_
boardid&",0,0,'"&_
username&"','"&_
topic&"','"&_
body&"','"&_
DateTimeStr&"',0,'"&_
strlength(body)&"',0,1,0,'"&ip&"','"&_
Expression&"',0,"&signflag&","&mailflag&",0,0,1,0)"
conn.execute(sql)
set rs=conn.execute("select top 1 announceid from bbs1 order by announceid desc")
announceid=rs(0)
sql="update bbs1 set rootid="&announceid&",times="&announceid&" where announceid="&announceid
conn.execute(sql)
if topic="" then
Topic=cutStr(body,20)
else
Topic=cutStr(topic,20)
end if
sql="update board set lastpostuser='"&username&"',lastposttime='"&datetimestr&"',lastbbsnum=lastbbsnum+1,lasttopicnum=lasttopicnum+1,todaynum="&boardtoday(boardid)&",lastrootid="&announceid&",lasttopic='"&topic&"' where boardid="&cstr(boardID)
conn.execute(sql)
conn.execute("update config set topicnum=topicnum+1,bbsnum=bbsnum+1,todayNum="&alltodays()&" where active=1")
if err.number<>0 then
err.clear
ErrMsg=ErrMsg+"<Br>"+"<li>數(shù)據(jù)庫操作失敗,請以后再試"&err.Description
call Error()
else
end if
set rs=nothing
end sub
'今日帖子
function boardtoday(boardid)
tmprs=conn.execute("Select count(announceid) from bbs1 Where datediff('d',dateandtime,Now())=0 and boardid="&boardid)
boardtoday=tmprs(0)
set tmprs=nothing
if isnull(boardtoday) then boardtoday=0
end function
function alltodays()
tmprs=conn.execute("Select count(announceid) from bbs1 Where datediff('d',dateandtime,Now())=0")
alltodays=tmprs(0)
set tmprs=nothing
if isnull(alltodays) then alltodays=0
end function
sub savevote()
set vrs=server.createobject("adodb.recordset")
sql="select * from vote"
vrs.open sql,conn,1,3
vrs.addnew
vrs("announceid")=announceid
vrs("vote")=vote
vrs("votenum")=votenum
vrs("votetype")=votetype
vrs("voteuser")=username
vrs.update
vrs.close
set vrs=nothing
if err.number<>0 then
err.clear
ErrMsg=ErrMsg+"<Br>"+"<li>數(shù)據(jù)庫操作失敗,請以后再試"&err.Description
call Error()
else
call success()
end if
end sub
'更新用戶在線資料
sub activeuser()
dim rsactiveusers,activeuser
dim membername
dim memberword
dim memberclass
membername=request.cookies("aspsky")("username")
memberword=request.cookies("aspsky")("password")
memberclass=request.cookies("aspsky")("userclass")
ComeFrom=address(Request.ServerVariables("REMOTE_HOST"))
actCome=address(Request.ServerVariables("HTTP_X_FORWARDED_FOR"))
statuserid=replace(Request.ServerVariables("REMOTE_HOST"),".","")
set rsactiveusers=server.createobject("adodb.recordset")
activeuser="select * from online where username='"&membername&"'"
rsactiveusers.open activeuser,conn,1,3
if rsactiveusers.eof and rsactiveusers.bof then
activeuser="insert into online(id,username,userclass,ip,startime,lastimebk,lastime,browser,stats,ComeFrom,actCome) values "&_
"("&statuserid&",'"&membername&"','"&memberclass&"','"&_
Request.ServerVariables("REMOTE_HOST")&"',Now(),Now(),'"&DateToStr(now())&"','"&_
Request.ServerVariables("HTTP_USER_AGENT")&"','"&_
boardtype&"','"&ComeFrom&"','"&actCome&"')"
conn.execute(activeuser)
else
activeuser="update online set lastimebk=Now(),lastime='"&DateToStr(now())&"',stats='"&boardtype&"' where username='"&membername&"'"
conn.execute(activeuser)
end if
if session("userid")<>"" then
activeuser="delete from online where id="&cstr(session("userid"))
Conn.Execute activeuser
end if
rsactiveusers.close
set rsactiveusers=nothing
end sub
rem ------獲得asp文件參數(shù)------
sub getInput()
if request("boardid")="" then
FoundErr=true
Errmsg=Errmsg+"<br>"+"<li>請指定論壇版面。"
elseif not isInteger(request("boardid")) then
FoundErr=true
Errmsg=Errmsg+"<br>"+"<li>非法的版面參數(shù)。"
else
boardID=request("boardID")
end if
IP=Request.ServerVariables("REMOTE_ADDR")
Expression=Checkstr(Request.Form("Expression")&".gif")
Topic=Checkstr(trim(request("subject")))
Body=Checkstr(trim(request("Content")))
UserName=Checkstr(trim(request("username")))
boardtype=Checkstr(trim(request("boardtype")))
signflag=Checkstr(trim(request("signflag")))
mailflag=Checkstr(trim(request("emailflag")))
UserPassWord=md5(Checkstr(trim(request("passwd"))))
votetype=Checkstr(request("votetype"))
vote=Checkstr(trim(request("vote")))
end sub
rem -----檢查user輸入數(shù)據(jù)的合法性------
function chkData()
if instr(Expression,"face")=0 then
Randomize
Do While Len(rndnum)<1
num1=CStr(Chr((57-48)*rnd+48))
rndnum=rndnum&num1
loop
Expression=facename & rndnum & ".gif"
end if
if signflag="yes" then
signflag=1
else
signflag=0
end if
if mailflag="yes" then
mailflag=1
else
mailflag=0
end if
if cint(RelayPost)=1 then
if not (isnull(session("lastpost")) or boardmaster or master) then
if DateDiff("s",session("lastpost"),Now())<cint(RelayPostTime) then
ErrMsg=ErrMsg+"<Br>"+"<li>本論壇限制發(fā)貼距離時間為10秒,請稍后再發(fā)。"
FoundErr=True
end if
end if
end if
if chkpost=false then
ErrMsg=ErrMsg+"<Br>"+"<li>您提交的數(shù)據(jù)不合法,請不要從外部提交發(fā)言。"
FoundErr=True
end if
if UserName="" or UserPassWord="" then
username=membername
UserPassWord=memberword
end if
if UserName="" or strLength(UserName)>20 then
ErrMsg=ErrMsg+"<Br>"+"<li>請輸入姓名(長度不能大于20)"
FoundErr=True
end if
if Topic="" then
FoundErr=True
if Len(ErrMsg)=0 then
ErrMsg=ErrMsg+"<Br>"+"<li>主題不應(yīng)為空。"
else
ErrMsg=ErrMsg+"<Br>"+"<li>主題不應(yīng)為空。"
end if
elseif strLength(topic)>100 then
FoundErr=True
if strLength(ErrMsg)=0 then
ErrMsg=ErrMsg+"<Br>"+"<li>主題長度不能超過100"
else
ErrMsg=ErrMsg+"<Br>"+"<li>主題長度不能超過100"
end if
end if
if strLength(body)>AnnounceMaxBytes then
ErrMsg=ErrMsg+"<Br>"+"<li>發(fā)言內(nèi)容不得大于" & CSTR(AnnounceMaxBytes) & "bytes"
FoundErr=true
end if
if body="" then
ErrMsg=ErrMsg+"<Br>"+"<li>沒有填寫內(nèi)容。"
FoundErr=true
end if
if vote="" then
ErrMsg=ErrMsg+"<Br>"+"<li>請輸入投票內(nèi)容"
FoundErr=true
else
vote=split(vote,chr(13)&chr(10))
j=0
for i = 0 to ubound(vote)
if not (vote(i)="" or vote(i)=" ") then
vote_1=""&vote_1&""&vote(i)&"|"
j=j+1
end if
if i>cint(vote_num)-2 then exit for
next
for k = 1 to j
votenum=""&votenum&"0|"
next
votelen=len(vote_1)
votenumlen=len(votenum)
votenum=left(votenum,votenumlen-1)
vote=left(vote_1,votelen-1)
end if
if err.number<>0 then err.clear
session("lastpost")=Now()
end function
sub success()
response.write "<meta http-equiv=refresh content=""4;URL=dispbbs.asp?boardid="&boardid&"&rootid="&announceid&"&id="&announceid&"&star="&request("star")&""">"
response.write "<br><table cellpadding=0 cellspacing=0 border=0 width="&tablewidth&" bgcolor="&tablebackcolor&" align=center>"&_
"<tr><td><table cellpadding=3 cellspacing=1 border=0 width=""100%"">"&_
"<tr align=center><td width=""100%"" bgcolor="&tabletitlecolor&"><b><FONT COLOR="&TableFontcolor&">狀態(tài):您發(fā)表投票成功</font></b></td>"&_
"</tr><tr><td width=""100%"" bgcolor="&tablebodycolor&">"&_
"<FONT COLOR="&TableContentcolor&">本頁面將在3秒后自動返回您所發(fā)表的帖子頁面,<b>您可以選擇以下操作:</b><br><ul>"&_
"<li><a href=""index.asp""><font color="""&TableContentcolor&""">返回首頁</font></a></li>"&_
"<li><a href=""list.asp?boardid="&boardid&"""><font color="""&TableContentcolor&""">"&boardtype&"</font></a></li>"&_
"<li><a href=""dispbbs.asp?boardid="&boardid&"&rootid="&announceid&"&id="&announceid&"&star="&request("star")&"""><font color="""&TableContentcolor&""">發(fā)表的帖子</font></a></li>"&_
"</ul></td></tr></table></td></tr></table>"
end sub
Function Checkstr(str)
str=replace(str,"'","''")
Checkstr=str
End Function
stats="發(fā)表投票"
%>
<!--#include file="footer.asp"-->
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -