You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
information-system/application/third_party/fastapi/controllers/index.php

43 lines
1.0 KiB
PHP

<?php
if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}
class Index extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->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' => '查询不到数据'));
}
}
}