Initial commit
This commit is contained in:
@@ -0,0 +1,311 @@
|
||||
<?php
|
||||
/**
|
||||
* 验证通信相关操作类模块
|
||||
* Created by PhpStorm.
|
||||
* User: 80071
|
||||
* Date: 2018/2/8
|
||||
* Time: 15:33
|
||||
*/
|
||||
|
||||
class communication
|
||||
{
|
||||
private $connectkey = '';
|
||||
private $decryptKey = '';
|
||||
|
||||
public function __construct($connectkey,$decryptKey)
|
||||
{
|
||||
$this->connectkey = $connectkey;
|
||||
$this->decryptKey = $decryptKey;
|
||||
}
|
||||
|
||||
private function str_decode($str, $key, $key_rand)
|
||||
{//解密函数
|
||||
return (string)$this->ARSC($this->BytesHex((string)$this->ARSC($this->BytesHex($str), (string)$key_rand)), $key);
|
||||
}
|
||||
|
||||
private function ARSC($Data, $Key)
|
||||
{
|
||||
$key[] = "";
|
||||
$box[] = "";
|
||||
$pwd_length = strlen($Key);
|
||||
$data_length = strlen($Data);
|
||||
for ($i = 0; $i < 256; $i++) {
|
||||
$key[$i] = ord($Key[$i % $pwd_length]);
|
||||
$box[$i] = $i;
|
||||
}
|
||||
for ($j = $i = 0; $i < 256; $i++) {
|
||||
$j = ($j + $box[$i] + $key[$i]) % 256;
|
||||
$tmp = $box[$i];
|
||||
$box[$i] = $box[$j];
|
||||
$box[$j] = $tmp;
|
||||
}
|
||||
$cipher = '';
|
||||
for ($a = $j = $i = 0; $i < $data_length; $i++) {
|
||||
$a = ($a + 1) % 256;
|
||||
$j = ($j + $box[$a]) % 256;
|
||||
$tmp = $box[$a];
|
||||
$box[$a] = $box[$j];
|
||||
$box[$j] = $tmp;
|
||||
|
||||
$k = $box[(($box[$a] + $box[$j]) % 256)];
|
||||
$cipher .= chr(ord($Data[$i]) ^ $k);
|
||||
}
|
||||
return $cipher;
|
||||
}
|
||||
|
||||
private function BytesHex($s)
|
||||
{
|
||||
$r = "";
|
||||
for ($i = 0; $i < strlen($s); $i += 2) {
|
||||
$x1 = ord($s{$i});
|
||||
$x1 = ($x1 >= 48 && $x1 < 58) ? $x1 - 48 : $x1 - 97 + 10;
|
||||
$x2 = ord($s{$i + 1});
|
||||
$x2 = ($x2 >= 48 && $x2 < 58) ? $x2 - 48 : $x2 - 97 + 10;
|
||||
$r .= chr((($x1 << 4) & 0xf0) | ($x2 & 0x0f));
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
private function str_encode($str, $key, $key_rand)
|
||||
{//加密函数
|
||||
$key_temp = $this->HexBytes($this->ARSC($str, (string)$key_rand));
|
||||
$key_temp = strtoupper($this->HexBytes($this->ARSC($key_temp, $key)));
|
||||
return $key_temp;
|
||||
}
|
||||
|
||||
private function HexBytes($s)
|
||||
{
|
||||
$r = "";
|
||||
$hexes = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f");
|
||||
for ($i = 0; $i < strlen($s); $i++) {
|
||||
$r .= ($hexes [(ord($s{$i}) >> 4)] . $hexes [(ord($s{$i}) & 0xf)]);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @access DynamicEncryption
|
||||
* @explain 该函数用于文本数据动态加密,每次加密结果不一致,但解密数据相同
|
||||
* @param string $date 将要加密的字符串
|
||||
* @param string $pas 加密密码
|
||||
* @return string 返回加密后的结果字符串
|
||||
*/
|
||||
private function DynamicEncryption($date,$pas){
|
||||
$date = $this->_tobit($date);
|
||||
if(count($date)%2 == 1){
|
||||
$date[] = '0';
|
||||
}
|
||||
$date = $this->_DataDisruption($date);
|
||||
$dateleng = count($date);
|
||||
$Code = $this->_DataDisruption($this->_tobit ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@#$%^&*()_+|'));
|
||||
$Codeleng = count($Code);
|
||||
$pasbit = $this->_DataDisruption($this->_tobit($pas));
|
||||
$pasleng = count($pasbit);
|
||||
$int2=0;
|
||||
$int3=0;
|
||||
$ret=Array();
|
||||
for ($x=1; $x<=$dateleng; $x++) {
|
||||
$int2=$int2+1;
|
||||
if($int2>$Codeleng){
|
||||
$int2=1;
|
||||
}
|
||||
$int3=$int3+1;
|
||||
if($int3>$pasleng){
|
||||
$int3=1;
|
||||
}
|
||||
$randompas =mt_rand(1,5000);
|
||||
$Bus = floor($randompas / $Codeleng + 1);
|
||||
$Yu = $randompas % $Codeleng + 1;
|
||||
$ret = array_merge($ret,array_slice($Code,floor($Bus)-1,1));
|
||||
$ret = array_merge($ret,array_slice($Code,floor($Yu)-1,1));
|
||||
|
||||
$tembit= $date[$x-1]^$Code[$int2-1]^$pasbit[$int3-1]^$randompas;
|
||||
$Bus = $tembit / $Codeleng + 1;
|
||||
$Yu = $tembit % $Codeleng + 1;
|
||||
$ret = array_merge($ret,array_slice($Code,floor($Bus)-1,1));
|
||||
$ret = array_merge($ret,array_slice($Code,floor($Yu)-1,1));
|
||||
}
|
||||
return $this->_bintotxt($ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @access DynamicDecryption
|
||||
* @explain 该函数用于文本数据动态解密
|
||||
* @param string $date 将要解密的字符串
|
||||
* @param string $pas 解密密码
|
||||
* @return string 返回解密后的结果字符串
|
||||
*/
|
||||
private function DynamicDecryption($date,$pas){
|
||||
|
||||
$date = $this->_tobit($date);
|
||||
$dateleng = count ($date);
|
||||
$Code = $this->_DataDisruption ($this->_tobit ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@#$%^&*()_+|"));
|
||||
$Codeleng = count ($Code);
|
||||
$pasbin = $this->_DataDisruption ($this->_tobit ($pas));
|
||||
$pasleng = count ($pasbin);
|
||||
$ret = Array();
|
||||
$lnt3=0;
|
||||
$lnt2=0;
|
||||
for ($lnt1=1; $lnt1<=($dateleng/4); $lnt1++) {
|
||||
$lnt2 = $lnt2 + 1 ;
|
||||
if($lnt2 > $Codeleng){
|
||||
$lnt2 = 1;
|
||||
}
|
||||
$lnt3 = $lnt3 + 1 ;
|
||||
if($lnt3 > $pasleng){
|
||||
$lnt3 = 1;
|
||||
}
|
||||
$Bus = array_slice($date, floor(($lnt1-1)*4+1)-1, 1);
|
||||
$Bus = array_search($Bus[0],$Code);
|
||||
$yu = array_slice($date, floor(($lnt1-1)*4+2)-1, 1);
|
||||
$yu = array_search($yu[0],$Code);
|
||||
$randompas = $Bus * $Codeleng + $yu;
|
||||
$Bus = array_slice($date, floor(($lnt1-1)*4+3)-1, 1);
|
||||
$Bus = array_search($Bus[0],$Code);
|
||||
$yu = array_slice($date, floor(($lnt1-1)*4+4)-1, 1);
|
||||
$yu = array_search($yu[0],$Code);
|
||||
$tembit = $Bus * $Codeleng + $yu;
|
||||
$tembit = $tembit^$Code[$lnt2-1]^$pasbin[$lnt3-1]^$randompas;
|
||||
$ret[] = $tembit;
|
||||
}
|
||||
return $this->_bintotxt($this->_DataDisruption($ret));
|
||||
//return @iconv('gbk','utf-8',$this->_bintotxt($this->_DataDisruption($ret)));
|
||||
}
|
||||
|
||||
private function _bintotxt($bytes) {
|
||||
$str='';
|
||||
foreach($bytes as $ch){
|
||||
$str.=chr($ch);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
private function _tobit($string){
|
||||
$bytes = array();
|
||||
for($i = 0; $i < strlen($string); $i++){
|
||||
$bytes[] = ord($string[$i]);
|
||||
}
|
||||
return $bytes;
|
||||
}
|
||||
private function _DataDisruption($date){
|
||||
$date1=array_slice($date,0,floor(count($date)/2));
|
||||
$date2=array_slice($date,ceil(count($date)-(count($date)/2)));
|
||||
return @array_merge($this->_DataReverse($date1),$this->_DataReverse($date2));
|
||||
}
|
||||
private function _DataReverse($date){
|
||||
$sj = array();
|
||||
for ($x=1; $x<=count($date); $x++) {
|
||||
$sj[$x-1]=$date[count($date)-$x];
|
||||
}
|
||||
return $sj;
|
||||
}
|
||||
|
||||
public function data_encode($data,&$sign){
|
||||
$data = $this->DynamicEncryption($data,$this->connectkey);
|
||||
$sign =md5(md5($this->connectkey.$this->decryptKey).$data);
|
||||
return $this->str_encode($data,$this->connectkey,$this->decryptKey);
|
||||
}
|
||||
|
||||
public function data_decode($data){
|
||||
$post_data = $this->str_decode($data,$this->connectkey,$this->connectkey);
|
||||
return $this->rc4_decode($this->DynamicDecryption($post_data,$this->decryptKey));
|
||||
}
|
||||
|
||||
public function getsign($data){
|
||||
$post_data = $this->str_decode($data,$this->connectkey,$this->connectkey);
|
||||
return md5(md5($this->connectkey.$this->decryptKey).$post_data);
|
||||
}
|
||||
|
||||
public function back($code,$type='',$options = array()){
|
||||
|
||||
global $Tips;
|
||||
//include 'Tips.php';
|
||||
$Tips['ok'] = 'ok';
|
||||
$type = empty($type) ? 'ok' : $type;
|
||||
$data = $this->data_encode(makejson($code,$Tips[$type],$options),$sign);//一次封装取签名
|
||||
//echo $data;
|
||||
//echo '222';
|
||||
die(makejson(1,'ok',array('sign'=>$sign,'data'=>$data)));//二次封装
|
||||
}
|
||||
|
||||
function rc4 ($pwd, $data) {
|
||||
|
||||
$key[] ="";
|
||||
|
||||
$box[] ="";
|
||||
|
||||
$pwd_length = strlen($pwd);
|
||||
|
||||
$data_length = strlen($data);
|
||||
|
||||
for ($i = 0; $i < 256; $i++) {
|
||||
|
||||
$key[$i] = ord($pwd[$i % $pwd_length]);
|
||||
|
||||
$box[$i] = $i;
|
||||
|
||||
}
|
||||
|
||||
for ($j = $i = 0; $i < 256; $i++) {
|
||||
|
||||
$j = ($j + $box[$i] + $key[$i]) % 256;
|
||||
|
||||
$tmp = $box[$i];
|
||||
|
||||
$box[$i] = $box[$j];
|
||||
|
||||
$box[$j] = $tmp;
|
||||
|
||||
}
|
||||
$cipher = '';
|
||||
for ($a = $j = $i = 0; $i < $data_length; $i++) {
|
||||
|
||||
$a = ($a + 1) % 256;
|
||||
|
||||
$j = ($j + $box[$a]) % 256;
|
||||
|
||||
$tmp = $box[$a];
|
||||
|
||||
$box[$a] = $box[$j];
|
||||
|
||||
$box[$j] = $tmp;
|
||||
|
||||
$k = $box[(($box[$a] + $box[$j]) %256)];
|
||||
|
||||
$cipher .= chr(ord($data[$i]) ^ $k);
|
||||
|
||||
}
|
||||
|
||||
return $cipher;
|
||||
|
||||
}
|
||||
|
||||
function hexToStr($hex)
|
||||
{
|
||||
$string="";
|
||||
for ($i=0;$i<strlen($hex)-1;$i+=2)
|
||||
$string.=chr(hexdec($hex[$i].$hex[$i+1]));
|
||||
return $string;
|
||||
}
|
||||
function strToHex($string)
|
||||
{
|
||||
return substr(chunk_split(bin2hex($string)),0,-2);
|
||||
|
||||
}
|
||||
private function rc4_encode($string)
|
||||
{
|
||||
|
||||
return $this->strToHex($this->rc4($this->connectkey,$string));
|
||||
|
||||
|
||||
}
|
||||
private function rc4_decode($string)
|
||||
{
|
||||
|
||||
return $this->rc4($this->connectkey,pack('H*',$string));
|
||||
|
||||
|
||||
}
|
||||
//rc4b解密
|
||||
//rc4a加密
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: 80071
|
||||
* Date: 2018/10/1
|
||||
* Time: 20:25
|
||||
*/
|
||||
|
||||
include "function_core.php";
|
||||
include 'VerificationCode.class.php';
|
||||
//error_reporting(E_ALL);
|
||||
|
||||
Verification::loadcode();
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
//页面全局
|
||||
$MailTipsFram = <<<Fram
|
||||
<p>尊敬的用户,上午好</p>
|
||||
<p>这封邮件是您在平台执行了某项操作发送的,若您并未进行任何操作请忽略此邮件并对邮件内容保密。</p>
|
||||
|
||||
[content]
|
||||
<center>
|
||||
<p><a href="{$G['config']['weburl']}query.php" style="display:inline-block;padding:4px 30px;border-radius:1px;color:#0083ff;border:2px solid #0083ff;text-decoration:none;margin-top:20px;box-shadow: 1px 1px 2px #888888;" target="_blank">查询中心</a> <a href="tencent://message/?uin={$G['config']['adminqq']}" style="display:inline-block;padding:4px 25px;border-radius:1px;color:#0083ff;border:2px solid #0083ff;text-decoration:none;margin-top:20px;box-shadow: 1px 1px 2px #888888;" target="_blank">联系客服</a></p>
|
||||
|
||||
<small><p>Powered by {$_SERVER['HTTP_HOST']}</p></small></center>
|
||||
Fram;
|
||||
|
||||
//内容+标题模板行
|
||||
$MailTipsCon = <<<CON
|
||||
<div style="box-shadow: 1px 1px 2px #888888;background:#fbfbfb;padding:10px 20px;font-size:18px;border-left:3px solid #0083ff;margin-top:20px;">
|
||||
[title]<br>
|
||||
<div style="margin-left:40px;margin-top:5px;font-size:16px;">
|
||||
[content]
|
||||
</div>
|
||||
</div>
|
||||
CON;
|
||||
|
||||
//内容行
|
||||
$MailTipsLine = <<<Lin
|
||||
[content]<br>
|
||||
Lin;
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* 提示文件配置说明:
|
||||
* 提示采用数组方式存放,所以此处配置格式为PHP Array
|
||||
* ----若您不知道什么是数组,请看下面----
|
||||
* 请修改 '=>' 后面的内容,请勿删除某行,否则会出错
|
||||
* 如果有有变量后面请使用双引号,无变量请使用单引号提高效率。
|
||||
* 无变量:'appid不能为空'
|
||||
* 有变量:'您输入的用户名{$data['user']}不存在'
|
||||
* 每行以半角逗号结尾,最后一行后面的逗号可有可无。
|
||||
* '//'后面的内容为注释内容,不会被PHP解析
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
$Tips = array(
|
||||
//提示行开始:
|
||||
//--------------------------系统初始化提示----------------------------
|
||||
'NoAppID'=> 'appid不能为空',
|
||||
'NoSign'=> '签名不能为空',
|
||||
'GetAppInfoErr'=> '应用信息获取失败',
|
||||
'SignError'=> '签名校验失败',
|
||||
'AppVerOld'=> '当前应用版本,请下载新版本',
|
||||
'AppClosed'=> '当前应用已停用,请与管理员联系',
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
|
||||
//--------------------------用户登录提示----------------------------
|
||||
'InitTimeOut'=> '初始化后太久未操作,数据已超时,请重启软件',
|
||||
'HeartNoToken'=> '心跳Token不能为空,请重新登录',
|
||||
'HeartTokenError'=> '您的账号在其他地方登录、或由于网络原因长时间未收到心跳、或由于管理员手动将您下线,请重新登录',
|
||||
|
||||
|
||||
//账号密码:
|
||||
'NoUsername'=> '用户名不能为空',
|
||||
'NoPassword'=> '密码不能为空',
|
||||
'LoginError'=> '用户名或密码错误',
|
||||
'ErrorUsername'=> '用户名输入错误',
|
||||
'ErrorPassword'=> '密码输入错误',
|
||||
|
||||
//卡密登录:
|
||||
'NoKami'=> '登录卡密不能为空',
|
||||
'ErrorKami'=> '您输入的授权卡密不存在',
|
||||
|
||||
//检查绑定:
|
||||
'ErrorBind'=> '未查询到您的授权信息',
|
||||
|
||||
//绑定提示:
|
||||
'IpBindNeed'=> '当前IP非授权绑定IP,您无法登录',
|
||||
'MacBindNeed' => '当前设备非授权绑定设备,您无法登录',
|
||||
'QQBindNeed' => '当前QQ非绑定QQ,您无法登录',
|
||||
|
||||
//其他提示:
|
||||
'UserCold'=> '您的账号已被冻结,请联系管理员处理',
|
||||
'AuthTimeOut'=> '您的授权已到期,请续费后再登录',
|
||||
'BalanceOut'=> '您的余额不足,请先充值后再登录',
|
||||
'LoggedInTips'=> '您的账号已在别处登录[{userip}],请问是否强制将其挤下线?',
|
||||
'HeartNoFoundUser'=>'您的授权已被删除,请联系管理员',
|
||||
//-------------------------------------------------------------------.
|
||||
//提示行结束
|
||||
);
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
class Verification
|
||||
{
|
||||
static function loadcode()
|
||||
{
|
||||
global $G;
|
||||
|
||||
if ($G['config']['opencode'] == 'true') {
|
||||
|
||||
die(' <div class="vaptcha-init-main">
|
||||
<div class="vaptcha-init-loading">
|
||||
<a href="/" target="_blank">
|
||||
<img src="https://cdn.vaptcha.com/vaptcha-loading.gif" />
|
||||
</a>
|
||||
<span class="vaptcha-text">Vaptcha启动中...</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
vaptcha({
|
||||
//配置参数
|
||||
vid: \'5aa3579ba4868a214c8f7b63\', // 验证单元id
|
||||
type: \'click\', // 展现类型 点击式
|
||||
container: \'#vaptchaContainer\' // 按钮容器,可为Element 或者 selector
|
||||
}).then(function (vaptchaObj) {
|
||||
vaptchaObj.render()// 调用验证实例 vaptchaObj 的 render 方法加载验证按钮
|
||||
window.vaptchaObj=vaptchaObj;
|
||||
})
|
||||
</script>');
|
||||
}
|
||||
}
|
||||
|
||||
static function check($token)
|
||||
{
|
||||
global $G;
|
||||
|
||||
if ($G['config']['opencode'] == 'true' || $G['config']['opencode'] == '1') {
|
||||
if (strlen($token) == 32) {
|
||||
unset($_POST['token']);
|
||||
//对待签名参数数组排序
|
||||
$para_filter = paraFilter($_POST);
|
||||
$para_sort = argSort($para_filter);
|
||||
//生成签名结果
|
||||
$prestr = createLinkstring($para_sort);
|
||||
$mysign = md5Sign($prestr, $G['config']['token']);
|
||||
//签名结果与签名方式加入请求提交参数组中
|
||||
if ($mysign == $token) {
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$info = json_decode(curl_request('http://api.vaptcha.com/v2/validate', 'id=' . $G['config']['codevid'] . '&secretkey=' . $G['config']['codekey'] . '&token=' . $token . '&ip=' . get_real_ip()), true);
|
||||
if ($info['success'] == '1') {
|
||||
return true;
|
||||
} else {
|
||||
return $info;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ApiCommunication
|
||||
{
|
||||
private $connectkey;
|
||||
private $decryptKey;
|
||||
public function __construct($connectKey,$decryptKey)
|
||||
{
|
||||
$this->connectkey = $connectKey;
|
||||
$this->decryptKey = $decryptKey;
|
||||
}
|
||||
|
||||
public function getsign($data)
|
||||
{
|
||||
return md5($this->connectkey.md5(md5($data.$this->connectkey).$this->decryptKey).$this->decryptKey);
|
||||
}
|
||||
|
||||
public function back($code,$type='',$options = array()){
|
||||
include 'Tips.php';
|
||||
global $Tips;
|
||||
$Tips['ok'] = 'ok';
|
||||
$type = empty($type) ? 'ok' : $type;
|
||||
$data = makejson($code,$Tips[$type],$options);//一次封装取签名
|
||||
$sign = $this->getsign($data);
|
||||
|
||||
die(makejson(1,'ok',array('sign'=>$sign,'data'=>$data)));//二次封装
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<link rel="stylesheet" href="./mdl/material.light_blue-purple.min.css" />
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* 验证通信相关操作类模块
|
||||
* Created by PhpStorm.
|
||||
* User: 80071
|
||||
* Date: 2018/2/8
|
||||
* Time: 15:33
|
||||
*/
|
||||
|
||||
class communication
|
||||
{
|
||||
|
||||
private function ARSC($Data,$Key)
|
||||
{
|
||||
$key[] ="";
|
||||
$box[] ="";
|
||||
$pwd_length = strlen($Key);
|
||||
$data_length = strlen($Data);
|
||||
for ($i = 0; $i < 256; $i++)
|
||||
{
|
||||
$key[$i] = ord($Key[$i % $pwd_length]);
|
||||
$box[$i] = $i;
|
||||
}
|
||||
for ($j = $i = 0; $i < 256; $i++)
|
||||
{
|
||||
$j = ($j + $box[$i] + $key[$i]) % 256;
|
||||
$tmp = $box[$i];
|
||||
$box[$i] = $box[$j];
|
||||
$box[$j] = $tmp;
|
||||
}
|
||||
$cipher = '';
|
||||
for ($a = $j = $i = 0; $i < $data_length; $i++)
|
||||
{
|
||||
$a = ($a + 1) % 256;
|
||||
$j = ($j + $box[$a]) % 256;
|
||||
$tmp = $box[$a];
|
||||
$box[$a] = $box[$j];
|
||||
$box[$j] = $tmp;
|
||||
|
||||
$k = $box[(($box[$a] + $box[$j]) % 256)];
|
||||
$cipher .= chr(ord($Data[$i]) ^ $k);
|
||||
}
|
||||
return $cipher;
|
||||
}
|
||||
private function BytesHex($s){
|
||||
$r = "";
|
||||
for ( $i = 0; $i<strlen($s); $i += 2)
|
||||
{
|
||||
$x1 = ord($s{$i});
|
||||
$x1 = ($x1>=48 && $x1<58) ? $x1-48 : $x1-97+10;
|
||||
$x2 = ord($s{$i+1});
|
||||
$x2 = ($x2>=48 && $x2<58) ? $x2-48 : $x2-97+10;
|
||||
$r .= chr((($x1 << 4) & 0xf0) | ($x2 & 0x0f));
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
private function HexBytes($s) {
|
||||
$r = "";
|
||||
$hexes = array ("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
|
||||
for ($i=0; $i<strlen($s); $i++) {$r .= ($hexes [(ord($s{$i}) >> 4)] . $hexes [(ord($s{$i}) & 0xf)]);}
|
||||
return $r;
|
||||
}
|
||||
public function str_decode($str,$key,$key_rand){//解密函数
|
||||
return (string)$this->ARSC($this->BytesHex((string)$this->ARSC($this->BytesHex($str),(string)$key_rand)),$key);
|
||||
}
|
||||
public function str_encode($str,$key,$key_rand){//加密函数
|
||||
$key_temp = $this->HexBytes($this->ARSC($str,(string)$key_rand));
|
||||
$key_temp = strtoupper($this->HexBytes($this->ARSC($key_temp,$key)));
|
||||
return $key_temp;
|
||||
}
|
||||
|
||||
public function GET_Temp_Key(){
|
||||
mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
|
||||
$charid = strtoupper(md5(uniqid(rand(), true)));
|
||||
$hyphen = chr(45);// "-"
|
||||
$uuid = chr(123)// "{"
|
||||
.substr($charid, 0, 8).$hyphen
|
||||
.substr($charid, 8, 4).$hyphen
|
||||
.substr($charid,12, 4).$hyphen
|
||||
.substr($charid,16, 4).$hyphen
|
||||
.substr($charid,20,12)
|
||||
.chr(125);// "}"
|
||||
return $uuid;
|
||||
}
|
||||
public function str_sign($str,$txmy,$tempkey){
|
||||
|
||||
return md5($str.$txmy.$tempkey);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,423 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: 温泉
|
||||
* Date: 2017-10-15
|
||||
* Time: 12:07
|
||||
* 温泉专用数据库类库
|
||||
*/
|
||||
|
||||
|
||||
class db
|
||||
{
|
||||
/*
|
||||
* 链接初始化
|
||||
*/
|
||||
public $connection;
|
||||
|
||||
function __construct($server, $username, $password, $dbname,$prot = 3306,$charset = 'utf8')
|
||||
{
|
||||
if (!$this->connection = new mysqli($server, $username, $password, $dbname, $prot)) {
|
||||
die('MySQL Connect Error (' . $this->connection->connect_errno . ') ' . $this->connection->connect_error);
|
||||
}
|
||||
if ($this->connection->connect_error) {
|
||||
die('MySQL Connect Error (' . $this->connection->connect_errno . ') ' . $this->connection->connect_error);
|
||||
}
|
||||
$this->connection->set_charset($charset);
|
||||
$this->connection->query('set names ' . $charset);
|
||||
}
|
||||
|
||||
/*
|
||||
* select 返回第一条数据
|
||||
*/
|
||||
public function select_first_row($table, $fields, $where, $wheretype)
|
||||
{
|
||||
$sql = 'SELECT ';
|
||||
$fidtmp = '';
|
||||
if (is_array($fields)) {
|
||||
foreach ($fields as $value) {
|
||||
if (empty($fidtmp)) {
|
||||
$fidtmp = $value;
|
||||
} else {
|
||||
$fidtmp .= ',' . $value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$fidtmp = $fields;
|
||||
}
|
||||
|
||||
$sql .= $fidtmp;
|
||||
unset($fidtmp);
|
||||
$sql .= ' FROM ' . $table;
|
||||
if (!empty($where)) {
|
||||
$sql .= ' WHERE ';
|
||||
$condition = '';
|
||||
$condition = $this->wheretosql($where, $wheretype);
|
||||
$sql .= $condition . ' LIMIT 1';
|
||||
unset($condition);
|
||||
}
|
||||
|
||||
//echo $sql;
|
||||
if (!$result = $this->connection->query($sql)) {
|
||||
$this->posterror($this->geterror(),'warning');
|
||||
//$this->insert_back_id('sq_log_system', array('time' => time(), 'ip' => get_real_ip(), 'msg' => '数据库错误:' . $this->geterror(), 'type' => 'danger'));
|
||||
return false;
|
||||
} else {
|
||||
if ($result->num_rows === 0) {
|
||||
return false;
|
||||
}
|
||||
return $result->fetch_array();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* select 返回所有数据
|
||||
*/
|
||||
|
||||
public function wheretosql($where, $wheretype)
|
||||
{
|
||||
$condition = '';
|
||||
if (is_array($where)) {
|
||||
foreach ($where as $key => $value) {
|
||||
if (empty($condition)) {
|
||||
$condition = $key . '=\'' . addslashes($value) . '\'';
|
||||
} else {
|
||||
$condition .= ' ' . $wheretype . ' ' . $key . '=\'' . addslashes($value) . '\'';
|
||||
}
|
||||
}
|
||||
return $condition;
|
||||
} else {
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 获取某个select行数
|
||||
*/
|
||||
|
||||
public function insert_back_id($table, $data)
|
||||
{
|
||||
$return = $this->query('SHOW FULL COLUMNS FROM ' . $table);
|
||||
while ($info = $return->fetch_assoc()) {
|
||||
if (!isset($data[$info['Field']])) {
|
||||
|
||||
if ($info['Field'] == 'ID' or $info['Field'] == 'id' or $info['Field'] == 'Id' or $info['Field'] == 'iD') {
|
||||
$data[$info['Field']] = '{nullvaluereplace}';
|
||||
} else if (stristr($info['Type'], 'int') || stristr($info['Type'], 'bigint') || stristr($info['Type'], 'integer') || stristr($info['Type'], 'double')) {
|
||||
$data[$info['Field']] = '{intvaluereplace}';
|
||||
} else {
|
||||
$data[$info['Field']] = '';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($data as $k => $v) {
|
||||
|
||||
if (empty($column)) {
|
||||
$column = $k;
|
||||
if ($v == '{nullvaluereplace}') {
|
||||
$value = 'NULL';
|
||||
} else if ($v == '{intvaluereplace}') {
|
||||
$value = '0';
|
||||
} else {
|
||||
$value = '\'' . addslashes($v) . '\'';
|
||||
}
|
||||
} else {
|
||||
$column .= ',' . $k;
|
||||
if ($v == '{nullvaluereplace}') {
|
||||
$value .= ',NULL';
|
||||
} else if ($v == '{intvaluereplace}') {
|
||||
$value .= ',0';
|
||||
} else {
|
||||
$value .= ',\'' . addslashes($v) . '\'';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$sql = 'INSERT INTO ' . $table . ' (' . $column . ') VALUES (' . $value . ')';
|
||||
//echo $sql;
|
||||
if (!$this->connection->query($sql)) {
|
||||
//echo $this->geterror();
|
||||
return false;
|
||||
} else {
|
||||
return $this->connection->insert_id;
|
||||
}
|
||||
}
|
||||
|
||||
public function query($sql)
|
||||
{
|
||||
return $this->connection->query($sql);
|
||||
}
|
||||
|
||||
/*
|
||||
* 执行查询语句(update),成功返回受影响的行数
|
||||
*/
|
||||
|
||||
public function geterror()
|
||||
{
|
||||
return $this->connection->error;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 插入数据到一个表,返回插入的ID
|
||||
*/
|
||||
|
||||
public function select_all_row($table, $fields = '*', $where = '', $wheretype = 'AND', $order = '')
|
||||
{
|
||||
$sql = 'SELECT ';
|
||||
$fidtmp = '';
|
||||
if (is_array($fields)) {
|
||||
foreach ($fields as $value) {
|
||||
if (empty($fidtmp)) {
|
||||
$fidtmp = $value;
|
||||
} else {
|
||||
$fidtmp .= ',' . $value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$fidtmp = $fields;
|
||||
}
|
||||
$sql .= $fidtmp;
|
||||
unset($fidtmp);
|
||||
$sql .= ' FROM ' . $table;
|
||||
if (!empty($where)) {
|
||||
$sql .= ' WHERE ';
|
||||
$condition = '';
|
||||
$condition = $this->wheretosql($where, $wheretype);
|
||||
$sql .= $condition;
|
||||
unset($condition);
|
||||
}
|
||||
|
||||
$return = array();
|
||||
|
||||
$sql .= $order;
|
||||
|
||||
if (!$result = $this->connection->query($sql)) {
|
||||
//$this->insert_back_id('sq_log_system', array('time' => time(), 'ip' => get_real_ip(), 'msg' => '数据库错误:' . $this->geterror(), 'type' => 'danger'));
|
||||
$this->posterror($this->geterror(),'warning');
|
||||
return false;
|
||||
} else {
|
||||
while ($info = $result->fetch_array()) {
|
||||
$return[] = $info;
|
||||
}
|
||||
$result->free();
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 插入多条数据到表,返回插入的行数
|
||||
*/
|
||||
|
||||
public function select_count_row($table, $where = '', $wheretype = '')
|
||||
{
|
||||
$sql = 'SELECT COUNT(ID) FROM ' . $table;
|
||||
if (!empty($where)) {
|
||||
if (is_array($where)) {
|
||||
$condition = ' WHERE ' . $this->wheretosql($where, $wheretype);
|
||||
$sql .= $condition;
|
||||
} else {
|
||||
$condition = ' WHERE ' . $where;
|
||||
$sql .= $condition;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
unset($condition);
|
||||
|
||||
if (!$result = $this->connection->query($sql)) {
|
||||
//$this->insert_back_id('sq_log_system', array('time' => time(), 'ip' => get_real_ip(), 'msg' => '数据库错误:' . $this->geterror(), 'type' => 'danger'));
|
||||
$this->posterror($this->geterror(),'warning');
|
||||
return false;
|
||||
} else {
|
||||
|
||||
$array = $result->fetch_array();
|
||||
|
||||
return intval($array[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 删除记录
|
||||
*/
|
||||
|
||||
public function select_limit_row($table, $fields, $limit = '', $num = 0, $where = '', $wheretype = 'AND', $order = '')
|
||||
{
|
||||
$sql = 'SELECT ';
|
||||
$fidtmp = '';
|
||||
if (is_array($fields)) {
|
||||
foreach ($fields as $value) {
|
||||
if (empty($fidtmp)) {
|
||||
$fidtmp = $value;
|
||||
} else {
|
||||
$fidtmp .= ',' . $value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$fidtmp = $fields;
|
||||
}
|
||||
$sql .= $fidtmp;
|
||||
unset($fidtmp);
|
||||
$sql .= ' FROM ' . $table;
|
||||
if (!empty($where)) {
|
||||
$sql .= ' WHERE ';
|
||||
$condition = '';
|
||||
$condition = $this->wheretosql($where, $wheretype);
|
||||
$sql .= $condition;
|
||||
unset($condition);
|
||||
}
|
||||
$sql .= ' ' . $order;
|
||||
$return = array();
|
||||
|
||||
if (empty($limit)) {
|
||||
if (!empty($num)) {
|
||||
$sql .= ' LIMIT ' . $num;
|
||||
}
|
||||
} else {
|
||||
if (!empty($num)) {
|
||||
$sql .= ' LIMIT ' . $limit . ',' . $num;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$result = $this->connection->query($sql)) {
|
||||
//$this->insert_back_id('sq_log_system', array('time' => time(), 'ip' => get_real_ip(), 'msg' => '数据库错误:' . $this->geterror(), 'type' => 'danger'));
|
||||
$this->posterror($this->geterror(),'warning');
|
||||
return false;
|
||||
} else {
|
||||
while ($info = $result->fetch_array()) {
|
||||
$return[] = $info;
|
||||
}
|
||||
$result->free();
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 获取最后一次出现的错误信息
|
||||
*/
|
||||
|
||||
public function update($table, $where, $wheretype, $newdata)
|
||||
{
|
||||
$newdatatmp = '';
|
||||
foreach ($newdata as $key => $value) {
|
||||
if (is_int($value) || is_double($value) || is_float($value)){
|
||||
$value = round($value,2);
|
||||
}
|
||||
if (empty($newdatatmp)) {
|
||||
$newdatatmp = $key . '=\'' . addslashes($value) . '\'';
|
||||
} else {
|
||||
$newdatatmp .= ', ' . $key . '=\'' . addslashes($value) . '\'';
|
||||
}
|
||||
}
|
||||
|
||||
$condition = $this->wheretosql($where, $wheretype);
|
||||
|
||||
$sql = 'UPDATE ' . $table . ' SET ' . $newdatatmp . ' WHERE ' . $condition;
|
||||
//echo $sql;
|
||||
if (!$result = $this->connection->query($sql)) {
|
||||
//$this->insert_back_id('sq_log_system', array('time' => time(), 'ip' => get_real_ip(), 'msg' => '数据库错误:' . $this->geterror(), 'type' => 'danger'));
|
||||
$this->posterror($this->geterror(),'warning');
|
||||
return false;
|
||||
} else {
|
||||
if ($this->connection->affected_rows === 0) {
|
||||
return false;
|
||||
}
|
||||
return $this->connection->affected_rows;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function insert_back_row($table, $k, $v)
|
||||
{
|
||||
$return = $this->query('SHOW FULL COLUMNS FROM ' . $table);
|
||||
while ($info = $return->fetch_assoc()) {
|
||||
$bool = false;
|
||||
foreach ($k as $value) {
|
||||
if ($value === $info['Field']) {
|
||||
$bool = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$bool) {
|
||||
$k[] = $info['Field'];
|
||||
foreach ($v as $key => $value) {
|
||||
if ($info['Field'] == 'ID' or $info['Field'] == 'id' or $info['Field'] == 'Id' or $info['Field'] == 'iD') {
|
||||
$v[$key] .= ',NULL';
|
||||
} else if (stristr($info['Type'], 'int') || stristr($info['Type'], 'bigint') || stristr($info['Type'], 'integer') || stristr($info['Type'], 'double')) {
|
||||
$v[$key] .= ',0';
|
||||
} else {
|
||||
|
||||
$v[$key] .= ',\'\'';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$datainfo = '';
|
||||
foreach ($v as $value) {
|
||||
if ($datainfo === '') {
|
||||
$datainfo = '(' . $value . ')';
|
||||
} else {
|
||||
$datainfo .= ',(' . $value . ')';
|
||||
}
|
||||
|
||||
}
|
||||
$sql = 'INSERT INTO ' . $table . ' (' . $this->arraytocomma($k) . ') VALUES ' . $datainfo;
|
||||
//echo $sql;
|
||||
if (!$this->connection->query($sql)) {
|
||||
//$this->insert_back_id('sq_log_system', array('time' => time(), 'ip' => get_real_ip(), 'msg' => '数据库错误:' . $this->geterror(), 'type' => 'danger'));
|
||||
$this->posterror($this->geterror(),'warning');
|
||||
return false;
|
||||
} else {
|
||||
return $this->connection->affected_rows;
|
||||
}
|
||||
}
|
||||
|
||||
private function arraytocomma($array)
|
||||
{
|
||||
$back = '';
|
||||
foreach ($array as $value) {
|
||||
if ($back === '') {
|
||||
$back = $value;
|
||||
} else {
|
||||
$back .= ', ' . $value;
|
||||
}
|
||||
}
|
||||
return $back;
|
||||
}
|
||||
|
||||
public function delete($table, $where, $wheretype)
|
||||
{
|
||||
$condition = $this->wheretosql($where, $wheretype);
|
||||
$sql = 'DELETE FROM ' . $table . ' WHERE ' . $condition;
|
||||
if (!$this->connection->query($sql)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public function affected_num(){
|
||||
return $this->connection->affected_rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $msg
|
||||
* @param string $type info | warning | success | danger
|
||||
*/
|
||||
public function posterror($msg,$type = "info"){
|
||||
$this->insert_back_id('sq_log_system', array('time' => time(), 'ip' => get_real_ip(), 'msg' => $msg, 'type' => $type));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: 温泉
|
||||
* Date: 2018-01-14
|
||||
* Time: 13:44
|
||||
*/
|
||||
function app_idgetinfo($id)
|
||||
{
|
||||
global $db;
|
||||
return $db->select_first_row('sq_apps', '*', array('ID' => $id), 'AND');
|
||||
}
|
||||
|
||||
function app_idgetname($id)
|
||||
{
|
||||
global $db;
|
||||
if (!$result = $db->select_first_row('sq_apps', 'appname', array('ID' => $id), 'AND')) {
|
||||
return false;
|
||||
}
|
||||
return $result['appname'];
|
||||
}
|
||||
|
||||
function level_idgetname($id)
|
||||
{
|
||||
global $db;
|
||||
if (!$result = $db->select_first_row('sq_level', 'lname', array('ID' => $id), 'AND')) {
|
||||
return false;
|
||||
} else {
|
||||
return $result['lname'];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,291 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: 温泉
|
||||
* Date: 2019/2/9
|
||||
* Time: 15:50
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 授权操作
|
||||
* @access public
|
||||
* @param string $username 用户名、卡密
|
||||
* @param string $password 密码
|
||||
* @param string $ip 用户IP、绑定的IP
|
||||
* @param int $balance 新增授权点数或秒数,-1为永久
|
||||
* @param string $uqq 用户QQ
|
||||
* @param string $mail 用户邮箱
|
||||
* @param int $appid 应用ID
|
||||
* @param int $agentid 代理ID
|
||||
* @param string $newkey 返回的卡密
|
||||
* @param string $tips 提示
|
||||
* @return int 1为新开成功,2为续费成功,3为卡密新开成功
|
||||
*/
|
||||
function auth_add($username,$password,$ip,$balance,$uqq,$mail,$appid,$origin,$oid,&$newkey,&$tips,$tradeinfo = array()){
|
||||
include_once 'function_app.php';
|
||||
global $db,$G,$MailTips;
|
||||
|
||||
|
||||
$appinfo = app_idgetinfo($appid);
|
||||
if ($appinfo['usetype']=='dqsj'){
|
||||
if ($balance!='-1'){
|
||||
$balance=$balance*60;
|
||||
}
|
||||
}
|
||||
if ($appinfo['logintype'] == 'zhmm') {
|
||||
//账号密码授权方式
|
||||
if (!$userinfo = $db->select_first_row('sq_user', '*', array('username' => $username, 'appid' => $appid), 'AND')) {
|
||||
$T['title'] = '您的授权账号已新开成功!';
|
||||
$T['content'][] = '应用名称:'.$appinfo['appname'];
|
||||
$T['content'][] = '注册时间:'.Get_Date();
|
||||
if ($appinfo['usetype']=='dqsj'){
|
||||
if ($balance!='-1'){
|
||||
$balance=time()+$balance;
|
||||
$T['content'][] = '到期时间:'.Get_Date($balance);
|
||||
}else{
|
||||
$T['content'][] = '到期时间:永久授权';
|
||||
}
|
||||
}else{
|
||||
if ($balance == '-1'){
|
||||
$T['content'][] = '开通余额:无限使用';
|
||||
}else{
|
||||
$T['content'][] = '开通余额:'.$balance;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$db->insert_back_id('sq_user', array(
|
||||
'username' => $username,
|
||||
'password' =>$password,
|
||||
'mail' => $mail,
|
||||
'uqq' => $uqq,
|
||||
'rtime' => time(),
|
||||
'status' => '1',
|
||||
'appid' => $appid,
|
||||
'aid' => $oid,
|
||||
'balance'=>$balance,
|
||||
'origin' => $origin,
|
||||
'oid'=>$oid
|
||||
)
|
||||
);
|
||||
$T['content'][] = '授权来源:'.GetOriginText($origin);
|
||||
$T['content'][] = '联系方式:QQ '.$uqq;
|
||||
$T['content'][] = '授权账号:'.$username;
|
||||
$T['content'][] = '用户邮箱:'.$mail;
|
||||
$MailTips[] = $T;
|
||||
SendTipsMail($mail,$MailTips,$backinfo);
|
||||
return 1;
|
||||
}
|
||||
$T['title'] = '您的授权账号已续费成功!';
|
||||
$T['content'][] = '应用名称:'.$appinfo['appname'];
|
||||
$T['content'][] = '注册时间:'.Get_Date($userinfo['rtime']);
|
||||
if ($balance != '-1') {
|
||||
if ($appinfo['usetype'] == 'dqsj') {
|
||||
if ($userinfo['balance'] < time()) {
|
||||
$usernewinfo['balance'] = time() + $balance;
|
||||
} else {
|
||||
$usernewinfo['balance'] = $userinfo['balance'] + $balance;
|
||||
}
|
||||
$T['content'][] = '到期时间:'.Get_Date($usernewinfo['balance']);
|
||||
} else if ($appinfo['usetype'] == 'kcye') {
|
||||
$usernewinfo['balance'] = $userinfo['balance'] +$balance;
|
||||
$T['content'][] = '授权余额:'.Get_Date($usernewinfo['balance']);
|
||||
} else {
|
||||
$tips='应用使用方式设置异常';
|
||||
return -3;
|
||||
}
|
||||
|
||||
} else {
|
||||
$usernewinfo['balance'] = '-1';
|
||||
$T['content'][] = $appinfo['usetype']=='dqsj' ? '到期时间:永久授权' : '开通余额:无限使用';
|
||||
}
|
||||
$T['content'][] = '授权来源:'.GetOriginText($origin);
|
||||
$T['content'][] = '联系方式:QQ '.$uqq;
|
||||
$T['content'][] = '授权账号:'.$userinfo['username'];
|
||||
$T['content'][] = '用户邮箱:'.$userinfo['mail'];
|
||||
$MailTips[]= $T;
|
||||
$db->update('sq_user', array('ID'=>$userinfo['ID']), 'AND', $usernewinfo);
|
||||
SendTipsMail($userinfo['mail'],$MailTips,$backinfo);
|
||||
return 2;
|
||||
} else if ($appinfo['logintype'] == 'kmsq') {
|
||||
//卡密登录方式
|
||||
if (empty($username)) {
|
||||
//没有卡密新开授权
|
||||
$T['title'] = '您的授权卡密已新开成功!';
|
||||
$T['content'][] = '应用名称:'.$appinfo['appname'];
|
||||
$T['content'][] = '注册时间:'.Get_Date();
|
||||
if ($appinfo['usetype']=='dqsj'){
|
||||
if ($balance!='-1'){
|
||||
$balance=time()+$balance;
|
||||
$T['content'][] = '到期时间:'.Get_Date($balance);
|
||||
}else{
|
||||
$T['content'][] = '到期时间:永久使用';
|
||||
}
|
||||
}else{
|
||||
if ($balance == '-1'){
|
||||
$T['content'][] = '开通余额:无限使用';
|
||||
}else{
|
||||
$T['content'][] = '开通余额:'.$balance;
|
||||
}
|
||||
}
|
||||
$newkey = rand_str(32);
|
||||
while ($info = $db->select_first_row('sq_user', 'ID', array('username' => $newkey, 'appid' => $appinfo['ID']), 'AND')) {
|
||||
$newkey = rand_str(32);
|
||||
}
|
||||
//echo $newkey;
|
||||
$db->insert_back_id('sq_user', array(
|
||||
'username' => $newkey,
|
||||
'mail' => $mail,
|
||||
'rtime' => time(),
|
||||
'balance' => $balance,
|
||||
'status' => 1,
|
||||
'origin' => $origin,
|
||||
'oid'=>$oid,
|
||||
'appid' => $appid,
|
||||
'aid' => $oid,
|
||||
));
|
||||
$T['content'][] = '授权来源:'.GetOriginText($origin);
|
||||
$T['content'][] = '联系方式:QQ '.$uqq;
|
||||
$T['content'][] = '授权卡密:'.$newkey;
|
||||
$T['content'][] = '用户邮箱:'.$mail;
|
||||
$MailTips[] = $T;
|
||||
SendTipsMail($mail,$MailTips,$backinfo);
|
||||
return 3;
|
||||
}
|
||||
//续费授权
|
||||
if (!$userinfo = $db->select_first_row('sq_user', '*', array('username' => $username, 'appid' => $appid), 'AND')) {
|
||||
$tips = '授权卡密不存在';
|
||||
return -2;
|
||||
}
|
||||
$T['title'] = '您的授权卡密已续费成功!';
|
||||
$T['content'][] = '应用名称:'.$appinfo['appname'];
|
||||
$T['content'][] = '注册时间:'.Get_Date($userinfo['rtime']);
|
||||
if ($balance != '-1') {
|
||||
if ($appinfo['usetype'] == 'dqsj') {
|
||||
if ($userinfo['balance'] < time()) {
|
||||
$usernewinfo['balance'] = time() + $balance;
|
||||
} else {
|
||||
$usernewinfo['balance'] = $userinfo['balance'] + $balance;
|
||||
}
|
||||
$T['content'][] = '到期时间:'.Get_Date($usernewinfo['balance']);
|
||||
} else if ($appinfo['usetype'] == 'kcye') {
|
||||
$usernewinfo['balance'] = $userinfo['balance'] +$balance;
|
||||
$T['content'][] = '授权余额:'.Get_Date($usernewinfo['balance']);
|
||||
} else {
|
||||
$tips='应用使用方式设置异常';
|
||||
return -3;
|
||||
}
|
||||
} else {
|
||||
$usernewinfo['balance'] = '-1';
|
||||
$T['content'][] = $appinfo['usetype']=='dqsj' ? '到期时间:永久授权' : '开通余额:无限使用';
|
||||
}
|
||||
$T['content'][] = '授权来源:'.GetOriginText($origin);
|
||||
$T['content'][] = '联系方式:QQ '.$uqq;
|
||||
$T['content'][] = '授权卡密:'.$userinfo['username'];
|
||||
$T['content'][] = '用户邮箱:'.$userinfo['mail'];
|
||||
$MailTips[]= $T;
|
||||
$db->update('sq_user', array('username' => $username, 'appid' => $appinfo['ID']), 'AND', $usernewinfo);
|
||||
SendTipsMail($userinfo['mail'],$MailTips,$backinfo);
|
||||
return 2;
|
||||
} else if ($appinfo['logintype'] == 'jcbd') {
|
||||
$chect = json_decode($username,true);
|
||||
if ($appinfo['bindip'] == '1'){
|
||||
$search['lip'] = $chect['lip'];
|
||||
$T['content'][] = '绑定IP:'.$chect['lip'];
|
||||
}
|
||||
if ($appinfo['bindqq'] == '1'){
|
||||
$search['rqq'] = $chect['rqq'];
|
||||
$T['content'][] = '绑定QQ:'.$chect['rqq'];
|
||||
}
|
||||
if ($appinfo['bindmac'] == '1'){
|
||||
$search['mac'] = $chect['mac'];
|
||||
$T['content'][] = '绑定设备:'.$chect['mac'];
|
||||
}
|
||||
if (!isset($chect['lip'])){
|
||||
$chect['lip'] = '';
|
||||
}
|
||||
if (!isset($chect['rqq'])){
|
||||
$chect['rqq'] = '';
|
||||
}
|
||||
if (!isset($chect['mac'])){
|
||||
$chect['mac'] = '';
|
||||
}
|
||||
if (!$userinfo = $db->select_first_row('sq_user', '*', $search, 'AND')) {
|
||||
$T['title'] = '您的授权绑定已新开成功!';
|
||||
$T['content'][] = '应用名称:'.$appinfo['appname'];
|
||||
$T['content'][] = '注册时间:'.Get_Date();
|
||||
if ($appinfo['usetype']=='dqsj'){
|
||||
if ($balance!='-1'){
|
||||
$balance=time()+$balance;
|
||||
$T['content'][] = '到期时间:'.Get_Date($balance);
|
||||
}else{
|
||||
$T['content'][] = '到期时间:永久使用';
|
||||
}
|
||||
}else{
|
||||
if ($balance == '-1'){
|
||||
$T['content'][] = '开通余额:无限使用';
|
||||
}else{
|
||||
$T['content'][] = '开通余额:'.$balance;
|
||||
}
|
||||
}
|
||||
|
||||
$db->insert_back_id('sq_user', array(
|
||||
'mail' => $mail,
|
||||
'rtime' => time(),
|
||||
'balance' => $balance,
|
||||
'status' => 1,
|
||||
'appid' => $appid,
|
||||
'uqq' => $uqq,
|
||||
'mac' => $chect['mac'],
|
||||
'rqq' => $chect['rqq'],
|
||||
'rip' => $ip,
|
||||
'lip' => $chect['lip'],
|
||||
'aid' => $oid,
|
||||
'origin' => $origin,
|
||||
'oid'=>$oid,
|
||||
));
|
||||
|
||||
$T['content'][] = '授权来源:'.GetOriginText($origin);
|
||||
$T['content'][] = '联系方式:QQ '.$uqq;
|
||||
$T['content'][] = '用户邮箱:'.$mail;
|
||||
$MailTips[] = $T;
|
||||
SendTipsMail($mail,$MailTips,$backinfo);
|
||||
return 1;
|
||||
}
|
||||
|
||||
$T['title'] = '您的授权卡密已续费成功!';
|
||||
$T['content'][] = '应用名称:'.$appinfo['appname'];
|
||||
$T['content'][] = '注册时间:'.Get_Date($userinfo['rtime']);
|
||||
if ($balance != '-1') {
|
||||
if ($appinfo['usetype'] == 'dqsj') {
|
||||
if ($userinfo['balance'] < time()) {
|
||||
$usernewinfo['balance'] = time() + $balance;
|
||||
} else {
|
||||
$usernewinfo['balance'] = $userinfo['balance'] + $balance;
|
||||
}
|
||||
$T['content'][] = '到期时间:'.Get_Date($usernewinfo['balance']);
|
||||
} else if ($appinfo['usetype'] == 'kcye') {
|
||||
$usernewinfo['balance'] = $userinfo['balance'] +$balance;
|
||||
$T['content'][] = '授权余额:'.Get_Date($usernewinfo['balance']);
|
||||
} else {
|
||||
$tips='应用使用方式设置异常';
|
||||
return -3;
|
||||
}
|
||||
} else {
|
||||
$usernewinfo['balance'] = '-1';
|
||||
$T['content'][] = $appinfo['usetype']=='dqsj' ? '到期时间:永久授权' : '开通余额:无限使用';
|
||||
}
|
||||
|
||||
$T['content'][] = '授权来源:'.GetOriginText($origin);
|
||||
$T['content'][] = '联系方式:QQ '.$uqq;
|
||||
$T['content'][] = '用户邮箱:'.$userinfo['mail'];
|
||||
$MailTips[]= $T;
|
||||
$db->update('sq_user', $search, 'AND', $usernewinfo);
|
||||
SendTipsMail($userinfo['mail'],$MailTips,$backinfo);
|
||||
return 2;
|
||||
}
|
||||
$tips = '未知授权请求?';
|
||||
return -2;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: caidi
|
||||
* Date: 2017-10-18
|
||||
* Time: 22:28
|
||||
*/
|
||||
function show_page_404()
|
||||
{
|
||||
die('404 您访问的页面不存在!');
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
$SetName = array(
|
||||
'pay_domain'=>'',
|
||||
'epay_pid'=>'',
|
||||
'epay_key'=>'',
|
||||
'epay_againcheck'=>'0',
|
||||
'alipaytype'=>'0',
|
||||
'qqpaytype'=>'0',
|
||||
'wxpaytype'=>'0',
|
||||
'kqxt'=>'1',
|
||||
'yjtx'=>'1',
|
||||
'alipay_id'=>'',
|
||||
'alipay_rsa'=>'',
|
||||
'alipay_pkey'=>'',
|
||||
'tenpay_id'=>'',
|
||||
'qqpay_key'=>'',
|
||||
'sitename'=>'温泉PHP网络授权',
|
||||
'adminqq'=>'80071319',
|
||||
'adminmail'=>'80071319@qq.com',
|
||||
'beian'=>'',
|
||||
'weburl'=>(((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://').$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"],
|
||||
'smtp_address'=>'',
|
||||
'smtp_port'=>'',
|
||||
'smtp_user'=>'',
|
||||
'smtp_pass'=>'',
|
||||
'agentnotice'=>'欢迎使用温泉PHP网络授权系统の代理端,您可以在此充值、自助提卡、开通用户等操作,如有问题请联系本站客服处理。',
|
||||
'mainnav'=>'<a class="mdl-navigation__link" href="链接地址1">链接名称1</a> <a class="mdl-navigation__link" href="http://fkw.wenquan6.cn">温泉发卡网</a>',
|
||||
'sitekey'=>'',
|
||||
'xtsy'=>'1',
|
||||
'opencode'=>'false',
|
||||
'codevid'=>'',
|
||||
'codekey'=>'',
|
||||
'maindrawer'=>'',
|
||||
'token'=>'',
|
||||
'sid'=>'0',
|
||||
'stime'=>'0'
|
||||
);
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: 温泉
|
||||
* Date: 2019/2/17
|
||||
* Time: 11:47
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 订单处理
|
||||
* @param $tradeinfo
|
||||
* @return false|string
|
||||
*/
|
||||
function trade_do($tradeinfo){
|
||||
global $db;
|
||||
$MailTips[] = MakeTradeTips($tradeinfo);
|
||||
ignore_user_abort(true);//关闭浏览器继续处理,保证订单不会处理到一半就凉了
|
||||
if ($tradeinfo['type'] == '1') {
|
||||
//代理充值
|
||||
if (!$agentinfo = $db->select_first_row('sq_agent', '*', array('username' => $tradeinfo['user']), 'AND')) {
|
||||
return makejson(-101,'代理信息获取失败');
|
||||
}
|
||||
$newinfo['money'] = $agentinfo['money'] + $tradeinfo['paymoney'];
|
||||
$newinfo['allrecharge'] = $agentinfo['allrecharge'] + $tradeinfo['paymoney'];
|
||||
if (!$db->update('sq_agent', array('username' => $tradeinfo['user']), 'AND', $newinfo)) {
|
||||
return makejson(-102,'代理信息更新失败');
|
||||
}
|
||||
$db->insert_back_id('sq_log_agent', array('time' => time(), 'aid' => $agentinfo['ID'], 'ip' => get_real_ip(), 'msg' => '成功充值' . $tradeinfo['paymoney'] . '元,余额' . $newinfo['allrecharge']));
|
||||
return makejson(1,'充值余额成功!');
|
||||
}
|
||||
if ($tradeinfo['type'] == '2') {
|
||||
//代理开通商品
|
||||
if (!$fidinfo = $db->select_first_row('sq_fidlist', '*', array('ID' => $tradeinfo['fid']), 'AND')) {
|
||||
return makejson(-201,'商品信息拉取失败');
|
||||
}
|
||||
if (!$agentinfo = $db->select_first_row('sq_agent', '*', array('ID' => $tradeinfo['agentid']), 'AND')) {
|
||||
return makejson(-202,'代理信息拉取失败');
|
||||
}
|
||||
$allspend = $agentinfo['allspend'] + $tradeinfo['paymoney'];
|
||||
$db->update('sq_agent', array('ID' => $tradeinfo['agentid']), 'AND', array('allspend' => $allspend));
|
||||
include_once 'function_auth.php';
|
||||
$back = auth_add($tradeinfo['user'],$tradeinfo['pass'],$tradeinfo['ip'],$tradeinfo['num'] * $fidinfo['num'],$tradeinfo['uqq'],$tradeinfo['mail'],$fidinfo['appid'],4,$agentinfo['ID'],$newkey,$tips);
|
||||
if ($back == 1){
|
||||
return makejson(1,'授权新增成功');
|
||||
}else if ($back==2){
|
||||
return makejson(1,'授权续费成功');
|
||||
}else if ($back==3){
|
||||
return makejson(2,'成功生成卡密',array('kami'=>$newkey));
|
||||
}else{
|
||||
return makejson($back,$tips);
|
||||
}
|
||||
}
|
||||
if ($tradeinfo['type'] == '3') {
|
||||
//在线购买
|
||||
if (!$fidinfo = $db->select_first_row('sq_fidlist', '*', array('ID' => $tradeinfo['fid']), 'AND')) {
|
||||
return makejson(-301,'商品信息拉取失败');
|
||||
}
|
||||
include_once 'function_auth.php';
|
||||
$back = auth_add($tradeinfo['user'],$tradeinfo['pass'],$tradeinfo['ip'],$tradeinfo['num'] * $fidinfo['num'],$tradeinfo['uqq'],$tradeinfo['mail'],$fidinfo['appid'],2,$tradeinfo['ID'],$newkey,$tips);
|
||||
if ($back == 1){
|
||||
return makejson(1,'授权新增成功');
|
||||
}else if ($back==2){
|
||||
return makejson(1,'授权续费成功');
|
||||
}else if ($back==3){
|
||||
return makejson(2,'成功生成卡密',array('kami'=>$newkey));
|
||||
}else{
|
||||
return makejson($back,$tips);
|
||||
}
|
||||
}
|
||||
if ($tradeinfo['type'] == '4') {
|
||||
$nowtime = Get_Date();
|
||||
$db->insert_back_id('sq_agent', array('username' => $tradeinfo['user'], 'password' => $tradeinfo['pass'], 'begintime' => time(), 'levelid' => $tradeinfo['fid'], 'status' => 1, 'qq' => $tradeinfo['uqq']));
|
||||
$T['title'] = '您的代理已成功开通!';
|
||||
$T['content'][] = 'QQ:'.$tradeinfo['uqq'];
|
||||
$T['content'][] = '账号:'.$tradeinfo['user'];
|
||||
$T['content'][] = '时间:'.Get_Date();
|
||||
$T['content'][] = '等级:'.level_idgetname($tradeinfo['fid']);
|
||||
$MailTips[] = $T;
|
||||
SendTipsMail($tradeinfo['mail'],$MailTips,$back);
|
||||
return makejson(1,'代理开通成功');
|
||||
}
|
||||
return makejson(-404,'订单类型异常');
|
||||
}
|
||||
|
||||
function MakeTradeTips($tradeinfo){
|
||||
$T['title'] = '您的订单已成功处理!';
|
||||
$T['content'][] = '订单金额:'.$tradeinfo['paymoney'].' 元';
|
||||
switch ($tradeinfo['paytype']){
|
||||
case 'czkm':
|
||||
$T['content'][] = '支付方式:充值卡密';
|
||||
break;
|
||||
case 'yezf':
|
||||
$T['content'][] = '支付方式:代理余额';
|
||||
break;
|
||||
case 'zxzf':
|
||||
switch ($tradeinfo['onlinepaytype']){
|
||||
case 'zfb':
|
||||
$T['content'][] = '支付方式:在线支付-支付宝';
|
||||
break;
|
||||
case 'wx':
|
||||
$T['content'][] = '支付方式:在线支付-微信支付';
|
||||
break;
|
||||
case 'qq':
|
||||
$T['content'][] = '支付方式:在线支付-QQ钱包';
|
||||
break;
|
||||
default:
|
||||
$T['content'][] = '支付方式:在线支付-未知';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$T['content'][] = '支付方式:未知方式';
|
||||
}
|
||||
$T['content'][] = '订单名称:'.$tradeinfo['name'];
|
||||
$T['content'][] = '下单时间:'.Get_Date($tradeinfo['begintime']);
|
||||
$T['content'][] = '完成时间:'.Get_Date();
|
||||
$T['content'][] = '订单编号:'.$tradeinfo['tradeno'];
|
||||
return $T;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: 温泉
|
||||
* Date: 2018/8/20
|
||||
* Time: 0:58
|
||||
*/
|
||||
|
||||
$G['siteinfo']['ver'] = '12.1';
|
||||
Reference in New Issue
Block a user