@@ -107,31 +107,36 @@ function isActive($address, $contract){
107
107
108
108
return substr ($ data ,-1 );
109
109
}
110
-
110
+
111
+
111
112
function getVersion ( $ contract ){
112
- $ url = getServerAddress ()."/api.php " ;
113
- $ ch = curl_init ();
114
- $ ethCall = ['to ' =>$ contract ,
115
- 'data ' => '0x54fd4d50 '
116
- ];
117
- $ fields = ['ethCall ' =>$ ethCall ];
118
- $ fields_string = http_build_query ($ fields );
119
-
120
- curl_setopt ($ ch , CURLOPT_URL , $ url );
121
- // Set so curl_exec returns the result instead of outputting it.
122
- curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
123
- curl_setopt ($ ch , CURLOPT_POST , count ($ fields ));
124
- curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ fields_string );
125
- curl_setopt ($ ch , CURLOPT_SSL_VERIFYPEER , false );
126
-
127
- // Get the response and close the channel.
128
- $ response = curl_exec ($ ch );
129
- curl_close ($ ch );
130
-
131
- $ json = json_decode ($ response );
132
- $ data = $ json ->{'data ' };
133
-
134
- return $ data ;
113
+ $ url = getServerAddress ()."/api.php " ;
114
+ $ ch = curl_init ();
115
+ $ ethCall = ['to ' =>$ contract ,
116
+ 'data ' => '0x54fd4d50 '
117
+ ];
118
+ $ fields = ['ethCall ' =>$ ethCall ];
119
+ $ fields_string = http_build_query ($ fields );
120
+
121
+ curl_setopt ($ ch , CURLOPT_URL , $ url );
122
+ // Set so curl_exec returns the result instead of outputting it.
123
+ curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
124
+ curl_setopt ($ ch , CURLOPT_POST , count ($ fields ));
125
+ curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ fields_string );
126
+ curl_setopt ($ ch , CURLOPT_SSL_VERIFYPEER , false );
127
+
128
+ // Get the response and close the channel.
129
+ $ response = curl_exec ($ ch );
130
+ curl_close ($ ch );
131
+
132
+ $ json = json_decode ($ response );
133
+ $ data = $ json ->{'data ' };
134
+
135
+ return $ data ; //hex2bin($data);
136
+ }
137
+
138
+
139
+
135
140
136
141
function getNumber ($ address , $ contract , $ function ){
137
142
$ url = getServerAddress ()."/api.php " ;
@@ -189,7 +194,7 @@ function getNumberInMap($address1, $addresse2, $contract, $function){
189
194
$ json = json_decode ($ response );
190
195
$ data = $ json ->{'data ' };
191
196
192
- return hexdec ($ data );
197
+ return hexdec ($ data );
193
198
}
194
199
195
200
function getBalance ($ address , $ contract ){
@@ -220,25 +225,27 @@ function checkSign($dat, $signature, $caller){
220
225
return $ caller ==personal_ecRecover ($ dat , $ signature );
221
226
}
222
227
228
+
223
229
function getAccountStatus ($ addresses , $ contract ) {
224
- $ version = getVersion ($ contract );
225
- $ result = array ();
226
- foreach ( $ addresses as $ add ) {
227
- $ result [$ add ] = 0 ;
228
- }
229
- if (strlen (strval ($ version ))>2 ) {
230
- // New Contract use isActive
231
- foreach ( $ addresses as $ add ) {
232
- $ result [$ add ] = isActive ($ add , $ contract );
233
- }
234
- } else {
235
- // Old contract fallback on getAccStatus
236
- foreach ( $ addresses as $ add ) {
237
- $ result [$ add ] = getAccStatus ($ add , $ contract );
238
- }
239
- }
240
-
241
- return $ result ;
230
+
231
+ $ version = getVersion ($ contract );
232
+ $ result = array ();
233
+ foreach ( $ addresses as $ add ) {
234
+ $ result [$ add ] = 0 ;
235
+ }
236
+ if (strlen (strval ($ version ))>2 ) {
237
+ // New Contract use isActive
238
+ foreach ( $ addresses as $ add ) {
239
+ $ result [$ add ] = isActive ($ add , $ contract );
240
+ }
241
+ } else {
242
+ // Old contract fallback on getAccStatus
243
+ foreach ( $ addresses as $ add ) {
244
+ $ result [$ add ] = getAccStatus ($ add , $ contract );
245
+ }
246
+ }
247
+
248
+ return $ result ;
242
249
}
243
250
244
251
0 commit comments