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

if (!empty($_POST)){
    
	$scuserid = $_SESSION["a_uid"];
    if (check_permission($scuserid,'version.php',2)){

		$id = intval($_POST["id"]);
	    $ym = flc_request(trim($_POST["ym"]));
	    $sn = flc_request(trim($_POST["sn"]));
	   
	    $sql="update {$tablepre}siteconfig set ym='".$ym."',sn='".$sn."' 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;
}

$sql="select * from {$tablepre}siteconfig order by id desc limit 1"; 
$myrow = $db->get_row($sql);
if (!empty($myrow)){
    $id=$myrow["id"];
    $ym=$myrow["ym"];
    $sn=$myrow["sn"];
}
?>
<!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="ym">网站域名</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" id="ym" name="ym" value="<?php echo $ym;?>">
                    </div>
                  </div>

				  <div class="form-group">
                    <label class="col-xs-12" for="sn">系统授权码</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" id="sn" name="sn" value="<?php echo $sn;?>">
                    </div>
                  </div>
				  <br>
                  
                  <div class="form-group">
                    <div class="col-xs-12">
					  <input type="hidden" name="id" id="id" value="<?php echo $id;?>">
					  <button class="btn btn-primary" type="button" id="submit">系统授权</button>
                    </div>
                  </div>
                </form>
				<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><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="../js/bootstrap-notify.min.js"></script>
<script src="../js/tips.js"></script>
<script>
$("#submit").click(function(){

    var ym = $("#ym").val();
	var sn = $("#sn").val();

	if (ym==''){
		tips.notify('请输入网站域名', 'warning', 200);
		return false;
	}
    
	if (sn==''){
		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>