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

$action=$_GET["action"];

if($action=="testemail"){
    $info=sendmail("发卡宝测试邮件", "如果您收到了此封邮件，说明您的邮箱接口配合正确！", $C_recieve);
    die("{\"msg\":\"$info\",\"recieve\":\"$C_recieve\"}");
}
if($action=="save"){
    $C_pid=t(trim($_POST["C_pid"]));
    $C_pkey=t(trim($_POST["C_pkey"]));
    $C_payurl=t(trim($_POST["C_payurl"]));
    $C_alipay_on=intval($_POST["C_alipay_on"]);
    $C_wxpay_on=intval($_POST["C_wxpay_on"]);
    $C_alipay_appid=t(htmlspecialchars($_POST["C_alipay_appid"]));
    $C_alipay_key=t(htmlspecialchars($_POST["C_alipay_key"]));
    $C_alipay_key2=t(htmlspecialchars($_POST["C_alipay_key2"]));
    $C_wxpay_appid=t(htmlspecialchars($_POST["C_wxpay_appid"]));
    $C_wxpay_appsecret=t(htmlspecialchars($_POST["C_wxpay_appsecret"]));
    $C_wxpay_mchid=t(htmlspecialchars($_POST["C_wxpay_mchid"]));
    $C_wxpay_key=t(htmlspecialchars($_POST["C_wxpay_key"]));
    
    $C_alipayon=intval($_POST["C_alipayon"]);
    $C_wxpayon=intval($_POST["C_wxpayon"]);

    if($C_payurl==""){
        die("请填全信息");
    }else{
        sql("update sl_config set 
        C_payurl='$C_payurl',
        C_pid='$C_pid',
        C_alipay_on='$C_alipay_on',
        C_wxpay_on='$C_wxpay_on',
        C_alipay_appid='$C_alipay_appid',
        C_wxpay_appid='$C_wxpay_appid',
        C_wxpay_mchid='$C_wxpay_mchid',
        C_wxpay_key='$C_wxpay_key',
        C_alipayon=$C_alipayon,
        C_wxpayon=$C_wxpayon");

        if($C_pkey!=""){
          sql("update sl_config set C_pkey='$C_pkey'");
        }
        if($C_alipay_key!=""){
          sql("update sl_config set C_alipay_key='$C_alipay_key'");
        }
        if($C_alipay_key2!=""){
          sql("update sl_config set C_alipay_key2='$C_alipay_key2'");
        }
        if($C_wxpay_appsecret!=""){
          sql("update sl_config set C_wxpay_appsecret='$C_wxpay_appsecret'");
        }
        if($C_wxpay_key!=""){
          sql("update sl_config set C_wxpay_key='$C_wxpay_key'");
        }

        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="shortcut icon" href="../media/<?php echo $C_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">
.qrcode{width:200px;height:200px}
</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 id="form">

          <div class="col-md-6">
            
                <div class="card">
              <div class="card-header"><h4>支付宝官方接口（需营业执照）</h4></div>
              <div class="card-body">
                <div class="row">
                  <div class="form-group row">
                    <label class="col-md-2" for="example-email-input">应用appid</label>
                    <div class="col-md-10">
                      <input class="form-control" type="text" name="C_alipay_appid" value="<?php echo $C_alipay_appid?>">
                    </div>
                  </div>
                  <div class="form-group row">
                    <label class="col-md-2" for="example-email-input">支付宝公钥</label>
                    <div class="col-md-10">
                      <textarea name="C_alipay_key" class="form-control" rows="2" placeholder="已加密保存，留空则不修改"></textarea>
                    </div>
                  </div>
                        
                  <div class="form-group row">
                    <label class="col-md-2" for="example-email-input">应用私钥</label>
                    <div class="col-md-10">
                      <textarea name="C_alipay_key2" class="form-control" rows="3" placeholder="已加密保存，留空则不修改"></textarea>
                    </div>
                  </div>

                  <div class="form-group row">
                    <label class="col-md-2" for="example-email-input">支付开关</label>
                    <div class="col-md-10">
                      <label><input type="checkbox" name="C_alipay_on" value="1" <?php if($C_alipay_on==1){echo "checked='checked'";}?>> 开启支付宝</label>
                    </div>
                  </div>
                  
                  
                  <div class="form-group row">
                    <label class="col-md-2" for="example-email-input"></label>
                    <div class="col-md-10">
                      <div style="font-size: 12px;margin-top: 10px;color: #33cabb">*如果您不知道如何填写，请点击<a href="https://www.7-card.cn/newsinfo.html?id=8" class="btn btn-xs btn-success" target="_blank">帮助文档</a> 提供平台：<a href="https://b.alipay.com" target="_blank">支付宝官网</a></div>
                    </div>
                  </div>
                  
                    </div>
                  </div>

                </div>
</div>
<div class="col-md-6">
                <div class="card">
              <div class="card-header"><h4>微信支付官方接口（需营业执照）</h4></div>
              <div class="card-body">
                <div class="row">
                  <div class="form-group row">
                    <label class="col-md-2" for="example-email-input">微信APP ID</label>
                    <div class="col-md-10">
                      <input class="form-control" type="text" name="C_wxpay_appid" value="<?php echo $C_wxpay_appid?>">
                    </div>
                  </div>
                  <div class="form-group row">
                    <label class="col-md-2" for="example-email-input">微信APP secret</label>
                    <div class="col-md-10">
                      <input class="form-control" type="text" name="C_wxpay_appsecret" value="" placeholder="已加密保存，留空则不修改">
                    </div>
                  </div>
                        
                  <div class="form-group row">
                    <label class="col-md-2" for="example-email-input">微信MCHID</label>
                    <div class="col-md-10">
                      <input class="form-control" type="text" name="C_wxpay_mchid" value="<?php echo $C_wxpay_mchid?>">
                    </div>
                  </div>

                  <div class="form-group row">
                    <label class="col-md-2" for="example-email-input">微信KEY</label>
                    <div class="col-md-10">
                      <input class="form-control" type="text" name="C_wxpay_key" value="" placeholder="已加密保存，留空则不修改">
                    </div>
                  </div>

                  <div class="form-group row">
                    <label class="col-md-2" for="example-email-input">支付开关</label>
                    <div class="col-md-10">
                      <label><input type="checkbox" name="C_wxpay_on" value="1" <?php if($C_wxpay_on==1){echo "checked='checked'";}?>> 开启微信支付</label>
                    </div>
                  </div>
                  
                  
                  <div class="form-group row">
                    <label class="col-md-2" for="example-email-input"></label>
                    <div class="col-md-10">
                      <div style="font-size: 12px;margin-top: 10px;color: #33cabb">*如果您不知道如何填写，请点击<a href="https://www.7-card.cn/newsinfo.html?id=9" class="btn btn-xs btn-success" target="_blank">帮助文档</a> 提供平台：<a href="https://pay.weixin.qq.com" target="_blank">微信支付官网</a></div>
                    </div>
                  </div>
                  
                    </div>
                  </div>

                </div>

                
              </div>

              <div class="col-md-12">

                <div class="card">
              <div class="card-header"><h4>易支付接口（推荐7PAY支付）</h4></div>
              <div class="card-body">
                <div class="row">
                  <div class="form-group row">
                    <label class="col-md-2" for="example-email-input">支付网关</label>
                    <div class="col-md-10">
                      <input class="form-control" type="text" name="C_payurl" value="<?php echo $C_payurl?>">
                    </div>
                  </div>
                  <div class="form-group row">
                    <label class="col-md-2" for="example-email-input">PID</label>
                    <div class="col-md-10">
                      <input class="form-control" type="text" name="C_pid" value="<?php echo $C_pid?>">
                    </div>
                  </div>
                        
                  <div class="form-group row">
                    <label class="col-md-2" for="example-email-input">PKEY</label>
                    <div class="col-md-10">
                      <input class="form-control" type="text" name="C_pkey" value="" placeholder="已加密保存，留空则不修改">
                    </div>
                  </div>

                  <div class="form-group row">
                    <label class="col-md-2" for="example-email-input">支付开关</label>
                    <div class="col-md-10">
                      <label><input type="checkbox" name="C_alipayon" value="1" <?php if($C_alipayon==1){echo "checked='checked'";}?>> 支付宝</label>
                      <label><input type="checkbox" name="C_wxpayon" value="1" <?php if($C_wxpayon==1){echo "checked='checked'";}?>> 微信支付</label>
                    </div>
                  </div>
                  
                  
                  <div class="form-group row">
                    <label class="col-md-2" for="example-email-input"></label>
                    <div class="col-md-10">
                      <div style="font-size: 12px;margin-top: 10px;color: #33cabb">推荐使用<a href="https://7-pay.cn" target="_blank"><u>7PAY支付</u></a>申请收款接口 <a href="https://www.7-card.cn/newsinfo.html?id=1" class="btn btn-xs btn-success" target="_blank">帮助文档</a></div>
                    </div>
                  </div>
                  
                    </div>
                  </div>

                </div>

              </div>

  
                    <div class="col-md-12">
                      <button class="btn btn-primary" type="button" onclick="api_save()">保存</button>
                    </div>
                  </div>
          </div>
          </form>
        </div>
      </div>
    </main>
  </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 src="../js/admin.js"></script>
</body>
</html>