|
|
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
|
|
class Welcome extends CI_Controller
|
|
|
{
|
|
|
|
|
|
/**
|
|
|
* Index Page for this controller.
|
|
|
*
|
|
|
* Maps to the following URL
|
|
|
* http://example.com/index.php/welcome
|
|
|
* - or -
|
|
|
* http://example.com/index.php/welcome/index
|
|
|
* - or -
|
|
|
* Since this controller is set as the default controller in
|
|
|
* config/routes.php, it's displayed at http://example.com/
|
|
|
*
|
|
|
* So any other public methods not prefixed with an underscore will
|
|
|
* map to /index.php/welcome/<method_name>
|
|
|
* @see http://codeigniter.com/user_guide/general/urls.html
|
|
|
*/
|
|
|
public function index()
|
|
|
{
|
|
|
$this->load->view('welcome_message');
|
|
|
}
|
|
|
|
|
|
public function dashboard()
|
|
|
{
|
|
|
$data = array();
|
|
|
//$data['boards'][] = $this->load->view('echarts/test', $data, true);
|
|
|
|
|
|
$data['boards'][] = $this->load->view('echarts/potential_customers', $data, true);
|
|
|
$data['boards'][] = $this->load->view('echarts/regular_customers', $data, true);
|
|
|
$data['boards'][] = $this->load->view('echarts/inchina_customers', $data, true);
|
|
|
$data['boards'][] = $this->load->view('echarts/mobile_deal', $data, true);
|
|
|
$this->load->view('echarts/dashboard', $data);
|
|
|
}
|
|
|
|
|
|
public function show_me_the_data()
|
|
|
{
|
|
|
//转发到后端的HT2.0服务器,解决js跨域问题和隐藏后端服务器
|
|
|
$url = $this->input->post('url');
|
|
|
echo $this->GET_HTTP('https://p9axztuwd7x8a7.mycht.cn' . $url);
|
|
|
}
|
|
|
|
|
|
function GET_HTTP($url, $data = '', $method = 'GET')
|
|
|
{
|
|
|
$curl = curl_init(); // 启动一个CURL会话
|
|
|
curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
|
|
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
|
|
|
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
|
|
|
if (isset($_SERVER['HTTP_USER_AGENT'])) {
|
|
|
$HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
|
|
|
} else {
|
|
|
$HTTP_USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36';
|
|
|
}
|
|
|
curl_setopt($curl, CURLOPT_USERAGENT, $HTTP_USER_AGENT); // 模拟用户使用的浏览器
|
|
|
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转
|
|
|
curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer
|
|
|
if ($method == 'POST' && !empty($data)) {
|
|
|
curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
|
|
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
|
|
|
}
|
|
|
curl_setopt($curl, CURLOPT_TIMEOUT, 45); // 设置超时限制防止死循环
|
|
|
curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
|
|
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
|
|
|
$tmpInfo = curl_exec($curl); // 执行操作
|
|
|
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
|
|
if ($httpCode >= 400) {//页面状态,如果大于400说明页面打不开
|
|
|
log_message('error', " curl {$httpCode} {$url} ");
|
|
|
return false;
|
|
|
}
|
|
|
$errno = curl_errno($curl);
|
|
|
if ($errno !== 0) {
|
|
|
return false;
|
|
|
$error_message = $errno . ' ' . curl_error($curl); //记录错误日志
|
|
|
log_message('error', "train/get_http curl {$error_message}");
|
|
|
}
|
|
|
curl_close($curl); //关闭CURL会话
|
|
|
return $tmpInfo; //返回数据
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
/* End of file welcome.php */
|
|
|
/* Location: ./application/controllers/welcome.php */ |