<!--#include file="inc_const.asp"-->
<%response.expires=0
Response.CacheControl = "Private"
application.lock

if application( ConstStr & "_disableaddact")="1" then
  response.redirect("showerr.asp?errtext=管理员禁止添加新动作！")
  application.unlock
  response.end
end if

set cschat=server.createobject("ffcschat.cssbchat")
my_level=cschat.getLevel(Session,Application(ConstStr & "_user_list"),Application(ConstStr & "_room_list"))

if my_level-application( ConstStr & "_l_addact")<0 then
  response.redirect("showerr.asp?errtext=你没有权利执行此项操作！")
  set cschat=nothing
  application.unlock
  response.end
end if

if request("cmdYes")="确认" then
  cschat.FilterStr = Application(ConstStr & "_saysfilterstr")
  act_name=replace(left(cschat.trdb(request("act_name")),10),"/","")
  alias=left(cschat.trdb(request("alias")),10)
  toall=request("toall")
  toself=request("toself")
  toother=request("toother")
  if len(toall)>100 or len(toself)>100 or len(toother)>100 then
    errtext="错误：动作内容太长，超过了100个字符！"
  elseif act_name="" or alias="" or toall="" then
    errtext="错误：动作名称、动作描述、对象是大家时的动作内容都不能为空！"
  else
    toall=cschat.trdb(toall)
    toself=cschat.trdb(toself)
    toother=cschat.trdb(toother)
    if toself="" then toself=toall
    if toother="" then toother=toall
    if mid(toall,1,2)="//" then toall="##"&mid(toall,3,len(toall))
    if mid(toself,1,2)="//" then toself="##"&mid(toself,3,len(toself))
    if mid(toother,1,2)="//" then toother="##"&mid(toother,3,len(toother))
    if instr(toall,"##")=0 or instr(toself,"##")=0 or instr(toother,"##")=0 then
      errText="错误：添加动作里必须要有“##”来指明动作使用者！"
    else
      Set Conn=Server.CreateObject("ADODB.Connection")
      conn.open Application( ConstStr & "_connstr")
      sql="select act_name from action where act_name='"&act_name&"'"
      set Rs=conn.Execute(sql)
      if (Rs.eof or Rs.bof) then
        sql="INSERT INTO action (act_name,alias,toall,toself,toother) VALUES ('"&act_name&"','"&alias&"','"&toall&"','"&toself&"','"&toother&"')"
        conn.Execute(sql)
        errText="操作成功：动作成功地写入动作库！"
      else
        errText="错误：动作库里已经有相同名称的动作！"
      end if
      rs.close
      set rs=nothing
      conn.close
      Set conn=nothing
    end if
  end if
  set cschat=nothing
  response.redirect("showerr.asp?errtext="&errText)
  application.unlock
  response.end
end if
set cschat=nothing%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="chat.css">
<style>u{color:red}</style>
<script language="JavaScript">
 function CheckValid() {
  if (document.frmNewadd.act_name.value == "") {
    alert( "请输入动作名称。");
    document.frmNewadd.act_name.focus();
    return false;}
  if (document.frmNewadd.alias.value == "") {
    alert( "请输入动作描述。");
    document.frmNewadd.alias.focus();
    return false;}
  if (document.frmNewadd.toall.value == "") {
    alert( "对象是大家时的动作内容不能为空。");
    document.frmNewadd.toall.focus();
    return false;}
  return true;}</script>
<body  style="background-color:EAF2FF;color:112233;scrollbar-Base-Color: #b0d8ff;SCROLLBAR-DARKSHADOW-COLOR:#b0d8ff;SCROLLBAR-arrow-COLOR:#336699;SCROLLBAR-TRACK-COLOR: EAF2FF;SCROLLBAR-3DLIGHT-COLOR: #b0d8ff;SCROLLBAR-SHADOW-COLOR: #336699;SCROLLBAR-HIGHLIGHT-COLOR: #b0d8ff;" leftmargin=3 topmargin=20 >
  <table width=400 align=center cellspacing=0 cellpadding=0 border=1 BORDERCOLORLIGHT=#000000 BORDERCOLORDARK=#ffffff>
  <tr><td class=navy1>添加新动作</td></tr>
 <form name="frmNewadd" action="actadd.asp" method="post" onsubmit="return CheckValid()">
  <tr><td height=50><u>英文</u>名称:<input type="text" name="act_name" maxlength="10" size="10"><font color=990000>[<u>必填</u>]</font>
  <u>中文</u>描述:<input type="text" name="alias" maxlength="5" size="5"><font color=990000>[<u>必填</u>]</font>
  <tr><td height=230>对象为<u>大家</u>时内容:<font color=990000>[<u>必填</u>，最多100个汉字]</font><BR>
  <textarea rows="3" name="toall" cols="50"></textarea><br>
   对象为<u>自己</u>时内容:<font color=990000>[不填与对象为大家时相同]</font>
  <textarea rows="3" name="toself" cols="50"></textarea><br>
   对象为<u>别人</u>时内容:<font color=990000>[不填与对象为大家时相同]</font>
  <textarea rows="3" name="toother" cols="50"></textarea>
  <tr><td height=40><input class=navy1 type="submit" name="cmdYes" value="确认" >
    <input class=navy1 type="reset" name="cmdClear" value="清除" onclick="javascript:document.frmNewadd.act_name.focus();return true">
    <input class=navy1 type="button" name="cmdCancel" value="放弃" onClick="javascript:parent.window.close()">
  <tr><td><ol>
    <li>动作中<font color=990000>##</font>代表自己，<font color=990000>%%</font>代表说话对象。大多数动作在对象是大家时、是自己时、是别人时，有不同的内容。</li>
    <li>添加动作时必须包含<font color=990000>##</font>，否则添加失败。动作添加后与原来库中的动作是完全一样的。</li>
  </td></tr></form></table><tr<td><br><center>[<a href='javascript:history.go(-1)'>后退</a>]</table></body></html>


















