<?php
require '../conn/conn.php';
require '../conn/function.php';
require 'admin_check.php';

$action=$_GET["action"];
if($action=="save"){

  $C_title=$_POST["C_title"];
  $C_pwd=$_POST["C_pwd"];

  if($C_title==""){
    die("请填全信息");
  }else{
    mysqli_query($conn,admin("config",$_POST));
    mysqli_query($conn,"update sl_config set C_vipprice=".round($_POST["C_vipprice"],2).",C_regon=".intval($_POST["C_regon"]).",C_indexon=".intval($_POST["C_indexon"]).",C_creatprice=".round($_POST["C_creatprice"],2));
    if($C_pwd!=""){
      mysqli_query($conn,"update sl_config set C_pwd='".md5($C_pwd)."'");
    }
    die("success");
  }
}
?>
<!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>
<link rel="icon" href="../media/<?php echo $C_ico?>" type="image/ico">
<link href="../css/bootstrap.min.css" rel="stylesheet">
<link href="../css/materialdesignicons.min.css" rel="stylesheet">
<link href="../css/style.min.css" rel="stylesheet">
<script type="text/javascript" src="../upload/upload.js"></script>
<style type="text/css">
.showpic{height: 60px;border: solid 1px #DDDDDD;padding: 5px;}
</style>
</head>
  
<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
  <?php require 'nav.php';?>
    <main class="lyear-layout-content">
      
      <div class="container-fluid">
        
        <div class="row">
          <form class="form-horizontal" id="form">
          <div class="col-md-6">
            <div class="card">
              <div class="card-header"><h4>基本设置</h4></div>
              <div class="card-body">
                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">网站标题</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" name="C_title" value="<?php echo $C_title?>">
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">网站关键词</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" name="C_keyword" value="<?php echo $C_keyword?>">
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">网站描述</label>
                    <div class="col-xs-12">
                      <textarea class="form-control" name="C_description"><?php echo $C_description?></textarea>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">网站logo</label>
                    <div class="col-xs-12">
                      <div class="row">
                      <div class="col-xs-3">
                      <img src="../media/<?php echo $C_logo?>" id="C_logox" class="showpic" onClick="showUpload('C_logo','C_logo','../media',1,null,'','');">
                    </div>
                    <div class="col-xs-9">
                            <div class="input-group">
                              <input type="text" id="C_logo" name="C_logo" class="form-control" value="<?php echo $C_logo?>">
                              <span class="input-group-btn">
                                      <button class="btn btn-primary m-b-5 m-t-5" type="button" onClick="showUpload('C_logo','C_logo','../media',1,null,'','');">上传</button>
                              </span>
                      </div>
                    </div>
                  </div>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">网站ico图标</label>
                    <div class="col-xs-12">
                      <div class="row">
                      <div class="col-xs-3">
                      <img src="../media/<?php echo $C_ico?>" id="C_icox" class="showpic" onClick="showUpload('C_ico','C_ico','../media',1,null,'','');">
                    </div>
                     <div class="col-xs-9">
                            <div class="input-group">
                              <input type="text" id="C_ico" name="C_ico" class="form-control" value="<?php echo $C_ico?>">
                              <span class="input-group-btn">
                                      <button class="btn btn-primary m-b-5 m-t-5" type="button" onClick="showUpload('C_ico','C_ico','../media',1,null,'','');">上传</button>
                              </span>
                      </div>
                    </div>
                    </div>
                  </div>
                  </div>

                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">微信公众号</label>
                    <div class="col-xs-12">
                      <div class="row">
                      <div class="col-xs-3">
                      <img src="../media/<?php echo $C_qrcode?>" id="C_qrcodex" class="showpic" onClick="showUpload('C_qrcode','C_qrcode','../media',1,null,'','');">
                    </div>
                    <div class="col-xs-9">
                            <div class="input-group">
                              <input type="text" id="C_qrcode" name="C_qrcode" class="form-control" value="<?php echo $C_qrcode?>">
                              <span class="input-group-btn">
                                      <button class="btn btn-primary m-b-5 m-t-5" type="button" onClick="showUpload('C_qrcode','C_qrcode','../media',1,null,'','');">上传</button>
                              </span>
                      </div>
                    </div>
                  </div>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">备案号</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" name="C_beian" value="<?php echo $C_beian?>" placeholder="可留空">
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">版权文字</label>
                    <div class="col-xs-12">
                      <textarea class="form-control" name="C_copyright"><?php echo $C_copyright?></textarea>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">统计代码</label>
                    <div class="col-xs-12">
                      <textarea class="form-control" name="C_code"><?php echo $C_code?></textarea>
                    </div>
                  </div>
              </div>
            </div>


            <div class="card">
              <div class="card-header"><h4>登录/注册设置</h4></div>
              <div class="card-body">
				<div class="form-group">
                    <label class="col-xs-12" for="example-email-input">注册会员</label>
                    <div class="col-xs-12">
                      <label><input type="radio" name="C_regon" value="1" <?php if($C_regon==1){echo "checked='checked'";}?>> 开启</label>
                      <label><input type="radio" name="C_regon" value="0" <?php if($C_regon==0){echo "checked='checked'";}?>> 关闭</label>
                    </div>
                  </div>
                <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">展示首页</label>
                    <div class="col-xs-12">
                      <label><input type="radio" name="C_indexon" value="1" <?php if($C_indexon==1){echo "checked='checked'";}?>> 开启</label>
                      <label><input type="radio" name="C_indexon" value="0" <?php if($C_indexon==0){echo "checked='checked'";}?>> 关闭</label>
                    </div>
                  </div>

              </div>
            </div>



            <button type="button" onClick="save()" class="btn btn-primary">保存</button>
            
          </div>

          <div class="col-md-6">
            <div class="card">
              <div class="card-header"><h4>价格设置</h4></div>
              <div class="card-body">
				<div class="form-group">
                    <label class="col-xs-12" for="example-email-input">生成短网址</label>
                    <div class="col-xs-12">
                      <div class="input-group">
                          <input class="form-control" type="text" name="C_creatprice" value="<?php echo $C_creatprice?>">
                          <span class="input-group-addon">元/个</span>
                      </div>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">临时短网址升级永久</label>
                    <div class="col-xs-12">
                      <div class="input-group">
                          <input class="form-control" type="text" name="C_urlprice" value="<?php echo $C_urlprice?>">
                          <span class="input-group-addon">元/个</span>
                      </div>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">临时短网址有效期</label>
                    <div class="col-xs-12">
                      <div class="input-group">
                          <input class="form-control" type="text" name="C_day" value="<?php echo $C_day?>">
                          <span class="input-group-addon">天</span>
                      </div>
                      <div style="font-size: 12px;margin-top: 10px;color: #33cabb">*填0则永久有效</div>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">VIP会员价格</label>
                    <div class="col-xs-12">
                      <div class="input-group">
                          <input class="form-control" type="text" name="C_vipprice" value="<?php echo $C_vipprice?>">
                          <span class="input-group-addon">元</span>
                      </div>
                      <div style="font-size: 12px;margin-top: 10px;color: #33cabb">*VIP会员可免费升级短链，填0则不开启该功能</div>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">防滥用时间限制</label>
                    <div class="col-xs-12">
                      <div class="input-group">
                          <input class="form-control" type="text" name="C_limit" value="<?php echo $C_limit?>">
                          <span class="input-group-addon">秒</span>
                          <input class="form-control" type="text" name="C_limit2" value="<?php echo $C_limit2?>">
                          <span class="input-group-addon">次</span>
                      </div>
                      <div style="font-size: 12px;margin-top: 10px;color: #33cabb">*填0秒则不开启时间限制</div>
                    </div>
                  </div>
              </div>
            </div>

            <div class="card">
              <div class="card-header"><h4>客服设置</h4></div>
              <div class="card-body">
                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">QQ客服</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" name="C_qq" value="<?php echo $C_qq?>">
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">微信客服</label>
                    <div class="col-xs-12">
                      <div class="row">
                      <div class="col-xs-3">
                      <img src="../media/<?php echo $C_wx?>" id="C_wxx" class="showpic" onClick="showUpload('C_wx','C_wx','../media',1,null,'','');">
                    </div>
                    <div class="col-xs-9">
                            <div class="input-group">
                              <input type="text" id="C_wx" name="C_wx" class="form-control" value="<?php echo $C_wx?>">
                              <span class="input-group-btn">
                                      <button class="btn btn-primary m-b-5 m-t-5" type="button" onClick="showUpload('C_wx','C_wx','../media',1,null,'','');">上传</button>
                              </span>
                      </div>
                    </div>
                  </div>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">联系电话</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" name="C_mobile" value="<?php echo $C_mobile?>">
                    </div>
                  </div>
              </div>
            </div>


            <div class="card">
              <div class="card-header"><h4>管理员设置</h4></div>
              <div class="card-body">
                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">管理员帐号</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" name="C_admin" value="<?php echo $C_admin?>">
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">管理员密码</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" name="C_pwd" placeholder="已加密保存，留空则不修改">
                    </div>
                  </div>
              </div>
            </div>
            
          </div>

        </form>
          

        </div>
        
      </div>
      
    </main>
    <!--End 页面主要内容-->
  </div>
</div>

<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="../js/main.min.js"></script>

<script src="../js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="../js/lightyear.js"></script>
<script src="../js/jqPaginator.min.js" type="text/javascript"></script>
<script src="../js/help.js" type="text/javascript"></script>
<script src="../js/jconfirm/jquery-confirm.min.js"></script>

<script type="text/javascript">
    function save(){
      lightyear.loading('show');
        $.ajax({
                url:'?action=save',
                type:'post',
                data:$("#form").serialize(),
                success:function (data) {
                lightyear.loading('hide');
                if(data=="success"){
                  lightyear.notify("保存成功", 'success', 100);
                }else{
                  lightyear.notify(data, 'danger', 100);
                }
                }
              });
      }

  var path=window.location.pathname;
  $("a").each(function(){
    if(path.indexOf($(this).attr("href"))!=-1){
      console.log($(this).attr("href"));
      $(this).parent("li").addClass("active");
      $(this).parent("li").parent("ul").parent("li").addClass("open active");
    }
  });
</script>
</body>
</html>