Exemple #1
0
 public function devicesBatch()
 {
     $method = Flight::request()->query->_method;
     $pkg = new Pkg();
     if ($method === 'DELETE') {
         $data = Flight::request()->data->getData();
         $devices = array_map(function ($deviceId) {
             return compact('deviceId');
         }, $data);
         $ret = $pkg->removeDevices($devices);
     } else {
         Flight::json(null, 400);
     }
     // 控制 Curl 请求错误
     $this->handleCurlError($pkg);
     Flight::json($ret);
 }
Exemple #2
0
 public function taskLog($taskId, $ip)
 {
     $pkg = new Pkg();
     $result = $pkg->getTaskResult($taskId);
     $log = null;
     foreach ($result as $row) {
         if ($row['ip'] === $ip) {
             $log = $row['taskInfo'];
             break;
         }
     }
     if (!$log) {
         Flight::notFound();
     }
     header('Content-Type: text/plain; charset=utf-8');
     echo $log;
 }