-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathopen.php
executable file
·123 lines (120 loc) · 3.25 KB
/
open.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
<?php
include 'config.php';
include 'Medoo.php';
use Medoo\Medoo;
include 'Telegram.php';
$database = new medoo($config);
$telegram = new Telegram($bot_token);
$data = file_get_contents('http://f.apiplus.net/pl3-1.json');
$data = json_decode($data,true);
$opencode = explode(",",$data['data'][0]['opencode']);
$expect = $data['data'][0]['expect'];
$lastopen = $database->get("lottery", [
"expect",
"opencode"
], [
"id" => 1
]);
$opendates = $lastopen["expect"] - 1;
if($opendates == $expect and $lastopen["opencode"] == 0){
$data = $database->select("game", [
"id",
"user",
"project",
"type",
"result",
"data"
], [
"expect" => $expect
]);
$database->insert("lottery", [
"expect" => $expect,
"opencode" => $opencode[0]
]);
if ($opencode[0]%2 == 0) {
$result1 = '双';
} else {
$result1 = '单';
}
if ($opencode[0] >= 5) {
$result2 = '大';
} else {
$result2 = '小';
}
//流量输掉的奖池
$data1 = $database->sum("game","data", [
"expect" => $expect,
"project[!]" => [$result1,$result2],
"type" => '流量',
"result" => '未开奖'
]);
$data2 = $database->sum("game","data", [
"expect" => $expect,
"project" => [$result1,$result2],
"type" => '流量',
"result" => '未开奖'
]);
//余额输掉的奖池
$data3 = $database->sum("game","data", [
"expect" => $expect,
"project[!]" => [$result1,$result2],
"type" => '余额',
"result" => '未开奖'
]);
$data4 = $database->sum("game","data", [
"expect" => $expect,
"project" => [$result1,$result2],
"type" => '余额',
"result" => '未开奖'
]);
$text = '本次开奖数字:'.$opencode[0].'
流量奖池共 '.$data1.' M 倍率:'.round($data1/$data2,2).'
余额奖池共 '.$data3.' 元倍率:'.round($data3/$data4,2).'
';
foreach ($data as $datas) {
if ($datas['result'] == '未开奖') {
if ($datas['project'] == $result1 OR $datas['project'] == $result2) {
$result = '已中奖';
if ($datas['type'] == '余额') {
$rrr1 = round(($datas['data']/$data4)*$data3,2);
$rrr = $datas['data'] + $rrr1;
$database->update("user", [
"money[+]" => $rrr
], [
"im_value" => $datas['user']
]);
} elseif ($datas['type'] == '流量') {
$rrr1 = ceil(($datas['data']/$data2)*$data1);
$rrr = ($datas['data'] + $rrr1)*1024*1024;
$database->update("user", [
"transfer_enable[+]" => $rrr
], [
"im_value" => $datas['user']
]);
}
$text = $text.'
@'.$datas['user'].' 第'.$expect.'期彩票已中奖,获得'.$datas['type'].' '.$rrr1;
} else {
$text = $text.'
@'.$datas['user'].' 第'.$expect.'期彩票未中奖';
$result = '未中奖';
}
$database->update("game", [
"result" => $result
], [
"id" => $datas['id']
]);
}
}
$content = array('chat_id' => '@liangchenyunss', 'text' => $text);
$telegram->sendMessage($content);
$content = array('chat_id' => '@lcykj', 'text' => $text);
$telegram->sendMessage($content);
$database->update("lottery", [
"opencode" => 1
], [
"id" => 1
]);
}
echo 'success';
?>