<?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')));
    }
    if(is_mobile()){
        //这是一个手机浏览器,可以跳转到手机版网页
        if(file_exists(__DIR__."/views/".$configs['views']."/m_enbody.php")) {
          include_once(__DIR__."/views/".$configs['views']."/m_enbody.php");//手机端模板为m_ 开头的  如果存在就显示 H5网页 
          die(); 
        }
         
      } 
    include_once(__DIR__."/views/".$configs['views']."/enbody.php");

?> 