-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiAction.php
More file actions
43 lines (36 loc) · 1.27 KB
/
Copy pathmultiAction.php
File metadata and controls
43 lines (36 loc) · 1.27 KB
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
<?php
ini_set('display_errors',1);
use MClient\Request;
require "vendor/autoload.php";
if ($_POST)
{
$rc = new \RollingCurl\RollingCurl();
if (request('type') === 'RESTART')
{
foreach (post('data') as $item){
if ($_ENV["MODEM_TYPE"] == "ALCATEL"){
redisSave("RESET_PROXY_TIMEX:".$item['inet'],10,60);
$rc->post("http://".$item['inet']."/jrd/webapi?api=SetDeviceReboot",'{"jsonrpc":"2.0","method":"SetDeviceReboot","params":null,"id":"13.5"}',[],[CURLOPT_TIMEOUT => 20],['inet' => $item['inet']]);
}
}
}
if (request('type') === 'CHECK')
{
foreach (post('data') as $proxies)
{
$rc->get("http://ip-api.com/json/",[],[CURLOPT_PROXY => $proxies['proxy'],CURLOPT_TIMEOUT => 10],$proxies);
}
}
$responses = [];
$rc->setCallback(function (\RollingCurl\Request $request, \RollingCurl\RollingCurl $rollingCurl) use(&$responses){
$responses[] = [
'response' => $request->getResponseText(),
'balancer' => $request->identifierParams
];
$rollingCurl->prunePendingRequestQueue();
$rollingCurl->clearCompleted();
});
$rc->setSimultaneousLimit(100);
$rc->execute();
echo json($responses);
}