|
|
@ -21,7 +21,7 @@ class infofix extends CI_Controller
|
|
|
|
// json参数
|
|
|
|
// json参数
|
|
|
|
$site = $this->input->get_post('site');
|
|
|
|
$site = $this->input->get_post('site');
|
|
|
|
$keys = $this->input->get_post('keys');
|
|
|
|
$keys = $this->input->get_post('keys');
|
|
|
|
$keyArr = explode(',', $keys);
|
|
|
|
$key_arr = explode(',', $keys);
|
|
|
|
|
|
|
|
|
|
|
|
// 容错
|
|
|
|
// 容错
|
|
|
|
if (empty($site) || empty($keys) || strpos($keys, '/') === false) {
|
|
|
|
if (empty($site) || empty($keys) || strpos($keys, '/') === false) {
|
|
|
@ -30,16 +30,20 @@ class infofix extends CI_Controller
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 关键字信息
|
|
|
|
// 关键字信息
|
|
|
|
$rs = $this->Information_model->list_by_keywords($site, $keyArr);
|
|
|
|
$rs = $this->Information_model->list_by_keywords($site, $key_arr);
|
|
|
|
|
|
|
|
|
|
|
|
// 调整数据
|
|
|
|
// 调整数据
|
|
|
|
foreach ($rs as $info) {
|
|
|
|
foreach ($rs as $info) {
|
|
|
|
$keycount = array();
|
|
|
|
$key_with_content = array();
|
|
|
|
foreach ($keyArr as $key) {
|
|
|
|
$key_with_json = array();
|
|
|
|
|
|
|
|
foreach ($key_arr as $key) {
|
|
|
|
// $info->ic_content = utf8_encode($info->ic_content);
|
|
|
|
// $info->ic_content = utf8_encode($info->ic_content);
|
|
|
|
// $info->ic_url = utf8_encode($info->ic_url);
|
|
|
|
// $info->ic_url = utf8_encode($info->ic_url);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 链接
|
|
|
|
$sub_url = $info->ic_url == $key ? $info->ic_url : '';
|
|
|
|
$sub_url = $info->ic_url == $key ? $info->ic_url : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 信息内容
|
|
|
|
$pos_content = 0;
|
|
|
|
$pos_content = 0;
|
|
|
|
$pos_content = mb_stripos($info->ic_content, $key);
|
|
|
|
$pos_content = mb_stripos($info->ic_content, $key);
|
|
|
|
$sub_content = array();
|
|
|
|
$sub_content = array();
|
|
|
@ -48,11 +52,46 @@ class infofix extends CI_Controller
|
|
|
|
$pos_content = mb_stripos($info->ic_content, $key, $pos_content + mb_strlen($key));
|
|
|
|
$pos_content = mb_stripos($info->ic_content, $key, $pos_content + mb_strlen($key));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// amp_json
|
|
|
|
|
|
|
|
$sub_content2 = array();
|
|
|
|
|
|
|
|
if ($info->amp_json) {
|
|
|
|
|
|
|
|
$pos_content2 = 0;
|
|
|
|
|
|
|
|
$pos_content2 = mb_stripos($info->amp_json, $key);
|
|
|
|
|
|
|
|
while ($pos_content2) {
|
|
|
|
|
|
|
|
array_push($sub_content2, '[...' . mb_substr($info->amp_json, $pos_content2 - 20, mb_strlen($key) + 20 * 2) . '...]');
|
|
|
|
|
|
|
|
$pos_content2 = mb_stripos($info->amp_json, $key, $pos_content2 + mb_strlen($key));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// amp_body
|
|
|
|
|
|
|
|
$sub_content3 = array();
|
|
|
|
|
|
|
|
if ($info->amp_body) {
|
|
|
|
|
|
|
|
$pos_content3 = 0;
|
|
|
|
|
|
|
|
$pos_content3 = mb_stripos($info->amp_body, $key);
|
|
|
|
|
|
|
|
while ($pos_content3) {
|
|
|
|
|
|
|
|
array_push($sub_content3, '[...' . mb_substr($info->amp_body, $pos_content3 - 20, mb_strlen($key) + 20 * 2) . '...]');
|
|
|
|
|
|
|
|
$pos_content3 = mb_stripos($info->amp_body, $key, $pos_content3 + mb_strlen($key));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($sub_url != '' || count($sub_content) != 0) {
|
|
|
|
if ($sub_url != '' || count($sub_content) != 0) {
|
|
|
|
array_push($keycount, array('key' => $key, 'sub_url' => $sub_url, 'sub_content' => $sub_content));
|
|
|
|
array_push(
|
|
|
|
|
|
|
|
$key_with_content,
|
|
|
|
|
|
|
|
array(
|
|
|
|
|
|
|
|
'key' => $key,
|
|
|
|
|
|
|
|
'sub_url' => $sub_url,
|
|
|
|
|
|
|
|
'sub_content' => $sub_content,
|
|
|
|
|
|
|
|
'sub_json' => $sub_content2,
|
|
|
|
|
|
|
|
'sub_body' => $sub_content3
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$info->ic_content = $keycount;
|
|
|
|
|
|
|
|
|
|
|
|
$info->ic_content = $key_with_content;
|
|
|
|
|
|
|
|
unset($info->amp_json);
|
|
|
|
|
|
|
|
unset($info->amp_body);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
echo json_encode($rs);
|
|
|
|
echo json_encode($rs);
|
|
|
|