<?php
/*
 * @Team : 孜然云
 * @Author : 孜然
 * @Url : zrv7.com
 * @Date : 2022-1-11 2:27
 * @Project : 孜然授权系统
 * @Description : 基于ZR框架开发的授权系统
 * @Qq : 2937978586
 * @Wx : hhr2937978586 
 * @Email : 2937978586@qq.com
 * @Read me : 孜然授权系统，是一款多模板/多用途/多权限的授权系统
 * @Remind : 孜然授权系统受《劳动知识产权》和《计算机软件著作法》的法律保护，使用破解即违法法律
 * @Dbfk : 如果您已经使用了盗版，孜然可以通过上述两法告你，不过我是不会这么做的，如果是传播盗版那么就必定告上法院
 */
//写法借鉴SF授权系统3.0
require_once 'head.php';
?>
<link rel="stylesheet" type="text/css" href="../assets/chat/css/hui.css" />
<link type="text/css" href="../assets/chat/css/zr.css" rel="stylesheet" />
<link href="../assets/chat/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link rel="stylesheet" href="../assets/chat/css/reset.css">
<script src="../chat/js/jquery.min.js"></script>
<script type="text/javascript" src="../assets/chat/js/jquery.qqFace.js"></script>
<script type="text/javascript" src="../assets/chat/js/hui.js"></script>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body images" style="background-image: url('https://bing.ioliu.cn/v1/rand?h=70');">
      <img style="border-radius:50%;width:50px;height:50px;"  src="../assets/img/zr.png" alt="...">  <font size="4" color="white"><b>授权助手</b></font>
        </div>

        
           
              <div id="divDetail" class="hui-wrap" style="height:380px;overFlow-y:scroll;">
  		         <div style="border: 1px  #000000; width: 90%; margin: 0 auto;">
  <div class="lite-chatbox"> 
    <div style="padding:5px" class="cleft cmsg">
        <img class="headIcon radius" ondragstart="return false;"  oncontextmenu="return false;"  src="https://q4.qlogo.cn/g?b=qq&nk=<?php echo $conf['kfqq']?>&s=140" />
        <span class="name"><span class='htitle admin'>助理</span>授权助手</span>
        <span class="content">试试看输出：充值、公告、客服QQ、授权系统</span>
    </div>
<div id="zrmsg"></div>

</div>
</div></div>
            
         <div class="hui-form-textarea" >
    <textarea placeholder="输入你的问题" name="msg" id="msg"></textarea>
  </div>
  <div style="padding:10px;">
     <button id="noticeBtn" class="hui-button hui-button-large hui-primary">发送</button>
  </div>    
        
    </div>
</div>
</div>
</div>

<script type="text/javascript" src="../assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="../assets/js/common.js?v=318"></script>
<script>
function getCookie(cname){
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++) {
        var c = ca[i].trim();
        if (c.indexOf(name)==0) { return c.substring(name.length,c.length); }
      }
    return "";
} 
function setCookie(cname,cvalue,exdays){
                var d = new Date();
                d.setTime(d.getTime()+(exdays*1000));
                var expires = "expires="+d.toGMTString();
                document.cookie = cname+"="+cvalue+"; "+expires;
 }
              
layui.use(['form', 'element', 'slider','jquery', 'tagsInput', 'notice'], function () {
        var form = layui.form;
        var $ = layui.jquery;
        var tagsInput = layui.tagsInput;
        var laydate = layui.laydate;
var notice = layui.notice;


$('#noticeBtn').click(function () {
 
var msg = $("#msg").val(); 
document.getElementById("msg").value="";
var div = document.getElementById('divDetail');
$("#zrmsg").append("<div style=\"padding:5px\" class=\"cright cmsg\"><img class=\"headIcon radius\" ondragstart=\"return false;\"  oncontextmenu=\"return false;\" src=\"https://q4.qlogo.cn/g?b=qq&nk=<?php echo $conf['kfqq']?>&s=140\" /><span class=\"name\"><?php echo $userrow['user']?></span><span class=\"content\">"+msg+"</span></div>");
 div.scrollTop = div.scrollHeight;  
var audio=document.createElement("audio");  
var play = function (s) {
    var URL = "https://fanyi.baidu.com/gettts?lan=zh&text=" + encodeURIComponent(s) + "&spd=5&source=web"
    if(!audio){
        audio.controls = false  
        audio.src = URL  
        document.body.appendChild(audio) 
    }
    audio.src = URL  
    audio.play();
}
var zrcxdm=getCookie("zrcxdm");
if(zrcxdm=="ZR<?php echo $conf['kfqq']?>"){
var SF=msg.split("|");
if(msg=='退出引'){
play("您已成功退出生成授权代码指引");
setCookie("zrcxdm","",0);
$("#zrmsg").append("<div style=\"padding:5px\" class=\"cleft cmsg\"><img class=\"headIcon radius\" ondragstart=\"return false;\"  oncontextmenu=\"return false;\"  src=\"https://q4.qlogo.cn/g?b=qq&nk=<?php echo $conf['kfqq']?>&s=140\" /><span class=\"name\"><span class='htitle admin'>助理</span>授权助手</span><span class=\"content\">您已成功退出生成授权代码指引！</div>");  
div.scrollTop = div.scrollHeight;    

return false; 
}
if(msg=='重id' || msg=='写ID'){

setCookie("ZR1","",0);
$("#zrmsg").append("<div style=\"padding:5px\" class=\"cleft cmsg\"><img class=\"headIcon radius\" ondragstart=\"return false;\"  oncontextmenu=\"return false;\"  src=\"https://q4.qlogo.cn/g?b=qq&nk=<?php echo $conf['kfqq']?>&s=140\" /><span class=\"name\"><span class='htitle admin'>助理</span>授权助手</span><span class=\"content\">请发送您的程序ID</div>");  
div.scrollTop = div.scrollHeight;    

return false; 
}
var ZR1=getCookie("ZR1");
if(ZR1==""){
$("#zrmsg").append("<div style=\"padding:5px\" class=\"cleft cmsg\"><img class=\"headIcon radius\" ondragstart=\"return false;\"  oncontextmenu=\"return false;\"  src=\"https://q4.qlogo.cn/g?b=qq&nk=<?php echo $conf['kfqq']?>&s=140\" /><span class=\"name\"><span class='htitle admin'>助理</span>授权助手</span><span class=\"content\">您发送的程序ID为：“ "+msg+" ”<br>请发送消息“ <font color=red>确认生成</font> ”或<font color=red>点击下方按钮</font>即可生成对应授权代码<br><br>（若要更改发送信息请发送“重写id”即可）<br>（退出生成代码指引请发送信息“退出指引”即可）</div>");  
$("#zrmsg").append("<div style=\"padding:5px\" class=\"cleft cmsg\"><img class=\"headIcon radius\" ondragstart=\"return false;\"  oncontextmenu=\"return false;\"  src=\"https://q4.qlogo.cn/g?b=qq&nk=<?php echo $conf['kfqq']?>&s=140\" /><span class=\"name\"><span class='htitle admin'>助理</span>授权助手</span><span class=\"content\"><button type=\"button\" id=\"scdm\" class=\"layui-btn layui-btn-SF-pink layui-btn-sm\">点此生成授权代码</button></div>");
$('#scdm').click(function () {
document.getElementById("msg").value = "确认生成";
$('#noticeBtn').click();
});
div.scrollTop = div.scrollHeight;
setCookie("ZR1",msg,150);    
return false;
}
if(ZR1!="" && msg=="认生成"){
var domain = window.location.href.split(':')[0] + '://' + document.domain;
var ZR2="<?=$conf['SF_SYS_KEY']?>";
$("#zrmsg").append("<div style=\"padding:5px\" class=\"cleft cmsg\"><img class=\"headIcon radius\" ondragstart=\"return false;\"  oncontextmenu=\"return false;\"  src=\"https://q4.qlogo.cn/g?b=qq&nk=<?php echo $conf['kfqq']?>&s=140\" /><span class=\"name\"><span class='htitle admin'>助理</span>授权助手</span><span class=\"content\">if(!isset($_SESSION['ZR_authcode'])) {<br>$ZR_id='"+ZR1+"';<br>$ZR_url='"+domain+"';<br>$ZR_query=get_curl($ZR_url.'/ZR/api/zr_check.php?url='.$ZR_url.'&authcode='.authcode.'&version='.ZR_VERSION'&ZRid='.$ZR_id);<br>if ($ZR_query=json_decode($ZR_query,true)) {<br>if ($ZR_query['code']==0) {<br>$_SESSION['ZR_authcode']=authcode;<br>}else {<br>exit('<h3>'.$ZR_query['msg'].'</h3>');<br>}<br>}<br>}</div>");
$("#zrmsg").append("<textarea id=\"copy\" style=\"width:0px;height:0px;white-space:pre;\">"+
"if(!isset($_SESSION['ZR_authcode'])) {\n"+
"$ZR_id='"+ZR1+"';\n"+
"$ZR_url='"+domain+"';\n"+
"$ZR_query=get_curl($ZR_url.'/ZR/api/zr_check.php?url='.$ZR_url.'&authcode='.authcode.'&version='.ZR_VERSION'&ZRid='.$ZR_id);\n"+
"if ($ZR_query=json_decode($ZR_query,true)) {\n"+
"if ($ZR_query['code']==0) {\n\n"+
"$_SESSION['ZR_authcode']=authcode;\n\n"+
"} else {\n\n"+
"exit('<h3>'.$ZR_query['msg'].'</h3>');\n"+
"}\n\n"+
"}\n\n"+
"}</textarea><div style=\"padding:5px\" class=\"cleft cmsg\"><img class=\"headIcon radius\" ondragstart=\"return false;\"  oncontextmenu=\"return false;\"  src=\"https://q4.qlogo.cn/g?b=qq&nk=<?php echo $conf['kfqq']?>&s=140\" /><span class=\"name\"><span class='htitle admin'>助理</span>授权助手</span><span class=\"content\"><button type=\"button\" id=\"copyText\" class=\"layui-btn layui-btn-warm layui-btn-sm\">点此复制完整代码</button></div>"); 
$('#copyText').click(function () {
	var e = document.getElementById("copy");
	console.log(e)
	e.select(); // 选择对象
    document.execCommand("Copy"); // 执行浏览器复制命令
    notice.msg('复制成功！', {icon: 1});
});
div.scrollTop = div.scrollHeight;
setCookie("ZR1","",0);    
setCookie("ZR2","",0);  
setCookie("zrcxdm","",0);
return false;
}else{
$("#zrmsg").append("<div style=\"padding:5px\" class=\"cleft cmsg\"><img class=\"headIcon radius\" ondragstart=\"return false;\"  oncontextmenu=\"return false;\"  src=\"https://q4.qlogo.cn/g?b=qq&nk=<?php echo $conf['kfqq']?>&s=140\" /><span class=\"name\"><span class='htitle admin'>助理</span>授权助手</span><span class=\"content\">请发送消息“ <font color=red>确认生成</font> ”或<font color=red>点击下方按钮</font>即可生成对应授权代码<br><br>（若要更改发送信息请发送“重写key”即可）<br>（退出生成代码指引请发送信息“退出指引”即可）</span></div>");  
$("#zrmsg").append("<div style=\"padding:5px\" class=\"cleft cmsg\"><img class=\"headIcon radius\" ondragstart=\"return false;\"  oncontextmenu=\"return false;\"  src=\"https://q4.qlogo.cn/g?b=qq&nk=<?php echo $conf['kfqq']?>&s=140\" /><span class=\"name\"><span class='htitle admin'>助理</span>授权助手</span><span class=\"content\"><button type=\"button\" id=\"scdm\" class=\"layui-btn layui-btn-SF-pink layui-btn-sm\">点此生成授权代码</button></span></div>");
$('#scdm').click(function () {
document.getElementById("msg").value = "确认生成";
$('#noticeBtn').click();
});
div.scrollTop = div.scrollHeight;  
return false;
}
return false; 
}
if(msg=='生成就是计算机代码'){
$("#zrmsg").append("<div style=\"padding:5px\" class=\"cleft cmsg\"><img class=\"headIcon radius\" ondragstart=\"return false;\"  oncontextmenu=\"return false;\"  src=\"https://q4.qlogo.cn/g?b=qq&nk=<?php echo $conf['kfqq']?>&s=140\" /><span class=\"name\"><span class='htitle admin'>助理</span>授权助手</span><span class=\"content\">请发送您的程序ID</span></div>");
div.scrollTop = div.scrollHeight;  
setCookie("zrcxdm","ZR<?php echo $conf['kfqq']?>",150);
 return false;  
} 
var ii = notice.msg('正在执行中..', {icon: 4, close: true});
    $.ajax({
        type: "GET",
        url: "ajax.php?act=ZR&msg="+msg,
        dataType: "json",
       
        success: function(data) {
          notice.destroy();   

            if (data.code == 0) {
            var patt = new RegExp('/');
        if(!patt.test(data.msg)){
               play(data.msg); 
        }
               $("#zrmsg").append("<div style=\"padding:5px\" class=\"cleft cmsg\"><img class=\"headIcon radius\" ondragstart=\"return false;\"  oncontextmenu=\"return false;\"  src=\"https://q4.qlogo.cn/g?b=qq&nk=<?php echo $conf['kfqq']?>&s=140\" /><span class=\"name\"><span class='htitle admin'>助理</span>授权助手</span><span class=\"content\">"+data.msg+"</span></div>");
               div.scrollTop = div.scrollHeight;  
            } else {
               play(data.msg); 
                  $("#zrmsg").append("<div style=\"padding:5px\" class=\"cleft cmsg\"><img class=\"headIcon radius\" ondragstart=\"return false;\"  oncontextmenu=\"return false;\"  src=\"https://q4.qlogo.cn/g?b=qq&nk=<?php echo $conf['kfqq']?>&s=140\" /><span class=\"name\"><span class='htitle admin'>助理</span>授权助手</span><span class=\"content\">"+data.msg+"</span></div>");
                        var audio=document.createElement("audio");  
               div.scrollTop = div.scrollHeight;  
            }
        }
    });
}); 
});
</script>