⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 forum_display.asp

📁 商会 商会 商会 商会 商会 商会 商会 商会 商会 商会 商会 商会 商会
💻 ASP
📖 第 1 页 / 共 3 页
字号:
<%@ Language=VBScript%>
<%
Response.Buffer=true
Response.Expires=0
%>
<!-- #include file="../dsn.asp" -->
<!-- #include file="init.inc" -->
<%

keyno=Request.QueryString("keyno")
method=Request.QueryString("method")
pageno=Request.QueryString("pageno")

set cn = Server.CreateObject("ADODB.Connection")
cn.Open(mycnstr)
set rs = Server.CreateObject("ADODB.Recordset")
set rs2 = Server.CreateObject("ADODB.Recordset")


tablename="forum"
if keyno="" then Response.End

sql="select keyno,classcode,querycount from "+tablename+" where keyno="&keyno
rs.Open sql,cn,1,3
if not rs.EOF then
	classcode=trim(rs("classcode"))
	querycount=rs("querycount")
end if
rs.Close

if classcode<>"" then
	sql="select * from forum_class where state='1' and classcode='"+classcode+"'"
else	
	sql="select * from forum_class where state='1' order by sortnum"
end if
rs2.Open sql,cn,1,1
if not rs2.EOF then
	manager=trim(rs2("manager"))
	classcode=trim(rs2("classcode"))
	classname=trim(rs2("classname"))
	topcount=rs2("topcount")
	totcount=rs2("reccount")
	flag=rs2("flag")
else
	Response.End
end if
rs2.Close

myurl="forum_display.asp?classcode="+classcode+"&keyno="+keyno
backurl="forum_list.asp?classcode="+classcode
usercode=Session("usercode")
userno=Session("userno")

select case Session("userflag")
	case "1"
		userqx=mid(flag,2,1)
	case "2"
		userqx=mid(flag,3,1)
	case else
		userqx=mid(flag,1,1)
end select		
if manager<>"" then
	keyword=manager+"/"
	manager=""
	xx1=1
	xx2=instr(xx1,keyword,chr(47))
	wheretxt=""
	do while xx2>0
		ttt=mid(keyword,xx1,xx2-xx1)
		if ttt<>"" then
			sql="select userno from userinfo where state='1' and usercode='"+ttt+"'"
			rs2.Open sql,cn,1,1
			if not rs2.EOF then
				if cstr(Session("userno"))=cstr(rs2(0)) then
					userqx="9"
				end if
				ttt="<a href='user_display.asp?userno="&rs2(0)&"' target=_blank>"+ttt+"</a>"
				if manager="" then
					manager=ttt
				else
					manager=manager+","+ttt 	
				end if
			end if	
			rs2.Close
		end if
		xx1=xx2+1
		xx2=instr(xx1,keyword,"/")
	loop
else
	manager="暂无"	
end if
if Session("userqx")="9" or Session("userflag")="9" then
	userqx="9"
end if	
if userqx="0" then
	Response.End
end if

if Request.ServerVariables("REQUEST_METHOD")="POST" then
  if method="" then
	bz=1
	formsize=request.totalbytes 
	formdata=request.binaryread(formsize) 
	bncrlf=chrB(13) & chrB(10) 
	if formsize>122880 then
		bz="2"	
		sysmess="上传文件太大!文件限为:<font color=red>120K</font>,"+"目前为:<font color=red>"&int(formsize/1024)&"K</font> 。"	
	end if

    hds=1
    datastart=1
    do while datastart<formsize and hds<=8

		divider=leftB(formdata,clng(instrb(formdata,bncrlf))-1) 
		datastart=instrb(datastart+dataend,formdata,bncrlf & bncrlf)+4 
		dataend=instrb(datastart+1,formdata,divider)-datastart 
		mydata=midb(formdata,datastart,dataend - 2) 
		
		select case hds
			case 1
				usercode=bin2str(mydata)
			case 2
				userpass=bin2str(mydata)
			case 3
				newtitle=bin2str(mydata)
			case 4
				emote=bin2str(mydata)
			case 5
				if datastart > dataend then
					picflag="0"
				else
					picflag="1"
				end if
				picdata=mydata
			case 6,7
			case 8
				newcontent=bin2str(mydata)
		end select
		hds=hds+1
	loop
	
if Session("userno")="" then
	sql="select userno,userpass,flag,state,logintime,logincount,ipaddress,cookieqx from userinfo where usercode='"+usercode+"' and state='1'"
	rs.Open sql,cn,1,3
	if rs.EOF then
		bz=2
	else
		oldpass=Lcase(trim(rs(1)))
		if oldpass=userpass then
			rs("logintime")=now()
			rs("logincount")=rs("logincount")+1
			rs("ipaddress")=Request.ServerVariables("Remote_HOST")
			cookieqx=trim(rs("cookieqx"))			
			rs.Update
			
			Response.Cookies("usercode")=usercode
			Response.Cookies("userpass")=userpass
			Response.Cookies("loginflag")=loginflag
			select case cookieqx
				case "1"
					Response.Cookies("usercode").Expires=now()+1
					Response.Cookies("userpass").Expires=now()+1
					Response.Cookies("loginflag").Expires=now()+1
				case "2"
					Response.Cookies("usercode").Expires=now()+30
					Response.Cookies("userpass").Expires=now()+30
					Response.Cookies("loginflag").Expires=now()+30
				case "3"
					Response.Cookies("usercode").Expires=now()+365
					Response.Cookies("userpass").Expires=now()+365
					Response.Cookies("loginflag").Expires=now()+365
			end select	
			Session("userno")=rs(0)
			Session("usercode")=usercode
			Session("userflag")=rs("flag")
			userno=rs(0)
			loginflag="1"

			cn.Execute "delete from user_login where userno="&userno&" or keyno="&Session.SessionID

			if databaseflag="access" then
				sql="Insert into user_login values ("&Session.SessionID&","&userno&",'"+usercode+"',now(),now(),'"+classcode+"','"+loginflag+"','"+Request.ServerVariables("Remote_HOST")+"')"
			else
				sql="Insert into user_login values ("&Session.SessionID&","&userno&",'"+usercode+"',getdate(),getdate(),'"+classcode+"','"+loginflag+"','"+Request.ServerVariables("Remote_HOST")+"')"
			end if
			cn.Execute sql				

		else
			bz=2
			Session.Abandon
		end if	
	end if
	rs.Close
end if
	
    if bz=1 and (userqx="1" or userqx="9") then
		sql="select top 1 * from "+tablename
		rs.Open sql,cn,1,3
		rs.AddNew

		newkeyno=syskeyno(tablename,"keyno")
		rs("keyno")=newkeyno
		rs("parentno")=keyno
		rs("title")=newtitle
		rs("classcode")=classcode
		rs("emote")=emote
		rs("content")=newcontent
		rs("grade")=2
		
		rs("userno")=userno
		rs("usercode")=usercode
		rs("userflag")="1"

		rs("clen")=len(content)
		rs("picflag")=picflag
		
		rs("querycount")=0
		rs("replycount")=0
		rs("flag")="0"
		rs("topflag")="0"
		rs("ipaddress")=Request.ServerVariables("Remote_HOST")
		rs("creadate")=Now()
	
		rs.Update
		rs.Close
		if picflag="1" then
			sql="select top 1 * from picfiles"
			rs2.Open sql,cn,1,3
			rs2.AddNew
			rs2("keyno")=newkeyno
			rs2("code")=tablename
			rs2("tablename")=tablename
			rs2("picfile").appendchunk picdata
			rs2.Update
			rs2.Close
		end if	

		sql="update userinfo set talkcount=talkcount+1,amount=amount+1 where userno="&userno
		cn.Execute sql

		sql="update forum_class set reccount=reccount+1 where classcode='"+classcode+"'"
		cn.Execute sql
		
		if databaseflag="sql" then
			sql="update forum set replycount=replycount+1,replyno="&newkeyno&",replytime=getdate(),replyuser='"+usercode+"' where keyno="&keyno
		else
			sql="update forum set replycount=replycount+1,replyno="&newkeyno&",replytime=now(),replyuser='"+usercode+"' where keyno="&keyno
		end if	
		cn.Execute sql
		
		xx=myurl&"&pageno="&pageno
		'Response.Write xx
		'Response.End
		Response.Redirect(xx)

		'Response.Redirect myurl&"&pageno="&pageno&"#end"
		 
	end if
  else
	if userqx="9" then
		delkeyno=Request.Form("delkeyno")

		sql="delete from forum  where keyno="&delkeyno
		cn.Execute sql

	  sql="select count(keyno) from forum where classcode='"+classcode+"' and grade=1"
	  rs2.Open sql,cn,1,1
	  topcount=rs2(0)
	  rs2.Close
	  sql="select count(keyno) from forum where classcode='"+classcode+"'"
	  rs2.Open sql,cn,1,1
	  reccount=rs2(0)
	  rs2.Close
	  sql="update forum_class set topcount="&topcount&",reccount="&reccount&" where classcode='"+classcode+"'"
	  cn.Execute sql
		
		Response.Redirect(myurl)
	end if
  end if	
end if	

Function bin2str(binstr)
   Dim varlen,clow,ccc,skipflag
   '中文字符Skip标志
   skipflag=0
   ccc = ""
   varlen=LenB(binstr)
   For i=1 To varlen
       If skipflag=0 Then

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -