diff --git a/api/v1/entries/hostSubmit.php b/api/v1/entries/hostSubmit.php new file mode 100644 index 0000000000..586a7bfdc5 --- /dev/null +++ b/api/v1/entries/hostSubmit.php @@ -0,0 +1,48 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + */ +class hostSubmitEntry extends baseEntry +{ + /** + * Listen host heartbeat. + * + * @param int|string $userID + * @access public + * @return void + */ + public function post() + { + /* Check authorize. */ + $header = getallheaders(); + $token = isset($header['Authorization']) ? substr($header['Authorization'], 7) : ''; + if(!$token) return $this->sendError(401, 'Unauthorized'); + + $now = helper::now(); + + /* Check param. */ + $image = new stdclass(); + $task = $this->requestBody->task; + $image->status = $this->requestBody->status; + $image->speed = $this->requestBody->speed; + $image->rate = $this->requestBody->rate; + + $this->dao = $this->loadModel('common')->dao; + $id = $this->dao->select('id')->from(TABLE_ZAHOST) + ->where('tokenSN')->eq($token) + ->andWhere('tokenTime')->gt($now)->fi() + ->fetch('id'); + if(!$id) return $this->sendError(400, 'Secret error.'); + + $this->dao->update(TABLE_IMAGE)->data($image)->where("id")->eq($task)->exec(); + + return $this->sendSuccess(200, 'success'); + } +} diff --git a/config/routes.php b/config/routes.php index 18a55e1ec6..6369c4ff10 100644 --- a/config/routes.php +++ b/config/routes.php @@ -162,6 +162,7 @@ $routes['/modules'] = 'modules'; $routes['/reports'] = 'reports'; $routes['/host/heartbeat'] = 'hostHeartbeat'; +$routes['/host/submitResult'] = 'hostSubmit'; $routes['/zanode/heartbeat'] = 'zanodeHeartbeat'; diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index 95aa835f71..f62bf33eaf 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -20,7 +20,7 @@ $lang->zahost->IP = 'Extranet Address'; $lang->zahost->extranet = 'Extranet Address'; $lang->zahost->cpuCores = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; -$lang->zahost->diskSize = 'diskSize Size'; +$lang->zahost->diskSize = 'Disk Size'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index 4d2a57326b..5b3885c409 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -20,7 +20,7 @@ $lang->zahost->IP = 'Extranet Address'; $lang->zahost->extranet = 'Extranet Address'; $lang->zahost->cpuCores = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; -$lang->zahost->diskSize = 'diskSize Size'; +$lang->zahost->diskSize = 'Disk Size'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php index 03737e60c7..3ab6b219af 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -20,7 +20,7 @@ $lang->zahost->IP = 'Extranet Address'; $lang->zahost->extranet = 'Extranet Address'; $lang->zahost->cpuCores = 'CPU Cores'; $lang->zahost->memory = 'Memory Size'; -$lang->zahost->diskSize = 'diskSize Size'; +$lang->zahost->diskSize = 'Disk Size'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; diff --git a/module/zahost/view/create.html.php b/module/zahost/view/create.html.php index 7eccdf9827..0cede66734 100644 --- a/module/zahost/view/create.html.php +++ b/module/zahost/view/create.html.php @@ -46,7 +46,7 @@