<!--#include file="conn.asp"-->
<!--#include file="config.asp"-->
<%

webtitle="客户留言"
webkeywords="客户留言"
webdescription="客户留言|"&webname
%> 



<!--#include file="include/header.asp"--> 
<TABLE width="980" BORDER="0" CELLSPACING="0" CELLPADDING="0" align="center" class=table-zuoyou  bgcolor="#Ffffff">
<TR><TD HEIGHT="30" bgcolor="#f1f1f1" width="75" class="table-xia"><FONT color="#333333">&nbsp;<b><FONT COLOR=#333333 >留言板块：</font></b></FONT></TD>
<td BGCOLOR=#ffffff class="table-xia">&nbsp;<FONT COLOR=#333333>尊敬的客户，请在这里将您们的宝贵建议反馈给我们，我们会及时回复，谢谢 ！</font></td></TR></table>
<%
dim action
action=Request.Form("action")
select case action
case ""
%>
<table width="980" border="0" cellspacing="0" cellpadding="0"  align="center" class=table-zuoyou bgcolor="#Ffffff">
 <TR> <TD width="100%"  valign="top">
	  <TABLE WIDTH="95%" BORDER="0" ALIGN="center" CELLPADDING="2" CELLSPACING="2" class=table-zuoyou>
	<TR> 
          <td WIDTH="100%" class=table-xia ALIGN="CENTER"><FONT COLOR=#000000><b>客户留言</b></font> </td>
            
            
        </TR>	

<TR><TD  VALIGN="TOP" class=table-xia>
      <%
				Const MaxPerPage=30
   				dim totalPut   
   				dim CurrentPage
   				dim TotalPages
   				dim j
   				dim sql
    			if Not isempty(SafeRequest("page",1)) then
      				currentPage=Cint(SafeRequest("page",1))
   				else
      				currentPage=1
   				end if 
		set rs=server.CreateObject("adodb.recordset")
	rs.open "select  messsubject,messid,messcontent,messusername,messfrom,messdtm from mess where audit=1 order by messdtm  desc",conn,1,1
		  
				if err.number<>0 then
				response.write ""
				end if
				if rs.eof And rs.bof then
       				Response.Write "<p align='center'> 对不起，目前还没有留言！</p>"
  				
   				else
	  				totalPut=rs.recordcount

      				if currentpage<1 then
          				currentpage=1
      				end if

      				if (currentpage-1)*MaxPerPage>totalput then
	   					if (totalPut mod MaxPerPage)=0 then
	     					currentpage= totalPut \ MaxPerPage
	   					else
	      					currentpage= totalPut \ MaxPerPage + 1
	   					end if
      				end if

       				if currentPage=1 then
            			showContent
            			showpage totalput,MaxPerPage,"gbook.asp"
       				else
          				if (currentPage-1)*MaxPerPage<totalPut then
            				rs.move  (currentPage-1)*MaxPerPage
            				dim bookbrand
            				bookbrand=rs.bookbrand
            				showContent
             				showpage totalput,MaxPerPage,"gbook.asp"
        				else
	        				currentPage=1
           					showContent
           					showpage totalput,MaxPerPage,"gbook.asp"
	      				end if
	   				end if
   				   				end if

   				sub showContent
       			dim i  
	   			i=0
                                
                     
			%>
 <%dim follows

follows=0

%>
      <%do while not rs.eof

follows=follows+1

%>
 
        
      <TABLE WIDTH="95%" BORDER="0" ALIGN="center" CELLPADDING="0" CELLSPACING="0" >
	
        <tr><td class=table-xia height="30">&nbsp;<%=follows%>.<b>&nbsp;主题:</b><%=trim(rs("messsubject"))%></td>
            <td class=table-xia height="30" WIDTH="20%">留言人:<%=trim(rs("messusername"))%></td>
            <td class=table-xia height="30" WIDTH="20%">时&nbsp;&nbsp;间:<%=trim(rs("messdtm"))%></td>
        </tr>
         <tr><td class=table-xia height="50" colspan="3">&nbsp;&nbsp;内容:<br>&nbsp;&nbsp;&nbsp;&nbsp;<% = rs("messcontent") %>
              </td>
         </tr>
         <tr><td class=table-xia height="40" colspan="3">&nbsp;&nbsp;回复:<br>&nbsp;&nbsp;&nbsp;&nbsp;<% = rs("messfrom") %>
              </td>
         </tr>
      </TABLE>
       
      <%i=i+1
          
			if i>=MaxPerPage then Exit Do
			rs.movenext
			loop
                         
			rs.close
			set rs=nothing%>
   
      <%  
				End Sub   
  
				Function showpage(totalnumber,maxperpage,filename)  
  				Dim n
  				
				If totalnumber Mod maxperpage=0 Then  
					n= totalnumber \ maxperpage  
				Else
					n= totalnumber \ maxperpage+1  
				End If %>
				<form method=Post action=<%=filename%>>
				<p align="center">
				<%
				If CurrentPage<2 Then  %>
				<FONT COLOR=#333333>首 页 上一页
				<% Else  %>
				<a href=<% = filename %>?page=1>首 页</a>
				<a href=<% = filename %>?page=<% = CurrentPage-1 %>>上一页</a> 
				<% End If 
				If n-currentpage<1 Then  %>
				下一页 末 页
				<%  Else  %>
				<a href=<% = filename %>?page=<% = (CurrentPage+1) %>>下一页</a> 
				<a href=<% = filename %>?page=<% = n %>>末 页</a>
				<% End If  %>
				 第 <b><% = CurrentPage %></b> 页 共 <b><% = n %></b> 页
				共&nbsp;<b><% = totalnumber %></b>&nbsp;条留言　每页 <b><% = maxperpage %></b> 条留言
				转到第：<input type='text' name='page' size=2 maxlength=10 class=smallInput value=<% = currentpage %>>
				页<input type='submit'  class='contents' value='跳转' name='cndok'></font></form>
				<%
				End Function  
			%>
    </TD>
  </TR>
</TABLE>
<table width="980" align="center" border="0" cellspacing="0" cellpadding="0"   bgcolor="#Ffffff">
  <TR> <TD width="100%"  align="center" class=table-xia HEIGHT="30"><FONT COLOR=#000000><b>请您留言</font></b>
   </TD>
  </TR>
</TABLE>
<table width="980" border="0" cellspacing="0" cellpadding="0" align="center"  >
  <TR> <TD width="100%"  valign="top">
	  <TABLE WIDTH="96%" BORDER="0" ALIGN="center" CELLPADDING="2" CELLSPACING="2" class=table-zuoyou>
	<TR> 

<FORM NAME="messinfo" METHOD="post" ACTION="gbook.asp">
    <TR> 
      <TD WIDTH="16%" class=table-xia>&nbsp;&nbsp;&nbsp;<FONT COLOR=#333333>类　型：</font></TD>
      <TD width="84%" class=table-xia><SELECT NAME="messtype" ID="messtype">
          <OPTION >选择留言类型</OPTION>
          <OPTION VALUE="1">普通留言</OPTION>
          <OPTION VALUE="2">意见建议</OPTION>
          <OPTION VALUE="3">缺货登记</OPTION>
          <OPTION VALUE="4">合作意向</OPTION>
          <OPTION VALUE="5">产品投诉</OPTION>
          <OPTION VALUE="6">服务投诉</OPTION>
        </SELECT> </TD>
      
    </TR>
    <TR> 
      <TD class=table-xia>&nbsp;&nbsp;&nbsp;<FONT COLOR=#333333>主　题：</font></TD>
      <TD HEIGHT="22" class=table-xia> <INPUT NAME="messsubject" TYPE="text" size="40" maxlength="20"></TD>
    </TR>
    <TR> 
      <TD class=table-xia>&nbsp;&nbsp;&nbsp;<FONT COLOR=#333333>姓　名：</font></TD>
      <TD HEIGHT="22" class=table-xia> <INPUT NAME="messusername" TYPE="text" size="40" maxlength="15"></TD>
    </TR>
    <TR> 
      <TD class=table-xia>&nbsp;&nbsp;&nbsp;<FONT COLOR=#333333>E-mail：</font></TD>
      <TD HEIGHT="22" class=table-xia> <INPUT NAME="messemail" TYPE="text" size="40" maxlength="30"> 
      </TD>
    </TR>
    <TR> 
      <TD class=table-xia>&nbsp;&nbsp;&nbsp;<FONT COLOR=#333333>电　话：</font></TD>
      <TD HEIGHT="22" class=table-xia> <INPUT NAME="messtel" TYPE="text" ID="messtel" size="40" maxlength="15"> 
      </TD>
    </TR>
    <TR> 
      <TD VALIGN="top" class=table-xia>&nbsp;&nbsp;&nbsp;<FONT COLOR=#333333>留　言：</font></TD>
      <TD class=table-xia><TEXTAREA NAME="messcontent" COLS="85" ROWS="8" wrap="VIRTUAL" ID="messcontent"></TEXTAREA> 
      </TD>
    </TR>
    <TR> 
      <TD HEIGHT="28">&nbsp;&nbsp;<input type="CheckBox" name="messtt" value="1" ><FONT COLOR=#333333>悄悄话</font><input name="action" type="hidden" value="save"></TD>
      <TD HEIGHT="28">验证码：<input name=passcode type=text size=5 maxlength="4">
              <img src="code.asp" alt="验证码" ><INPUT TYPE="submit" NAME="Submit" VALUE="发布留言"  ONCLICK="return checkmess();"></TD>
    </TR>
   
  </FORM>
</TABLE>
  </TD>
  </TR>
</TABLE>
<%
	  case "save"
           if not isnumeric(request.form("passcode")) then
response.Write "<script LANGUAGE='javascript'>alert('登录失败！验证码必须是数字，请正确填写！');history.go(-1);</script>"
conn.Close
set conn=nothing
response.end
end if
passcode=Cint(request.form("passcode"))
if passcode<>Session("GetCode") then
response.Write "<script LANGUAGE='javascript'>alert('登录失败！验证码错误！');history.go(-1);</script>"
conn.Close
set conn=nothing
response.end
end if
	  if session("messmess")=minute(now) then
	  response.write "<script language=javascript>alert('对不起，您不可以重复提交信息，请稍后再试！');history.go(-1);</script>"
	  response.End
	  end if
	  function HTMLEncode2(fString)
	fString = Replace(fString, CHR(13), "")
	fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
	fString = Replace(fString, CHR(10), "<BR>")
	HTMLEncode2 = fString
    end function
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from mess",conn,1,3
rs.addnew
rs("messsubject")=trim(request.form("messsubject"))
rs("messtype")=request.form("messtype")
rs("messcontent")=sqlCheckstr(trim(request.form("messcontent")))
rs("messusername")=sqlCheckstr(request.form("messusername"))
rs("messemail")=sqlCheckstr(request.form("messemail"))
rs("messtel")=sqlCheckstr(request.form("messtel"))
rs("messdtm")=now
rs("messip")=Request.ServerVariables("remote_addr")
rs.update
rs.close
set rs=nothing
session("messmess")=minute(now)
response.write "<br><br><center><FONT COLOR=#333333>您的信息反馈已成功提交，感谢您的参与！<br><br><a href=index.asp>返回首页</a></center>"
end select%>
<!--#include file="include/footer.asp"--> 
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}

function checkmess()
{  
   if(checkspace(document.messinfo.messtype.value)) {
	document.messinfo.messtype.focus();
    alert("您没有选择留言类型！");
	return false;
  }
   if(checkspace(document.messinfo.messsubject.value)) {
	document.messinfo.messsubject.focus();
    alert("您没有填写主题！");
	return false;
  }
   if(checkspace(document.messinfo.messusername.value)) {
	document.messinfo.messusername.focus();
    alert("请填写您的姓名！");
	return false;
  }
     if(checkspace(document.messinfo.messcontent.value)) {
	document.messinfo.messcontent.focus();
    alert("请填写反馈信息内容！");
	return false;
  }
  
  if(document.messinfo.messemail.value.length!=0)
  {
    if (document.messinfo.messemail.value.charAt(0)=="." ||        
         document.messinfo.messemail.value.charAt(0)=="@"||       
         document.messinfo.messemail.value.indexOf('@', 0) == -1 || 
         document.messinfo.messemail.value.indexOf('.', 0) == -1 || 
         document.messinfo.messemail.value.lastIndexOf("@")==document.messinfo.messemail.value.length-1 || 
         document.messinfo.messemail.value.lastIndexOf(".")==document.messinfo.messemail.value.length-1)
     {
      alert("Email地址格式不正确！");
      document.messinfo.messemail.focus();
      return false;
      }
   }
 else
  {
   alert("Email不能为空！");
   document.messinfo.messemail.focus();
   return false;
   }
if(checkspace(document.messinfo.passcode.value)) {
	document.messinfo.passcode.focus();
    alert("请输入验证码！");
	return false;
}
}
//-->
</script> 
