forked from Voemushroom/ALIS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdistribution.php
143 lines (113 loc) · 3.96 KB
/
distribution.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
<?php
ini_set("display_errors", 1);
error_reporting(E_ALL);
// twitter OAuth
require_once("TwistOAuth.phar");
$consumerKey = "xxxxx";
$consumerSecret = "xxxxx";
$accessToken = "xxxxx";
$accessTokenSecret = "xxxxx";
// etherscan.ioから500人分のALISホルダー抽出
$url ="https://etherscan.io/token/tokenholderchart/0xea610b1153477720748dc13ed378003941d84fab?range=500";
$kari = file_get_contents($url);
$number = strpos("$kari","VIEWSTATEGENERATOR");
$distribution = substr("$kari",$number);
$dis = mb_convert_encoding($distribution, "UTF-8", "auto");
//トークン保有量抽出
$start = strpos($dis,'</a></td><td>')+13;
$end = strpos($dis,'</td><td>', $start);
$quantity_0 = substr($dis, $start, $end-$start);
$quantity_2 = preg_replace( '/,/', '', $quantity_0);
$quantity_3 = 0;
$quantity_4 = 0;
$count_2 = 1;
$count_3 = 0;
$count_4 = 0;
for($i=0; $i<444; $i++){
$start = strpos($dis,'</a></td><td>',$end)+13;
$end = strpos($dis,'</td><td>', $start);
$number_0 = substr($dis, $start, $end-$start);
$number = floatval(preg_replace( '/,/', '', $number_0));
if ($number >= 1000000){
$quantity_2 += $number;
$count_2++;
continue;
}
if ($number >= 100000){
$quantity_3 += $number;
$count_3++;
continue;
}
if ($number >= 10000){
$quantity_4 += $number;
$count_4++;
}
}
// CEのみ例外処理
$start1 = strpos($dis,'(CoinExchange.io)</td><td>')+26;
$end1 = strpos($dis,'</td><td>', $start1);
$quan_0 = substr($dis, $start1, $end1-$start1);
$quan = preg_replace( '/,/', '', $quan_0);
if ($quan >= 1000000){
$quantity_2 += $quan;
$count_2++;
}elseif($quan >= 100000 && $quan < 1000000){
$quantity_3 += $quan;
$count_3++;
}elseif($quan >= 10000 && $quan < 100000){
$quantity_4 += $quan;
$count_4++;
}elseif($quan < 10000){
$quantity_5 += $quan;
$count_5++;
}
$quantity_5 = 75200000 - $quantity_2 - $quantity_3 - $quantity_4;
// coin割合を計算
$par_2 = round($quantity_2 / 75200000 *100 , 1)."%";
$par_3 = round($quantity_3 / 75200000 *100 , 1)."%";
$par_4 = round($quantity_4 / 75200000 *100 , 1)."%";
$par_5 = round($quantity_5 / 75200000 *100 , 1)."%";
// total holderから1万ALIS以下のホルダー数計算
$start1 = strpos($dis,">Token Holders:")+16;
$end1 = 5;
$holder_0 = substr($dis, $start1, $end1);
$holder = preg_replace( '/,/', '', $holder_0);
$count_5 = $holder - $count_2 - $count_3 - $count_4;
// add割合を計算
$add_2 = round($count_2 / $holder *100 ,2)."%";
$add_3 = round($count_3 / $holder *100 ,2)."%";
$add_4 = round($count_4 / $holder *100 ,2)."%";
$add_5 = round($count_5 / $holder *100 ,2)."%";
// 区切り追加
$ad_2 = number_format($count_2);
$ad_3 = number_format($count_3);
$ad_4 = number_format($count_4);
$ad_5 = number_format($count_5);
$coin_2 = number_format((int)$quantity_2);
$coin_3 = number_format((int)$quantity_3);
$coin_4 = number_format((int)$quantity_4);
$coin_5 = number_format((int)$quantity_5);
//出力分作成
$tweet= "["."1,000,000 ALIS ~"."]"."\n".
$ad_2." Add (".$add_2.")"."\n".
$coin_2 . " ALIS (" .$par_2.")"."\n"."\n".
"["."100,000~1,000,000 ALIS"."]"."\n".
$ad_3." Add (".$add_3.")"."\n".
$coin_3 . " ALIS (" .$par_3.")"."\n"."\n".
"["."10,000~100,000 ALIS"."]" ."\n".
$ad_4." Add (".$add_4.")"."\n".
$coin_4 . " ALIS (" .$par_4.")"."\n"."\n".
"["."~ 10,000 ALIS"."]" ."\n".
$ad_5." Add (".$add_5.")"."\n".
$coin_5 . " ALIS (" .$par_5.")"."\n"."\n".
"Total Holders : ".$holder_0."\n".
"#ALIS";
// Tweet実行
$twitter = new TwistOAuth($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
$result = $twitter->post("statuses/update", ["status" => "$tweet"]);
// 一応保存
$fp = fopen("distribution.txt", "w");
fwrite($fp, "$tweet");
fclose($fp);
// 確認用
echo $tweet;