|
|
@ -13,33 +13,39 @@ class infofix extends CI_Controller
|
|
|
|
$this->site_code = $this->input->get('site_code') ? $this->input->get('site_code') : $this->config->item('site_code');
|
|
|
|
$this->site_code = $this->input->get('site_code') ? $this->input->get('site_code') : $this->config->item('site_code');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function list_info_by_keys($site = '', $keys = [])
|
|
|
|
function list_info_by_keys()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
set_time_limit(300);
|
|
|
|
// 防止超时
|
|
|
|
$site = 'cht';
|
|
|
|
header('Access-Control-Allow-Origin: *');
|
|
|
|
$keys = ['/beijing/', '/yangshuo/'];
|
|
|
|
set_time_limit(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// json参数
|
|
|
|
|
|
|
|
$site = $this->input->get_post('site');
|
|
|
|
|
|
|
|
$keys = $this->input->get_post('keys');
|
|
|
|
|
|
|
|
$keyArr = json_decode($keys, true);
|
|
|
|
|
|
|
|
|
|
|
|
// 容错
|
|
|
|
// 容错
|
|
|
|
if (empty($site) || empty($keys)) {
|
|
|
|
if (empty($site) || empty($keys) || strpos($keys, '/') === false) {
|
|
|
|
echo json_encode(
|
|
|
|
echo json_encode(array());
|
|
|
|
array(
|
|
|
|
|
|
|
|
'data' => []
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 关键字信息
|
|
|
|
$rs = $this->Information_model->list_by_keywords($site, $keys);
|
|
|
|
$rs = $this->Information_model->list_by_keywords($site, $keys);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 调整数据
|
|
|
|
foreach ($rs as $info) {
|
|
|
|
foreach ($rs as $info) {
|
|
|
|
$keycount = array();
|
|
|
|
$keycount = array();
|
|
|
|
foreach ($keys as $key) {
|
|
|
|
foreach ($keyArr as $key) {
|
|
|
|
$pos_url = stripos($info->ic_url, $key);
|
|
|
|
// $info->ic_content = utf8_encode($info->ic_content);
|
|
|
|
$sub_url = $info->ic_url == $key ? $info->ic_url : '';
|
|
|
|
// $info->ic_url = utf8_encode($info->ic_url);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sub_url = $info->ic_url == $key ? $info->ic_url : '';
|
|
|
|
$pos_content = 0;
|
|
|
|
$pos_content = 0;
|
|
|
|
$pos_content = stripos($info->ic_content, $key);
|
|
|
|
$pos_content = stripos($info->ic_content, $key);
|
|
|
|
$sub_content = array();
|
|
|
|
$sub_content = array();
|
|
|
|
while ($pos_content) {
|
|
|
|
while ($pos_content) {
|
|
|
|
array_push($sub_content, '[...' . substr($info->ic_content, $pos_content - 20, strlen($key) + 20 * 2) . '...]');
|
|
|
|
array_push($sub_content, '[...' . mb_substr($info->ic_content, $pos_content - 20, strlen($key) + 20 * 2) . '...]');
|
|
|
|
$pos_content = stripos($info->ic_content, $key, $pos_content + strlen($key));
|
|
|
|
$pos_content = stripos($info->ic_content, $key, $pos_content + strlen($key));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -51,6 +57,7 @@ class infofix extends CI_Controller
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
echo json_encode($rs);
|
|
|
|
echo json_encode($rs);
|
|
|
|
|
|
|
|
echo json_last_error_msg();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|