123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- <?php
- class ProjectController
- {
-
- private $returnJson = array('type' => 'project');
-
- public function __construct()
- {
-
- $server = new GuestModule;
- if (!$server->checkLogin()) {
- $this->returnJson['statusCode'] = '120005';
- exitOutput($this->returnJson);
- }
- }
-
- public function addProject()
- {
- $nameLen = mb_strlen(quickInput('projectName'), 'utf8');
- $projectName = securelyInput('projectName');
- $projectType = securelyInput('projectType');
- $projectVersion = quickInput('projectVersion');
- $version_len = mb_strlen(quickInput('projectVersion'));
-
- if (!($nameLen >= 1 && $nameLen <= 32 && preg_match('/^[0-3]{1}$/', $projectType))) {
-
- $this->returnJson['statusCode'] = '140002';
- } elseif ($version_len < 1 || $version_len > 10) {
-
- $this->returnJson['statusCode'] = '140017';
- } else {
-
- $service = new ProjectModule();
- $result = $service->addProject($projectName, $projectType, $projectVersion);
-
- if ($result) {
-
- $this->returnJson['statusCode'] = '000000';
- $this->returnJson['projectInfo'] = $result;
- } else
-
- $this->returnJson['statusCode'] = '140001';
- }
- exitOutput($this->returnJson);
- }
-
- public function deleteProject()
- {
- $projectID = securelyInput('projectID');
- $module = new ProjectModule();
- $userType = $module->getUserType($projectID);
- if ($userType != 0) {
- $this->returnJson['statusCode'] = '120007';
- exitOutput($this->returnJson);
- }
-
- if (preg_match('/^[0-9]{1,11}$/', $projectID)) {
-
- $service = new ProjectModule();
- $result = $service->deleteProject($projectID);
-
- if ($result)
-
- $this->returnJson['statusCode'] = '000000';
- else
-
- $this->returnJson['statusCode'] = '140003';
- } else {
-
- $this->returnJson['statusCode'] = '140004';
- }
- exitOutput($this->returnJson);
- }
-
- public function getProjectList()
- {
- $nameLen = mb_strlen(quickInput('projectName'), 'utf8');
- $projectType = securelyInput('projectType');
-
- if (!preg_match('/^[0-3]|[-1]{1}$/', $projectType) || ($nameLen != 0 && $nameLen < 1 || $nameLen > 30)) {
-
- $this->returnJson['statusCode'] = '140002';
- exitOutput($this->returnJson);
- } else {
- $service = new ProjectModule();
- $result = $service->getProjectList($projectType);
- if ($result) {
-
- $this->returnJson['statusCode'] = '000000';
- $this->returnJson['projectList'] = $result;
- } else {
-
- $this->returnJson['statusCode'] = '140005';
- }
- }
- exitOutput($this->returnJson);
- }
-
- public function editProject()
- {
- $nameLen = mb_strlen(quickInput('projectName'), 'utf8');
- $projectID = securelyInput('projectID');
- $module = new ProjectModule();
- $userType = $module->getUserType($projectID);
- if ($userType < 0 || $userType > 1) {
- $this->returnJson['statusCode'] = '120007';
- exitOutput($this->returnJson);
- }
- $projectType = securelyInput('projectType');
- $projectName = securelyInput('projectName');
- $projectVersion = quickInput('projectVersion');
- $version_len = mb_strlen(quickInput('projectVersion'));
-
- if (!(preg_match('/^[0-9]{1,11}$/', $projectID) && $nameLen >= 1 && $nameLen <= 32 && preg_match('/^[0-3]{1}$/', $projectType))) {
-
- $this->returnJson['statusCode'] = '140007';
- } elseif ($version_len < 1 || $version_len > 10) {
-
- $this->returnJson['statusCode'] = '140017';
- } else {
-
- $service = new ProjectModule();
- $result = $service->editProject($projectID, $projectName, $projectType, $projectVersion);
-
- if ($result)
-
- $this->returnJson['statusCode'] = '000000';
- else
-
- $this->returnJson['statusCode'] = '140006';
- }
- exitOutput($this->returnJson);
- }
-
- public function getProject()
- {
- $projectID = securelyInput('projectID');
- if (preg_match('/^[0-9]{1,11}$/', $projectID)) {
- $service = new ProjectModule;
- $result = $service->getProject($projectID);
- if ($result) {
- $this->returnJson['statusCode'] = '000000';
- $this->returnJson = array_merge($this->returnJson, $result);
- } else {
- $this->returnJson['statusCode'] = '140005';
- }
- } else {
- $this->returnJson['statusCode'] = '140007';
- }
- exitOutput($this->returnJson);
- }
-
- public function dumpProject()
- {
- $projectID = securelyInput('projectID');
- if (!preg_match('/^[0-9]{1,11}$/', $projectID)) {
-
- $this->returnJson['statusCode'] = '140004';
- exitOutput($this->returnJson);
- }
- $service = new ProjectModule;
- $fileName = $service->dumpProject($projectID);
- if ($fileName) {
- $this->returnJson['statusCode'] = '000000';
- $this->returnJson['fileName'] = $fileName;
- } else {
-
- $this->returnJson['statusCode'] = '140021';
- }
- exitOutput($this->returnJson);
- }
-
- public function getApiNum()
- {
- $projectID = securelyInput('projectID');
- if (!preg_match('/^[0-9]{1,11}$/', $projectID)) {
-
- $this->returnJson['statusCode'] = '140004';
- exitOutput($this->returnJson);
- }
- $service = new ProjectModule;
- $result = $service->getApiNum($projectID);
- if ($result) {
- $this->returnJson['statusCode'] = '000000';
- $this->returnJson['num'] = $result['num'];
- } else {
- $this->returnJson['statusCode'] = '140023';
- }
- exitOutput($this->returnJson);
- }
-
- public function getProjectLogList()
- {
-
- $project_id = securelyInput('projectID');
-
- $page = securelyInput('page', 1);
-
- $page_size = securelyInput('pageSize', 15);
- if (!preg_match('/^[0-9]{1,11}$/', $project_id)) {
-
- $this->returnJson['statusCode'] = '140004';
- } else {
- $service = new ProjectModule();
- $result = $service->getProjectLogList($project_id, $page, $page_size);
- if ($result) {
-
- $this->returnJson['statusCode'] = '000000';
- $this->returnJson = array_merge($this->returnJson, $result);
- } else {
-
- $this->returnJson['statusCode'] = '140000';
- }
- }
- exitOutput($this->returnJson);
- }
- }
- ?>
|