forked from rakirizu/QuanAuth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax.php
1162 lines (1079 loc) · 50.7 KB
/
ajax.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Created by PhpStorm.
* User: 温泉
* Date: 2018/2/3
* Time: 13:24
*/
include "function/function_core.php";
error_reporting(E_ALL);
switch ($_GET['mod']) {
case 'buy_applist':
$back = $db->select_all_row('sq_apps', 'ID,appname', array(), 'AND');
if (count($back) === 0) {
die();
}
$i = '<option value="0">显示所有应用</option>';
foreach ($back as $value) {
$i .= '<option value="' . $value['ID'] . '">' . $value['appname'] . '</option>';
}
die($i);
break;
case 'loadbuylist':
include 'function/function_app.php';
$where = array();
$where['openbuy'] = '1';
if (!empty($_POST['loadbuylist']) && $_POST['loadbuylist'] != 0) {
$where['appid'] = intval($_POST['loadbuylist']);
}
//print_r($where);
if (!$result = $db->select_all_row('sq_fidlist', '*', $where, 'AND')) {
die('站长没有添加任何商品' . $db->geterror());
}
//print_r($result);
$info = '';
foreach ($result as $item) {
//echo '1';
if (!$appinfo = $db->select_first_row('sq_apps', 'appname,usetype,imgsrc,upurl', array('ID' => $item['appid']), 'AND')) {
echo $db->geterror();
continue;
}
//echo '2';
if ($item['num'] != '-1') {
if ($appinfo['usetype'] === 'dqsj') {
$numtip = '使用时长:' . time_last($item['num'] * 60);
} else {
$numtip = '充值点数:' . $item['num'] . '点';
}
} else {
if ($appinfo['usetype'] === 'dqsj') {
$numtip = '使用时长:无期授权';
} else {
$numtip = '充值点数:无限使用';
}
}
if (empty($appinfo['imgsrc'])) {
$appinfo['imgsrc'] = './mdl/dog.png';
}
$info .= '<div style="display: inline-block;padding: 10px;"><div class="demo-card-square mdl-card mdl-shadow--2dp">
<div class="mdl-card__title mdl-card--expand" style="color: #fff;text-shadow: #000 1px 1px 1px;background: url(' . $appinfo['imgsrc'] . ') top left no-repeat #46B6AC;background-size: 100% 100%;">
<h2 class="mdl-card__title-text">' . $item['fidname'] . '</h2>
</div>
<div class="mdl-card__supporting-text">
购买价格:' . $item['buyprice'] . '元<br>' . $numtip . '<br>应用名称:' . $appinfo['appname'] . '
</div>
<div class="mdl-card__actions mdl-card--border">
<button class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect" onclick="info(' . $item['appid'] . ')">
查看详情
</button>
<button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent" onclick="buy(' . $item['ID'] . ')">
立即购买
</button>
<button class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-js-ripple-effect" onclick="window.location.href=\'' . $appinfo['upurl'] . '\'">
下载应用
</button>
</div>
</div></div>';
}
die($info);
break;
case 'buy_first':
include "function/function_app.php";
$fidinfo = $db->select_first_row('sq_fidlist', '*', array('ID' => $_GET['fid']), 'AND');
$appinfo = app_idgetinfo($fidinfo['appid']);
$output = '<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="Material Design Lite">
<title>授权在线开通 - '.$G['config']['sitename'].'</title>
<link rel="stylesheet" href="./mdl/material.min.css">
<script src="https://v.vaptcha.com/v3.js"></script>
</head>
<body class="flat-blue landing-page">';
$output .= '<div id="submit_div" style="padding: 20px;">';
$output .= GetBuyFormHtml($appinfo,$type);
$output .= '<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width: 100%">
<label for="kt_num" class="mdl-textfield__label">开通数量(如果为永久系统默认为1,修改无效)</label>
<input class="mdl-textfield__input" id="kt_num" value="1" type="text">
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width: 100%">
<label for="kt_mail" class="mdl-textfield__label">请输入主人QQ,我们将通过此QQ联系您</label>
<input class="mdl-textfield__input" id="kt_adminqq" onkeyup="dofill()" type="text">
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width: 100%">
<label for="kt_mail" class="mdl-textfield__label">请输入您的邮箱</label>
<input class="mdl-textfield__input" id="kt_mail" type="text">
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width: 100%">
请选择您的支付方式:
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="radio4">
<input type="radio" id="radio4" class="mdl-radio__button" name="zffs" value="zxzf" onclick="$(\'#show_kmcz\').hide();$(\'#show_zxzf\').show();" checked>
<span class="mdl-radio__label">在线支付</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="radio5" >
<input type="radio" id="radio5" class="mdl-radio__button" name="zffs" value="czkm" onclick="$(\'#show_kmcz\').show();$(\'#show_zxzf\').hide();">
<span class="mdl-radio__label">余额卡密</span>
</label>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" id="show_kmcz" style="width: 100%">
<label for="kt_key" class="mdl-textfield__label">请输入卡密</label>
<input class="mdl-textfield__input" id="kt_key" type="text">
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" id="show_zxzf" style="width: 100%">
请选择在线支付方式:
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="radio6" >
<input type="radio" id="radio6" class="mdl-radio__button" name="zxzffs" value="zfb" checked>
<span class="mdl-radio__label">支付宝</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="radio7" >
<input type="radio" id="radio7" class="mdl-radio__button" name="zxzffs" value="wx">
<span class="mdl-radio__label">微信支付</span>
</label>
<label class="mdl-radio mdl-js-radio mdl-js-ripple-effect" for="radio8" >
<input type="radio" id="radio8" class="mdl-radio__button" name="zxzffs" value="qq">
<span class="mdl-radio__label">QQ钱包</span>
</label>
</div>
<div id="vaptchaContainer" class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width: 100%">
</div><br><br>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width: 100%">
<button type="button" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent" onclick="buy_submit(' . $_GET['fid'] . ',' . $type . ');" style="width: 100%">立即开通</button>
</div>
</div>
<script src="./static/jquery-3.3.1.js"></script>
<script type="text/javascript" src="./static/frame/layui/layui.js"></script>
<script>layui.use([\'layer\'],function () {var layer = layui.layer; $.ajax({
url: \'./function/GetVerification.php\',
type: \'GET\',
dataType: \'html\',
success: function(data){
$(\'#vaptchaContainer\').html(data);
},
error: function(data){
layer.msg(\'[\'+data.status+\']\'+data.statusText);
}
});});
function buy_submit(id,type) {
var loading = layer.load();
if (type === 1){
//账号密码登陆
var kt_user= $("#kt_user").val();
var kt_pass= $("#kt_pass").val();
var kt_varinfo = \'&kt_user=\'+encodeURI(kt_user)+\'&kt_pass=\'+kt_pass;
}else if (type === 2){
//卡密授权
var kt_kami= $("#kt_user").val();
var kt_varinfo = \'&kt_user=\'+encodeURI(kt_kami);
var kt_kaminum= $("#kt_keysnum").val();
}else if (type === 3){
//检查绑定
var kt_robotqq= $("#kt_robotqq").val();
var kt_mac= $("#kt_mac").val();
var kt_ip= $("#kt_ip").val();
var kt_varinfo = \'&kt_robotqq=\'+kt_robotqq+\'&kt_mac=\'+kt_mac+\'&kt_ip=\'+encodeURI(kt_ip);
}
var kt_num= $("#kt_num").val();
var kt_adminqq= $("#kt_adminqq").val();
var kt_mail= $("#kt_mail").val();
var zffs = $(\'input:radio[name="zffs"]:checked\').val();
var zxzffs = $(\'input:radio[name="zxzffs"]:checked\').val();
var kt_key= $("#kt_key").val();
var token =\'\';
if (typeof vaptchaObj != \'undefined\'){
token = vaptchaObj.getToken();
vaptchaObj.reset();
}
$.ajax({
url: \'ajax.php?mod=buy_submit\',
type: \'POST\',
dataType: \'json\',
data: \'id=\'+id+kt_varinfo+\'&kt_num=\'+kt_num+\'&kt_mail=\'+kt_mail+\'&zffs=\'+zffs+\'&zxzffs=\'+zxzffs+\'&kt_key=\'+kt_key+\'&type=\'+type+\'&kt_adminqq=\'+kt_adminqq+\'&token=\'+token,
success: function(data){
layer.close(loading);
if(data.code === \'1\'){
layer.confirm(data.info, {
btn: [\'立即付款\',\'关闭\'] //按钮
}, function(){
window.open(\'payment.php?tradeno=\'+data.tradeno);
layer.closeAll();
layer.confirm(\'请在新打开的窗口中进行付款!\', {
btn: [\'已付款\',\'关闭\'] //按钮
}, function(){
window.open(\'payresult.php?tradeno=\'+data.tradeno);
});
});
}else{
layer.msg(data.msg);
}
},
error: function(data){
layer.close(loading);
layer.msg(\'请求失败\'+data);
}
})
}
function dofill() {
var value= $(\'#kt_adminqq\').val()+\'@qq.com\';
//alert(value);
$(\'#kt_mail\').val(value)
}
</script>
<script src="./mdl/material.min.js"></script>
<!-- /.container -->
<script>$(\'#show_kmcz\').hide();$(\'#show_zxzf\').show();</script>
</body>
</html>
';
die($output);
break;
case 'buy_agent':
include './function/VerificationCode.class.php';
$verification = Verification::check($_POST['token']);
if ($verification !== true) {
die(json_encode(array('code' => '-88', 'msg' => '请先进行人机验证')));
}
if (empty($_POST['lid'])) {
die(json_encode(array('code' => -2, 'msg' => '请选择一个级别')));
}
if (empty($_POST['username'])) {
die(json_encode(array('code' => -3, 'msg' => '请输入用户名,用户名和密码是您登陆代理后台的唯一凭证!')));
}
if (empty($_POST['password'])) {
die(json_encode(array('code' => -4, 'msg' => '请输入您的密码,用户名和密码是您登陆代理后台的唯一凭证!')));
}
if (empty($_POST['qq'])) {
die(json_encode(array('code' => -5, 'msg' => '请输入您的QQ')));
}
if (!$levelinfo = $db->select_first_row('sq_level', 'lname,price', array('ID' => $_POST['lid']), 'AND')) {
die(json_encode(array('code' => -5, 'msg' => '无法找到该代理等级')));
}
if ($levelinfo['price'] <= 0) {
die(json_encode(array('code' => -6, 'msg' => '该代理等级不允许在线开通')));
}
if ($db->select_first_row('sq_agent', 'ID', array('username' => $_POST['username']), '') != false) {
die(json_encode(array('code' => -6, 'msg' => '用户名重复,请尝试其他用户名')));
}
$time = time();
$tradno = $time . rand_str(10, 'num');
$money = $levelinfo['price'];
$tips = '您正在开通新代理,请确认以下信息:<br>';
$tips .= '交易订单号:' . $tradno . '<br>';
$tips .= '正在开通等级:' . $levelinfo['lname'] . '<br>';
$tips .= '代理用户名:' . $_POST['username'] . '<br>';
$tips .= '代理代理密码:' . $_POST['password'] . '<br>';
$tips .= '代理QQ:' . $_POST['qq'] . '<br>';
$tips .= '应付金额:' . $levelinfo['price'] . '<br>';
if ($_POST['zffs'] == 'zxzf') {
$tips .= '付款方式:在线支付<br>';
switch ($_POST['zxzffs']) {
case 'zfb':
$tips .= '支付方式:支付宝<br>';
break;
case 'wx':
$tips .= '支付方式:微信<br>';
break;
case 'qq':
$tips .= '支付方式:QQ钱包<br>';
break;
default:
die(json_encode(array('code' => -7, 'msg' => '错误的付款方式')));
}
} else if ($_POST['zffs'] == 'czkm') {
$tips .= '付款方式:余额卡密<br>';
if (empty($_POST['kt_key'])) {
die(json_encode(array('code' => -8, 'msg' => '余额卡密不能为空')));
}
$tips .= '正在使用的卡密:' . $_POST['kt_key'] . '<br>';
} else {
die(json_encode(array('code' => -5, 'msg' => '错误的支付方式')));
}
$newtrade = array('name' => $levelinfo['lname'],
'tradeno' => $tradno,
'begintime' => $time,
'user' => $_POST['username'],
'pass' => $_POST['password'],
'fid' => $_POST['lid'],
'num' => 1,
'paymoney' => $money,
'mail' => $_POST['qq'] . '@qq.com',
'paytype' => $_POST['zffs'],
'onlinepaytype' => $_POST['zxzffs'],
'kami' => $_POST['kt_key'],
'uqq' => $_POST['qq'],
'ip' => get_real_ip(),
'status' => '1',
'type' => 4
);
$db->insert_back_id('sq_trade', $newtrade);
die(json_encode(array('code' => '1', 'tradeno' => $tradno, 'info' => $tips)));
break;
case 'buy_submit':
include './function/VerificationCode.class.php';
$verification = Verification::check($_POST['token']);
if ($verification !== true) {
die(json_encode(array('code' => '-88', 'msg' => '请先进行人机验证')));
}
include 'function/function_app.php';
if (empty($_POST['kt_key'])) {
$_POST['kt_key'] = '无';
}
if (!$fidinfo = $db->select_first_row('sq_fidlist', '*', array('ID' => $_POST['id']), 'AND')) {
die(json_encode(array('code' => -2, 'msg' => '无法找到该商品,请刷新页面重试')));
}
if (!$appinfo = app_idgetinfo($fidinfo['appid'])) {
die(json_encode(array('code' => -2, 'msg' => '无法找到应用,也许是该应用已下架')));
}
if ($fidinfo['num'] == -1 && $_POST['kt_num'] != 1) {
die(json_encode(array('code' => '-3', 'msg' => '此套餐包含的授权时长为永久,请固定开通数量为1')));
}
if ($_POST['kt_num'] <= 0 || $_POST['kt_num'] >= 10) {
die(json_encode(array('code' => '-4', 'msg' => '开通数量填写错误,开通数量必须为1-10之间')));
}
$time = time();
$tradno = $time . rand_str(10, 'num');
$tips = '交易订单号:' . $tradno . '<br>';
$spendmoney = $fidinfo['buyprice'] * $_POST['kt_num'];
$tips .= '应付金额:' . $spendmoney . '<br>';
if ($spendmoney <= 0) {
die(json_encode(array('code' => -7, 'msg' => '错误的支付金额:' . $spendmoney)));
}
if ($_POST['type'] == '1') {
if (empty($_POST['kt_user'])) {
die(json_encode(array('code' => -13, 'msg' => '用户名不能为空!')));
}
if (empty($_POST['kt_pass'])) {
die(json_encode(array('code' => -14, 'msg' => '密码不能为空!')));
}
if (!$userinfo = $db->select_first_row('sq_user', '*', array('username' => $_POST['kt_user'], 'appid' => $fidinfo['appid']), 'AND')) {
} else {
if ($_POST['kt_pass'] !== $userinfo['password']) {
die(json_encode(array('code' => -2, 'msg' => '您的用户名已开通,您需要输入的正确密码才能进行续费,当前输入的用户密码错误!')));
}
}
$tips .= '开通用户名:' . $_POST['kt_user'] . '<br>';
$newtrade = array('name' => $fidinfo['fidname'],
'tradeno' => $tradno,
'begintime' => $time,
'user' => $_POST['kt_user'],
'pass' => $_POST['kt_pass'],
'fid' => $_POST['id'],
'num' => $_POST['kt_num'],
'paymoney' => $spendmoney,
'mail' => $_POST['kt_mail'],
'paytype' => $_POST['zffs'],
'onlinepaytype' => $_POST['zxzffs'],
'kami' => $_POST['kt_key'],
'uqq' => $_POST['kt_adminqq'],
'ip' => get_real_ip(),
'status' => '1',
'type' => 3
);
} else if ($_POST['type'] == '2') {
//卡密方式
if (!$userinfo = $db->select_first_row('sq_user', '*', array('username' => $_POST['kt_user'], 'appid' => $fidinfo['appid']), 'AND')) {
$userkey = $userinfo['username'];
$tips .= '开通方式:新开卡密<br>';
} else {
$userkey = '';
$tips .= '开通方式:续费卡密(' . $_POST['kt_user'] . ')<br>';
}
$newtrade = array(
'user'=>$_POST['kt_user'],
'name' => $fidinfo['fidname'],
'tradeno' => $tradno,
'begintime' => $time,
'fid' => $_POST['id'],
'num' => $_POST['kt_num'],
'paymoney' => $spendmoney,
'mail' => $_POST['kt_mail'],
'paytype' => $_POST['zffs'],
'onlinepaytype' => $_POST['zxzffs'],
'uqq' => $_POST['kt_adminqq'],
'kami' => $_POST['kt_key'],
'ip' => get_real_ip(),
'status' => '1',
'type' => 3
);
} else {
//检查绑定
$tips_ = '';
if ($appinfo['bindip'] == '1') {
$check['lip'] = $_POST['kt_ip'];
if (empty($_POST['kt_ip']) || $_POST['kt_ip'] == 'undefined') {
die(json_encode(array('code' => -10, 'msg' => '绑定的IP不能为空')));
}
$tips_ .= '绑定IP:' . $check['lip'] . '<br>';
}
if ($appinfo['bindmac'] == '1') {
$check['mac'] = $_POST['kt_mac'];
if (empty($_POST['kt_mac']) || $_POST['kt_mac'] == 'undefined') {
die(json_encode(array('code' => -10, 'msg' => '绑定的机器不能为空')));
}
$tips_ .= '绑定机器:' . $check['mac'] . '<br>';
}
if ($appinfo['bindqq'] == '1') {
$check['rqq'] = $_POST['kt_robotqq'];
if (empty($_POST['kt_robotqq']) || $_POST['kt_robotqq'] == 'undefined') {
die(json_encode(array('code' => -10, 'msg' => '绑定的机器人QQ不能为空')));
}
$tips_ .= '绑定QQ:' . $check['rqq'] . '<br>';
}
//$check['appid'] = $appinfo['ID'];
if (empty($check)) {
die(json_encode(array('code' => -10, 'msg' => '系统内部错误(应用绑定信息配置异常),请联系管理员解决')));
}
$newtrade = array('name' => $fidinfo['fidname'],
'tradeno' => $tradno,
'begintime' => $time,
'user' => json_encode($check),
'fid' => $_POST['id'],
'num' => $_POST['kt_num'],
'paymoney' => $spendmoney,
'mail' => $_POST['kt_mail'],
'paytype' => $_POST['zffs'],
'onlinepaytype' => $_POST['zxzffs'],
'kami' => $_POST['kt_key'],
'ip' => get_real_ip(),
'status' => '1',
'uqq' => $_POST['kt_adminqq'],
'type' => 3
);
if (!$userinfo = $db->select_first_row('sq_user', '*', $check, 'AND')) {
$tips .= '开通方式:新开授权<br>绑定信息如下:<br>' . $tips_ . '<br><br>';
} else {
$tips .= '开通方式:续费授权<br>绑定信息如下:<br>' . $tips_ . '<br><br>';
}
}
if (empty($userinfo['balance'])) {
$userinfo['balance'] = 0;
}
$tips .= '正在开通套餐:' . $fidinfo['fidname'] . '<br>';
if ($appinfo['usetype'] === 'dqsj') {
if (empty($userinfo['balance']) || $userinfo['balance'] == 0) {
$tips .= '您目前到期时间:无<br>';
$userinfo['balance'] = time();
} else {
$tips .= '您目前到期时间:' . Get_Date($userinfo['balance']) . '<br>';
}
$tips .= '新增时长:' . time_last($fidinfo['num'] * $_POST['kt_num'] * 60) . '<br>';
} else {
$tips .= '用户剩余点数:' . $userinfo['balance'] . '点<br>';
$tips .= '购买后点数:' . ($userinfo['balance'] + $fidinfo['num'] * $_POST['kt_num']) . '点<br>';
}
if ($_POST['zffs'] == 'zxzf') {
$tips .= '付款方式:在线支付<br>';
switch ($_POST['zxzffs']) {
case 'zfb':
$tips .= '支付方式:支付宝<br>';
break;
case 'wx':
$tips .= '支付方式:微信<br>';
break;
case 'qq':
$tips .= '支付方式:QQ钱包<br>';
break;
default:
die(json_encode(array('code' => -5, 'msg' => '错误的付款方式')));
}
} else if ($_POST['zffs'] == 'czkm') {
if ($fidinfo['allrechargecard'] != 1) {
die(json_encode(array('code' => -5, 'msg' => '本套餐不支持使用卡密支付')));
}
$tips .= '付款方式:余额卡密<br>';
$tips .= '正在使用的卡密:' . $_POST['kt_key'] . '<br>';
} else {
die(json_encode(array('code' => -5, 'msg' => '错误的支付方式')));
}
$tips .= '注意:请认真核对信息,付款后一律不支持退款!<br>';
if (!$db->insert_back_id('sq_trade', $newtrade)) {
die(json_encode(array('code' => -3, 'msg' => '系统错误:' . $db->geterror())));
} else {
die(json_encode(array('code' => '1', 'tradeno' => $tradno, 'info' => $tips)));
}
break;
case 'introduce':
if (!$appinfo = $db->select_first_row('sq_apps', 'introduce', array('ID' => $_GET['appid']), 'AND')) {
die('服务器内部错误');
} else {
if (empty($appinfo['introduce'])){
die('管理员没有写任何详情 :(');
}
die($appinfo['introduce']);
}
break;
case 'queryauth':
include './function/VerificationCode.class.php';
$verification = Verification::check($_POST['token']);
if ($verification !== true) {
die(json_encode(array('code' => '-88', 'msg' => '请先进行人机验证')));
}
if($result = $db->select_first_row('sq_bclist','*',array('obj'=>$_POST['qq']),'AND')){
if ($result['appid'] != 0){
include_once 'function/function_app.php';
$app = app_idgetname($result['appid']);
}else{
$app = '所有应用';
}
die('查询对象属于云黑名单中!<br>原因:'.$result['reason'].'<br>拉黑应用:'.$app);
}
$_POST['qq'] = intval($_POST['qq']);
if (empty($_POST['qq'])) {
die('查询的QQ号码不能为空');
}
$info = $db->select_all_row('sq_agent', 'begintime,levelid,qq', array('qq' => $_POST['qq'], 'status' => 1), 'AND');
include 'function/function_app.php';
if (!is_array($info) || count($info) == 0) {
echo('QQ' . $_POST['qq'] . '没有查询到任何代理信息' . '<br>');
} else {
foreach ($info as $qqinfo) {
echo '代理QQ:' . $qqinfo['qq'] . '<br>';
echo '开通时间:' . Get_Date($qqinfo['begintime']) . '<br>';
$levelinfo = $db->select_first_row('sq_level', '*', array('ID' => $qqinfo['levelid']), 'AND');
echo '代理级别:' . $levelinfo['lname'] . '<br>';
$array = explode(',', $levelinfo['appid']);
$appname = '';
foreach ($array as $appid) {
if (!empty($appname)) {
$appname .= ',' . app_idgetname($appid);
} else {
$appname = app_idgetname($appid);
}
}
echo '所属应用:' . $appname;
echo '<hr>';
}
}
$info = $db->select_all_row('sq_user', 'uqq,rqq,rtime,balance,appid,aid', array('uqq' => $_POST['qq'], 'rqq' => $_POST['qq']), 'OR');
if (!is_array($info) || count($info) == 0) {
die('QQ' . $_POST['qq'] . '没有查询到任何授权信息');
}
foreach ($info as $qqinfo) {
echo '用户QQ:' . $qqinfo['uqq'] . '<br>';
echo '机器人QQ:' . $qqinfo['rqq'] . '<br>';
echo '开通时间:' . Get_Date($qqinfo['rtime']) . '<br>';
$appinfo = app_idgetinfo($qqinfo['appid']);
echo '所属应用:' . $appinfo['appname'] . '<br>';
if ($appinfo['usetype'] == 'dqsj') {
if ($qqinfo['balance'] == '-1') {
echo '到期时间:永久授权<br>';
} else {
echo '到期时间:' . Get_Date($qqinfo['balance']) . '<br>';
}
} else if ($appinfo['usetype'] == 'kcye') {
echo '剩余余额:' . $qqinfo['balance'] . '<br>';
}
if ($qqinfo['aid'] != 0) {
$agentinfo = $db->select_first_row('sq_agent', 'username', array('ID' => $qqinfo['aid']), 'AND');
echo '开通代理:' . $agentinfo['username'] . '<br>';
}
echo '<hr>';
}
die();
case 'levellist':
$info = $db->select_all_row('sq_level', 'ID,lname', 'price<>0', '', '');
$i = '';
foreach ($info as $value) {
$i .= '<option value="' . $value['ID'] . '">' . $value['lname'] . '</option>';
}
die($i);
break;
case 'FieldKamiOpen_First':
include './function/VerificationCode.class.php';
$verification = Verification::check($_GET['token']);
if ($verification !== true) {
die(json_encode(array('code' => '-88', 'msg' => '请先进行人机验证')));
}
if (!$info = $db->select_first_row('sq_fidkey','*',array('kami'=>$_GET['kami']),'AND')) die('卡密不存在');
if ($info['status'] != 1) die('卡密已被冻结');
if ( !empty($info['user']) || !empty($info['usetime'])) die('卡密已被使用');
if (!$fidinfo = $db->select_first_row('sq_fidlist','fidname,appid',array('ID'=>$info['fid']),'AND'))die('无法找到对应套餐,请联系管理员处理');
include "function/function_app.php";
$appinfo = app_idgetinfo($fidinfo['appid']);
$output = '<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="Material Design Lite">
<title>使用卡密'.$_GET['kami'].' - '.$G['config']['sitename'].'</title>
<link rel="stylesheet" href="./mdl/material.min.css">
<script src="https://v.vaptcha.com/v3.js"></script>
</head>
<body class="flat-blue landing-page">';
$output .= '<div id="submit_div" style="padding: 20px;">';
$output .= GetBuyFormHtml($appinfo,$type);
$output .= '
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width: 100%">
<label for="kt_mail" class="mdl-textfield__label">请输入您的邮箱</label>
<input class="mdl-textfield__input" id="kt_mail" type="text">
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width: 100%">
<label for="kt_mail" class="mdl-textfield__label">请输入主人QQ,我们将通过此QQ联系您</label>
<input class="mdl-textfield__input" id="kt_adminqq" type="text">
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" id="show_kmcz" style="width: 100%" hidden>
<label for="kt_key" class="mdl-textfield__label">请输入卡密</label>
<input class="mdl-textfield__input" id="kt_key" type="text" value="'.$_GET['kami'].'">
</div>
<div id="vaptchaContainer" class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"
style="width: 95%">
</div>
<br><br>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width: 100%">
<button type="button" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent" onclick="buy_submit(' . $info['fid'] . ',' . $type . ');" style="width: 100%">立即开通</button>
</div>
</div>
<script src="./static/jquery-3.3.1.js"></script>
<script type="text/javascript" src="./static/frame/layui/layui.js"></script>
<script>
layui.use([\'layer\'],function () {
var layer = layui.layer;
$.ajax({
url: \'./function/GetVerification.php\',
type: \'GET\',
dataType: \'html\',
success: function(data){
$(\'#vaptchaContainer\').html(data);
},
error: function(data){
layer.msg(\'[\'+data.status+\']\'+data.statusText);
}
});
});
function buy_submit(id,type) {
var loading = layer.load();
if (type === 1){
//账号密码登陆
var kt_user= $("#kt_user").val();
var kt_pass= $("#kt_pass").val();
var kt_varinfo = \'&kt_user=\'+encodeURI(kt_user)+\'&kt_pass=\'+kt_pass;
}else if (type === 2){
//卡密授权
var kt_kami= $("#kt_user").val();
var kt_varinfo = \'&kt_user=\'+encodeURI(kt_kami);
var kt_kaminum= $("#kt_keysnum").val();
}else if (type === 3){
//检查绑定
var kt_robotqq= $("#kt_robotqq").val();
var kt_mac= $("#kt_mac").val();
var kt_ip= $("#kt_ip").val();
var kt_varinfo = \'&kt_robotqq=\'+kt_robotqq+\'&kt_mac=\'+kt_mac+\'&kt_ip=\'+encodeURI(kt_ip);
}
var kt_adminqq= $("#kt_adminqq").val();
var kt_mail= $("#kt_mail").val();
var kt_key= $("#kt_key").val();
var token = \'\';
if (typeof vaptchaObj != \'undefined\'){
token = vaptchaObj.getToken();
vaptchaObj.reset();
}
$.ajax({
url: \'ajax.php?mod=FieldKeyBuy_submit\',
type: \'POST\',
dataType: \'json\',
data: \'id=\'+id+kt_varinfo+\'&kt_mail=\'+kt_mail+\'&kt_key=\'+kt_key+\'&type=\'+type+\'&kt_adminqq=\'+kt_adminqq+\'&token=\'+token,
success: function(data){
layer.close(loading);
layer.alert(data.msg);
},
error: function(data){
layer.close(loading);
layer.msg(\'请求失败\'+data);
}
})
}
</script>
<script src="./mdl/material.min.js"></script>
<!-- /.container -->
<script>$(\'#show_kmcz\').hide();$(\'#show_zxzf\').show();</script>
</body>
</html>
';
die($output);
break;
case 'FieldKeyBuy_submit':
error_reporting(E_ALL);
include './function/VerificationCode.class.php';
$verification = Verification::check($_POST['token']);
if ($verification !== true) {
die(json_encode(array('code' => '-88', 'msg' => '请先进行人机验证')));
}
if (!$info = $db->select_first_row('sq_fidkey','*',array('kami'=>$_POST['kt_key']),'AND')) die(json_encode(array('code' => '-1', 'msg' => '卡密不存在')));;
if ($info['status'] != 1) die(json_encode(array('code' => '-101', 'msg' => '卡密已被冻结')));
if ( !empty($info['user']) || !empty($info['usetime'])) die(json_encode(array('code' => '-102', 'msg' => '卡密已被使用')));
if (!$fidinfo = $db->select_first_row('sq_fidlist','*',array('ID'=>$info['fid']),'AND'))die(json_encode(array('code' => '-201', 'msg' => '套餐无法找到,请联系管理员')));;
$tips='';
include 'function/function_app.php';
if (!$appinfo = app_idgetinfo($fidinfo['appid'])) {
die(json_encode(array('code' => -2, 'msg' => '无法找到应用,也许是该应用已下架')));
}
$spendmoney = 0;
$time = time();
if ($_POST['type'] == '1') {
if (empty($_POST['kt_user'])) {
die(json_encode(array('code' => -13, 'msg' => '用户名不能为空!')));
}
if (empty($_POST['kt_pass'])) {
die(json_encode(array('code' => -14, 'msg' => '密码不能为空!')));
}
if (!$userinfo = $db->select_first_row('sq_user', '*', array('username' => $_POST['kt_user'], 'appid' => $fidinfo['appid']), 'AND')) {
} else {
if ($_POST['kt_pass'] !== $userinfo['password']) {
die(json_encode(array('code' => -2, 'msg' => '用户密码错误!')));
}
}
$tips .= '开通用户名:' . $_POST['kt_user'] . '<br>';
$newtrade = array('name' => $fidinfo['fidname'],
'begintime' => $time,
'user' => $_POST['kt_user'],
'pass' => $_POST['kt_pass'],
'fid' => $_POST['id'],
'mail' => $_POST['kt_mail'],
'kami' => $_POST['kt_key'],
'uqq' => $_POST['kt_adminqq'],
'ip' => get_real_ip(),
'status' => '1',
'type' => 3,
);
} else if ($_POST['type'] == '2') {
//卡密方式
if (!$userinfo = $db->select_first_row('sq_user', '*', array('username' => $_POST['kt_user'], 'appid' => $fidinfo['appid']), 'AND')) {
$userkey = $userinfo['username'];
$tips .= '开通方式:新开卡密<br>';
} else {
$userkey = '';
$tips .= '开通方式:续费卡密(' . $_POST['kt_user'] . ')<br>';
}
$newtrade = array('name' => $fidinfo['fidname'],
'tradeno' => $tradno,
'begintime' => $time,
'user' => $_POST['kt_user'],
'fid' => $_POST['id'],
'paymoney' => $spendmoney,
'mail' => $_POST['kt_mail'],
'paytype' => 'tck',
'onlinepaytype' => '',
'uqq' => $_POST['kt_adminqq'],
'kami' => $_POST['kt_key'],
'ip' => get_real_ip(),
'status' => '1',
'type' => 3,
'pass'=>''
);
} else {
//检查绑定
$tips_ = '';
if ($appinfo['bindip'] == '1') {
$check['lip'] = $_POST['kt_ip'];
if (empty($_POST['kt_ip']) || $_POST['kt_ip'] == 'undefined') {
die(json_encode(array('code' => -10, 'msg' => '绑定的IP不能为空')));
}
$tips_ .= '绑定IP:' . $check['lip'] . '<br>';
}
if ($appinfo['bindmac'] == '1') {
$check['mac'] = $_POST['kt_mac'];
if (empty($_POST['kt_mac']) || $_POST['kt_mac'] == 'undefined') {
die(json_encode(array('code' => -10, 'msg' => '绑定的机器不能为空')));
}
$tips_ .= '绑定机器:' . $check['mac'] . '<br>';
}
if ($appinfo['bindqq'] == '1') {
$check['rqq'] = $_POST['kt_robotqq'];
if (empty($_POST['kt_robotqq']) || $_POST['kt_robotqq'] == 'undefined') {
die(json_encode(array('code' => -10, 'msg' => '绑定的机器人QQ不能为空')));
}
$tips_ .= '绑定QQ:' . $check['rqq'] . '<br>';
}
//$check['appid'] = $appinfo['ID'];
if (empty($check)) {
die(json_encode(array('code' => -10, 'msg' => '系统内部错误(应用绑定信息配置异常),请联系管理员解决')));
}
$tradno = $time . rand_str(10, 'num');
$newtrade = array('name' => $fidinfo['fidname'],
'tradeno' => $tradno,
'begintime' => $time,
'user' => json_encode($check),
'fid' => $_POST['id'],
'paymoney' => $spendmoney,
'mail' => $_POST['kt_mail'],
'paytype' => 'tck',
'onlinepaytype' => '',
'kami' => $_POST['kt_key'],
'ip' => get_real_ip(),
'status' => '1',
'uqq' => $_POST['kt_adminqq'],
'type' => 3,
'pass'=>''
);
if (!$userinfo = $db->select_first_row('sq_user', '*', $check, 'AND')) {
$tips .= '开通方式:新开授权<br>绑定信息如下:<br>' . $tips_ . '<br><br>';
} else {
$tips .= '开通方式:续费授权<br>绑定信息如下:<br>' . $tips_ . '<br><br>';
}
}
//$newtrade['ID'] = $db->insert_back_id('sq_trade', $newtrade);
include_once './function/function_auth.php';
$back = auth_add($newtrade['user'],$newtrade['pass'],$newtrade['ip'], $fidinfo['num'],$newtrade['uqq'],$newtrade['mail'],$fidinfo['appid'],3,$info['ID'],$info['aid'],$newkey,$tips,$newtrade);
$db->update('sq_fidkey',array('ID'=>$info['ID']),'AND',array('usetime'=>time(),'user'=>$newtrade['user']));
if ($back == 1){
die(makejson(1,$tips.'授权新开成功!'));
}else if ($back==2){
die(makejson(1,$tips.'授权续费成功!'));
}else if ($back==3){
die(makejson(2,'授权登录卡密生成成功,请使用此卡密登录授权:'.$newkey));
}else{
die(makejson($back,$tips));
}
break;
case 'changegetform':
include './function/function_app.php';
if(!$appinfo = app_idgetinfo(intval($_POST['appid']))){
die('');
}
$output = '';
if ($appinfo['logintype'] == 'zhmm') {
$output .= '
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width: 100%">
<label for="kt_user" class="mdl-textfield__label">请输入您的账号</label>
<input class="mdl-textfield__input" id="kt_user" type="text">
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width: 100%">
<label for="kt_pass" class="mdl-textfield__label">请输入您的密码</label>
<input class="mdl-textfield__input" id="kt_pass" type="password">
</div>
';
$type = 1;
} else if ($appinfo['logintype'] == 'kmsq') {
$output .= '
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width: 100%">
<label for="kt_user" class="mdl-textfield__label">请输入授权登录卡密</label>
<input class="mdl-textfield__input" id="kt_user" type="text">
</div>';
$type = 2;
}else if ($appinfo['logintype'] == 'jcbd') {
if ($appinfo['bindqq'] == '1') {
$output .= '
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width: 100%">
<label for="kt_robotqq" class="mdl-textfield__label">原机器人QQ</label>
<input class="mdl-textfield__input" id="kt_robotqq" type="text">
</div>
';
}
if ($appinfo['bindmac'] == '1') {
$output .= '<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width: 100%">
<label for="kt_mac" class="mdl-textfield__label">原设备码</label>
<input class="mdl-textfield__input" id="kt_mac" type="text">
</div>
';
}
if ($appinfo['bindip'] == '1') {
$output .= '<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width: 100%">
<label for="kt_ip" class="mdl-textfield__label">原IP地址</label>
<input class="mdl-textfield__input" id="kt_ip" type="text">
</div>
';
}
$type = 3;
} else {
die('未知授权方式:' . $appinfo['logintype']);
}
$check = false;
if ($appinfo['bindqq'] == '1') {
$check = true;
$output .= '
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width: 100%">
<label for="cg_robotqq" class="mdl-textfield__label">新机器人QQ</label>
<input class="mdl-textfield__input" id="cg_robotqq" type="text">
</div>
';
}
if ($appinfo['bindmac'] == '1') {
$check = true;
$output .= '<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width: 100%">
<label for="cg_mac" class="mdl-textfield__label">新设备码</label>
<input class="mdl-textfield__input" id="cg_mac" type="text">
</div>
';
}
if ($appinfo['bindip'] == '1') {
$check = true;
$output .= '<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="width: 100%">
<label for="cg_ip" class="mdl-textfield__label">新IP地址</label>
<input class="mdl-textfield__input" id="cg_ip" type="text">
</div>
';
}
if(!$check){
die('<script>layer.alert("当前应用未绑定任何数据")</script>');
}
die($output);
break;
case 'ChangeGetVerCode':
include './function/VerificationCode.class.php';
$verification = Verification::check($_POST['token']);
if ($verification !== true) {
die(json_encode(array('code' => '-88', 'msg' => '请先进行人机验证')));
}
include './function/function_app.php';
if(!$appinfo = app_idgetinfo(intval($_POST['applist']))){
die(makejson(-1,'请先选择一个应用'));
}
$appid = $_POST['applist'];
if ($appinfo['logintype'] === 'zhmm'){
if (empty($_POST['kt_user']) || empty($_POST['kt_pass'])){
die(makejson(-2,'请输入您的登录信息'));