示例#1
0
文件: api.php 项目: wAmpIre/netmon
 private function config()
 {
     $this->_request['api_key'] = isset($this->_request['api_key']) ? $this->_request['api_key'] : 'a';
     $user = new User(false, false, false, false, false, $this->_request['api_key']);
     if ($user->fetch()) {
         if ($user->getPermission() == 120) {
             if ($this->get_request_method() == "GET" && (isset($this->_request['id']) || isset($this->_request['name']))) {
                 $this->_request['id'] = isset($this->_request['id']) ? $this->_request['id'] : false;
                 $this->_request['name'] = isset($this->_request['name']) ? $this->_request['name'] : false;
                 $config_line = new ConfigLine((int) $this->_request['id'], $this->_request['name']);
                 if ($config_line->fetch()) {
                     $domxmldata = $config_line->getDomXMLElement($this->domxml);
                     $this->response($this->finishxml($domxmldata), 200);
                 } else {
                     $this->error_code = 1;
                     $this->error_message = "Config not found";
                     $this->response($this->finishxml(), 404);
                 }
             }
             die;
         } else {
             $this->error_code = 2;
             $this->error_message = "Your API-Key has not enough permission.";
         }
     } else {
         $this->error_code = 2;
         $this->error_message = "The api_key is not valid.";
     }
     $this->authentication = 0;
     $this->response($this->finishxml(), 401);
 }