<?php 
	include './head.php';
  if(file_get_contents(siteHttp().'/'.rootPath().'/sitemap.xml')){
    $isSitemap = siteHttp().'/'.rootPath().'/sitemap.xml';
    $isSitemapBtn = '更新sitemap文件';
  }else{
    $isSitemap = '您还没生成';
    $isSitemapBtn = 'sitemap文件';
  }
?>
<div class="layui-row layui-col-space15">
        <div class="layui-col-md8 layui-col-md-offset2">
            <div class="layui-card" style="border-radius: 20px;">
              <div class="layui-card-header">
                <h3 style="padding-top: 3px;color: hsl(230,10%,40%);"><b>推送配置</b></h3>
              </div>
              <div class="layui-card-body">
                <div class="layui-form layui-form-pane">
                  <div class="layui-form-item">
                    <label class="layui-form-label">百度接口</label>
                    <div class="layui-input-block">
                      <input type="text" name="baiduApi" autocomplete="off" value="<?php echo conf('baiduApi')?>" placeholder="比如：http://data.zz.baidu.com/urls?site=url&token=token" class="layui-input">
                    </div>
                  </div>
                  <center><button class="layui-btn" lay-submit="" lay-filter="configEdit">确定保存</button></center>
                  <br><br>
                  <div class="layui-form-item">
                    <label class="layui-form-label">sitemap</label>
                    <div class="layui-input-block">
                       <input type="text" disabled value="<?php echo $isSitemap;?>"  class="layui-input">
                    </div>
                  </div>
                  <center><button class="layui-btn layui-btn-danger" lay-submit="" lay-filter="isSitemap"><?php echo $isSitemapBtn; ?></button></center>
          </div>
    </div>
<script src="../public/static/layuiadmin/layui/layui.all.js"></script>
  <script>
  layui.config({
      base: '../public/static/layuiadmin/' //静态资源所在路径
    }).extend({
      index: 'lib/index' //主入口模块
    }).use(['index','form','table'], function(){
      var $ = layui.$
      ,table = layui.table
      ,layedit = layui.layedit
      ,laydate = layui.laydate
      ,form = layui.form
      ,admin = layui.admin
      ,element = layui.element
      ,layer = layui.layer;
      element.render();

       form.on('submit(configEdit)', function(data){
          baiduApi = data.field.baiduApi;
          var load = layer.load({time:false});
          $.ajax({
                url: "./ajax.php?act=configEdit",
                data: {baiduApi},
                type: "POST",
                dataType: "json",
                success: function(data){
                    layer.close(load);
                    if(data.code==1){
                      layer.msg(data.msg,{icon:6});
                    }else{
                      layer.msg(data.msg,{icon:5});
                    }
                },
                error: function(data){
                    layer.close(load);
                    layer.msg("未知错误");
                }
            });
        });

       form.on('submit(isSitemap)', function(data){
          var load = layer.load({time:false});
          $.ajax({
                url: "./ajax.php?act=sitemap",
                type: "POST",
                dataType: "json",
                success: function(data){
                    layer.close(load);
                    if(data.code==1){
                      layer.msg(data.msg,{icon:6});
                    }else{
                      layer.msg(data.msg,{icon:5});
                    }
                },
                error: function(data){
                    layer.close(load);
                    layer.msg("未知错误");
                }
            });
        });
  });
  </script>
<?php 
	include 'foot.php';
?>