<?php
include_once("htui_header.php");

if (!empty($_POST)){
    
	$scuserid = $_SESSION["a_uid"];
    if (check_permission($scuserid,'content.php?a=agreement',2) || check_permission($scuserid,'content.php?a=copyright',2)){

		$id=intval($_POST["id"]);
		$zd = flc_request(trim($_POST["a"]));
		$nl = flc_request(trim($_POST["nl"]));

		$sql="update {$tablepre}content set ".$zd."='".$nl."' where id=".$id; 
		$db->exec($sql);
		$response_arr = array("status" => 1,"message"  => '操作成功');

	}else{
        $response_arr = array("status" => -1,"message"  => '对不起,您无权限操作!');
	}

    echo json_encode($response_arr);
    exit;
}

$field = flc_request($_GET['a']);
$sql="select * from {$tablepre}content order by id desc limit 1"; 
$myrow = $db->get_row($sql);
if (!empty($myrow)){
   $id=$myrow["id"];
   $nl=$myrow[$field];
}
?>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>后台管理中心_飞天素材网</title>
<meta name="author" content="ftsucai.com">
<link href="../css/bootstrap.min.css" rel="stylesheet">
<link href="../css/fonts.css" rel="stylesheet">
<link href="../css/htstyle.css" rel="stylesheet">
<link href="../js/bootstrap-datepicker/bootstrap-datepicker3.min.css" rel="stylesheet">
<link href="../js/bootstrap-colorpicker/css/bootstrap-colorpicker.min.css" rel="stylesheet">
</head>
  
<body>

    <!--页面主要内容-->
    <main class="ftdms-layout-content">
      
      <div class="container-fluid" style="margin-bottom:90px;">
        
        <div class="row" style="margin-top:15px;">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-header"><h4>修改模板内容</h4></div>
              <div class="card-body" style="padding:5px 20px;">
                
                <form class="form-horizontal" action="" method="post" id="form">

				  <div class="form-group">
                    <!--<label class="col-xs-12" for="nl">修改模板内容</label>-->
                    <div class="col-xs-12">
					  <textarea id="nl" name="nl" class="xheditor-simple" rows="25" cols="80" style="width: 100%"><?php echo $nl;?></textarea>
                    </div>
                  </div>
                  
                  <div class="form-group">
                    <div class="col-xs-12">
					  <input type="hidden" name="id" id="id" value="<?php echo $id;?>">
					  <input type="hidden" name="a" id="a" value="<?php echo $field;?>">
					  <button class="btn btn-primary" type="button" id="submit">确认修改</button>
                    </div>
                  </div>
                </form>
				<br>
                
              </div>
            </div>
          </div>
          
        </div>
        
      </div>
      
    </main>
    <!--End 页面主要内容-->
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.js"></script>
<script src="../js/perfect-scrollbar.min.js"></script>
<script src="../js/main.min.js"></script>
<script src="../xheditor/xheditor-1.2.2.min.js"></script>
<script src="../xheditor/zh-cn.js"></script>
<script src="../js/bootstrap-notify.min.js"></script>
<script src="../js/tips.js"></script>
<script>
$("#submit").click(function(){

    var nl = $("#nl").val();
	if (nl==''){
		tips.notify('请输入模板内容', 'warning', 200);
		return false;
	}

    $.post("version.php", $("#form").serialize(), function(data) {
		var rs  = eval('('+data+')');
        if(rs.status==1){
           tips.notify(rs.message, 'success', 200, 'ftsucai-name', 'top', 'center');
		}else{
		   tips.notify(rs.message, 'danger', 200);
		}
    });
	
});
</script>
</body>
</html>