<!--#include file="../../conn/conn.asp"-->
<!--#include file="../../conn/nosql.asp"-->
<!--#include file="../../conn/config.asp"-->
<!--#include file="../../conn/count.asp"-->
<!--#include file="../page.asp"-->
<!--#include file="../count.asp"-->
<%
if isChkInteger(request("web_id")) then
web_id=request("web_id")
else
Response.Redirect ("../../index.asp")
end if
sql="select * from snsn_user where id="&web_id
Set rs= Server.CreateObject("ADODB.Recordset") 
rs.open sql,conn,1,1
if rs.eof or rs.bof then
response.write "<script language='javascript'>"
response.write "alert('没有此用户，请确认后或联系管理员再访问本页！');"
response.write"this.location.href='/index.asp';</SCRIPT>"
response.end
else
if request("action")="add" then
   iname=nosql(request.Form("name"))
   ititle=nosql(request.Form("title"))
   iqq=nosql(request.Form("qq"))
   show=nosql(request.Form("show"))
   zshow=nosql(request.form("zshow"))
   iemail=nosql(request.Form("email"))
   iurl=nosql(request.form("url"))
   isex=nosql(request.form("sex"))
   icontent=nosql(request.form("content"))
   iuserid=nosql(request.form("web_id"))
   iqqh=request.form("qqh")
   icontent=icontent&show
      if show<>"" and zshow<>"" then
Response.Write "<script Language=Javascript>alert('使用魔法表情请先关闭文字秀功能！');javascript:history.go(-1)</script>"
Response.end
end if
if show<>"" or zshow<>"" then
if session("id")="" then
Response.Write "<script Language=Javascript>alert('未登录不能使用魔法表情和文字秀功能！');javascript:history.go(-1)</script>"
Response.end
else
sql="select * from snsn_user where  id="&session("id")&""
Set rsjf= Server.CreateObject("ADODB.Recordset") 
rsjf.open sql,conn,1,3
if rsjf.eof or rsjf.bof then
response.write "<script language='javascript'>"
response.write "alert('没有此用户，请确认后或联系管理员再访问本页！');"
response.write"this.location.href='/index.asp';</SCRIPT>"
response.end
end if
rsjf.close
set rsjf=nothing
end if
end if

  set rs=server.createobject("adodb.recordset")
  rs.open "select * from snsn_guestbook",conn,1,3
  rs.addnew
  rs("name")=iname
  rs("title")=ititle
  rs("qq")=iqq
  rs("email")=iemail
  rs("url")=iurl
  rs("sex")=isex
  rs("content")=icontent
  rs("adddate")=now()
  rs("userid")=iuserid
  if iqqh="" then
  rs("qqh")=0
  else
  rs("qqh")=1
  end if
    if zshow<>"" then
rs("zshow")=1
end if
  rs.update
  rs.close
  set rs=nothing
  '今日更新
sql="select * from snsn_user where id="&web_id
Set rscount= Server.CreateObject("ADODB.Recordset") 
rscount.open sql,conn,1,1
if rscount.eof or rscount.bof then
response.write "<script language='javascript'>"
response.write "alert('没有此用户，请确认后或联系管理员再访问本页！');"
response.write"this.location.href='/index.asp';</SCRIPT>"
response.end
else

    if datediff("d",rscount("inewdate"),now())<1 then
	conn.execute("update snsn_user set inew=inew+1 where id="&web_id)
    else
	conn.execute("update snsn_user set inew=1,inewdate=getdate() where id="&web_id)
    end if
    
end if
rscount.close
set rscount=nothing
'结束
  
  Response.Redirect ("guestbook.asp?web_id="&iuserid&"")
elseif request("action")="reply" then
if isChkInteger(request("id")) then
id=nosql(request("id"))
else
Response.Redirect ("../../index.asp")
end if
reply=nosql(request.form("reply"))
conn.execute("update [snsn_guestbook] set reply='"&reply&"' where id="&id)
'今日更新
sql="select * from snsn_user where id="&web_id
Set rscount= Server.CreateObject("ADODB.Recordset") 
rscount.open sql,conn,1,1
if rscount.eof or rscount.bof then
response.write "<script language='javascript'>"
response.write "alert('没有此用户，请确认后或联系管理员再访问本页！');"
response.write"this.location.href='/index.asp';</SCRIPT>"
response.end
else

    if datediff("d",rscount("inewdate"),now())<1 then
	conn.execute("update snsn_user set inew=inew+1 where id="&web_id)
    else
	conn.execute("update snsn_user set inew=1,inewdate=getdate() where id="&web_id)
    end if
    
end if
rscount.close
set rscount=nothing
'结束

Response.Redirect ("guestbook.asp?web_id="&web_id&"")
elseif request("action")="del" then
if isChkInteger(request("id")) then
id=nosql(request("id"))
else
Response.Redirect ("../../index.asp")
end if
sql="delete from [snsn_guestbook] where id="&id
conn.execute sql
Response.Redirect ("guestbook.asp?web_id="&web_id&"")
else
%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<link rel="stylesheet" href="css.css" type="text/css">
<style type="text/css">
<!--
.style1 {
	color: #0158B5;
	font-weight: bold;
}
.style2 {
	color: #FE6D02;
	font-weight: bold;
}
.style3 {
	color: #BF7900;
	font-weight: bold;
}
.style5 {color: #D90089; font-weight: bold; }
.style7 {color: #FFFFFF; font-weight: bold; }
.style8 {color: #FF3300}
-->
</style>
</head>
  <SCRIPT language=JavaScript>

function is_number(str)
{
	exp=/[^0-9()-]/g;
	if(str.search(exp) != -1)
	{
		return false;
	}
	return true;
}

function CheckInput(){

if(snsn.title.value==''){
		alert("您没有填写主题！");
		snsn.title.focus();
		return false;
	}
	if(snsn.title.value.length>50){
		alert("主题不能超过50个字符！");
		snsn.title.focus();
		return false;
	}

	if(snsn.name.value==''){
		alert("您没有填写昵称！");
		snsn.name.focus();
		return false;
	}
	if(snsn.name.value.length>20){
		alert("昵称不能超过20个字符！");
		snsn.name.focus();
		return false;
	}

	if(!is_number(document.snsn.qq.value)){
		alert("QQ号必须是数字！");
		snsn.qq.focus();
		return false;
	}

	if(snsn.content.value==''){
		alert("您没有填写留言内容！");
		snsn.content.focus();
		return false;
	}
	if(snsn.content.value=='留言内容'){
		alert("您没有填写留言内容！");
		snsn.content.focus();
		return false;
	}
	if(snsn.content.value.length>255){
		alert("留言内容不能超过255个字符！");
		snsn.content.focus();
		return false;
	}
	
	return true;
}
</SCRIPT>
<body>
<table width="420"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="22">
      <table width="420"  border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="1" height="1"></td>
          <td height="1" colspan="2" bgcolor="#CCCCCC"></td>
          <td width="1" height="1"></td>
        </tr>
        <tr>
          <td width="1" bgcolor="#CCCCCC"></td>
          <td width="30" bgcolor="#F1F1F1"><div align="center"><span class="style8"><img src="img/p_13.gif" width="19" height="19"></span></div></td>
          <td height="25" bgcolor="#F1F1F1"><span class="M"><FONT 
                              color=#000000><a href="web.asp?web_id=<%=web_id%>"><U><%=home%></U></a></FONT> -&gt; <FONT 
                              color=#000000><a href="guestbook.asp?web_id=<%=web_id%>"><U><%=ly%></U></a></FONT> -&gt; <FONT 
                              color=#000000><a href="guestbook_add.asp?web_id=<%=web_id%>"><U>发表</U></a></FONT></span></td>
          <td width="1" bgcolor="#CCCCCC"></td>
        </tr>
        <tr>
          <td width="1" height="1"></td>
          <td height="1" colspan="2" bgcolor="#CCCCCC"></td>
          <td width="1" height="1"></td>
        </tr>
      </table></td>
    </tr><tr>
    <td height="6"></td>
  </tr>
  <tr>
    <td>
      <%if request("action")="save" then
	  if isChkInteger(request("id")) then
       id=nosql(request("id"))
      else
       Response.Redirect ("../../index.asp")
      end if
	  set rs=server.createobject("adodb.recordset")
      rs.open "select * from snsn_guestbook where id="&id,conn,1,1
      content=rs("content")
	
	  %>
      <FORM action="?web_id=<%=request("web_id")%>&action=reply&id=<%=id%>" method=post name="snsn" id="snsn">
        <table width="90%"  border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="8"><%=content%></td>
          </tr>
        </table>
        <TABLE width="100%" border=0 cellPadding=0 cellSpacing=0>
          <TBODY>
          
          <TR>
            <TD height="130" noWrap> &nbsp;&nbsp;
                <textarea name=reply cols=60 rows=12 id="reply" class="wenbenkuang"><%if rs("reply")="" then%>回复内容<%else%><%=rs("reply")%><%end if%></textarea>
            </TD>
          <TR>
            <TD height="30" colspan="2"> &nbsp;&nbsp;
                <input name="submit2" type=submit class="go-wenbenkuang" id="submit2" value=我要留言 onClick="return CheckInput();">
&nbsp;&nbsp;
        <input name="submit32" type=reset class="go-wenbenkuang" id="submit32" value=清除重来>
        <input name="web_id2" type="hidden" id="web_id2" value="<%=request("web_id")%>">
            </TD>
          </TR>
        </TABLE>
      </FORM>
      <%else%><FORM action="?web_id=<%=request("web_id")%>&action=add" method=post name="snsn" id="snsn">
            <table width="90%"  border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td height="8"></td>
              </tr>
            </table>
            <TABLE width="100%" border=0 cellPadding=0 cellSpacing=1 bgcolor="f1f1f1">
              <TBODY>
              <TD height="25" bgcolor="#FFFFFF">&nbsp;&nbsp; 姓名：
                      <input name=name class="wenbenkuang" id="name" value="<%=session("user")%>">
        <label>
        <input name="sex" type="radio" value="boy" checked>
先生</label>
        <label>
        <input type="radio" name="sex" value="girl">
小姐</label></TD>
              </TR><tr>
                <TD height="25" bgcolor="#FFFFFF">&nbsp;&nbsp; 主题：
                  <input name=title class="wenbenkuang" id="qq" size="35">
                  <label></label>
                  <label> </label>
                <label></label></TD>
              </TR>
              <tr>
                <TD height="25" bgcolor="#FFFFFF">&nbsp;&nbsp; OICQ：
                  <input name=qq class="wenbenkuang" id="qq3">
                  <label></label>
                <label>                  </label><label>不填写请留空</label></TD>
              </TR>
              <TR>
                <TD height="25" bgcolor="#FFFFFF">&nbsp;&nbsp; 网址：
                    <input name=url class="wenbenkuang" id="url" size="35">
                不填写请留空</TD>
              </TR>
              <TR>
                <TD height="25" bgcolor="#FFFFFF">&nbsp;&nbsp; 邮箱：
                <input  name=email class="wenbenkuang" id="email" size="35">
                不填写请留空</TD>
              </TR><tr bgcolor="#FFFFFF">
          <TD height=25 align="left" bgcolor="#FFFFFF" title="如果使用魔法表情将不能使用文字秀功能">&nbsp;&nbsp; 魔法：            
            <input name="show" type="text" class=wenbenkuang id="show" size="28" maxlength="28" readOnly>
          <a href="javascript:;" onClick="window.open('../qq/selqq.asp','web_show','scrollbars=no,resizable=no,width=370,height=365,menubar=no,top=188,left=188')" class=over>魔法表情浏览</a></TD>
        </tr>
              <TR>
                <TD height="25" noWrap bgcolor="#FFFFFF"> &nbsp;&nbsp;
                <textarea name=content cols=60 rows=8 id="content" class="wenbenkuang">留言内容</textarea>                </TD>
              <TR>
                <TD height="25" colspan="2" bgcolor="#FFFFFF"> &nbsp;&nbsp;
                    <input name="submit" type=submit class="go-wenbenkuang" id="submit" value=我要留言 onClick="return CheckInput();">
&nbsp;
<input name="submit3" type=reset class="go-wenbenkuang" id="submit3" value=清除重来>
        <input name="web_id" type="hidden" id="web_id" value="<%=web_id%>">
        <input name="qqh" type="checkbox" id="iqqh" value="1">
        悄悄话[仅站长可见]</TD>
              </TR>
              <TR>
                <TD height="25" colspan="2" bgcolor="#FFFFFF" title="如果使用文字秀则发表的一些文字会被图片替代">&nbsp;&nbsp;
                  <input name="zshow" type="checkbox" id="zshow" value="1">
是否使用文字秀,没登录将不能使用魔法和文字秀</TD>
              </TR>
        <tr bgcolor="#FFFFFF">
          <td height="25" bgcolor="#FFFFFF">&nbsp; &nbsp; &nbsp; 魔法表情和文字秀不能同时使用。</td>
        </tr>
        <tr bgcolor="#FFFFFF">
          <td height="25" bgcolor="#FFFFFF">&nbsp; &nbsp; &nbsp; 使用文字秀将失去HTML功能。</td>
              </TR>
        </TABLE>
      </FORM>    <%end if%>      </td>
  </tr>
</table>
</body>
</html><%end if
end if
  rs.close
      set rs=nothing
%>
