|
@@ -9,21 +9,34 @@ $act = get('act');
|
|
|
|
|
|
switch ($act) {
|
|
switch ($act) {
|
|
case 'list':
|
|
case 'list':
|
|
- $count = $DB->count('account_hostname');
|
|
|
|
|
|
+ $total = $DB->count('account_hostname');
|
|
$list = array();
|
|
$list = array();
|
|
- if ($count > 0) {
|
|
|
|
|
|
+ $total = intval($total);
|
|
|
|
+ if ($total > 0) {
|
|
$list = $DB->findAll('account_hostname', '*', array(), '`host_id` ASC');
|
|
$list = $DB->findAll('account_hostname', '*', array(), '`host_id` ASC');
|
|
}
|
|
}
|
|
- exit(json_encode(['code' => 0, 'total' => $total, 'list' => $list]));
|
|
|
|
|
|
+ send_response(200, array('total' => $total, 'list' => $list));
|
|
|
|
+ break;
|
|
|
|
+ case 'options':
|
|
|
|
+ $api_id = get('api_id');
|
|
|
|
+ if (!$api_id) {
|
|
|
|
+ send_response(-1, array());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $where = array(
|
|
|
|
+ 'api_id' => $api_id
|
|
|
|
+ );
|
|
|
|
+ $list = $DB->findAll('account_hostname', 'api_id,host_id,host_name', $where, '`host_id` ASC');
|
|
|
|
+ send_response(200, $list);
|
|
break;
|
|
break;
|
|
case 'add':
|
|
case 'add':
|
|
$hostname = post('hostname');
|
|
$hostname = post('hostname');
|
|
if (!$hostname) {
|
|
if (!$hostname) {
|
|
- exit(json_encode(['code' => -1, 'msg' => '主机名不能为空 !']));
|
|
|
|
|
|
+ send_response(-1, null, '主机名不能为空 !');
|
|
}
|
|
}
|
|
$api_id = post('api_id');
|
|
$api_id = post('api_id');
|
|
if (!$api_id) {
|
|
if (!$api_id) {
|
|
- exit(json_encode(['code' => -1, 'msg' => '托管服务提供商不能为空 !']));
|
|
|
|
|
|
+ send_response(-1, null, '托管服务提供商不能为空 !');
|
|
}
|
|
}
|
|
|
|
|
|
$domain = strtolower($hostname);
|
|
$domain = strtolower($hostname);
|
|
@@ -39,20 +52,20 @@ switch ($act) {
|
|
|
|
|
|
$has = $DB->count('account_hostname', $data);
|
|
$has = $DB->count('account_hostname', $data);
|
|
if ($has && $has > 0) {
|
|
if ($has && $has > 0) {
|
|
- exit(json_encode(['code' => -1, 'msg' => 'Hostname aleady exsist !']));
|
|
|
|
|
|
+ send_response(-1, null, 'Hostname aleady exsist !');
|
|
} else {
|
|
} else {
|
|
$result = $DB->insert('account_hostname', $data);
|
|
$result = $DB->insert('account_hostname', $data);
|
|
if ($result) {
|
|
if ($result) {
|
|
- exit(json_encode(['code' => 0, 'msg' => 'Hostname added successfully !']));
|
|
|
|
|
|
+ send_response(0, null, 'Hostname added successfully !');
|
|
} else {
|
|
} else {
|
|
- exit(json_encode(['code' => -1, 'msg' => 'Something went wrong !']));
|
|
|
|
|
|
+ send_response(-1, null, 'Something went wrong !');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case 'delete':
|
|
case 'delete':
|
|
$host_id = post('host_id');
|
|
$host_id = post('host_id');
|
|
if (!$host_id) {
|
|
if (!$host_id) {
|
|
- exit(json_encode(['code' => -1, 'msg' => '主机ID不能为空 !']));
|
|
|
|
|
|
+ send_response(-1, null, '主机ID不能为空 !');
|
|
}
|
|
}
|
|
$data = array(
|
|
$data = array(
|
|
'host_id' => $host_id
|
|
'host_id' => $host_id
|
|
@@ -60,16 +73,16 @@ switch ($act) {
|
|
|
|
|
|
$has = $DB->count('account_hostname', $data);
|
|
$has = $DB->count('account_hostname', $data);
|
|
if (!$has > 0) {
|
|
if (!$has > 0) {
|
|
- exit(json_encode(['code' => -1, 'msg' => 'Hostname not found !']));
|
|
|
|
|
|
+ send_response(-1, null, 'Hostname not found !');
|
|
} else {
|
|
} else {
|
|
$result = $DB->delete('account_hostname', $data);
|
|
$result = $DB->delete('account_hostname', $data);
|
|
if ($result) {
|
|
if ($result) {
|
|
- exit(json_encode(['code' => 0, 'msg' => 'Hostname deleted successfully !']));
|
|
|
|
|
|
+ send_response(0, null, 'Hostname deleted successfully !');
|
|
} else {
|
|
} else {
|
|
- exit(json_encode(['code' => -1, 'msg' => 'Something went wrong !']));
|
|
|
|
|
|
+ send_response(-1, null, 'Something went wrong !');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
default:
|
|
default:
|
|
- exit('{"code":-4,"msg":"No Act"}');
|
|
|
|
|
|
+ send_response(-4, NULL, 'No Act');
|
|
break;
|
|
break;
|
|
}
|
|
}
|