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

📄 savewrite.asp

📁 红金羚v1.5办公自动化软件是基于大型数据库系统开发的应用系统
💻 ASP
字号:
<%@ LANGUAGE="VBSCRIPT" %>
<% option explicit
Response.Cookies("userinfo")("UserName")=trim(Request.Form("username"))
Response.Cookies("userinfo")("Useremail")=trim(Request.Form("email"))
Response.Cookies("userinfo").Expires = now() + 365
%>
<!--#include file="newconn.asp"-->
<!-- #include file="inc/char.inc" -->
<% 
dim announceid
dim UserName
dim userPassword
dim useremail
dim Topic
dim body
dim FoundError
dim ErrMsg
dim dateTimeStr
dim addAll
dim newUser
dim UserID
dim ip
dim Expression
dim boardID
%>
<html>

<head>
<meta NAME="GENERATOR" Content="Microsoft FrontPage 3.0">
<meta HTTP-EQUIV="Expires" CONTENT="0">
<link rel="stylesheet" type="text/css" href="forum.css">
<title>我要发言</title>
</head>

<body>
<%	  
'addall=request("chkAddAll")
IP=Request.ServerVariables("REMOTE_ADDR") 
Expression=Request.Form("Expression")&".gif"
   UserName=trim(request("username"))
   UserPassWord=request("passwd")
   UserEmail=request("email")
   Topic=trim(request("subject"))
   Body=request("body")
boardID=request("boardID")
FoundError=false
if UserName="" or strLength(UserName)>50 then
   ErrMsg="请输入姓名(长度不能大于50)"
   foundError=True
elseif Trim(UserPassWord)="" or strLength(UserPassWord)>10 then
   ErrMsg=ErrMsg+"<Br>"+"请输入密码(长度不能大于10)"
   foundError=True
end if
if Topic="" then
   FoundError=True
   if Len(ErrMsg)=0 then
      ErrMsg="主题不应为空"
   else
      ErrMsg=ErrMsg+"<Br>"+"主题不应为空"
   end if
elseif strLength(topic)>255 then
   FoundError=True
   if strLength(ErrMsg)=0 then
      ErrMsg="主题长度不能超过255"
   else
      ErrMsg=ErrMsg+"<Br>"+"主题长度不能超过255"
   end if
end if
if strLength(body)>ANNOUNCE_MAXBYTE then
   ErrMsg=ErrMsg+"<Br>"+"发言内容不得大于" & CSTR(ANNOUNCE_MAXBYTE) & "bytes"
   foundError=true
end if

%>
<%
if FoundError=true then
   showAnnounce(ErrMsg)
else
   dim sql
   dim rs
   dim FoundUser
   set rs=server.createobject("adodb.recordset")
   sql="select * from User where ucase(username)='"&ucase(username)&"'"
   rs.open sql,conn,1,3
   if not rs.EOF then
        FoundUser=True
	    UserID=rs("UserID")
 	  
   end if
	  if not FoundUser then
         SaveNewUser username,userpassword,useremail
	     NewUser=true
         if founderror=true then showAnnounce(ErrMsg)
         elseif UserPassword<>rs("UserPassword") then
           ErrMsg="您的密码不正确(或者该名字被注册,请用别的名字)"
	       foundError=true
            showAnnounce(ErrMsg)
      else
         rs("article")=rs("article")+1
         rs.update
      end if
    rs.close
      if foundError=false then
        ' if Need_password=false then 
        '    session("bbsUserName")=Trim(UserName)
        '    session("bbsUserPwd")=UserPassword
        ' end if
         DateTimeStr=CSTR(NOW()+TIME_ADJUST/24)
	 'if addAll=false then
         dim rsBoard
         dim boardname
         dim boardsql
         set rsBoard=server.createobject("adodb.recordset")
         boardsql="select board.boardname,board.boardtype from board where boardID="&request("boardid")
         rsboard.open boardsql,conn,1,1
         boardname=rsboard("boardname")
         session("boardtype")=rsboard("boardtype")
         rsboard.close
         
         dim cmdTemp
	     dim InsertCursor
         dim dataconn
         Set DataConn = Server.CreateObject("ADODB.Connection")
         dataconn.open connstr
         Set cmdTemp = Server.CreateObject("ADODB.Command")
	     Set InsertCursor = Server.CreateObject("ADODB.Recordset")
         cmdTemp.CommandText="SELECT *, UserName FROM bbs1 WHERE (UserName IS NULL)"
         cmdTemp.CommandType = 1
         Set cmdTemp.ActiveConnection = dataconn
  	     InsertCursor.Open cmdTemp, , 1, 3
	     InsertCursor.AddNew
		InsertCursor("BoardID") = boardID
	     InsertCursor("ParentID") = 0
         InsertCursor("Child") = 0
	     InsertCursor("UserName") = UserName
	     InsertCursor("UserEmail") =UserEmail
	     InsertCursor("Topic") =Topic
	     InsertCursor("Body") =Body
	     InsertCursor("DateAndTime") =DateTimeStr
	     InsertCursor("hits") =0
	     InsertCursor("length")=strlength(body)
	     InsertCursor("rootID")=0
	     InsertCursor("layer")=1
	     InsertCursor("orders")=0
         InsertCursor("ip")=ip
         InsertCursor("Expression")=Expression
	     InsertCursor.Update
         announceid=InsertCursor("AnnounceID")
         InsertCursor("RootID")= announceid
	     InsertCursor.Update
  	     if err.number<>0 then
	       err.clear
		   ErrMsg="数据库操作失败,请以后再试"&err.Description 
  	       showAnnounce(ErrMsg)
	     else
		   response.write "<p align='center'><strong>"
		   if pwsonchsys then
              showBody Topic
           else
              response.write Server.HTMLEncode(Topic)
           end if
		   response.write "</strong></p> "+chr(13)+chr(10)
           response.write "<hr size='1'>"+chr(13)+chr(10)
		   if Trim(UserEmail)<>"" then 
              response.write "<p>"
		      response.write " <a href='mailto:"+Server.HTMLEncode(UserEmail)+"'>"
		     if pwsonchsys then
                  showBody UserName
             else
                  response.write Server.HTMLEncode(UserName)
             end if
	  	     response.write "</a> 于 "+DateTimeStr+" 发表在:"
             response.write "<font color=darkblue><strong>"+session("boardtype")+"</strong></font>"      
             response.write "</p>"+chr(13)+chr(10)
           else
             if pwsonchsys then
                  showBody UserName
             else
                  response.write Server.HTMLEncode(UserName)
             end if
	  	     response.write " 于 "+DateTimeStr+" 发表在:"
             response.write "<font color=darkblue><strong>"+session("boardtype")+"</strong></font>"      
             response.write "</p>"+chr(13)+chr(10)
        
           end if
             response.write "<p> "
             ShowBody(body)
		     response.write "<hr size='1'>"+chr(13)+chr(10)
		     response.write "<a href='List.asp?boardID="+cstr(boardID)+"' >刷新浏览</a>"+chr(13)+chr(10)
     		    
 	    InsertCursor.close
		dataconn.close
    end if	  
  end if
end if
response.write "</body>"+chr(13)+chr(10)
response.write "</html>"+chr(13)+chr(10)

function showAnnounce(ErrMsg)
      on error resume next
      response.write "<font color='red'><strong><Big>输入错误:</big></strong></font><BR><font color='#0000FF'>"+ErrMsg+"</font><BR>"+chr(13)+chr(10)
%>

<form action="Savewrite.asp?boardID=<%=request("boardid")%>" method="POST"
name="frmAnnounce">
  <div align="center"><center><table border="1" width="530" bgcolor="#F7FBFF"
  bordercolorlight="#2F97FF" cellspacing="0" bordercolordark="#F0F8FF">
    <tr>
          <td width="100%" bgcolor="#CCCCFF" height="15"> 
            <div align="center"></div>
            <p align="center"><font color="#000000"><strong>我 要 发 言</strong></font>
          </td>
    </tr>
    <tr align="center">
      <td width="100%"><table border="0" width="100%" cellspacing="1">
        <tr>
                <td width="14%" align="right">论 坛:</td>
                <td colspan="2"><font color="darkblue"><strong><%=session("boardtype")%></strong></font>&nbsp;<font
          color="red"><strong>*</strong></font>为必填项目 第一次发言自动注册</td>
        </tr>
        <tr>
                <td width="14%" align="right">姓 名:</td>
                <td colspan="2">
<input class="smallInput" name="username" size="16"
          maxlength="50" value="<%=UserName%>"><font color="red"><strong>*</strong></font> 
          &nbsp; 密 码:<input class="smallInput" name="passwd" size="10" maxlength="10"
          type="password"><font color="red"><strong>*</strong></font></td>
        </tr>
        <tr>
                <td width="14%" align="right">Email:</td>
                <td colspan="2">
<input class="smallInput" name="email" size="42"
          maxlength="40" value="<%=htmlencode2(useremail)%>"></td>
        </tr>
        <tr>
                <td width="14%" align="right">主 题:</td>
                <td colspan="2">
<input class="smallInput" name="subject" size="65"
          maxlength="255" value="<%=htmlencode2(topic)%>"><font color="red"><strong>*</strong></font> 
          </td>
        </tr>
        <tr>
                <td width="14%" align="right" valign="top"><span class="smallFont">表 
                  情:</span></td>
                <td colspan="2">
<input type="radio" value="smiley" name="Expression" checked><img
          src="IMAGES/smiley.gif" width="15" height="15"> <input type="radio" name="Expression"
          value="sad"><img src="IMAGES/sad.gif" width="16" height="16"> <input type="radio"
          name="Expression" value="angry"><img src="IMAGES/angry.gif" width="15" height="15"> <input
          type="radio" name="Expression" value="1"><img src="IMAGES/13.gif" width="15" height="15"> <input
          type="radio" name="Expression" value="11"><img src="IMAGES/14.gif" width="15" height="15"> 
          <input type="radio" name="Expression" value="15"><img src="IMAGES/15.gif" width="15"
          height="15"> <input type="radio" name="Expression" value="13"><img src="IMAGES/16.gif"
          width="15" height="15"> <br>
          <input type="radio" value="18" name="Expression"><img src="IMAGES/18.gif" width="15"
          height="15"> <input type="radio" name="Expression" value="17"><img src="IMAGES/17.gif"
          width="15" height="15"> <input type="radio" name="Expression" value="19"><img
          src="IMAGES/19.gif" width="15" height="15"> <input type="radio" name="Expression"
          value="20"><img src="IMAGES/20.gif" width="15" height="15"> <input type="radio"
          name="Expression" value="21"><img src="IMAGES/21.gif" width="15" height="15"> <input
          type="radio" name="Expression" value="22"><img src="IMAGES/22.gif" width="15" height="15"> 
          <input type="radio" name="Expression" value="23"><img src="IMAGES/23.gif" width="15"
          height="15"> </td>
        </tr>
        <tr>
                <td width="14%" align="right"><span class="smallFont">内 容:</span></td>
                <td width="31%"><span class="smallFont">(最多<%=ANNOUNCE_MAXBYTE\1024%>KB)</span></td>
                <td width="55%">
<p><input class="buttonface" type="submit"
          value=" 发 送 ">&nbsp; <input class="buttonface" type="reset" value=" 重 填 "> </td>
        </tr>
        <tr align="center">
                <td width="14%"><span class="smallFont"></span></td>
                <td colspan="2">
<p><textarea class="smallarea" cols="65"
          name="body" rows="10"><%=htmlencode2(body)%></textarea></td>
        </tr>
        <tr align="center">
                <td width="14%" height="15"><span class="smallFont"></span></td>
                <td colspan="2"></td>
        </tr>
      </table>
      </td>
    </tr>
  </table>
  </center></div>
</form>
<%
end function

function SaveNewUser(username,userpassword,email)
        on error resume next
        dim cmdTemp
		dim InsertCursor
		dim dataconn
        Set DataConn = Server.CreateObject("ADODB.Connection")
		dataconn.open connstr
        Set cmdTemp = Server.CreateObject("ADODB.Command")
		Set InsertCursor = Server.CreateObject("ADODB.Recordset")
		cmdTemp.CommandText = "SELECT *, UserName FROM User WHERE (UserName IS NULL)"
		cmdTemp.CommandType = 1
		Set cmdTemp.ActiveConnection = dataConn
		InsertCursor.Open cmdTemp, , 1, 3
        InsertCursor.AddNew
		InsertCursor("UserName") = UserName
		InsertCursor("UserPassword") = UserPassword
		InsertCursor("UserEmail") = UserEmail
		InsertCursor("article") = 1
		InsertCursor.Update
        if not err.number<>0 then 
		   
		   UserID=insertcursor("UserID")
		else 
           err.clear
		   FoundError=true
		   ErrMsg="数据库操作失败,请以后再试"&err.Description 
		end if
        InsertCursor.close
		dataconn.close
end function
%>
</body>
</html>

⌨️ 快捷键说明

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