<?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>
    <meta name="robots" content="noindex,nofollow" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>留言管理</title>
    <link href="../themes/<?php echo $themes_Path; ?>/main.css" rel="stylesheet" type="text/css" />
    <link href="../../themes/default/theme.css" rel="stylesheet" type="text/css" />
    <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;
            }
        }
    </script>
    <!-- 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>
</head>
<body  id="bodyBg1">
<br />
&nbsp; <a href="guestBook_Manage.php">留言管理</a> | <a href="guestBook_Add.php">添加留言</a>
<hr color="#0099FF" size="1" />
<br />
<dl class="manageContent">
    <dt>留言 回复编辑管理</dt>
    <dd>
    	<br />

<?php
if( !empty ($_POST['guestName']) && !empty ($_POST['guestContent']) && !empty ($_GET['id']) ){
    $guest_ID=$_GET['id'];
    $guestName=$_POST['guestName'];
    $guestFace=$_POST['guestFace'];
    $guestFrom=$_POST['guestFrom'];
    $guestQQ=$_POST['guestQQ'];
    $guestMSN=$_POST['guestMSN'];
    $guestHomePage=$_POST['guestHomePage'];
    $guestEmail=$_POST['guestEmail'];
    $guestTel=$_POST['guestTel'];
    $guestTitle=$_POST['guestTitle'];
    $guestContent=$_POST['guestContent'];

    $guestDatetime=$_POST['guestDatetime'];
    $guestType=$_POST['guestType'];
    $guestIsPassed=$_POST['guestIsPassed'];
    $guestIP=$_SERVER['REMOTE_ADDR'];
    $user_id=0;
    $sql="update deep_GuestBook set guestName='$guestName',guestFrom='$guestFrom',guestTitle='$guestTitle',guestContent='$guestContent',guestType=$guestType,guestIsPassed=$guestIsPassed,guestFace='$guestFace',guestQQ='$guestQQ',guestMSN='$guestMSN',guestHomePage='$guestHomePage',guestEmail='$guestEmail',guestTel='$guestTel',guestDatetime='$guestDatetime',guestIP='$guestIP',user_id=$user_id where guest_ID=$guest_ID";
    //echo $sql;
    $rsOK=$conn->query($sql);
    if($rsOK>0){
        echo "留言修改成功，才能看到！！<br />";
    }else{
        echo "留言修改失败！！<br />";
    }
    echo ("<p align='center'>3秒自动转到留言管理页</p>");
    ?>
    <meta http-equiv="refresh" content="3;URL=guestBook_Manage.php" />
    <?php
}else{
    $sql="select * from deep_GuestBook where guest_ID=".$_GET['id'];
    $rs=$conn->query($sql);
    while($row=$rs->fetch()){
?>
        <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" value="<?php echo $row['guestName'] ?>" />
                </td>
            </tr>
            <?php
            if($row['guestType']==0 ){
            ?>
            <tr>
                <td class="left">
                    留言头像：
                </td>
                <td class="right"><select name="guestFace" id="guestFace" onchange="selectFace(this.value)">
			<?php
                        for($i=1;$i<=50;$i++){
                        ?>
                        <option value="<?php echo $i ?>" <?php if($row['guestFace']==$i){ ?> selected="selected"<?php } ?> ><?php echo $i ?>.gif</option>
                        <?php
                        }
                        ?>
                 	</select>
                    <div class="span-1" style="position:relative;">
                        <div id="selFace" style="width:100px;height:100px;border:solid 1px #6699FF; background-color:#eee; position:absolute;top:-40px;"  class="push-11 guestFace guestFace-<?php echo $row['guestFace']?>" ></div>
                    </div>
                    <script type="text/javascript">
                        function selectFace(v){
                            oSelFace=document.getElementById('selFace');
                            oSelFace.className="push-11 guestFace guestFace-"+v;
                        }
                </script>
                </td>
            </tr>
            <?php
            }else{
            ?>
                <input type="hidden" name="guestFace" value="<?php echo $row['guestFace'] ?>" />
            <?php
            }
            ?>
            <tr>
                <td class="left">
                    来自：
                </td>
                <td class="right"><input type="text" name="guestFrom" value="<?php echo $row['guestFrom'] ?>" />
                </td>
            </tr>
            <tr>
                <td class="left">
                    QQ：
                </td>
                <td class="right"><input type="text" name="guestQQ" value="<?php echo $row['guestQQ'] ?>" />
                </td>
            </tr>
            <tr>
                <td class="left">
                    msn：
                </td>
                <td class="right"><input type="text" name="guestMSN" size="60" value="<?php echo $row['guestMSN'] ?>" />
                </td>
            </tr>
            <tr>
                <td class="left">
                    主页：
                </td>
                <td class="right"><input type="text" name="guestHomePage" size="60" value="<?php echo $row['guestHomePage'] ?>" />
                </td>
            </tr>
            <tr>
                <td class="left">
                    E-mail：
                </td>
                <td class="right"><input type="text" name="guestEmail" size="60" value="<?php echo $row['guestEmail'] ?>" />
                </td>
            </tr>
            <tr>
                <td class="left">
                    电话：
                </td>
                <td class="right"><input type="text" name="guestTel" value="<?php echo $row['guestTel'] ?>" />
                </td>
            </tr>
            <?php
            if($row['guestType']==0 ){
            ?>
            <tr>
                <td class="left">
                    留言标题：
                </td>
                <td class="right"><input type="text" name="guestTitle" size="60" value="<?php echo $row['guestTitle'] ?>" />
                </td>
            </tr>
            <?php
            }else{
            ?>
                <input type="hidden" name="guestTitle" value="<?php echo $row['guestTitle'] ?>" />
            <?php
            }
            ?>
            <tr>
                <td class="left">
                    留言内容：
                </td>
                <td class="right"><textarea name="guestContent" id="guestContent"><?php echo $row['guestContent'] ?></textarea>
                </td>
            </tr>
            <tr>
                <td class="left">
                    留言时间：
                </td>
                <td class="right"><input type="text" name="guestDatetime" size="60" value="<?php echo $row['guestDatetime'] ?>" />
                </td>
            </tr>
            <tr>
                <td class="left">&nbsp;
                <input type="hidden" name="guestType" value="<?php echo $row['guestType'] ?>" />
                <input type="hidden" name="guestIsPassed" value="<?php echo $row['guestIsPassed'] ?>" />
                </td>
                <td class="right"><input type="submit" value="编辑" /><input type="reset" value="重置" />
                </td>
            </tr>
        </table>
    </form>
<?php
    }
}
?>



        <br />
    </dd>
</dl>
<br />
</body>
</html>
