forked from eeg1412/wikimoe_card_system_for_emlog_plugin
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwm_card_setting.php
129 lines (121 loc) · 6.9 KB
/
wm_card_setting.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
<?php
if(!defined('IN_DISCUZ')) {exit('error!');}
session_start();
header("Content-Type: text/html;charset=utf-8");
function set_wmtoken() {
$_SESSION['wmtoken'] = md5(microtime(true));
};
function valid_wmtoken() {
$return = $_REQUEST['wmtoken'] === $_SESSION['wmtoken'] ? true : false;
set_wmtoken();
return $return;
};
//如果wmtoken为空则生成一个wmtoken
if(!isset($_SESSION['wmtoken']) || $_SESSION['wmtoken']=='') {
set_wmtoken();
};
function plugin_setting_view(){
$wmCard_set=unserialize(ltrim(file_get_contents(dirname(__FILE__).'/wm_card.com.php'),'<?php die; ?>'));
?>
<style>
.card_setting label{
padding-bottom:10px;
display:block;
}
.card_setting{
margin-bottom:30px;
padding:10px;
border:1px dashed #ccc;
}
.success_alert{
text-align: center;
padding: 5px 0;
margin: 5px 0;
background: #25c930;
color: #fff;
}
.error_alert{
text-align: center;
padding: 5px 0;
margin: 5px 0;
background: #ff5050;
color: #fff;
}
</style>
<form class="card_setting" method="post">
<input type="hidden" name="wmtoken" value="<?php echo $_SESSION['wmtoken']?>">
<input type="hidden" name="settingType" value="setting" />
<label>每日抽卡次数:<input type="number" autocomplete="off" name="chance" value="<?php echo $wmCard_set['chance']; ?>" /></label>
<label>挖矿所获星星倍率:<input type="number" autocomplete="off" name="deminingStar" value="<?php echo $wmCard_set['deminingStar']; ?>" /></label>
<label>卡牌CDN(注意末尾斜杆):<input type="text" name="cdn" placeholder="不填写则为本地" value="<?php echo $wmCard_set['cdn']; ?>" /></label>
<label>关闭插件后删除表(1为删除 0为不删除):<input type="number" name="delDatabase" autocomplete="off" placeholder="1为删除 0为不删除" value="<?php echo $wmCard_set['delDatabase']; ?>" /></label>
<label>挖矿设置验证码(1为设置 0为不设置):<input type="number" name="deminingCaptcha" autocomplete="off" placeholder="1为设置 0为不设置" value="<?php echo $wmCard_set['deminingCaptcha']; ?>" /></label>
<label>腾讯防水墙App Secret Key:<input type="text" name="appSecretKey" placeholder="请填写App Secret Key" value="<?php echo $wmCard_set['appSecretKey']; ?>" /></label>
<label>腾讯防水墙App ID:<input type="text" name="appID" placeholder="请填写App ID" value="<?php echo $wmCard_set['appID']; ?>" /></label>
<label>腾讯防水墙注册:<a href="http://007.qq.com" target="_blank">http://007.qq.com</a></label>
<label>捐赠地址:<input type="text" name="donate" placeholder="填写用于捐赠显示的页面地址" value="<?php echo $wmCard_set['donate']; ?>" /></label>
<br />
<input type="submit" value="更改设置" />
</form>
<form class="card_setting" method="post">
<input type="hidden" name="wmtoken" value="<?php echo $_SESSION['wmtoken']?>">
<input type="hidden" name="settingType" value="postStar" />
<div>给用户<input style="margin:0 5px;" type="text" name="giveUid" placeholder="请输入uid" value="" autocomplete="on" />赠送<input style="margin:0 5px;" type="number" name="star" placeholder="请输入星星数量" value="" autocomplete="off" />个星星</div>
<br />
<input type="submit" value="发送星星" />
</form>
<?php
}
if(!empty($_POST)&&valid_wmtoken()){
if($_POST['settingType']=='setting'){
$chance=empty(intval($_POST['chance']))?'1':trim($_POST['chance']);
$deminingStar=empty(intval($_POST['deminingStar']))?'1':trim($_POST['deminingStar']);
$cdn=empty($_POST['cdn'])?'':trim($_POST['cdn']);
$delDatabase=empty($_POST['delDatabase'])?0:trim($_POST['delDatabase']);
$deminingCaptcha=empty($_POST['deminingCaptcha'])?0:trim($_POST['deminingCaptcha']);
$donate=empty($_POST['donate'])?'':trim($_POST['donate']);
$appSecretKey=empty($_POST['appSecretKey'])?'':trim($_POST['appSecretKey']);
$appID=empty($_POST['appID'])?'':trim($_POST['appID']);
file_put_contents(dirname(__FILE__).'/wm_card.com.php','<?php die; ?>'.serialize(array(
'chance'=>$chance,
'deminingStar'=>$deminingStar,
'cdn'=>$cdn,
'delDatabase'=>$delDatabase,
'deminingCaptcha'=>$deminingCaptcha,
'donate'=>$donate,
'appSecretKey'=>$appSecretKey,
'appID'=>$appID,
)));
echo '<div class="success_alert">设置成功</div>';
}else if($_POST['settingType']=='postStar'){
$uid = strip_tags($_POST['giveUid']);
if(isset($uid) && $uid!=""){
{//用正则表达式函数进行判断
//uid正确
$DB = DB::object();
$send_uid = "\"".md5($uid)."\"";
$mgid=$DB->query("SELECT * FROM pre_common_wm_card WHERE uid=".$send_uid."");
$mgidinfo=$DB->fetch_array($mgid);
if (!$mgidinfo){
echo '<div class="error_alert">无该用户</div>';
}else{
$starCount = intval($_POST['star']);
if(empty($starCount)){
//输入的星星有误
echo '<div class="error_alert">请输入1以上的星星数量</div>';
}else{
//开始赠送
$query = "Update pre_common_wm_card set starCount=starCount+".$starCount." where uid=".$send_uid."";
$result=$DB->query($query);
echo '<div class="success_alert">成功给'.$uid.'赠送了'.$starCount.'个星星</div>';
}
}
}
}else{
echo '<div class="error_alert">uid为空</div>';
}
}
//header("Location: {$_SERVER['REQUEST_URI']}");
}
plugin_setting_view();
?>