<?php
include_once("global.php");
 // print_r($_SESSION);

    $msg = getMsgBook();

    if ($_POST['act'] == 'submit') {
        if ($_POST['content'] == '') {
            die(json_encode(array("code" => '1', "msg" => '内容不能为空')));
        }
        if ($_POST['scode'] == '') {
            die(json_encode(array("code" => '1', "msg" => '验证码不能为空')));
        }
        if ($_POST['scode'] != $_SESSION['check_checks']) {
            die(json_encode(array("code" => '1', "msg" => '验证码不正确')));
        }
        if ($configs['md5str'] != '') {
            if ($_POST['md5str'] != md5($_POST['time'] . $configs['md5str'])) {
            die(json_encode(array("code" => '1', "msg" => '二次验证不正确')));
            }
        }
        if ((time() - 300) > $_POST['time']) {
            die(json_encode(array("code" => '1', "msg" => '页面提交时间过长，请刷新再试')));
        }
        $sql = "INSERT INTO guestbook(info,create_time,ip)VALUES('" . $_POST['content'] . "','" . date("Y-m-d H:i:s") . "' ,'" . $_SERVER["REMOTE_ADDR"] . "' )";
        mysqli_query($link, $sql);
        die(json_encode(array("code" => '0', "msg" => 'ok')));
    }
?><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title><?=$configs['site_title']?>收录留言</title>
<meta name="renderer" content="webkit">
    <link rel="stylesheet" href="./css/bootstrap.min.css">
        <meta name="description" content="<?= $configs['index_desc'] ?>,收录提交">
            <meta name="keywords" content="<?= $configs['index_Keyword'] ?>,留言本">
                <link rel="shortcut icon" href="http://sezhan.pw/favicon.ico" tppabs="/favicon.ico">
<link rel="stylesheet" href="./css/layui.css" media="all">
    <link rel="stylesheet" href="./css/style1.css" media="all">
        <style>
            .re{border: solid 1px #ccc;padding: 15px;margin-top: 20px;}
        </style>
        <link rel="stylesheet" href="./css/style.css" media="all">

        <script src="./js/jquery.min.js"></script>
        <script>

           $(function ()  {
              $("#spost").click(function () {
                 if($("#content").val() =='') {
                     layer.alert('内容不能为空',{offset: '100px',title:'提交出错' });
                     return false;
                 }
                 if($("#scode").val() =='') {
                      layer.alert('验证码不能为空',{offset: '100px',title:'提交出错' });
                     return false;
                 }
                $.post("enbody.php", { "act": "submit",'content': $("#content").val(),'scode':$("#scode").val() ,'time':$("#time").val() ,'md5str':$("#md5str").val()},
                    function(data){
                        if(data.code =='0') {
                            layer.alert('提交成功');
                            location.reload();
                        } else {
                            layer.alert(data.msg,{offset: '100px',title:'提交出错' });
                        }
                    }, "json");
                 });
            });
        </script>
        <script src="./js/layer/layer.js"></script>
        </head>
<body class="" style="">
<header class="layui-bg-black">
  <nav class="layui-container">
      <div class="logo"> <a href="<?= $configs['site_url'] ?>"><?= $configs['site_title'] ?></a> </div>
      <ul class="layui-nav layui-layout-left header-menu">
          <span class="introduce"> <?= $configs['site_title'] ?> <?= $configs['site_subtitle'] ?> 
          </span>
    <span class="layui-nav-bar"></span></ul>
    <ul class="layui-nav layui-layout-right">
        <li class="layui-nav-item"><a href="<?= $configs['site_url'] ?>">首页</a></li>
        <li class="layui-nav-item layui-this"><a href="#">收录</a></li>
        <span class="layui-nav-bar" style="left: 88px; top: 55px; width: 0px; opacity: 0;"></span></ul>
  </nav>
</header>
<div class="main layui-container">
  <div class="layui-row layui-col-space10">
    <div class="layui-col-md12 layui-mt10">
      <div class="layui-card margin-bottom-0">
        <div class="layui-card-header">
          <h2>收录留言</h2>
          <span class="layui-hide-xs">本站收录规则请仔细阅读，请按照提示留言，感谢您的配合</span></div>
        <div class="index-links-content layui-pd10">
          <div class="content">
              </div><table class="layui-table layui-mt0" lay-even="" lay-skin="nob">
            <tbody>
            </tbody></table><table class="layui-table layui-mt0" lay-even="" lay-skin="nob" style="border-collapse: collapse; border-spacing: 0px; margin: 0px; width: 1120px; color: rgb(102, 102, 102); font-family: &quot;Microsoft YaHei&quot;, &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, sans-serif; font-size: 14px;">
                <thead>
                  <tr style="transition: all 0.3s; background-color: rgb(242, 242, 242);">
                    <th style="margin: 0px; padding: 9px 15px; font-weight: 400; border: none; position: relative; min-height: 20px; line-height: 20px; text-align: left;">1、必须将本站放置前五位，前三优先收录，其他位置一律不收录也不用申请，新站、站群一律不收录！</th>
                  </tr>
                </thead>
                <tbody>
                  <tr style="transition: all 0.3s;">
                    <td style="margin: 0px; padding: 9px 15px; border: none; position: relative; min-height: 20px; line-height: 20px;">2、网站地址更新的，请及时提交，3日无法访问的，将清理。</td>
                  </tr>
                  <tr style="transition: all 0.3s; background-color: rgb(242, 242, 242);">
                    <td style="margin: 0px; padding: 9px 15px; border: none; position: relative; min-height: 20px; line-height: 20px;">3、本站会不定期根据来路排名调整网站位置，来路越多排名越靠前！</td>
                  </tr>
                  <tr style="transition: all 0.3s;">
                    <td style="margin: 0px; padding: 9px 15px; border: none; position: relative; min-height: 20px; line-height: 20px;">4、不收录任何钓.鱼、大量弹窗、满屏广告影响正常浏览的网站以及需下载播放器才能播放的视频站。</td>
                  </tr>
                  <tr style="transition: all 0.3s; background-color: rgb(242, 242, 242);">
                      <td style="margin: 0px; padding: 9px 15px; border: none; position: relative; min-height: 20px; line-height: 20px;">5、本站名称：<?= $configs['site_title'] ?>  本站网址：<?= $configs['site_url'] ?> 其他地址不收录！</td>
                  </tr>
                </tbody>
              </table>
              <br>
                  <?php if ($configs['Contact_email'] != '') { ?>  <span style="color:#FF0000;">联系邮箱：<?php echo $configs['Contact_email']; ?></span> <?php } ?></div>


<form id="myform" class="form">
<div class="form-group">
    <textarea class="form-control" rows="5" id="content"  name='content' placeholder="留言内容" maxlength="200"></textarea>
    <input type="hidden" id="time" class="form-control"  name='time' value="<?php echo time(); ?>">
        <?php if ($configs['md5str'] != '') { ?>
                        <input type="hidden" id="md5str" class="form-control"  name='md5str' value="<?php echo md5(time() . $configs['md5str']); ?>">
                <?php } ?>
</div>
<div class="form-group">
<input type="text" id="scode" class="form-control" placeholder="验证码">
</div>
<div class="form-group">
    <img src="./scode.php" alt="点击刷新" title="点击刷新" id="scode_img" style="vertical-align:middle;cursor:pointer;">
</div>
    <div class="form-group">
                <?php if ($configs['guestbook_switch'] == '1') { ?>
        <button type="button" id="spost"  name='spost' class="btn btn-success btn-block"  >发布留言</button>
            <?php } else { ?>
        <button type="button" class="btn btn-fail btn-block">留言关闭中</button>
            <?php } ?>
    </div>
</form>
<div id="top"></div>
<div id="list">

        <?php if ($msg) { ?>
            <?php foreach ($msg as $k => $v): ?>
                <div class="card mb-3">
                                            <div class="card-header bg-info text-white"><?php echo $v['create_time']; ?> </div>
                                                                    <div class="card-body">

                                                                                    <?php echo nl2br($v['info']); ?>
                                                                                    <?php if ($v['re_msg'] != '') { ?>     <div class='re'>站长回复:  <?php echo nl2br($v['re_msg']); ?> </div> <?php } ?>
                                                                                </div>

                            </div>     　 　
            <?php endforeach; ?>
        <?php } ?>


    <nav aria-label="Page navigation ">
  <ul class="pagination" id="pager">
        <li class="page-item">
            <a href="enbody.php?page=" class="page-link" id="next">下一页</a>
        </li>
      </ul>
</nav></div>
<footer class="mb-5">© <?= $configs['site_title'] ?> 2020-2021 <a href="index.php">返回导航</a></footer>
      </div>

</div>
</div>





</div></body></html>