123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <?php
- class EnvController
- {
-
- private $returnJson = array('type' => 'environment');
-
- public function __construct()
- {
-
- $module = new GuestModule;
- if (!$module->checkLogin()) {
- $this->returnJson['statusCode'] = '120005';
- exitOutput($this->returnJson);
- }
- }
-
- public function getEnvList()
- {
- $service = new EnvModule;
- $projectID = securelyInput('projectID');
- if (!preg_match('/^[0-9]{1,11}$/', $projectID)) {
- $this->returnJson['statusCode'] = '170003';
- } else {
- $result = $service->getEnvList($projectID);
-
- if ($result) {
- $this->returnJson['statusCode'] = '000000';
- $this->returnJson['envList'] = $result;
- } else {
-
- $this->returnJson['statusCode'] = '170000';
- }
- }
- exitOutput($this->returnJson);
- }
-
- public function addEnv()
- {
-
- $env_name = securelyInput('envName');
-
- $name_length = mb_strlen(quickInput('envName'), 'utf8');
-
- $front_uri = securelyInput('frontURI');
-
- $headers = json_decode(quickInput('headers'), TRUE);
-
- $params = json_decode(quickInput('params'), TRUE);
-
- $additional_params = json_decode(quickInput('additionalParams'), TRUE);
- $projectID = securelyInput('projectID');
- $apply_protocol = -1;
- if (!preg_match('/^[0-9]{1,11}$/', $projectID)) {
- $this->returnJson['statusCode'] = '170003';
- }
- elseif ($name_length < 1 || $name_length > 32) {
-
- $this->returnJson['statusCode'] = '170001';
- } else {
- $service = new EnvModule;
- $result = $service->addEnv($projectID, $env_name, $front_uri, $headers, $params, $apply_protocol, $additional_params);
-
- if ($result) {
- $this->returnJson['statusCode'] = '000000';
- $this->returnJson['envID'] = $result;
- } else {
- $this->returnJson['statusCode'] = '170000';
- }
- }
- exitOutput($this->returnJson);
- }
-
- public function deleteEnv()
- {
- $env_id = securelyInput('envID');
- $project_id = securelyInput('projectID');
- if (!preg_match('/^[0-9]{1,11}$/', $project_id)) {
- $this->returnJson['statusCode'] = '170003';
- }
- elseif (!preg_match('/^[0-9]{1,11}$/', $env_id)) {
-
- $this->returnJson['statusCode'] = '170002';
- } else {
- $service = new EnvModule();
- if ($service->deleteEnv($project_id, $env_id)) {
- $this->returnJson['statusCode'] = '000000';
- } else {
-
- $this->returnJson['statusCode'] = '170000';
- }
- }
- exitOutput($this->returnJson);
- }
-
- public function editEnv()
- {
- $env_id = securelyInput('envID');
- $env_name = securelyInput('envName');
- $name_length = mb_strlen(quickInput('envName'), 'utf8');
-
- $front_uri = securelyInput('frontURI');
-
- $headers = json_decode(quickInput('headers'), TRUE);
-
- $params = json_decode(quickInput('params'), TRUE);
-
- $additional_params = json_decode(quickInput('additionalParams'), TRUE);
- $apply_protocol = -1;
- if ($name_length < 1 || $name_length > 32) {
-
- $this->returnJson['statusCode'] = '170001';
- } elseif (!preg_match('/^[0-9]{1,11}$/', $env_id)) {
-
- $this->returnJson['statusCode'] = '170002';
- } else {
- $service = new EnvModule();
- if ($service->editEnv($env_id, $env_name, $front_uri, $headers, $params, $apply_protocol, $additional_params)) {
- $this->returnJson['statusCode'] = '000000';
- } else {
-
- $this->returnJson['statusCode'] = '170000';
- }
- }
- exitOutput($this->returnJson);
- }
- }
|