<?php
/*
 * @Team : 孜然云
 * @Author : 孜然
 * @Url : zrv7.com
 * @Date : 2022-1-12 20:25
 * @Project : 孜然授权系统
 * @Description : 基于ZR框架开发的授权系统
 * @Qq : 2937978586
 * @Wx : hhr2937978586 
 * @Email : 2937978586@qq.com
 * @Read me : 孜然授权系统，是一款多模板/多用途/多权限的授权系统
 * @Remind : 孜然授权系统受《劳动知识产权》和《计算机软件著作法》的法律保护，使用破解即违法法律
 * @Dbfk : 如果您已经使用了盗版，孜然可以通过上述两法告你，不过我是不会这么做的，如果是传播盗版那么就必定告上法院
 */
$id=isset($_GET['id'])?$_GET['id']:null;
?>
<?php
if($id=='add'){
$title='添加授权';
require_once 'head.php';
?>
<div class="layui-fluid" id="LAY-component-timeline">
<div class="layui-row layui-col-space15">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-header"><?=$title?></div>
<div class="layui-card-body">
<?php
if($userrow['api_token']==''){
?>
<blockquote class="layui-elem-quote layui-quote-nm">未生成TOKEN，<button type="submit" onclick="change()" class="layui-btn layui-btn-normal layui-btn-xs">点击生成TOKEN</button></blockquote>
<?php
}else{
?>
<div class="layui-form-item">
<label class="layui-form-label">我的TOKEN</label>
<div class="layui-input-block">
<input type="text" name="api_token" autocomplete="off"value="<?=$userrow['api_token']?>" class="layui-input" disabled/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">IP白名单</label>
<div class="layui-input-block">
<textarea name="api_ip" style="height:100px" class="layui-textarea" disabled><?=$userrow['api_ip']?></textarea>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<div class="layui-footer">
<button type="submit" onclick="ghtoken()" class="layui-btn layui-btn-normal layui-btn-xs">更换TOKEN</button>
<button type="submit" onclick="api_ip()" class="layui-btn layui-btn-warm layui-btn-xs">设置白名单</button>
</div>
</div>
</form>
</div>
<?php
}
?>
</div>
</div>
</div>

<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-header">API对接文档</div>
<div class="layui-card-body">
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
<ul class="layui-tab-title">
<li class="layui-this">添加授权</li>
<li>添加代理</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<blockquote class="layui-elem-quote layui-quote-nm">
<br><h3 class="linep">对接接口</h3><br>
对接api：<span class="url" data-clipboard-text="http://<?=$_SERVER['HTTP_HOST']?>/ZR/api/zr_api.php?act=addurl&token=你的TOKEN&qq=需要授权的QQ&url=需要授权的域名&ZRid=程序ID">http://<?=$_SERVER['HTTP_HOST']?>/ZR/api/zr_api.php?act=addurl&token=你的TOKEN&qq=需要授权的QQ&url=需要授权的域名&ZRid=程序ID</span><br><br>
<h3 class="linep">API返回格式</h3><br>
<p>提交方式:GET</p>
<p>GET接口：<span class="url">http://<?=$_SERVER['HTTP_HOST']?>/ZR/api/zr_api.php?act=addurl&token=你的TOKEN&qq=需要授权的QQ&url=需要授权的域名&ZRid=程序ID</span></p>
<p>GET示范：<span class="url">http://<?=$_SERVER['HTTP_HOST']?>/ZR/api/zr_api.php?act=addurl&token=b9f781de4c96e915ae8ba5fd9144f3aa&qq=2937978586&url=<?=$_SERVER['HTTP_HOST']?>&ZRid=1</span></p>
<table class="layui-table">
<colgroup>
<col width="150">
<col width="200">
<col>
</colgroup>
<thead>
<tr>
<th>参数</th>
<th>是否必填</th>
<th>描述</th>
<th>示例</th>
</tr> 
</thead>
<tbody>
<tr>
<td>token</td>
<td>是</td>
<td>用户的对接Token</td>
<td>b9f781de4c96e915ae8ba5fd9144f3aa</td>
</tr>
<tr>
<td>qq</td>
<td>是</td>
<td>需要授权的QQ</td>
<td>2937978586</td>
</tr>
<tr>
<td>url</td>
<td>是</td>
<td>需要授权的域名</td>
<td><?=$_SERVER['HTTP_HOST']?></td>
</tr>
<tr>
<td>程序ID</td>
<td>是</td>
<td>对接的多程序ID</td>
<td>1</td>
</tr>
</tbody>
</table>
<br><h3 class="linep">注意事项</h3><br>
对接前，请先添加服务器IP到白名单，否则无法成功对接！
</blockquote>
</div>
<div class="layui-tab-item">
<blockquote class="layui-elem-quote layui-quote-nm">
<br><h3 class="linep">对接接口</h3><br>
对接api：<span class="url" data-clipboard-text="http://<?=$_SERVER['HTTP_HOST']?>/ZR/api/zr_api.php?act=adduser&token=你的TOKEN&qq=需要添加的代理QQ&user=需要添加的代理账号&pwd=需要添加的代理密码&email=所属的邮箱&power=需要添加的代理类型&ZRid=对接的程序ID">http://<?=$_SERVER['HTTP_HOST']?>/ZR/api/zr_api.php?act=adduser&token=你的TOKEN&qq=需要添加的代理QQ&user=需要添加的代理账号&pwd=需要添加的代理密码&email=所属的邮箱&power=需要添加的代理类型&ZRid=程序ID</span>
<br><br><h3 class="linep">API返回格式</h3><br>
<p>提交方式:GET</p>
<p>GET接口：<span class="url">http://<?=$_SERVER['HTTP_HOST']?>/ZR/api/zr_api.php?act=adduser&token=你的TOKEN&qq=需要添加的代理QQ&user=需要添加的代理账号&pwd=需要添加的代理密码&email=所属的邮箱&power=需要添加的代理类型&ZRid=程序ID</span></p>
<p>GET示范：<span class="url">http://<?=$_SERVER['HTTP_HOST']?>/ZR/api/zr_api.php?act=adduser&token=b9f781de4c96e915ae8ba5fd9144f3aa&qq=2937978586&user=2937978586&pwd=123456&email=2937978586@qq.com&power=1&ZRid=1</span></p>
<table class="layui-table">
<colgroup>
<col width="150">
<col width="200">
<col>
</colgroup>
<thead>
<tr>
<th>参数</th>
<th>是否必填</th>
<th>描述</th>
<th>示例</th>
</tr> 
</thead>
<tbody>
<tr>
<td>token</td>
<td>是</td>
<td>用户的对接Token</td>
<td>b9f781de4c96e915ae8ba5fd9144f3aa</td>
</tr>
<tr>
<td>qq</td>
<td>是</td>
<td>需要添加的代理QQ</td>
<td>2937978586</td>
</tr>
<tr>
<td>user</td>
<td>是</td>
<td>需要添加的代理账号</td>
<td>2937978586</td>
</tr>
<tr>
<td>pwd</td>
<td>是</td>
<td>需要添加的代理密码</td>
<td>123456</td>
</tr>
<tr>
<td>email</td>
<td>是</td>
<td>注册的邮箱</td>
<td>2937978586@qq.com</td>
</tr>
<tr>
<td>power</td>
<td>是</td>
<td>需要添加的代理类型</td>
<td>1为代理商,2为授权商,3为合作商</td>
</tr>
<tr>
<td>程序ID</td>
<td>是</td>
<td>对接的多程序ID</td>
<td>1</td>
</tr>
</tbody>
</table>
<br><h3 class="linep">注意事项</h3><br>
对接前，请先添加服务器IP到白名单，否则无法成功对接！
</blockquote>

</div>


</div>
</div>

<script src="https://cdn.bootcss.com/clipboard.js/2.0.4/clipboard.js"></script>
<script>
var clipboard = new ClipboardJS('.url');
clipboard.on('success', function(e) {
layer.msg('复制成功!');
});
clipboard.on('error', function(e) {
layer.msg('复制成功!');
});
</script>
<script>
function change() {
var ii = layer.load(3, {shade:[0.1,'#fff']});
$.ajax({
type: "GET",
url: "ajax.php?act=change_token",
dataType: "json",
success: function(data) {
layer.close(ii);
if (data.code == 0) {
 layer.msg(data.msg);
 setTimeout(function(){
 window.location.reload();
},1000)
} else {
layer.alert(data.msg);
}
}
});
};
function ghtoken() {
layer.confirm('更换后则之前的TOKEN将失效！<br>确认更换？', {icon: 3, title:'提示'}, function(index){
var ii = layer.load(3, {shade:[0.1,'#fff']});
$.ajax({
type: "GET",
url: "ajax.php?act=change_token",
dataType: "json",
success: function(data) {
layer.close(ii);
if (data.code == 0) {
 layer.msg(data.msg);
 setTimeout(function(){
 window.location.reload();
},1000)
} else {
layer.alert(data.msg);
}
}
});
layer.close(index);
});
};
function api_ip() {
var ii = layer.load(3, {shade:[0.1,'#fff']});
$.ajax({
type: "GET",
url: "ajax.php?act=change_ip",
dataType: "json",
success: function(data) {
layer.close(ii);
 
 if(data.code == 0){
layer.open({
type: 1,
title: '白名单设置',
skin: 'layui-layer-rim',
maxmin: true,
content: data.data

});
}else{
layer.alert(data.msg);
}
}
});
};
function api_ip_n() {
var api_ip=$("#api_ip").val();

var ii = layer.load(3, {shade:[0.1,'#fff']});
$.ajax({
type : "POST",
url : "ajax.php?act=change_ip_n",
data : {api_ip:api_ip},
dataType : 'json',
success : function(data) {
layer.close(ii);
if(data.code == 0){
layer.msg('设置白名单成功！');
setTimeout(function () {
location.href="";
}, 400);
}else{
layer.alert(data.msg);
}


} 
});

}
</script>
<script type="text/javascript">
layui.use(['form', 'element', 'jquery', 'admin', 'laydate', 'notice'], function () {
var form = layui.form;
var $ = layui.jquery;
var laydate = layui.laydate;
var admin = layui.admin;
var notice = layui.notice;
laydate.render({
elem: '#updatetime'
});
$('#mailtest').click(function () {
var ii = notice.msg('正在执行中..', {icon: 4, close: true});
$.ajax({
type: "GET",
url: "ajax.php?act=mailtest",
dataType: "json",
success: function(data) {
notice.destroy();
if (data.code == 0) {
notice.msg(data.msg, {icon: 1});
} else {
notice.msg(data.msg, {icon: 2});
}
}
});
});
form.on('select(mail_cloud)', function(data){ 
if(data.value == '0'){
$("#frame_set1").show(500);
$("#frame_set2").hide(500);
}else{
$("#frame_set1").hide(500);
$("#frame_set2").show(500);
}
});
form.on('submit(noticeBtn)', function (data) {
var ii = layer.load(2, {shade:[0.1,'#fff']});
notice.destroy();
$.post('ajax.php?act=set', data.field, function (data) {
layer.close(ii);
notice.destroy();
admin.btnLoading('[lay-filter="noticeBtn"]', false);
if(data.code == 0){
notice.msg('设置保存成功！', {animateInside: true, icon: 1});
} else {
notice.msg(data.msg, {animateInside: true, icon: 2});
}
});
return false;
});
});
</script>
<?php
}else{
$title='孜然';
require_once 'head.php';
if (isset($_GET['kw'])) {
$kw = daddslashes($_GET['kw']);
$sql = " url like '%" . $kw . "%' or qq like '%" . $kw. "%'";
$numrows = $DB->count("SELECT count(*) from zrauth_url WHERE{$sql}");
$con = "包含 <b>" . $kw . "</b> 共有 <b>" . $numrows . "</b> 域名";
$link = "&kw=" . $kw;
} else {
$sql = " 1";
$numrows = $DB->count("SELECT count(*) from zrauth_url");
$con = "共有 <b>" . $numrows . "</b> 个域名";
}
$pagesize=50;
$pages=intval($numrows/$pagesize);
if ($numrows%$pagesize) {
$pages++;
}
if (isset($_GET['page'])) {
$page=intval($_GET['page']);
} else {
$page=1;
}
$offset=$pagesize*($page - 1);
?>
1.5版本更新
<?php } ?>