diff --git a/module/common/lang/en.php b/module/common/lang/en.php index 90984425de..282c550ee5 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.php @@ -436,25 +436,6 @@ $lang->error->noData = 'No Data'; $lang->error->editedByOther = 'This record might have been changed. Please refresh and try to edit again!'; $lang->error->tutorialData = 'No data can be imported in tutorial mode. Please exit tutorial first!'; -if(!defined('PARAM_CODE_MISSING')) define('PARAM_CODE_MISSING', 301); -if(!defined('PARAM_TOKEN_MISSING')) define('PARAM_TOKEN_MISSING', 302); -if(!defined('INVALID_ENTRY')) define('INVALID_ENTRY', 311); -if(!defined('EMPTY_KEY')) define('EMPTY_KEY', 312); -if(!defined('IP_DENIED')) define('IP_DENIED', 321); -if(!defined('INVALID_TOKEN')) define('INVALID_TOKEN', 331); -if(!defined('SESSION_CODE_MISSING')) define('SESSION_CODE_MISSING', 341); -if(!defined('SESSION_VERIFY_FAILED')) define('SESSION_VERIFY_FAILED', 342); - -$lang->error->entry = array(); -$lang->error->entry['PARAM_CODE_MISSING'] = 'Param code is missing.'; -$lang->error->entry['PARAM_TOKEN_MISSING'] = 'Param token is missing.'; -$lang->error->entry['INVALID_ENTRY'] = 'Entry does not exist.'; -$lang->error->entry['EMPTY_KEY'] = 'Key of entry is missing.'; -$lang->error->entry['IP_DENIED'] = 'IP is denied.'; -$lang->error->entry['INVALID_TOKEN'] = 'Invalid token.'; -$lang->error->entry['SESSION_CODE_MISSING'] = 'Session code is missing.'; -$lang->error->entry['SESSION_VERIFY_FAILED'] = 'Session verification failed.'; - /* 分页信息。*/ $lang->pager = new stdclass(); $lang->pager->noRecord = "No Records"; diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index acf66b64cc..7fc0082aac 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -436,25 +436,6 @@ $lang->error->noData = '没有数据'; $lang->error->editedByOther = '该记录可能已经被改动。请刷新页面重新编辑!'; $lang->error->tutorialData = '新手模式下不会插入数据,请退出新手模式操作'; -if(!defined('PARAM_CODE_MISSING')) define('PARAM_CODE_MISSING', 301); -if(!defined('PARAM_TOKEN_MISSING')) define('PARAM_TOKEN_MISSING', 302); -if(!defined('INVALID_ENTRY')) define('INVALID_ENTRY', 311); -if(!defined('EMPTY_KEY')) define('EMPTY_KEY', 312); -if(!defined('IP_DENIED')) define('IP_DENIED', 321); -if(!defined('INVALID_TOKEN')) define('INVALID_TOKEN', 331); -if(!defined('SESSION_CODE_MISSING')) define('SESSION_CODE_MISSING', 341); -if(!defined('SESSION_VERIFY_FAILED')) define('SESSION_VERIFY_FAILED', 342); - -$lang->error->entry = array(); -$lang->error->entry['PARAM_CODE_MISSING'] = '缺少code参数'; -$lang->error->entry['PARAM_TOKEN_MISSING'] = '缺少token参数'; -$lang->error->entry['INVALID_ENTRY'] = '应用不存在'; -$lang->error->entry['EMPTY_KEY'] = '应用未设置密钥'; -$lang->error->entry['IP_DENIED'] = '该IP访问被限制访问'; -$lang->error->entry['INVALID_TOKEN'] = '不合法的token参数'; -$lang->error->entry['SESSION_CODE_MISSING'] = '缺少session code'; -$lang->error->entry['SESSION_VERIFY_FAILED'] = 'session验证失败'; - /* 分页信息。*/ $lang->pager = new stdclass(); $lang->pager->noRecord = "暂时没有记录"; diff --git a/module/common/lang/zh-tw.php b/module/common/lang/zh-tw.php index 76e9de3f8b..5f23ba0fd3 100644 --- a/module/common/lang/zh-tw.php +++ b/module/common/lang/zh-tw.php @@ -436,25 +436,6 @@ $lang->error->noData = '沒有數據'; $lang->error->editedByOther = '該記錄可能已經被改動。請刷新頁面重新編輯!'; $lang->error->tutorialData = '新手模式下不會插入數據,請退出新手模式操作'; -if(!defined('PARAM_CODE_MISSING')) define('PARAM_CODE_MISSING', 301); -if(!defined('PARAM_TOKEN_MISSING')) define('PARAM_TOKEN_MISSING', 302); -if(!defined('INVALID_ENTRY')) define('INVALID_ENTRY', 311); -if(!defined('EMPTY_KEY')) define('EMPTY_KEY', 312); -if(!defined('IP_DENIED')) define('IP_DENIED', 321); -if(!defined('INVALID_TOKEN')) define('INVALID_TOKEN', 331); -if(!defined('SESSION_CODE_MISSING')) define('SESSION_CODE_MISSING', 341); -if(!defined('SESSION_VERIFY_FAILED')) define('SESSION_VERIFY_FAILED', 342); - -$lang->error->entry = array(); -$lang->error->entry['PARAM_CODE_MISSING'] = '缺少code參數'; -$lang->error->entry['PARAM_TOKEN_MISSING'] = '缺少token參數'; -$lang->error->entry['INVALID_ENTRY'] = '應用不存在'; -$lang->error->entry['EMPTY_KEY'] = '應用未設置密鑰'; -$lang->error->entry['IP_DENIED'] = '該IP訪問被限制訪問'; -$lang->error->entry['INVALID_TOKEN'] = '不合法的token參數'; -$lang->error->entry['SESSION_CODE_MISSING'] = '缺少session code'; -$lang->error->entry['SESSION_VERIFY_FAILED'] = 'session驗證失敗'; - /* 分頁信息。*/ $lang->pager = new stdclass(); $lang->pager->noRecord = "暫時沒有記錄"; diff --git a/module/common/model.php b/module/common/model.php index 51533490bd..8f3a86d4b6 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -1192,7 +1192,7 @@ class commonModel extends model // limited project $limitedProject = false; if(!empty($module) && $module == 'task' && !empty($object->project) or - !empty($module) && $module == 'project' && !empty($object->id)) + !empty($module) && $module == 'project' && !empty($object->id)) { $objectID = ''; if(!empty($object->id)) $objectID = $object->id; @@ -1212,14 +1212,14 @@ class commonModel extends model if(is_null($object)) return true; if(!empty($object->openedBy) && $object->openedBy == $app->user->account or - !empty($object->addedBy) && $object->addedBy == $app->user->account or - !empty($object->assignedTo) && $object->assignedTo == $app->user->account or - !empty($object->finishedBy) && $object->finishedBy == $app->user->account or - !empty($object->canceledBy) && $object->canceledBy == $app->user->account or - !empty($object->closedBy) && $object->closedBy == $app->user->account or - !empty($object->lastEditedBy) && $object->lastEditedBy == $app->user->account) + !empty($object->addedBy) && $object->addedBy == $app->user->account or + !empty($object->assignedTo) && $object->assignedTo == $app->user->account or + !empty($object->finishedBy) && $object->finishedBy == $app->user->account or + !empty($object->canceledBy) && $object->canceledBy == $app->user->account or + !empty($object->closedBy) && $object->closedBy == $app->user->account or + !empty($object->lastEditedBy) && $object->lastEditedBy == $app->user->account) { - return true; + return true; } return false; @@ -1387,25 +1387,30 @@ class commonModel extends model */ public function checkEntry() { + $this->loadModel('entry'); + if($this->session->valid_entry) { - if(!$this->session->entry_code) $this->response(SESSION_CODE_MISSING); - if($this->session->valid_entry != md5(md5($this->get->code) . $this->server->remote_addr)) $this->response(SESSION_VERIFY_FAILED); + if(!$this->session->entry_code) $this->response('SESSION_CODE_MISSING'); + if($this->session->valid_entry != md5(md5($this->get->code) . $this->server->remote_addr)) $this->response('SESSION_VERIFY_FAILED'); return true; } - if(!$this->get->code) $this->response(PARAM_CODE_MISSING); - if(!$this->get->token) $this->response(PARAM_TOKEN_MISSING); + if(!$this->get->code) $this->response('PARAM_CODE_MISSING'); + if(!$this->get->token) $this->response('PARAM_TOKEN_MISSING'); - $entry = $this->loadModel('entry')->getByCode($this->get->code); - if(!$entry) $this->response(INVALID_ENTRY); - if(!$entry->key) $this->response(EMPTY_KEY); - if(!$this->checkIP($entry->ip)) $this->response(IP_DENIED); - if(!$this->checkEntryToken($entry->key)) $this->response(INVALID_TOKEN); + $entry = $this->entry->getByCode($this->get->code); + if(!$entry) $this->response('EMPTY_ENTRY'); + if(!$entry->key) $this->response('EMPTY_KEY'); + if(!$this->checkIP($entry->ip)) $this->response('IP_DENIED'); + if(!$this->checkEntryToken($entry->key)) $this->response('INVALID_TOKEN'); $this->session->set('ENTRY_CODE', $this->get->code); $this->session->set('VALID_ENTRY', md5(md5($this->get->code) . $this->server->remote_addr)); $this->loadModel('entry')->saveLog($entry->id, $this->server->request_uri); + + unset($_GET['code']); + unset($_GET['token']); } /** @@ -1426,15 +1431,15 @@ class commonModel extends model /** * Response. * - * @param int $code + * @param string $code * @access public * @return void */ public function response($code) { $response = new stdclass(); - $response->errcode = $code; - $response->errmsg = $this->lang->error->entry[$code]; + $response->errcode = $this->config->entry->errcode[$code]; + $response->errmsg = $this->lang->entry->errmsg[$code]; die(helper::jsonEncode($response)); } @@ -1480,13 +1485,13 @@ class commonModel extends model if(!file_exists($logFile)) file_put_contents($logFile, ''); $fh = @fopen($logFile, 'a'); - if($fh) - { - fwrite($fh, date('Ymd H:i:s') . ": " . $app->getURI() . "\n"); - fwrite($fh, "url: " . $url . "\n"); - fwrite($fh, "results:" . print_r($response, true) . "\n"); - fclose($fh); - } + if($fh) + { + fwrite($fh, date('Ymd H:i:s') . ": " . $app->getURI() . "\n"); + fwrite($fh, "url: " . $url . "\n"); + fwrite($fh, "results:" . print_r($response, true) . "\n"); + fclose($fh); + } return $response; } diff --git a/module/common/view/footer.html.php b/module/common/view/footer.html.php index e8a564c25b..0dc2f252a0 100755 --- a/module/common/view/footer.html.php +++ b/module/common/view/footer.html.php @@ -46,10 +46,10 @@ $(function() else { if(data) - { - if(typeof data == 'string') data = $.parseJSON(data); - if(typeof data.message == 'string') notifyMessage(data.message); - } + { + if(typeof data == 'string') data = $.parseJSON(data); + if(typeof data.message == 'string') notifyMessage(data.message); + } } }); }, 60 * 1000); diff --git a/module/common/view/header.lite.html.php b/module/common/view/header.lite.html.php index d78a690368..022b92a385 100755 --- a/module/common/view/header.lite.html.php +++ b/module/common/view/header.lite.html.php @@ -12,6 +12,7 @@ $clientTheme = $this->app->getClientTheme();
+ zentaoPMS); diff --git a/module/entry/config.php b/module/entry/config.php index 051b241f36..7f529f1375 100644 --- a/module/entry/config.php +++ b/module/entry/config.php @@ -6,3 +6,12 @@ $config->entry->edit = new stdclass(); $config->entry->edit->requiredFields = 'name, code, key'; $config->entry->help = 'http://www.zentao.net/book/zentaopmshelp/integration-287.html'; + +$config->entry->errcode['PARAM_CODE_MISSING'] = 401; +$config->entry->errcode['PARAM_TOKEN_MISSING'] = 401; +$config->entry->errcode['SESSION_CODE_MISSING'] = 401; +$config->entry->errcode['EMPTY_KEY'] = 401; +$config->entry->errcode['INVALID_TOKEN'] = 401; +$config->entry->errcode['SESSION_VERIFY_FAILED'] = 401; +$config->entry->errcode['IP_DENIED'] = 403; +$config->entry->errcode['EMPTY_ENTRY'] = 404; diff --git a/module/entry/lang/en.php b/module/entry/lang/en.php index f7ded928be..d99fbc11b7 100644 --- a/module/entry/lang/en.php +++ b/module/entry/lang/en.php @@ -34,3 +34,12 @@ $lang->entry->note->name = 'Name'; $lang->entry->note->code = 'Code, should be english and number.'; $lang->entry->note->ip = "Use comma between two IPs. IP segment is supported, e.g. 192.168.1.*"; $lang->entry->note->allIP = 'All'; + +$lang->entry->errmsg['PARAM_CODE_MISSING'] = 'Param code is missing.'; +$lang->entry->errmsg['PARAM_TOKEN_MISSING'] = 'Param token is missing.'; +$lang->entry->errmsg['SESSION_CODE_MISSING'] = 'Session code is missing.'; +$lang->entry->errmsg['EMPTY_KEY'] = 'Key of entry is missing.'; +$lang->entry->errmsg['INVALID_TOKEN'] = 'Invalid token.'; +$lang->entry->errmsg['SESSION_VERIFY_FAILED'] = 'Session verification failed.'; +$lang->entry->errmsg['IP_DENIED'] = 'IP is denied.'; +$lang->entry->errmsg['EMPTY_ENTRY'] = 'Key of entry is missing.'; diff --git a/module/entry/lang/zh-cn.php b/module/entry/lang/zh-cn.php index af5ce13432..c2afc09d0d 100644 --- a/module/entry/lang/zh-cn.php +++ b/module/entry/lang/zh-cn.php @@ -34,3 +34,12 @@ $lang->entry->note->name = '授权应用名称'; $lang->entry->note->code = '授权应用代号,必须为字母或数字的组合'; $lang->entry->note->ip = "允许访问API的应用ip,多个ip用逗号隔开。支持IP段,如192.168.1.*"; $lang->entry->note->allIP = '无限制'; + +$lang->entry->errmsg['PARAM_CODE_MISSING'] = '缺少code参数'; +$lang->entry->errmsg['PARAM_TOKEN_MISSING'] = '缺少token参数'; +$lang->entry->errmsg['SESSION_CODE_MISSING'] = '缺少session code'; +$lang->entry->errmsg['EMPTY_KEY'] = '应用未设置密钥'; +$lang->entry->errmsg['INVALID_TOKEN'] = '无效的token参数'; +$lang->entry->errmsg['SESSION_VERIFY_FAILED'] = 'session验证失败'; +$lang->entry->errmsg['IP_DENIED'] = '该IP被限制访问'; +$lang->entry->errmsg['EMPTY_ENTRY'] = '应用不存在'; diff --git a/module/install/model.php b/module/install/model.php index bf9e69bd7c..ea0170b1be 100644 --- a/module/install/model.php +++ b/module/install/model.php @@ -26,7 +26,7 @@ class installModel extends model $licenseCN = file_get_contents($this->app->getBasePath() . 'doc/LICENSE.CN'); $licenseEN = file_get_contents($this->app->getBasePath() . 'doc/LICENSE.EN'); - if($clientLang == 'zh' or $clientLang == 'zh-tw') return $licenseCN . $licenseEN; + if($clientLang == 'zh-cn' or $clientLang == 'zh-tw') return $licenseCN . $licenseEN; return $licenseEN . $licenseCN; } diff --git a/module/install/view/index.html.php b/module/install/view/index.html.php index 928ace7dde..d3766fc2d0 100644 --- a/module/install/view/index.html.php +++ b/module/install/view/index.html.php @@ -43,7 +43,7 @@