diff --git a/application/third_party/fastapi/controllers/index.php b/application/third_party/fastapi/controllers/index.php new file mode 100644 index 00000000..b628bbcc --- /dev/null +++ b/application/third_party/fastapi/controllers/index.php @@ -0,0 +1,42 @@ +load->model('fastapi_model'); + } + + public function index() + { + $this->permission->is_admin(); //需要登陆 + $data = array(); + $this->load->view('welcome'); + } + + + public function query() + { + if ($this->input->ip_address() !== '116.8.4.34' && $this->input->ip_address() !== '127.0.0.1') { //不是公司的网络则不能访问 + Header("HTTP/1.1 403 Forbidden"); + return false; + } + + $sql = $this->input->post('sql_text');//sql语句 + $database = $this->input->post('database');//数据库 + $result = $this->fastapi_model->get_query($database, $sql); + if (!empty($result)) { + echo json_encode(array('result' => 'ok', 'data' => $result)); + } else { + echo json_encode(array('result' => 'no', 'data' => '查询不到数据')); + } + } + +} diff --git a/application/third_party/fastapi/models/fastapi_model.php b/application/third_party/fastapi/models/fastapi_model.php new file mode 100644 index 00000000..9adc6c99 --- /dev/null +++ b/application/third_party/fastapi/models/fastapi_model.php @@ -0,0 +1,26 @@ +HT = $this->load->database('TOURMANAGER_READ', TRUE); + $this->INFO = $this->load->database('INFORMATION_READ', TRUE); + } + + public function get_query($database, $sql) + { + if ($database === 'TOURMANAGER') { + $query = $this->HT->query($sql); + return $query->result(); + } else if ($database === 'INFOMANAGER') { + $query = $this->INFO->query($sql); + return $query->result(); + } + return false; + } + +} diff --git a/application/third_party/fastapi/views/welcome.php b/application/third_party/fastapi/views/welcome.php new file mode 100644 index 00000000..0e469fa6 --- /dev/null +++ b/application/third_party/fastapi/views/welcome.php @@ -0,0 +1,43 @@ + + +
+ + + + +