<?php
require_once 'web.config.php';


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>回复留言</title>
    <link href="themes/default/theme.css" rel="stylesheet" type="text/css" />
    <!-- TinyMCE -->
    <script type="text/javascript" src="Deep_library/tiny_mce/tiny_mce.js"></script>
    <script type="text/javascript" src="Deep_library/tiny_mce/plugins/tinybrowser/tb_tinymce.js.php"></script>
    <script type="text/javascript">
        tinyMCE.init({
            mode : "exact",
            elements : "guestContent",
            language : "zh",
            theme : "simple",
			width : "550"
        });
    </script>
    <!-- /TinyMCE -->
    <script type="text/javascript">
        function checkSubmit()
        {
			tinyMCE.triggerSave(); 
            if(document.forms['form1'].guestName.value==''){
                alert("留言人不能为空！！");
                document.forms['form1'].guestName.focus();
                return false;
            }
            if(document.forms['form1'].guestContent.value==''){
                alert("留言内容不能为空！！");
                //document.forms['form1'].guestContent.focus();
                return false;
            }
            if(document.forms['form1'].checkCode.value==''){
                alert("验证码不能为空！！");
                document.forms['form1'].checkCode.focus();
                return false;
            }
        }
    </script>
</head>
<body>
    <!--logo区-->
    <!--include file="include/include.top.asp" -->
    <div id="guestBook">
        <br />
        <br />
        回复留言<br />
<?php
if( !empty ($_POST['guestName']) && !empty ($_POST['guestContent']) &&  !empty($_GET['id'])){
	if( (strtolower($_SESSION["checkCode"])) != (strtolower($_POST['checkCode'] )) ){
		echo "验证码输入错误！！！<br />";
	}else{
		$guestName=$_POST['guestName'];
		//$guestFace=$_POST['guestFace'];
		$guestFace='';
		$guestFrom=$_POST['guestFrom'];
		$guestQQ=$_POST['guestQQ'];
		$guestMSN=$_POST['guestMSN'];
		$guestHomePage=$_POST['guestHomePage'];
		$guestEmail=$_POST['guestEmail'];
		$guestTel=$_POST['guestTel'];
		//$guestTitle=$_POST['guestTitle'];
		$guestTitle='';
		$guestContent=$_POST['guestContent'];
	
		$guestDatetime=date("Y-m-d H:i:s");
		$guestType=$_GET['id'];
		$guestIsPassed=0;
		$guestIP=$_SERVER['REMOTE_ADDR'];
		$user_id=0;
		$sql="insert into deep_GuestBook(guestName,guestFrom,guestTitle,guestContent,guestType,guestIsPassed,guestFace,guestQQ,guestMSN,guestHomePage,guestEmail,guestTel,guestDatetime,guestIP,user_id)values('$guestName','$guestFrom','$guestTitle','$guestContent',$guestType,$guestIsPassed,'$guestFace','$guestQQ','$guestMSN','$guestHomePage','$guestEmail','$guestTel','$guestDatetime','$guestIP',$user_id)";
		//echo $sql;
		$rsOK=$conn->query($sql);
		if($rsOK>0){
			echo "回复留言成功，请等待管理员审核，才能看到！！<br />";
		}else{
			echo "回复留言失败！！<br />";
		}
	}
}else{
?>
        <form action="" method="post" name="form1" onsubmit="return checkSubmit()">
           <table class="guestOneTopic">
            <tr>
                <td class="left">
                    回复人：
                </td>
                <td class="right"><input type="text" name="guestName" />
                </td>
            </tr>
            <tr>
                <td class="left">
                    来自：
                </td>
                <td class="right"><input type="text" name="guestFrom" />
                </td>
            </tr>
            <tr>
                <td class="left">
                    QQ：
                </td>
                <td class="right"><input type="text" name="guestQQ" />
                </td>
            </tr>
            <tr>
                <td class="left">
                    msn：
                </td>
                <td class="right"><input type="text" name="guestMSN" size="60" />
                </td>
            </tr>
            <tr>
                <td class="left">
                    主页：
                </td>
                <td class="right"><input type="text" name="guestHomePage" size="60" />
                </td>
            </tr>
            <tr>
                <td class="left">
                    E-mail：
                </td>
                <td class="right"><input type="text" name="guestEmail" size="60" />
                </td>
            </tr>
            <tr>
                <td class="left">
                    电话：
                </td>
                <td class="right"><input type="text" name="guestTel" />
                </td>
            </tr>
            <tr>
                <td class="left">
                    回复内容：
                </td>
                <td class="right"><textarea name="guestContent"  id="guestContent" ></textarea>
                </td>
            </tr>
            <tr>
                <td class="left">
                    验证码：
                </td>
                <td class="right"><input type="text" name="checkCode" />
                	<img src="Deep_library/Deep.util.validatorCode.php" width="85" height="20" onClick="this.src+='?rand='+Math.random();" title="看不清？单击此处刷新" style="cursor:pointer;"/>
                </td>
            </tr>
            <tr>
                <td class="left">&nbsp;

                </td>
                <td class="right"><input type="submit" value="回复" /><input type="reset" value="重置" />
                </td>
            </tr>
        </table>
    </form>
<?php
}
?>
      <a href="guestBook.php">返回留言板</a><br />
    </div>
    <!--版权区-->
    <!--include file="include/include.foot.asp" -->
</body>
</html>
